1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,22951,850390,e=>{"use strict";let t,n,r,i;var a=e.i(843476),s=e.i(271645),l=e.i(174080),o=e.i(618566),c=e.i(542356),d=e.i(522016),u=e.i(643531),h=e.i(531278),p=e.i(686311),m=e.i(385663),g=e.i(541071),f=e.i(555436),b=e.i(662031),x=e.i(497960),y=e.i(870273),v=e.i(158524),w=e.i(37727),_=e.i(406120),k=e.i(440160),N=e.i(837647),E=e.i(147845),C=e.i(227516),S=e.i(694351),j=e.i(486631),A=e.i(875800),D=e.i(846696),M=e.i(494499),T=e.i(827121),O=e.i(428762),I=e.i(256378),L=e.i(555841),R=e.i(97643),P=e.i(103869),F=e.i(78696),B=e.i(844054);let U=B.ListItem.extend({content:"(paragraph | pageLink) block*"});e.i(265055);let $=["not_started","in_progress","complete"],z="http://www.w3.org/2000/svg",q=B.TaskItem.extend({content:"(paragraph | pageLink) block*",addAttributes:()=>({status:{default:"not_started",parseHTML:e=>{let t=e.getAttribute("data-status");if("in_progress"===t||"complete"===t||"not_started"===t)return t;let n=e.getAttribute("data-checked");return"true"===n||""===n?"complete":"not_started"},renderHTML:e=>({"data-status":e.status})}}),renderHTML({node:e,HTMLAttributes:t}){return["li",{...t,"data-type":this.name,"data-status":e.attrs.status},["div",{class:"page-task-item-content"},0]]},addNodeView(){return({node:e,getPos:t,editor:n})=>{let r=document.createElement("li");r.setAttribute("data-type",this.name);let i=document.createElement("button");i.type="button",i.contentEditable="false",i.className="page-task-item-circle";let a=document.createElement("div");a.className="page-task-item-content";let s=e=>{let t,n;for(r.setAttribute("data-status",e),i.setAttribute("data-status",e),i.setAttribute("aria-label","not_started"===e?"Mark in progress":"in_progress"===e?"Mark complete":"Mark not started");i.firstChild;)i.removeChild(i.firstChild);"complete"===e&&i.appendChild(((t=document.createElementNS(z,"svg")).setAttribute("viewBox","0 0 24 24"),t.setAttribute("width","12"),t.setAttribute("height","12"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","3.5"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),(n=document.createElementNS(z,"polyline")).setAttribute("points","20 6 9 17 4 12"),t.appendChild(n),t))};return s(e.attrs.status),i.addEventListener("mousedown",e=>e.preventDefault()),i.addEventListener("click",()=>{if(!n.isEditable||"function"!=typeof t)return;let e=t();if("number"!=typeof e)return;let r=n.state.doc.nodeAt(e);if(!r)return;let i=r.attrs.status,a=$.indexOf(i),s=$[(-1===a?0:a+1)%$.length],l=n.state.tr.setNodeMarkup(e,void 0,{...r.attrs,status:s});n.view.dispatch(l)}),r.appendChild(i),r.appendChild(a),{dom:r,contentDOM:a,update:e=>e.type===this.type&&(s(e.attrs.status),!0)}}}});var H=e.i(103819),K=e.i(634236),V=e.i(827427),G=e.i(10552);let W=()=>new Map,Z=e=>{let t=W();return e.forEach((e,n)=>{t.set(n,e)}),t},J=(e,t,n)=>{let r=e.get(t);return void 0===r&&e.set(t,r=n()),r},X=()=>new Set,Q=e=>e[e.length-1],Y=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},ee=Array.from,et=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},en=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},er=Array.isArray;class ei{constructor(){this._observers=W()}on(e,t){return J(this._observers,e,X).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return ee((this._observers.get(e)||W()).values()).forEach(e=>e(...t))}destroy(){this._observers=W()}}class ea{constructor(){this._observers=W()}on(e,t){J(this._observers,e,X).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return ee((this._observers.get(e)||W()).values()).forEach(e=>e(...t))}destroy(){this._observers=W()}}let es=Math.floor,el=Math.abs,eo=(e,t)=>e<t?e:t,ec=(e,t)=>e>t?e:t,ed=e=>0!==e?e<0:1/e<0,eu=Number.MAX_SAFE_INTEGER,eh=Number.MIN_SAFE_INTEGER,ep=Number.isInteger||(e=>"number"==typeof e&&isFinite(e)&&es(e)===e),em=String.fromCharCode;em(65535);let eg=/^\s*/g,ef=/([A-Z])/g,eb=(e,t)=>e.replace(ef,e=>`${t}${e.toLowerCase()}`).replace(eg,""),ex="u">typeof TextEncoder?new TextEncoder:null,ey=ex?e=>ex.encode(e):e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},ev="u"<typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ev&&1===ev.decode(new Uint8Array).length&&(ev=null);let ew=(e,t)=>((e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n})(t,()=>e).join("");class e_{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}let ek=()=>new e_,eN=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},eE=e=>{let t=new Uint8Array(eN(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},eC=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*n),e.cpos=0),e.cbuf[e.cpos++]=t},eS=(e,t)=>{for(;t>127;)eC(e,128|127&t),t=es(t/128);eC(e,127&t)},ej=(e,t)=>{let n=ed(t);for(n&&(t=-t),eC(e,128*(t>63)|64*!!n|63&t),t=es(t/64);t>0;)eC(e,128*(t>127)|127&t),t=es(t/128)},eA=new Uint8Array(3e4),eD=eA.length/3,eM=ex&&ex.encodeInto?(e,t)=>{if(t.length<eD){let n=ex.encodeInto(t,eA).written||0;eS(e,n);for(let t=0;t<n;t++)eC(e,eA[t])}else eO(e,ey(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;eS(e,r);for(let t=0;t<r;t++)eC(e,n.codePointAt(t))},eT=(e,t)=>
1{let n=e.cbuf.length,r=e.cpos,i=eo(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ec(2*n,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},eO=(e,t)=>{eS(e,t.byteLength),eT(e,t)},eI=(e,t)=>{let n;(n=e.cbuf.length)-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(2*ec(n,t)),e.cpos=0);let r=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,r},eL=new DataView(new ArrayBuffer(4)),eR=(e,t)=>{switch(typeof t){case"string":eC(e,119),eM(e,t);break;case"number":if(ep(t)&&0x7fffffff>=el(t))eC(e,125),ej(e,t);else if(eL.setFloat32(0,t),eL.getFloat32(0)===t)eC(e,124),eI(e,4).setFloat32(0,t,!1);else eC(e,123),eI(e,8).setFloat64(0,t,!1);break;case"bigint":eC(e,122),eI(e,8).setBigInt64(0,t,!1);break;case"object":if(null===t)eC(e,126);else if(er(t)){eC(e,117),eS(e,t.length);for(let n=0;n<t.length;n++)eR(e,t[n])}else if(t instanceof Uint8Array)eC(e,116),eO(e,t);else{eC(e,118);let n=Object.keys(t);eS(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];eM(e,i),eR(e,t[i])}}break;case"boolean":eC(e,t?120:121);break;default:eC(e,127)}};class eP extends e_{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&eS(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}let eF=e=>{e.count>0&&(ej(e.encoder,1===e.count?e.s:-e.s),e.count>1&&eS(e.encoder,e.count-2))};class eB{constructor(){this.encoder=new e_,this.s=0,this.count=0}write(e){this.s===e?this.count++:(eF(this),this.count=1,this.s=e)}toUint8Array(){return eF(this),eE(this.encoder)}}let eU=e=>{if(e.count>0){let t=2*e.diff+ +(1!==e.count);ej(e.encoder,t),e.count>1&&eS(e.encoder,e.count-2)}};class e${constructor(){this.encoder=new e_,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(eU(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return eU(this),eE(this.encoder)}}class ez{constructor(){this.sarr=[],this.s="",this.lensE=new eB}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){let e=new e_;return this.sarr.push(this.s),this.s="",eM(e,this.sarr.join("")),eT(e,this.lensE.toUint8Array()),eE(e)}}let eq=()=>{throw Error("Method unimplemented")},eH=()=>{throw Error("Unexpected case")},eK=Error("Unexpected end of array"),eV=Error("Integer out of Range");class eG{constructor(e){this.arr=e,this.pos=0}}let eW=e=>new eG(e),eZ=e=>{var t;let n;return t=eX(e),n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t),e.pos+=t,n},eJ=e=>e.arr[e.pos++],eX=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(127&r)*n,n*=128,r<128)return t;if(t>eu)throw eV}throw eK},eQ=e=>{let t=e.arr[e.pos++],n=63&t,r=64,i=(64&t)>0?-1:1;if((128&t)==0)return i*n;let a=e.arr.length;for(;e.pos<a;){if(n+=(127&(t=e.arr[e.pos++]))*r,r*=128,t<128)return i*n;if(n>eu)throw eV}throw eK},eY=ev?e=>ev.decode(eZ(e)):e=>{let t=eX(e);if(0===t)return"";{let n=String.fromCodePoint(eJ(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(eJ(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},e0=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},e1=[e=>void 0,e=>null,eQ,e=>e0(e,4).getFloat32(0,!1),e=>e0(e,8).getFloat64(0,!1),e=>e0(e,8).getBigInt64(0,!1),e=>!1,e=>!0,eY,e=>{let t=eX(e),n={};for(let r=0;r<t;r++)n[eY(e)]=e2(e);return n},e=>{let t=eX(e),n=[];for(let r=0;r<t;r++)n.push(e2(e));return n},eZ],e2=e=>e1[127-eJ(e)](e);class e3 extends eG{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){0===this.count&&(this.s=this.reader(this),this.pos!==this.arr.length?this.count=eX(this)+1:this.count=-1);return this.count--,this.s}}class e5 extends eG{constructor(e){super(e),this.s=0,this.count=0}read(){if(0===this.count){this.s=eQ(this);let e=ed(this.s);this.count=1,e&&(this.s=-this.s,this.count=eX(this)+2)}return this.count--,this.s}}class e4 extends eG{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){let e=eQ(this);this.diff=es(e/2),this.count=1,1&e&&(this.count=eX(this)+2)}return this.s+=this.diff,this.count--,this.s}}class e8{constructor(e){this.decoder=new e5(e),this.str=eY(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}crypto.subtle;let e6=crypto.getRandomValues.bind(crypto),e9=Math.random,e7=()=>e6(new Uint32Array(1))[0],te=Date.now,tt=e=>new Promise(e);
1Promise.all.bind(Promise);var tn=e.i(467034),tr=e.i(247167);let ti=e=>void 0===e?null:e,ta=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}};try{"u">typeof localStorage&&localStorage&&(ta=localStorage)}catch(e){}let ts=ta,tl=Symbol("Equality"),to=(e,t)=>e===t||!!e?.[tl]?.(t),tc=Object.assign,td=Object.keys,tu=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},th=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),tp=Object.freeze,tm=e=>{for(let t in e){let n=e[t];("object"==typeof n||"function"==typeof n)&&tm(e[t])}return tp(e)},tg=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&tg(e,t,n+1)}},tf=e=>e,tb=(e,t)=>{if(e===t)return!0;if(null==e||null==t||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(null!=e[tl])return e[tl](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!tb(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(td(e).length!==td(t).length)return!1;for(let n in e)if(!th(e,n)||!tb(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!tb(e[n],t[n]))return!1;break;default:return!1}return!0},tx=void 0!==tr.default&&tr.default.release&&/node|io\.js/.test(tr.default.release.name)&&"[object process]"===Object.prototype.toString.call(void 0!==tr.default?tr.default:0),ty="u">typeof window&&"u">typeof document&&!tx;"u">typeof navigator&&/Mac/.test(navigator.platform);let tv=[],tw=e=>(()=>{if(void 0===t)if(tx){t=W();let e=tr.default.argv,n=null;for(let r=0;r<e.length;r++){let i=e[r];"-"===i[0]?(null!==n&&t.set(n,""),n=i):null!==n?(t.set(n,i),n=null):tv.push(i)}null!==n&&t.set(n,"")}else"object"==typeof location?(t=W(),(location.search||"?").slice(1).split("&").forEach(e=>{if(0!==e.length){let[n,r]=e.split("=");t.set(`--${eb(n,"-")}`,r),t.set(`-${eb(n,"-")}`,r)}})):t=W();return t})().has(e),t_=e=>tx?ti(tr.default.env[e.toUpperCase().replaceAll("-","_")]):ti(ts.getItem(e)),tk=e=>tw("--"+e)||null!==t_(e),tN=tk("production"),tE=tx&&["true","1","2"].includes(tr.default.env.FORCE_COLOR)||!tw("--no-colors")&&!tk("no-color")&&(!tx||tr.default.stdout.isTTY)&&(!tx||tw("--color")||null!==t_("COLORTERM")||(t_("TERM")||"").includes("color")),tC=ty?e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=em(e[n]);return btoa(t)}:e=>tn.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");class tS{constructor(e,t){this.left=e,this.right=t}}let tj=(e,t)=>new tS(e,t),tA=e=>e.next()>=.5,tD=(e,t,n)=>es(e.next()*(n+1-t)+t),tM=(e,t,n)=>es(e.next()*(n+1-t)+t),tT=e=>em(tM(e,97,122)),tO=(e,t)=>t[tM(e,0,t.length-1)],tI=Symbol("0schema");class tL{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(ew(" ",(this._rerrs.length-t)*2)+`${null!=n.path?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join("\n")}}let tR=(e,t)=>e===t||null!=e&&null!=t&&e.constructor===t.constructor&&(e[tl]?to(e,t):er(e)?et(e,e=>en(t,t=>tR(e,t))):"object"==typeof e&&tu(e,(e,n)=>tR(e,t[n])));class tP{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),tR(t,n)}equals(e){return this.constructor===e.constructor&&tb(this.shape,e.shape)}[tI](){return!0}[tl](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){eq()}get nullable(){return nr(this,nx)}get optional(){return new tW(this)}cast(e){return n_(e,this),e}expect(e){return n_(e,this),e}}class tF extends tP{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e?.constructor===this.shape&&(null==this._c||this._c(e));return n||t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}}let tB=(e,t=null)=>new tF(e,t);tB(tF);class tU extends tP{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return n||t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),n}}
1let t$=e=>new tU(e);tB(tU);class tz extends tP{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return n||t?.extend(null,this.shape.join(" | "),e.toString()),n}}let tq=(...e)=>new tz(e),tH=tB(tz),tK=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),tV=e=>np.check(e)?[tK(e)]:tH.check(e)?e.shape.map(e=>e+""):nh.check(e)?["[+-]?\\d+.?\\d*"]:nm.check(e)?[".*"]:ni.check(e)?e.shape.map(tV).flat(1):void eH();tB(class extends tP{constructor(e){super(),this.shape=e,this._r=RegExp("^"+e.map(tV).map(e=>`(${e.join("|")})`).join("")+"$")}check(e,t){let n=null!=this._r.exec(e);return n||t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),n}});let tG=Symbol("optional");class tW extends tP{constructor(e){super(),this.shape=e}check(e,t){let n=void 0===e||this.shape.check(e);return n||t?.extend(null,"undefined (optional)","()"),n}get[tG](){return!0}}let tZ=tB(tW);class tJ extends tP{check(e,t){return t?.extend(null,"never",typeof e),!1}}new tJ,tB(tJ);class tX extends tP{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new tX(this.shape,!0)}check(e,t){return null==e?(t?.extend(null,"object","null"),!1):tu(this.shape,(n,r)=>{let i=this._isPartial&&!th(e,r)||n.check(e[r],t);return i||t?.extend(r.toString(),n.toString(),typeof e[r],"Object property does not match"),i})}}let tQ=tB(tX),tY=t$(e=>null!=e&&(e.constructor===Object||null==e.constructor));class t0 extends tP{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return null!=e&&tu(e,(n,r)=>{let i=this.shape.keys.check(r,t);return i||t?.extend(r+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(n,t)})}}let t1=(e,t)=>new t0(e,t),t2=tB(t0);class t3 extends tP{constructor(e){super(),this.shape=e}check(e,t){return null!=e&&tu(this.shape,(n,r)=>{let i=n.check(e[r],t);return i||t?.extend(r.toString(),"Tuple",typeof n),i})}}tB(t3);class t5 extends tP{constructor(e){super(),this.shape=1===e.length?e[0]:new nn(e)}check(e,t){let n=er(e)&&et(e,e=>this.shape.check(e));return n||t?.extend(null,"Array",""),n}}let t4=(...e)=>new t5(e),t8=tB(t5),t6=t$(e=>er(e));class t9 extends tP{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(null==this._c||this._c(e));return n||t?.extend(null,this.shape.name,e?.constructor.name),n}}tB(t9);let t7=((e,t=null)=>new t9(e,t))(tP),ne=tB(class extends tP{constructor(e){super(),this.len=e.length-1,this.args=((...e)=>new t3(e))(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return n||t?.extend(null,"function",typeof e),n}}),nt=t$(e=>"function"==typeof e);tB(class extends tP{constructor(e){super(),this.shape=e}check(e,t){let n=et(this.shape,n=>n.check(e,t));return n||t?.extend(null,"Intersectinon",typeof e),n}},e=>e.shape.length>0);class nn extends tP{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=en(this.shape,n=>n.check(e,t));return t?.extend(null,"Union",typeof e),n}}let nr=(...e)=>e.findIndex(e=>ni.check(e))>=0?nr(...e.map(e=>nw(e)).map(e=>ni.check(e)?e.shape:[e]).flat(1)):1===e.length?e[0]:new nn(e),ni=tB(nn),na=()=>!0,ns=t$(na),nl=tB(tU,e=>e.shape===na),no=t$(e=>"bigint"==typeof e),nc=t$(e=>e===no),nd=t$(e=>"symbol"==typeof e);t$(e=>e===nd);let nu=t$(e=>"number"==typeof e),nh=t$(e=>e===nu),np=t$(e=>"string"==typeof e),nm=t$(e=>e===np),ng=t$(e=>"boolean"==typeof e),nf=t$(e=>e===ng),nb=tq(void 0);tB(tz,e=>1===e.shape.length&&void 0===e.shape[0]),tq(void 0);let nx=tq(null),ny=tB(tz,e=>1===e.shape.length&&null===e.shape[0]);tB(Uint8Array),tB(tF,e=>e.shape===Uint8Array);let nv=nr(nu,np,nx,nb,no,ng,nd);n=t4(ns),r=t1(np,ns),i=nr(nu,np,nx,ng,n,r),n.shape=i,r.shape.values=i;let nw=e=>{if(t7.check(e))return e;if(tY.check(e)){let t={};for(let n in e)t[n]=nw(e[n]);return new tX(t)}if(t6.check(e))return nr(...e.map(nw));if(nv.check(e))return tq(e);if(nt.check(e))return tB(e);eH()},n_=tN?()=>{}:(e,t)=>{let n=new tL;if(!t.check(e,n))throw Error(`Expected value to be of type ${t.constructor.name}. 2${n.toString()}`)},nk=new class e{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:nw(e),h:t}),this}else(e){return this.if(ns,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Error("Unhandled pattern")}}}(ns).if(nh,(e,t)=>tD(t,eh,eu)).if(nm,(e,t)=>((e,t=0,n=20)=>{let r=tM(e,t,n),i="";for(let t=0;t<r;t++)i+=tT(e);return i})(t)).if(nf,(e,t)=>tA(t)).if(nc,(e,t)=>BigInt(tD(t,eh,eu))).if(ni,(e,t)=>nN(t,tO(t,e.shape))).if(tQ,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(tZ.check(i)){if(tA(t))continue;i=i.shape}n[r]=nk(i,t)}return n}).if(t8,(e,t)=>{let n=[],r=tM(t,0,42);for(let i=0;i<r;i++)n.push(nN(t,e.shape));return n}).if(tH,(e,t)=>tO(t,e.shape)).if(ny,(e,t)=>null).if(ne,(e,t)=>{let n=nN(t,e.res);return()=>n}).if(nl,(e,t)=>nN(t,tO(t,[nu,np,nx,nb,no,ng,t4(nu),t1(nr("a","b","c"),nu)]))).if(t2,(e,t)=>{let n={},r=tD(t,0,3);for(let i=0;i<r;i++){let r=nN(t,e.shape.keys),i=nN(t,e.shape.values);n[r]=i}return n}).done(),nN=(e,t)=>nk(nw(t),e),nE="u">typeof document?document:{};t$(e=>e.nodeType===nD),"u">typeof DOMParser&&new DOMParser,t$(e=>e.nodeType===nS),t$(e=>e.nodeType===nj);let nC=e=>((e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n})(e,(e,t)=>`${t}:${e};`).join(""),nS=nE.ELEMENT_NODE,nj=nE.TEXT_NODE;nE.CDATA_SECTION_NODE,nE.COMMENT_NODE;let nA=nE.DOCUMENT_NODE;nE.DOCUMENT_TYPE_NODE;
2let nD=nE.DOCUMENT_FRAGMENT_NODE;t$(e=>e.nodeType===nA);let nM=e=>class{constructor(e){this._=e}destroy(){e(this._)}},nT=nM(clearTimeout),nO=(e,t)=>new nT(setTimeout(t,e));nM(clearInterval),nM(e=>"u">typeof requestAnimationFrame&&cancelAnimationFrame(e)),nM(e=>"u">typeof cancelIdleCallback&&cancelIdleCallback(e));let nI=Symbol,nL=nI(),nR=nI(),nP=nI(),nF=nI(),nB=nI(),nU=nI(),n$=nI(),nz=nI(),nq=nI();te();let nH={[nL]:tj("font-weight","bold"),[nR]:tj("font-weight","normal"),[nP]:tj("color","blue"),[nB]:tj("color","green"),[nF]:tj("color","grey"),[nU]:tj("color","red"),[n$]:tj("color","purple"),[nz]:tj("color","orange"),[nq]:tj("color","black")},nK=tE?e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=W(),i=[],a=0;for(;a<e.length;a++){let i=e[a],s=nH[i];if(void 0!==s)r.set(s.left,s.right);else{if(void 0===i)break;if(i.constructor===String||i.constructor===Number){let e=nC(r);a>0||e.length>0?(t.push("%c"+i),n.push(e)):t.push(i)}else break}}for(a>0&&(i=n).unshift(t.join(""));a<e.length;a++){let t=e[a];t instanceof Symbol||i.push(t)}return i}:e=>{1===e.length&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let n=e[r];if(void 0===n)break;if(n.constructor===String||n.constructor===Number)t.push(n);else if(n.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let t=e[r];t instanceof Symbol||n.push(t)}return n},nV=(...e)=>{console.warn(...nK(e)),e.unshift(nz),nG.forEach(t=>t.print(e))},nG=X(),nW=e=>({[Symbol.iterator](){return this},next:e}),nZ=(e,t)=>nW(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});
2class nJ{constructor(e,t){this.clock=e,this.len=t}}class nX{constructor(){this.clients=new Map}}let nQ=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(null!=i){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,s=t[r];r<t.length&&s.clock<a;s=t[++r])rz(e,i,s.clock,s.len,n)}}),nY=(e,t)=>{let n=e.clients.get(t.client);return void 0!==n&&null!==((e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=es((n+r)/2),a=e[i],s=a.clock;if(s<=t){if(t<s+a.len)return i;n=i+1}else r=i-1}return null})(n,t.clock)},n0=e=>{e.clients.forEach(e=>{let t,n;for(e.sort((e,t)=>e.clock-t.clock),t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new nJ(r.clock,ec(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},n1=e=>{let t=new nX;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)Y(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return n0(t),t},n2=(e,t,n,r)=>{J(e.clients,t,()=>[]).push(new nJ(n,r))},n3=()=>new nX,n5=e=>{let t=n3();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new nJ(i,a))}}r.length>0&&t.clients.set(n,r)}),t},n4=(e,t)=>{eS(e.restEncoder,t.clients.size),ee(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),eS(e.restEncoder,t);let r=n.length;eS(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},n8=e=>{let t=new nX,n=eX(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=eX(e.restDecoder),r=eX(e.restDecoder);if(r>0){let i=J(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new nJ(e.readDsClock(),e.readDsLen()))}}return t},n6=(e,t,n)=>{let r=new nX,i=eX(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=eX(e.restDecoder),a=eX(e.restDecoder),s=n.clients.get(i)||[],l=rL(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<l){l<a&&n2(r,i,l,a-l);let e=rP(s,n),o=s[e];for(!o.deleted&&o.id.clock<n&&(s.splice(e+1,0,ah(t,o,n-o.id.clock)),e++);e<s.length;)if((o=s[e++]).id.clock<a)o.deleted||(a<o.id.clock+o.length&&s.splice(e,0,ah(t,o,a-o.id.clock)),o.delete(t));else break}else n2(r,i,n,a-n)}}if(r.clients.size>0){let e=new rs;return eS(e.restEncoder,0),n4(e,r),e.toUint8Array()}return null};class n9 extends ei{constructor({guid:e="10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(e^e7()&15>>e/4).toString(16)),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:s=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=e7(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new rO,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=s,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=tt(e=>{this.on("load",()=>{this.isLoaded=!0,e(this)})});const l=()=>tt(e=>{let t=n=>{(void 0===n||!0===n)&&(this.off("sync",t),e())};this.on("sync",t)});this.on("sync",e=>{!1===e&&this.isSynced&&(this.whenSynced=l()),this.isSynced=void 0===e||!0===e,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let e=this._item;null===e||this.shouldLoad||rW(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ee(this.subdocs).map(e=>e.guid))}transact(e,t=null){return rW(this,e,t)}get(e,t=id){let n=J(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==id&&r!==t)if(r===id){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;null!==e;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;null!==e;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=""){return this.get(e,ij)}getText(e=""){return this.get(e,iV)}getMap(e=""){return this.get(e,iD)}getXmlElement(e=""){return this.get(e,iZ)}getXmlFragment(e=""){return this.get(e,iW)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}
2destroy(){this.isDestroyed=!0,ee(this.subdocs).forEach(e=>e.destroy());let e=this._item;if(null!==e){this._item=null;let t=e.content;t.doc=new n9({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,rW(e.parent.doc,n=>{let r=t.doc;e.deleted||n.subdocsAdded.add(r),n.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class n7{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return eX(this.restDecoder)}readDsLen(){return eX(this.restDecoder)}}class re extends n7{readLeftID(){return rx(eX(this.restDecoder),eX(this.restDecoder))}readRightID(){return rx(eX(this.restDecoder),eX(this.restDecoder))}readClient(){return eX(this.restDecoder)}readInfo(){return eJ(this.restDecoder)}readString(){return eY(this.restDecoder)}readParentInfo(){return 1===eX(this.restDecoder)}readTypeRef(){return eX(this.restDecoder)}readLen(){return eX(this.restDecoder)}readAny(){return e2(this.restDecoder)}readBuf(){var e=eZ(this.restDecoder);let t=new Uint8Array(e.byteLength);return t.set(e),t}readJSON(){return JSON.parse(eY(this.restDecoder))}readKey(){return eY(this.restDecoder)}}class rt{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=eX(this.restDecoder),this.dsCurrVal}readDsLen(){let e=eX(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class rn extends rt{constructor(e){super(e),this.keys=[],eX(e),this.keyClockDecoder=new e4(eZ(e)),this.clientDecoder=new e5(eZ(e)),this.leftClockDecoder=new e4(eZ(e)),this.rightClockDecoder=new e4(eZ(e)),this.infoDecoder=new e3(eZ(e),eJ),this.stringDecoder=new e8(eZ(e)),this.parentInfoDecoder=new e3(eZ(e),eJ),this.typeRefDecoder=new e5(eZ(e)),this.lenDecoder=new e5(eZ(e))}readLeftID(){return new rf(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new rf(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return e2(this.restDecoder)}readBuf(){return eZ(this.restDecoder)}readJSON(){return e2(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class rr{constructor(){this.restEncoder=ek()}toUint8Array(){return eE(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){eS(this.restEncoder,e)}writeDsLen(e){eS(this.restEncoder,e)}}class ri extends rr{writeLeftID(e){eS(this.restEncoder,e.client),eS(this.restEncoder,e.clock)}writeRightID(e){eS(this.restEncoder,e.client),eS(this.restEncoder,e.clock)}writeClient(e){eS(this.restEncoder,e)}writeInfo(e){eC(this.restEncoder,e)}writeString(e){eM(this.restEncoder,e)}writeParentInfo(e){eS(this.restEncoder,+!!e)}writeTypeRef(e){eS(this.restEncoder,e)}writeLen(e){eS(this.restEncoder,e)}writeAny(e){eR(this.restEncoder,e)}writeBuf(e){eO(this.restEncoder,e)}writeJSON(e){eM(this.restEncoder,JSON.stringify(e))}writeKey(e){eM(this.restEncoder,e)}}class ra{constructor(){this.restEncoder=ek(),this.dsCurrVal=0}toUint8Array(){return eE(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,eS(this.restEncoder,t)}writeDsLen(e){0===e&&eH(),eS(this.restEncoder,e-1),this.dsCurrVal+=e}}class rs extends ra{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new e$,this.clientEncoder=new eB,this.leftClockEncoder=new e$,this.rightClockEncoder=new e$,this.infoEncoder=new eP(eC),this.stringEncoder=new ez,this.parentInfoEncoder=new eP(eC),this.typeRefEncoder=new eB,this.lenEncoder=new eB}toUint8Array(){let e=ek();return eS(e,0),eO(e,this.keyClockEncoder.toUint8Array()),eO(e,this.clientEncoder.toUint8Array()),eO(e,this.leftClockEncoder.toUint8Array()),eO(e,this.rightClockEncoder.toUint8Array()),eO(e,eE(this.infoEncoder)),eO(e,this.stringEncoder.toUint8Array()),eO(e,eE(this.parentInfoEncoder)),eO(e,this.typeRefEncoder.toUint8Array()),eO(e,this.lenEncoder.toUint8Array()),eT(e,eE(this.restEncoder)),eE(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)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){eR(this.restEncoder,e)}writeBuf(e){eO(this.restEncoder,e)}writeJSON(e){eR(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);void 0===t?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}
2let rl=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{rL(t,n)>e&&r.set(n,e)}),rI(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),eS(e.restEncoder,r.size),ee(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{((e,t,n,r)=>{r=ec(r,t[0].id.clock);let i=rP(t,r);eS(e.restEncoder,t.length-i),e.writeClient(n),eS(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)})(e,t.clients.get(n),n,r)})},ro=(e,t,n,r=rn)=>{let i=eW(t);((e,t,n,r=new rn(e))=>rW(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=((e,t,n)=>{let r=[],i=ee(n.keys()).sort((e,t)=>e-t);if(0===i.length)return null;let a=()=>{if(0===i.length)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;){if(i.pop(),!(i.length>0))return null;e=n.get(i[i.length-1])}return e},s=a();if(null===s)return null;let l=new rO,o=new Map,c=(e,t)=>{let n=o.get(e);(null==n||n>t)&&o.set(e,t)},d=s.refs[s.i++],u=new Map,h=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,l.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):l.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(d.constructor!==ax){let i=J(u,d.id.client,()=>rL(t,d.id.client))-d.id.clock;if(i<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{let a=d.getMissing(e,t);if(null!==a){r.push(d);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)c(a,rL(t,a)),h();else{d=e.refs[e.i++];continue}}else(0===i||i<d.length)&&(d.integrate(e,i),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(null!==s&&s.i<s.refs.length)d=s.refs[s.i++];else{if(null===(s=a()))break;d=s.refs[s.i++]}}if(l.clients.size>0){let e=new rs;return rl(e,l,new Map),eS(e.restEncoder,0),{missing:o,update:e.toUint8Array()}}return null})(e,i,((e,t)=>{let n=W(),r=eX(e.restDecoder);for(let i=0;i<r;i++){let r=eX(e.restDecoder),i=Array(r),a=e.readClient(),s=eX(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new i0(rx(a,s),t),s+=t;break}case 10:{let t=eX(e.restDecoder);i[n]=new ax(rx(a,s),t),s+=t;break}default:{let l=(192&r)==0,o=new ag(rx(a,s),null,(128&r)==128?e.readLeftID():null,null,(64&r)==64?e.readRightID():null,l?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,l&&(32&r)==32?e.readString():null,af(e,r));i[n]=o,s+=o.length}}}}return n})(r,n)),s=i.pendingStructs;if(s){for(let[e,n]of s.missing)if(n<rL(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=s.missing.get(e);(null==n||n>t)&&s.missing.set(e,t)}s.update=r3([s.update,a.update])}}else i.pendingStructs=a;let l=n6(r,e,i);if(i.pendingDs){let t=new rn(eW(i.pendingDs));eX(t.restDecoder);let n=n6(t,e,i);l&&n?i.pendingDs=r3([l,n]):i.pendingDs=l||n}else i.pendingDs=l;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,ro(e.doc,t)}},n,!1))(i,e,n,new r(i))},rc=(e,t)=>((e,t=new Uint8Array([0]),n=new rs)=>{((e,t,n=new Map)=>{rl(e,t.store,n),n4(e,n5(t.store))})(n,e,rd(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(r5(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===ri)return r1(r.map((e,t)=>0===t?e:r9(e)));else if(n.constructor===rs)return r3(r)}return r[0]})(e,t,new ri),rd=e=>(e=>{let t=new Map,n=eX(e.restDecoder);for(let r=0;r<n;r++){let n=eX(e.restDecoder),r=eX(e.restDecoder);t.set(n,r)}return t})(new n7(eW(e))),ru=(e,t)=>(eS(e.restEncoder,t.size),ee(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{eS(e.restEncoder,t),eS(e.restEncoder,n)}),e);class rh{constructor(){this.l=[]}}let rp=()=>new rh,rm=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(e=>t!==e),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},rg=(e,t,n)=>tg(e.l,[t,n]);class rf{constructor(e,t){this.client=e,this.clock=t}}let rb=(e,t)=>e===t||null!==e&&null!==t&&e.client===t.client&&e.clock===t.clock,rx=(e,t)=>new rf(e,t),ry=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw eH()},rv=(e,t)=>{for(;null!==t;){if(t.parent===e)return!0;t=t.parent._item}return!1};class rw{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}}let r_=e=>new rw(null==e.type?null:rx(e.type.client,e.type.clock),e.tname??null,null==e.item?null:rx(e.item.client,e.item.clock),null==e.assoc?0:e.assoc);class rk{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}}let rN=(e,t,n)=>{let r=null,i=null;return null===e._item?i=ry(e):r=rx(e._item.id.client,e._item.id.clock),new rw(r,i,t,n)},rE=(e,t,n=0)=>{let r=e._start;if(n<0){if(0===t)return rN(e,null,n);t--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>t)return rN(e,rx(r.id.client,r.id.clock+t),n);t-=r.length}if(null===r.right&&n<0)return rN(e,r.lastId,n);r=r.right}return rN(e,null,n)},rC=(e,t,n=!0)=>
2{let r=t.store,i=e.item,a=e.type,s=e.tname,l=e.assoc,o=null,c=0;if(null!==i){let e,t;if(rL(r,i.client)<=i.clock)return null;let a=n?ad(r,i):(e=rF(r,i),t=i.clock-e.id.clock,{item:e,diff:t}),s=a.item;if(!(s instanceof ag))return null;if(null===(o=s.parent)._item||!o._item.deleted){c=s.deleted||!s.countable?0:a.diff+(l>=0?0:1);let e=s.left;for(;null!==e;)!e.deleted&&e.countable&&(c+=e.length),e=e.left}}else{if(null!==s)o=t.get(s);else if(null!==a){if(rL(r,a.client)<=a.clock)return null;let{item:e}=n?ad(r,a):{item:rF(r,a)};if(!(e instanceof ag)||!(e.content instanceof ac))return null;o=e.content.type}else throw eH();c=l>=0?o._length:0}return((e,t,n=0)=>new rk(e,t,n))(o,c,e.assoc)},rS=(e,t)=>e===t||null!==e&&null!==t&&e.tname===t.tname&&rb(e.item,t.item)&&rb(e.type,t.type)&&e.assoc===t.assoc;class rj{constructor(e,t){this.ds=e,this.sv=t}}let rA=(e,t)=>new rj(e,t);rA(n3(),new Map);let rD=e=>rA(n5(e.store),rI(e.store)),rM=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!nY(t.ds,e.id),rT=(e,t)=>{let n=J(e.meta,rT,X),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<rL(r,n)&&rU(e,rx(n,t))}),nQ(e,t.ds,e=>{}),n.add(t))};class rO{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}let rI=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},rL=(e,t)=>{let n=e.clients.get(t);if(void 0===n)return 0;let r=n[n.length-1];return r.id.clock+r.length},rR=(e,t)=>{let n=e.clients.get(t.id.client);if(void 0===n)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw eH()}n.push(t)},rP=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let s=es(t/(a+i.length-1)*r);for(;n<=r;){if((a=(i=e[s]).id.clock)<=t){if(t<a+i.length)return s;n=s+1}else r=s-1;s=es((n+r)/2)}throw eH()},rF=(e,t)=>{let n=e.clients.get(t.client);return n[rP(n,t.clock)]},rB=(e,t,n)=>{let r=rP(t,n),i=t[r];return i.id.clock<n&&i instanceof ag?(t.splice(r+1,0,ah(e,i,n-i.id.clock)),r+1):r},rU=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[rB(e,n,t.clock)]},r$=(e,t,n)=>{let r=t.clients.get(n.client),i=rP(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==i0&&r.splice(i+1,0,ah(e,a,n.clock-a.id.clock+1)),a},rz=(e,t,n,r,i)=>{let a;if(0===r)return;let s=n+r,l=rB(e,t,n);do s<(a=t[l++]).id.clock+a.length&&rB(e,t,s),i(a);while(l<t.length&&t[l].id.clock<s)};class rq{constructor(e,t,n){this.doc=e,this.deleteSet=new nX,this.beforeState=rI(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}let rH=(e,t)=>(0!==t.deleteSet.clients.size||!!((e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1})(t.afterState,(e,n)=>t.beforeState.get(n)!==e))&&(n0(t.deleteSet),rl(e,t.doc.store,t.beforeState),n4(e,t.deleteSet),!0),rK=(e,t,n)=>{let r=t._item;(null===r||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&J(e.changed,t,X).add(n)},rV=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ag&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},rG=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,s=n._mergeStructs;try{n0(a),n.afterState=rI(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{null!==r._item&&r._item.deleted||r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(null===r._item||!r._item.deleted)&&((t=t.filter(e=>null===e.target._item||!e.target._item.deleted)).forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{rg(r._dEH,t,n)}))}),e.push(()=>r.emit("afterTransaction",[n,r])),e.push(()=>{n._needFormattingCleanup&&iq(n)})}),tg(e,[])}finally{r.gc&&((e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],s=a.clock+a.len;for(let r=rP(e,a.clock),i=e[r];r<e.length&&i.id.clock<s;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof ag&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}}
2)(a,i,r.gcFilter),a.clients.forEach((e,t)=>{let n=i.clients.get(t);for(let t=e.length-1;t>=0;t--){let r=e[t],i=eo(n.length-1,1+rP(n,r.clock+r.len-1));for(let e=i,t=n[e];e>0&&t.id.clock>=r.clock;t=n[e])e-=1+rV(n,e)}}),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=ec(rP(e,r),1);for(let t=e.length-1;t>=n;)t-=1+rV(e,t)}});for(let e=s.length-1;e>=0;e--){let{client:t,clock:n}=s[e].id,r=i.clients.get(t),a=rP(r,n);!(a+1<r.length&&rV(r,a+1)>1)&&a>0&&rV(r,a)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(((...e)=>{console.log(...nK(e)),nG.forEach(t=>t.print(e))})(nz,nL,"[yjs] ",nR,nU,"Changed the client-id because another client seems to be using it."),r.clientID=e7()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let e=new ri;rH(e,n)&&r.emit("update",[e.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let e=new rs;rH(e,n)&&r.emit("updateV2",[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:l,subdocsLoaded:o,subdocsRemoved:c}=n;(l.size>0||c.size>0||o.size>0)&&(l.forEach(e=>{e.clientID=r.clientID,null==e.collectionid&&(e.collectionid=r.collectionid),r.subdocs.add(e)}),c.forEach(e=>r.subdocs.delete(e)),r.emit("subdocs",[{loaded:o,added:l,removed:c},r,n]),c.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):rG(e,t+1)}}},rW=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,s=null;null===e._transaction&&(a=!0,e._transaction=new rq(e,n,r),i.push(e._transaction),1===i.length&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&rG(i,0)}}return s};class rZ{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}let rJ=(e,t,n)=>{nQ(e,n.deletions,n=>{n instanceof ag&&t.scope.some(t=>t===e.doc||rv(t,n))&&au(n,!1)})},rX=(e,t,n)=>{let r=null,i=e.doc,a=e.scope;rW(i,n=>{for(;t.length>0&&null===e.currStackItem;){let r=i.store,s=t.pop(),l=new Set,o=[],c=!1;nQ(n,s.insertions,e=>{if(e instanceof ag){if(null!==e.redone){let{item:t,diff:i}=ad(r,e.id);i>0&&(t=rU(n,rx(t.id.client,t.id.clock+i))),e=t}!e.deleted&&a.some(t=>t===n.doc||rv(t,e))&&o.push(e)}}),nQ(n,s.deletions,e=>{e instanceof ag&&a.some(t=>t===n.doc||rv(t,e))&&!nY(s.insertions,e.id)&&l.add(e)}),l.forEach(t=>{c=null!==am(n,t,l,s.insertions,e.ignoreRemoteMapChanges,e)||c});for(let t=o.length-1;t>=0;t--){let r=o[t];e.deleteFilter(r)&&(r.delete(n),c=!0)}e.currStackItem=c?s:null}n.changed.forEach((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)}),r=n},e);let s=e.currStackItem;if(null!=s){let t=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:s,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return s};class rQ extends ei{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:a=!1,doc:s=er(e)?e[0].doc:e instanceof n9?e:e.doc}={}){super(),this.scope=[],this.doc=s,this.addToScope(e),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=a,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!this.captureTransaction(e)||!this.scope.some(t=>e.changedParentTypes.has(t)||t===this.doc)||!this.trackedOrigins.has(e.origin)&&(!e.origin||!this.trackedOrigins.has(e.origin.constructor)))return;let t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);let i=new nX;e.afterState.forEach((t,n)=>{let r=e.beforeState.get(n)||0,a=t-r;a>0&&n2(i,n,r,a)});let a=te(),s=!1;if(this.lastChange>0&&a-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){let t=r[r.length-1];t.deletions=n1([t.deletions,e.deleteSet]),t.insertions=n1([t.insertions,i])}else r.push(new rZ(e.deleteSet,i)),s=!0;t||n||(this.lastChange=a),nQ(e,e.deleteSet,t=>{t instanceof ag&&this.scope.some(n=>n===e.doc||rv(n,t))&&au(t,!0)});let l=[{stackItem:r[r.length-1],origin:e.origin,type:t?"redo":"undo",changedParentTypes:e.changedParentTypes},this];
2s?this.emit("stack-item-added",l):this.emit("stack-item-updated",l)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){let t=new Set(this.scope);(e=er(e)?e:[e]).forEach(e=>{t.has(e)||(t.add(e),(e instanceof id?e.doc!==this.doc:e!==this.doc)&&nV("[yjs#509] Not same Y.Doc"),this.scope.push(e))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(n=>{e&&(this.undoStack.forEach(e=>rJ(n,this,e)),this.undoStack=[]),t&&(this.redoStack.forEach(e=>rJ(n,this,e)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){let e;this.undoing=!0;try{e=rX(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){let e;this.redoing=!0;try{e=rX(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()}}class rY{constructor(e,t){this.gen=function*(e){let t=eX(e.restDecoder);for(let n=0;n<t;n++){let t=eX(e.restDecoder),n=e.readClient(),r=eX(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(10===t){let t=eX(e.restDecoder);yield new ax(rx(n,r),t),r+=t}else if((31&t)!=0){let i=(192&t)==0,a=new ag(rx(n,r),null,(128&t)==128?e.readLeftID():null,null,(64&t)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(32&t)==32?e.readString():null,af(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new i0(rx(n,r),t),r+=t}}}}(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&null!==this.curr&&this.curr.constructor===ax)return this.curr}}class r0{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}let r1=e=>r3(e,re,ri),r2=(e,t)=>{if(e.constructor===i0){let{client:n,clock:r}=e.id;return new i0(rx(n,r+t),e.length-t)}if(e.constructor===ax){let{client:n,clock:r}=e.id;return new ax(rx(n,r+t),e.length-t)}{let{client:n,clock:r}=e.id;return new ag(rx(n,r+t),null,rx(n,r+t-1),null,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t))}},r3=(e,t=rn,n=rs)=>{if(1===e.length)return e[0];let r=e.map(e=>new t(eW(e))),i=r.map(e=>new rY(e,!0)),a=null,s=new n,l=new r0(s);for(;(i=i.filter(e=>null!==e.curr)).sort((e,t)=>{if(e.curr.id.client!==t.curr.id.client)return t.curr.id.client-e.curr.id.client;{let n=e.curr.id.clock-t.curr.id.clock;return 0===n?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===ax?1:-1:n}}),0!==i.length;){let e=i[0],t=e.curr.id.client;if(null!==a){let n=e.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(null===n||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)r8(l,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===ax)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{r8(l,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new ax(rx(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===ax?a.struct.length-=t:n=r2(n,t)),a.struct.mergeWith(n)||(r8(l,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;null!==n&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==ax;n=e.next())r8(l,a.struct,a.offset),a={struct:n,offset:0}}return null!==a&&(r8(l,a.struct,a.offset),a=null),r6(l),n4(s,n1(r.map(e=>n8(e)))),s.toUint8Array()},r5=(e,t,n=rn,r=rs)=>{let i=rd(t),a=new r,s=new r0(a),l=new n(eW(e)),o=new rY(l,!1);for(;o.curr;){let e=o.curr,t=e.id.client,n=i.get(t)||0;if(o.curr.constructor===ax){o.next();continue}if(e.id.clock+e.length>n)for(r8(s,e,ec(n-e.id.clock,0)),o.next();o.curr&&o.curr.id.client===t;)r8(s,o.curr,0),o.next();else for(;o.curr&&o.curr.id.client===t&&o.curr.id.clock+o.curr.length<=n;)o.next()}return r6(s),n4(a,n8(l)),a.toUint8Array()},r4=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:eE(e.encoder.restEncoder)}),e.encoder.restEncoder=ek(),e.written=0)}
2,r8=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&r4(e),0===e.written&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),eS(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},r6=e=>{r4(e);let t=e.encoder.restEncoder;eS(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];eS(t,r.written),eT(t,r.restEncoder)}},r9=e=>((e,t,n,r)=>{let i=new n(eW(e)),a=new rY(i,!1),s=new r,l=new r0(s);for(let e=a.curr;null!==e;e=a.next())r8(l,t(e),0);return r6(l),n4(s,n8(i)),s.toUint8Array()})(e,tf,rn,ri),r7="You must not compute changes after the event-handler fired.";class ie{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=it(this.currentTarget,this.target))}deletes(e){return nY(this.transaction.deleteSet,e.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw Error(r7);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(null!==n){let r,i,a=t._map.get(n);if(this.adds(a)){let e=a.left;for(;null!==e&&this.adds(e);)e=e.left;if(this.deletes(a))if(!(null!==e&&this.deletes(e)))return;else r="delete",i=Q(e.content.getContent());else null!==e&&this.deletes(e)?(r="update",i=Q(e.content.getContent())):(r="add",i=void 0)}else{if(!this.deletes(a))return;r="delete",i=Q(a.content.getContent())}e.set(n,{action:r,oldValue:i})}}),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(null===e){if(0===this.transaction.doc._transactionCleanups.length)throw Error(r7);let t=this.target,n=X(),r=X(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;null!==i;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((null===e||void 0===e.delete)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((null===e||void 0===e.insert)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((null===e||void 0===e.retain)&&(a(),e={retain:0}),e.retain+=i.length);null!==e&&void 0===e.retain&&a()}this._changes=e}return e}}let it=(e,t)=>{let n=[];for(;null!==t._item&&t!==e;){if(null!==t._item.parentSub)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&null!==r;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},ir=()=>{nV("Invalid access: Add Yjs type to a document before reading data.")},ii=0;class ia{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ii++}}let is=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=ii++},il=(e,t)=>{if(null===e._start||0===t||null===e._searchMarker)return null;let n=0===e._searchMarker.length?null:e._searchMarker.reduce((e,n)=>el(t-e.index)<el(t-n.index)?e:n),r=e._start,i=0;for(null!==n&&(r=n.p,i=n.index,n.timestamp=ii++);null!==r.right&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;null!==r.left&&i>t;)!(r=r.left).deleted&&r.countable&&(i-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)!(r=r.left).deleted&&r.countable&&(i-=r.length);if(null!==n&&el(n.index-i)<r.parent.length/80)return is(n,r,i),n;var a=e._searchMarker,s=r,l=i;if(a.length>=80){let e=a.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return is(e,s,l),e}{let e=new ia(s,l);return a.push(e),e}},io=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)(t=t.left)&&!t.deleted&&t.countable&&(i.index-=t.length);if(null===t||!0===t.marker){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=ec(t,i.index+n))}},ic=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;J(i,e,()=>[]).push(n),null!==e._item;)e=e._item.parent;rg(r._eH,n,t)};class id{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=rp(),this._dEH=rp(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}
2_copy(){throw eq()}clone(){throw eq()}_write(e){}get _first(){let e=this._start;for(;null!==e&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){let t;t=this._eH,t.l.push(e)}observeDeep(e){let t;t=this._dEH,t.l.push(e)}unobserve(e){rm(this._eH,e)}unobserveDeep(e){rm(this._dEH,e)}toJSON(){}}let iu=(e,t,n)=>{e.doc??ir(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;null!==a&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},ih=e=>{e.doc??ir();let t=[],n=e._start;for(;null!==n;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},ip=(e,t)=>{let n=[],r=e._start;for(;null!==r;){if(r.countable&&rM(r,t)){let e=r.content.getContent();for(let t=0;t<e.length;t++)n.push(e[t])}r=r.right}return n},im=(e,t)=>{let n=0,r=e._start;for(e.doc??ir();null!==r;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},ig=(e,t)=>{let n=[];return im(e,(r,i)=>{n.push(t(r,i,e))}),n},ib=(e,t)=>{e.doc??ir();let n=il(e,t),r=e._start;for(null!==n&&(r=n.p,t-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},ix=(e,t,n,r)=>{let i=n,a=e.doc,s=a.clientID,l=a.store,o=null===n?t._start:n.right,c=[],d=()=>{c.length>0&&((i=new ag(rx(s,rL(l,s)),i,i&&i.lastId,o,o&&o.id,t,null,new i7(c))).integrate(e,0),c=[])};r.forEach(n=>{if(null===n)c.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(n);break;default:switch(d(),n.constructor){case Uint8Array:case ArrayBuffer:(i=new ag(rx(s,rL(l,s)),i,i&&i.lastId,o,o&&o.id,t,null,new i1(new Uint8Array(n)))).integrate(e,0);break;case n9:(i=new ag(rx(s,rL(l,s)),i,i&&i.lastId,o,o&&o.id,t,null,new i5(n))).integrate(e,0);break;default:if(n instanceof id)(i=new ag(rx(s,rL(l,s)),i,i&&i.lastId,o,o&&o.id,t,null,new ac(n))).integrate(e,0);else throw Error("Unexpected content type in insert operation")}}}),d()},iy=(e,t,n,r)=>{if(n>t._length)throw Error("Length exceeded!");if(0===n)return t._searchMarker&&io(t._searchMarker,n,r.length),ix(e,t,null,r);let i=n,a=il(t,n),s=t._start;for(null!==a&&(s=a.p,0==(n-=a.index)&&(n+=(s=s.prev)&&s.countable&&!s.deleted?s.length:0));null!==s;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&rU(e,rx(s.id.client,s.id.clock+n));break}n-=s.length}return t._searchMarker&&io(t._searchMarker,i,r.length),ix(e,t,s,r)},iv=(e,t,n,r)=>{if(0===r)return;let i=n,a=r,s=il(t,n),l=t._start;for(null!==s&&(l=s.p,n-=s.index);null!==l&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&rU(e,rx(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&null!==l;)l.deleted||(r<l.length&&rU(e,rx(l.id.client,l.id.clock+r)),l.delete(e),r-=l.length),l=l.right;if(r>0)throw Error("Length exceeded!");t._searchMarker&&io(t._searchMarker,i,-a+r)},iw=(e,t,n)=>{let r=t._map.get(n);void 0!==r&&r.delete(e)},i_=(e,t,n,r)=>{let i,a=t._map.get(n)||null,s=e.doc,l=s.clientID;if(null==r)i=new i7([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:i=new i7([r]);break;case Uint8Array:i=new i1(r);break;case n9:i=new i5(r);break;default:if(r instanceof id)i=new ac(r);else throw Error("Unexpected content type")}new ag(rx(l,rL(s.store,l)),a,a&&a.lastId,null,null,t,n,i).integrate(e,0)},ik=(e,t)=>{e.doc??ir();let n=e._map.get(t);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},iN=e=>{let t={};return e.doc??ir(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},iE=(e,t)=>{e.doc??ir();let n=e._map.get(t);return void 0!==n&&!n.deleted},iC=e=>{let t,n;return e.doc??ir(),t=e._map.entries(),n=e=>!e[1].deleted,nW(()=>{let e;do e=t.next();while(!e.done&&!n(e.value))return e})};class iS extends ie{}class ij extends id{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new ij;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ij}clone(){let e=new ij;return e.insert(0,this.toArray().map(e=>e instanceof id?e.clone():e)),e}get length(){return this.doc??ir(),this._length}_callObserver(e,t){super._callObserver(e,t),ic(this,e,new iS(this,e))}insert(e,t){null!==this.doc?rW(this.doc,n=>{iy(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){null!==this.doc?rW(this.doc,t=>
2{((e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return ix(e,t,r,n)})(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){null!==this.doc?rW(this.doc,n=>{iv(n,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return ib(this,e)}toArray(){return ih(this)}slice(e=0,t=this.length){return iu(this,e,t)}toJSON(){return this.map(e=>e instanceof id?e.toJSON():e)}map(e){return ig(this,e)}forEach(e){im(this,e)}[Symbol.iterator](){let e,t,n;return e=this._start,t=null,n=0,{[Symbol.iterator](){return this},next:()=>{if(null===t){for(;null!==e&&e.deleted;)e=e.right;if(null===e)return{done:!0,value:void 0};t=e.content.getContent(),n=0,e=e.right}let r=t[n++];return t.length<=n&&(t=null),{done:!1,value:r}}}}_write(e){e.writeTypeRef(an)}}class iA extends ie{constructor(e,t,n){super(e,t),this.keysChanged=n}}class iD extends id{constructor(e){super(),this._prelimContent=null,void 0===e?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new iD}clone(){let e=new iD;return this.forEach((t,n)=>{e.set(n,t instanceof id?t.clone():t)}),e}_callObserver(e,t){ic(this,e,new iA(this,e,t))}toJSON(){this.doc??ir();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof id?r.toJSON():r}}),e}get size(){return[...iC(this)].length}keys(){return nZ(iC(this),e=>e[0])}values(){return nZ(iC(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return nZ(iC(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ir(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){null!==this.doc?rW(this.doc,t=>{iw(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return null!==this.doc?rW(this.doc,n=>{i_(n,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return ik(this,e)}has(e){return iE(this,e)}clear(){null!==this.doc?rW(this.doc,e=>{this.forEach(function(t,n,r){iw(e,r,n)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(ar)}}let iM=(e,t)=>{let n,r;return e===t||"object"==typeof e&&"object"==typeof t&&e&&t&&((n=e)===(r=t)||td(n).length===td(r).length&&tu(n,(e,t)=>(void 0!==e||th(r,t))&&to(r[t],e)))};class iT{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){null===this.right&&eH(),this.right.content.constructor===i8?this.right.deleted||iR(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}let iO=(e,t,n)=>{for(;null!==t.right&&n>0;)t.right.content.constructor===i8?t.right.deleted||iR(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&rU(e,rx(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},iI=(e,t,n,r)=>{let i=new Map,a=r?il(t,n):null;return a?iO(e,new iT(a.p.left,a.p,a.index,i),n-a.index):iO(e,new iT(null,t._start,0,i),n)},iL=(e,t,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===i8&&iM(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,s)=>{let l=n.left,o=n.right,c=new ag(rx(a,rL(i.store,a)),l,l&&l.lastId,o,o&&o.id,t,null,new i8(s,r));c.integrate(e,0),n.right=c,n.forward()})},iR=(e,t)=>{let{key:n,value:r}=t;null===r?e.delete(n):e.set(n,r)},iP=(e,t)=>{for(;null!==e.right&&(e.right.deleted||e.right.content.constructor===i8&&iM(t[e.right.content.key]??null,e.right.content.value));){;e.forward()}},iF=(e,t,n,r)=>{let i=e.doc,a=i.clientID,s=new Map;for(let l in r){let o=r[l],c=n.currentAttributes.get(l)??null;if(!iM(c,o)){s.set(l,c);let{left:r,right:d}=n;n.right=new ag(rx(a,rL(i.store,a)),r,r&&r.lastId,d,d&&d.id,t,null,new i8(l,o)),n.right.integrate(e,0),n.forward()}}return s},iB=(e,t,n,r,i)=>
2{n.currentAttributes.forEach((e,t)=>{void 0===i[t]&&(i[t]=null)});let a=e.doc,s=a.clientID;iP(n,i);let l=iF(e,t,n,i),o=r.constructor===String?new ae(r):r instanceof id?new ac(r):new i4(r),{left:c,right:d,index:u}=n;t._searchMarker&&io(t._searchMarker,n.index,o.getLength()),(d=new ag(rx(s,rL(a.store,s)),c,c&&c.lastId,d,d&&d.id,t,null,o)).integrate(e,0),n.right=d,n.index=u,n.forward(),iL(e,t,n,l)},iU=(e,t,n,r,i)=>{let a=e.doc,s=a.clientID;iP(n,i);let l=iF(e,t,n,i);for(;null!==n.right&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===i8));){if(!n.right.deleted)if(n.right.content.constructor===i8){let{key:t,value:a}=n.right.content,s=i[t];if(void 0!==s){if(iM(s,a))l.delete(t);else{if(0===r)break;l.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a)}else r<n.right.length&&rU(e,rx(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;n.forward()}if(r>0){let i="";for(;r>0;r--)i+="\n";n.right=new ag(rx(s,rL(a.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new ae(i)),n.right.integrate(e,0),n.forward()}iL(e,t,n,l)},i$=(e,t,n,r,i)=>{let a=t,s=W();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===i8){let e=a.content;s.set(e.key,e)}a=a.right}let l=0,o=!1;for(;t!==a;){if(n===t&&(o=!0),!t.deleted){let n=t.content;if(n.constructor===i8){let{key:a,value:c}=n,d=r.get(a)??null;(s.get(a)!==n||d===c)&&(t.delete(e),l++,o||(i.get(a)??null)!==c||d===c||(null===d?i.delete(a):i.set(a,d))),o||t.deleted||iR(i,n)}}t=t.right}return l},iz=e=>{let t=0;return rW(e.doc,n=>{let r=e._start,i=e._start,a=W(),s=Z(a);for(;i;)!1===i.deleted&&(i.content.constructor===i8?iR(s,i.content):(t+=i$(n,r,i,a,s),a=Z(s),r=i)),i=i.right}),t},iq=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&rz(e,n.store.clients.get(r),a,i,e=>{e.deleted||e.content.constructor!==i8||e.constructor===i0||t.add(e.parent)})}rW(n,n=>{for(let r of(nQ(e,e.deleteSet,e=>{if(e instanceof i0||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;if(e.content.constructor===i8)t.add(r);else{for(var i=e;i&&i.right&&(i.right.deleted||!i.right.countable);)i=i.right;let t=new Set;for(;i&&(i.deleted||!i.countable);){if(!i.deleted&&i.content.constructor===i8){let e=i.content.key;t.has(e)?i.delete(n):t.add(e)}i=i.left}}}),t))iz(r)})},iH=(e,t,n)=>{let r=n,i=Z(t.currentAttributes),a=t.right;for(;n>0&&null!==t.right;){if(!1===t.right.deleted)switch(t.right.content.constructor){case ac:case i4:case ae:n<t.right.length&&rU(e,rx(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&i$(e,a,t.right,i,t.currentAttributes);let s=(t.left||t.right).parent;return s._searchMarker&&io(s._searchMarker,t.index,-r+n),t};class iK extends ie{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{null===e?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(null===this._changes){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(null===this._delta){let e=this.target.doc,t=[];rW(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,s={},l="",o=0,c=0,d=()=>{if(null!==a){let e=null;switch(a){case"delete":c>0&&(e={delete:c}),c=0;break;case"insert":("object"==typeof l||l.length>0)&&(e={insert:l},n.size>0&&(e.attributes={},n.forEach((t,n)=>{null!==t&&(e.attributes[n]=t)}))),l="";break;case"retain":o>0&&(e={retain:o},(e=>{for(let t in e)return!1;return!0})(s)||(e.attributes=tc({},s))),o=0}e&&t.push(e),a=null}};for(;null!==i;){switch(i.content.constructor){case ac:case i4:this.adds(i)?this.deletes(i)||(d(),a="insert",l=i.content.getContent()[0],d()):this.deletes(i)?("delete"!==a&&(d(),a="delete"),c+=1):i.deleted||("retain"!==a&&(d(),a="retain"),o+=1);break;case ae:this.adds(i)?this.deletes(i)||("insert"!==a&&(d(),a="insert"),l+=i.content.str):this.deletes(i)?("delete"!==a&&(d(),a="delete"),c+=i.length):i.deleted||("retain"!==a&&(d(),a="retain"),o+=i.length);break;case i8:{let{key:t,value:l}=i.content;if(this.adds(i))this.deletes(i)||(iM(n.get(t)??null,l)?null!==l&&i.delete(e):("retain"===a&&d(),iM(l,r.get(t)??null)?delete s[t]:s[t]=l));else if(this.deletes(i)){r.set(t,l);let e=n.get(t)??null;iM(e,l)||("retain"===a&&d(),s[t]=e)}else if(!i.deleted){r.set(t,l);let n=s[t];void 0!==n&&(iM(n,l)?null!==n&&i.delete(e):("retain"===a&&d(),null===l?delete s[t]:s[t]=l))}i.deleted||("insert"===a&&d(),iR(n,i.content))}}i=i.right}for(d();t.length>0;){let e=t[t.length-1];if(void 0!==e.retain&&void 0===e.attributes)t.pop();else break}}),this._delta=t}return this._delta}}class iV extends id{constructor(e){super(),this._pending=void 0!==e?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ir(),this._length}_integrate(e,t){super._integrate(e,t);
2try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new iV}clone(){let e=new iV;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let n=new iK(this,e,t);ic(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ir();let e="",t=this._start;for(;null!==t;)!t.deleted&&t.countable&&t.content.constructor===ae&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){null!==this.doc?rW(this.doc,n=>{let r=new iT(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(void 0!==a.insert){let s=t||"string"!=typeof a.insert||i!==e.length-1||null!==r.right||"\n"!==a.insert.slice(-1)?a.insert:a.insert.slice(0,-1);("string"!=typeof s||s.length>0)&&iB(n,this,r,s,a.attributes||{})}else void 0!==a.retain?iU(n,this,r,a.retain,a.attributes||{}):void 0!==a.delete&&iH(n,r,a.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,n){this.doc??ir();let r=[],i=new Map,a=this.doc,s="",l=this._start;function o(){if(s.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:s};t&&(n.attributes=e),r.push(n),s=""}}let c=()=>{for(;null!==l;){if(rM(l,e)||void 0!==t&&rM(l,t))switch(l.content.constructor){case ae:{let r=i.get("ychange");void 0===e||rM(l,e)?void 0===t||rM(l,t)?void 0!==r&&(o(),i.delete("ychange")):(void 0===r||r.user!==l.id.client||"added"!==r.type)&&(o(),i.set("ychange",n?n("added",l.id):{type:"added"})):(void 0===r||r.user!==l.id.client||"removed"!==r.type)&&(o(),i.set("ychange",n?n("removed",l.id):{type:"removed"})),s+=l.content.str;break}case ac:case i4:{o();let e={insert:l.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case i8:rM(l,e)&&(o(),iR(i,l.content))}l=l.right}o()};return e||t?rW(a,n=>{e&&rT(n,e),t&&rT(n,t),c()},"cleanup"):c(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;null!==r?rW(r,r=>{let i=iI(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),iB(r,this,i,t,n)}):this._pending.push(()=>this.insert(e,t,n))}insertEmbed(e,t,n){let r=this.doc;null!==r?rW(r,r=>{let i=iI(r,this,e,!n);iB(r,this,i,t,n||{})}):this._pending.push(()=>this.insertEmbed(e,t,n||{}))}delete(e,t){if(0===t)return;let n=this.doc;null!==n?rW(n,n=>{iH(n,iI(n,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,n){if(0===t)return;let r=this.doc;null!==r?rW(r,r=>{let i=iI(r,this,e,!1);null!==i.right&&iU(r,this,i,t,n)}):this._pending.push(()=>this.format(e,t,n))}removeAttribute(e){null!==this.doc?rW(this.doc,t=>{iw(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){null!==this.doc?rW(this.doc,n=>{i_(n,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return ik(this,e)}getAttributes(){return iN(this)}_write(e){e.writeTypeRef(ai)}}class iG{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ir()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(null!==e&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,e.deleted||t.constructor!==iZ&&t.constructor!==iW||null===t._start)for(;null!==e;){let t=e.next;if(null!==t){e=t;break}e=e.parent===this._root?null:e.parent._item}else e=t._start;while(null!==e&&(e.deleted||!this._filter(e.content.type)))return(this._firstCall=!1,null===e)?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class iW extends id{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new iW}clone(){let e=new iW;return e.insert(0,this.toArray().map(e=>e instanceof id?e.clone():e)),e}get length(){return this.doc??ir(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(e){return new iG(this,e)}querySelector(e){e=e.toUpperCase();let t=new iG(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),ee(new iG(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){ic(this,e,new iJ(this,t,e))}toString(){return ig(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),im(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){null!==this.doc?rW(this.doc,n=>{iy(n,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(null!==this.doc)rW(this.doc,n=>{ix(n,this,e&&e instanceof id?e._item:e,t)});else{let n=this._prelimContent,r=null===e?0:n.findIndex(t=>t===e)+1;if(0===r&&null!==e)throw Error("Reference item not found");n.splice(r,0,...t)}}delete(e,t=1){null!==this.doc?rW(this.doc,n=>{iv(n,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return ih(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ib(this,e)}slice(e=0,t=this.length){return iu(this,e,t)}forEach(e){im(this,e)}_write(e){e.writeTypeRef(as)}}class iZ extends iW{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}
2_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new iZ(this.nodeName)}clone(){let e=new iZ(this.nodeName);var t,n,r=this.getAttributes();for(let i in r){t=r[i],n=i,e.setAttribute(n,t)}return e.insert(0,this.toArray().map(e=>e instanceof id?e.clone():e)),e}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+'="'+e[r]+'"')}let i=this.nodeName.toLocaleLowerCase(),a=t.length>0?" "+t.join(" "):"";return`<${i}${a}>${super.toString()}</${i}>`}removeAttribute(e){null!==this.doc?rW(this.doc,t=>{iw(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){null!==this.doc?rW(this.doc,n=>{i_(n,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return ik(this,e)}hasAttribute(e){return iE(this,e)}getAttributes(e){let t;return e?(t={},this._map.forEach((n,r)=>{let i=n;for(;null!==i&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;null!==i&&rM(i,e)&&(t[r]=i.content.getContent()[i.length-1])}),t):iN(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];"string"==typeof t&&r.setAttribute(e,t)}return im(this,i=>{r.appendChild(i.toDOM(e,t,n))}),void 0!==n&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(aa),e.writeKey(this.nodeName)}}class iJ extends ie{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{null===e?this.childListChanged=!0:this.attributesChanged.add(e)})}}class iX extends iD{constructor(e){super(),this.hookName=e}_copy(){return new iX(this.hookName)}clone(){let e=new iX(this.hookName);return this.forEach((t,n)=>{e.set(n,t)}),e}toDOM(e=document,t={},n){let r,i=t[this.hookName];return(r=void 0!==i?i.createDom(this):document.createElement(this.hookName)).setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(al),e.writeKey(this.hookName)}}class iQ extends iV{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new iQ}clone(){let e=new iQ;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n="";for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=">"}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(ao)}}class iY{constructor(e,t){this.id=e,this.length=t}get deleted(){throw eq()}mergeWith(e){return!1}write(e,t,n){throw eq()}integrate(e,t){throw eq()}}class i0 extends iY{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),rR(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}}class i1{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new i1(this.content)}splice(e){throw eq()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class i2{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new i2(this.len)}splice(e){let t=new i2(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){n2(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}let i3=(e,t)=>new n9({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class i5{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 t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),null!==e.meta&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new i5(i3(this.doc.guid,this.opts))}
2splice(e){throw eq()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,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,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}class i4{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new i4(this.embed)}splice(e){throw eq()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class i8{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new i8(this.key,this.value)}splice(e){throw eq()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}class i6{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new i6(this.arr)}splice(e){let t=new i6(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(void 0===t?"undefined":JSON.stringify(t))}}getRef(){return 2}}let i9="development"===t_("node_env");class i7{constructor(e){this.arr=e,i9&&tm(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new i7(this.arr)}splice(e){let t=new i7(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}}class ae{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new ae(this.str)}splice(e){let t=new ae(this.str.slice(e));this.str=this.str.slice(0,e);let n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(0===t?this.str:this.str.slice(t))}getRef(){return 4}}let at=[e=>new ij,e=>new iD,e=>new iV,e=>new iZ(e.readKey()),e=>new iW,e=>new iX(e.readKey()),e=>new iQ],an=0,ar=1,ai=2,aa=3,as=4,al=5,ao=6;class ac{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new ac(this.type._copy())}splice(e){throw eq()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;null!==t;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;null!==t;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(t=>{for(;null!==t;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}let ad=(e,t)=>{let n,r=t,i=0;do i>0&&(r=rx(r.client,r.clock+i)),n=rF(e,r),i=r.clock-n.id.clock,r=n.redone;while(null!==r&&n instanceof ag)return{item:n,diff:i}},au=(e,t)=>{for(;null!==e&&e.keep!==t;)e.keep=t,e=e.parent._item},ah=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new ag(rx(r,i+n),t,rx(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),null!==t.redone&&(a.redone=rx(t.redone.client,t.redone.clock+n)),t.right=a,null!==a.right&&(a.right.left=a),e._mergeStructs.push(a),null!==a.parentSub&&null===a.right&&a.parent._map.set(a.parentSub,a),t.length=n,a},ap=(e,t)=>en(e,e=>nY(e.deletions,t)),am=(e,t,n,r,i,a)=>{let s,l=e.doc,o=l.store,c=l.clientID,d=t.redone;if(null!==d)return rU(e,d);let u=t.parent._item,h=null;if(null!==u&&!0===u.deleted){if(null===u.redone&&(!n.has(u)||null===am(e,u,n,r,i,a)))return null;for(;null!==u.redone;)u=rU(e,u.redone)}let p=null===u?t.parent:u.content.type;if(null===t.parentSub){for(h=t.left,s=t;null!==h;){let t=h;for(;null!==t&&t.parent._item!==u;)t=null===t.redone?null:rU(e,t.redone);if(null!==t&&t.parent._item===u){h=t;break}h=h.left}for(;null!==s;){let t=s;for(;null!==t&&t.parent._item!==u;)t=null===t.redone?null:rU(e,t.redone);if(null!==t&&t.parent._item===u){s=t;break}s=s.right}}else{if(s=null,t.right&&!i){for(h=t;null!==h&&null!==h.right&&(h.right.redone||nY(r,h.right.id)||ap(a.und
2oStack,h.right.id)||ap(a.redoStack,h.right.id));)for(h=h.right;h.redone;)h=rU(e,h.redone);if(h&&null!==h.right)return null}else h=p._map.get(t.parentSub)||null;null!==h&&h.parent._item!==u&&(h=p._map.get(t.parentSub)||null)}let m=rL(o,c),g=rx(c,m),f=new ag(g,h,h&&h.lastId,s,s&&s.id,p,t.parentSub,t.content.copy());return t.redone=g,au(f,!0),f.integrate(e,0),f};class ag extends iY{constructor(e,t,n,r,i,a,s,l){super(e,l.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=s,this.redone=null,this.content=l,this.info=2*!!this.content.isCountable()}set marker(e){(8&this.info)>0!==e&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=rL(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=rL(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===rf&&this.id.client!==this.parent.client&&this.parent.clock>=rL(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=r$(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=rU(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===i0||this.right&&this.right.constructor===i0)this.parent=null;else if(this.parent){if(this.parent.constructor===rf){let e=rF(t,this.parent);e.constructor===i0?this.parent=null:this.parent=e.content.type}}else this.left&&this.left.constructor===ag?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ag&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=r$(e,e.doc.store,rx(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let t,n=this.left;if(null!==n)t=n.right;else if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start;let r=new Set,i=new Set;for(;null!==t&&t!==this.right;){if(i.add(t),r.add(t),rb(this.origin,t.origin)){if(t.id.client<this.id.client)n=t,r.clear();else if(rb(this.rightOrigin,t.rightOrigin))break}else if(null!==t.origin&&i.has(rF(e.doc.store,t.origin)))r.has(rF(e.doc.store,t.origin))||(n=t,r.clear());else break;t=t.right}this.left=n}if(null!==this.left){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(e)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),rR(e.doc.store,this),this.content.integrate(e,this),rK(e,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(e)}else new i0(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;null!==e&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;null!==e&&e.deleted;)e=e.left;return e}get lastId(){return 1===this.length?this.id:rx(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&rb(e.origin,this.lastId)&&this.right===e&&rb(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&null===this.redone&&null===e.redone&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,null!==this.right&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;this.countable&&null===this.parentSub&&(t._length-=this.length),this.markDeleted(),n2(e.deleteSet,this.id.client,this.id.clock,this.length),rK(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw eH();if(this.content.gc(e),t){var n;let t;n=new i0(this.id,this.length),(t=e.clients.get(this.id.client))[rP(t,this.id.clock)]=n}else this.content=new i2(this.length)}write(e,t){let n=t>0?rx(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=31&this.content.getRef()|128*(null!==n)|64*(null!==r)|32*(null!==i);if(e.writeInfo(a),null!==n&&e.writeLeftID(n),null!==r&&e.writeRightID(r),null===n&&null===r){let t=this.parent;if(void 0!==t._item){let n=t._item;if(null===n){let n=ry(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===rf?(e.writeParentInfo(!1),e.writeLeftID(t)):eH();null!==i&&e.writeString(i)}this.content.write(e,t)}}let af=(e,t)=>
2ab[31&t](e),ab=[()=>{eH()},e=>new i2(e.readLen()),e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();"undefined"===t?n.push(void 0):n.push(JSON.parse(t))}return new i6(n)},e=>new i1(e.readBuf()),e=>new ae(e.readString()),e=>new i4(e.readJSON()),e=>new i8(e.readKey(),e.readJSON()),e=>new ac(at[e.readTypeRef()](e)),e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new i7(n)},e=>new i5(i3(e.readString(),e.readAny())),()=>{eH()}];class ax extends iY{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){eH()}write(e,t){e.writeInfo(10),eS(e.restEncoder,this.length-t)}getMissing(e,t){return null}}let ay="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,av="__ $YJS$ __";!0===ay[av]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),ay[av]=!0;var aw=e.i(571141);let a_=/[\uD800-\uDBFF]/,ak=/[\uDC00-\uDFFF]/,aN=(e,t)=>e>>>t|e<<32-t,aE=e=>aN(e,2)^aN(e,13)^aN(e,22),aC=e=>aN(e,6)^aN(e,11)^aN(e,25),aS=e=>aN(e,7)^aN(e,18)^e>>>3,aj=e=>aN(e,17)^aN(e,19)^e>>>10,aA=new Uint32Array([0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0xfc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x6ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2]),aD=new Uint32Array([0x6a09e66
27,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19]);class aM{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(aD),this._W=new Uint32Array(e,64,64)}_updateHash(){let e=this._H,t=this._W;for(let e=16;e<64;e++)t[e]=aj(t[e-2])+t[e-7]+aS(t[e-15])+t[e-16];let n=e[0],r=e[1],i=e[2],a=e[3],s=e[4],l=e[5],o=e[6],c=e[7];for(let e=0,d,u;e<64;e++)d=c+aC(s)+(s&l^~s&o)+aA[e]+t[e]>>>0,u=aE(n)+(n&r^n&i^r&i)>>>0,c=o,o=l,l=s,s=a+d>>>0,a=i,i=r,r=n,n=d+u>>>0;e[0]+=n,e[1]+=r,e[2]+=i,e[3]+=a,e[4]+=s,e[5]+=l,e[6]+=o,e[7]+=c}digest(e){let t=0;for(;t+56<=e.length;){let n=0;for(;n<16&&t+3<e.length;n++)this._W[n]=e[t++]<<24|e[t++]<<16|e[t++]<<8|e[t++];if(t%64!=0){for(this._W.fill(0,n,16);t<e.length;)this._W[n]|=e[t]<<(3-t%4)*8,t++;this._W[n]|=128<<(3-t%4)*8}this._updateHash()}let n=t%64!=0;this._W.fill(0,0,16);let r=0;for(;t<e.length;r++)for(let n=3;n>=0&&t<e.length;n--)this._W[r]|=e[t++]<<8*n;n||(this._W[r-(t%4!=0)]|=128<<(3-t%4)*8),this._W[14]=e.byteLength/0x20000000,this._W[15]=8*e.byteLength,this._updateHash();let i=new Uint8Array(32);for(let e=0;e<this._H.length;e++)for(let t=0;t<4;t++)i[4*e+t]=this._H[e]>>>(3-t)*8;return i}}var aT=e.i(674729);let aO=new T.PluginKey("y-sync"),aI=new T.PluginKey("y-undo"),aL=new T.PluginKey("yjs-cursor"),aR=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&t.sv.get(e.id.client)>e.id.clock&&!nY(t.ds,e.id),aP=[{light:"#ecd44433",dark:"#ecd444"}],aF=(e,t,n,r)=>{if(null==n||!(null===r||n>1&&r<=1||so(t,e,n,r)))return r;let i=sl(t,e,n);return null!==i?i:r},aB=(e,t)=>{let n=t.selection.jsonID;return{type:n,depth:"nodeRange"===n?t.selection.depth:void 0,anchor:sr(t.selection.anchor,e.type,e.mapping),head:sr(t.selection.head,e.type,e.mapping),absAnchor:t.selection.anchor,absHead:t.selection.head}};class aU{constructor(e,t=new Map){this.type=e,this.prosemirrorView=null,this.mux=(()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else void 0!==n&&n()}})(),this.mapping=t,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{null===this.beforeTransactionSelection&&null!=this.prosemirrorView&&(this.beforeTransactionSelection=aB(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()&&(ty&&null===this._domSelectionInView&&(nO(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView)}_isDomSelectionInView(){let e=this.prosemirrorView._root.getSelection();if(null==e||null==e.anchorNode)return!1;let t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),0===t.getClientRects().length&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);let n=t.getBoundingClientRect(),r=nE.documentElement;return n.bottom>=0&&n.right>=0&&n.left<=(window.innerWidth||r.clientWidth||0)&&n.top<=(window.innerHeight||r.clientHeight||0)}renderSnapshot(e,t){t||(t=rA(n3(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(aO,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{let e=this.type.toArray().map(e=>az(e,this.prosemirrorView.state.schema,this)).filter(e=>null!==e),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new O.Slice(O.Fragment.from(e),0,0));t.setMeta(aO,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{let e=null!==this.beforeTransactionSelection?null:this.prosemirrorView.state.selection,t=this.type.toArray().map(e=>az(e,this.prosemirrorView.state.schema,this)).filter(e=>null!==e),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new O.Slice(O.Fragment.from(t),0,0));if(e){let t=eo(ec(e.anchor,0),n.doc.content.size),r=eo(ec(e.head,0),n.doc.content.size);n.setSelection(T.TextSelection.create(n.doc,t,r))}this.prosemirrorView.dispatch(n.setMeta(aO,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,n){let r=this.doc,i=this.type;if(e||(e=rD(this.doc)),e instanceof Uint8Array||t instanceof Uint8Array)if(e instanceof Uint8Array&&t instanceof Uint8Array||eH(),ro(r=new n9({gc:!1}),t),t=rD(r),ro(r,e),e=rD(r),null===i._item){let e=Array.from(this.doc.share.keys()).find(e=>this.doc.share.get(e)===this.type);i=r.getXmlFragment(e)}else{let e=r.store.clients.get(i._item.id.client)??[],t=rP(e,i._item.id.clock);i=e[t].content.type}this.mapping.clear(),this.mux(()=>{r.transact(r=>{let a=n.permanentUserData;
2a&&a.dss.forEach(e=>{nQ(r,e,e=>{})});let s=(e,t)=>{let r="added"===e?a.getUserByClientId(t.client):a.getUserByDeletedId(t);return{user:r,type:e,color:((e,t,n)=>{if(!e.has(n)){let r;if(e.size<t.length){let n=X();e.forEach(e=>n.add(e)),t=t.filter(e=>!n.has(e))}e.set(n,(r=t)[es(e9()*r.length)])}return e.get(n)})(n.colorMapping,n.colors,r)}},l=ip(i,new rj(t.ds,e.sv)).map(n=>!n._item.deleted||aR(n._item,e)||aR(n._item,t)?az(n,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,t,s):null).filter(e=>null!==e),o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new O.Slice(O.Fragment.from(l),0,0));this.prosemirrorView.dispatch(o.setMeta(aO,{isChangeOrigin:!0}))},aO)})}_typeChanged(e,t){if(null==this.prosemirrorView)return;let n=aO.getState(this.prosemirrorView.state);0===e.length||null!=n.snapshot||null!=n.prevSnapshot?this.renderSnapshot(n.snapshot,n.prevSnapshot):this.mux(()=>{let e=(e,t)=>this.mapping.delete(t);nQ(t,t.deleteSet,e=>{if(e.constructor===ag){let t=e.content.type;t&&this.mapping.delete(t)}}),t.changed.forEach(e),t.changedParentTypes.forEach(e),this.mapping.clear();let n=this.type.toArray().map(e=>a$(e,this.prosemirrorView.state.schema,this)).filter(e=>null!==e),r=this.prosemirrorView.state.doc,i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new O.Slice(O.Fragment.from(n),0,0));((e,t,n,r)=>{if(null!==t&&null!==t.anchor&&null!==t.head)if("all"===t.type)e.setSelection(new T.AllSelection(e.doc));else if("node"===t.type){var i,a;let r,s=sa(n.doc,n.type,t.anchor,n.mapping);null!==s&&e.setSelection((i=e,a=s,(r=i.doc.resolve(a)).nodeAfter?T.NodeSelection.create(i.doc,a):T.TextSelection.near(r)))}else if("nodeRange"===t.type){let r=((e,t,n,r)=>{if(null===t||null===n)return null;
2let i=Math.min(Math.max(t,0),e.doc.content.size),a=Math.min(Math.max(n,0),e.doc.content.size);try{let t=T.Selection.fromJSON(e.doc,{type:"nodeRange",anchor:i,head:a,depth:r});if(!t.ranges.length)return T.TextSelection.near(e.doc.resolve(i));return t}catch(t){return T.TextSelection.near(e.doc.resolve(i))}})(e,sa(n.doc,n.type,t.anchor,n.mapping),sa(n.doc,n.type,t.head,n.mapping),t.depth);null!==r&&e.setSelection(r)}else{let i=sa(n.doc,n.type,t.anchor,n.mapping),a=sa(n.doc,n.type,t.head,n.mapping);null!=r&&(i=aF(e.doc,r,t.absAnchor,i),a=aF(e.doc,r,t.absHead,a)),null===i&&(i=a),null===a&&(a=i),null!==i&&null!==a&&e.setSelection(T.TextSelection.between(e.doc.resolve(i),e.doc.resolve(a)))}})(i,this.beforeTransactionSelection,this,r),i=i.setMeta(aO,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof rQ}),null!==this.beforeTransactionSelection&&this._isLocalCursorInView()&&i.scrollIntoView(),this.prosemirrorView.dispatch(i)})}_prosemirrorChanged(e){this.doc.transact(()=>{a6(this.doc,this.type,e,this),this.beforeTransactionSelection=aB(this,this.prosemirrorView.state)},aO)}initView(e){null!=this.prosemirrorView&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){null!=this.prosemirrorView&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}let a$=(e,t,n,r,i,a)=>{let s=n.mapping.get(e);if(void 0===s)if(e instanceof iZ)return az(e,t,n,r,i,a);else throw eq();return s},az=(e,t,n,r,i,a)=>{let s=[],l=e=>{if(e instanceof iZ){let l=a$(e,t,n,r,i,a);null!==l&&s.push(l)}else{let l=e._item.right?.content?.type;l instanceof iV&&!l._item.deleted&&l._item.id.client===l.doc.clientID&&(e.applyDelta([{retain:e.length},...l.toDelta()]),l.doc.transact(e=>{l._item.delete(e)}));let o=aq(e,t,n,r,i,a);null!==o&&o.forEach(e=>{null!==e&&s.push(e)})}};void 0===r||void 0===i?e.toArray().forEach(l):ip(e,new rj(i.ds,r.sv)).forEac
2h(l);try{let l=e.getAttributes(r);void 0!==r&&(aR(e._item,r)?aR(e._item,i)||(l.ychange=a?a("added",e._item.id):{type:"added"}):l.ychange=a?a("removed",e._item.id):{type:"removed"});let o=t.node(e.nodeName,l,s);return n.mapping.set(e,o),o}catch(t){return e.doc.transact(t=>{e._item.delete(t)},aO),n.mapping.delete(e),null}},aq=(e,t,n,r,i,a)=>{let s=[],l=e.toDelta(r,i,a);try{for(let e=0;e<l.length;e++){let n=l[e];s.push(t.text(n.insert,a4(n.attributes,t)))}}catch(t){return e.doc.transact(t=>{e._item.delete(t)},aO),null}return s},aH=(e,t)=>{let n,r;return e instanceof Array?(n=new iQ,r=e.map(e=>({insert:e.text,attributes:a8(e.marks,t)})),n.applyDelta(r),t.mapping.set(n,e),n):((e,t)=>{let n=new iZ(e.type.name);for(let t in e.attrs){let r=e.attrs[t];null!==r&&"ychange"!==t&&n.setAttribute(t,r)}return n.insert(0,aG(e).map(e=>aH(e,t))),t.mapping.set(n,e),n})(e,t)},aK=e=>"object"==typeof e&&null!==e,aV=(e,t)=>{let n=Object.keys(e).filter(t=>null!==e[t]),r=n.length===Object.keys(t).filter(e=>null!==t[e]).length;for(let i=0;i<n.length&&r;i++){let a=n[i],s=e[a],l=t[a];r="ychange"===a||s===l||aK(s)&&aK(l)&&aV(s,l)}return r},aG=e=>{let t=e.content.content,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.isText){let r=[];for(let n=t[e];e<t.length&&n.isText;n=t[++e])r.push(n);e--,n.push(r)}else n.push(r)}return n},aW=(e,t)=>{let n=e.toDelta();return n.length===t.length&&n.every((e,n)=>e.insert===t[n].text&&td(e.attributes||{}).length===t[n].marks.length&&tu(e.attributes,(e,r)=>{let i=a5(r),a=t[n].marks;return!!a.find(e=>e.type.name===i)&&aV(e,a.find(e=>e.type.name===i)?.attrs)}))},aZ=(e,t)=>{if(e instanceof iZ&&!(t instanceof Array)&&a9(e,t)){let n=aG(t);return e._length===n.length&&aV(e.getAttributes(),t.attrs)&&e.toArray().every((e,t)=>aZ(e,n[t]))}return e instanceof iQ&&t instanceof Array&&aW(e,t)},aJ=(e,t)=>e===t||e instanceof Array&&t instanceof Array&&e.length===t.length&&e.every((e,n)=>t[n]===e),aX=(e,t,n,r)=>{n>0&&(e.slice(t,t+n).forEach(e=>r.mapping.delete(e)),e.delete(t,n))},aQ=(e,t,n,r,i,a)=>{if(r<i){let s=[];for(let e=r;e<i;e++)s.push(aH(n[e],a));e.insert(t,s)}},aY=(e,t,n,r)=>t instanceof iQ&&n instanceof Array?(aW(t,n)?r.mapping.set(t,n):a2(t,n,r),!0):!!(t instanceof iZ&&!(n instanceof Array)&&a9(t,n))&&(aZ(t,n)?r.mapping.set(t,n):a6(e,t,n,r),!0),a0=(e,t,n,r,i,a,s,l,o)=>{let c=eo(a-i,l-s);for(let a=0;a<c;a++)aY(e,r[i+a],n[s+a],o)||(aX(t,s+a,1,o),aQ(t,s+a,n,s+a,s+a+1,o));aX(t,s+c,a-i-c,o),aQ(t,s+c,n,s+c,l,o)},a1=(e,t,n)=>{let r=e.toArray(),i=aG(t),a=i.length,s=r.length,l=eo(s,a),o=0,c=0,d=!1;for(;o<l;o++){let e=r[o],t=i[o];if(aJ(n.mapping.get(e),t))d=!0;else if(!aZ(e,t))break}for(;o+c<l;c++){let e=r[s-c-1],t=i[a-c-1];if(aJ(n.mapping.get(e),t))d=!0;else if(!aZ(e,t))break}return{equalityFactor:o+c,foundMappedChild:d}},a2=(e,t,n)=>{n.mapping.set(e,t);let{nAttrs:r,str:i}=(e=>{let t="",n=e._start,r={};for(;null!==n;)!n.deleted&&(n.countable&&n.content instanceof ae?t+=n.content.str:n.content instanceof i8&&(r[n.content.key]=null)),n=n.right;return{str:t,nAttrs:r}})(e),a=t.map(e=>({insert:e.text,attributes:Object.assign({},r,a8(e.marks,n))})),{insert:s,remove:l,index:o}=((e,t)=>{let n=0,r=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;for(n>0&&a_.test(e[n-1])&&n--;r+n<e.length&&r+n<t.length&&e[e.length-r-1]===t[t.length-r-1];)r++;return r>0&&ak.test(e[e.length-r])&&r--,{index:n,remove:e.length-n-r,insert:t.slice(n,t.length-r)}})(i,a.map(e=>e.insert).join(""));e.delete(o,l),e.insert(o,s),e.applyDelta(a.map(e=>({retain:e.insert.length,attributes:e.attributes})))},a3=/(.*)(--[a-zA-Z0-9+/=]{8})$/,a5=e=>a3.exec(e)?.[1]??e,a4=(e,t)=>{let n=[];for(let r in e)n.push(t.mark(a5(r),e[r]));return n},a8=(e,t)=>{let n={};return e.forEach(e=>{if("ychange"!==e.type.name){var r;let i,a;n[J(t.isOMark,e.type,()=>!e.type.excludes(e.type))?`${e.type.name}--${tC((e=>{for(let t=6;t<e.length;t++)e[t%6]=e[t%6]^e[t];return e.slice(0,6)})((r=e.toJSON(),(e=>eR(e,r))(i=ek()),a=eE(i),new aM().digest(a))))}`:e.type.name]=e.attrs}}),n},a6=(e,t,n,r)=>{if(t instanceof iZ&&t.nodeName!==n.type.name)throw Error("node name mismatch!");if(r.mapping.set(t,n),t instanceof iZ){let e=t.getAttributes(),r=n.attrs;for(let n in r)null!==r[n]?e[n]!==r[n]&&"ychange"!==n&&t.setAttribute(n,r[n]):t.removeAttribute(n);for(let n in e)void 0===r[n]&&t.removeAttribute(n)}let i=aG(n),a=i.length,s=t.toArray(),l=s.length,o=eo(a,l);if(((e,t,n,r,i)=>{let a=((e,t,n)=>{let r=new Map;t.forEach((e,t)=>{r.has(e)||r.set(e,t)});let i=[];if(e.forEach((e,a)=>{let s=n.mapping.get(e),l=r.get(s);void 0!==l&&aJ(s,t[l])&&i.push({yIndex:a,pIndex:l,yChild:e})}),0===i.length)return[];let a=Array(i.length),s=[];for(let e=0;e<i.length;e++){let t=0,n=s.length;for(;t<n;){let r=t+n>>1;i[s[r]].pIndex<i[e].pIndex?t=r+1:n=r}a[e]=t>0?s[t-1]:-1,s[t]=e}let l=[];for(let e=s[s.length-1];-1!==e;e=a[e])l.push(i[e]);return l.reverse()})(r,n,i);if(a.length<2||!a.some(e=>e.yIndex!==e.pIndex)||a.some(e=>{let t=n[e.pIndex];return!(e.yChild instanceof iQ&&t instanceof Array||e.yChild instanceof iZ&&!(t instanceof Array))}))return!1;let s=0,l=0;for(let o of a){a0(e,t,n,r,s,o.yIndex,l,o.pIndex,i);let a=n[o.pIndex];aY(e,o.yChild,a,i),s=o.yIndex+1,l=o.pIndex+1}return a0(e,t,n,r,s,r.length,l,n.length,i),!0})(e,t,i,s,r))return;let c=0,d=0;for(;c<o;c++){let e=s[c],t=i[c];if(!aJ(r.mapping.get(e),t))if(aZ(e,t))r.mapping.set(e,t);else break}for(;d+c+1<o;d++){let e=s[l-d-1],t=i[a-d-1];if(!aJ(r.mapping.get(e),t))if(aZ(e,t))r.mapping.set(e,t);else break}e.transact(()=>{for(;l-c-d>0&&a-c-d>0;){let n=s[c],o=i[c],u=s[l-d-1],h=i[a-d-1];if(n instanceof iQ&&o instanceof Array)aW(n,o)||a2(n,o,r),c+=1;else{let i=n instanceof iZ&&a9(n,o),a=u instanceof iZ&&a9(u,h);if(i&&a){let e=a1(n,o,r),t=a1(u,h,r);
2e.foundMappedChild&&!t.foundMappedChild?a=!1:!e.foundMappedChild&&t.foundMappedChild||e.equalityFactor<t.equalityFactor?i=!1:a=!1}i?(a6(e,n,o,r),c+=1):a?(a6(e,u,h,r),d+=1):(r.mapping.delete(t.get(c)),t.delete(c,1),t.insert(c,[aH(o,r)]),c+=1)}}let n=l-c-d;if(1===l&&0===a&&s[0]instanceof iQ?(r.mapping.delete(s[0]),s[0].delete(0,s[0].length)):n>0&&(t.slice(c,c+n).forEach(e=>r.mapping.delete(e)),t.delete(c,n)),c+d<a){let e=[];for(let t=c;t<a-d;t++)e.push(aH(i[t],r));t.insert(c,e)}},aO)},a9=(e,t)=>!(t instanceof Array)&&e.nodeName===t.type.name,a7=null;class se{constructor(e,t,n){this.view=e,this.key=t,this.value=n}apply(){let e=aO.getState(this.view.state);if(e&&e.binding&&!e.binding.isDestroyed){let e=this.view.state.tr;e.setMeta(this.key,this.value),this.view.dispatch(e)}}}class st{constructor(e=[]){this.entries=e}getFirst(){return this.entries[0]}dequeueFirst(){return this.entries.shift()}isEmpty(){return 0===this.entries.length}static fromViewsToUpdate(){let e=a7;a7=null;let t=[];return e.forEach((e,n)=>{e.forEach((e,r)=>{t.push(new se(n,r,e))})}),new st(t)}}let sn=(e=st.fromViewsToUpdate(),t=!1)=>{let n=!0;for(;!e.isEmpty();){let r=e.getFirst();try{r.apply()}catch(r){if(r instanceof RangeError){t&&n&&e.dequeueFirst(),e.isEmpty()||nO(0,()=>sn(e,!0));return}throw r}n=!1,e.dequeueFirst()}},sr=(e,t,n)=>{if(0===e)return rE(t,0,-1);let r=null===t._first?null:t._first.content.type;for(;null!==r&&t!==r;){if(r instanceof iQ){if(r._length>=e)return rE(r,e,-1);if(e-=r._length,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{do r=null===r._item?null:r._item.parent,e--;while(r!==t&&null!==r&&null!==r._item&&null===r._item.next)null!==r&&r!==t&&(r=null===r._item?null:r._item.next.content.type)}}else{let i=(n.get(r)||{nodeSize:0}).nodeSize;if(null!==r._first&&e<i)r=r._first.content.type,e--;else{if(1===e&&0===r._length&&i>1)return new rw(null===r._item?null:r._item.id,null===r._item?ry(r):null,null);if(e-=i,null!==r._item&&null!==r._item.next)r=r._item.next.content.type;else{if(0===e)return new rw(null===(r=null===r._item?r:r._item.parent)._item?null:r._item.id,null===r._item?ry(r):null,null);do r=r._item.parent,e--;while(r!==t&&null===r._item.next)r!==t&&(r=r._item.next.content.type)}}}if(null===r)throw eH();if(0===e&&r.constructor!==iQ&&r!==t)return si(r._item.parent,r._item)}return rE(t,t._length,-1)},si=(e,t)=>{let n=null,r=null;return null===e._item?r=ry(e):n=rx(e._item.id.client,e._item.id.clock),new rw(n,r,t.id)},sa=(e,t,n,r)=>{let i=rC(n,e);if(null===i||i.type!==t&&!rv(t,i.type._item))return null;let a=i.type,s=0;if(a.constructor===iQ)s=i.index;else if(null===a._item||!a._item.deleted){let e=a._first,t=0;for(;t<a._length&&t<i.index&&null!==e;){if(!e.deleted){let n=e.content.type;if(t++,n instanceof iQ)s+=n._length;else{let e=r.get(n);if(null==e)return null;s+=e.nodeSize}}e=e.right}s+=1}for(;a!==t&&null!==a._item;){let e=a._item.parent;if(null===e._item||!e._item.deleted){s+=1;let t=e._first;for(;null!==t;){let e=t.content.type;if(e===a)break;if(!t.deleted)if(e instanceof iQ)s+=e._length;else{let t=r.get(e);if(null==t)return null;s+=t.nodeSize}t=t.right}}a=e}let l=s-1;return((e,t,n)=>{if(null===n)return!1;let r=rC(t,e);return null!==r&&r.type instanceof iQ&&null!==t.item&&n<=1})(e,n,l)?null:l},ss=(e,t)=>{if(e===t)return!0;let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])},sl=(e,t,n)=>{let r,i=0,a=0;for(;a<e.childCount;a++){let t=e.child(a);if(i+t.nodeSize>n)break;i+=t.nodeSize}if(a>=e.childCount)return null;let s=e.child(a),l=e.resolve(n),o=(r,s=!1)=>{let o=0;for(let t=0;t<=a;t++)r(e.child(t))&&o++;let c=0,d=-1,u=null,h=0;for(let e=0;e<t.childCount;e++){let n=t.child(e);r(n)&&++c===o&&(d=h,u=n),h+=n.nodeSize}if(null===u||s&&(1!==o||1!==c))return null;var p=d,m=u;if(0===l.depth){let e=p+(n-i);return Math.max(p+1,Math.min(e,p+m.nodeSize-1))}return((e,t,n)=>{let r=t+1,i=n;for(let t=1;t<e.depth;t++){let n=e.index(t);if(n>=i.childCount)return null;for(let e=0;e<n;e++)r+=i.child(e).nodeSize;if(r+=1,(i=i.child(n)).type!==e.node(t+1).type)return null}return i.isTextblock?r+Math.min(e.parentOffset,i.content.size):null})(l,p,m)},c=e=>e.type===s.type&&ss(e.attrs,s.attrs),d=s.textContent,u=o(e=>c(e)&&e.textContent===d);if(null!==u)return u;let h=o(e=>e.type===s.type&&e.textContent===d);if(null!==h)return h;if(r=s.type.spec.attrs||{},Object.keys(s.attrs).some(e=>{let t=r[e];return null==t||!Object.prototype.hasOwnProperty.call(t,"default")||t.default!==s.attrs[e]})){let e=o(c,!0);if(null!==e)return e}return o(e=>c(e)&&""!==d&&""!==e.textContent&&(d.startsWith(e.textContent)||e.textContent.startsWith(d)),!0)},so=(e,t,n,r)=>{if(null===r)return!1;let i=e.resolve(n),a=t.resolve(r);if(!i.parent.isTextblock)return!1;if(!a.parent.isTextblock||i.parent.textContent!==a.parent.textContent||0!==i.parentOffset&&0===a.parentOffset)return!0;let s=0===i.parentOffset&&0===a.parentOffset,l=i.parentOffset!==a.parentOffset||i.parent.type!==a.parent.type||!ss(i.parent.attrs,a.parent.attrs);if(s||l){let i=sl(e,t,n);return null!==i&&i!==r}return!1},sc=(e,t,n)=>e!==t,sd=e=>{let t=document.createElement("span");t.classList.add("ProseMirror-yjs-cursor"),t.setAttribute("style",`border-color: ${e.color}`);let n=document.createElement("div");n.setAttribute("style",`background-color: ${e.color}`),n.insertBefore(document.createTextNode(e.name),null);let r=document.createTextNode("â "),i=document.createTextNode("â ");return t.insertBefore(r,null),t.insertBefore(n,null),t.insertBefore(i,null),t},su=e=>({style:`background-color: ${e.color}70`,class:"ProseMirror-yjs-selection"}),sh=/^#[0-9a-fA-F]{6}$/,sp=(e,t,n,r,i)=>{let a=aO.getState(e);if(null==a||null==a.doc||null==a.binding)return aw.DecorationSet.create(e.doc,[]);let s=a.doc,l=[];return null!=a.snapshot||null!=a.prevSnapshot||0===a.binding.mapping.size?aw.DecorationSet.create(e.doc,[]):(t.getStates().forEac
2h((t,o)=>{if(n(s.clientID,o,t)&&t&&null!=t.cursor){let n=t.user||{};null==n.color?n.color="#ffa500":sh.test(n.color)||console.warn("A user uses an unsupported color format",n),null==n.name&&(n.name=`User: ${o}`);let c=sa(s,a.type,r_(t.cursor.anchor),a.binding.mapping),d=sa(s,a.type,r_(t.cursor.head),a.binding.mapping);if(null!==c&&null!==d){let t=ec(e.doc.content.size-1,0);c=eo(c,t),d=eo(d,t),l.push(aw.Decoration.widget(d,()=>r(n,o),{key:o+"",side:10}));let a=eo(c,d),s=ec(c,d);l.push(aw.Decoration.inline(a,s,i(n,o),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),aw.DecorationSet.create(e.doc,l))},sm=new Set(["paragraph"]);function sg(e){return!!e.getMeta(aO)}function sf(e,t){let n=aO.getState(e);return sr(t,n.type,n.binding.mapping)}var sb=class e extends G.MappablePosition{constructor(e,t){super(e),this.yRelativePosition=t}static fromJSON(t){return new e(t.position,t.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};let sx=G.Extension.create({name:"collaboration",priority:1e3,addOptions:()=>({document:null,field:"default",fragment:null,provider:null}),addStorage:()=>({isDisabled:!1}),onCreate(){this.editor.extensionManager.extensions.find(e=>"undoRedo"===e.name)&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(e,t)=>(function(e,t,n){let r=e instanceof sb?e.yRelativePosition:null;if(sg(t)&&r){let e;return{position:new sb(sa((e=aO.getState(n)).doc,e.type,r,e.binding.mapping)||0,r),mapResult:null}}let i=(0,G.getUpdatedPosition)(e,t),a=i.position.position;return{position:new sb(a,null!=r?r:sf(n,a)),mapResult:i.mapResult}})(e,t,this.editor.state),this.editor.utils.createMappablePosition=e=>new sb(e,sf(this.editor.state,e))},addCommands:()=>({undo:()=>({tr:e,state:t,dispatch:n})=>{if(e.setMeta("preventDispatch",!0),0===aI.getState(t).undoManager.undoStack.length)return!1;if(!n)return!0;let r=aI.getState(t).undoManager;return null!=r?(r.undo(),!0):void 0},redo:()=>({tr:e,state:t,dispatch:n})=>{if(e.setMeta("preventDispatch",!0),0===aI.getState(t).undoManager.redoStack.length)return!1;if(!n)return!0;let r=aI.getState(t).undoManager;return null!=r?(r.redo(),!0):void 0}}),addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){let e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),t=(({protectedNodes:e=sm,trackedOrigins:t=[],undoManager:n=null}={})=>new T.Plugin({key:aI,state:{init:(r,i)=>{let a=aO.getState(i),s=n;if(!s){let n=a.doc,r=new Set(n?n._observers.get("destroy"):[]);s=new rQ(a.type,{trackedOrigins:new Set([aO].concat(t)),deleteFilter:t=>!(t instanceof ag)||!(t.content instanceof ac)||!(t.content.type instanceof iV||t.content.type instanceof iZ&&e.has(t.content.type.nodeName))||0===t.content.type._length,captureTransaction:e=>!1!==e.meta.get("addToHistory")});let i=n?n._observers.get("destroy"):new Set;s._yTiptapDocDestroyListeners=Array.from(i||[]).filter(e=>!r.has(e))}return{undoManager:s,prevSel:null,hasUndoOps:s.undoStack.length>0,hasRedoOps:s.redoStack.length>0}},apply:(e,t,n,r)=>{let i=aO.getState(r).binding,a=t.undoManager,s=a.undoStack.length>0,l=a.redoStack.length>0;return i?{undoManager:a,prevSel:aB(i,n),hasUndoOps:s,hasRedoOps:l}:s!==t.hasUndoOps||l!==t.hasRedoOps?Object.assign({},t,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):t}},view:e=>{let t=aO.getState(e.state),n=aI.getState(e.state).undoManager;return n.on("stack-item-added",({stackItem:n})=>{let r=t.binding;r&&n.meta.set(r,aI.getState(e.state).prevSel)}),n.on("stack-item-popped",({stackItem:e})=>{let n=t.binding;n&&(n.beforeTransactionSelection=e.meta.get(n)||n.beforeTransactionSelection)}),{destroy:()=>{n.destroy();let e=n._yTiptapDocDestroyListeners;e&&n.doc&&(e.forEach(e=>n.doc.off("destroy",e)),n._yTiptapDocDestroyListeners=null)}}}}))(this.options.yUndoOptions),n=t.spec.view;return t.spec.view=e=>{let{undoManager:t}
2=aI.getState(e.state);t.restore&&(t.restore(),t.restore=()=>{});let r=n?n(e):void 0;return{destroy:()=>{let e=t.trackedOrigins.has(t),n=t._observers;t.restore=()=>{e&&t.trackedOrigins.add(t),t.doc.on("afterTransaction",t.afterTransactionHandler),t._observers=n},(null==r?void 0:r.destroy)&&r.destroy()}}},[((e,{colors:t=aP,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{},mapping:a}={})=>{let s=!1,l=new aU(e,a),o=new T.Plugin({props:{editable:e=>{let t=aO.getState(e);return null==t.snapshot&&null==t.prevSnapshot}},key:aO,state:{init:(i,a)=>({type:e,doc:e.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:t,colorMapping:n,permanentUserData:r}),apply:(e,t)=>{let n=e.getMeta(aO);if(void 0!==n)for(let e in t=Object.assign({},t),n)t[e]=n[e];return e.docChanged&&(t.addToHistory=!1!==e.getMeta("addToHistory")),t.isChangeOrigin=void 0!==n&&!!n.isChangeOrigin,t.isUndoRedoOperation=void 0!==n&&!!n.isChangeOrigin&&!!n.isUndoRedoOperation,null!==l.prosemirrorView&&void 0!==n&&(null!=n.snapshot||null!=n.prevSnapshot)&&nO(0,()=>{null!=l.prosemirrorView&&(null==n.restore?l._renderSnapshot(n.snapshot,n.prevSnapshot,t):(l._renderSnapshot(n.snapshot,n.snapshot,t),delete t.restore,delete t.snapshot,delete t.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),t}},view:e=>(l.initView(e),null==a&&l._forceRerender(),i(),{update:()=>{let t=o.getState(e.state);if(null==t.snapshot&&null==t.prevSnapshot&&(s||null!==e.state.doc.content.findDiffStart(e.state.doc.type.createAndFill().content))){if(s=!0,!1===t.addToHistory&&!t.isChangeOrigin){let t=aI.getState(e.state),n=t&&t.undoManager;n&&n.stopCapturing()}l.mux(()=>{t.doc.transact(n=>{n.meta.set("addToHistory",t.addToHistory),l._prosemirrorChanged(e.state.doc)},aO)})}},destroy:()=>{l.destroy()}})});return o})(e,{...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender}),t,this.editor.options.enableContentCheck&&new T.Plugin({key:new T.PluginKey("filterInvalidContent"),filterTransaction:t=>{if(!sg(t))return!0;if(this.storage.isDisabled)return!1;if(!t.docChanged)return!0;try{return t.doc.check(),!0}catch(t){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:t,editor:this.editor,disableCollaboration:()=>{var t;null==(t=e.doc)||t.destroy()}}),!0}}})].filter(Boolean)}});function sy(e){return"string"==typeof e&&/^#[0-9a-fA-F]{6}$/.test(e)}let sv=e=>Array.from(e.entries()).map(([e,t])=>t&&t.user?{clientId:e,...t.user}:{clientId:e}),sw=()=>null,s_=e=>({...e,color:sy(e.color)?e.color:"transparent"}),sk=G.Extension.create({name:"collaborationCaret",priority:999,addOptions:()=>({provider:null,user:{name:null,color:null},render:e=>{let t=document.createElement("span"),{color:n}=s_(e);t.classList.add("collaboration-carets__caret"),t.style.borderColor=n;let r=document.createElement("div");return r.classList.add("collaboration-carets__label"),r.style.backgroundColor=n,r.insertBefore(document.createTextNode(e.name),null),t.insertBefore(r,null),t},selectionRender:e=>sy(e.color)?su(e):{},onUpdate:sw}),onCreate(){if(this.options.onUpdate!==sw&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCaret.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),!this.options.provider)throw Error('The "provider" option is required for the CollaborationCaret extension')},addStorage:()=>({users:[]}),addCommands(){return{updateUser:e=>()=>(this.options.provider.awareness.setLocalStateField("user",e),!0),user:e=>({editor:t})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-caret'),t.commands.updateUser(e))}},addProseMirrorPlugins(){let{provider:e}=this.options,t=this.storage,n=this.options.user;return[new T.Plugin({key:new T.PluginKey("collaborationCaretAwarenessListener"),view:()=>{let r=()=>{t.users=sv(e.awareness.states)};return e.awareness.setLocalStateField("user",n),t.users=sv(e.awareness.states),e.awareness.on("update",r),{destroy:()=>{e.awareness.off("update",r),t.users=[]}}}}),((e,{awarenessStateFilter:t=sc,cursorBuilder:n=sd,selectionBuilder:r=su,getSelection:i=e=>e.selection}={},a="cursor")=>new T.Plugin({key:aL,state:{init:(i,a)=>sp(a,e,t,n,r),apply(i,a,s,l){let o=aO.getState(l),c=i.getMeta(aL),d=o&&o.isChangeOrigin;return i.docChanged&&!d&&((e,t)=>{if(!e.docChanged)return!1;if(e.doc.childCount!==t.childCount)return!0;for(let n of e.steps)if(n instanceof aT.ReplaceStep){if(0===n.from&&n.to===t.content.size)return!0;
2if(n.slice.content.size>0){let e=!1;if(n.slice.content.forEach(t=>{t.isBlock&&(e=!0)}),e)return!0}else if(n.to>n.from){let e=t.resolve(n.from),r=t.resolve(n.to);if(0===e.depth&&0===r.depth&&e.index()!==r.index())return!0}}return!1})(i,s.doc)?aw.DecorationSet.empty:d||c&&c.awarenessUpdated?sp(l,e,t,n,r):i.docChanged?a.map(i.mapping,i.doc):a}},props:{decorations:e=>aL.getState(e)},view:t=>{let n=()=>{t.docView&&(a7||(a7=new Map,nO(0,sn)),J(a7,t,W).set(aL,{awarenessUpdated:!0}))},r=(t,n={})=>{let r=aO.getState(t.state);if(!r||!r.binding)return;let s=e.getLocalState()||{};if(t.hasFocus()){let l=i(t.state),o=sr(l.anchor,r.type,r.binding.mapping),c=sr(l.head,r.type,r.binding.mapping);!n.force&&null!=s.cursor&&rS(r_(s.cursor.anchor),o)&&rS(r_(s.cursor.head),c)||e.setLocalStateField(a,{anchor:o,head:c})}else null!=s.cursor&&null!==sa(r.doc,r.type,r_(s.cursor.anchor),r.binding.mapping)&&e.setLocalStateField(a,null)},s=()=>r(t);return e.on("change",n),t.dom.addEventListener("focusin",s),t.dom.addEventListener("focusout",s),{update:(e,t)=>{let n=aO.getState(e.state),i=!!(n?.isChangeOrigin&&t?.doc&&!t.doc.eq(e.state.doc));r(e,{force:i})},destroy:()=>{t.dom.removeEventListener("focusin",s),t.dom.removeEventListener("focusout",s),e.off("change",n),e.setLocalStateField(a,null)}}}}))(e.awareness,{cursorBuilder:e=>this.options.render(s_(e)),selectionBuilder:e=>this.options.selectionRender(s_(e))})]}});var sN=e.i(771649),sE=e.i(936046),sC=e.i(255149),sS=e.i(590911),sj=e.i(370956),sA=e.i(448876),sD=e.i(656272),sM=e.i(865960),sT=e.i(758472),sO=e.i(299023),sI=e.i(735501),sL=e.i(278716),sR=e.i(204753),sP=e.i(915085),sF=e.i(206003),sB=e.i(274768),sU=e.i(221345),s$=e.i(178583),sz=e.i(114890),sz=sz,sq=e.i(666293),sq=sq,sH=e.i(195083),sH=sH,sK=e.i(341240),sV=e.i(664659),sG=e.i(174886),sW=e.i(248256),sZ=e.i(424274),sZ=sZ,sJ=e.i(110031),sX=e.i(727612),sQ=e.i(57086),sY=e.i(489853),s0=e.i(959208),s1=e.i(263457),s2=e.i(180722),s2=s2,s3=e.i(63804),s5=e.i(726308),s5=s5,s4=e.i(134754),s8=e.i(346897),s6=e.i(426612),s9=e.i(889832),s7=e.i(732893),le=e.i(726796),lt=e.i(59377),ln=e.i(920755),lr=e.i(826244),li=e.i(74473),la=e.i(773449),ls=e.i(778917);function ll({node:e,updateAttributes:t,selected:n}){let[r,i]=(0,s.useState)(!1),l=e.attrs.src,o=e.attrs.name||"Document.pdf",c=e.attrs.height||480,d=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let n=e.clientY;i(!0);let r=e=>{t({height:Math.round(Math.max(160,c+(e.clientY-n)))})},a=()=>{i(!1),window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",r),window.addEventListener("pointerup",a)},[c,t]);return(0,a.jsxs)(M.NodeViewWrapper,{"data-pdf-embed":!0,"data-resize-state":n?"selected":"idle",className:`doc-pdf-embed${r?" resizing":""}`,children:[(0,a.jsxs)("div",{className:"doc-pdf-embed-bar",contentEditable:!1,children:[(0,a.jsx)(s$.FileText,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,a.jsx)("span",{className:"doc-pdf-embed-name",children:o}),(0,a.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"doc-pdf-embed-open","aria-label":"Open PDF in a new tab",title:"Open in new tab",onMouseDown:e=>e.stopPropagation(),children:(0,a.jsx)(ls.ExternalLink,{className:"h-3.5 w-3.5"})})]}),(0,a.jsx)("iframe",{src:l,title:o,className:"doc-pdf-embed-frame",style:{height:`${c}px`,pointerEvents:r?"none":void 0}}),(0,a.jsx)("span",{"data-pdf-resize-handle":!0,onPointerDown:d})]})}let lo=G.Node.create({name:"pdf",group:"block",draggable:!0,selectable:!0,atom:!0,addOptions:()=>({HTMLAttributes:{}}),addAttributes:()=>({src:{default:null},name:{default:null},height:{default:480}}),parseHTML:()=>[{tag:"div[data-pdf]",getAttrs:e=>{let t=parseInt(e.getAttribute("data-height")||"",10);return{src:e.getAttribute("data-src"),name:e.getAttribute("data-name"),height:Number.isFinite(t)?t:480}}}],renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.src||"",r=e.attrs.name||"Document.pdf";return["div",(0,G.mergeAttributes)(this.options.HTMLAttributes,t,{"data-pdf":"","data-src":n,"data-name":r,"data-height":String(e.attrs.height||480),class:"doc-pdf-card"}),["a",{href:n,target:"_blank",rel:"noopener noreferrer",class:"doc-pdf-card-link"},["span",{class:"doc-pdf-card-icon"}],["span",{class:"doc-pdf-card-name"},r]]]},addCommands(){return{setPdf:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(ll)});var lc=e.i(534857);let ld=new Map;function lu(e,t){ld.set(e,t)}function lh({node:e}
2){let t=(0,o.useRouter)(),n=e.attrs.docId,[r,i]=(0,s.useState)(()=>{let t=ld.get(n);return t?{title:t.title.trim()||"Untitled",icon:t.icon}:{title:e.attrs.title||"Untitled",icon:e.attrs.icon??null}}),[c,d]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null),p=(0,s.useRef)(null),m=(0,s.useRef)(null),g=(0,s.useCallback)(async()=>{if(!n)return;let e=(0,ln.createClient)(),{data:t}=await e.from("docs").select("title, icon").eq("id",n).is("deleted_at",null).maybeSingle();if(t){let e=ld.get(n),r=(t.title||"").trim();i({title:e?.title.trim()?e.title.trim():r||"Untitled",icon:e?e.icon:t.icon})}},[n]);(0,s.useEffect)(()=>{if(!n)return;let e=!1;(async()=>{if(await g(),e)return})();let t=(0,ln.createClient)(),r=t.channel(`page-link-${n}-${Math.random().toString(36).slice(2)}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"docs",filter:`id=eq.${n}`},e=>{let t=e.new;i({title:t.title||"Untitled",icon:t.icon??null})}).subscribe(),a=()=>{"visible"===document.visibilityState&&g()};return document.addEventListener("visibilitychange",a),window.addEventListener("focus",g),()=>{e=!0,t.removeChannel(r),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",g)}},[n,g]),(0,s.useEffect)(()=>{if(!c)return;let e=e=>{let t=e.target;!t||m.current?.contains(t)||p.current?.contains(t)||d(!1)};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[c]);let f=async e=>{i(t=>({...t,icon:e})),d(!1),await fetch(`/api/docs/${n}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({icon:e})})},b=e=>{e.preventDefault(),e.stopPropagation()};return(0,a.jsxs)(M.NodeViewWrapper,{as:"div","data-page-link":!0,"data-doc-id":n,draggable:!1,onDragStart:b,children:[(0,a.jsxs)("div",{contentEditable:!1,draggable:!1,onDragStart:b,className:"page-link-card",onMouseDown:e=>e.stopPropagation(),onClick:e=>{e.preventDefault(),e.stopPropagation(),t.push(`/docs/${n}`)},role:"link",tabIndex:0,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),t.push(`/docs/${n}`))},children:[(0,a.jsx)("button",{ref:p,type:"button",onClick:e=>{if(e.stopPropagation(),e.preventDefault(),!p.current)return;let t=p.current.getBoundingClientRect();h((0,lr.clampIconPickerAnchor)(t)),d(!0)},"aria-label":"Change icon",className:"page-link-icon",children:r.icon?(0,a.jsx)(lr.DocIcon,{icon:r.icon,size:18}):(0,a.jsx)(li.QuillIcon,{className:"h-[18px] w-[18px] text-muted-foreground"})}),(0,a.jsx)("span",{className:"page-link-title",children:r.title||"Untitled"})]}),c&&u&&"u">typeof document&&(0,l.createPortal)((0,a.jsx)("div",{ref:m,className:"fixed z-50",style:{left:u.left,top:u.top},children:(0,a.jsx)(lr.IconPicker,{onSelect:e=>void f(e),onClose:()=>d(!1)})}),document.body)]})}let lp=G.Node.create({name:"pageLink",group:"block",atom:!0,selectable:!0,draggable:!1,addAttributes:()=>({docId:{default:null,parseHTML:e=>e.getAttribute("data-doc-id"),renderHTML:e=>e.docId?{"data-doc-id":e.docId}:{}},title:{default:"Untitled",parseHTML:e=>{let t=e.getAttribute("data-page-title");if(t)return t;let n=(e.textContent??"").trim(),r=n.match(/^\S+\s+(.*)$/);return(r?r[1]:n)||"Untitled"},renderHTML:e=>({"data-page-title":e.title??"Untitled"})},icon:{default:null,parseHTML:e=>e.getAttribute("data-page-icon")??e.getAttribute("icon"),renderHTML:e=>e.icon?{"data-page-icon":e.icon}:{}}}),parseHTML:()=>[{tag:"div[data-page-link]",priority:100},{tag:"a[data-page-link]",priority:100}],renderHTML({node:e,HTMLAttributes:t}){let{title:n,icon:r}=e.attrs,i="string"!=typeof r||!r||r.startsWith("lucide:")||(0,lc.isDocIconImage)(r)?"ð":r;return["div",(0,G.mergeAttributes)(t,{"data-page-link":"",class:"page-link-card"}),`${i} `,n||"Untitled"]},addCommands(){return{insertPageLink:e=>({chain:t})=>t().insertContent([{type:this.name,attrs:e},{type:"paragraph"}]).run()}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(lh)}),lm=new Map;function lg(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}var lf=e.i(950263),lb=e.i(941388);let lx=G.Node.create({name:"tabPanel",content:"block+",addAttributes:()=>({label:{default:"Untitled",parseHTML:e=>e.getAttribute("data-label")||"Untitled",renderHTML:e=>({"data-label":e.label})}}),parseHTML:()=>[{tag:"div[data-tab-panel]"}],renderHTML:({HTMLAttributes:e})=>["div",{...e,"data-tab-panel":""},0]});function ly({node:e,editor:t,getPos:n}
2){let[r,i]=(0,s.useState)(0),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(""),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{r>=e.childCount&&e.childCount>0&&i(e.childCount-1)},[r,e.childCount]);let h=t=>{let n=e.maybeChild(t);return n?.attrs.label||`Tab ${t+1}`},p=e=>{d(h(e)),o(e)},m=e=>{let r=c.trim()||`Tab ${e+1}`;o(null);let i="function"==typeof n?n():null;if("number"!=typeof i)return;let a=t.state.doc.nodeAt(i);if(!a)return;let s=i+1,l=-1;if(a.forEach((t,n,r)=>{r===e&&(l=s),s+=t.nodeSize}),l<0)return;let d=t.state.doc.nodeAt(l);if(!d)return;let u=t.state.tr.setNodeMarkup(l,void 0,{...d.attrs,label:r});t.view.dispatch(u)};return(0,a.jsxs)(M.NodeViewWrapper,{ref:u,as:"div","data-tabs":!0,"data-active-tab":r,className:"doc-tabs",children:[(0,a.jsxs)("div",{className:"doc-tabs-strip",contentEditable:!1,children:[Array.from({length:e.childCount}).map((e,t)=>{let n=t===r;return l===t?(0,a.jsx)("input",{type:"text",autoFocus:!0,value:c,onChange:e=>d(e.target.value),onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),m(t)):"Escape"===e.key&&(e.preventDefault(),o(null))},onBlur:()=>m(t),onFocus:e=>e.currentTarget.select(),className:"doc-tab-pill is-active is-editing",size:Math.max(c.length||1,4)},t):(0,a.jsx)("button",{type:"button","data-active":n,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),e.stopPropagation(),l!==t&&(t===r?p(t):i(t))},onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),p(t)},title:n?"Click again to rename · Double-click to rename":"Click to switch",className:`doc-tab-pill ${n?"is-active":""}`,children:h(t)},t)}),(0,a.jsx)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:e=>{e.preventDefault(),e.stopPropagation();let r="function"==typeof n?n():null;if("number"!=typeof r)return;let a=t.state.doc.nodeAt(r);if(!a)return;let s=r+a.nodeSize-1;t.chain().focus().insertContentAt(s,{type:"tabPanel",attrs:{label:`Tab ${a.childCount+1}`},content:[{type:"paragraph"}]}).run(),requestAnimationFrame(()=>i(a.childCount))},"aria-label":"Add tab",title:"Add tab",className:"doc-tab-add",children:(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})})]}),(0,a.jsx)(M.NodeViewContent,{as:"div","data-tabs-body":!0,className:"doc-tabs-body"})]})}let lv=G.Node.create({name:"tabs",group:"block",content:"tabPanel+",parseHTML:()=>[{tag:"div[data-tabs]"}],renderHTML:()=>["div",{"data-tabs":""},0],addCommands(){return{insertTabs:()=>({commands:e})=>e.insertContent({type:this.name,content:[{type:"tabPanel",attrs:{label:"Tab 1"},content:[{type:"paragraph"}]},{type:"tabPanel",attrs:{label:"Tab 2"},content:[{type:"paragraph"}]}]})}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(ly)});var lw=e.i(951930),l_=e.i(822229),lk=e.i(698764),lk=lk,lN=e.i(149717),lN=lN,lE=e.i(431343);let lC="doc-present-slide",lS=[{id:"paper",name:"Paper",swatch:"#FFFFFF"},{id:"ink",name:"Ink",swatch:"#1E1E1C"},{id:"blue",name:"Blue",swatch:"#D8E4ED"},{id:"green",name:"Green",swatch:"#DDEDE1"},{id:"sand",name:"Sand",swatch:"#F0E6BD"},{id:"rose",name:"Rose",swatch:"#F1D8D8"}],lj=new Set(lS.map(e=>e.id));function lA({node:e,editor:t,getPos:n,updateAttributes:r,deleteNode:i}
2){let[l,o]=(0,s.useState)({index:0,total:1}),c=(0,s.useRef)(null),[d,u]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let e=()=>{let e="function"==typeof n?n():void 0,r=0,i=0;t.state.doc.descendants((t,n)=>"slide"!==t.type.name||(void 0!==e&&n<e&&(r+=1),i+=1,!1)),o({index:r,total:Math.max(i,1)})};return e(),t.on("update",e),()=>{t.off("update",e)}},[t,n]),(0,s.useEffect)(()=>{let e=c.current?.querySelector(".doc-slide-body");if(!e)return;let n=()=>u(e.scrollHeight-e.clientHeight>2);n();let r=new ResizeObserver(n);return r.observe(e),t.on("update",n),()=>{r.disconnect(),t.off("update",n)}},[t]);let h=lj.has(e.attrs.theme)?e.attrs.theme:"paper",p="top"===e.attrs.align?"top":"center";return(0,a.jsxs)(M.NodeViewWrapper,{as:"div",className:"doc-slide-shell","data-slide-shell":!0,children:[(0,a.jsxs)("div",{className:"doc-slide-meta",contentEditable:!1,children:[(0,a.jsxs)("span",{children:["Slide ",l.index+1]}),(0,a.jsxs)("span",{className:"doc-slide-meta-total",children:["of ",l.total]}),d&&(0,a.jsx)("span",{className:"doc-slide-meta-overflow",title:"Anything past the frame is cut off when you present",children:"Runs past the slide"})]}),(0,a.jsxs)("section",{ref:c,className:"doc-slide","data-slide":"","data-theme":h,"data-align":p,children:[(0,a.jsxs)("div",{className:"doc-slide-tools",contentEditable:!1,onMouseDown:e=>e.preventDefault(),children:[(0,a.jsx)("div",{className:"doc-slide-swatches",children:lS.map(e=>(0,a.jsx)("button",{type:"button",title:e.name,"aria-label":e.name,"aria-pressed":h===e.id,onClick:()=>r({theme:e.id}),className:"doc-slide-swatch","data-active":h===e.id?"":void 0,style:{backgroundColor:e.swatch}},e.id))}),(0,a.jsx)("span",{className:"doc-slide-tools-divider"}),(0,a.jsx)("button",{type:"button",className:"doc-slide-tool",title:"center"===p?"Align content to the top":"Centre the content",onClick:()=>r({align:"center"===p?"top":"center"}),children:"center"===p?(0,a.jsx)(lk.default,{className:"h-3.5 w-3.5"}):(0,a.jsx)(lN.default,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{type:"button",className:"doc-slide-tool",title:"Present from here",onClick:()=>{let e=t.view.dom.closest("[data-doc-id]")?.dataset.docId??null;window.dispatchEvent(new CustomEvent(lC,{detail:{index:l.index,docId:e}}))},children:(0,a.jsx)(lE.Play,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{type:"button",className:"doc-slide-tool",title:"Duplicate slide",onClick:()=>{let r="function"==typeof n?n():void 0;void 0!==r&&t.chain().focus().insertContentAt(r+e.nodeSize,e.toJSON()).run()},children:(0,a.jsx)(sG.Copy,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{type:"button",className:"doc-slide-tool",title:"Delete slide",onClick:()=>i(),children:(0,a.jsx)(sX.Trash2,{className:"h-3.5 w-3.5"})})]}),(0,a.jsx)(M.NodeViewContent,{className:"doc-slide-body"})]})]})}let lD=G.Node.create({name:"slide",group:"block",content:"block+",defining:!0,isolating:!0,addAttributes:()=>({theme:{default:"paper",parseHTML:e=>{let t=e.getAttribute("data-theme");return t&&lj.has(t)?t:"paper"},renderHTML:e=>({"data-theme":e.theme||"paper"})},align:{default:"center",parseHTML:e=>"top"===e.getAttribute("data-align")?"top":"center",renderHTML:e=>({"data-align":"top"===e.align?"top":"center"})}}),parseHTML:()=>[{tag:"section[data-slide]",contentElement:e=>e.querySelector(".doc-slide-body")??e}],renderHTML:({HTMLAttributes:e})=>["section",(0,G.mergeAttributes)(e,{"data-slide":"",class:"doc-slide"}),["div",{class:"doc-slide-body"},0]],addCommands(){return{insertSlide:(e={})=>({chain:t,state:n})=>{let r={type:this.name,attrs:{theme:e.theme||"paper",align:e.align||"center"},content:[{type:"heading",attrs:{level:1}},{type:"paragraph"}]},{$from:i}=n.selection,a=null;for(let e=i.depth;e>0;e--)if("slide"===i.node(e).type.name){a=i.after(e);break}let s=a??Math.max(0,n.selection.from-1);return(null===a?t().insertContent(r):t().insertContentAt(a,r)).command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=null;return e.doc.nodesBetween(s,e.doc.content.size,(e,t)=>null===n&&("slide"===e.type.name&&t>=s&&(n=t),null===n)),null!==n&&e.setSelection(T.TextSelection.near(e.doc.resolve(n+2))),!0}).run()}}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(lA)});var lM=e.i(23750),lT=e.i(167881),lO=e.i(626250),lI=e.i(955414),lL=e.i(524657),lR=e.i(647163);let lP=lL.STATUS_PASTEL_PALETTE[0].hex,lF=[{value:"percent",label:"Percent"},{value:"ratio",label:"Out of total"}];function lB({node:e,updateAttributes:t,editor:n}){let r=e.attrs,i=r.label??"Status",l=r.color??lP,o=(0,lI.toNumber)(r.value),c=(0,lI.safeTotal)(r.total),d="ratio"===r.format?"ratio":"percent",[u,h]=(0,s.use
2State)(!1),[p,m]=(0,s.useState)({label:i,value:"",total:"",format:d}),g="ratio"===p.format?p.total:"100",f=()=>{let e=(0,lI.toNumber)(p.value),n=(0,lI.toNumber)(g);t({label:p.label.trim()||"Status",value:e,total:n&&n>0?n:100,format:p.format}),h(!1)},b=(e,t)=>(0,a.jsx)(lM.Input,{type:"number",placeholder:t,value:p[e],onWheel:e=>e.target.blur(),onChange:t=>m(n=>({...n,[e]:t.target.value})),onKeyDown:e=>{"Enter"===e.key&&f(),"Escape"===e.key&&h(!1)},className:"h-8"});return(0,a.jsx)(M.NodeViewWrapper,{as:"span",className:"inline-flex max-w-full align-middle",children:(0,a.jsxs)(lt.Popover,{open:u,onOpenChange:e=>{n.isEditable&&(e&&m({label:i,value:null===o?"":String(o),total:String(c),format:d}),h(e))},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("span",{contentEditable:!1,className:(0,lR.cn)("inline-flex align-middle",n.isEditable&&"cursor-pointer"),children:null===o?(0,a.jsx)(lI.StatusPill,{label:i,color:l}):(0,a.jsx)(lI.ProgressPill,{value:o,total:c,format:d,className:"w-28"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-72 space-y-3 p-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",children:"Label"}),(0,a.jsx)(lM.Input,{autoFocus:!0,value:p.label,placeholder:"Status",onChange:e=>m(t=>({...t,label:e.target.value})),onKeyDown:e=>{"Enter"===e.key&&f(),"Escape"===e.key&&h(!1)},className:"h-8"}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Shown when there is no value. Leave the value empty for a plain status pill."})]}),(0,a.jsxs)("div",{className:(0,lR.cn)("grid gap-2","ratio"===p.format&&"grid-cols-2"),children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",children:"Value"}),b("value","empty")]}),"ratio"===p.format&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",children:"Out of"}),b("total","100")]})]}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",children:"Show as"}),(0,a.jsx)("div",{className:"flex gap-1",children:lF.map(e=>(0,a.jsx)(lT.Button,{type:"button",size:"sm",variant:p.format===e.value?"secondary":"outline",onClick:()=>m(t=>({...t,format:e.value})),className:"h-7 flex-1 text-xs",children:e.label},e.value))}),(0,a.jsxs)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:["Preview: ",(0,lI.formatProgress)(p.value,g,p.format)]})]}),null===(0,lI.toNumber)(p.value)&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("label",{className:"text-[11px] text-muted-foreground",children:"Colour"}),(0,a.jsx)(lO.StatusColorField,{value:l,onChange:e=>t({color:e})})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)(lT.Button,{variant:"ghost",size:"sm",onClick:()=>h(!1),children:"Cancel"}),(0,a.jsx)(lT.Button,{size:"sm",onClick:f,children:"Save"})]})]})]})})}let lU=G.Node.create({name:"statusPill",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({label:{default:"Status",parseHTML:e=>e.getAttribute("data-label")||e.textContent?.trim()||"Status",renderHTML:e=>({"data-label":String(e.label??"Status")})},color:{default:lP,parseHTML:e=>e.getAttribute("data-color")||lP,renderHTML:e=>({"data-color":String(e.color??lP)})},value:{default:null,parseHTML:e=>(0,lI.toNumber)(e.getAttribute("data-value")??e.getAttribute("data-percent")),renderHTML:e=>{let t=(0,lI.toNumber)(e.value);return null===t?{}:{"data-value":String(t)}}},total:{default:100,parseHTML:e=>(0,lI.safeTotal)(e.getAttribute("data-total")),renderHTML:e=>({"data-total":String((0,lI.safeTotal)(e.total))})},format:{default:"percent",parseHTML:e=>"ratio"===e.getAttribute("data-format")?"ratio":"percent",renderHTML:e=>({"data-format":String(e.format??"percent")})}}),parseHTML:()=>[{tag:"span[data-status-pill]"}],renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs,r=(0,lI.toNumber)(n.value);return["span",(0,G.mergeAttributes)(t,{"data-status-pill":"",class:"doc-status-pill"}),null===r?n.label??"Status":(0,lI.formatProgress)(r,n.total,"ratio"===n.format?"ratio":"percent")]},addCommands(){return{insertStatusPill:e=>({chain:t})=>t().insertContent([{type:this.name,attrs:{label:"Status",color:lP,...e}},{type:"text",text:" "}]).run()}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(lB)});var l$=e.i(157734),lz=e.i(314743);let lq=/^(\d{4}-\d{2}-\d{2})(?:[T ](\d{2}:\d{2}))?/,lH=/(\d{1,4}[/-]\d{1,2}[/-]\d{1,4})|((jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\.?\s+\d{1,4})|(\d{1,2}\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec))/i;function lK(e){let t="string"==typeof e?e.trim():"";if(!t)return{date:"",time:""};let n=t.match(lq);if(n)return{date:n[1],time:n[2]??""};if(!lH.test(t))return{date:"",time:""};let r=new Date(t);return Number.isNaN(r.getTime())?{date:"",time:""}:{date:lV(r),time:""}}function lV(e){return`${e.getFullYear()}
2-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function lG(e){if(!e)return;let t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?void 0:t}function lW(e,t,n){return e?n&&t?`${e}T${t}`:e:""}function lZ(e){let{date:t,time:n}=lK(e),r=lG(t);if(!r)return"string"==typeof e?e:"";let i=r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),a=n?(0,lz.formatTimeValue)(n):"";return a?`${i} at ${a}`:i}function lJ(e,t){let n=lK(e),r=lK(t),i=lG(n.date),a=lG(r.date);if(!i||!a)return lZ(e);if(n.time||r.time)return`${lZ(e)} to ${lZ(t)}`;let s=i.getFullYear()===a.getFullYear(),l=s&&i.getMonth()===a.getMonth(),o=a.getFullYear(),c=e=>e.toLocaleDateString("en-US",{month:"short",day:"numeric"});return l?`${c(i)} to ${a.getDate()}, ${o}`:s?`${c(i)} to ${c(a)}, ${o}`:`${lZ(e)} to ${lZ(t)}`}function lX({node:e,updateAttributes:t,editor:n}){let r=e.attrs,i="string"==typeof r.value?r.value:"",l="string"==typeof r.end?r.end:"",o=!0===r.withTime,c=!0===r.range,{date:d,time:u}=lK(i),{date:h,time:p}
2=lK(l),m=lG(d),g=lG(h),f=c?lJ(i,l):lZ(i),[b,x]=(0,s.useState)(!1),y=(e,t)=>lW(lV(e),t||"09:00",o),v=e=>{e?(t({value:y(e,u)}),o||x(!1)):t({value:""})},w=e=>{t({value:e?.from?y(e.from,u):"",end:e?.to?y(e.to,p):""}),e?.from&&e?.to&&!o&&x(!1)};return(0,a.jsx)(M.NodeViewWrapper,{as:"span",className:"inline-flex max-w-full align-middle",children:(0,a.jsxs)(lt.Popover,{open:b,onOpenChange:e=>n.isEditable&&x(e),children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("span",{contentEditable:!1,className:(0,lR.cn)("entity-chip entity-chip-quiet inline-flex items-center rounded-full border px-2 pt-[0.28em] pb-[0.36em] align-middle leading-none tabular-nums transition-colors",n.isEditable&&"cursor-pointer",!f&&"text-muted-foreground"),children:f||(c?"Pick dates":"Pick a date")})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-auto p-0",children:[c?(0,a.jsx)(l$.Calendar,{mode:"range",selected:{from:m,to:g},onSelect:w,defaultMonth:m,numberOfMonths:2,captionLayout:"dropdown",autoFocus:!0}):(0,a.jsx)(l$.Calendar,{mode:"single",selected:m,onSelect:v,defaultMonth:m,captionLayout:"dropdown",autoFocus:!0}),o&&(0,a.jsxs)("div",{className:"flex items-center gap-2 border-t px-3 py-2",children:[(0,a.jsx)(lz.TimePicker,{value:u,onValueChange:e=>t({value:lW(d,e,!0)}),variant:"on-white",className:"w-full",inputClassName:"h-8 text-xs","aria-label":c?"Start time":"Time"}),c&&(0,a.jsx)(lz.TimePicker,{value:p,onValueChange:e=>t({end:lW(h,e,!0)}),variant:"on-white",className:"w-full",inputClassName:"h-8 text-xs","aria-label":"End time"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between border-t px-2 py-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{t({value:"",end:""}),x(!1)},className:"rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:"Clear"}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>t({range:!c,...c?{end:""}:{}}),className:"rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:c?"Single date":"Range"}),(0,a.jsx)("button",{type:"button",onClick:()=>{let e=new Date;c?w({from:e,to:g??e}):v(e)},className:"rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:o?"Now":"Today"})]})]})]})]})})}let lQ=G.Node.create({name:"docDate",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({value:{default:"",parseHTML:e=>e.getAttribute("data-value")??"",renderHTML:e=>({"data-value":String(e.value??"")})},end:{default:"",parseHTML:e=>e.getAttribute("data-end")??"",renderHTML:e=>({"data-end":String(e.end??"")})},withTime:{default:!1,parseHTML:e=>"true"===e.getAttribute("data-with-time"),renderHTML:e=>({"data-with-time":e.withTime?"true":"false"})},range:{default:!1,parseHTML:e=>"true"===e.getAttribute("data-range"),renderHTML:e=>({"data-range":e.range?"true":"false"})}}),parseHTML:()=>[{tag:"span[data-doc-date]"}],renderHTML({node:e,HTMLAttributes:t}
2){let n=e.attrs,r=!0===n.range?lJ(n.value,n.end):lZ(n.value);return["span",(0,G.mergeAttributes)(t,{"data-doc-date":"",class:"doc-date"}),r||"Pick a date"]},addCommands(){return{insertDocDate:e=>({chain:t})=>{let n=e?.withTime===!0,r=e?.range===!0,i=lV(new Date),a=new Date;return a.setDate(a.getDate()+7),t().insertContent([{type:this.name,attrs:{value:lW(i,"09:00",n),end:r?lW(lV(a),"17:00",n):"",withTime:n,range:r,...e}},{type:"text",text:" "}]).run()}}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(lX)});var lY=e.i(625959);function l0({node:e,updateAttributes:t,editor:n}){let r=!0===e.attrs.checked;return(0,a.jsx)(M.NodeViewWrapper,{as:"span",className:"inline-flex align-text-bottom",children:(0,a.jsx)(lY.Checkbox,{checked:r,disabled:!n.isEditable,onCheckedChange:e=>t({checked:!0===e}),tabIndex:-1,"aria-label":r?"Checked":"Unchecked",className:"mx-0.5 disabled:cursor-default disabled:opacity-100"})})}let l1=G.Node.create({name:"docCheckbox",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({checked:{default:!1,parseHTML:e=>"true"===e.getAttribute("data-checked"),renderHTML:e=>({"data-checked":e.checked?"true":"false"})}}),parseHTML:()=>[{tag:"span[data-doc-checkbox]"}],renderHTML({node:e,HTMLAttributes:t}){let n=!0===e.attrs.checked;return["span",(0,G.mergeAttributes)(t,{"data-doc-checkbox":"",class:"doc-checkbox"}),n?"â":"â"]},addCommands(){return{insertDocCheckbox:e=>({chain:t})=>t().insertContent([{type:this.name,attrs:{checked:!1,...e}},{type:"text",text:" "}]).run()}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(l0)});var l2=e.i(788699),l3=e.i(341256);let l5=lL.STATUS_PASTEL_PALETTE[0].hex,l4=lL.STATUS_PASTEL_PALETTE.slice(1).map(e=>e.hex);function l8(e,t){let n=new Set(e);return l4.find(e=>!n.has(e))??l4[t%l4.length]}function l6(e,t,n){if(!e)return t;try{let r=JSON.parse(e);return n(r)?r:t}catch{return t}}let l9=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),l7=e=>!!e&&"object"==typeof e&&!Array.isArray(e);function oe({node:e,updateAttributes:t,editor:n}){let r=e.attrs,i=Array.isArray(r.values)?r.values:[],l=Array.isArray(r.options)?r.options:[],o=r.colors??{}
2,c=!1!==r.multiple,[d,u]=(0,s.useState)(!1),[h,p]=(0,s.useState)(null),[m,g]=(0,s.useState)(!1),[f,b]=(0,s.useState)(""),x=e=>o[e]??l5,y=c?"rect":"pill",v=()=>{p(null),g(!1),b("")},w=(e,t)=>e?{options:l.includes(e)?l:[...l,e],colors:{...o,[e]:t??o[e]??l8(Object.values(o),l.length)}}:{options:l,colors:o},_=e=>{let n=w(e);if(c){t({...n,values:i.includes(e)?i.filter(t=>t!==e):[...i,e]}),b("");return}t({...n,values:[e]}),u(!1),b("")};return(0,a.jsx)(M.NodeViewWrapper,{as:"span",className:"inline-flex max-w-full align-middle",children:(0,a.jsxs)(lt.Popover,{open:d,onOpenChange:e=>{n.isEditable&&(u(e),e||v())},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("span",{contentEditable:!1,className:(0,lR.cn)("inline-flex max-w-full flex-wrap items-center gap-1 align-middle",n.isEditable&&"cursor-pointer"),children:i.length?i.map(e=>(0,a.jsx)(lI.StatusPill,{label:e,color:x(e),shape:y},e)):(0,a.jsx)(lI.StatusPill,{label:c?"Pick options":"Pick one",color:l5,shape:y,className:"text-muted-foreground"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-60 p-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 py-0.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:c?"Select any":"Select"}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>t({multiple:!c,values:c?i.slice(0,1):i}),className:"rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground",children:c?"One only":"Allow many"}),i.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>{t({values:[]}),c||u(!1)},className:"rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground",children:"Clear"})]})]}),(0,a.jsx)("div",{className:(0,lR.cn)(!h&&!m&&"max-h-56 overflow-auto"),children:l.map(e=>h===e?(0,a.jsx)(ot,{initialLabel:e,initialColor:x(e),submitLabel:"Save",onSubmit:(n,r)=>((e,n,r)=>{let a=n.trim()||e,s={};for(let[t,n]of Object.entries(o))s[t===e?a:t]=n;s[a]=r,t({options:l.map(t=>t===e?a:t),values:i.map(t=>t===e?a:t),colors:s}),p(null)})(e,n,r),onCancel:()=>p(null)},e):(0,a.jsxs)("div",{className:(0,lR.cn)("group/opt flex items-center gap-1 rounded-md px-2 py-1 transition-colors hover:bg-accent",!c&&i.includes(e)&&"bg-accent"),children:[(0,a.jsxs)("button",{type:"button",onClick:()=>_(e),className:"flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 text-left",children:[c&&(0,a.jsx)(lY.Checkbox,{checked:i.includes(e),tabIndex:-1,className:"pointer-events-none shrink-0"}),(0,a.jsx)(lI.StatusPill,{label:e,color:x(e),shape:y})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover/opt:opacity-100",children:[(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),g(!1),p(e)},className:"rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground","aria-label":`Edit ${e}`,children:(0,a.jsx)(l2.Pencil,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:n=>{let r;n.stopPropagation(),r={...o},delete r[e],t({options:l.filter(t=>t!==e),values:i.filter(t=>t!==e),colors:r})},className:"rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive","aria-label":`Delete ${e}`,children:(0,a.jsx)(l3.TrashIcon,{className:"size-3"})})]})]},e))}),m?(0,a.jsx)("div",{className:"mt-1 border-t pt-1",children:(0,a.jsx)(ot,{initialLabel:f,initialColor:l8(Object.values(o),l.length),submitLabel:"Create",onSubmit:(e,n)=>{t(w(e.trim(),n)),v()},onCancel:v})}):(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-1 border-t pt-1",children:[(0,a.jsx)(lM.Input,{variant:"on-white",value:f,onChange:e=>b(e.target.value),onKeyDown:e=>{let t;"Enter"===e.key&&(t=f.trim())&&(b(""),i.includes(t)||_(t))},placeholder:"Add optionâ¦",className:"h-7 text-xs"}),(0,a.jsx)("button",{type:"button",onClick:()=>{p(null),g(!0)},className:"rounded p-1 text-muted-foreground hover:bg-accent","aria-label":"Add option with a color",title:"Add option with a color",children:(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})})]})]})]})})}function ot({initialLabel:e,initialColor:t,submitLabel:n,onSubmit:r,onCancel:i}
2){let[l,o]=(0,s.useState)(e),[c,d]=(0,s.useState)(t),u=()=>{l.trim()&&r(l.trim(),c)};return(0,a.jsxs)("div",{className:"space-y-2.5 p-2",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&u(),"Escape"===e.key&&i()},children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(lM.Input,{autoFocus:!0,variant:"on-white",placeholder:"Option name",value:l,onChange:e=>o(e.target.value),className:"h-7 flex-1 text-xs"}),(0,a.jsx)("button",{type:"button",onClick:i,className:"shrink-0 p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Cancel",children:(0,a.jsx)(w.X,{className:"size-3"})})]}),(0,a.jsx)(lO.StatusColorField,{value:c,onChange:d}),(0,a.jsx)("button",{type:"button",onClick:u,disabled:!l.trim(),className:"h-7 w-full rounded-md bg-foreground text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:cursor-not-allowed disabled:opacity-40",children:n})]})}let on=G.Node.create({name:"docMultiSelect",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({values:{default:[],parseHTML:e=>l6(e.getAttribute("data-values"),[],l9),renderHTML:e=>({"data-values":JSON.stringify(e.values??[])})},options:{default:[],parseHTML:e=>l6(e.getAttribute("data-options"),[],l9),renderHTML:e=>({"data-options":JSON.stringify(e.options??[])})},colors:{default:{},parseHTML:e=>l6(e.getAttribute("data-colors"),{},l7),renderHTML:e=>({"data-colors":JSON.stringify(e.colors??{})})},multiple:{default:!0,parseHTML:e=>"false"!==e.getAttribute("data-multiple"),renderHTML:e=>({"data-multiple":!1===e.multiple?"false":"true"})}}),parseHTML:()=>[{tag:"span[data-doc-multi-select]"}],renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs,r=Array.isArray(n.values)?n.values:[];return["span",(0,G.mergeAttributes)(t,{"data-doc-multi-select":"",class:"doc-multi-select"}),r.join(", ")]},addCommands(){return{insertDocMultiSelect:e=>({chain:t})=>t().insertContent([{type:this.name,attrs:{values:[],options:[],colors:{},multiple:!0,...e}},{type:"text",text:" "}]).run()}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(oe)});var or=e.i(477183),oi=e.i(76590),oa=e.i(807311),os=e.i(786350),ol=e.i(156084),oo=e.i(463059),oc=e.i(975558),od=e.i(425063),ou=e.i(687130),oh=e.i(88081),op=e.i(87316),om=e.i(473708),og=e.i(569074),of=e.i(649582),ob=e.i(286536),ox=e.i(77705),oy=e.i(680676),oy=oy,ov=e.i(947627),ow=e.i(463415),o_=e.i(447170),ok=e.i(630374),oN=e.i(195898),oE=or,oC=e.i(398361),oS=e.i(740043),oj=e.i(651035);let oA="group:",oD="white-surface rounded-[0.75rem] bg-card";function oM(e){return null==e||""===e||!!Array.isArray(e)&&0===e.length}function oT(e,t){let n=e.cells[t.id];return Array.isArray(n)?n[0]??"":"string"==typeof n?n:null==n?"":String(n)}function oO(e){return null==e?"":Array.isArray(e)?e.join(", "):cX(e)||cQ(e)||cY(e)?e.name:String(e)}function oI(e){let t=e.target,n=e.currentTarget;if(!(t instanceof Element)||!(n instanceof Element)||!n.contains(t))return!1;let r=t.closest('input, textarea, select, [contenteditable="true"], [data-no-dnd]');return!r||!n.contains(r)}class oL extends oE.MouseSensor{static activators=[{eventName:"onMouseDown",handler:e=>0===e.nativeEvent.button&&oI(e)}]}class oR extends oE.TouchSensor{static activators=[{eventName:"onTouchStart",handler:e=>oI(e)}]}function oP({columns:e,rows:t,groupCol:n,hidden:r,optionColor:i,onMove:o,onAddCard:c,onOpenCard:d,onSetCell:u,onReorderGroups:h,onAddGroup:p,renderCardIcon:m,renderCell:g,renderGroupEditor:f,renderNewProperty:b}){let x=e[0],y=(0,s.useMemo)(()=>n.options??[],[n.options]),v=(0,s.useMemo)(()=>{let e=[];for(let r of t){let t=oT(r,n);!t||y.includes(t)||e.includes(t)||e.push(t)}return[...y,...e,""]},[t,n,y]),w=(0,s.useMemo)(()=>{let e=Object.fromEntries(v.map(e=>[e,[]]));for(let r of t)e[oT(r,n)]?.push(r.id);return e},[t,v,n]),[_,k]=(0,s.useState)(null),[N,E]=(0,s.useState)(null),C=_&&(N||_.from===w)?_.lists:w,S=(0,s.useRef)(C),j=(0,s.useRef)(null),A=(0,s.useRef)(null),D=(0,s.useRef)(!1);(0,s.useLayoutEffect)(()=>{S.current=C,j.current=N}),(0,s.useEffect)(()=>{let e=requestAnimationFrame(()=>{D.current=!1});return()=>cancelAnimationFrame(e)},[C]);let M=(0,s.useCallback)(e=>{let t=(0,oE.pointerWithin)(e),n=t.length>0?t:(0,oE.rectIntersection)(e),r=(0,oE.getFirstCollision)(n,"id");if(null!=r){let t=String(r);if(t.startsWith(oA)){let n=S.current[t.slice(oA.length)]??[];n.length>0&&(r=(0,oE.closestCenter)({...e,droppableContainers:e.droppableContainers.filter(e=>n.includes(String(e.id)))})[0]?.id??r)}return A.current=r,[{id:r}]}return D.current&&(A.current=j.current),null!=A.current?[{id:A.current}]:[]},[]),T=(0,s.useMemo)(()=>new Map(t.map(e=>
2[e.id,e])),[t]),[O,I]=(0,s.useState)(null),[L,R]=(0,s.useState)({}),[P,F]=(0,s.useState)(null),[B,U]=(0,s.useState)(null),$=(0,oE.useSensors)((0,oE.useSensor)(oL,{activationConstraint:{distance:6}}),(0,oE.useSensor)(oR,{activationConstraint:{delay:220,tolerance:8}})),z=(e,t)=>{if(e.startsWith(oA)){let n=e.slice(oA.length);return n in t?n:null}for(let n of Object.keys(t))if(t[n].includes(e))return n;return null},q=N?T.get(N):void 0,H=t=>({row:t,columns:e,titleCol:x,groupCol:n,hidden:r,revealed:L[t.id]??[],icon:m(t)});return(0,a.jsxs)(oE.DndContext,{sensors:$,collisionDetection:M,onDragStart:e=>{E(String(e.active.id)),k({lists:w,from:w})},onDragOver:({active:e,over:t})=>{if(!t)return;let n=String(e.id),r=String(t.id);k(e=>{let t=e?.lists??w,i=z(n,t),a=z(r,t);if(!i||!a||i===a)return e;let s=t[a].filter(e=>e!==n),l=s.indexOf(r);return s.splice(-1===l?s.length:l,0,n),D.current=!0,{lists:{...t,[i]:t[i].filter(e=>e!==n),[a]:s},from:e?.from??w}})},onDragEnd:({active:e,over:t})=>{let n=String(e.id),r=_?.lists??w;E(null);let i=t?z(n,r):null;if(!t||!i)return void k(null);let a=r[i],s=a.indexOf(String(t.id)),l=a.indexOf(n);(-1!==s&&-1!==l&&s!==l&&(a=(0,oi.arrayMove)(a,l,s)),z(n,w)===i&&w[i].length===a.length&&w[i].every((e,t)=>a[t]===e))?k(null):(k({lists:{...r,[i]:a},from:w}),o(n,i,a))},onDragCancel:()=>{E(null),k(null)},children:[(0,a.jsx)(ol.DragHaptics,{}),(0,a.jsxs)("div",{"data-doc-board":"",className:"doc-table-board flex items-start gap-3 overflow-x-auto pb-2",children:[v.map(e=>{let t=C[e]??[];if(""===e&&0===t.length&&!N)return null;let r=y.includes(e);return(0,a.jsx)(oF,{value:e,label:e||`No ${n.name||"value"}`,color:e?i(e):null,ids:t,editable:r,renderEditor:t=>f(e,t),isHeaderDragOver:B===e&&P!==e,onHeaderDragStart:()=>F(e),onHeaderDragOver:()=>{null!==P&&r&&U(e)},onHeaderDrop:()=>{null===P||P===e||y.includes(P)&&y.includes(e)&&h((0,oi.arrayMove)(y,y.indexOf(P),y.indexOf(e))),F(null),U(null)},onHeaderDragEnd:()=>{F(null),U(null)},onAdd:()=>{let t=c(e);t&&I(t)},children:t.map(e=>{let t=T.get(e);return t?(0,a.jsx)(oB,{id:e,onOpen:()=>d(e),children:(0,a.jsx)(oU,{...H(t),editingTitle:O===e,onEditTitle:t=>I(t?e:null),onSetCell:u,onOpen:()=>d(e),onReveal:t=>R(n=>({...n,[e]:[...n[e]??[],t]})),renderCell:g,renderNewProperty:b})},e):null})},e||"__empty__")}),(0,a.jsx)(oH,{onAdd:p,existing:y})]}),"u">typeof document&&(0,l.createPortal)((0,a.jsx)(oE.DragOverlay,{dropAnimation:{duration:160,easing:"cubic-bezier(0.2, 0, 0, 1)"},children:q?(0,a.jsx)("div",{className:(0,lR.cn)(oD,"w-[15rem] rotate-2 shadow-[0_8px_24px_rgba(0,0,0,0.12)]"),children:(0,a.jsx)(oU,{...H(q),preview:!0})}):null}),document.body)]})}function oF({value:e,label:t,color:n,ids:r,editable:i,renderEditor:l,isHeaderDragOver:o,onHeaderDragStart:c,onHeaderDragOver:d,onHeaderDrop:u,onHeaderDragEnd:h,onAdd:p,children:m}){let{setNodeRef:g,isOver:f}=(0,oE.useDroppable)({id:`${oA}${e}`}
2),[b,x]=(0,s.useState)(!1),y=n?(0,a.jsx)(lI.StatusDot,{color:n,className:"size-2.5"}):(0,a.jsx)("span",{className:"size-2.5 shrink-0 rounded-full border border-dashed border-muted-foreground/50"});return(0,a.jsxs)("div",{ref:g,className:(0,lR.cn)("flex w-[16rem] min-w-[16rem] shrink-0 flex-col overflow-hidden rounded-[20px] border bg-light-oat dark:bg-secondary",f?"border-dashed border-muted-foreground/30":"border-card-border",o&&"ring-2 ring-foreground/10"),children:[(0,a.jsxs)("div",{className:(0,lR.cn)("mx-3 flex shrink-0 items-center gap-1.5 border-b border-border/60 py-2",i&&"cursor-grab active:cursor-grabbing"),draggable:i&&!b,onDragStart:e=>{i&&(e.stopPropagation(),e.dataTransfer.effectAllowed="move",c())},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),d()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),u()},onDragEnd:h,children:[i?(0,a.jsxs)(lt.Popover,{open:b,onOpenChange:x,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",title:"Rename or recolor",className:"-ml-1.5 flex min-w-0 items-center gap-2 rounded-lg [corner-shape:squircle] squircle-safari-fallback px-1.5 py-1 hover:bg-accent data-[state=open]:bg-accent",children:[y,(0,a.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:t})]})}),(0,a.jsx)(lt.PopoverContent,{align:"start",className:"w-60 p-1",children:l(()=>x(!1))})]}):(0,a.jsxs)("span",{className:"flex min-w-0 items-center gap-2 py-1",children:[y,(0,a.jsx)("span",{className:"min-w-0 truncate text-sm font-medium",children:t})]}),(0,a.jsx)("span",{className:"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:r.length}),(0,a.jsx)("button",{type:"button",onClick:p,"aria-label":`New card in ${t}`,className:"ml-auto inline-flex h-6 w-6 shrink-0 items-center justify-center squircle text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})})]}),(0,a.jsx)(oi.SortableContext,{items:r,strategy:oi.verticalListSortingStrategy,children:(0,a.jsxs)("div",{className:"flex min-h-12 flex-col gap-2 p-2",children:[m,(0,a.jsxs)("button",{type:"button",onClick:p,className:"flex items-center gap-1.5 rounded-[0.75rem] px-2 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})," New"]})]})})]})}function oB({id:e,onOpen:t,children:n}){let{attributes:r,listeners:i,setNodeRef:s,transform:l,transition:o,isDragging:c}=(0,oi.useSortable)({id:e}),{onKeyDown:d,...u}=i??{};return(0,a.jsx)("div",{ref:s,style:{transform:oa.CSS.Translate.toString(l),transition:o},...r,...u,tabIndex:-1,onClick:e=>{let n=e.target;!e.currentTarget.contains(n)||n.closest('a, button, input, textarea, label, [role="checkbox"], [data-card-field]')||t()},className:(0,lR.cn)(oD,"group/card relative touch-manipulation transition-shadow hover:shadow-[0_1px_4px_rgba(0,0,0,0.08)]",c&&"opacity-30"),children:n})}function oU({row:e,columns:t,titleCol:n,groupCol:r,hidden:i,revealed:s,icon:l,preview:o=!1,editingTitle:c=!1,onEditTitle:d,onSetCell:u,onOpen:h,onReveal:p,renderCell:m,renderNewProperty:g}){let f=t.filter(e=>e.id!==n.id&&e.id!==r.id&&!i.includes(e.id)),b=function(e,t){for(let n of t){let t=e.cells[n.id];if(cY(t)&&"image"===t.kind)return{col:n,media:t}}return null}(e,f),x=f.filter(t=>t.id!==b?.col.id&&("checkbox"===t.type||!oM(e.cells[t.id])||s.includes(t.id))),y=f.filter(e=>!x.includes(e)&&e.id!==b?.col.id),v=e.cells[n.id],w=cX(v)?v:null,_=!o&&("text"===n.type||"url"===n.type),k=oO(v);return(0,a.jsxs)("div",{children:[b&&(0,a.jsx)("img",{src:b.media.url,alt:b.media.name,draggable:!1,className:"h-28 w-full rounded-t-[0.75rem] object-cover"}),!o&&h&&(0,a.jsx)("button",{type:"button",onClick:h,"aria-label":"Open",title:"Open",className:"absolute right-1.5 top-1.5 z-10 inline-flex h-6 w-6 items-center justify-center squircle bg-card text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 group-hover/card:opacity-100",children:(0,a.jsx)(oC.Maximize2,{className:"h-3 w-3"})}),(0,a.jsxs)("div",{className:"space-y-0.5 p-3",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 pr-5",children:[l,w?(0,a.jsx)("span",{"data-no-dnd":"",onClick:e=>e.stopPropagation(),children:(0,a.jsx)(oS.MentionPill,{type:w.type,id:w.id,name:w.name,variant:"pill"})}):_&&c?(0,a.jsx)(o$,{initial:k,onDone:t=>{t!==k&&u?.(e.id,n.id,t),d?.(!1)}}):(0,a.jsx)("p",{onClick:_?e=>{e.stopPropagation(),d?.(!0)}:void 0,className:(0,lR.cn)("min-w-0 flex-1 break-words text-sm font-medium leading-6",_&&"cursor-text",!k&&"text-muted-foreground
2/60"),children:k||"Untitled"})]}),x.map(t=>{let n=e.cells[t.id];if("checkbox"===t.type)return(0,a.jsxs)("label",{"data-card-field":"",className:"flex w-fit cursor-pointer items-center gap-1.5 py-1 text-xs text-muted-foreground",children:[(0,a.jsx)(lY.Checkbox,{checked:!!n,disabled:o,onCheckedChange:n=>u?.(e.id,t.id,!0===n)}),(0,a.jsx)("span",{className:(0,lR.cn)(n?"text-foreground":void 0),children:t.name})]},t.id);let r=oM(n);return(0,a.jsxs)("div",{"data-card-field":"",title:t.name,className:"flex min-w-0 items-center gap-1",children:[r&&(0,a.jsx)("span",{className:"shrink-0 truncate text-xs text-muted-foreground/70",children:t.name}),(0,a.jsx)("div",{className:"doc-card-field min-w-0 flex-1",children:o||!m?(0,a.jsx)(oz,{col:t,value:n}):m(e,t)})]},t.id)}),!o&&g&&p&&(0,a.jsx)(oq,{emptyCols:y,onReveal:p,renderNewProperty:g})]})]})}function o$({initial:e,onDone:t}){let n=(0,s.useRef)(null),r=()=>{let e=n.current;e&&(e.style.height="0px",e.style.height=`${e.scrollHeight}px`)};return(0,s.useLayoutEffect)(()=>{r();let e=n.current;e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},[]),(0,a.jsx)("textarea",{ref:n,rows:1,defaultValue:e,placeholder:"Untitled",onInput:r,onClick:e=>e.stopPropagation(),onBlur:e=>t(e.target.value.replace(/\s*\n\s*/g," ").trim()),onKeyDown:t=>{("Enter"===t.key||"Escape"===t.key)&&(t.preventDefault(),"Escape"===t.key&&(t.currentTarget.value=e),t.currentTarget.blur())},className:"min-w-0 flex-1 resize-none overflow-hidden bg-transparent text-sm font-medium leading-6 outline-none placeholder:text-muted-foreground/60"})}function oz({col:e,value:t}){if(oM(t))return(0,a.jsx)("span",{className:"px-1 text-xs text-muted-foreground/40",children:"-"});if("select"===e.type||"multiselect"===e.type){let n=Array.isArray(t)?t:[String(t)];return(0,a.jsx)("div",{className:"flex flex-wrap gap-1 py-1",children:n.map(t=>(0,a.jsx)(lI.StatusPill,{label:t,color:e.optionColors?.[t]??l5,shape:"multiselect"===e.type?"rect":"pill"},t))})}return void 0!==t&&cQ(t)?(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 px-1 py-1 text-xs",children:[(0,a.jsx)(oj.UserAvatar,{name:t.name}),(0,a.jsx)("span",{className:"truncate",children:t.name})]}):(0,a.jsx)("p",{className:"truncate px-1 py-1 text-xs text-muted-foreground",children:oO(t)})}function oq({emptyCols:e,onReveal:t,renderNewProperty:n}
2){let[r,i]=(0,s.useState)(!1),[l,o]=(0,s.useState)(!1);return(0,a.jsxs)(lt.Popover,{open:r,onOpenChange:e=>{i(e),e||o(!1)},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",className:"-ml-1 flex items-center gap-1 rounded-md px-1 py-0.5 text-xs text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground focus-visible:opacity-100 group-hover/card:opacity-100 data-[state=open]:opacity-100",children:[(0,a.jsx)(lb.Plus,{className:"h-3 w-3"})," Property"]})}),(0,a.jsx)(lt.PopoverContent,{align:"start",className:(0,lR.cn)("p-1",l?"w-56":"w-52"),children:l?n(e=>{t(e),i(!1),o(!1)}):(0,a.jsxs)(a.Fragment,{children:[e.length>0&&(0,a.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground",children:"Add to this card"}),e.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>{t(e.id),i(!1)},className:"flex w-full items-center rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-left text-sm hover:bg-accent",children:(0,a.jsx)("span",{className:"truncate",children:e.name})},e.id)),e.length>0&&(0,a.jsx)("div",{className:"my-1 h-px bg-border"}),(0,a.jsxs)("button",{type:"button",onClick:()=>o(!0),className:"flex w-full items-center gap-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-left text-sm hover:bg-accent",children:[(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5 text-muted-foreground"})," New property"]})]})})]})}function oH({onAdd:e,existing:t}){let[n,r]=(0,s.useState)(!1),[i,l]=(0,s.useState)(""),o=()=>{let n=i.trim();n&&!t.includes(n)&&e(n),l(""),r(!1)};return n?(0,a.jsx)("div",{className:"w-[16rem] min-w-[16rem] shrink-0",children:(0,a.jsx)("input",{autoFocus:!0,value:i,onChange:e=>l(e.target.value),onBlur:o,onKeyDown:e=>{"Enter"===e.key&&o(),"Escape"===e.key&&(l(""),r(!1))},placeholder:"Group name",className:"h-9 w-full rounded-[12px] [corner-shape:squircle] squircle-field-fallback border border-transparent bg-lighter-oat px-3 text-sm outline-none placeholder:text-muted-foreground dark:bg-black"})}):(0,a.jsxs)("button",{type:"button",onClick:()=>r(!0),className:"inline-flex h-9 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-[12px] [corner-shape:squircle] squircle-safari-fallback px-3 text-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:[(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})," New group"]})}var oK=e.i(714468),oV=e.i(428605);let oG={people:"contact",contacts:"contact",companies:"company",deals:"deal",plans:"plan"},oW=RegExp("^(?:https?://[^/\\s]+)?/(people|contacts|companies|deals|plans)/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})(?:[/?#][^\\s)]*)?$"),oZ=/^\[([^\]]+)\]\(([^)\s]+)\)$/,oJ=/^<a\b[^>]*\bhref=(["'])([^"']+)\1[^>]*>([\s\S]*?)<\/a>$/i;var oX=e.i(609216),oQ=e.i(773993);let oY=null,o0=null;var o1=e.i(86906);function o2(e,t){let n=e.target;if(!(n instanceof Element))return!1;if(t instanceof Element&&!t.contains(n))return!0;let r=n.closest('input, textarea, select, option, [contenteditable="true"], [data-no-dnd]');return!!r&&t instanceof Element&&t.contains(r)}class o3 extends or.MouseSensor{static activators=[{eventName:"onMouseDown",handler:({nativeEvent:e,currentTarget:t})=>0===e.button&&!o2(e,t)}]}class o5 extends or.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:e,currentTarget:t})=>!o2(e,t)}]}let o4=[{type:"text",label:"Text",icon:sN.Type},{type:"number",label:"Number",icon:oh.Hash},{type:"date",label:"Date",icon:op.Calendar},{type:"checkbox",label:"Checkbox",icon:sD.CheckSquare},{type:"select",label:"Select",icon:sj.List},{type:"multiselect",label:"Multi-select",icon:s3.ListChecks},{type:"url",label:"URL",icon:sU.Link},{type:"media",label:"Media",icon:om.Image},{type:"progress",label:"Progress",icon:sQ.Percent},{type:"record",label:"Record",icon:oQ.PeopleIcon},{type:"person",label:"Person",icon:oy.default}],o8=[{value:"date",label:"Date"},{value:"datetime",label:"Date and time"}],o6=[{value:"percent",label:"Percentage"},{value:"ratio",label:"Value out of total"}],o9=/^(image|video)\/|^application\/pdf$/;async function o7(e){let t=new FormData;t.append("file",e);let n=await fetch("/api/docs/upload-media",{method:"POST",body:t});return n.ok?n.json():(console.error("[doc-table] media upload failed",n.status),null)}let ce=Object.fromEntries(o4.map(e=>[e.type,e.icon]));function ct(e){return null===e.icon||""===e.icon}function cn({col:e,className:t}){if(ct(e))return null;if("string"==typeof e.icon&&e.icon.length>0)return(0,a.jsx)(lr.DocIcon,{icon:e.icon,size:12,className:(0,lR.cn)("leading-none",t)});let n=ce[e.type];return(0,a.jsx)(n,{className:(0,lR.cn)("h-3 w-3 shrink-0 opacity-60",t)})}let cr=[{name:"Gray",value:"#E6E6E1"},{name:"Blue",value:"#D8E4ED"},{name:"Green",value:"#DDEDE1"},{name:"Yellow",value:"#F0E6BD"},{name:"Red",value:"#F1D8D8"},{name:"Purple",value:"#E3D9EE"}],ci=cr[0].value,ca="#3f3f46";function cs(e){return"select"===e.type||"multiselect"===e.type}function cl(e){if("ratio"!==co(e))return 100;let t=e.progressTotal;return"number"==typeof t&&t>0?t:100}function co(e){return"ratio"===e.progressFormat?"ratio":"percent"}function cc(e,t){return`[data-doc-cell="${e}:${t}"]`}function cd(e,t,n){let r=e.querySelector(cc(t,n));r&&(r.focus({preventScroll:!1}),r.scrollIntoView({block:"nearest",inline:"nearest"}))}function cu(e,t){if(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement))return!0;let n=e.selectionStart??0,r=e.selectionEnd??0;return n===r&&("left"===t?0===n:r===e.value.length)}let ch=new Set(["text","number","url","progress","record","select","multiselect","person"]),cp=new Set(["text","number","url"]);function cm(e){if(!e)return null;let t=e.indexOf(":");return t<=0?null:{rowId:e.slice(0,t),colId:e.slice(t+1)}}function cg(e){return"checkbox"!==e.type&&("multiselect"===e.type?[]:"")}function cf({rootRef:e,anchor:t,focus:n,onExtendTo:r}
2){let[i,o]=(0,s.useState)(null),c=(0,o1.usePaneContainer)(),d=()=>{let r=e.current;if(!r||!t||!n)return void o(null);let i=r.querySelector(cc(t.rowId,t.colId)),a=r.querySelector(cc(n.rowId,n.colId));if(!i||!a)return void o(null);let s=i.getBoundingClientRect(),l=a.getBoundingClientRect(),c=Math.min(s.top,l.top),d=Math.min(s.left,l.left);o({top:c,left:d,width:Math.max(s.right,l.right)-d,height:Math.max(s.bottom,l.bottom)-c})};return((0,s.useLayoutEffect)(()=>{d();let t=e.current;if(!t||"u"<typeof ResizeObserver)return;let n=new ResizeObserver(()=>d());n.observe(t),t.querySelectorAll("[data-doc-cell]").forEach(e=>n.observe(e));let r=[window],i=t;for(;i;)r.push(i),i=i.parentElement;return r.forEach(e=>e.addEventListener("scroll",d,{capture:!0,passive:!0})),window.addEventListener("resize",d),()=>{n.disconnect(),r.forEach(e=>e.removeEventListener("scroll",d,!0)),window.removeEventListener("resize",d)}},[t?.rowId,t?.colId,n?.rowId,n?.colId]),i)?(0,l.createPortal)((0,a.jsx)("div",{className:"doc-cell-selection",style:{top:i.top,left:i.left,width:i.width,height:i.height},children:(0,a.jsx)("button",{type:"button",tabIndex:-1,"aria-label":"Extend selection",className:"doc-cell-selection-handle",onPointerDown:e=>{e.preventDefault(),e.stopPropagation();let t=e=>{let t=document.elementFromPoint(e.clientX,e.clientY),n=t?.closest("[data-doc-cell]"),i=cm(n?.getAttribute("data-doc-cell")??null);i&&r(i)},n=()=>{window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",n)};window.addEventListener("pointermove",t),window.addEventListener("pointerup",n)}})}),c??document.body):null}function cb(e){if(Array.isArray(e))return e.filter(e=>"string"==typeof e&&""!==e);let t=cy(e);return t?[t]:[]}function cx(e,t){return l8([...Object.values(e.optionColors??{}),...t],e.options?.length??0)}function cy(e){return null==e?"":"boolean"==typeof e?e?"true":"false":Array.isArray(e)?e.join(", "):cY(e)||cX(e)||cQ(e)?e.name:String(e)}let cv="application/x-everything-table-cell",cw=null;function c_(e){return e instanceof HTMLElement&&(!!e.closest('[data-slot="popover-content"]')||(e instanceof HTMLInputElement?"checkbox"!==e.type&&"radio"!==e.type:e instanceof HTMLTextAreaElement||e.isContentEditable))}function ck(e,t){let n=cy(t);if(!n)return n;if("progress"===e.type){let r=(0,lI.toNumber)(t);return null===r?n:`${n} ${(0,lI.formatProgress)(r,cl(e),"percent")} ${(0,lI.formatProgress)(r,cl(e),"ratio")}`}return"date"!==e.type?n:`${n} ${lZ(t)}`}function cN(e){let{date:t,time:n}=lK(e);return t?`${t} ${n}`:""}function cE({node:e,updateAttributes:t}){let n=e.attrs.data??c2(),{columns:r,rows:i}
2=n,[l,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),[u,h]=(0,s.useState)(null),[p,m]=(0,s.useState)({}),[g,b]=(0,s.useState)([]),[x,y]=(0,s.useState)({}),v=(0,s.useRef)(null),[_,k]=(0,s.useState)({}),[N,E]=(0,s.useState)(null),[C,S]=(0,s.useState)(new Set),j=(0,s.useRef)(null),A=(0,s.useRef)(null),[D,T]=(0,s.useState)(null),[O,I]=(0,s.useState)(null),L=(0,s.useRef)(null),R=(0,s.useRef)(null);L.current=D,R.current=O;let[P,F]=(0,s.useState)(null);(0,s.useEffect)(()=>{P&&F(null)},[P]);let B=function(){let[e,t]=(0,s.useState)(oY??[]);return(0,s.useEffect)(()=>{if(oY)return;let e=!0;return(oY?Promise.resolve(oY):o0??=fetch("/api/workspace/members").then(e=>e.ok?e.json():{members:[]}).then(e=>oY=(e.members??[]).map(e=>({id:e.user_id,name:e.profile?.full_name?.trim()||e.profile?.email||"Teammate",email:e.profile?.email??null,avatarUrl:e.profile?.avatar_url??null}))).catch(()=>(o0=null,[]))).then(n=>{e&&t(n)}),()=>{e=!1}},[]),e}(),U=(0,or.useSensors)((0,or.useSensor)(o3,{activationConstraint:{distance:8}}),(0,or.useSensor)(o5,{activationConstraint:{delay:220,tolerance:8}})),$=e=>t({data:{...n,...e}}),z=e=>$({...n,columns:e}),q=(e,t)=>z(r.map(n=>n.id===e?{...n,...t}:n)),H=(e,t)=>{let n={id:c1(),name:e.trim()||"Untitled",type:t};return("select"===t||"multiselect"===t)&&(n.options=[]),$({columns:[...r,n],rows:i.map(e=>({...e,cells:{...e.cells,[n.id]:"checkbox"!==t&&""}}))}),n.id},K=()=>{let e=c1(),t=Object.fromEntries(r.map(e=>[e.id,"checkbox"!==e.type&&""]));return $({...n,rows:[...i,{id:e,cells:t}]}),e},V=e=>$({...n,rows:i.filter(t=>t.id!==e)}),G=(e,t,r)=>$({...n,rows:i.map(n=>n.id===e?{...n,cells:{...n.cells,[t]:r}}:n)}),W=(e,t)=>$({...n,rows:i.map(n=>n.id===e?{...n,...t}:n)}),Z=(e,t)=>`${e}:${t}`,J=async(e,t,n)=>{if(!o9.test(n.type))return;let a=Z(e,t);k(e=>({...e,[a]:!0}));try{let a=await o7(n);if(!a)return;let s={kind:a.kind,url:a.url,name:n.name.replace(/\.[^.]+$/,"")};$({columns:r.map(e=>e.id===t?{...e,type:"media",options:void 0}:e),rows:i.map(n=>n.id===e?{...n,cells:{...n.cells,[t]:s}}:n)})}finally{k(e=>{let t={...e};return delete t[a],t})}},X=(e,t,n)=>{let i=r.find(t=>t.id===e);!i||!cs(i)||!t||i.options?.includes(t)||q(e,{options:[...i.options??[],t],optionColors:{...i.optionColors??{},[t]:n??cx(i,[])}})},Q=(e,t)=>e.optionColors?.[t]??l5,Y=(e,t,n,a)=>{let s=r.find(t=>t.id===e);if(!s)return;let l=n.trim();if(!l)return;let o=l!==t&&!(s.options??[]).includes(l),c=o?l:t,d={...s.optionColors??{}};o&&delete d[t],d[c]=a,$({columns:r.map(n=>n.id===e?{...n,options:(n.options??[]).map(e=>e===t?c:e),optionColors:d}:n),rows:o?i.map(n=>{let r=n.cells[e];return Array.isArray(r)?r.includes(t)?{...n,cells:{...n.cells,[e]:r.map(e=>e===t?c:e)}}:n:r===t?{...n,cells:{...n.cells,[e]:c}}:n}):i})},ee=(e,t)=>{let n=r.find(t=>t.id===e);if(!n)return;let a={...n.optionColors??{}};delete a[t],$({columns:r.map(n=>n.id===e?{...n,options:(n.options??[]).filter(e=>e!==t),optionColors:a}:n),rows:i.map(n=>{let r=n.cells[e];return Array.isArray(r)?r.includes(t)?{...n,cells:{...n.cells,[e]:r.filter(e=>e!==t)}}:n:r===t?{...n,cells:{...n.cells,[e]:""}}:n})})},et=e=>{b(t=>t.includes(e)?(m(t=>{let n={...t};return delete n[e],n}),t.filter(t=>t!==e)):[...t,e])},en=null===u&&""===l.trim()&&0===g.length,er=(0,s.useMemo)(()=>{let e=[...i],t=l.trim().toLowerCase();for(let n of(t&&(e=e.filter(e=>r.some(n=>ck(n,e.cells[n.id]).toLowerCase().includes(t)))),g)){let t=(p[n]??"").trim().toLowerCase();if(!t)continue;let i=r.find(e=>e.id===n);e=e.filter(e=>(i?ck(i,e.cells[n]):cy(e.cells[n])).toLowerCase().includes(t))}if(u){let t=r.find(e=>e.id===u.colId),n="asc"===u.dir?1:-1;e.sort((e,r)=>{let i=e.cells[u.colId],a=r.cells[u.colId];return(t?.type==="number"||t?.type==="progress"?(Number(i)||0)-(Number(a)||0):t?.type==="checkbox"?!!i-!!a:t?.type==="date"?cN(i).localeCompare(cN(a)):cy(i).toLowerCase().localeCompare(cy(a).toLowerCase()))*n})}return e},[i,r,l,g,p,u]);(0,s.useEffect)(()=>{let e=A.current;if(!e)return;A.current=null;let t=j.current;t&&cd(t,e.rowId,e.colId)},[er]);let ei=()=>{let e=L.current,t=R.current;return e||t?e&&t?function(e,t,n,r){let i=n.indexOf(e.rowId),a=n.indexOf(t.rowId),s=r.indexOf(e.colId),l=r.indexOf(t.colId);if(i<0||a<0||s<0||l<0)return[t];let o=[],c=Math.min(i,a),d=Math.max(i,a),u=Math.min(s,l),h=Math.max(s,l);for(let e=c;e<=d;e++)for(let t=u;t<=h;t++)o.push({rowId:n[e],colId:r[t]});return o}(e,t,er.map(e=>e.id),r.map(e=>e.id)):[e??t]:[]},ea=()=>{let e=ei();if(!e.length)return;let t=new Set(e.map(e=>`${e.rowId}:${e.colId}`));$({...n,rows:i.map(e=>{let n=null;for(let i of r)t.has(`${e.id}:${i.id}`)&&(n||(n={...e.cells}),n[i.id]=cg(i));return n?{...e,cells:n}:e})})},es=e=>{let{key:t}=e;if(e.metaKey||e.ctrlKey||e.altKey||e.isComposing)return;let n=j.current;if(!n)return;let i=e.target;if(!i||!n.contains(i)||i.closest('[data-slot="popover-content"]'))return;if(1===t.length&&!c_(i)){let n=i.closest("[data-doc-cell]"),a=cm(n?.getAttribute("data-doc-cell")??null);if(n&&a){if(" "===t&&i.closest('button, [role="checkbox"]'))return;e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();let n=r.find(e=>e.id===a.colId);if(!n||!ch.has(n.type))return;T(a),I(a),F({...a,text:t,n:e.timeStamp});return}}if("Backspace"===t||"Delete"===t){let t=ei();if(c_(i)&&t.length<=1||!t.length)return;e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),i instanceof HTMLElement&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName)&&i.blur(),ea();return}if("ArrowUp"!==t&&"ArrowDown"!==t&&"ArrowLeft"!==t&&"ArrowRight"!==t&&"Enter"!==t&&"Tab"!==t)return;let a=i.closest("[data-doc-cell]");if(!a)return;let s=cm(a.getAttribute("data-doc-cell"));if(!s)return;let l=e.shiftKey&&t.startsWith("Arrow"),{rowId:o,colId:c}
2=l&&R.current?R.current:s;if("ArrowLeft"===t&&!l&&!cu(i,"left")||"ArrowRight"===t&&!l&&!cu(i,"right"))return;let d=er.map(e=>e.id),u=r.map(e=>e.id),h=d.indexOf(o),p=u.indexOf(c);if(h<0||p<0||("ArrowUp"===t||"Enter"===t&&e.shiftKey&&!l?h-=1:"ArrowDown"===t||"Enter"===t?h+=1:"ArrowLeft"===t||"Tab"===t&&e.shiftKey?p-=1:("ArrowRight"===t||"Tab"===t)&&(p+=1),l?(h=Math.max(0,Math.min(d.length-1,h)),p=Math.max(0,Math.min(u.length-1,p))):p<0?(p=u.length-1,h-=1):p>=u.length&&(p=0,h+=1),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),i instanceof HTMLElement&&("INPUT"===i.tagName||"TEXTAREA"===i.tagName)&&!l&&i.blur(),h<0))return;if(h>=d.length){if("Enter"===t&&!e.shiftKey&&u[p]){let e=u[p];setTimeout(()=>{let t=ed.current();A.current={rowId:t,colId:e},T({rowId:t,colId:e}),I({rowId:t,colId:e})},0)}return}let m={rowId:d[h],colId:u[p]};if(l){L.current||T(s),I(m);return}T(m),I(m),cd(n,m.rowId,m.colId)},el=e=>{let t=j.current;return!t||e instanceof Node&&!t.contains(e)?null:R.current?R.current:e instanceof HTMLElement?cm(e.closest("[data-doc-cell]")?.getAttribute("data-doc-cell")??null):L.current},eo=e=>{let t=e.target,n="cut"===e.type;if(n&&c_(t))return;let a=el(t);if(!a||function(e){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return(e.selectionStart??0)!==(e.selectionEnd??0);let t=window.getSelection();return!!t&&0!==t.rangeCount&&!t.isCollapsed&&e instanceof Node&&!!t.anchorNode&&(e.contains(t.anchorNode)||t.anchorNode.parentElement?.closest("[data-doc-cell]")===e.closest?.("[data-doc-cell]"))}(t))return;let s=r.find(e=>e.id===a.colId),l=i.find(e=>e.id===a.rowId);if(!s||!l)return;let o=l.cells[s.id]??("checkbox"!==s.type&&""),c=function(e,t){let n={type:e.type,value:t};if(cs(e)){let r={};for(let n of cb(t)){let t=e.optionColors?.[n];t&&(r[n]=t)}Object.keys(r).length&&(n.optionColors=r)}return n}(s,o);cw=c;let d=function(e,t){if("date"===e.type)return lZ(t)||cy(t);if("progress"===e.type){let n=(0,lI.toNumber)(t);return null===n?"":(0,lI.formatProgress)(n,cl(e),co(e))}return"checkbox"===e.type?!0===t?"true":"":cy(t)}(s,o);e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),e.clipboardData?.setData("text/plain",d),e.clipboardData?.setData(cv,JSON.stringify(c)),n&&ea()},ec=e=>{let t=e.target;if(c_(t))return;let n=el(t);if(!n)return;let a=r.find(e=>e.id===n.colId);if(!a)return;let s=function(e,t,n){let r=t?.value,i=(n||(void 0!==r?cy(r):"")).trim();switch(e.type){case"media":return void 0!==r&&cY(r)?{value:r}:null;case"record":return void 0!==r&&cX(r)?{value:r}:null;case"person":return void 0!==r&&cQ(r)?{value:r}:null;case"checkbox":{if("boolean"==typeof r)return{value:r};let e=i.toLowerCase();if("true"===e||"yes"===e||"1"===e||"checked"===e)return{value:!0};if(""===e||"false"===e||"no"===e||"0"===e||"unchecked"===e)return{value:!1};return null}case"number":case"progress":{let e=(0,lI.toNumber)(r??i);if(null===e)return""===i?{value:""}:null;return{value:e}}case"date":{let{date:t,time:n}
2=lK("string"==typeof r&&r?r:i);if(!t)return""===i?{value:""}:null;return{value:lW(t,n,"datetime"===e.dateFormat)}}case"select":return{value:(void 0!==r?cb(r):i?[i]:[])[0]??"",optionColors:t?.optionColors};case"multiselect":return{value:void 0!==r?cb(r):i?i.split(/,\s*/).filter(Boolean):[],optionColors:t?.optionColors};default:if(void 0!==r&&(cY(r)||cX(r)||cQ(r)))return{value:r.name};if(t?.type==="date"&&"string"==typeof r)return{value:lZ(r)||r};if("boolean"==typeof r)return{value:r?"true":""};if("number"==typeof r)return{value:String(r)};if(Array.isArray(r))return{value:r.join(", ")};return{value:"string"==typeof r?r:i}}}(a,function(e){try{let t=JSON.parse(e);if(t&&"string"==typeof t.type&&"value"in t)return t}catch{}return null}(e.clipboardData?.getData(cv)??"")??cw,e.clipboardData?.getData("text/plain")??"");if(!s){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),cs(a)){let e=a.options??[],t=cb(s.value).filter(t=>!e.includes(t)),l={...a.optionColors??{}};for(let e of t)l[e]=s.optionColors?.[e]??cx(a,Object.values(l));$({columns:t.length?r.map(n=>n.id===a.id?{...n,options:[...e,...t],optionColors:l}:n):r,rows:i.map(e=>e.id===n.rowId?{...e,cells:{...e.cells,[a.id]:s.value}}:e)})}else G(n.rowId,a.id,s.value)},ed=(0,s.useRef)(K);ed.current=K;let eu=(0,s.useRef)(es);eu.current=es;let eh=(0,s.useRef)(eo);eh.current=eo;let ep=(0,s.useRef)(ec);ep.current=ec,(0,s.useEffect)(()=>{let e=e=>eu.current(e),t=e=>eh.current(e),n=e=>ep.current(e),r=e=>eh.current(e);return window.addEventListener("keydown",e,!0),window.addEventListener("copy",t,!0),window.addEventListener("paste",n,!0),window.addEventListener("cut",r,!0),()=>{window.removeEventListener("keydown",e,!0),window.removeEventListener("copy",t,!0),window.removeEventListener("paste",n,!0),window.removeEventListener("cut",r,!0)}},[]);let em=e=>{let t=x[e.id]??e.width;return t?{width:t,minWidth:t,maxWidth:t}:void 0},eg=er.map(e=>e.id),ef=eg.length>0&&eg.every(e=>C.has(e)),eb=eg.some(e=>C.has(e)),ex=()=>S(new Set),ey=(e,t,n=!1)=>{let s=Z(e.id,t.id);return(0,a.jsx)(cR,{col:t,value:e.cells[t.id]??("checkbox"!==t.type&&""),onChange:n=>cs(t)?((e,t,n)=>{let a=r.find(e=>e.id===t);if(!a)return;let s=a.options??[],l=cb(n).filter(e=>!s.includes(e)),o={...a.optionColors??{}};for(let e of l)o[e]=cx(a,Object.values(o));$({columns:l.length?r.map(e=>e.id===t?{...e,options:[...s,...l],optionColors:o}:e):r,rows:i.map(r=>r.id===e?{...r,cells:{...r.cells,[t]:n}}:r)})})(e.id,t.id,n):G(e.id,t.id,n),onEnsureOption:(e,n)=>X(t.id,e,n),uploading:!!_[s],onPickFile:n=>void J(e.id,t.id,n),selectOps:{colorFor:e=>Q(t,e),update:(e,n,r)=>Y(t.id,e,n,r),remove:e=>ee(t.id,e)},clickToEdit:n,members:B,seed:P&&P.rowId===e.id&&P.colId===t.id?P:null})},ev=e=>(0,a.jsx)(cj,{col:e,onRename:t=>q(e.id,{name:t}),onChangeType:t=>((e,t)=>{let n=r.find(t=>t.id===e);if(!n)return;let a="select"===t||"multiselect"===t,s="multiselect"===n.type,l="multiselect"===t,o="progress"===t&&"progress"!==n.type,c="person"===t&&"person"!==n.type,d="person"===n.type&&"person"!==t;$({columns:r.map(n=>n.id===e?{...n,type:t,options:a?n.options??[]:void 0,optionColors:a?n.optionColors:void 0,dateFormat:"date"===t?n.dateFormat??"date":void 0}:n),rows:c||d?i.map(t=>{let n=t.cells[e];return d?cQ(n)?{...t,cells:{...t.cells,[e]:n.name}}:t:{...t,cells:{...t.cells,[e]:(e=>{let t=cy(e).trim().toLowerCase();if(!t)return"";let n=B.find(e=>e.name.toLowerCase()===t||e.email?.toLowerCase()===t);return n?{kind:"person",id:n.id,name:n.name}:cy(e)})(n??"")}}}):o?i.map(t=>{let n=(0,lI.toNumber)(t.cells[e]);return{...t,cells:{...t.cells,[e]:null===n?"":n}}}):s===l?i:i.map(t=>{let n=cb(t.cells[e]);return{...t,cells:{...t.cells,[e]:l?n:n[0]??""}}})})})(e.id,t),onChangeDateFormat:t=>q(e.id,{dateFormat:t}),onPatch:t=>q(e.id,t),onSortAsc:()=>h({colId:e.id,dir:"asc"}),onSortDesc:()=>h({colId:e.id,dir:"desc"}),onFilter:()=>{g.includes(e.id)||et(e.id)},onDelete:()=>{var t;return t=e.id,void(!(r.length<=1)&&($({columns:r.filter(e=>e.id!==t),rows:i.map(e=>{let n={...e.cells};return delete n[t],{...e,cells:n}})}),b(e=>e.filter(e=>e!==t))))},canDelete:r.length>1}),ew=e=>(0,a.jsx)(cM,{icon:e.icon??null,color:e.color??null,onPickIcon:t=>W(e.id,{icon:t}),onPickColor:t=>W(e.id,{color:t}),onRemoveIcon:()=>W(e.id,{icon:null})}),e_=n.view??"table",ek=r.find(e=>e.id===n.boardGroupBy&&"select"===e.type)??r.find(e=>
2"select"===e.type)??null,eN=n.boardHidden??[],[eE,eC]=(0,s.useState)(null),eS=r.slice(1).filter(e=>{if("text"!==e.type)return!1;let t=new Set(i.map(t=>cy(t.cells[e.id]??"").trim()).filter(Boolean));return t.size>0&&t.size<=12}),ej=eE?i.find(e=>e.id===eE.id)??null:null;return(0,a.jsxs)(M.NodeViewWrapper,{as:"div","data-doc-table":!0,contentEditable:!1,className:"doc-data-table",children:[(0,a.jsx)("div",{className:"doc-data-table-toolbar",children:C.size>0?(0,a.jsx)(cG,{count:C.size,columns:r,optionColorFor:Q,onSet:(e,t)=>$({...n,rows:i.map(n=>C.has(n.id)?{...n,cells:{...n.cells,[e]:t}}:n)}),onDelete:()=>{$({...n,rows:i.filter(e=>!C.has(e.id))}),ex()},onClear:ex}):(0,a.jsxs)(a.Fragment,{children:[c||l?(0,a.jsxs)("div",{className:"relative w-[180px]",children:[(0,a.jsx)(f.Search,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsx)("input",{autoFocus:!0,value:l,onChange:e=>o(e.target.value),onBlur:()=>{l.trim()||d(!1)},placeholder:"Searchâ¦",className:(0,lR.cn)("flex w-full rounded-[12px] [corner-shape:squircle] squircle-field-fallback border border-transparent bg-lighter-oat dark:bg-black pl-8 h-8 text-xs placeholder:text-muted-foreground outline-none",l.length>0?"pr-8":"pr-3")}),l.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>{o(""),d(!1)},"aria-label":"Clear search",className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,a.jsx)(w.X,{className:"h-3.5 w-3.5"})})]}):(0,a.jsx)("button",{type:"button",onClick:()=>d(!0),"aria-label":"Search",className:"inline-flex h-8 w-8 items-center justify-center squircle text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,a.jsx)(f.Search,{className:"h-4 w-4"})}),(0,a.jsx)(cV,{columns:r,active:g,onToggle:et}),g.map(e=>{let t=r.find(t=>t.id===e);return t?(0,a.jsxs)("div",{className:"inline-flex items-center gap-1 rounded-md border bg-muted/40 pl-2 pr-1 h-7",children:[(0,a.jsx)(ou.Filter,{className:"h-3 w-3 text-muted-foreground/70"}),(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:t.name}),(0,a.jsx)(lM.Input,{value:p[e]??"",onChange:t=>m(n=>({...n,[e]:t.target.value})),placeholder:"containsâ¦",className:"h-5 w-24 border-0 bg-transparent px-1 text-xs focus-visible:ring-0"}),(0,a.jsx)("button",{type:"button",onClick:()=>et(e),className:"rounded-lg [corner-shape:squircle] squircle-safari-fallback p-0.5 hover:bg-accent text-muted-foreground","aria-label":"Remove filter",children:(0,a.jsx)(w.X,{className:"h-3 w-3"})})]},e):null}),(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5",children:["kanban"===e_&&(0,a.jsx)(cW,{columns:r,groupCol:ek,hidden:eN,renderColumnMenu:ev,onGroupBy:e=>$({...n,boardGroupBy:e}),onToggleHidden:e=>$({...n,boardHidden:eN.includes(e)?eN.filter(t=>t!==e):[...eN,e]})}),(0,a.jsx)(oN.ViewToggle,{view:e_,onChange:e=>{e!==e_&&(ex(),T(null),I(null),$({...n,view:e}))}})]})]})}),"kanban"===e_?ek?(0,a.jsx)(oP,{columns:r,rows:er,groupCol:ek,hidden:eN,optionColor:e=>Q(ek,e),onMove:(e,t,r)=>{if(!ek)return;let a=i.find(t=>t.id===e);if(!a)return;let s={...a,cells:{...a.cells,[ek.id]:t}},l=i.map(t=>t.id===e?s:t);if(null===u){l=l.filter(t=>t.id!==e);let t=r.indexOf(e),n=r[t+1],i=r[t-1],a=n?l.findIndex(e=>e.id===n):-1;if(-1===a&&i){let e=l.findIndex(e=>e.id===i);-1!==e&&(a=e+1)}-1===a&&(a=l.length),l.splice(a,0,s)}$({...n,rows:l})},onAddCard:e=>{if(!ek)return;let t=c1(),a=Object.fromEntries(r.map(e=>[e.id,cg(e)]));return a[ek.id]=e,$({...n,rows:[...i,{id:t,cells:a}]}),t},onOpenCard:e=>eC({id:e,focusTitle:!1}),onSetCell:G,onReorderGroups:e=>q(ek.id,{options:e}),onAddGroup:e=>X(ek.id,e),renderCell:(e,t)=>ey(e,t,!0),renderGroupEditor:(e,t)=>(0,a.jsx)(cJ,{value:e,color:Q(ek,e),onSave:(n,r)=>{Y(ek.id,e,n,r),t()},onDelete:()=>{ee(ek.id,e),t()},onCancel:t}),renderNewProperty:e=>(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)(cD,{onAdd:(t,n)=>e(H(t,n))})}),renderCardIcon:e=>e.icon?(0,a.jsx)("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center squircle",style:{backgroundColor:e.color||ci,color:ca},children:(0,a.jsx)(lr.DocIcon,{icon:e.icon,size:14,className:"leading-none"})}):null}):(0,a.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-[20px] border border-card-border bg-light-oat px-6 py-10 text-center dark:bg-secondary",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"A board groups rows by a Select column. This table doesn't have one yet."}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[eS.map(e=>(0,a.jsxs)(lT.Button,{size:"sm",variant:"outline",onClick:()=>(e=>{let t=r.find(t=>
2t.id===e);if(!t)return;let a=[];for(let t of i){let n=cy(t.cells[e]??"").trim();n&&!a.includes(n)&&a.push(n)}let s={};for(let e of a)s[e]=cx({...t,options:a},Object.values(s));$({...n,columns:r.map(t=>t.id===e?{...t,type:"select",options:a,optionColors:s,dateFormat:void 0}:t),rows:i.map(t=>({...t,cells:{...t.cells,[e]:cy(t.cells[e]??"").trim()}})),boardGroupBy:e})})(e.id),children:[(0,a.jsx)(sj.List,{className:"h-3.5 w-3.5"})," Group by ",e.name]},e.id)),(0,a.jsxs)(lT.Button,{size:"sm",variant:eS.length?"ghost":"outline",onClick:()=>{let e={id:c1(),name:"Status",type:"select",options:[...c0]},t={};for(let n of e.options)t[n]=cx(e,Object.values(t));e.optionColors=t,$({...n,columns:[...r,e],rows:i.map(t=>({...t,cells:{...t.cells,[e.id]:""}})),boardGroupBy:e.id})},children:[(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})," Add a Status column"]})]})]}):(0,a.jsxs)("div",{ref:j,className:"relative overflow-hidden rounded-lg border border-border/50",children:[(0,a.jsxs)(or.DndContext,{sensors:U,collisionDetection:or.closestCenter,modifiers:[os.restrictToVerticalAxis],onDragEnd:e=>{let{active:t,over:r}=e;if(!r||t.id===r.id)return;let a=i.findIndex(e=>e.id===t.id),s=i.findIndex(e=>e.id===r.id);-1!==a&&-1!==s&&$({...n,rows:(0,oi.arrayMove)(i,a,s)})},children:[(0,a.jsx)(ol.DragHaptics,{}),(0,a.jsx)(oi.SortableContext,{items:er.map(e=>e.id),strategy:oi.verticalListSortingStrategy,children:(0,a.jsxs)(ov.Table,{autoHeight:!1,mobileFixedHeight:!1,children:[(0,a.jsx)(ov.TableHeader,{children:(0,a.jsxs)(ov.TableRow,{className:"group/head hover:bg-transparent",children:[(0,a.jsx)(ov.TableHead,{className:"w-10 min-w-10 overflow-hidden text-clip pl-4 pr-0",children:(0,a.jsx)(lY.Checkbox,{"aria-label":"Select all rows",checked:!!ef||!!eb&&"indeterminate",onCheckedChange:()=>S(e=>{if(eg.every(t=>e.has(t))){let t=new Set(e);return eg.forEach(e=>t.delete(e)),t}return new Set([...e,...eg])}),className:(0,lR.cn)("transition-opacity",!eb&&"opacity-0 group-hover/head:opacity-100")})}),r.map(e=>{let t=u?.colId===e.id;return(0,a.jsxs)(ov.TableHead,{style:em(e),draggable:!0,onDragStart:t=>{t.target.closest("button, input")?t.preventDefault():v.current=e.id},onDragOver:e=>{v.current&&e.preventDefault()},onDrop:t=>{t.preventDefault(),v.current&&((e,t)=>{if(e===t)return;let n=[...r],i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(-1===i||-1===a)return;let[s]=n.splice(i,1);n.splice(a,0,s),z(n)})(v.current,e.id),v.current=null},className:"group/col text-xs text-muted-foreground font-medium select-none",onClick:t=>{t.target.closest('button, input, [data-slot="table-resize-handle"]')||(e=>{let t=er.map(e=>e.id);if(!t.length)return;T({rowId:t[0],colId:e}),I({rowId:t[t.length-1],colId:e});let n=j.current;n&&cd(n,t[0],e)})(e.id)},children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[ev(e),(0,a.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void h(e=>e&&e.colId===t?"asc"===e.dir?{colId:t,dir:"desc"}:null:{colId:t,dir:"asc"})},className:(0,lR.cn)("shrink-0 rounded-lg [corner-shape:squircle] squircle-safari-fallback p-0.5 hover:bg-accent hover:text-foreground",t?"opacity-100":"text-muted-foreground/40 opacity-0 group-hover/col:opacity-100"),title:"Sort","aria-label":"Sort column",children:t&&"desc"===u.dir?(0,a.jsx)(od.ArrowDown,{className:"h-3 w-3"}):(0,a.jsx)(oc.ArrowUp,{className:"h-3 w-3"})})]}),(0,a.jsx)(ov.TableResizeHandle,{onMouseDown:t=>{var n;let r,i,a,s,l,o;return n=e.id,t.preventDefault(),t.stopPropagation(),i=(r=t.target.closest("th"))?r.getBoundingClientRect().width:150,a=t.clientX,s=i,l=e=>{s=Math.max(60,i+(e.clientX-a)),y(e=>({...e,[n]:s}))},o=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",o),document.body.style.cursor="",document.body.style.userSelect="",q(n,{width:Math.round(s)}),y(e=>{let t={...e};return delete t[n],t})},void(document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",l),document.addEventListener("mouseup",o))},onDoubleClick:t=>{t.stopPropagation(),q(e.id,{width:void 0})}})]},e.id)}),(0,a.jsx)(ov.TableHead,{className:"w-10 min-w-10 overflow-hidden text-clip",children:(0,a.jsx)(cA,{onAdd:H})})]})}),(0,a.jsx)(ov.TableBody,{children:0===er.length?(0,a.jsx)(ov.TableRow,{children:(0,a.jsx)(ov.TableCell,{colSpan:r.length+2,className:"text-center text-xs text-muted-foreground py-8",children:0===i.length?"No rows yet.":"No rows match."})}):er.map(e=>(0,a.jsxs)(cC,{id:e.id,disabled:!en,selected:C.has(e.id),children:[(0,a.jsx)(ov.TableCell,{className:"w-10 min-w-10 overflow-hidden text-clip pl-4 pr-0 align-middle","data-no-dnd":"",children:(0,a.jsx)(lY.Checkbox,{"aria-label":"Select row",checked:C.has(e.id),onCheckedChange:()=>{let t;return t=e.id,S(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},className:(0,lR.cn)("transition-opacity",!C.has(e.id)&&0===C.size&&"opacity-0 group-hover/row:opacity-100")})}),r.map((t,n)=>{let r=Z(e.id,t.id),i=ey(e,t);return(0,a.jsx)(ov.TableCell,{style:em(t),className:(0,lR.cn)("p-0 align-middle outline-none",N===r&&"ring-2 ring-inset ring-ring/60"),tabIndex:-1,"data-doc-cell":`${e.id}:${t.id}`,onPointerDown:n=>{if(0!==n.button||!n.currentTarget.contains(n.target))return;let r={rowId:e.id,colId:t.id};
2n.shiftKey?(I(r),D||T(r)):(T(r),I(r)),n.currentTarget.focus({preventScroll:!0})},onDoubleClick:cI,onDragOver:e=>{Array.from(e.dataTransfer.types).includes("Files")&&(e.preventDefault(),e.stopPropagation(),E(r))},onDragLeave:()=>E(e=>e===r?null:e),onDrop:n=>{if(!n.dataTransfer.files.length)return;n.preventDefault(),n.stopPropagation(),E(null);let r=Array.from(n.dataTransfer.files).find(e=>o9.test(e.type));r&&J(e.id,t.id,r)},children:0!==n||"media"===t.type||"record"===t.type||cX(e.cells[t.id])?i:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 pl-2",children:[ew(e),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:i})]})},t.id)}),(0,a.jsx)(ov.TableCell,{className:"w-10 min-w-10 overflow-hidden text-clip px-0 text-center align-middle","data-no-dnd":"",children:(0,a.jsx)("button",{type:"button",onClick:()=>V(e.id),className:"rounded-lg [corner-shape:squircle] squircle-safari-fallback p-1 text-muted-foreground/40 opacity-0 group-hover/row:opacity-100 hover:text-destructive hover:bg-accent","aria-label":"Delete row",children:(0,a.jsx)(l3.TrashIcon,{className:"h-3.5 w-3.5"})})})]},e.id))})]})})]}),(0,a.jsx)(cf,{rootRef:j,anchor:D,focus:O,onExtendTo:I}),(0,a.jsxs)("button",{type:"button",onClick:K,className:"flex w-full items-center gap-1.5 border-t border-border/60 px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground transition-colors",children:[(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})," New row"]})]}),(0,a.jsx)(cZ,{row:ej,columns:r,focusTitle:!!eE?.focusTitle,onOpenChange:e=>{e||eC(null)},onTitle:(e,t,n)=>G(e,t,n),onDelete:e=>{V(e),eC(null)},renderCell:(e,t)=>ey(e,t,!0),renderSquircle:ew,renderColumnMenu:ev,onAddProperty:H})]})}function cC({id:e,disabled:t,selected:n,children:r}){let{listeners:i,setNodeRef:s,transform:l,transition:o,isDragging:c}=(0,oi.useSortable)({id:e,disabled:t});return(0,a.jsx)(ov.TableRow,{ref:s,...t?{}:i,style:{transform:oa.CSS.Translate.toString(l),transition:o,opacity:c?.45:void 0,position:"relative",zIndex:c?20:void 0},className:(0,lR.cn)("group/row",n&&"bg-accent/40",c&&"bg-accent/30 cursor-grabbing"),children:r})}function cS({col:e,onChange:t,children:n}){let[r,i]=(0,s.useState)(!1),l=ct(e);return(0,a.jsxs)(lt.Popover,{open:r,onOpenChange:i,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:n}),(0,a.jsx)(lt.PopoverContent,{align:"start",side:"bottom",className:"w-auto border-0 bg-transparent p-0 shadow-none",onMouseDown:e=>e.stopPropagation(),children:(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[!l&&(0,a.jsx)("div",{className:"flex items-center rounded-lg [corner-shape:squircle] squircle-safari-fallback border bg-popover px-1.5 py-1 shadow-xl",children:(0,a.jsxs)("button",{type:"button",onClick:()=>{t(null),i(!1)},className:"flex w-full items-center gap-2 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[(0,a.jsx)(w.X,{className:"h-3.5 w-3.5"})," Remove icon"]})}),(0,a.jsx)(lr.IconPicker,{onSelect:e=>{t(e),i(!1)},onClose:()=>i(!1)})]})})]})}function cj({col:e,onSortAsc:t,onSortDesc:n,onRename:r,onChangeType:i,onChangeDateFormat:l,onPatch:o,onFilter:c,onDelete:d,canDelete:h}){let[p,m]=(0,s.useState)(!1),[g,f]=(0,s.useState)(e.name),b=ce[e.type],x=ct(e),y="flex w-full items-center gap-2 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1.5 text-sm hover:bg-accent",v=(t=g)=>{let n=t.trim()||"Untitled";n!==e.name&&r(n),f(n)},w=e=>o({icon:e});return(0,a.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-0.5",children:[!x&&(0,a.jsx)(cS,{col:e,onChange:w,children:(0,a.jsx)("button",{type:"button","aria-label":"Change column icon",title:"Change or remove icon",onMouseDown:e=>e.stopPropagation(),className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:bg-accent hover:text-foreground",children:(0,a.jsx)(cn,{col:e})})}),(0,a.jsxs)(lt.Popover,{open:p,onOpenChange:t=>{t?f(e.name):v(),m(t)},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",onMouseDown:e=>e.stopPropagation(),className:(0,lR.cn)("inline-flex min-w-0 items-center gap-1 rounded-md px-1.5 py-0.5 hover:text-foreground",p&&"bg-muted text-foreground"),title:"Column options",children:[(0,a.jsx)("span",{className:"truncate",children:e.name}),(0,a.jsx)(sV.ChevronDown,{className:(0,lR.cn)("h-3.5 w-3.5 shrink-0 text-muted-foreground
2/50",p?"opacity-100":"opacity-0 group-hover/col:opacity-100")})]})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-56 space-y-1 p-1.5",children:[(0,a.jsx)(lM.Input,{variant:"on-white",autoFocus:!0,value:g,onChange:e=>f(e.target.value),onFocus:e=>e.target.select(),onBlur:()=>v(),onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),v()):"Escape"===t.key&&(t.preventDefault(),f(e.name),m(!1))},placeholder:"Column name","aria-label":"Column name",className:"h-8 text-sm"}),(0,a.jsx)(cS,{col:e,onChange:w,children:(0,a.jsxs)("button",{type:"button",className:y,children:[x?(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5 text-muted-foreground"}):(0,a.jsx)(cn,{col:e,className:"h-3.5 w-3.5"}),x?"Add icon":"Change icon",(0,a.jsx)(oo.ChevronRight,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground"})]})}),(0,a.jsxs)(lt.Popover,{children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",className:y,children:[(0,a.jsx)(b,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Field type",(0,a.jsx)(oo.ChevronRight,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground"})]})}),(0,a.jsx)(lt.PopoverContent,{side:"right",align:"start",sideOffset:6,collisionPadding:32,className:"w-44 p-1",children:o4.map(t=>{let n=t.icon,r=e.type===t.type;return(0,a.jsxs)("button",{type:"button",onClick:()=>i(t.type),className:(0,lR.cn)(y,r&&"bg-accent/60"),children:[(0,a.jsx)(n,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,a.jsx)("span",{className:"flex-1 text-left",children:t.label}),r&&(0,a.jsx)(u.Check,{className:"h-3.5 w-3.5"})]},t.type)})})]}),"progress"===e.type&&(0,a.jsxs)("div",{className:"space-y-1 px-0.5 pb-1",children:[(0,a.jsx)(o_.SearchableSelect,{value:e.progressFormat??"percent",onValueChange:e=>o({progressFormat:e}),variant:"on-white",size:"sm",searchable:!1,className:"w-full","aria-label":"Show as",options:o6.map(e=>({value:e.value,label:e.label}))}),"ratio"===co(e)&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"mb-1 block text-[11px] text-muted-foreground",children:"Out of"}),(0,a.jsx)(lM.Input,{type:"number",min:1,defaultValue:e.progressTotal??100,onWheel:e=>e.target.blur(),onBlur:e=>{let t=Number(e.target.value);o({progressTotal:Number.isFinite(t)&&t>0?t:100})},className:"h-7 text-xs"})]})]}),"date"===e.type&&(0,a.jsx)("div",{className:"px-0.5 pb-1",children:(0,a.jsx)(o_.SearchableSelect,{value:e.dateFormat??"date",onValueChange:e=>l(e),variant:"on-white",size:"sm",searchable:!1,className:"w-full","aria-label":"Date format",options:o8.map(e=>({value:e.value,label:e.label}))})}),(0,a.jsxs)("div",{className:"border-t border-border/60 pt-1",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>{t(),m(!1)},className:y,children:[(0,a.jsx)(oc.ArrowUp,{className:"h-3.5 w-3.5 text-muted-foreground"})," Sort ascending"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{n(),m(!1)},className:y,children:[(0,a.jsx)(od.ArrowDown,{className:"h-3.5 w-3.5 text-muted-foreground"})," Sort descending"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>{c(),m(!1)},className:y,children:[(0,a.jsx)(ou.Filter,{className:"h-3.5 w-3.5 text-muted-foreground"})," Filter"]})]}),(0,a.jsx)("div",{className:"border-t border-border/60 pt-1",children:(0,a.jsxs)("button",{type:"button",onClick:()=>{d(),m(!1)},disabled:!h,className:(0,lR.cn)(y,"text-destructive hover:bg-destructive/10 disabled:opacity-40"),children:[(0,a.jsx)(l3.TrashIcon,{className:"h-3.5 w-3.5"})," Delete column"]})})]})]})]})}function cA({onAdd:e,trigger:t,align:n="end"}){let[r,i]=(0,s.useState)(!1);return(0,a.jsxs)(lt.Popover,{open:r,onOpenChange:i,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:t??(0,a.jsx)("button",{type:"button",className:"rounded-lg [corner-shape:squircle] squircle-safari-fallback p-1 text-muted-foreground/60 hover:bg-accent hover:text-foreground","aria-label":"Add column",children:(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(lt.PopoverContent,{align:n,className:"w-56 p-3",children:(0,a.jsx)(cD,{onAdd:(t,n)=>{e(t,n),i(!1)}})})]})}function cD({onAdd:e}){let[t,n]=(0,s.useState)(""),[r,i]=(0,s.useState)("text"),l=()=>{e(t,r),n(""),i("text")};return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(lM.Input,{variant:"on-white",autoFocus:!0,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"===e.key&&l()},placeholder:"Field name",className:"h-8 text-sm"}),(0,a.jsx)(o_.SearchableSelect,{value:r,onValueChange:e=>i(e),variant:"on-white",size:"sm",className:"w-full","aria-label":"Field type",options:o4.map(e=>{let t=e.icon;return{value:e.type,label:e.label,icon:(0,a.jsx)(t,{className:"h-3.5 w-3.5"})}})}),(0,a.jsx)(lT.Button,{size:"sm",className:"w-full",onClick:l,children:"Add field"})]})}function cM({icon:e,color:t,onPickIcon:n,onPickColor:r,onRemoveIcon:i}
2){let[l,o]=(0,s.useState)(!1),c=!!e,d=t||ci;return(0,a.jsxs)(lt.Popover,{open:l,onOpenChange:o,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:c?(0,a.jsx)("button",{type:"button","aria-label":"Entry icon",title:"Icon & color",className:"flex h-6 w-6 shrink-0 items-center justify-center squircle text-[11px] font-semibold",style:{backgroundColor:d,color:ca},children:(0,a.jsx)(lr.DocIcon,{icon:e,size:14,className:"leading-none"})}):(0,a.jsx)("button",{type:"button","aria-label":"Add icon",title:"Add icon",className:"flex h-6 w-6 shrink-0 items-center justify-center squircle text-muted-foreground/70 opacity-0 hover:bg-accent hover:text-foreground group-hover/row:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100",children:(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(lt.PopoverContent,{align:"start",className:"w-auto border-0 bg-transparent p-0 shadow-none",children:(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 rounded-lg [corner-shape:squircle] squircle-safari-fallback border bg-popover px-2 py-1.5 shadow-xl",children:[cr.map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>r(e.value),title:e.name,"aria-label":e.name,className:(0,lR.cn)("h-5 w-5 squircle border transition-transform hover:scale-110",d===e.value?"ring-2 ring-ring border-transparent":"border-border"),style:{backgroundColor:e.value}},e.value)),c&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"mx-0.5 h-4 w-px bg-border"}),(0,a.jsx)("button",{type:"button",onClick:()=>{i(),o(!1)},className:"rounded-lg [corner-shape:squircle] squircle-safari-fallback p-1 text-muted-foreground hover:bg-accent hover:text-foreground",title:"Remove icon","aria-label":"Remove icon",children:(0,a.jsx)(w.X,{className:"h-3.5 w-3.5"})})]})]}),(0,a.jsx)(lr.IconPicker,{onSelect:e=>{n(e),o(!1)},onClose:()=>o(!1)})]})})]})}function cT(e){e.focus({preventScroll:!0}),e.select()}function cO(e){"click"===e.type&&e.detail<2||(e.preventDefault(),cT(e.currentTarget))}function cI(e){let t=e.target;if(t?.closest('[data-slot="popover-content"], a, button, [role="checkbox"]'))return;let n=()=>{let t=e.currentTarget.querySelector('input:not([type="checkbox"]):not([type="file"]), textarea');return!!t&&(e.preventDefault(),cT(t),!0)};n()||requestAnimationFrame(n)}function cL({col:e,value:t,onChange:n,clickToEdit:r=!1,seed:i=null}
2){let[l,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(null),u=(0,s.useRef)(!1),h=cl(e),p=co(e),m=(0,lI.toNumber)(t),g=i?.n;(0,s.useEffect)(()=>{i&&(u.current=!1,d(i.text),o(!0))},[g]);let f=()=>{o(!1),d(null)};return l?(0,a.jsx)(lM.Input,{autoFocus:!0,type:"number",onWheel:e=>e.target.blur(),defaultValue:c??(null===m?"":String(m)),onFocus:e=>{u.current&&(u.current=!1,e.currentTarget.select())},onClick:cO,onDoubleClick:cO,onBlur:e=>{let t=(0,lI.toNumber)(e.target.value);n(null===t?"":t),f()},onKeyDown:e=>{"Enter"===e.key&&e.target.blur(),"Escape"===e.key&&f()},className:"doc-cell-input h-8 rounded-none border-0 bg-transparent px-3 text-sm shadow-none focus-visible:ring-0 focus-visible:outline-none"}):(0,a.jsx)("div",{onClick:r?()=>o(!0):void 0,onDoubleClick:e=>{e.preventDefault(),u.current=!0,o(!0)},className:"min-h-8 cursor-text px-3 py-2",title:null===m?void 0:(0,lI.formatProgress)(m,h,"percent"===p?"ratio":"percent"),children:null===m?(0,a.jsx)("span",{className:"text-sm text-muted-foreground/40",children:"-"}):(0,a.jsx)(lI.ProgressPill,{value:m,total:h,format:p})})}function cR({col:e,value:t,onChange:n,onEnsureOption:r,uploading:i,onPickFile:l,selectOps:o,clickToEdit:c=!1,members:d=[],seed:u=null}
2){let[h,p]=(0,s.useState)(!1),[m,g]=(0,s.useState)(null),f=(0,s.useRef)(!1),b=(e=!1)=>{f.current=e,g(null),p(!0)},x=()=>{p(!1),g(null)},y=u?.n;if((0,s.useEffect)(()=>{u&&cp.has(e.type)&&(f.current=!1,g(u.text),p(!0))},[y]),"media"===e.type||cY(t))return(0,a.jsx)(cH,{media:cY(t)?t:null,uploading:!!i,onPickFile:l,onRename:e=>{cY(t)&&n({...t,name:e})},onRemove:()=>n("")});if("checkbox"===e.type)return(0,a.jsx)("div",{className:"flex items-center justify-center px-3 py-2",children:(0,a.jsx)(lY.Checkbox,{checked:!!t,onCheckedChange:e=>n(!0===e)})});if("date"===e.type)return(0,a.jsx)(cP,{col:e,value:t,onChange:n});if(cs(e))return(0,a.jsx)(cU,{col:e,value:t,onChange:n,onEnsureOption:r,ops:o,seed:u});if("person"===e.type||cQ(t))return(0,a.jsx)(c$,{value:t,onChange:n,members:d,seed:u});if("progress"===e.type)return(0,a.jsx)(cL,{col:e,value:t,onChange:n,clickToEdit:c,seed:u});if("record"===e.type||cX(t))return(0,a.jsx)(cq,{value:t,onChange:n,seed:u});if(h)return(0,a.jsx)(lM.Input,{autoFocus:!0,type:"number"===e.type?"number":"text",defaultValue:m??cy(t),...{onFocus:e=>{let t=e.currentTarget;if(null!==m){try{t.setSelectionRange(t.value.length,t.value.length)}catch{}return}f.current&&(f.current=!1,t.select())},onClick:cO,onDoubleClick:cO},onBlur:t=>{let r=t.target.value;n("number"===e.type?""===r?"":Number(r):r),x()},onKeyDown:e=>{"Enter"===e.key&&e.target.blur(),"Escape"===e.key&&x()},className:"doc-cell-input h-8 rounded-none border-0 bg-transparent px-3 text-sm shadow-none focus-visible:ring-0 focus-visible:outline-none"});let v=cy(t);return(0,a.jsx)("div",{onClick:c?()=>b():void 0,onDoubleClick:e=>{e.preventDefault(),b(!0)},className:"min-h-8 cursor-text px-3 py-2 text-sm",children:"url"===e.type&&v?(0,a.jsx)("a",{href:v,target:"_blank",rel:"noreferrer",onClick:e=>e.stopPropagation(),className:"text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 hover:text-foreground",children:v}):(0,a.jsx)("span",{className:(0,lR.cn)(!v&&"text-muted-foreground/40"),children:v||"-"})})}function cP({col:e,value:t,onChange:n}){let[r,i]=(0,s.useState)(!1),l="datetime"===e.dateFormat,{date:o,time:c}=lK(t),d=lG(o),u=lZ(t),h=e=>{if(!e)return void n("");let t=l?c||"09:00":"";n(lW(lV(e),t,l)),l||i(!1)};return(0,a.jsxs)(lt.Popover,{open:r,onOpenChange:i,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button",className:"flex min-h-8 w-full items-center px-3 py-2 text-left text-sm hover:bg-muted/40",children:u?(0,a.jsx)("span",{className:"truncate tabular-nums",children:u}):(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"-"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-auto p-0",children:[(0,a.jsx)(l$.Calendar,{mode:"single",selected:d,onSelect:h,defaultMonth:d,captionLayout:"dropdown",autoFocus:!0}),l&&(0,a.jsx)("div",{className:"border-t px-3 py-2",children:(0,a.jsx)(lz.TimePicker,{value:c,onValueChange:e=>n(lW(o,e,!0)),variant:"on-white",className:"w-full",inputClassName:"h-8 text-xs","aria-label":"Time"})}),(0,a.jsxs)("div",{className:"flex items-center justify-between border-t px-2 py-1.5",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{n(""),i(!1)},className:"rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:"Clear"}),(0,a.jsx)("button",{type:"button",onClick:()=>h(new Date),className:"rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:"Today"})]})]})]})}function cF({value:e,color:t,shape:n="pill"}){return(0,a.jsx)(lI.StatusPill,{label:e,color:t,shape:n})}function cB({initialLabel:e,initialColor:t,submitLabel:n,onSubmit:r,onCancel:i}
2){let[l,o]=(0,s.useState)(e),[c,d]=(0,s.useState)(t),u=()=>{let e=l.trim();e&&r(e,c)};return(0,a.jsxs)("div",{className:"space-y-2.5 p-2",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key&&u(),"Escape"===e.key&&i()},children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(lM.Input,{autoFocus:!0,variant:"on-white",placeholder:"Option name",value:l,onChange:e=>o(e.target.value),className:"h-7 flex-1 text-xs"}),(0,a.jsx)("button",{type:"button",onClick:i,className:"shrink-0 p-1 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Cancel",children:(0,a.jsx)(w.X,{className:"size-3"})})]}),(0,a.jsx)(lO.StatusColorField,{value:c,onChange:d}),(0,a.jsx)("button",{type:"button",onClick:u,disabled:!l.trim(),className:"h-7 w-full rounded-md bg-foreground text-xs font-medium text-background transition-colors hover:bg-foreground/90 disabled:cursor-not-allowed disabled:opacity-40",children:n})]})}function cU({col:e,value:t,onChange:n,onEnsureOption:r,ops:i,seed:l=null}){let[o,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(null),[h,p]=(0,s.use
2State)(!1),[m,g]=(0,s.useState)(""),f="multiselect"===e.type,b=e.options??[],x=cb(t),y=l?.n;(0,s.useEffect)(()=>{l&&(g(l.text),c(!0))},[y]);let v=m.trim().toLowerCase(),w=v?b.filter(e=>e.toLowerCase().includes(v)):b,_=e=>i?.colorFor(e)??l5,k=f?"rect":"pill",N=e=>n(f?e:e[0]??""),E=e=>{if(f){N(x.includes(e)?x.filter(t=>t!==e):[...x,e]),g("");return}N(e?[e]:[]),c(!1),g("")},C=()=>{u(null),p(!1),g("")};return(0,a.jsxs)(lt.Popover,{open:o,onOpenChange:e=>{c(e),e||C()},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button",className:"flex min-h-8 w-full flex-wrap items-center gap-1 px-3 py-2 text-left text-sm hover:bg-muted/40",children:x.length?x.map(e=>(0,a.jsx)(cF,{value:e,color:_(e),shape:k},e)):(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"-"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-60 p-1",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-2 py-0.5",children:[(0,a.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:f?"Select any":"Select"}),x.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>{N([]),f||c(!1)},className:"rounded px-1 py-0.5 text-[11px] text-muted-foreground hover:bg-accent hover:text-foreground",children:"Clear"})]}),(0,a.jsx)("div",{className:(0,lR.cn)(!d&&!h&&"max-h-56 overflow-auto"),children:w.map(e=>d===e?(0,a.jsx)(cB,{initialLabel:e,initialColor:_(e),submitLabel:"Save",onSubmit:(t,n)=>{i?.update(e,t,n),u(null)},onCancel:()=>u(null)},e):(0,a.jsxs)("div",{className:(0,lR.cn)("group/opt flex items-center gap-1 rounded-md px-2 py-1 transition-colors hover:bg-accent",!f&&x.includes(e)&&"bg-accent"),children:[(0,a.jsxs)("button",{type:"button",onClick:()=>E(e),className:"flex min-w-0 flex-1 cursor-pointer items-center gap-1.5 text-left",children:[f&&(0,a.jsx)(lY.Checkbox,{checked:x.includes(e),tabIndex:-1,className:"pointer-events-none shrink-0"}),(0,a.jsx)(cF,{value:e,color:_(e),shape:k})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover/opt:opacity-100",children:[(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),p(!1),u(e)},className:"rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground","aria-label":`Edit ${e}`,children:(0,a.jsx)(l2.Pencil,{className:"size-3"})}),(0,a.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),i?.remove(e)},className:"rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive","aria-label":`Delete ${e}`,children:(0,a.jsx)(l3.TrashIcon,{className:"size-3"})})]})]},e))}),h?(0,a.jsx)("div",{className:"mt-1 border-t pt-1",children:(0,a.jsx)(cB,{initialLabel:m,initialColor:cx(e,[]),submitLabel:"Create",onSubmit:(e,t)=>{r(e,t),C()},onCancel:C})}):(0,a.jsxs)("div",{className:"mt-1 flex items-center gap-1 border-t pt-1",children:[(0,a.jsx)(lM.Input,{variant:"on-white",autoFocus:""!==m,value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(()=>{let e=m.trim();if(!e)return;let t=1===w.length?w[0]:e;g(""),x.includes(t)||E(t)})()},placeholder:"Add optionâ¦",className:"h-7 text-xs"}),(0,a.jsx)("button",{type:"button",onClick:()=>{u(null),p(!0)},className:"rounded p-1 text-muted-foreground hover:bg-accent","aria-label":"Add option with a color",title:"Add option with a color",children:(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})})]})]})]})}function c$({value:e,onChange:t,members:n,seed:r=null}){let[i,l]=(0,s.useState)(!1),[o,c]=(0,s.useState)(""),[d,h]=(0,s.use
2State)(0),[p,m]=(0,s.useState)(!1),g=(0,s.useRef)(null),f=e=>{e&&m(!!g.current?.closest('[role="dialog"]')),l(e)},b=cQ(e)?e:null,x=b?n.find(e=>e.id===b.id):void 0,y=b?"":cy(e),v=r?.n;(0,s.useEffect)(()=>{r&&(c(r.text),h(0),f(!0))},[v]);let w=o.trim().toLowerCase(),_=w?n.filter(e=>e.name.toLowerCase().includes(w)||e.email?.toLowerCase().includes(w)):n,k=e=>{t(e?{kind:"person",id:e.id,name:e.name}:""),l(!1),c("")};return(0,a.jsxs)(lt.Popover,{open:i,modal:p,onOpenChange:e=>{f(e),e||c(""),h(0)},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{ref:g,type:"button",className:"flex min-h-8 w-full items-center gap-1.5 px-3 py-1.5 text-left text-sm hover:bg-muted/40",children:b?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(oj.UserAvatar,{name:b.name,email:x?.email,avatarUrl:x?.avatarUrl}),(0,a.jsx)("span",{className:"min-w-0 truncate",children:x?.name??b.name})]}):y?(0,a.jsx)("span",{className:"min-w-0 truncate text-muted-foreground",children:y}):(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"-"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-64 p-1",children:[(0,a.jsx)(lM.Input,{variant:"on-white",autoFocus:!0,value:o,onChange:e=>{c(e.target.value),h(0)},onKeyDown:e=>{"ArrowDown"===e.key?(e.preventDefault(),h(e=>Math.min(e+1,_.length-1))):"ArrowUp"===e.key?(e.preventDefault(),h(e=>Math.max(e-1,0))):"Enter"===e.key&&(e.preventDefault(),_[d]&&k(_[d]))},placeholder:"Search peopleâ¦",className:"mb-1 h-8 text-sm"}),(0,a.jsx)("div",{className:"max-h-56 overflow-auto",children:0===n.length?(0,a.jsx)("div",{className:"space-y-1 p-1",children:[0,1,2].map(e=>(0,a.jsx)("div",{className:"h-7 animate-pulse rounded-md bg-muted"},e))}):0===_.length?(0,a.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No one matches"}):_.map((e,t)=>(0,a.jsxs)("button",{type:"button",onClick:()=>k(e),onMouseEnter:()=>h(t),className:(0,lR.cn)("flex w-full items-center gap-2 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1.5 text-left text-sm",t===d&&"bg-accent"),children:[(0,a.jsx)(oj.UserAvatar,{name:e.name,email:e.email,avatarUrl:e.avatarUrl}),(0,a.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e.name}),b?.id===e.id&&(0,a.jsx)(u.Check,{className:"h-3.5 w-3.5 shrink-0"})]},e.id))}),(b||y)&&(0,a.jsx)("div",{className:"mt-1 border-t pt-1",children:(0,a.jsx)("button",{type:"button",onClick:()=>k(null),className:"flex w-full items-center rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:"Clear"})})]})]})}let cz=["contact","company","deal"];function cq({value:e,onChange:t,seed:n=null}
2){let[r,i]=(0,s.useState)(!1),[l,o]=(0,s.useState)(""),[c,d]=(0,s.useState)(!1),u=(0,s.useRef)(null),h=(0,s.useRef)(null),p=e=>{e&&d(!!u.current?.closest('[role="dialog"]')),i(e)},m=cX(e)?e:null,g=m?"":cy(e),f=n?.n;(0,s.useEffect)(()=>{n&&(o(n.text),p(!0))},[f]);let b=()=>{i(!1),o("")};return(0,a.jsxs)(lt.Popover,{open:r,modal:c,onOpenChange:e=>{p(e),e||o("")},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{ref:u,type:"button",className:"flex min-h-8 w-full items-center gap-1.5 px-3 py-1.5 text-left text-sm hover:bg-muted/40",children:m?(0,a.jsx)("span",{className:"min-w-0",onClick:e=>e.stopPropagation(),children:(0,a.jsx)(oS.MentionPill,{type:m.type,id:m.id,name:m.name,variant:"pill"})}):g?(0,a.jsx)("span",{className:"min-w-0 truncate text-muted-foreground",children:g}):(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"-"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-80 p-1",children:[(0,a.jsx)(lM.Input,{variant:"on-white",autoFocus:!0,value:l,onChange:e=>o(e.target.value),onKeyDown:e=>{if("Enter"===e.key){let n=function(e){let t=(0,oV.decodeHtmlEntities)(e).replace(/<\/?(p|div|span)\b[^>]*>/gi,"").trim(),n=null,r=null,i=oZ.exec(t);if(i)n=i[1],r=i[2];else{let e=oJ.exec(t);e&&(r=e[2],n=e[3].replace(/<[^>]*>/g,""))}if(!r||!n)return null;let a=oW.exec((0,oV.decodeHtmlEntities)(r).trim());if(!a)return null;let s=oG[a[1]],l=n.replace(/\s+/g," ").trim();return s&&l?{kind:"record",type:s,id:a[2].toLowerCase(),name:l}:null}(l.trim());if(n){e.preventDefault(),t(n),b();return}}"Escape"!==e.key&&h.current?.handleKeyDown(e.key)&&e.preventDefault()},placeholder:"Search people, companies, dealsâ¦",className:"mb-1 h-8 text-sm"}),(0,a.jsx)(oK.MentionSuggestions,{ref:h,query:l,types:cz,heading:"Records",onSelect:e=>{("contact"===e.type||"company"===e.type||"deal"===e.type)&&(t({kind:"record",type:e.type,id:e.id,name:e.name}),b())},onClose:b}),(m||g)&&(0,a.jsx)("div",{className:"mt-1 border-t pt-1",children:(0,a.jsx)("button",{type:"button",onClick:()=>{t(""),b()},className:"flex w-full items-center rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1.5 text-left text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:"Clear"})})]})]})}function cH({media:e,uploading:t,onPickFile:n,onRename:r,onRemove:i}
2){let[l,o]=(0,s.useState)(!1),c=(0,s.useRef)(null);return t?(0,a.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",children:[(0,a.jsx)(h.Loader2,{className:"h-3.5 w-3.5 animate-spin"})," Uploadingâ¦"]}):e?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>o(!0),className:"flex w-full items-center gap-2 px-2 py-1.5 text-left hover:bg-muted/40",title:e.name,children:[(0,a.jsx)("span",{className:"relative flex h-8 w-8 shrink-0 items-center justify-center overflow-hidden rounded-[8px] bg-muted",children:"image"===e.kind?(0,a.jsx)("img",{src:e.url,alt:e.name,className:"h-full w-full object-cover"}):"video"===e.kind?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("video",{src:e.url,className:"h-full w-full object-cover",muted:!0,preload:"metadata"}),(0,a.jsx)(lE.Play,{className:"absolute h-3.5 w-3.5 text-white drop-shadow",fill:"currentColor"})]}):(0,a.jsx)(s$.FileText,{className:"h-4 w-4 text-destructive"})}),(0,a.jsx)("span",{className:"truncate text-sm",children:e.name||"Untitled"})]}),(0,a.jsx)(cK,{media:e,open:l,onOpenChange:o,onRename:r,onRemove:()=>{i(),o(!1)}})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("button",{type:"button",onClick:()=>c.current?.click(),className:"flex w-full items-center gap-1.5 px-3 py-2 text-xs text-muted-foreground/50 hover:text-muted-foreground",children:[(0,a.jsx)(og.Upload,{className:"h-3.5 w-3.5"})," Drop or upload"]}),(0,a.jsx)("input",{ref:c,type:"file",accept:"image/*,video/*,application/pdf",className:"hidden",onChange:e=>{let t=e.target.files?.[0];t&&n?.(t),e.target.value=""}})]})}function cK({media:e,open:t,onOpenChange:n,onRename:r,onRemove:i}){return(0,a.jsx)(ok.Dialog,{open:t,onOpenChange:n,children:(0,a.jsxs)(ok.DialogContent,{className:"max-w-3xl overflow-hidden p-0",children:[(0,a.jsx)("div",{className:"flex max-h-[68vh] items-center justify-center bg-black/90",children:"image"===e.kind?(0,a.jsx)("img",{src:e.url,alt:e.name,className:"max-h-[68vh] w-auto object-contain"}):"video"===e.kind?(0,a.jsx)(oX.VideoPlayer,{src:e.url,autoPlay:!0,keyboard:!0,videoClassName:"max-h-[68vh] w-auto"}):(0,a.jsx)("iframe",{src:e.url,title:e.name,className:"h-[68vh] w-full bg-white"})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 p-3",children:[(0,a.jsx)(lM.Input,{variant:"default",defaultValue:e.name,onBlur:t=>{let n;(n=t.target.value.trim())&&n!==e.name&&r(n)},onKeyDown:e=>{"Enter"===e.key&&e.target.blur()},placeholder:"File name",className:"h-8 flex-1 text-sm"},e.name),(0,a.jsxs)("a",{href:e.url,download:e.name,className:"inline-flex h-8 items-center gap-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback border px-2.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[(0,a.jsx)(k.Download,{className:"h-3.5 w-3.5"})," Download"]}),(0,a.jsx)("button",{type:"button",onClick:i,className:"inline-flex h-8 items-center rounded-md [corner-shape:squircle] squircle-safari-fallback border px-2 text-muted-foreground hover:bg-accent hover:text-destructive","aria-label":"Remove media",children:(0,a.jsx)(l3.TrashIcon,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(ok.DialogClose,{className:"sr-only",children:"Close"})]})]})})}function cV({columns:e,active:t,onToggle:n}){let[r,i]=(0,s.useState)(!1);return(0,a.jsxs)(lt.Popover,{open:r,onOpenChange:i,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button","aria-label":"Filter",className:(0,lR.cn)("relative inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground",t.length>0&&"text-foreground"),children:[(0,a.jsx)(ou.Filter,{className:"h-4 w-4"}),t.length>0&&(0,a.jsx)("span",{className:"absolute -right-1 -top-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-foreground px-1 text-[9px] font-medium leading-none text-background",children:t.length})]})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",className:"w-48 p-1",children:[(0,a.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground",children:"Filter by column"}),e.map(e=>{let r=t.includes(e.id);return(0,a.jsxs)("button",{type:"button",onClick:()=>n(e.id),className:(0,lR.cn)("flex w-full items-center gap-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-left text-sm hover:bg-accent",r&&"bg-accent/60"),children:[(0,a.jsx)(cn,{col:e}),(0,a.jsx)("span",{className:"truncate",children:e.name}),r&&(0,a.jsx)("span",{className:"ml-auto text-xs",children:"â"})]},e.id)})]})]})}function cG({count:e,columns:t,optionColorFor:n,onSet:r,onDelete:i,onClear:s}){let l=t.filter(cs),o=t.filter(e=>"checkbox"===e.type),c=0===l.length&&0===o.length;return(0,a.jsxs)("div",{className:"flex w-full items-center gap-2",children:[(0,a.jsxs)("span",{className:"text-xs font-medium text-foreground",children:[e," selected"]}),(0,a.jsxs)(ow.DropdownMenu,{children:[(0,a.jsx)(ow.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",className:"inline-flex h-7 items-center gap-1 rounded-md [corner-shape:squircle] squircle-safari-fallback border bg-background px-2 text-xs text-foreground hover:bg-accent",children:[(0,a.jsx)(l2.Pencil,{className:"h-3 w-3"})," Set field",(0,a.jsx)(sV.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,a.jsxs)(ow.DropdownMenuContent,{align:"start",className:"w-48",children:[c&&(0,a.jsx)(ow.DropdownMenuItem,{disabled:!0,children:"No status fields"}),l.map(e=>(0,a.jsxs)(ow.DropdownMenuSub,{children:[(0,a.jsxs)(ow.DropdownMenuSubTrigger,{children:["multiselect"===e.type?(0,a.jsx)(s3.ListChecks,{className:"mr-1.5 h-3.5 w-3.5 opacity-70"}):(0,a.jsx)(sj.List,{className:"mr-1.5 h-3.5 w-3.5 opacity-70"}),e.name]}),(0,a.jsxs)(ow.DropdownMenuSubContent,{children:[0===(e.options??[]).length&&(0,a.jsx)(ow.DropdownMenuItem,{disabled:!0,children:"No options"}),(e.options??[]).map(t=>(0,a.jsx)(ow.DropdownMenuItem,{onClick:()=>r(e.id,"multiselect"===e.type?[t]:t),children:(0,a.jsx)(cF,{value:t,color:n(e,t),shape:"multiselect"===e.type?"rect":"pill"})},t)),(0,a.jsx)(ow.DropdownMenuSeparator,{}),(0,a.jsx)(ow.DropdownMenuItem,{onClick:()=>r(e.id,"multiselect"===e.type?[]:""),children:"Clear"})]})]},e.id)),o.map(e=>(0,a.jsxs)(ow.DropdownMenuSub,{children:[(0,a.jsxs)(ow.DropdownMenuSubTrigger,{children:[(0,a.jsx)(sD.CheckSquare,{className:"mr-1.5 h-3.5 w-3.5 opacity-70"}),e.name]}),(0,a.jsxs)(ow.DropdownMenuSubContent,{children:[(0,a.jsx)(ow.DropdownMenuItem,{onClick:()=>r(e.id,!0),children:"Checked"}),(0,a.jsx)(ow.DropdownMenuItem,{onClick:()=>r(e.id,!1),children:"Unchecked"})]})]},e.id))]})]}),(0,a.jsxs)("button",{type:"button",onClick:i,className:"inline-flex h-7 items-center gap-1 rounded-md [corner-shape:squircle] squircle-safari-fallback border px-2 text-xs text-muted-foreground hover:bg-accent hover:text-destructive",children:[(0,a.jsx)(l3.TrashIcon,{className:"h-3.5 w-3.5"})," Delete"]}),(0,a.jsx)("button",{type:"button",onClick:s,className:"ml-auto inline-flex h-7 items-center rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:"Done"})]})}function cW({columns:e,groupCol:t,hidden:n,renderColumnMenu:r,onGroupBy:i,onToggleHidden:s}){let l=e.filter(e=>"select"===e.type),o=e.slice(1).filter(e=>e.id!==t?.id);return(0,a.jsxs)(lt.Popover,{children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button","aria-label":"Board options",title:"Board options",className:"inline-flex h-8 w-8 items-center justify-center squircle text-muted-foreground hover:bg-accent hover:text-foreground data-[state=open]:bg-accent data-[state=open]:text-foreground",children:(0,a.jsx)(of.SlidersHorizontal,{className:"h-4 w-4"})})}),(0,a.jsxs)(lt.PopoverContent,{align:"end",className:"w-56 p-1",children:[(0,a.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground",children:"Group by"}),0===l.length&&(0,a.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No Select columns"}),l.map(e=>(0,a.jsxs)("button",{type:"button",onClick:()=>i(e.id),className:"flex w-full items-center gap-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1 text-left text-sm hover:bg-accent",children:[(0,a.jsx)(cn,{col:e}),(0,a.jsx)("span",{className:"truncate",children:e.name}),t?.id===e.id&&(0,a.jsx)(u.Check,{className:"ml-auto h-3.5 w-3.5"})]},e.id)),o.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"my-1 h-px bg-border"}),(0,a.jsx)("div",{className:"px-2 py-1 text-[11px] font-medium text-muted-foreground",children:"Card properties"}),o.map(e=>{let t=!n.includes(e.id);return(0,a.jsxs)("div",{className:(0,lR.cn)("group/col flex w-full items-center gap-1 rounded-md [corner-shape:squircle] squircle-safari-fallback py-0.5 pl-1.5 pr-1 text-sm hover:bg-accent",!t&&"text-muted-foreground"),children:[(0,a.jsx)("div",{className:"min-w-0 flex-1",children:r(e)}),(0,a.jsx)("button",{type:"button",onClick:()=>s(e.id),"aria-label":t?`Hide ${e.name} on cards`:`Show ${e.name} on cards`,title:t?"Hide on cards":"Show on cards",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center squircle hover:bg-background/60",children:t?(0,a.jsx)(ob.Eye,{className:"h-3.5 w-3.5 text-muted-foreground"}):(0,a.jsx)(ox.EyeOff,{className:"h-3.5 w-3.5 text-muted-foreground
2/50"})})]},e.id)})]})]})]})}function cZ({row:e,columns:t,focusTitle:n,onOpenChange:r,onTitle:i,onDelete:s,renderCell:l,renderSquircle:o,renderColumnMenu:c,onAddProperty:d}){let u=t[0],h=!!u&&("text"===u.type||"url"===u.type),p=h?t.slice(1):t,m=e&&u?cy(e.cells[u.id]??""):"";return(0,a.jsx)(ok.Dialog,{open:!!e,onOpenChange:r,children:(0,a.jsxs)(ok.DialogContent,{className:"max-w-xl gap-0 p-0",children:[(0,a.jsx)(ok.DialogTitle,{className:"sr-only",children:m||"Untitled"}),e&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"group/row flex items-center gap-2 px-6 pt-6 pb-3",children:[u&&"media"!==u.type&&"record"!==u.type&&o(e),h?(0,a.jsx)("input",{autoFocus:n,defaultValue:m,placeholder:"Untitled",onBlur:t=>{t.target.value!==m&&i(e.id,u.id,t.target.value)},onKeyDown:e=>{"Enter"===e.key&&e.target.blur()},className:"min-w-0 flex-1 bg-transparent text-xl font-semibold outline-none placeholder:text-muted-foreground/50"},e.id):(0,a.jsx)("span",{className:"text-xl font-semibold",children:m||"Untitled"})]}),(0,a.jsxs)("div",{className:"max-h-[60vh] overflow-y-auto px-4 pb-2",children:[p.map(t=>(0,a.jsxs)("div",{className:"group/col grid grid-cols-[9rem_minmax(0,1fr)] items-center rounded-md [corner-shape:squircle] squircle-safari-fallback hover:bg-muted/40",children:[(0,a.jsx)("div",{className:"flex min-w-0 items-center px-1 text-xs text-muted-foreground",children:c(t)}),(0,a.jsx)("div",{className:"min-w-0 [&>div.justify-center]:justify-start",children:l(e,t)})]},t.id)),(0,a.jsx)(cA,{align:"start",onAdd:d,trigger:(0,a.jsxs)("button",{type:"button",className:"mt-0.5 flex items-center gap-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",children:[(0,a.jsx)(lb.Plus,{className:"h-3.5 w-3.5"})," Add a property"]})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 border-t border-border/60 px-4 py-2.5",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>s(e.id),className:"inline-flex h-7 items-center gap-1 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 text-xs text-muted-foreground hover:bg-accent hover:text-destructive",children:[(0,a.jsx)(l3.TrashIcon,{className:"h-3.5 w-3.5"})," Delete"]}),(0,a.jsx)(ok.DialogClose,{asChild:!0,children:(0,a.jsx)(lT.Button,{size:"sm",variant:"ghost",className:"ml-auto h-7 text-xs",children:"Done"})})]})]})]})})}function cJ({value:e,color:t,onSave:n,onDelete:r,onCancel:i}){return(0,a.jsxs)("div",{children:[(0,a.jsx)(cB,{initialLabel:e,initialColor:t,submitLabel:"Save",onSubmit:n,onCancel:i}),(0,a.jsxs)("button",{type:"button",onClick:r,className:"mx-2 mb-2 flex w-[calc(100%-1rem)] items-center justify-center gap-1 rounded-md py-1 text-xs text-muted-foreground hover:bg-accent hover:text-destructive",children:[(0,a.jsx)(l3.TrashIcon,{className:"h-3 w-3"})," Delete state"]})]})}function cX(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&"record"===e.kind&&"string"==typeof e.id&&"string"==typeof e.name}function cQ(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&"person"===e.kind&&"string"==typeof e.id&&"string"==typeof e.name}function cY(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&"url"in e&&"kind"in e&&("image"===e.kind||"video"===e.kind||"pdf"===e.kind)}let c0=["To-do","Doing","Done"],c1=()=>Math.random().toString(36).slice(2,10);function c2(){let e=[{id:c1(),name:"Name",type:"text"},{id:c1(),name:"Status",type:"select",options:[...c0]},{id:c1(),name:"Date",type:"date"}],t=Array.from({length:3},()=>({id:c1(),cells:Object.fromEntries(e.map(e=>[e.id,"checkbox"!==e.type&&""]))}));return{columns:e,rows:t}}function c3(e){if(!(e instanceof Element))return!1;let t=e.closest("[data-doc-cell]");if(!t)return!1;let n=e.closest('input, textarea, select, button, [contenteditable="true"]');return!n||!t.contains(n)}let c5=G.Node.create({name:"dataTable",group:"block",atom:!0,selectable:!0,draggable:!0,addAttributes:()=>({data:{default:null,parseHTML:e=>{let t=e.getAttribute("data-table");if(!t)return null;try{return JSON.parse(t)}catch{return null}},renderHTML:e=>e.data?{"data-table":JSON.stringify(e.data)}:{}}
2}),parseHTML:()=>[{tag:"div[data-doc-table]"}],renderHTML:({HTMLAttributes:e})=>["div",(0,G.mergeAttributes)(e,{"data-doc-table":""})],addCommands(){return{insertDataTable:()=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:c2()}})}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(cE),addProseMirrorPlugins:()=>[new T.Plugin({props:{handleDOMEvents:{mousedown:(e,t)=>!!(t.target instanceof Element&&t.target.closest("[data-doc-board]"))||c3(t.target),keydown:(e,t)=>!t.metaKey&&!t.ctrlKey&&c3(t.target),keypress:(e,t)=>c3(t.target),beforeinput:(e,t)=>c3(t.target),cut:(e,t)=>c3(t.target)}}})]});var c4=e.i(309211);let c8=G.Mark.create({name:"templateField",inclusive:!1,addOptions:()=>({HTMLAttributes:{}}),addAttributes:()=>({fieldId:{default:null,parseHTML:e=>e.getAttribute("data-field-id"),renderHTML:e=>e.fieldId?{"data-field-id":e.fieldId}:{}},label:{default:"",parseHTML:e=>e.getAttribute("data-field-label")||"",renderHTML:e=>({"data-field-label":e.label??""})}}),parseHTML:()=>[{tag:"span[data-template-field]"}],renderHTML({HTMLAttributes:e}){return["span",(0,G.mergeAttributes)({"data-template-field":"",class:"doc-template-field"},this.options.HTMLAttributes,e),0]},addCommands(){return{setTemplateField:e=>({commands:t})=>t.setMark(this.name,{label:e.label,fieldId:e.fieldId??crypto.randomUUID()}),unsetTemplateField:()=>({commands:e})=>e.unsetMark(this.name)}}});function c6({node:e}){let t=e.attrs.type,n=e.attrs.id,r=e.attrs.label||"Unknown";return(0,a.jsx)(M.NodeViewWrapper,{as:"span",className:"doc-mention-host",children:(0,a.jsx)("span",{contentEditable:!1,onMouseDown:e=>e.stopPropagation(),className:"cursor-pointer",children:(0,a.jsx)(oS.MentionPill,{type:t,id:n,name:r,variant:"pill"})})})}let c9=G.Node.create({name:"docMention",group:"inline",inline:!0,atom:!0,selectable:!0,addAttributes:()=>({type:{default:null},id:{default:null},label:{default:null}}),parseHTML:()=>[{tag:"span[data-mention]",getAttrs:e=>{let t=e.getAttribute("data-mention-type"),n=e.getAttribute("data-mention-id");return!!t&&!!n&&{type:t,id:n,label:e.getAttribute("data-mention-name")||e.textContent?.replace(/^@/,"")||""}}}],renderHTML({node:e,HTMLAttributes:t}){let{type:n,id:r,label:i}=e.attrs;return["span",(0,G.mergeAttributes)(t,{"data-mention":"","data-mention-type":n??"","data-mention-id":r??"","data-mention-name":i??"",class:"doc-mention"}),`@${i??""}`]},addCommands(){return{insertMention:e=>({chain:t})=>t().insertContent([{type:this.name,attrs:e},{type:"text",text:" "}]).run()}},addNodeView:()=>(0,M.ReactNodeViewRenderer)(c6)}),c7=["ArrowDown","ArrowUp","Enter","Tab","Escape"];function de({position:e,query:t,onSelect:n,onClose:r}){let i=(0,s.useRef)(null),o=(0,s.useRef)(null),c=(0,s.useRef)(0),[d,u]=(0,s.useState)(e);return(0,s.useEffect)(()=>{let e=e=>{!c7.includes(e.key)||i.current?.handleKeyDown(e.key)&&(e.preventDefault(),e.stopPropagation())};return window.addEventListener("keydown",e,!0),()=>window.removeEventListener("keydown",e,!0)},[]),(0,s.useEffect)(()=>{c.current=Date.now();let e=e=>{Date.now()-c.current<100||o.current&&!o.current.contains(e.target)&&r()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),(0,s.useLayoutEffect)(()=>
2{let t=o.current;if(!t)return;let n=t.getBoundingClientRect(),r=e.top,i=e.left;r+n.height>window.innerHeight-8&&(r=Math.max(8,e.top-n.height-28)),i+n.width>window.innerWidth-8&&(i=Math.max(8,window.innerWidth-n.width-8)),u({top:r,left:i})},[e,t]),(0,l.createPortal)((0,a.jsx)("div",{ref:o,"data-doc-mention-menu":!0,className:"fixed z-[200] w-80 rounded-[20px] [corner-shape:squircle] squircle-safari-fallback border bg-popover shadow-xl overflow-hidden",style:{top:d.top,left:d.left},onMouseDown:e=>e.preventDefault(),children:(0,a.jsx)(oK.MentionSuggestions,{ref:i,query:t,onSelect:n,onClose:r})}),document.body)}var dt=e.i(350218),dn=e.i(992712);function dr(e){return e.value||e.children||[]}function di({doc:e,name:t,lowlight:n,defaultLanguage:r}){let i=[];return(0,G.findChildren)(e,e=>e.type.name===t).forEach(e=>{var t;let a=e.pos+1,s=e.node.attrs.language||r,l=n.listLanguages();(function e(t,n=[]){return t.flatMap(t=>{let r=[...n,...t.properties?t.properties.className:[]];return t.children?e(t.children,r):{text:t.value,classes:r}})})(s&&(l.includes(s)||dn.default.getLanguage(s)||(null==(t=n.registered)?void 0:t.call(n,s)))?dr(n.highlight(s,e.node.textContent)):dr(n.highlightAuto(e.node.textContent))).forEach(e=>{let t=a+e.text.length;if(e.classes.length){let n=aw.Decoration.inline(a,t,{class:e.classes.join(" ")});i.push(n)}a=t})}),aw.DecorationSet.create(e,i)}let da=dt.CodeBlock.extend({addOptions(){var e;return{...null==(e=this.parent)?void 0:e.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var e;return[...(null==(e=this.parent)?void 0:e.call(this))||[],function({name:e,lowlight:t,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(e=>"function"==typeof t[e]))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");let r=new T.Plugin({key:new T.PluginKey("lowlight"),state:{init:(r,{doc:i})=>di({doc:i,name:e,lowlight:t,defaultLanguage:n}),apply:(r,i,a,s)=>{let l=a.selection.$head.parent.type.name,o=s.selection.$head.parent.type.name,c=(0,G.findChildren)(a.doc,t=>t.type.name===e),d=(0,G.findChildren)(s.doc,t=>t.type.name===e);return r.docChanged&&([l,o].includes(e)||d.length!==c.length||r.steps.some(e=>void 0!==e.from&&void 0!==e.to&&c.some(t=>t.pos>=e.from&&t.pos+t.node.nodeSize<=e.to)))?di({doc:r.doc,name:e,lowlight:t,defaultLanguage:n}):i.map(r.mapping,r.doc)}},props:{decorations:e=>r.getState(e)}});return r}({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}});var ds=e.i(500694);let dl=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],dc=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),dd=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invali
2d","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),du=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),dh=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-
2area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();var dp="[0-9](_*[0-9])*",dm=`\\.(${dp})`,dg="[0-9a-fA-F](_*[0-9a-fA-F])*",df={className:"number",variants:[{begin:`(\\b(${dp})((${dm})|\\.)?|(${dm}))[eE][+-]?(${dp})[fFdD]?\\b`},{begin:`\\b(${dp})((${dm})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${dm})[fFdD]?\\b`},{begin:`\\b(${dp})[fFdD]\\b`},{begin:`\\b0[xX]((${dg})\\.?|(${dg})?\\.(${dg}))[pP][+-]?(${dp})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${dg})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let db="[A-Za-z$_][0-9A-Za-z$_]*",dx=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],dy=["true","false","null","undefined","NaN","Infinity"],dv=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],dw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],d_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decode
2URI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],dk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],dN=[].concat(d_,dv,dw);var dE="[0-9](_*[0-9])*",dC=`\\.(${dE})`,dS="[0-9a-fA-F](_*[0-9a-fA-F])*",dj={className:"number",variants:[{begin:`(\\b(${dE})((${dC})|\\.)?|(${dC}))[eE][+-]?(${dE})[fFdD]?\\b`},{begin:`\\b(${dE})((${dC})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${dC})[fFdD]?\\b`},{begin:`\\b(${dE})[fFdD]\\b`},{begin:`\\b0[xX]((${dS})\\.?|(${dS})?\\.(${dS}))[pP][+-]?(${dE})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${dS})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};let dA=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],dD=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),dM=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),dT=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),dO=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-
2area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),dI=dM.concat(dT).sort().reverse(),dL=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],dR=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),dP=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invali
2d","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),dF=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),dB=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-
2area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function dU(e){return e?"string"==typeof e?e:e.source:null}function d$(e){return dz("(?=",e,")")}function dz(...e){return e.map(e=>dU(e)).join("")}function dq(...e){let t;return"("+(("object"==typeof(t=e[e.length-1])&&t.constructor===Object?(e.splice(e.length-1,1),t):{}).capture?"":"?:")+e.map(e=>dU(e)).join("|")+")"}let dH=e=>dz(/\b/,e,/\w$/.test(e)?/\b/:/\B/),dK=["Protocol","Type"].map(dH),dV=["init","self"].map(dH),dG=["Any","Self"],dW=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],dZ=["false","nil","true"],dJ=["assignment","associativity","higherThan","left","lowerThan","none","right"],dX=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],dQ=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","
2withoutActuallyEscaping","zip"],dY=dq(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),d0=dq(dY,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),d1=dz(dY,d0,"*"),d2=dq(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),d3=dq(d2,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),d5=dz(d2,d3,"*"),d4=dz(/[A-Z]/,d3,"*"),d8=["attached","autoclosure",dz(/convention\(/,dq("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",dz(/objc\(/,d5,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],d6=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"],d9="[A-Za-z$_][0-9A-Za-z$_]*",d7=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],ue=["true","false","null","undefined","NaN","Infinity"],ut=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],un=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],ur=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],ui=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],ua=[].concat(ur,ut,un),us={arduino:function(e){let t,n,r,i,a,s,l,o,c,d,u,h,p,m,g,f,b=(t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),i="[a-zA-Z_]\\w*::",a="(?!struct)("+(r="decltype\\(auto\\)")+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},l={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(l,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",g={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:h={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_
2noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},contains:(m=[p={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},c,s,n,e.C_BLOCK_COMMENT_MODE,o,l]).concat([{begin:/\(/,end:/\)/,keywords:h,contains:m.concat(["self"]),relevance:0}]),relevance:0},f={className:"function",begin:"("+a+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[l,o]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,l,o,s,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,l,o,s]}]},s,n,e.C_BLOCK_COMMENT_MODE,c]},{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:h,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(g,f,p,m,[c,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:h,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:h},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}),x=b.keywords;return x.type=[...x.type,"boolean","byte","word","String"],x.literal=[...x.literal,"DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"],x.built_in=[...x.built_in,"KeyboardController","MouseController","SoftwareSerial","
2EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],x._hints=["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],b.name="Arduino",b.aliases=["ino"],b.supersetOf="cpp",b},bash:function(e){let t=e.regex,n={};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},{begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]}]});let r={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},i=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},s={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,r]};r.contains.push(s);let l={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},o=e.SHEBANG({binary:"(fish|bash|zsh|sh|csh|ksh|tcsh|dash|scsh)",relevance:10}),c={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0};return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],literal:["true","false"],built_in:["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset","alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias","set","shopt","autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp","chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"]},contains:[o,e.SHEBANG(),c,l,i,a,{match:/(\/[a-z._-]+)+/},s,{match:/\\"/},{className:"string",begin:/'/,end:/'/},{match:/\\'/},n]}},c:function(e){let t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}
vendor: 5,675 bytes, line 2
2),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",a="("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},l={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(l,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",h={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},p=[c,s,n,e.C_BLOCK_COMMENT_MODE,o,l],m={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:h,contains:p.concat([{begin:/\(/,end:/\)/,keywords:h,contains:p.concat(["self"]),relevance:0}]),relevance:0},g={begin:"("+a+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[e.inherit(d,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,l,o,s,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,l,o,s]}]},s,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C",aliases:["h"],keywords:h,disableAutodetect:!0,illegal:"</",contains:[].concat(m,g,p,[c,{begin:e.IDENT_RE+"::",keywords:h},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:c,strings:l,keywords:h}}},cpp:function(e){let t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",a="(?!struct)("+r+"|"+t.optional(i)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",s={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},l={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'(\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},o={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},c={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(l,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},d={className:"title",begin:t.optional(i)+e.IDENT_RE,relevance:0},u=t.optional(i)+e.IDENT_RE+"\\s*\\(",h={type:["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],keyword:["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_
2noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"]},p={className:"function.dispatch",relevance:0,keywords:{_hint:["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"]},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},m=[p,c,s,n,e.C_BLOCK_COMMENT_MODE,o,l],g={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:h,contains:m.concat([{begin:/\(/,end:/\)/,keywords:h,contains:m.concat(["self"]),relevance:0}]),relevance:0},f={className:"function",begin:"("+a+"[\\*&\\s]+)+"+u,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:h,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:h,relevance:0},{begin:u,returnBegin:!0,contains:[d],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[l,o]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,l,o,s,{begin:/\(/,end:/\)/,keywords:h,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,l,o,s]}]},s,n,e.C_BLOCK_COMMENT_MODE,c]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:h,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(g,f,p,m,[c,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:h,contains:["self",s]},{begin:e.IDENT_RE+"::",keywords:h},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}},csharp:function(e){let t={keyword:["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","
2sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"].concat(["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"]),built_in:["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],literal:["default","false","null","true"]},n=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),r={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},i={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},a=e.inherit(i,{illegal:/\n/}),s={className:"subst",begin:/\{/,end:/\}/,keywords:t},l=e.inherit(s,{illegal:/\n/}),o={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,l]},c={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},s]},d=e.inherit(c,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},l]});s.contains=[c,o,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.C_BLOCK_COMMENT_MODE],l.contains=[d,o,a,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];let u={variants:[{className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},c,o,i,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},h={begin:"<",end:">",contains:[{beginKeywords:"in out"},n]},p=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",m={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:t,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},u,r,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},n,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[n,h,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+p+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:t,contains:[{beginKeywords:"public private protected static internal protected abstract async extern override unsafe virtual new sealed partial",relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,h],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:t,relevance:0,contains:[u,r,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},m]}},css:function(e){let t=e.regex,n={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}
vendor: 4,515 bytes, line 2
2,r=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,{begin:/-(webkit|moz|ms|o)-(?=[a-z])/},n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+dd.join("|")+")"},{begin:":(:)?("+du.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+dh.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...r,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...r,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:dc.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...r,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+dl.join("|")+")\\b"}]}},diff:function(e){let t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}},go:function(e){let t={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:t,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,illegal:/["']/}]}]}},graphql:function(e){let t=e.regex;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(/[_A-Za-z][_0-9A-Za-z]*/,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}},ini:function(e){let t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];let i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},a={className:"literal",begin:/\bon|off|true|false|yes|no\b/},s={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},l=t.either(/[A-Za-z0-9_-]+/,/"(\\"|[^"])*"/,/'[^']*'/);return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,c
vendor: 5,861 bytes, line 2
2ontains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:t.concat(l,"(\\s*\\.\\s*",l,")*",t.lookahead(/\s*=\s*[^#\s]/)),className:"attr",starts:{end:/$/,contains:[r,{begin:/\[/,end:/\]/,contains:[r,a,i,s,n,"self"],relevance:0},a,i,s,n]}}]}},java:function(e){let t=e.regex,n="[Ã-ʸa-zA-Z_$][Ã-ʸa-zA-Z_$0-9]*",r=n+function e(t,n,r){return -1===r?"":t.replace(n,i=>e(t,n,r-1))}("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),i={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},a={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},s={className:"params",begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:i,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[s,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:i,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:i,relevance:0,contains:[a,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,df,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},df,a]}},javascript:function(e){var t;let n=e.regex,r=/<[A-Za-z0-9\\._:-]+/,i=/\/[A-Za-z0-9\\._:-]+>|\/>/,a={$pattern:db,keyword:dx,literal:dy,built_in:dN,"variable.language":dk},s="[0-9](_?[0-9])*",l=`\\.(${s})`,o="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",c={className:"number",variants:[{begin:`(\\b(${o})((${l})|\\.)?|(${l}))[eE][+-]?(${s})\\b`},{begin:`\\b(${o})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},d={className:"subst",begin:"\\$\\{",end:"\\}",keywords:a,contains:[]},u={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"css"}},p={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"graphql"}},m={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,d]},g={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:db+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},f=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,h,p,m,{match:/\$\d+/},c];d.contains=f.concat({begin:/\{/,end:/\}/,keywords:a,contains:["self"].concat(f)});let b=[].concat(g,d.contains),x=b.concat([{begin:/(\s*)\(/,end:/\)/,keywords:a,contains:["self"].concat(b)}]),y={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:x},v={variants:[{match:[/class/,/\s+/,db,/\s+/,/extends/,/\s+/,n.concat(db,"(",n.concat(/\./,db),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,db],scope:{1:"keyword",3:"title.class"}}]},w={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...dv,...dw]}},_={match:n.concat(/\b/,(t=[...d_,"super","import"].map(e=>`${e}\\s*\\(`),n.concat("(?!",t.join("|"),")")),db,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},k={begin:n.concat(/\./,n.lookahead(n.concat(db,/(?![0-9A-Za-z$_(])/))),end:db,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},N="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",E={match:[/const|var|let/,/\s+/,db,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(N)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[y]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:a,exports:{PARAMS_CONTAINS:x,CLASS_REFERENCE:w},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,u,h,p,m,g,{match:/\$\d+/},c,w,{scope:"attr",match:db+n.lookahead(":"),relevance:0},E,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[g,e.REGEXP_MODE,{className:"function",begin:N,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0}
2,{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:a,contains:x}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r,"on:begin":(e,t)=>{let n,r=e[0].length+e.index,i=e.input[r];if("<"===i||","===i)return void t.ignoreMatch();">"!==i||((e,{after:t})=>{let n="</"+e[0].slice(1);return -1!==e.input.indexOf(n,t)})(e,{after:r})||t.ignoreMatch();let a=e.input.substring(r);if((n=a.match(/^\s*=/))||(n=a.match(/^\s+extends\s+/))&&0===n.index)return void t.ignoreMatch()},end:i}],subLanguage:"xml",contains:[{begin:r,end:i,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,db,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[y],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[y,e.inherit(e.TITLE_MODE,{begin:db,className:"title.function"})]},{match:/\.\.\./,relevance:0},k,{match:"\\$"+db,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[y]},_,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},v,{match:[/get|set/,/\s+/,db,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},y]},{match:/\$[(.]/}]}},json:function(e){let t=["true","false","null"],n={scope:"literal",beginKeywords:t.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:t},contains:[{className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},{match:/[{}[\],:]/,className:"punctuation",relevance:0},e.QUOTE_STRING_MODE,n,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}},kotlin:function(e){let t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},r={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},a={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,r]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,i,r]}]};r.contains.push(a);let s={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},l={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(a,{className:"string"}),"self"]}]},o=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),c={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]};return c.variants[1].contains=[c],c.variants[1].contains=[c],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,o,{className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},n,s,l,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[c,e.C_LINE_COMMENT_MODE,o],relevance:0},e.C_LINE_COMMENT_MODE,o,s,l,a,e.C_NUMBER_MODE]},o]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0}
2,{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},s,l]},a,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:"\n"},dj]}},less:function(e){let t={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},n="[\\w-]+",r="("+n+"|@\\{"+n+"\\})",i=[],a=[],s=function(e){return{className:"string",begin:"~?"+e+".*?"+e}},l=function(e,t,n){return{className:e,begin:t,relevance:n}},o={$pattern:/[a-z-]+/,keyword:"and or not only",attribute:dD.join(" ")};a.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s("'"),s('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,{begin:"\\(",end:"\\)",contains:a,keywords:o,relevance:0},l("variable","@@?"+n,10),l("variable","@\\{"+n+"\\}"),l("built_in","~?`[^`]*?`"),{className:"attribute",begin:n+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);let c=a.concat({begin:/\{/,end:/\}/,contains:i}),d={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(a)},u={begin:r+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+dO.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:a}}]},h={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:r,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:"[<='$\"]",relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,d,l("keyword","all\\b"),l("variable","@\\{"+n+"\\}"),{begin:"\\b("+dA.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,l("selector-tag",r,0),l("selector-id","#"+r),l("selector-class","\\."+r,0),l("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+dM.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+dT.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:c},{begin:"!important"},t.FUNCTION_DISPATCH]},p={begin:n+":(:)?"+`(${dI.join("|")})`,returnBegin:!0,contains:[h]};return i.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:o,returnEnd:!0,contains:a,relevance:0}},{className:"variable",variants:[{begin:"@"+n+"\\s*:",relevance:15},{begin:"@"+n}],starts:{end:"[;}]",returnEnd:!0,contains:c}},p,u,h,d,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:"[=>'/<($\"]",contains:i}},lua:function(e){let t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},i=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:i.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}},makefile:function(e){let t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,{className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},r,{className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},{className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]}]}},markdown:function(e){let t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,/[A-Za-z][A-Za-z0-9+.-]*/,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},i={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},a={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/}
2,{begin:/_(?![_\s])/,end:/_/,relevance:0}]},s=e.inherit(i,{contains:[]}),l=e.inherit(a,{contains:[]});i.contains.push(l),a.contains.push(s);let o=[n,r];return[i,a,s,l].forEach(e=>{e.contains=e.contains.concat(o)}),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:o=o.concat(i,a)},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:o}]}]},n,{className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i,a,{className:"quote",begin:"^>\\s+",contains:o,end:"$"},{className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},{begin:"^[-\\*]{3,}",end:"$"},r,{begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}},objectivec:function(e){let t=/[a-zA-Z@][a-zA-Z0-9_]*/,n={$pattern:t,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:{"variable.language":["this","super"],$pattern:t,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},illegal:"</",contains:[{className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+n.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:n,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}},perl:function(e){let t=e.regex,n=/[dualxmsipngr]{0,12}/,r={$pattern:/[\w.]+/,keyword:"abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot class close closedir c
2onnect continue cos crypt dbmclose dbmopen defined delete die do dump each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eval exec exists exit exp fcntl field fileno flock for foreach fork format formline getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst length link listen local localtime log lstat lt ma map method mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q|0 qq quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x|0 xor y|0"},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:r},a={begin:/->\{/,end:/\}/},s={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},l={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[s]},o={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},c=[e.BACKSLASH_ESCAPE,i,l],d=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],u=(e,r,i="\\1")=>{let a="\\1"===i?i:t.concat(i,r);return t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,a,/(?:\\.|[^\\\/])*?/,i,n)},h=(e,r,i)=>t.concat(t.concat("(?:",e,")"),r,/(?:\\.|[^\\\/])*?/,i,n),p=[l,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),a,{className:"string",contains:c,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},o,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:u("s|tr|y",t.either(...d,{capture:!0}))},{begin:u("s|tr|y","\\(","\\)")},{begin:u("s|tr|y","\\[","\\]")},{begin:u("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:h("(?:m|qr)?",/\//,/\//)},{begin:h("m|qr",t.either(...d,{capture:!0}),/\1/)},{begin:h("m|qr",/\(/,/\)/)},{begin:h("m|qr",/\[/,/\]/)},{begin:h("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,s,o]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=p,a.contains=p,{name:"Perl",aliases:["pl","pm"],keywords:r,contains:p}},php:function(e){let t,n=e.regex,r=/(?![A-Za-z0-9])(?![$])/,i=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,r),a=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,r),s=n.concat(/[A-Z]+/,r),l={scope:"variable",match:"\\$+"+i},o={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},c=e.inherit(e.APOS_STRING_MODE,{illegal:null}),d=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(o)}),u={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(o),"on:begin":(e,t)=>
vendor: 13,276 bytes, line 2
2{t.data._beginMatch=e[1]||e[2]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}},h=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),p="[ \n]",m={scope:"string",variants:[d,c,u,h]},g={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},f=["false","null","true"],b=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],x=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],y={keyword:b,literal:(t=[],f.forEach(e=>{t.push(e),e.toLowerCase()===e?t.push(e.toUpperCase()):t.push(e.toLowerCase())}),t),built_in:x},v=e=>e.map(e=>e.replace(/\|\d+$/,"")),w={variants:[{match:[/new/,n.concat(p,"+"),n.concat("(?!",v(x).join("\\b|"),"\\b)"),a],scope:{1:"keyword",4:"title.class"}}]},_=n.concat(i,"\\b(?!\\()"),k={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),_],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[a,n.concat(/::/,n.lookahead(/(?!class\b)/)),_],scope:{1:"title.class",3:"variable.constant"}},{match:[a,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[a,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},N={scope:"attr",match:n.concat(i,n.lookahead(":"),n.lookahead(/(?!::)/))},E={relevance:0,begin:/\(/,end:/\)/,keywords:y,contains:[N,l,k,e.C_BLOCK_COMMENT_MODE,m,g,w]},C={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",v(b).join("\\b|"),"|",v(x).join("\\b|"),"\\b)"),i,n.concat(p,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[E]};E.contains.push(C);let S=[N,k,e.C_BLOCK_COMMENT_MODE,m,g,w],j={begin:n.concat(/#\[\s*\\?/,n.either(a,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:f,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:f,keyword:["new","array"]},contains:["self",...S]},...S,{scope:"meta",variants:[{match:a},{match:s}]}]};return{case_insensitive:!1,keywords:y,contains:[j,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},{scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},{scope:"variable.language",match:/\$this\b/},l,C,k,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},w,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:y,contains:["self",j,l,k,e.C_BLOCK_COMMENT_MODE,m,g]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},m,g]}},"php-template":function(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}},plaintext:function(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}},python:function(e){let t=e.regex,n=/[\p{XID_Start}_]\p{XID_Continue}*/u,r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],i={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},s={className:"subst",begin:/\{/,end:/\}/,keywords:i,illegal:/#/},l={begin:/\{\{/,relevance:0},o={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,a,l,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,a,l,s]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,l,s]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,l,s]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},c="[0-9](_?[0-9])*",d=`(\\b(${c}))?\\.(${c})|\\b(${c})\\.`,u=`\\b|${r.join("|")}`,h={className:"number",relevance:0,variants:[{begin:`(\\b(${c})|(${d}))[eE][+-]?(${c})[jJ]?(?=${u})`},{begin:`(${d})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${u})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${u})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${u})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${u})`},{begin:`\\b(${c})[jJ](?=${u})`}]},p={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:i,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},m={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:i,contains:["self",a,h,o,e.HASH_COMMENT_MODE]}]};return s.contains=[o,h,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:i,illegal:/(<\/|\?)|=>/,contains:[a,h,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},o,p,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[m]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[h,m,o]}]}},"python-repl":function(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}},r:function(e){let t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,a=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[i,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[a,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:a},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}},ruby:function(e){let t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),i=t.concat(r,/(::\w+)*/),a={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield","include","extend","prepe
vendor: 7,018 bytes, line 2
2nd","public","private","protected","raise","throw"],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},s={className:"doctag",begin:"@[A-Za-z]+"},l={begin:"#<",end:">"},o=[e.COMMENT("#","$",{contains:[s]}),e.COMMENT("^=begin","^=end",{contains:[s],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],c={className:"subst",begin:/#\{/,end:/\}/,keywords:a},d={className:"string",contains:[e.BACKSLASH_ESCAPE,c],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,c]})]}]},u="[0-9](_?[0-9])*",h={className:"number",relevance:0,variants:[{begin:`\\b([1-9](_?[0-9])*|0)(\\.(${u}))?([eE][+-]?(${u})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},p={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:a}]},m=[d,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:a},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:a},{relevance:0,match:[i,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[p]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[d,{begin:n}],relevance:0},h,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:a},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,c],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(l,o),relevance:0}].concat(l,o);c.contains=m,p.contains=m;let g=[{begin:/^\s*=>/,starts:{end:"$",contains:m}},{className:"meta.prompt",begin:"^([>?]>|[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]|(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>)(?=[ ])",starts:{end:"$",keywords:a,contains:m}}];return o.unshift(l),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:a,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(g).concat(o).concat(m)}},rust:function(e){let t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),a={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,t.lookahead(/\s*\(/))},s="([ui](8|16|32|64|128|size)|f(32|64))?",l=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],o=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:o,keyword:["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],literal:["true","false","Some","None","Ok","Err"],built_in:l},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+s},{begin:"\\b0o([0-7_]+)"+s},{begin:"\\b0x([A-Fa-f0-9_]+)"+s},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+s}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:l,type:o}},{className:"punctuation",begin:"->"},a]}},scss:function(e){let t={IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}},n="@[a-z-]+",r={className:"variable",begin:"(\\$[a-zA-Z-][a-zA-Z0-9_-]*)\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0}
vendor: 1,113 bytes, line 2
2,{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+dL.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+dP.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+dF.join("|")+")"},r,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+dB.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inl
2ine-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,r,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:n,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:"and or not only",attribute:dR.join(" ")},contains:[{begin:n,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},r,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}},shell:function(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}},sql:function(e){let t=e.regex,n=e.COMMENT("--","$"),r=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],i=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","ver
2sioning","when","whenever","where","width_bucket","window","with","within","without","year","add","asc","collation","desc","final","first","last","view"].filter(e=>!r.includes(e)),a={match:t.concat(/\b/,t.either(...r),/\s*\(/),relevance:0,keywords:{built_in:r}};function s(e){return t.concat(/\b/,t.either(...e.map(e=>e.replace(/\s+/,"\\s+"))),/\b/)}let l={scope:"keyword",match:s(["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"]),relevance:0};return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:function(e,{exceptions:t,when:n}={}){return t=t||[],e.map(e=>e.match(/\|\d+$/)||t.includes(e)?e:n(e)?`${e}|0`:e)}(i,{when:e=>e.length<3}),literal:["true","false","unknown"],type:["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],built_in:["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"]},contains:[{scope:"type",match:s(["double precision","large object","with timezone","without timezone"])},l,a,{scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},{scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},{begin:/"/,end:/"/,contains:[{match:/""/}]},e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,{scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0}]}},swift:function(e){let t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,dq(...dK,...dV)],className:{2:"keyword"}},a={match:dz(/\./,dq(...dW)),relevance:0},s=dW.filter(e=>"string"==typeof e).concat(["_|0"]),l={variants:[{className:"keyword",match:dq(...dW.filter(e=>"string"!=typeof e).concat(dG).map(dH),...dV)}]},o={$pattern:dq(/\b\w+/,/#\w+/),keyword:s.concat(dX),literal:dZ},c=[i,a,l],d=[{match:dz(/\./,dq(...dQ)),relevance:0},{className:"built_in",match:dz(/\b/,dq(...dQ),/(?=\()/)}],u={match:/->/,relevance:0},h=[u,{className:"operator",relevance:0,variants:[{match:d1},{match:`\\.(\\.|${d0})+`}]}],p="([0-9]_*)+",m="([0-9a-fA-F]_*)+",g={className:"number",relevance:0,variants:[{match:`\\b(${p})(\\.(${p}))?([eE][+-]?(${p}))?\\b`},{match:`\\b0x(${m})(\\.(${m}))?([pP][+-]?(${p}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},f=(e="")=>({className:"subst",variants:[{match:dz(/\\/,e,/[0\\tnr"']/)},{match:dz(/\\/,e,/u\{[0-9a-fA-F]{1,8}\}/)}]}),b=(e="")=>({className:"subst",label:"interpol",begin:dz(/\\/,e,/\(/),end:/\)/}),x=(e="")=>({begin:dz(e,/"""/),end:dz(/"""/,e),contains:[f(e),((e="")=>({className:"subst",match:dz(/\\/,e,/[\t ]*(?:[\r\n]|\r\n)/)}))(e),b(e)]}),y=(e="")=>({begin:dz(e,/"/),end:dz(/"/,e),contains:[f(e),b(e)]}),v={className:"string",variants:[x(),x("#"),x("##"),x("###"),y(),y("#"),y("##"),y("###")]},w=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],_=e=>{let t=dz(e,/\//),n=dz(/\//,e);return{begin:t,end:n,contains:[...w,{scope:"comment",begin:`#(?!.*${n})`,end:/$/}]}},k={scope:"regexp",variants:[_("###"),_("##"),_("#"),{begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:w}]},N={match:dz(/`/,d5,/`/)},E=[N,{className:"variable",match:/\$\d+/},{className:"variable",match:`\\$${d3}+`}],C=[{match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:d6,contains:[...h,g,v]}]}},{scope:"keyword",match:dz(/@/,dq(...d8),d$(dq(/\(/,/\s+/)))},{scope:"meta",match:dz(/@/,d5)}],S={match:d$(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:dz(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,d3,"+")},{className:"type",match:d4,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:dz(/\s+&\s+/,d$(d4)),relevance:0}]},j={begin:/</,end:/>/,keywords:o,contains:[...r,...c,...C,u,S]};S.contains.push(j);let A={begin:/\(/,end:/\)/,relevance:0,keywords:o,contains:["self",{match:dz(d5,/\s*:/),keywords:"_|0",relevance:0},...r,k,...c,...d,...h,g,v,...E,...C,S]},D={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,S]},M={begin:/\(/,end:/\)/,keywords:o,contains:[{begin:dq(d$(dz(d5,/\s*:/)),d$(dz(d5,/\s+/,d5,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:d5}]},...r,...c,...h,g,v,...C,S,A],endsParent:!0,illegal:/["']/},T={match:[/(func|macro)/,/\s+/,dq(N.match,d5,d1)],className:{1:"keyword",3:"title.function"},contains:[D,M,t],illegal:[/\[/,/%/]},O={begin:[/precedencegroup/,/\s+/,d4],className:{1:"keyword",3:"title"},contains:[S],keywords:[...dJ,...dZ],end:/}/},I={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,d5,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:o,contains:[D,...c,{begin:/:/,end:/\{/,keywords:o,contains:[{scope:"title.class.inherited",match:d4},...c],relevance:0}]};for(let e of v.variants){let t=e.contains.find(e=>"interpol"===e.label);t.keywords=o;let n=[...c,...d,...h,g,v,...E];t.contains=[...n,{begin:/\(/,end:/\)/,contains:["self",...n]}]}return{name:"Swift",keywords:o,contains:[...r,T,{match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[D,M,t],illegal:/\[|%/},{match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/
2],scope:{1:"keyword",3:"keyword",5:"title.function"}},{match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},I,{match:[/operator/,/\s+/,d1],className:{1:"keyword",3:"title"}},O,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},k,...c,...d,...h,g,v,...E,...C,S,A]}},typescript:function(e){var t;let n,r,i,a,s,l,o,c,d,u,h,p,m,g,f,b,x,y,v,w,_,k,N,E,C,S=e.regex,j=(n=e.regex,r=/<[A-Za-z0-9\\._:-]+/,i=/\/[A-Za-z0-9\\._:-]+>|\/>/,a=(e,t)=>{let n,r=e[0].length+e.index,i=e.input[r];if("<"===i||","===i)return void t.ignoreMatch();">"!==i||((e,{after:t})=>{let n="</"+e[0].slice(1);return -1!==e.input.indexOf(n,t)})(e,{after:r})||t.ignoreMatch();let a=e.input.substring(r);if((n=a.match(/^\s*=/))||(n=a.match(/^\s+extends\s+/))&&0===n.index)return void t.ignoreMatch()},s={$pattern:d9,keyword:d7,literal:ue,built_in:ua,"variable.language":ui},l="[0-9](_?[0-9])*",o=`\\.(${l})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${c})((${o})|\\.)?|(${o}))[eE][+-]?(${l})\\b`},{begin:`\\b(${c})\\b((${o})\\b|\\.)?|(${o})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},u={className:"subst",begin:"\\$\\{",end:"\\}",keywords:s,contains:[]},h={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,u],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,u]},f={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:d9+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},u.contains=(b=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,h,p,m,g,{match:/\$\d+/},d]).concat({begin:/\{/,end:/\}/,keywords:s,contains:["self"].concat(b)}),y=(x=[].concat(f,u.contains)).concat([{begin:/(\s*)\(/,end:/\)/,keywords:s,contains:["self"].concat(x)}]),v={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:y},w={variants:[{match:[/class/,/\s+/,d9,/\s+/,/extends/,/\s+/,n.concat(d9,"(",n.concat(/\./,d9),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,d9],scope:{1:"keyword",3:"title.class"}}]},_={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...ut,...un]}},k={match:n.concat(/\b/,(t=[...ur,"super","import"].map(e=>`${e}\\s*\\(`),n.concat("(?!",t.join("|"),")")),d9,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},N={begin:n.concat(/\./,n.lookahead(n.concat(d9,/(?![0-9A-Za-z$_(])/))),end:d9,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},E="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",C={match:[/const|var|let/,/\s+/,d9,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(E)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[v]},{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:s,exports:{PARAMS_CONTAINS:y,CLASS_REFERENCE:_},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,h,p,m,g,f,{match:/\$\d+/},d,_,{scope:"attr",match:d9+n.lookahead(":"),relevance:0},C,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[f,e.REGEXP_MODE,{className:"function",begin:E,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0}
2,{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:s,contains:y}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:"<>",end:"</>"},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r,"on:begin":a,end:i}],subLanguage:"xml",contains:[{begin:r,end:i,skip:!0,contains:["self"]}]}]},{variants:[{match:[/function/,/\s+/,d9,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[v],illegal:/%/},{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[v,e.inherit(e.TITLE_MODE,{begin:d9,className:"title.function"})]},{match:/\.\.\./,relevance:0},N,{match:"\\$"+d9,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[v]},k,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},w,{match:[/get|set/,/\s+/,d9,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},v]},{match:/\$[(.]/}]}),A=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],D={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},M={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:A},contains:[j.exports.CLASS_REFERENCE]},T={$pattern:d9,keyword:d7.concat(["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"]),literal:ue,built_in:ua.concat(A),"variable.language":ui},O={className:"meta",begin:"@"+d9},I=(e,t,n)=>{let r=e.contains.findIndex(e=>e.label===t);if(-1===r)throw Error("can not find mode to replace");e.contains.splice(r,1,n)};Object.assign(j.keywords,T),j.exports.PARAMS_CONTAINS.push(O);let L=j.contains.find(e=>"attr"===e.scope),R=Object.assign({},L,{match:S.concat(d9,S.lookahead(/\s*\?:/))});return j.exports.PARAMS_CONTAINS.push([j.exports.CLASS_REFERENCE,L,R]),j.contains=j.contains.concat([O,D,M,R]),I(j,"shebang",e.SHEBANG()),I(j,"use_strict",{className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/}),j.contains.find(e=>"func.def"===e.label).relevance=0,Object.assign(j,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),j},vbnet:function(e){let t=e.regex,n=/\d{1,2}\/\d{1,2}\/\d{4}/,r=/\d{4}-\d{1,2}-\d{1,2}/,i=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,a=/\d{1,2}(:\d{1,2}){1,2}/,s={className:"literal",variants:[{begin:t.concat(/# */,t.either(r,n),/ *#/)},{begin:t.concat(/# */,a,/ *#/)},{begin:t.concat(/# */,i,/ *#/)},{begin:t.concat(/# */,t.either(r,n),/ +/,t.either(i,a),/ *#/)}]},l=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),o=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single str
2ing uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[{className:"string",begin:/"(""|[^/n])"C\b/},{className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s,{className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},{className:"label",begin:/^\w+:/},l,o,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[o]}]}},wasm:function(e){e.regex;let t=e.COMMENT(/\(;/,/;\)/);return t.contains.push("self"),{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"]},contains:[e.COMMENT(/;;/,/$/),t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},{className:"variable",begin:/\$[\w_]+/},{match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},{begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},e.QUOTE_STRING_MODE,{match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},{className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/},{className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/}]}},xml:e.i(216571).default,yaml:function(e){let t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,{className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]}]},i=e.inherit(r,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),a={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},s=[{className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},{className:"number",begin:"\\b[0-9]{4}(-[0-9][0-9]){0,2}([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?(\\.[0-9]*)?([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?\\b"},{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},{begin:/\{/,end:/\}/,contains:[a],illegal:"\\n",relevance:0},{begin:"\\[",end:"\\]",contains:[a],illegal:"\\n",relevance:0},{className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},r],l=[...s];return l.pop(),l.push(i),a.contains=l,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:s}}};var ul=e.i(26984),uo=e.i(283686),uc=e.i(992427),ud=e.i(543067),uu=e.i(989926);function uh({editor:e,containerEl:t}){let n=(0,s.useRef)(null),r=(0,s.useRef)(null),i=(0,s.useRef)(!1);return(0,s.useEffect)(()=>
2{if(!e||!t)return;let a=e.view,s=a.dom,l=null,o=null,c=()=>{n.current&&(n.current.style.visibility="hidden"),r.current=null},d=d=>{i.current||!e.isEditable||(s.classList.contains("is-block-dragging")?c():(o={x:d.clientX,y:d.clientY},null===l&&(l=requestAnimationFrame(()=>{l=null;let e=o;if(o=null,!e)return;let i=function(e,t,n){let r=e.dom,i=document.elementFromPoint(t,n);if(!i||i===r||!r.contains(i))return null;let a=i;for(;a&&a.parentElement!==r;)a=a.parentElement;if(!a)return null;try{let t=e.posAtDOM(a,0),n=e.state.doc.resolve(t),r=0===n.depth?t:n.before(1),i=e.state.doc.nodeAt(r);if(!i)return null;return{start:r,node:i,dom:a}}catch{return null}}(a,e.x,e.y);if(!i||"columns"===i.node.type.name)return void c();let s=n.current;if(!s)return;r.current=i;let d=t.getBoundingClientRect(),u=i.dom.getBoundingClientRect();s.style.top=`${u.top-d.top}px`,s.style.height=`${u.height}px`,s.style.left=`${u.right-d.left-4}px`,s.style.visibility="visible"}))))},u=e=>{if(i.current)return;let t=e.relatedTarget;t&&n.current?.contains(t)||c()};return s.addEventListener("mousemove",d),s.addEventListener("mouseleave",u),()=>{null!==l&&cancelAnimationFrame(l),s.removeEventListener("mousemove",d),s.removeEventListener("mouseleave",u)}},[e,t]),(0,a.jsx)("div",{ref:n,className:"doc-split-handle",style:{visibility:"hidden"},onPointerDown:a=>{if(0!==a.button||!e?.isEditable||!t)return;let s=r.current;if(!s)return;a.preventDefault(),a.stopPropagation();let l=e.view,o=s.dom,c=s.node,d=s.start,u=o.getBoundingClientRect(),h=u.width;if(h<172)return;let p=t.getBoundingClientRect(),m=n.current,g=a.clientX,f=!1,b=h,x=null,y=e=>{let n=e.clientX-g;if(!f){if(4>Math.abs(n))return;f=!0,i.current=!0,document.body.style.cursor="col-resize",m?.classList.add("is-active"),(x=document.createElement("div")).className="doc-split-ghost",x.style.top=`${u.top-p.top}px`,x.style.height=`${Math.max(u.height,28)}px`,t.appendChild(x)}b=Math.max(60,Math.min(h-60-52,h+n)),o.style.width=`${b}px`,m&&(m.style.left=`${u.left-p.left+b+26-8}px`),x&&(x.style.left=`${u.left-p.left+b+52}px`,x.style.width=`${h-b-52}px`)},v=()=>{if(window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),o.style.width="",x?.remove(),m?.classList.remove("is-active"),document.body.style.cursor="",i.current=!1,!f||l.state.doc.nodeAt(d)!==c)return;let{columns:e,column:t,paragraph:n}=l.state.schema.nodes;if(!e||!t||!n)return;let r=b/h*100;try{let i=t.create({width:r},O.Fragment.from(c)),a=t.create({width:100-r},n.create()),s=e.create(null,O.Fragment.fromArray([i,a])),o=l.state.tr.replaceWith(d,d+c.nodeSize,s),u=d+1+i.nodeSize+2;o.setSelection(T.TextSelection.create(o.doc,u)),l.dispatch(o),l.focus()}catch(e){console.warn("[doc-block-split-handle] split failed",e)}};window.addEventListener("pointermove",y),window.addEventListener("pointerup",v)},onMouseEnter:()=>{n.current&&(n.current.style.visibility="visible")},onMouseLeave:t=>{if(i.current)return;let r=t.relatedTarget;!(r&&e?.view.dom.contains(r))&&n.current&&(n.current.style.visibility="hidden")},"aria-label":"Resize block into columns",title:"Drag to split into columns"})}var up=e.i(742008),um=e.i(395567),ug=e.i(656766),uf=e.i(567136),ub=e.i(452997),ux=e.i(672922),uy=e.i(723448);let uv=(0,ds.createLowlight)(us),uw=/^(image|video)\//,u_=/\.(png|jpe?g|gif|webp|heic|heif|svg|mov|mp4|m4v|webm|pdf)$/i,uk=e=>uw.test(e.type)||"application/pdf"===e.type||u_.test(e.name),uN=[{id:"paragraph",label:"Text",description:"Plain paragraph",icon:sN.Type,aliases:["p","text"]},{id:"heading1",label:"Heading 1",description:"Large heading",icon:sE.Heading1,aliases:["h1"]},{id:"heading2",label:"Heading 2",description:"Medium heading",icon:sC.Heading2,aliases:["h2"]},{id:"heading3",label:"Heading 3",description:"Small heading",icon:sS.Heading3,aliases:["h3"]},{id:"bulletList",label:"Bullet List",description:"Unordered list",icon:sj.List,aliases:["ul","bullets"]},{id:"orderedList",label:"Numbered List",description:"Ordered list",icon:sA.ListOrdered,aliases:["ol","numbers"]},{id:"taskList",label:"Task List",description:"Checklist with to-dos",icon:sD.CheckSquare,aliases:["todo","checklist"]},{id:"blockquote",label:"Quote",description:"Block quote",icon:sM.Quote,aliases:["quote","bq"]},{id:"callout",label:"Callout",description:"Highlighted info box with icon",icon:sK.Lightbulb,aliases:["note","tip","info","box","warning"]},{id:"codeBlock",label:"Code Block",description:"Monospace code",icon:sT.Code,aliases:["code","pre"]},{id:"horizontalRule",label:"Divider",description:"Horizontal line",icon:sO.Minus,aliases:["hr","divider","line"]},{id:"image",label:"Image",description:"Upload an image",icon:sI.ImageIcon,aliases:["img","photo"]},{id:"video",label:"Video",description:"Upload a video",icon:sL.Video,aliases:["movie","mp4"]},{id:"pdf",label:"PDF",description:"Upload a PDF",icon:sz.default,aliases:["pdf","document","file","attachment"]},{id:"page",label:"Page",description:"Embed a new sub-page",icon:s$.FileText,aliases:["doc","subpage","nested"]},{id:"slide",label:"Slide",description:"A 16:9 slide you can present full screen",icon:j.Presentation,aliases:["slides","deck","present","presentation","keynote","ppt"]},{id:"tabs",label:"Tabs",description:"Multiple panels in one block",icon:sq.default,aliases:["tab","tabbed","sections"]},{id:"columns2",label:"2 Columns",description:"Two side-by-side columns",icon:sH.default,aliases:["column","col","split","side","2col"]},{id:"columns3",label:"3 Columns",description:"Three side-by-side columns",icon:sH.default,aliases:["3col","three"]},{id:"columns4",label:"4 Columns",description:"Four side-by-side columns",icon:sH.default,aliases:["4col","four"]},{id:"columns5",label:"5 Columns",description:"Five side-by-side columns",icon:sH.default,aliases:["5col","five"]},{id:"table",label:"Table",description:"Sortable, filterable data table",icon:sZ.default,aliases:["grid","db","database","sheet","spreadsheet","data"]},{id:"map",label:"Map",description:"An address, or a list of them, with pins on a map",icon:s8.MapPin,aliases:["address","location","pin","place","directions","geo"]},{id:"statusPill",label:"Status",description:"Inline status pill, optionally with a progress bar",icon:sQ.Percent,aliases:["pill","badge","chip","progress","percent","bar"]},{id:"date",label:"Date",description:"Inline date with a calendar picker",icon:sY.CalendarDays,aliases:["day","calendar","due","deadline","today"]},{id:"datetime",label:"Date & time",description:"Inline date with a time",icon:s0.CalendarClock,aliases:["datetime","time","clock","when","schedule"]},{id:"dateRange",label:"Date range",description:"Inline start and end date",icon:s1.CalendarRange,aliases:["range","daterange","span","period","from","until","between"]},{id:"checkbox",label:"Checkbox",description:"Inline checkbox you can tick mid-sentence",icon:s2.default,aliases:["check","tick","box","bool","yes","no"]},{id:"multiSelect",label:"Select",description:"Inline single or multi-select with coloured options",icon:s3.ListChecks,aliases:["multiselect","multi","options","tags","labels","choice","dropdown"]}];async function uE(e){let t=new FormData;t.append("file",e);let n=await fetch("/api/docs/upload-media",{method:"POST",body:t});return n.ok?n.json():(console.error("[doc-editor] upload failed",n.status),null)}function uC(e,t){"image"===t.kind?e.chain().focus().setImage({src:t.url}).run():"video"===t.kind?e.chain().focus().setVideo({src:t.url}).run():e.chain().focus().setPdf({src:t.url,name:t.name}).run()}let uS=(0,s.forwardRef)(function({initialContent:e,onHtmlChange:t,placeholder:n="Type '/' for commands, or just start writingâ¦",autoFocus:r=!1,parentDocId:i,onComment:c,templateMode:d=!1,onHistoryChange:u,onHtmlCommit:h,collab:p},m){let g=(0,o.useRouter)(),f=(0,uc.useIsMobile)(),[b,x]=(0,s.use
2State)(null),[y,v]=(0,s.useState)(null),w=(0,s.useRef)(null),[_,k]=(0,s.useState)(""),{videos:N,meetings:E}=(0,uo.useVideoSlashItems)(null!==y,!0,_),[C,S]=(0,s.useState)(null),j=(0,s.useRef)(null),[A,B]=(0,s.useState)(!1),[$,z]=(0,s.useState)(null),[G,W]=(0,s.useState)(null),Z=(0,s.useRef)(new Set),J=(0,s.useRef)(t),X=(0,s.useRef)(h),Q=(0,s.useRef)(null),Y=(0,s.useRef)(!1),ee=(0,s.useRef)(u);(0,s.useEffect)(()=>{J.current=t,ee.current=u,X.current=h},[t,u,h]);let et=(0,s.useRef)(null),en=(0,s.useCallback)(e=>{let t={canUndo:e.can().undo(),canRedo:e.can().redo()},n=et.current;n&&n.canUndo===t.canUndo&&n.canRedo===t.canRedo||(et.current=t,ee.current?.(t))},[]),er=(0,M.useEditor)({immediatelyRender:!1,extensions:[I.default.configure({heading:{levels:[1,2,3]},codeBlock:!1,blockquote:{HTMLAttributes:{class:"border-l-4 border-muted-foreground/30 pl-4 italic"}},horizontalRule:{HTMLAttributes:{class:"my-4 border-muted-foreground/20"}},link:{openOnClick:!1,HTMLAttributes:{class:"text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 cursor-pointer hover:text-foreground hover:decoration-muted-foreground/70 transition-colors"}},dropcursor:{color:"#A6BFD0",width:4,class:"doc-dropcursor"},...p?{undoRedo:!1}:{},listItem:!1}),U,da.configure({lowlight:uv,defaultLanguage:null,HTMLAttributes:{class:"doc-code-block"}}),L.default.configure({placeholder:n}),R.default.configure({types:["heading","paragraph"],alignments:["left","center","right","justify"]}),P.default.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"rounded-md max-w-full mx-auto"},resize:{enabled:!0,directions:["bottom-right","bottom-left","top-right","top-left"],minWidth:50,minHeight:50,alwaysPreserveAspectRatio:!0}}),la.Video,lo,lp,lv,lx,lw.Columns,lw.Column,l_.Callout,lD,lU,lQ,l1,on,c5,c4.DocMap,c9,F.default.configure({HTMLAttributes:{class:"not-prose"}}),q.configure({nested:!0}),H.default.configure({multicolor:!0}),K.TextStyle,V.default,c8,um.BlockSelection,...p?[sx.configure({document:p.doc}),sk.configure({provider:p.provider,user:{name:p.user.name,color:p.user.color}})]:[]],content:p?void 0:e||"",editorProps:{attributes:{class:"tiptap doc-canvas focus:outline-none min-h-[60vh] text-[16px] leading-7 px-8 md:pl-16 md:pr-8"},handleKeyDown:(e,t)=>{if(function(e,t){if("Enter"!==t.key||t.shiftKey||t.metaKey||t.ctrlKey||t.altKey)return!1;let{state:n}=e,{$from:r,empty:i}=n.selection;if(!i)return!1;let a=r.parent;if(!a.isTextblock||a.type.spec.code||""!==a.textContent.trim())return!1;let s=!0;if(a.content.forEach(e=>{e.isText||(s=!1)}),!s)return!1;if(a.content.size>0){let t=r.start();e.dispatch(n.tr.delete(t,t+a.content.size))}let l=e.state.schema.nodes.paragraph;if("paragraph"!==a.type.name&&l){let t=e.state.selection.$from;return e.dispatch(e.state.tr.setBlockType(t.before(),t.after(),l).scrollIntoView()),!0}return!1}(e,t))return!0;if("Enter"===t.key&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let{state:t}=e,{$from:n,empty:r}=t.selection;if(r&&"paragraph"===n.parent.type.name&&0===n.parent.content.size)for(let r=n.depth-1;r>=1;r--){let i=n.node(r),a=i.type.name;if("tabPanel"!==a&&"column"!==a&&"callout"!==a&&"slide"!==a)continue;if(i.childCount<2||n.index(r)!==i.childCount-1)break;let s="callout"===a||"slide"===a?r:r-1,l=t.schema.nodes.paragraph;if(!l)break;let o=n.before(),c=n.after(),d=n.after(s),u=t.tr.delete(o,c),h=d-(c-o);return u.insert(h,l.create()),u.setSelection(T.TextSelection.near(u.doc.resolve(h+1))),e.dispatch(u.scrollIntoView()),!0}}if("Backspace"===t.key&&!t.shiftKey&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let{state:t}=e,{$from:n,empty:r}=t.selection,i=n.parent;if(r&&0===n.parentOffset&&i.content.size>0&&("paragraph"===i.type.name||"heading"===i.type.name)){let r=n.index(n.depth-1),i=r>0?n.node(n.depth-1).child(r-1):null;if(i&&"pageLink"===i.type.name){let r=n.before(n.depth);return e.dispatch(t.tr.delete(r-i.nodeSize,r).scrollIntoView()),!0}}}return(0,lf.deleteEmptyLineOnBackspace)(e,t)},handleDrop:(e,t)=>!t.target?.closest("[data-doc-table]")&&!!(0,uy.isRecentFileDrag)(t.dataTransfer)&&(t.preventDefault(),!0),handleDOMEvents:{dragover:(e,t)=>!!(0,uy.isRecentFileDrag)(t.dataTransfer)&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="copy"),!1)}},onUpdate:({editor:e})=>{Y.current=!0,Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>{Q.current=null,Y.current&&!e.isDestroyed&&(Y.current=!1,J.current(e.getHTML()))},250),ea(e),es(e),en(e)},onSelectionUpdate:({editor:e})=>{ei(e)},onBlur:({event:e})=>{let t=e.relatedTarget;t&&(t.closest("[data-doc-bubble]")||t.closest("[data-radix-popper-content-wrapper]"))||z(null)},onCreate:({editor:e})=>{r&&setTimeout(()=>e.commands.focus("end"),50),en(e)}});(0,s.useEffect)(()=>
2{if(!er)return;let e=()=>{Y.current&&(Q.current&&(clearTimeout(Q.current),Q.current=null),Y.current=!1,er.isDestroyed||J.current(er.getHTML()))},t=()=>{"hidden"===document.visibilityState&&e()};return window.addEventListener("beforeunload",e),window.addEventListener("pagehide",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("beforeunload",e),window.removeEventListener("pagehide",e),document.removeEventListener("visibilitychange",t),e()}},[er]),(0,s.useImperativeHandle)(m,()=>({focus:()=>er?.commands.focus("start"),getHTML:()=>er?.getHTML()??"",setContent:e=>{er?.commands.setContent(e,{emitUpdate:!1})},isFocused:()=>er?.isFocused??!1,undo:()=>er?.chain().focus().undo().run(),redo:()=>er?.chain().focus().redo().run(),appendContent:e=>{if(!er||!e.trim())return;let{state:t,view:n}=er,r=new DOMParser().parseFromString(e,"text/html").body,i=O.DOMParser.fromSchema(t.schema).parse(r);if(0===i.content.size)return;let a=t.doc.lastChild,s=a?.isTextblock&&0===a.content.size?a:null,l=t.doc.content.size-(s?.nodeSize??0);n.dispatch(t.tr.insert(l,i.content))}}),[er]),(0,s.useEffect)(()=>{if(!b)return;let e=null,t=()=>{e&&(clearTimeout(e),e=null)},n=e=>{let n=e.target,r=n?.closest?.("a[href]");if(!r||!b.contains(r))return;t();let i=r.getBoundingClientRect();W({href:r.href,rect:{top:i.top,left:i.left,bottom:i.bottom,right:i.right}})},r=n=>{let r=n.target,i=r?.closest?.("a[href]");if(!i)return;let a=n.relatedTarget;a&&(a.closest?.("a[href]")===i||a.closest?.("[data-doc-link-hover]"))||(t(),e=setTimeout(()=>W(null),120))};return b.addEventListener("mouseover",n),b.addEventListener("mouseout",r),()=>{b.removeEventListener("mouseover",n),b.removeEventListener("mouseout",r),t()}},[b]);let ei=(0,s.useCallback)(e=>{let{from:t,to:n,empty:r}=e.state.selection;if(r||t===n)return void z(null);let i=e.view.coordsAtPos(t),a=e.view.coordsAtPos(n),s=Math.max(i.right,a.right)+6;z({top:Math.min(i.top,a.top)-8,bottom:Math.max(i.bottom,a.bottom)+8,left:s})},[]),ea=(0,s.useCallback)(e=>{let{state:t}=e,{selection:n}=t,{$anchor:r}=n,i=r.parent.textContent.slice(0,r.parentOffset),a=r.pos,s=i.lastIndexOf("/"),l=!1;if(s>=0&&(0===s||" "===i[s-1]||"\n"===i[s-1])){let t=i.slice(s+1);if(t.length<=30&&!t.includes(" ")&&!t.includes("/")){null===w.current&&(w.current=a-t.length-1);let n=e.view.coordsAtPos(a);v({position:{top:n.bottom+6,left:n.left},query:t}),l=!0}}l||(v(null),w.current=null)},[]),es=(0,s.useCallback)(e=>{let{state:t}=e,{$anchor:n}=t.selection,r=n.parent.textContent.slice(0,n.parentOffset),i=n.pos,a=r.lastIndexOf("@"),s=!1;if(a>=0&&(0===a||/\s/.test(r[a-1]))){let t=r.slice(a+1);if(t.length<=40&&!/[\s@]/.test(t)){null===j.current&&(j.current=i-t.length-1);let n=e.view.coordsAtPos(i);S({position:{top:n.bottom+6,left:n.left},query:t}),s=!0}}s||(S(null),j.current=null)},[]),el=(0,s.useCallback)(e=>{if(!er||null===j.current)return;let t=j.current,n=er.state.selection.$anchor.pos;(0,oS.primeMentionMeta)(e.type,e.id,{imageUrl:e.imageUrl??e.logoUrl??null,domain:e.domain??null}),er.chain().focus().deleteRange({from:t,to:n}).insertMention({type:e.type,id:e.id,label:e.name}).run(),S(null),j.current=null},[er]),eo=(0,s.useCallback)(()=>{S(null),j.current=null},[]),ec=(0,s.useCallback)(async e=>{if(!er)return;let t=document.createElement("input");t.type="file",t.accept=e,t.onchange=async()=>{let e=t.files?.[0];if(e){B(!0);try{let t=await uE(e);if(!t)return;uC(er,t)}finally{B(!1)}}},t.click()},[er]),ed=(0,s.useCallback)(()=>{if(!er||!i)return;let e=crypto.randomUUID();document.cookie=`doc-creating=${e}|${i}; Path=/; Max-Age=15; SameSite=Lax`;let t=fetch("/api/docs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,parent_id:i,title:""})});if(er.chain().focus().insertPageLink({docId:e,title:"Untitled",icon:null}).run(),lu(e,{title:"",icon:null}),g.push(`/docs/${e}`),!er.isDestroyed){let e=er.getHTML();lm.set(i,e),X.current?.(e),Y.current=!1,Q.current&&(clearTimeout(Q.current),Q.current=null),fetch(`/api/docs/${i}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content_html:e})})}t.then(e=>{e.ok||(D.toast.error("Could not create page"),g.push(`/docs/${i}`))})},[er,i,g]),eu=(0,s.useCallback)(async e=>{if(!er)return!1;let{state:t}=er,{from:n,to:r}=t.selection,i=t.doc.resolve(n),a=t.doc.resolve(r),s=i.depth>=1?i.before(1):0,l=a.depth>
2=1?a.after(1):t.doc.content.size;if(l<=s)return!1;let o=t.doc.slice(s,l);if(0===o.content.size)return!1;let c=O.DOMSerializer.fromSchema(er.schema),d=document.createElement("div");d.appendChild(c.serializeFragment(o.content));let u=d.innerHTML;if(!u.trim())return!1;let h=[];return(o.content.descendants(e=>{"pageLink"===e.type.name&&"string"==typeof e.attrs.docId&&h.push(e.attrs.docId)}),h.forEach(e=>Z.current.add(e)),(await fetch(`/api/docs/${e}/append`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:u})})).ok)?(await Promise.all(h.map(t=>fetch(`/api/docs/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({parent_id:e})}).catch(()=>{}))),er.chain().focus().deleteRange({from:s,to:l}).run(),z(null),!0):(h.forEach(e=>Z.current.delete(e)),D.toast.error("Could not move to that page"),!1)},[er]),eh=(0,s.useCallback)(e=>{if(!er||null===w.current)return;let t=w.current,n=er.state.selection.$anchor.pos,r=er.chain().focus().deleteRange({from:t,to:n});switch(e){case"paragraph":r.setParagraph().run();break;case"heading1":r.setHeading({level:1}).run();break;case"heading2":r.setHeading({level:2}).run();break;case"heading3":r.setHeading({level:3}).run();break;case"bulletList":r.toggleBulletList().run();break;case"orderedList":r.toggleOrderedList().run();break;case"taskList":r.toggleTaskList().run();break;case"blockquote":r.toggleBlockquote().run();break;case"codeBlock":r.toggleCodeBlock().run();break;case"horizontalRule":r.setHorizontalRule().run();break;case"image":r.run(),ec("image/*");break;case"video":r.run(),ec("video/*");break;case"pdf":r.run(),ec("application/pdf");break;case"page":r.run(),ed();break;case"tabs":r.run(),er.chain().focus().insertTabs().run();break;case"columns2":r.run(),er.chain().focus().insertColumns(2).run();break;case"columns3":r.run(),er.chain().focus().insertColumns(3).run();break;case"columns4":r.run(),er.chain().focus().insertColumns(4).run();break;case"columns5":r.run(),er.chain().focus().insertColumns(5).run();break;case"callout":r.run(),er.chain().focus().insertCallout().run();break;case"slide":r.run(),er.chain().focus().insertSlide().run();break;case"table":r.run(),er.chain().focus().insertDataTable().run();break;case"map":r.run(),er.chain().focus().insertDocMap().run();break;case"statusPill":r.run(),er.chain().focus().insertStatusPill().run();break;case"date":r.run(),er.chain().focus().insertDocDate({withTime:!1}).run();break;case"datetime":r.run(),er.chain().focus().insertDocDate({withTime:!0}).run();break;case"dateRange":r.run(),er.chain().focus().insertDocDate({range:!0}).run();break;case"checkbox":r.run(),er.chain().focus().insertDocCheckbox().run();break;case"multiSelect":r.run(),er.chain().focus().insertDocMultiSelect().run();break;default:r.run()}v(null),w.current=null},[er,ec,ed]),ep=(0,s.useCallback)(e=>{if(!er||null===w.current)return;let t=w.current,n=er.state.selection.$anchor.pos;er.chain().focus().deleteRange({from:t,to:n}).setVideo({src:`/api/videos/${e.id}/file`,title:e.title}).run(),v(null),w.current=null},[er]),em=(0,s.useCallback)(e=>{e.data?ep(e.data):eh(e.id)},[eh,ep]),eg=(0,s.useCallback)(()=>{v(null),w.current=null},[]),ef=(0,s.useCallback)(()=>{if(!er||null===w.current){v(null),w.current=null;return}let e=w.current,t=er.state.selection.anchor;er.chain().focus().deleteRange({from:e,to:t}).run(),v(null),w.current=null},[er]);return(0,s.useEffect)(()=>{if(!er)return;let e=async e=>{if(e.target?.closest("[data-doc-table]"))return;if(!(0,uy.isRecentFileDrag)(e.dataTransfer)){let t=e.dataTransfer?.files;if(!t?.length)return}e.preventDefault(),e.stopPropagation();let t=e.dataTransfer?await (0,uy.filesFromRecentDrag)(e.dataTransfer):null,n=t?.length?Array.from(t).filter(uk):[];if(0===n.length)return;let r=er.view.posAtCoords({left:e.clientX,top:e.clientY}),i=r?.pos??er.state.doc.content.size;B(!0);try{let e=i;for(let t of n){let n=await uE(t);if(!n)continue;let r="image"===n.kind?{type:"image",attrs:{src:n.url}}:"video"===n.kind?{type:"video",attrs:{src:n.url}}:{type:"pdf",attrs:{src:n.url,name:n.name}};er.chain().focus().insertContentAt(e,r).run(),e=er.state.selection.$anchor.pos}}finally{B(!1)}},t=async e=>{let t=e.clipboardData?.files,n=t?.length?Array.from(t).filter(uk):[];if(n.length>0){e.preventDefault(),B(!0);try{for(let e of n){let t=await uE(e);t&&uC(er,t)}}finally{B(!1)}return}let r=e.clipboardData?.getData("text/html")??"";if(r.includes("data-page-link")){let t=Array.from(new Set(Array.from(r.matchAll(/data-doc-id="([0-9a-fA-F-]{36})"/g)).map(e=>e[1])));if(t.length>0){e.preventDefault();let n=r;for(let e of t)try{let t=await fetch(`/api/docs/${e}/clone`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parentId:i??null})});if(!t.ok)continue;let r=await t.json();r.id&&(n=n.split(e).join(r.id))}catch{}er.chain().focus().insertContent(n).run()}}},n=er.view.dom;return n.addEventListener("drop",e,!0),n.addEventListener("paste",t),()=>{n.removeEventListener("drop",e,!0),n.removeEventListener("paste",t)}},[er,i]),(0,s.useEffect)(()=>
2{if(!er)return;let e=()=>{let e=new Set;return er.state.doc.descendants(t=>{"pageLink"===t.type.name&&"string"==typeof t.attrs.docId&&e.add(t.attrs.docId)}),e},t=e(),n=new Map,r=new Set,i=()=>{let i=e();for(let e of t)if(!i.has(e)&&!n.has(e)){if(Z.current.has(e)){Z.current.delete(e);continue}let t=setTimeout(()=>{n.delete(e),r.add(e),fetch(`/api/docs/${e}`,{method:"DELETE"})},600);n.set(e,t)}for(let e of i){let t=n.get(e);t?(clearTimeout(t),n.delete(e)):r.has(e)&&(r.delete(e),fetch(`/api/docs/${e}/restore`,{method:"POST"}))}t=i};return er.on("update",i),()=>{er.off("update",i),n.forEach(e=>clearTimeout(e)),n.clear()}},[er]),(0,up.useBlockMarquee)(er),(0,a.jsxs)("div",{ref:x,className:`relative${d?" doc-template-mode":""}`,children:[(0,a.jsx)(M.EditorContent,{editor:er}),er&&f&&(0,a.jsx)(ud.MobileBlockReorder,{editor:er,containerEl:b}),er&&!f&&(0,a.jsx)(uu.DocBlockHandle,{editor:er,containerEl:b}),er&&!f&&(0,a.jsx)(uh,{editor:er,containerEl:b}),$&&er&&"u">typeof document&&(0,l.createPortal)((0,a.jsx)(uO,{top:$.top,bottom:$.bottom,left:$.left,editor:er,onComment:c,templateMode:d,currentDocId:i,onMove:eu}),document.body),G&&er&&"u">typeof document&&(0,l.createPortal)((0,a.jsx)(uI,{href:G.href,rect:G.rect,editor:er,onClose:()=>W(null)}),document.body),A&&(0,a.jsx)("div",{className:"pointer-events-none fixed bottom-4 right-4 rounded-md bg-foreground
2/90 px-3 py-1.5 text-xs text-background shadow-md",children:"Uploadingâ¦"}),y&&(0,a.jsx)(ul.UnifiedSlashMenu,{position:y.position,query:y.query,sections:[{id:"blocks",label:"Insert block",tabLabel:"Blocks",defaultIcon:sN.Type,items:uN.map(e=>({id:e.id,label:e.label,description:e.description,icon:e.icon,aliases:e.aliases}))},...N.length>0?[{id:"videos",label:"Videos",tabLabel:"Videos",icon:sL.Video,defaultIcon:sL.Video,maxItems:5,items:N.map(e=>({id:`vid-${e.id}`,...(0,uo.videoSlashPresentation)(e),data:e}))}]:[],...E.length>0?[{id:"meetings",label:"Meeting recordings",tabLabel:"Meetings",icon:s4.MonitorPlay,defaultIcon:s4.MonitorPlay,maxItems:5,items:E.map(e=>({id:`vid-${e.id}`,...(0,uo.videoSlashPresentation)(e),data:e}))}]:[]],onSelect:em,onClose:eg,onDismissFromEmptyBackspace:ef,onSearchChange:k,searchPlaceholder:"Search blocks, videos, meetingsâ¦"}),C&&(0,a.jsx)(de,{position:C.position,query:C.query,onSelect:el,onClose:eo})]})}),uj=[{id:"paragraph",label:"Text",icon:sN.Type},{id:"h1",label:"Heading 1",icon:sE.Heading1},{id:"h2",label:"Heading 2",icon:sC.Heading2},{id:"h3",label:"Heading 3",icon:sS.Heading3},{id:"bulletList",label:"Bulleted list",icon:sj.List},{id:"orderedList",label:"Numbered list",icon:sA.ListOrdered},{id:"taskList",label:"To-do list",icon:sD.CheckSquare},{id:"blockquote",label:"Quote",icon:sM.Quote},{id:"callout",label:"Callout",icon:sK.Lightbulb},{id:"codeBlock",label:"Code block",icon:sT.Code}],uA=[{name:"Default",value:null},{name:"Gray",value:"#787774"},{name:"Brown",value:"#9F6B53"},{name:"Orange",value:"#D9730D"},{name:"Yellow",value:"#CB912F"},{name:"Green",value:"#448361"},{name:"Blue",value:"#337EA9"},{name:"Purple",value:"#9065B0"},{name:"Pink",value:"#C14C8A"},{name:"Red",value:"#D44C47"}],uD=[{name:"None",value:null},{name:"Gray",value:"#F1F1EF"},{name:"Brown",value:"#F4EEEE"},{name:"Orange",value:"#FAEBDD"},{name:"Yellow",value:"#FBF3DB"},{name:"Green",value:"#DDEDEA"},{name:"Blue",value:"#DDEBF1"},{name:"Purple",value:"#EAE4F2"},{name:"Pink",value:"#F4DFEB"},{name:"Red",value:"#FBE4E4"}],uM=[{id:"left",label:"Align left",shortcut:"Align left (ââ§L)",icon:s6.AlignLeft},{id:"center",label:"Align center",shortcut:"Align center (ââ§E)",icon:s9.AlignCenter},{id:"right",label:"Align right",shortcut:"Align right (ââ§R)",icon:s7.AlignRight},{id:"justify",label:"Justify",shortcut:"Justify (ââ§J)",icon:le.AlignJustify}];function uT({currentDocId:e,excludeRoots:t,onPick:n}
2){let[r,i]=(0,s.useState)(""),[l,o]=(0,s.useState)([]),[c,d]=(0,s.useState)(!0);(0,s.useEffect)(()=>{let e=!1;return(async()=>{let t=(0,ln.createClient)(),{data:n}=await t.from("docs").select("id, title, icon, parent_id, updated_at").is("deleted_at",null).order("updated_at",{ascending:!1}).limit(200);e||(o(n||[]),d(!1))})(),()=>{e=!0}},[]);let u=(0,s.useMemo)(()=>{let n=new Map;for(let e of l){if(!e.parent_id)continue;let t=n.get(e.parent_id);t?t.push(e.id):n.set(e.parent_id,[e.id])}let r=new Set([e]),i=[...t];for(;i.length;){let e=i.shift();if(r.has(e))continue;r.add(e);let t=n.get(e);t&&i.push(...t)}return r},[l,e,t]),h=(0,s.useMemo)(()=>{let e=r.trim().toLowerCase(),t=l.filter(e=>!u.has(e.id));return(e?t.filter(t=>(t.title||"Untitled").toLowerCase().includes(e)):t).slice(0,50)},[l,u,r]);return(0,a.jsxs)("div",{className:"flex flex-col max-h-[320px]",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 border-b px-2.5 py-2",children:[(0,a.jsx)(f.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("input",{value:r,onChange:e=>i(e.target.value),placeholder:"Move toâ¦",autoFocus:!0,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground"})]}),(0,a.jsx)("div",{className:"overflow-y-auto p-1",children:c?(0,a.jsx)("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"Loading pagesâ¦"}):0===h.length?(0,a.jsx)("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:r.trim()?"No pages match.":"No other pages yet."}):h.map(e=>(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),n(e)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback text-sm hover:bg-accent text-left",children:[(0,a.jsx)("span",{className:"shrink-0 inline-flex items-center justify-center w-5",children:e.icon?(0,a.jsx)(lr.DocIcon,{icon:e.icon,size:16}):(0,a.jsx)(li.QuillIcon,{className:"h-4 w-4 text-muted-foreground"})}),(0,a.jsx)("span",{className:"truncate",children:e.title||"Untitled"})]},e.id))})]})}function uO({top:e,bottom:t,left:n,editor:r,onComment:i,templateMode:l=!1,currentDocId:c,onMove:d}){let u=(0,o.useRouter)(),h=(0,ub.useAssistantPanelOptional)(),{agent:m,name:g}
2=(0,uf.useAgentBrand)(),f=(0,s.useRef)(null),[b,x]=(0,s.useState)(!1),[y,v]=(0,s.useState)(""),[w,_]=(0,s.useState)(!1),[k,N]=(0,s.useState)(!1),[E,C]=(0,s.useState)(""),S=r.isActive("templateField"),j=r.isActive({textAlign:"center"})?"center":r.isActive({textAlign:"right"})?"right":r.isActive({textAlign:"justify"})?"justify":"left",A=uM.find(e=>e.id===j)?.icon??s6.AlignLeft,[M,T]=(0,s.useState)({dx:0,flipBelow:!1});(0,s.useLayoutEffect)(()=>{let t=f.current;if(!t)return;let r=t.offsetWidth,i=t.offsetHeight,a=0,s=n+r;s>window.innerWidth-8&&(a=window.innerWidth-8-s),n+a<8&&(a=8-n),T({dx:a,flipBelow:e-i<8})},[e,t,n]);let O=({active:e,onClick:t,label:n,children:r,className:i=""})=>(0,a.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),t()},"aria-label":n,title:n,className:`h-7 w-7 inline-flex items-center justify-center rounded-full text-sm hover:bg-accent ${e?"bg-accent text-foreground":"text-foreground"} ${i}`,children:r}),I=(0,s.useCallback)(()=>{if(y){let e=y.startsWith("http")?y:`https://${y}`;r.chain().focus().extendMarkRange("link").setLink({href:e}).run()}else r.chain().focus().extendMarkRange("link").unsetLink().run();v(""),x(!1)},[r,y]),L=()=>{let e=E.trim();if(!e)return;let t=r.chain().focus();S&&t.extendMarkRange("templateField"),t.setTemplateField({label:e}).run(),N(!1)};return(0,a.jsxs)("div",{ref:f,"data-doc-bubble":!0,className:"fixed z-40",style:{top:M.flipBelow?t:e,left:n,transform:`translate(${M.dx}px, ${M.flipBelow?"0":"-100%"})`},children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full border bg-popover shadow-xl px-1.5 py-1",children:[l&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(lt.Popover,{open:k,onOpenChange:e=>{e?(C(S&&r.getAttributes("templateField").label||""),N(!0)):N(!1)},children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),className:`h-7 inline-flex items-center gap-1 px-2.5 rounded-full text-xs font-medium hover:bg-accent ${S?"text-[#337EA9]":"text-foreground"}`,"aria-label":S?"Edit field":"Mark as editable field",children:[(0,a.jsx)(sJ.SquarePen,{className:"h-3.5 w-3.5"}),S?"Edit field":"Mark as field"]})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",sideOffset:6,className:"w-64 p-2",onOpenAutoFocus:e=>e.preventDefault(),children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground px-1 mb-1.5",children:"Editable field"}),(0,a.jsx)("input",{value:E,onChange:e=>C(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),L()):"Escape"===e.key&&(e.preventDefault(),N(!1))},placeholder:"Field name, e.g. Client Name",autoFocus:!0,className:"w-full rounded-[12px] [corner-shape:squircle] squircle-field-fallback border border-transparent bg-lighter-oat dark:bg-black px-2 py-1.5 text-sm outline-none placeholder:text-muted-foreground"}),(0,a.jsxs)("div",{className:"mt-2 flex items-center justify-between gap-2",children:[S?(0,a.jsxs)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),r.chain().focus().extendMarkRange("templateField").unsetTemplateField().run(),N(!1)},className:"inline-flex items-center gap-1 text-xs text-destructive hover:bg-destructive/10 rounded-md [corner-shape:squircle] squircle-safari-fallback px-2 py-1",children:[(0,a.jsx)(sX.Trash2,{className:"h-3.5 w-3.5"}),"Remove"]}):(0,a.jsx)("span",{}),(0,a.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),L()},disabled:!E.trim(),className:"text-xs px-3 py-1 rounded-md [corner-shape:squircle] squircle-safari-fallback bg-foreground text-background disabled:opacity-40 hover:bg-foreground
2/90",children:S?"Update":"Add field"})]})]})]}),(0,a.jsx)("div",{className:"w-px h-4 bg-border mx-0.5"})]}),(0,a.jsxs)(lt.Popover,{children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),className:"h-7 inline-flex items-center gap-1 px-2.5 rounded-full text-xs font-medium text-foreground hover:bg-accent",children:[r.isActive("heading",{level:1})?"Heading 1":r.isActive("heading",{level:2})?"Heading 2":r.isActive("heading",{level:3})?"Heading 3":r.isActive("bulletList")?"Bulleted list":r.isActive("orderedList")?"Numbered list":r.isActive("taskList")?"To-do list":r.isActive("blockquote")?"Quote":r.isActive("codeBlock")?"Code block":"Text",(0,a.jsx)(sV.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",sideOffset:6,className:"w-48 p-1",onOpenAutoFocus:e=>e.preventDefault(),children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground px-2 py-1",children:"Turn into"}),uj.map(e=>{let t=e.icon;return(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault();var n=e.id;let i=r.chain().focus();switch(n){case"paragraph":i.setParagraph().run();break;case"h1":i.setHeading({level:1}).run();break;case"h2":i.setHeading({level:2}).run();break;case"h3":i.setHeading({level:3}).run();break;case"bulletList":i.toggleBulletList().run();break;case"orderedList":i.toggleOrderedList().run();break;case"taskList":i.toggleTaskList().run();break;case"blockquote":i.toggleBlockquote().run();break;case"callout":i.toggleWrap("callout").run();break;case"codeBlock":i.toggleCodeBlock().run()}},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md [corner-shape:squircle] squircle-safari-fallback text-sm hover:bg-accent",children:[(0,a.jsx)(t,{className:"h-4 w-4 text-muted-foreground"}),e.label]},e.id)})]})]}),(0,a.jsxs)(lt.Popover,{children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button",onMouseDown:e=>e.preventDefault(),className:`h-7 w-7 inline-flex items-center justify-center rounded-full text-sm hover:bg-accent ${"left"!==j?"bg-accent text-foreground":"text-foreground"}`,"aria-label":"Text alignment",title:"Text alignment",children:(0,a.jsx)(A,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(lt.PopoverContent,{align:"center",side:"bottom",sideOffset:6,collisionPadding:8,className:"w-auto p-1",onOpenAutoFocus:e=>e.preventDefault(),children:(0,a.jsx)("div",{className:"flex items-center gap-0.5",children:uM.map(e=>{let t=e.icon,n=j===e.id;return(0,a.jsx)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),r.chain().focus().setTextAlign(e.id).run()},title:e.shortcut,"aria-label":e.label,className:`h-7 w-7 inline-flex items-center justify-center rounded-md [corner-shape:squircle] squircle-safari-fallback text-sm hover:bg-accent ${n?"bg-accent text-foreground":"text-foreground"}`,children:(0,a.jsx)(t,{className:"h-3.5 w-3.5"})},e.id)})})})]}),(0,a.jsx)("div",{className:"w-px h-4 bg-border mx-0.5"}),(0,a.jsx)(O,{active:r.isActive("bold"),onClick:()=>r.chain().focus().toggleBold().run(),label:"Bold (âB)",children:(0,a.jsx)(sR.Bold,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(O,{active:r.isActive("italic"),onClick:()=>r.chain().focus().toggleItalic().run(),label:"Italic (âI)",children:(0,a.jsx)(sP.Italic,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(O,{active:r.isActive("underline"),onClick:()=>r.chain().focus().toggleUnderline().run(),label:"Underline (âU)",children:(0,a.jsx)(sF.Underline,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(O,{active:r.isActive("strike"),onClick:()=>r.chain().focus().toggleStrike().run(),label:"Strikethrough",children:(0,a.jsx)(sB.Strikethrough,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(O,{active:r.isActive("code"),onClick:()=>r.chain().focus().toggleCode().run(),label:"Inline code",children:(0,a.jsx)(sT.Code,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-border mx-0.5"}),(0,a.jsxs)(lt.Popover,{children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),className:"h-7 inline-flex items-center gap-0.5 px-2 rounded-full text-sm text-foreground hover:bg-accent","aria-label":"Color",title:"Color",children:[(0,a.jsx)("span",{className:"font-serif font-semibold text-[13px] leading-none",children:"A"}),(0,a.jsx)(sV.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,a.jsxs)(lt.PopoverContent,{align:"start",sideOffset:6,className:"w-52 p-2 space-y-2",onOpenAutoFocus:e=>e.preventDefault(),children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground px-1 mb-1",children:"Text color"}
2),(0,a.jsx)("div",{className:"grid grid-cols-5 gap-1",children:uA.map(e=>(0,a.jsx)("button",{type:"button",onMouseDown:t=>{var n;t.preventDefault(),(n=e.value)?r.chain().focus().setColor(n).run():r.chain().focus().unsetColor().run()},className:"h-7 w-7 inline-flex items-center justify-center rounded-lg [corner-shape:squircle] squircle-safari-fallback border border-border hover:bg-accent text-sm font-semibold",style:{color:e.value||"var(--foreground)"},title:e.name,children:"A"},e.name))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-muted-foreground px-1 mb-1",children:"Background"}),(0,a.jsx)("div",{className:"grid grid-cols-5 gap-1",children:uD.map(e=>(0,a.jsx)("button",{type:"button",onMouseDown:t=>{var n;t.preventDefault(),(n=e.value)?r.chain().focus().setMark("highlight",{color:n}).run():r.chain().focus().unsetMark("highlight").run()},className:"h-7 w-7 inline-flex items-center justify-center rounded-md border border-border hover:ring-1 hover:ring-ring text-xs font-medium",style:{backgroundColor:e.value||"transparent",color:"var(--foreground)"},title:e.name,children:"A"},e.name))})]})]})]}),(0,a.jsx)(O,{active:r.isActive("link")||b,onClick:()=>{r.isActive("link")?r.chain().focus().unsetLink().run():(v(r.getAttributes("link").href||""),x(e=>!e))},label:"Link (âK)",children:(0,a.jsx)(sU.Link,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("div",{className:"w-px h-4 bg-border mx-0.5"}),h&&(0,a.jsx)(O,{onClick:()=>{let{state:e}=r,t=e.doc.textBetween(e.selection.from,e.selection.to,"\n"," ").trim();if(!t)return;let n=e.selection.$from.parent.textContent.trim();(0,ux.setClaudeSelection)({text:t,path:window.location.pathname,docId:c,blockText:n&&n!==t?n.slice(0,600):void 0,capturedAt:Date.now()}),h?.setOpen(!0)},label:`Ask ${g} about this`,children:(0,a.jsx)(ug.AgentGlyph,{agent:m,className:"h-3.5 w-3.5",tinted:!1})}),i&&(0,a.jsx)(O,{onClick:()=>i(),label:"Comment on selection",children:(0,a.jsx)(p.MessageSquare,{className:"h-3.5 w-3.5"})}),(0,a.jsx)(O,{onClick:()=>{let e=r.state.selection,t=e.node;if(t&&"pageLink"===t.type.name&&"string"==typeof t.attrs.docId){let n=t.attrs.docId,i=e.to;(async()=>{try{let e=await fetch(`/api/docs/${n}/clone`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({parentId:c??null})});if(!e.ok)return;let t=await e.json();r.chain().focus().insertContentAt(i,{type:"pageLink",attrs:{docId:t.id,title:t.title??"Untitled",icon:t.icon??null}}).run()}catch{}})();return}let n=e.$anchor;if(n.depth<1)return;let i=n.depth;for(;i>1;)i--;let a=n.before(i),s=n.after(i),l=r.state.doc.nodeAt(a);l&&r.chain().focus().insertContentAt(s,l.toJSON()).run()},label:"Duplicate block",children:(0,a.jsx)(sG.Copy,{className:"h-3.5 w-3.5"})}),d&&c&&(0,a.jsxs)(lt.Popover,{open:w,onOpenChange:_,children:[(0,a.jsx)(lt.PopoverTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button",onMouseDown:e=>e.preventDefault(),"aria-label":"Move to page",title:"Move to page",className:"h-7 w-7 inline-flex items-center justify-center rounded-full text-sm text-foreground hover:bg-accent",children:(0,a.jsx)(s5.default,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(lt.PopoverContent,{align:"end",sideOffset:6,className:"w-72 p-0",onOpenAutoFocus:e=>e.preventDefault(),children:(0,a.jsx)(uT,{currentDocId:c,excludeRoots:(()=>{let{state:e}=r,{from:t,to:n}=e.selection,i=e.doc.resolve(t),a=e.doc.resolve(n),s=i.depth>=1?i.before(1):0,l=a.depth>=1?a.after(1):e.doc.content.size,o=e.doc.slice(s,l),c=[];return o.content.descendants(e=>{"pageLink"===e.type.name&&"string"==typeof e.attrs.docId&&c.push(e.attrs.docId)}),c})(),onPick:async e=>{_(!1),await d(e.id)&&D.toast.success(`Moved to â${e.title||"Untitled"}â`,{action:{label:"Open",onClick:()=>u.push(`/docs/${e.id}`)}})}})})]})]}),b&&(0,a.jsxs)("div",{className:"mt-1.5 flex items-center gap-1 rounded-full border bg-popover shadow-lg px-2 py-1",children:[(0,a.jsx)("input",{value:y,onChange:e=>v(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),I())},placeholder:"Paste a linkâ¦",autoFocus:!0,className:"w-56 bg-transparent outline-none text-xs placeholder:text-muted-foreground"}),(0,a.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),I()},className:"text-xs px-2 py-0.5 rounded-full hover:bg-accent",children:"Set"})]})]})}function uI({href:e,rect:t,editor:n,onClose:r}
2){let i=(0,s.useRef)(null),l=(0,s.useRef)(null),[o,c]=(0,s.useState)(!1),[d,h]=(0,s.useState)(e),[p,m]=(0,s.useState)(!1),[g,f]=(0,s.useState)({top:t.bottom+6,left:t.left});(0,s.useLayoutEffect)(()=>{let e=i.current;if(!e)return;let n=e.offsetWidth,r=e.offsetHeight,a=t.bottom+6;a+r>window.innerHeight-8&&(a=Math.max(8,t.top-r-6));let s=t.left;s+n>window.innerWidth-8&&(s=Math.max(8,window.innerWidth-8-n)),s<8&&(s=8),f({top:a,left:s})},[t.top,t.bottom,t.left,o]);let b=()=>{l.current&&(clearTimeout(l.current),l.current=null)},x=e.length>48?`${e.slice(0,45)}â¦`:e,y=async()=>{try{await navigator.clipboard.writeText(e),m(!0),setTimeout(()=>m(!1),1200)}catch{}},v=()=>{let e=d.trim();if(e){let t=e.startsWith("http")||e.startsWith("mailto:")?e:`https://${e}`;n.chain().focus().extendMarkRange("link").setLink({href:t}).run()}else n.chain().focus().extendMarkRange("link").unsetLink().run();c(!1),r()};return(0,a.jsxs)("div",{ref:i,"data-doc-link-hover":!0,onMouseEnter:b,onMouseLeave:()=>{b(),l.current=setTimeout(()=>r(),120)},className:"fixed z-50 flex items-center gap-1 rounded-full border bg-popover text-popover-foreground shadow-md pl-2 pr-1 py-1 text-xs",style:{to
2p:g.top,left:g.left},children:[(0,a.jsx)(sW.Globe,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),o?(0,a.jsx)("input",{value:d,onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),v()):"Escape"===e.key&&(e.preventDefault(),c(!1))},autoFocus:!0,placeholder:"Paste a linkâ¦",className:"w-64 bg-transparent outline-none px-1 placeholder:text-muted-foreground"}):(0,a.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"max-w-[18rem] truncate text-muted-foreground hover:text-foreground",title:e,children:x}),(0,a.jsx)("button",{type:"button",onMouseDown:e=>{e.preventDefault(),o?v():y()},"aria-label":o?"Save link":"Copy link",title:o?"Save":"Copy",className:"h-6 w-6 inline-flex items-center justify-center rounded-full hover:bg-accent text-muted-foreground hover:text-foreground",children:o||p?(0,a.jsx)(u.Check,{className:"h-3.5 w-3.5"}):(0,a.jsx)(sG.Copy,{className:"h-3.5 w-3.5"})}),!o&&(0,a.jsx)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),h(e),c(!0)},className:"px-2 py-0.5 rounded-full hover:bg-accent",children:"Edit"})]})}var uL=e.i(611423),uR=e.i(871689),uP=e.i(319036),uF=e.i(986677),uB=e.i(25257);function uU({docId:e,docTitle:t,onBack:n}
2){let[r,i]=(0,s.useState)(!0),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(""),[u,h]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let t=!1;return(async()=>{let n=await fetch(`/api/docs/${e}/share`);if(!t){if(n.ok){let{share:e}=await n.json();t||o(e)}i(!1)}})(),()=>{t=!0}},[e]);let p=async t=>{h(!0);let n=await fetch(`/api/docs/${e}/share`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(h(!1),!n.ok)return D.toast.error("Something went wrong"),null;let{share:r}=await n.json();return o(r),r},m=async()=>{let e=c.split(/[\s,;]+/).map(uF.normalizeEmail).filter(Boolean).filter(uF.isValidEmail);if(0===e.length)return void D.toast.error("Enter a valid email");let t=l?.allowed_emails??[],n=Array.from(new Set([...t,...e])),r=n.length-t.length;d(""),await p({allowed_emails:n})&&D.toast.success(1===r?"Invite sent":`${r} invites sent`)},g=(0,uB.useShareOrigin)("docs"),f=l?`${g}/share/docs/${l.token}`:"";return(0,a.jsxs)("div",{className:"animate-in fade-in slide-in-from-right-2 duration-150",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 px-1 pb-2 mb-1 border-b border-border",children:[(0,a.jsx)("button",{type:"button",onClick:n,"aria-label":"Back",className:"inline-flex items-center justify-center h-7 w-7 squircle text-muted-foreground/80 hover:text-foreground hover:bg-accent/50 transition-colors",children:(0,a.jsx)(uR.ArrowLeft,{className:"h-4 w-4"})}),(0,a.jsxs)("span",{className:"text-sm font-medium truncate",children:["Share â",t,"â"]})]}),r?(0,a.jsx)("div",{className:"px-1 py-1 space-y-3",children:Array.from({length:3}).map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,a.jsx)(uL.Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 space-y-1.5",children:[(0,a.jsx)(uL.Skeleton,{className:"h-3.5 w-32"}),(0,a.jsx)(uL.Skeleton,{className:"h-3 w-24"})]})]},t))}):(0,a.jsxs)("div",{className:"px-1 py-1 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)(sW.Globe,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("div",{className:"text-sm font-medium leading-tight",children:"Make public"}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground leading-tight",children:"Anyone with the link can view"})]})]}),(0,a.jsx)(uP.Switch,{size:"xs",noThumbShadow:!0,checked:!!l?.is_public,disabled:u,onCheckedChange:e=>void p({is_public:e})})]}),l?.is_public&&f&&(0,a.jsx)(u$,{url:f}),(0,a.jsx)("div",{className:"h-px bg-border"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Invite people"}),(0,a.jsxs)("form",{className:"flex gap-1.5",onSubmit:e=>{e.preventDefault(),m()},children:[(0,a.jsx)(lM.Input,{variant:"on-white",type:"text",placeholder:"Emails, comma separated",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>e.stopPropagation(),className:"h-8 text-sm"}),(0,a.jsx)(lT.Button,{type:"submit",size:"sm",disabled:u,className:"h-8 shrink-0",children:"Invite"})]}),l&&l.allowed_emails.length>0&&(0,a.jsx)("ul",{className:"space-y-1 max-h-40 overflow-y-auto",children:l.allowed_emails.map(e=>(0,a.jsxs)("li",{className:"flex items-center justify-between rounded-md bg-muted/50 px-2 py-1 text-sm",children:[(0,a.jsx)("span",{className:"truncate",children:e}),(0,a.jsx)("button",{type:"button","aria-label":`Remove ${e}`,disabled:u,onClick:()=>{p({allowed_emails:(l?.allowed_emails??[]).filter(t=>t!==e)})},className:"shrink-0 text-muted-foreground/60 hover:text-foreground",children:(0,a.jsx)(w.X,{className:"h-3.5 w-3.5"})})]},e))})]})]})]})}function u$({url:e}){let[t,n]=(0,s.useState)(!1),r=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{D.toast.error("Could not copy")}};return(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/30 px-2 py-1.5",children:[(0,a.jsx)(v.Link2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("span",{className:"flex-1 truncate text-xs text-muted-foreground",children:e}),(0,a.jsx)("button",{type:"button",onClick:r,"aria-label":"Copy link",className:"shrink-0 text-muted-foreground
2/70 hover:text-foreground",children:t?(0,a.jsx)(u.Check,{className:"h-3.5 w-3.5"}):(0,a.jsx)(sG.Copy,{className:"h-3.5 w-3.5"})})]})}var uz=e.i(367240),uq=e.i(362597),uH=e.i(852917),uK=e.i(330009);function uV({open:e,onOpenChange:t,onChanged:n}){let[r,i]=(0,s.useState)(null),[l,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,h]=(0,s.useState)(!1),p=(0,s.useCallback)(async()=>{let e=await fetch("/api/docs/trash");if(!e.ok){i([]),D.toast.error("Could not load trash");return}i((await e.json()).docs??[])},[]);(0,s.useEffect)(()=>{e&&p()},[e,p]);let m=(0,s.useCallback)(async e=>{o(e.id);let t=await fetch(`/api/docs/${e.id}/restore`,{method:"POST"});(o(null),t.ok)?(i(t=>t?t.filter(t=>t.id!==e.id):t),D.toast.success(`Restored â${e.title||"Untitled"}â`),n?.()):D.toast.error("Could not restore")},[n]),g=(0,s.useCallback)(e=>{d(null);let t=(0,uq.removeByIds)([e.id]);(0,uq.deleteWithUndo)({message:"Permanently deleted",onOptimistic:()=>i(e=>e?t.remove(e):e),onUndo:()=>i(e=>e?t.restore(e):e),onCommitted:()=>n?.(),onError:()=>D.toast.error("Could not delete"),commit:async()=>{if(!(await fetch(`/api/docs/${e.id}?permanent=1`,{method:"DELETE"})).ok)throw Error("Purge failed")}})},[n]),f=(0,s.useCallback)(()=>{h(!1);let e=null;(0,uq.deleteWithUndo)({message:"Trash emptied",onOptimistic:()=>i(t=>(e=t,[])),onUndo:()=>i(e),onCommitted:()=>n?.(),onError:()=>D.toast.error("Could not empty trash"),commit:async()=>{if(!(await fetch("/api/docs/trash",{method:"DELETE"})).ok)throw Error("Empty failed")}})},[n]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(uH.Sheet,{open:e,onOpenChange:t,children:(0,a.jsxs)(uH.SheetContent,{side:"right",className:"w-[420px] sm:max-w-[420px] p-0 flex flex-col",children:[(0,a.jsxs)(uH.SheetHeader,{className:"px-4 pt-4 pb-3 border-b",children:[(0,a.jsx)(uH.SheetTitle,{className:"text-sm font-medium",children:"Recently deleted"}),(0,a.jsx)(uH.SheetDescription,{className:"text-xs",children:"Deleted pages are kept for 30 days, then removed for good."})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-2",children:null===r?(0,a.jsx)(uG,{}):0===r.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 px-6 py-16 text-center",children:[(0,a.jsx)(sX.Trash2,{className:"h-6 w-6 text-muted-foreground/50"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Nothing here yet"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Pages you delete show up here for 30 days."})]}):(0,a.jsx)("ul",{className:"flex flex-col",children:r.map(e=>{var t;let n,r,i,s;return(0,a.jsxs)("li",{className:"group flex items-center gap-2.5 rounded-lg [corner-shape:squircle] squircle-safari-fallback px-2 py-2 hover:bg-accent/50",children:[(0,a.jsx)("span",{className:"shrink-0",children:e.icon?(0,a.jsx)(lr.DocIcon,{icon:e.icon,size:18}):(0,a.jsx)(li.QuillIcon,{className:"h-[18px] w-[18px] text-muted-foreground"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("p",{className:"truncate text-sm text-foreground",children:e.title||"Untitled"}),(0,a.jsx)("p",{className:"truncate text-[11px] text-muted-foreground",children:(t=e.deleted_at,r=Math.max(0,30-(n=Math.floor((Date.now()-new Date(t).getTime())/864e5))),i=n<=0?"today":1===n?"1 day ago":`${n} days ago`,s=r<=0?"deletes soon":1===r?"deletes in 1 day":`deletes in ${r} days`,`Deleted ${i} \xb7 ${s}`)})]}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,a.jsx)("button",{type:"button","aria-label":"Restore",title:"Restore",disabled:l===e.id,onClick:()=>void m(e),className:"inline-flex items-center justify-center h-7 w-7 rounded-lg [corner-shape:squircle] squircle-safari-fallback text-muted-foreground hover:text-foreground hover:bg-accent disabled:opacity-40 transition-colors",children:(0,a.jsx)(uz.RotateCcw,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{type:"button","aria-label":"Delete permanently",title:"Delete permanently",disabled:l===e.id,onClick:()=>d(e),className:"inline-flex items-center justify-center h-7 w-7 rounded-lg [corner-shape:squircle] squircle-safari-fallback text-muted-foreground hover:text-destructive hover:bg-destructive/10 disabled:opacity-40 transition-colors",children:(0,a.jsx)(sX.Trash2,{className:"h-3.5 w-3.5"})})]})]},e.id)})})}),r&&r.length>0&&(0,a.jsx)("div",{className:"border-t px-3 py-2.5",children:(0,a.jsx)("button",{type:"button",onClick:()=>h(!0),className:"w-full text-xs px-3 py-2 rounded-lg [corner-shape:squircle] squircle-safari-fallback text-destructive hover:bg-destructive/10 transition-colors",children:"Empty trash"})})]})}),(0,a.jsx)(uK.AlertDialog,{open:!!c,onOpenChange:e=>{e||d(null)},children:(0,a.jsxs)(uK.AlertDialogContent,{children:[(0,a.jsxs)(uK.AlertDialogHeader,{children:[(0,a.jsxs)(uK.AlertDialogTitle,{children:["Delete â",c?.title||"Untitled","â forever?"]}),(0,a.jsx)(uK.AlertDialogDescription,{children:"This permanently removes the page and any sub-pages. This canât be undone."})]}),(0,a.jsxs)(uK.AlertDialogFooter,{children:[(0,a.jsx)(uK.AlertDialogCancel,{children:"Cancel"}),(0,a.jsx)(uK.AlertDialogAction,{onClick:()=>c&&void g(c),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete forever"})]})]})}),(0,a.jsx)(uK.AlertDialog,{open:u,onOpenChange:h,children:(0,a.jsxs)(uK.AlertDialogContent,{children:[(0,a.jsxs)(uK.AlertDialogHeader,{children:[(0,a.jsx)(uK.AlertDialogTitle,{children:"Empty trash?"}),(0,a.jsx)(uK.AlertDialogDescription,{children:"Every page in the trash will be permanently deleted. This canât be undone."})]}),(0,a.jsxs)(uK.AlertDialogFooter,{children:[(0,a.jsx)(uK.AlertDialogCancel,{children:"Cancel"}),(0,a.jsx)(uK.AlertDialogAction,{onClick:()=>void f(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Empty trash"})]})]})})]})}function uG(){return(0,a.jsx)("ul",{className:"flex flex-col",children:[0,1,2,3].map(e=>(0,a.jsxs)("li",{className:"flex items-center gap-2.5 px-2 py-2",children:[(0,a.jsx)("span",{className:"h-[18px] w-[18px] shrink-0 rounded bg-muted animate-pulse"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-1.5",children:[(0,a.jsx)("span",{className:"block h-3 w-1/2 roun
2ded bg-muted animate-pulse"}),(0,a.jsx)("span",{className:"block h-2.5 w-1/3 rounded bg-muted/70 animate-pulse"})]})]},e))})}var uW=e.i(210578),uZ=e.i(728231);function uJ({color:e}){return(0,a.jsx)("span",{className:"inline-flex items-center gap-[3px]","aria-hidden":!0,children:[0,1,2].map(t=>(0,a.jsx)("span",{className:"h-1 w-1 rounded-full animate-bounce",style:{backgroundColor:e,animationDelay:`${.15*t}s`,animationDuration:"1s"}},t))})}function uX({collaborators:e}){var t;if(0===e.length)return null;let n=[...e].sort((e,t)=>Number(t.isTyping)-Number(e.isTyping)),r=n.slice(0,3),i=n.length-r.length,s=e.filter(e=>e.isTyping),l=1===s.length?`${(t=s[0].name).split(/\s+/)[0]||t} is editing`:s.length>1?`${s.length} people editing`:null;return(0,a.jsx)(uZ.TooltipProvider,{delayDuration:150,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[l&&(0,a.jsxs)("span",{className:"hidden md:inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[l,(0,a.jsx)(uJ,{color:s[0].color})]}),(0,a.jsxs)("div",{className:"flex items-center -space-x-1.5",children:[r.map(e=>(0,a.jsxs)(uZ.Tooltip,{children:[(0,a.jsx)(uZ.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("span",{className:(0,lR.cn)("relative inline-flex rounded-full ring-2",!e.isTyping&&"ring-card"),style:e.isTyping?{"--tw-ring-color":e.color}:void 0,children:[(0,a.jsx)(uW.ContactAvatar,{imageUrl:e.avatarUrl,name:e.name,size:"xs",shape:"circle"}),e.isTyping&&(0,a.jsxs)("span",{className:"absolute -bottom-0.5 -right-0.5 flex h-2 w-2",children:[(0,a.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full opacity-60 animate-ping",style:{backgroundColor:e.color}}),(0,a.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full ring-1 ring-card",style:{backgroundColor:e.color}})]})]})}),(0,a.jsxs)(uZ.TooltipContent,{children:[e.name,e.isTyping&&" · editingâ¦"]})]},e.userId)),i>0&&(0,a.jsxs)(uZ.Tooltip,{children:[(0,a.jsx)(uZ.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("span",{className:"relative inline-flex h-5 w-5 items-center justify-center rounded-full ring-2 ring-card bg-muted text-[10px] font-medium text-muted-foreground tabular-nums",children:["+",i]})}),(0,a.jsx)(uZ.TooltipContent,{children:n.slice(3).map(e=>e.name).join(", ")})]})]})]})})}let uQ=["#E5896A","#5B9A8B","#6A8CC2","#C2799E","#C9A24B","#7BA05B","#8E7CC3","#4FA3C7"];function uY(e){let t=0;for(let n=0;n<e.length;n++)t=31*t+e.charCodeAt(n)>>>0;return uQ[t%uQ.length]}class u0 extends ea{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=te();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&u1(this,t,"timeout")},es(3e3)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){let t=this.clientID,n=this.meta.get(t),r=void 0===n?0:n.clock+1,i=this.states.get(t);null===e?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:te()});let a=[],s=[],l=[],o=[];null===e?o.push(t):null==i?null!=e&&a.push(t):(s.push(t),tb(i,e)||l.push(t)),(a.length>0||l.length>0||o.length>0)&&this.emit("change",[{added:a,updated:l,removed:o},"local"]),this.emit("update",[{added:a,updated:s,removed:o},"local"])}setLocalStateField(e,t){let n=this.getLocalState();null!==n&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}}let u1=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:te()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},u2=(e,t,n=e.states)=>{let r=t.length,i=ek();eS(i,r);for(let a=0;a<r;a++){let r=t[a],s=n.get(r)||null,l=e.meta.get(r).clock;eS(i,r),eS(i,l),eM(i,JSON.stringify(s))}return eE(i)};function u3(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function u5(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}class u4{doc;awareness;synced=!1;supabase;channel;onSyncedCb;destroyed=!1;subscribed=!1;
2handleDocUpdate;handleAwarenessUpdate;handleUnload;constructor(e){this.doc=e.doc,this.supabase=e.supabase,this.onSyncedCb=e.onSynced,this.awareness=new u0(this.doc),this.channel=e.supabase.channel(e.channelName,{config:{broadcast:{self:!1}}}),this.handleDocUpdate=(e,t)=>{if(t===this)return;let n=ek();eS(n,0),eS(n,2),eO(n,e),this.broadcast(n)},this.doc.on("update",this.handleDocUpdate),this.handleAwarenessUpdate=({added:e,updated:t,removed:n},r)=>{if(r===this)return;let i=e.concat(t,n),a=ek();eS(a,1),eO(a,u2(this.awareness,i)),this.broadcast(a)},this.awareness.on("update",this.handleAwarenessUpdate),this.channel.on("broadcast",{event:"y"},({payload:e})=>{let t=e?.b64;t&&this.onMessage(u5(t))}),this.channel.subscribe(e=>{if("SUBSCRIBED"!==e||this.destroyed)return;this.subscribed=!0;let t=ek();eS(t,0);var n=this.doc;eS(t,0),eO(t,((e,t=new ra)=>(e instanceof Map?ru(t,e):ru(t,rI(e.store)),t.toUint8Array()))(n,new rr)),this.broadcast(t),this.broadcastAwareness()}),this.handleUnload=()=>{u1(this.awareness,[this.doc.clientID],"unload")},window.addEventListener("beforeunload",this.handleUnload)}
2broadcastAwareness(){if(null===this.awareness.getLocalState())return;let e=ek();eS(e,1),eO(e,u2(this.awareness,[this.doc.clientID])),this.broadcast(e)}broadcast(e){if(this.destroyed||!this.subscribed)return;let t=eE(e);this.channel.send({type:"broadcast",event:"y",payload:{b64:u3(t)}})}onMessage(e){if(this.destroyed)return;let t=eW(e),n=eX(t);if(0===n){let e=ek();eS(e,0);let n=((e,t,n,r)=>{let i=eX(e);switch(i){case 0:var a;a=eZ(e),eS(t,1),eO(t,rc(n,a));break;case 1:case 2:var s=e,l=n,o=r,c=void 0;try{let e;e=eZ(s),ro(l,e,o,re)}catch(e){null!=c&&c(e),console.error("Caught error while handling a Yjs update",e)}break;default:throw Error("Unknown message type")}return i})(t,e,this.doc,this);eN(e)>1&&this.broadcast(e),0===n&&this.broadcastAwareness(),1!==n||this.synced||(this.synced=!0,this.onSyncedCb?.())}else 1===n&&((e,t,n)=>{let r=eW(t),i=te(),a=[],s=[],l=[],o=[],c=eX(r);for(let t=0;t<c;t++){let t=eX(r),n=eX(r),c=JSON.parse(eY(r)),d=e.meta.get(t),u=e.states.get(t),h=void 0===d?0:d.clock;(h<n||h===n&&null===c&&e.states.has(t))&&(null===c?t===e.clientID&&null!=e.getLocalState()?n++:e.states.delete(t):e.states.set(t,c),e.meta.set(t,{clock:n,lastUpdated:i}),void 0===d&&null!==c?a.push(t):void 0!==d&&null===c?o.push(t):null!==c&&(tb(c,u)||l.push(t),s.push(t)))}(a.length>0||l.length>0||o.length>0)&&e.emit("change",[{added:a,updated:l,removed:o},n]),(a.length>0||s.length>0||o.length>0)&&e.emit("update",[{added:a,updated:s,removed:o},n])})(this.awareness,eZ(t),this)}destroy(){this.destroyed||(this.destroyed=!0,window.removeEventListener("beforeunload",this.handleUnload),u1(this.awareness,[this.doc.clientID],"destroy"),this.awareness.off("update",this.handleAwarenessUpdate),this.doc.off("update",this.handleDocUpdate),this.awareness.destroy(),this.supabase.removeChannel(this.channel))}}let u8=(0,ds.createLowlight)(us);function u6(e){let{placeholder:t,collab:n}=e,r=[I.default.configure({heading:{levels:[1,2,3]},codeBlock:!1,blockquote:{HTMLAttributes:{class:"pl-4"}},horizontalRule:{HTMLAttributes:{class:"my-4 border-muted-foreground/20"}},link:{openOnClick:!1,HTMLAttributes:{class:"text-muted-foreground underline decoration-muted-foreground/40 underline-offset-2 cursor-pointer hover:text-foreground hover:decoration-muted-foreground/70 transition-colors"}},dropcursor:{color:"#A6BFD0",width:4,class:"doc-dropcursor"},...n?{undoRedo:!1}:{},listItem:!1}),U,da.configure({lowlight:u8,defaultLanguage:null,HTMLAttributes:{class:"doc-code-block"}}),L.default.configure({placeholder:t}),R.default.configure({types:["heading","paragraph"],alignments:["left","center","right","justify"]}),P.default.configure({inline:!1,allowBase64:!1,HTMLAttributes:{class:"rounded-md max-w-full mx-auto"},resize:{enabled:!0,directions:["bottom-right","bottom-left","top-right","top-left"],minWidth:50,minHeight:50,alwaysPreserveAspectRatio:!0}}),la.Video,lo,lp,lv,lx,lw.Columns,lw.Column,l_.Callout,lD,lU,lQ,l1,on,c5,c4.DocMap,c9,F.default.configure({HTMLAttributes:{class:"not-prose"}}),q.configure({nested:!0}),H.default.configure({multicolor:!0}),K.TextStyle,V.default,c8];return n&&r.push(sx.configure({document:n.doc}),sk.configure({provider:n.provider,user:{name:n.user.name,color:n.user.color}})),r}let u9="default",u7="load",he=(0,s.forwardRef)(function({docId:e,initialHtml:t,...n},r){let{status:i,session:l}=function(e){let{enabled:t,docId:n}=e,[r,i]=(0,s.useState)(null),a=t?r?"ready":"connecting":"disabled",l=(0,s.useRef)(e.initialHtml),o=(0,s.useRef)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(!1),u=(0,s.useCallback)(async(e=!1)=>{let t,r=o.current;if(!r)return;d.current=!1;let i=u3(rc(r.doc));try{var a;a=r.doc,t=function(e,t){if("u"<typeof window)throw Error("generateHTML can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");let n=(0,G.getSchema)(t);var r=O.Node.fromJSON(n,e);if("u"<typeof window)throw Error("getHTMLFromFragment can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");let i=window.document.createElement("div");return O.DOMSerializer.fromSchema(n).serializeFragment(r.content,{document:window.document},i),i.innerHTML}(function(e,t="prosemirror"){let n,r;return n=e.getXmlFragment(t).toArray(),r=e=>{let t;if(e instanceof iQ)t=e.toDelta().map(e=>{let t={type:"text",text:e.insert};return e.attributes&&(t.marks=Object.keys(e.attributes).map(t=>{let n=e.attributes[t],r={type:a5(t)};return Object.keys(n)&&(r.attrs=n),r})),t});else if(e instanceof iZ){t={type:e.nodeName};let n=e.getAttributes();Object.keys(n).length&&(t.attrs=n);let i=e.toArray();i.length&&(t.content=i.map(r).flat())}else eH();return t},{type:"doc",content:n.map(r)}}(a,u9),u6({placeholder:""}))}catch{}await fetch(`/api/docs/${n}/ydoc`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:i,content_html:t}
2),keepalive:e}).catch(()=>{})},[n]);return(0,s.useEffect)(()=>{if(!t)return;let e=!1,r=(0,ln.createClient)(),a=new n9,s=null;return(async()=>{let{data:{user:t}}=await r.auth.getUser();if(e)return;let h=t?.email??"Someone",p=uY(t?.id??"anon");if(t){let{data:e}=await r.from("profiles").select("full_name").eq("id",t.id).maybeSingle();e?.full_name?.trim()&&(h=e.full_name.trim())}if(e)return;let m=null;try{let e=await fetch(`/api/docs/${n}/ydoc`);e.ok&&(m=(await e.json()).state)}catch{}if(e)return;if(m)ro(a,u5(m),u7,re);else{let t=null;try{let e=u6({placeholder:""}),r=function(e,t){if("u"<typeof window)throw Error("generateJSON can only be used in a browser environment\nIf you want to use this in a Node environment, use the `@tiptap/html/server` import instead.");let n=(0,G.getSchema)(t),r=new window.DOMParser().parseFromString(e,"text/html");if(!r)throw Error("Failed to parse HTML string");return O.DOMParser.fromSchema(n).parse(r.body,void 0).toJSON()}(l.current||"<p></p>",e),i=function(e,t,n="prosemirror"){return function(e,t="prosemirror"){var n;let r,i=new n9,a=i.get(t,iW);return a.doc?(n=e,r=a||new iW,a6(r.doc?r.doc:{transact:e=>e(void 0)},r,n,{mapping:new Map,isOMark:new Map}),a.doc):i}(O.Node.fromJSON(e,t),n)}((0,G.getSchema)(e),r,u9),a=u3(rc(i));i.destroy();let s=await fetch(`/api/docs/${n}/ydoc`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:a,seed:!0})});t=s.ok?(await s.json()).state:a}catch{}if(e)return;t&&ro(a,u5(t),u7,re)}if(e)return;let g=new u4({supabase:r,channelName:`doc-collab-${n}`,doc:a});o.current=g;let f=(e,t)=>{t!==g&&t!==u7&&(d.current=!0,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{u()},800))};a.on("update",f),s=()=>a.off("update",f),e||i({doc:a,provider:g,user:{name:h,color:p}})})(),()=>{e=!0,c.current&&clearTimeout(c.current),d.current&&u(!0),s?.(),o.current?.destroy(),o.current=null,a.destroy(),i(null)}},[t,n,u]),{status:a,session:r}}({enabled:!0,docId:e,initialHtml:t});return"ready"===i&&l?(0,a.jsx)(uS,{ref:r,initialContent:t,collab:l,...n}):(0,a.jsx)("div",{className:"tiptap doc-canvas px-8 md:pl-16 md:pr-8 min-h-[60vh]","aria-hidden":!0,children:(0,a.jsxs)("div",{className:"space-y-3 pt-1",children:[(0,a.jsx)("div",{className:"h-4 w-2/3 rounded bg-muted animate-pulse"}),(0,a.jsx)("div",{className:"h-4 w-full rounded bg-muted animate-pulse"}),(0,a.jsx)("div",{className:"h-4 w-5/6 rounded bg-muted animate-pulse"}
2),(0,a.jsx)("div",{className:"h-4 w-1/2 rounded bg-muted animate-pulse"})]})})});var ht=e.i(287045),hn=e.i(438133),hr=e.i(841074),hi=e.i(607709);let ha="doc:demo-agent-append";e.s(["DEMO_DOC_APPEND_EVENT",0,ha],850390);var hs=e.i(357657),hl=e.i(327147);let ho="docs-agent-auto-accept";function hc(e){if(!e)return[];let t=new DOMParser().parseFromString(e,"text/html"),n=[],r=new Set;return t.querySelectorAll("[data-template-field]").forEach(e=>{let t=e.getAttribute("data-field-id")||crypto.randomUUID();r.has(t)||(r.add(t),n.push({id:t,label:(e.getAttribute("data-field-label")||"Field").trim()||"Field",sample:(e.textContent||"").trim().slice(0,120)}))}),n}function hd({docId:e,docTitle:t,isHome:n,parentId:r,onOpenComments:i,onTurnIntoTemplate:l,onDownloadPdf:c,templateMode:d,initialIsDocTemplate:u=!1}){let f=(0,o.useRouter)(),[x,y]=(0,s.useState)(!1),[v,w]=(0,s.useState)(!1),[N,E]=(0,s.useState)(!1),[j,A]=(0,s.useState)(u),[M,T]=(0,s.useState)(!1),[O,I]=(0,s.useState)("menu"),[L,R]=(0,s.useState)(null);(0,s.useEffect)(()=>{let t=!1;return(async()=>{let n=(0,ln.createClient)(),{count:r}=await n.from("comments").select("id",{count:"exact",head:!0}).eq("entity_type","doc").eq("entity_id",e).is("resolved_at",null);t||R(r??0)})(),()=>{t=!0}},[e]);let P=async()=>{let t=!j;T(!0),A(t);try{(await fetch("/api/docs/templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({docId:e,isTemplate:t})})).ok?f.refresh():A(!t)}catch{A(!t)}finally{T(!1)}},F=async()=>{(y(!1),(await fetch(`/api/docs/${e}`,{method:"DELETE"})).ok)?((0,uq.undoToast)("Deleted",async()=>{(await fetch(`/api/docs/${e}/restore`,{method:"POST"})).ok?(f.push(`/docs/${e}`),f.refresh()):D.toast.error("Could not restore doc")}),f.push(r?`/docs/${r}`:"/docs"),f.refresh()):D.toast.error("Could not delete doc")},B=async()=>{E(!0);try{let t=await fetch(`/api/docs/${e}/move-to-home`,{method:"POST"}),n=await t.json().catch(()=>({}));if(!t.ok)return void D.toast.error(n?.error||"Could not move to home page");D.toast.success(n?.linked===!1?"Already on your home page":"Moved to your home page",{action:{label:"View",onClick:()=>f.push("/docs")}}),f.refresh()}catch{D.toast.error("Could not move to home page")}finally{E(!1)}};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(ow.DropdownMenu,{onOpenChange:e=>{e||I("menu")},children:[(0,a.jsx)(ow.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsx)("button",{type:"button","aria-label":"More",className:"inline-flex items-center justify-center h-8 w-8 rounded-[10px] [corner-shape:squircle] squircle-safari-fallback text-xs text-muted-foreground/80 hover:text-foreground hover:bg-accent transition-colors",children:(0,a.jsx)(g.MoreHorizontal,{className:"h-4 w-4"})})}),(0,a.jsx)(ow.DropdownMenuContent,{align:"end",className:"share"===O?"w-80 p-2":"w-48",onCloseAutoFocus:e=>{"share"===O&&e.preventDefault()},children:"menu"===O?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(ow.DropdownMenuItem,{onSelect:e=>{e.preventDefault(),i()},children:[(0,a.jsx)(p.MessageSquare,{className:"h-3.5 w-3.5 mr-2"}),"Comments",null!=L&&L>0?(0,a.jsx)("span",{className:"ml-auto text-[11px] tabular-nums px-1 rounded bg-foreground
2/10",children:L}):null]}),(0,a.jsxs)(ow.DropdownMenuItem,{onSelect:e=>{e.preventDefault(),c()},children:[(0,a.jsx)(k.Download,{className:"h-3.5 w-3.5 mr-2"}),"Download as PDF"]}),!n&&(0,a.jsxs)(ow.DropdownMenuItem,{onSelect:e=>{e.preventDefault(),I("share")},children:[(0,a.jsx)(b.Share2,{className:"h-3.5 w-3.5 mr-2"}),"Share"]}),!n&&(0,a.jsxs)(ow.DropdownMenuItem,{disabled:d,onSelect:e=>{e.preventDefault(),l()},children:[(0,a.jsx)(_.FileSignature,{className:"h-3.5 w-3.5 mr-2"}),"Turn into contract template"]}),!n&&(0,a.jsxs)(ow.DropdownMenuItem,{disabled:M,onSelect:e=>{e.preventDefault(),P()},children:[(0,a.jsx)(m.LayoutTemplate,{className:"h-3.5 w-3.5 mr-2"}),j?"Remove from doc templates":"Save as doc template"]}),!n&&(0,a.jsxs)(ow.DropdownMenuItem,{disabled:N,onSelect:e=>{e.preventDefault(),B()},children:[N?(0,a.jsx)(h.Loader2,{className:"h-3.5 w-3.5 mr-2 animate-spin"}):(0,a.jsx)(S.Home,{className:"h-3.5 w-3.5 mr-2"}),"Move to home page"]}),(0,a.jsxs)(ow.DropdownMenuItem,{onSelect:e=>{e.preventDefault(),w(!0)},children:[(0,a.jsx)(C.History,{className:"h-3.5 w-3.5 mr-2"}),"Recently deleted"]}),(0,a.jsxs)(ow.DropdownMenuItem,{disabled:n,onSelect:e=>{e.preventDefault(),y(!0)},className:"text-destructive focus:text-destructive",children:[(0,a.jsx)(l3.TrashIcon,{className:"h-3.5 w-3.5 mr-2"}),"Delete page"]})]}):(0,a.jsx)(uU,{docId:e,docTitle:t,onBack:()=>I("menu")})})]}),(0,a.jsx)(uK.AlertDialog,{open:x,onOpenChange:y,children:(0,a.jsxs)(uK.AlertDialogContent,{children:[(0,a.jsxs)(uK.AlertDialogHeader,{children:[(0,a.jsxs)(uK.AlertDialogTitle,{children:["Delete â",t,"â?"]}),(0,a.jsx)(uK.AlertDialogDescription,{children:"This deletes the page and all of its sub-pages. You can restore them from Recently deleted within 30 days."})]}),(0,a.jsxs)(uK.AlertDialogFooter,{children:[(0,a.jsx)(uK.AlertDialogCancel,{children:"Cancel"}),(0,a.jsx)(uK.AlertDialogAction,{onClick:F,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),(0,a.jsx)(uV,{open:v,onOpenChange:w,onChanged:()=>f.refresh()})]})}function hu({docId:e}){let[t,n]=(0,s.useState)(!1),r=async()=>{try{let t=`${window.location.origin}/docs/${e}`;await navigator.clipboard.writeText(t),D.toast.success("Link copied"),n(!0),setTimeout(()=>n(!1),1500)}catch{D.toast.error("Could not copy")}};return(0,a.jsx)("button",{type:"button",onClick:r,"aria-label":"Copy page link",title:"Copy page link",className:"inline-flex items-center justify-center h-8 w-8 rounded-[10px] [corner-shape:squircle] squircle-safari-fallback text-muted-foreground/80 hover:text-foreground hover:bg-accent transition-colors",children:t?(0,a.jsx)(u.Check,{className:"h-4 w-4"}):(0,a.jsx)(v.Link2,{className:"h-4 w-4"})})}function hh({docId:e,initialStarred:t}){let[n,r]=(0,s.useState)(t),i=async()=>{let t=!n;r(t),(await fetch(`/api/docs/${e}/star`,{method:t?"POST":"DELETE"})).ok||(r(!t),D.toast.error("Could not update star"))};return(0,a.jsx)("button",{type:"button",onClick:i,"aria-label":n?"Unstar page":"Star page",title:n?"Unstar":"Star",className:"inline-flex items-center justify-center h-8 w-8 rounded-[10px] [corner-shape:squircle] squircle-safari-fallback text-muted-foreground/80 hover:text-foreground hover:bg-accent transition-colors",children:(0,a.jsx)(y.Star,{className:`h-4 w-4 ${n?"fill-amber-400 text-amber-500":""}`})})}function hp({docId:e,open:t,onOpenChange:n}){return(0,a.jsx)(uH.Sheet,{open:t,onOpenChange:n,children:(0,a.jsxs)(uH.SheetContent,{side:"right",className:"w-[420px] sm:max-w-[420px] p-0 flex flex-col",children:[(0,a.jsx)(uH.SheetHeader,{className:"px-4 pt-4 pb-2 border-b",children:(0,a.jsx)(uH.SheetTitle,{className:"text-sm font-medium",children:"Comments"})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto p-3",children:(0,a.jsx)(hr.CommentsSection,{entityType:"doc",entityId:e,variant:"compact"})})]})})}function hm(){let[e,t]=(0,s.useState)(!1),[n,r]=(0,s.useState)(""),[i,l]=(0,s.useState)(null),d=(0,s.useRef)(null),u=(0,s.useRef)(null),h=(0,o.useRouter)(),p=(0,s.useMemo)(()=>(0,c.createIntentPrefetcher)(h),[h]);(0,s.useEffect)(()=>
2{if(!e)return;let t=!1;return(async()=>{let e=(0,ln.createClient)(),{data:n}=await e.from("docs").select("id, title, icon, updated_at").eq("is_home",!1).is("deleted_at",null).order("updated_at",{ascending:!1}).limit(200);t||l(n||[])})(),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>d.current?.focus(),120);return()=>clearTimeout(t)},[e]);let m=(0,s.useCallback)(e=>{let r=e.relatedTarget;!(r&&u.current?.contains(r))&&(n.trim()||t(!1))},[n]),g=(0,s.useCallback)(()=>{t(!1),r("")},[]),b=(0,s.useMemo)(()=>{if(!i)return null;let e=n.trim().toLowerCase();return e?i.filter(t=>(t.title||"Untitled").toLowerCase().includes(e)):i},[i,n]);return(0,a.jsxs)("div",{ref:u,onBlur:m,className:(0,lR.cn)("relative flex items-center h-8 transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]",e?"w-[220px]":"w-8"),children:[(0,a.jsx)("button",{type:"button",onClick:()=>t(!0),"aria-label":"Search docs",title:"Search docs",className:(0,lR.cn)("absolute inset-0 inline-flex items-center justify-center rounded-[10px] [corner-shape:squircle] squircle-safari-fallback text-muted-foreground/80 hover:text-foreground hover:bg-accent transition-colors",e?"opacity-0 pointer-events-none":"opacity-100"),children:(0,a.jsx)(f.Search,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:(0,lR.cn)("search-pill flex items-center gap-1.5 w-full h-8 rounded-full border bg-white border-[oklch(0.85_0.01_60)] dark:bg-black dark:border-transparent pl-2.5 pr-2 overflow-hidden transition-opacity duration-200 delay-100",e?"opacity-100":"opacity-0 pointer-events-none"),children:[(0,a.jsx)(f.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,a.jsx)("input",{ref:d,type:"text",value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),g())},placeholder:"Search docsâ¦","aria-label":"Search docs",tabIndex:e?0:-1,className:"search-pill-input flex-1 min-w-0 bg-transparent outline-none placeholder:text-muted-foreground"})]}),e&&(0,a.jsx)("div",{className:"absolute right-0 top-full mt-1 w-[320px] z-50 max-h-[60vh] overflow-y-auto p-1.5 rounded-[20px] [corner-shape:squircle] squircle-safari-fallback border border-black/15 dark:border-white/15 bg-white dark:bg-popover shadow-[0_2px_8px_rgba(0,0,0,0.08),0_12px_32px_rgba(0,0,0,0.12)] dark:shadow-[0_2px_8px_rgba(0,0,0,0.2),0_12px_32px_rgba(0,0,0,0.3)]",children:null===b?(0,a.jsx)("div",{className:"space-y-0.5","aria-hidden":!0,children:Array.from({length:5}).map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,a.jsx)("span",{className:"h-4 w-4 shrink-0 rounded bg-muted animate-pulse"}),(0,a.jsx)("span",{className:"h-3.5 rounded bg-muted animate-pulse",style:{width:`${72-9*t}%`}})]},t))}):0===b.length?(0,a.jsx)("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:n.trim()?"No docs match.":"No docs yet."}):b.map(e=>(0,a.jsxs)("button",{type:"button",onMouseDown:t=>{t.preventDefault(),h.push(`/docs/${e.id}`),g()},onMouseEnter:()=>p.enter(`/docs/${e.id}`),onMouseLeave:p.leave,className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-[14px] [corner-shape:squircle] squircle-safari-fallback text-sm hover:bg-accent text-left",children:[(0,a.jsx)("span",{className:"text-base shrink-0 inline-flex items-center justify-center w-5",children:e.icon?(0,a.jsx)(lr.DocIcon,{icon:e.icon,size:16}):(0,a.jsx)(li.QuillIcon,{className:"h-4 w-4 text-muted-foreground"})}),(0,a.jsx)("span",{className:"truncate",children:e.title||"Untitled"})]},e.id))})]})}function hg({icon:e,onIconChange:t,title:n,onTitleChange:r,titlePlaceholder:i="Untitled",autoFocus:o=!1,defaultIcon:c=null,onEnter:d}){let[u,h]=(0,s.useState)(!1),[p,m]=(0,s.useState)(null),g=(0,s.useRef)(null),f=(0,s.useRef)(null),b=(0,s.useRef)(null);(0,s.useEffect)(()=>{o&&b.current?.focus()},[]),(0,s.useLayoutEffect)(()=>{let e=b.current;if(!e)return;let t=()=>{e.style.height="auto",e.style.height=`${e.scrollHeight}px`};t(),document.fonts?.ready.then(t).catch(()=>{});let n=e.clientWidth,r=new ResizeObserver(()=>{e.clientWidth!==n&&(n=e.clientWidth,t())});return r.observe(e),()=>r.disconnect()},[n]),(0,s.useEffect)(()=>
2{if(!u)return;let e=e=>{let t=e.target;!t||f.current?.contains(t)||g.current?.contains(t)||h(!1)};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[u]);let y=!!e,v=y&&e.startsWith("lucide:"),_=y&&(0,lc.isDocIconImage)(e),k=v||_,N=!y&&!!c;return(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("button",{ref:g,type:"button",onClick:()=>{if(!g.current)return;let e=g.current.getBoundingClientRect();m((0,lr.clampIconPickerAnchor)(e)),h(!0)},"aria-label":y?"Change icon":N?"Set a custom icon":"Add icon",className:(0,lR.cn)("mb-3 inline-flex items-center justify-center rounded-lg [corner-shape:squircle] squircle-safari-fallback transition-colors",y&&!k&&"text-[56px] leading-none hover:bg-accent/50 p-0.5",y&&k&&"hover:bg-accent/50 p-0.5",N&&"p-1 hover:bg-accent/40",!y&&!N&&"text-xs text-muted-foreground/60 hover:text-foreground hover:bg-accent px-1.5 py-1"),children:y?(0,a.jsx)(lr.DocIcon,{icon:e,size:k?56:void 0,className:v?"text-foreground":void 0}):N?c:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,a.jsx)(x.Smile,{className:"h-3.5 w-3.5"}),"Add icon"]})}),(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("textarea",{ref:b,rows:1,value:n,onChange:e=>r(e.target.value.replace(/[\r\n]+/g," ")),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),d?.())},placeholder:i,className:"flex-1 min-w-0 resize-none overflow-hidden break-words bg-transparent text-4xl md:text-[2.625rem] leading-tight font-[720] tracking-[-0.016em] outline-none placeholder:text-muted-foreground/50"}),y&&(0,a.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),t(null)},"aria-label":"Remove icon",className:"mt-3 p-1 rounded-lg [corner-shape:squircle] squircle-safari-fallback text-muted-foreground/40 hover:text-foreground hover:bg-accent opacity-0 hover:opacity-100 focus:opacity-100",title:"Remove icon",children:(0,a.jsx)(w.X,{className:"h-3.5 w-3.5"})})]}),u&&p&&"u">typeof document&&(0,l.createPortal)((0,a.jsx)("div",{ref:f,className:"fixed z-50",style:{left:p.left,top:p.top},children:(0,a.jsx)(lr.IconPicker,{onSelect:e=>{t(e),h(!1)},onClose:()=>h(!1)})}),document.body)]})}function hf({state:e}){return"saving"===e?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(h.Loader2,{className:"h-3 w-3 animate-spin"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Savingâ¦"})]}):"saved"===e?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,a.jsx)(u.Check,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Saved"})]}):"dirty"===e?(0,a.jsx)("span",{className:"hidden sm:inline text-xs text-muted-foreground/70",children:"Unsaved"}):null}function hb({kind:e,disabled:t,onClick:n}){let r="undo"===e?N.Undo2:E.Redo2,i="undo"===e?"Undo":"Redo";return(0,a.jsx)("button",{type:"button","aria-label":i,title:`${i} (${"undo"===e?"âZ":"ââ§Z"})`,disabled:t,onMouseDown:e=>e.preventDefault(),onClick:n,className:"inline-flex items-center justify-center h-8 w-8 rounded-[10px] [corner-shape:squircle] squircle-safari-fallback text-muted-foreground/80 hover:text-foreground hover:bg-accent disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-muted-foreground/80 disabled:cursor-default transition-colors",children:(0,a.jsx)(r,{className:"h-4 w-4"})})}e.s(["DocEditorPage",0,function({doc:e,breadcrumbs:t,isHome:n=!1,initialStarred:r=!1,awaitingRow:i=!1}){let l=(0,o.useRouter)(),c=(0,uc.useIsMobile)(),[u,h]=(0,s.useState)(e.title||""),[p]=(0,s.useState)(()=>{var t;return t=e.id,lm.get(t)??e.content_html??""}),[m,g]=(0,s.useState)(p),[f,b]=(0,s.useState)(e.icon),[x,y]=(0,s.useState)("idle"),[v,w]=(0,s.useState)(!1),[k,N]=(0,s.useState)(!1),E=(0,s.useCallback)(e=>{w(e.canUndo),N(e.canRedo)},[]),[C,S]=(0,s.useState)(!1),[M,T]=(0,s.useState)(!1),[O,I]=(0,s.use
2State)(!1),[L,R]=(0,s.useState)(null),P=(0,s.useMemo)(()=>(0,hn.countSlides)(m),[m]),F=(0,s.useMemo)(()=>M?hc(m):[],[M,m]),B=(0,s.useRef)({title:e.title||"",content_html:e.content_html||"",icon:e.icon}),U=(0,s.useRef)(null),$=(0,s.useRef)(null),[z]=(0,s.useState)(()=>"u">typeof crypto&&crypto.randomUUID?crypto.randomUUID():`c-${Math.random().toString(36).slice(2)}-${Date.now()}`),q=(0,s.useRef)(!1),H=(0,s.useRef)(null),K=(0,s.useRef)(null);(0,s.useEffect)(()=>{K.current=H.current?.querySelector(".ProseMirror")??null});let[V,G]=(0,s.useState)(null),[W,Z]=(0,s.useState)(()=>{try{return"1"===localStorage.getItem(ho)}catch{return!1}}),J=(0,hs.useClaudeDocWriting)(e.id),{agent:X,name:Q}=(0,uf.useAgentBrand)(),{collaborators:Y,notifyTyping:ee}=function(e,t){let[n,r]=(0,s.useState)([]),[i,a]=(0,s.useState)(()=>new Set),[l,o]=(0,s.useState)(null),c=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(new Map);(0,s.useEffect)(()=>{let e=!1;return(async()=>{let n=(0,ln.createClient)(),{data:{user:r}}=await n.auth.getUser();if(!r||e)return;let{data:i}=await n.from("profiles").select("full_name, avatar_url").eq("id",r.id).maybeSingle();e||o({clientId:t,userId:r.id,name:i?.full_name?.trim()||r.email||"Someone",avatarUrl:i?.avatar_url??null,color:uY(r.id)})})(),()=>{e=!0}},[t]);let h=(0,s.useCallback)(e=>{let t=u.current,n=t.get(e);n&&clearTimeout(n),a(t=>t.has(e)?t:new Set(t).add(e)),t.set(e,setTimeout(()=>{t.delete(e),a(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},3500))},[]);(0,s.useEffect)(()=>{if(!l)return;let n=(0,ln.createClient)(),i=u.current,s=n.channel(`doc-presence-${e}`,{config:{presence:{key:t}}});return c.current=s,s.on("presence",{event:"sync"},()=>{r(Object.values(s.presenceState()).flat())}).on("broadcast",{event:"typing"},({payload:e})=>{let n=e?.clientId;n&&n!==t&&h(n)}).subscribe(e=>{"SUBSCRIBED"===e&&s.track(l)}),()=>{c.current=null,n.removeChannel(s),i.forEach(e=>clearTimeout(e)),i.clear(),a(new Set),r([])}},[e,t,l,h]);let p=(0,s.useCallback)(()=>{let e=c.current;if(!e)return;let n=Date.now();n-d.current<1500||(d.current=n,e.send({type:"broadcast",event:"typing",payload:{clientId:t}}))},[t]);return{collaborators:(0,s.useMemo)(()=>{let e=new Map;for(let t of n){if(!t.userId||t.userId===l?.userId)continue;let n=i.has(t.clientId),r=e.get(t.userId);r?r.isTyping=r.isTyping||n:e.set(t.userId,{userId:t.userId,name:t.name,avatarUrl:t.avatarUrl,color:t.color,isTyping:n})}return Array.from(e.values())},[n,i,l?.userId]),notifyTyping:p}}(e.id,z),[et,en]=(0,s.useState)(!1);(0,s.useEffect)(()=>{en(function(){try{let e=new URLSearchParams(window.location.search).get("collab");("1"===e||"0"===e)&&localStorage.setItem("docs-collab",e);let t=localStorage.getItem("docs-collab");if("1"===t)return!0;if("0"===t)return!1}catch{}return"1"===tr.default.env.NEXT_PUBLIC_DOCS_LIVE_CURSORS}())},[]);let er=(0,s.useRef)({title:u,contentHtml:m,icon:f});er.current={title:u,contentHtml:m,icon:f};let ei=(0,s.useCallback)(e=>{er.current={...er.current,contentHtml:e}},[]),ea=(0,s.useCallback)((t,n)=>{lu(e.id,{title:t,icon:n}),e.parent_id&&function(e,t,n,r){let i=lm.get(e);if(!i||!i.includes(t))return;let a=i.replace(/<div\b[^>]*\bdata-page-link\b[^>]*>/g,e=>{if(!e.includes(`data-doc-id="${t}"`))return e;let i=lg(n.trim()||"Untitled"),a=/data-page-title="[^"]*"/.test(e)?e.replace(/data-page-title="[^"]*"/,`data-page-title="${i}"`):e.replace(/data-doc-id="[^"]*"/,e=>`${e} data-page-title="${i}"`);if(r){let e=lg(r);a=/data-page-icon="[^"]*"/.test(a)?a.replace(/data-page-icon="[^"]*"/,`data-page-icon="${e}"`):a.replace(/data-page-title="[^"]*"/,t=>`${t} data-page-icon="${e}"`)}else a=a.replace(/\s*data-page-icon="[^"]*"/,"");return a});lm.set(e,a)}(e.parent_id,e.id,t,n)},[e.id,e.parent_id]),es=(0,s.useCallback)(e=>{h(e),ea(e,f)},[f,ea]),el=(0,s.useCallback)(e=>{b(e),ea(u,e)},[u,ea]),[eo,ec]=(0,s.useState)(!i),ed=(0,s.useRef)(eo);ed.current=eo,(0,s.useEffect)(()=>{if(!i)return;document.cookie="doc-creating=; Path=/; Max-Age=0; SameSite=Lax";let t=!1,n=(0,ln.createClient)();return(async()=>{for(let r=0;r<40&&!t;r++){let{data:r}=await n.from("docs").select("id").eq("id",e.id).is("deleted_at",null).maybeSingle();if(r){t||ec(!0);return}await new Promise(e=>setTimeout(e,50))}t||ec(!0)})(),()=>{t=!0}},[i,e.id]);let eu=(0,s.useCallback)((e=0)=>{let t=(0,hn.parseSlides)(er.current.contentHtml);0===t.length?D.toast.error("Add a slide first â type /slide"):R({slides:t,startIndex:Math.min(Math.max(e,0),t.length-1)})},[]);(0,s.useEffect)(()=>{let t=t=>{let n=t.detail;!n||n.docId&&n.docId!==e.id||eu(n.index)};return window.addEventListener(lC,t),()=>window.removeEventListener(lC,t)},[e.id,eu]);let eh=(0,s.useCallback)(e=>{er.current={...er.current,contentHtml:e},g(e)},[]),ep=!n&&!(e.title||"").trim()&&!(e.content_html||"").trim(),em=(0,s.useCallback)(async t=>{y("saving");let n=et?{title:t.title,icon:t.icon,origin:z}:{...t,origin:z};(await fetch(`/api/docs/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})).ok?(B.current=t,q.current=!1,y("saved"),setTimeout(()=>y(e=>"saved"===e?"idle":e),1500),l.refresh()):y("dirty")},[e.id,l,z,et]),eg=(0,s.useCallback)(async()=>{let t=hc(m);if(0===t.length)return void D.toast.error("Mark at least one editable field first");I(!0);let n=await fetch("/api/contract-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_doc_id:e.id,title:u||"Untitled",content_html:m,fields:t})});(I(!1),n.ok)?(D.toast.success("Saved as contract template"),T(!1),l.push("/templates?tab=contracts")):D.toast.error("Could not save template")},[e.id,u,m,l]);(0,s.useEffect)(()=>{let e=u!==B.current.title||!et&&m!==B.current.content_html||f!==B.current.icon;if(q.current=e,e&&eo)return ee(),y("dirty"),U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{em({title:u,content_html:m,icon:f})},800),()=>{U.current&&clearTimeout(U.current)}},[u,m,f,em,ee,et,eo]);let{consume:ef,streaming:eb}=function({editorRef:e,contentElRef:t,enabled:n,onApplied:r}
2){let i=(0,s.useRef)([]),a=(0,s.useRef)(null),[l,o]=(0,s.useState)(!1),c=(0,s.useRef)(r);(0,s.useEffect)(()=>{c.current=r},[r]);let d=(0,s.useCallback)(()=>{let e=t.current,n=e?.lastElementChild;!n||n.classList.contains("doc-agent-block-in")||(n.classList.add("doc-agent-block-in"),setTimeout(()=>n.classList.remove("doc-agent-block-in"),620))},[t]),u=(0,s.useRef)(()=>{}),h=(0,s.useCallback)(()=>{a.current=null;let t=e.current,n=i.current.shift();if(void 0===n||!t){i.current=[],o(!1);return}(t.appendContent(n),d(),c.current(t.getHTML()),0===i.current.length)?o(!1):a.current=setTimeout(()=>u.current(),Math.min(90,Math.max(22,Math.round(700/i.current.length))))},[e,d]);(0,s.useEffect)(()=>{u.current=h},[h]);let p=(0,s.useCallback)(e=>{if(!n||!e.agent)return!1;let t=e.appended_html;if("string"!=typeof t||!t.trim())return!1;let r=function(e){if(!e.trim())return e.trim()?[e]:[];let t=new DOMParser().parseFromString(`<body>${e}</body>`,"text/html"),n=[];for(let e of Array.from(t.body.childNodes))if(e.nodeType===Node.ELEMENT_NODE)n.push(e.outerHTML);else if(e.nodeType===Node.TEXT_NODE){let t=e.textContent??"";t.trim()&&n.push(`<p>${t}</p>`)}return n.length>0?n:[e]}(t);return 0!==r.length&&(i.current.push(...r),o(!0),a.current||(a.current=setTimeout(()=>u.current(),0)),!0)},[n]);return(0,s.useEffect)(()=>()=>{a.current&&clearTimeout(a.current),a.current=null,i.current=[]},[]),{consume:p,streaming:l}}({editorRef:$,contentElRef:K,enabled:!et,onApplied:(0,s.useCallback)(e=>{B.current.content_html=e,er.current={...er.current,contentHtml:e},g(e)},[])}),ex=(0,s.useCallback)(t=>{if(!(t.agent&&ef(t))&&!(q.current||$.current?.isFocused())){if(t.agent&&!et&&"string"==typeof t.content_html&&!W){let e=$.current?.getHTML()??B.current.content_html;e.trim()&&G({previousHtml:e})}if("string"==typeof t.title&&(B.current.title=t.title,h(t.title),lu(e.id,{title:t.title,icon:f})),"icon"in t){let n=t.icon??null;B.current.icon=n,b(n),lu(e.id,{title:"string"==typeof t.title?t.title:u,icon:n})}et||"string"!=typeof t.content_html||(B.current.content_html=t.content_html,$.current?.setContent(t.content_html),g(t.content_html))}},[et,ef,W,e.id,f,u]);return(0,s.useEffect)(()=>{let t=(0,ln.createClient)(),n=t.channel(`doc-${e.id}`).on("broadcast",{event:"doc_updated"},({payload:e})=>{e&&e.origin!==z&&ex(e)}).subscribe();return()=>{t.removeChannel(n)}},[e.id,z,ex]),(0,s.useEffect)(()=>{if(!(0,hi.isDemoMode)())return;let e=e=>{let t=e.detail;t?.appended_html&&ex({agent:!0,appended_html:t.appended_html})};return window.addEventListener(ha,e),()=>window.removeEventListener(ha,e)},[ex]),(0,s.useEffect)(()=>{let t=()=>{let{title:t,contentHtml:n,icon:r}=er.current;(t!==B.current.title||!et&&n!==B.current.content_html||r!==B.current.icon)&&ed.current&&fetch(`/api/docs/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(et?{title:t,icon:r,origin:z}:{title:t,content_html:n,icon:r,origin:z}),keepalive:!0})},n=()=>{"hidden"===document.visibilityState&&t()};return window.addEventListener("beforeunload",t),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("beforeunload",t),document.removeEventListener("visibilitychange",n),t()}},[e.id,z,et]),(0,a.jsxs)("div",{className:(0,lR.cn)("relative overflow-x-clip",c&&"h-[calc(100dvh-3.5rem)] overflow-y-auto"),children:[(0,a.jsxs)("div",{className:"sticky top-0 z-30 flex items-center justify-between gap-4 px-4 h-12 bg-card",children:[(0,a.jsx)("div",{className:"flex items-center gap-1 text-xs min-w-0 overflow-hidden",children:!n&&t.map((t,n)=>{let r=t.is_home?"/docs":`/docs/${t.id}`,i=t.id===e.id,s=i?u||"Untitled":t.title||"Untitled",l=i?f:t.icon;return(0,a.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[n>0&&(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"âº"}),i?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 text-muted-foreground/80 truncate max-w-[240px]",children:[l&&(0,a.jsx)(lr.DocIcon,{icon:l,size:12,className:"shrink-0"}),s]}):(0,a.jsxs)(d.default,{href:r,className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md [corner-shape:squircle] squircle-safari-fallback text-muted-foreground
2/70 hover:text-foreground hover:bg-accent transition-colors truncate max-w-[240px]",children:[l&&(0,a.jsx)(lr.DocIcon,{icon:l,size:12,className:"shrink-0"}),s]})]},t.id)})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsx)(uX,{collaborators:Y}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(hb,{kind:"undo",disabled:!v,onClick:()=>$.current?.undo()}),(0,a.jsx)(hb,{kind:"redo",disabled:!k,onClick:()=>$.current?.redo()})]}),J||eb?(0,a.jsxs)("span",{className:"flex items-center gap-1.5 shrink-0","aria-live":"polite",children:[(0,a.jsx)(ug.AgentGlyph,{agent:X,className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"claude-shimmer-text",children:"Writing"})]}):(0,a.jsx)(hf,{state:x}),P>0&&(0,a.jsxs)("button",{type:"button",onClick:()=>eu(0),title:`Present ${P} slide${1===P?"":"s"} full screen`,className:"inline-flex items-center gap-1.5 h-8 pl-2 pr-2.5 rounded-[10px] [corner-shape:squircle] squircle-safari-fallback text-muted-foreground/80 hover:text-foreground hover:bg-accent transition-colors",children:[(0,a.jsx)(j.Presentation,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"text-xs",children:"Present"})]}),(0,a.jsx)(hm,{}),!n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(hu,{docId:e.id}),(0,a.jsx)(hh,{docId:e.id,initialStarred:r})]}),(0,a.jsx)(hd,{docId:e.id,docTitle:u||"Untitled",isHome:n,parentId:e.parent_id,onOpenComments:()=>S(!0),onTurnIntoTemplate:()=>T(!0),initialIsDocTemplate:!!e.is_template,onDownloadPdf:()=>(0,A.downloadDocAsPdf)({title:u||"Untitled",html:m}),templateMode:M})]})]}),M&&(0,a.jsxs)("div",{className:"sticky top-12 z-20 flex items-center justify-between gap-3 px-4 py-2 border-b border-[#A6BFD0]/50 bg-[#A6BFD0]/15 dark:bg-[#7AC8F0]/10",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-foreground/80 min-w-0",children:[(0,a.jsx)(_.FileSignature,{className:"h-4 w-4 shrink-0 text-[#337EA9] dark:text-[#7AC8F0]"}),(0,a.jsxs)("span",{className:"truncate",children:[(0,a.jsx)("span",{className:"font-medium text-foreground",children:"Template editing"})," - select text and mark editable fields."]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,a.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[F.length," field",1===F.length?"":"s"]}),(0,a.jsx)("button",{type:"button",onClick:()=>T(!1),className:"text-xs px-3 py-1.5 rounded-full text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",children:"Exit"}),(0,a.jsxs)("button",{type:"button",onClick:eg,disabled:O||0===F.length,className:"inline-flex items-center gap-1.5 text-xs px-4 py-1.5 rounded-full bg-foreground text-background hover:bg-foreground
2/90 disabled:opacity-40 transition-colors",children:[O&&(0,a.jsx)(hl.ButtonSpinner,{}),(0,a.jsx)(hl.ShimmerLabel,{active:O,children:"Save as template"})]})]})]}),V&&(0,a.jsx)("div",{className:"pointer-events-none sticky top-12 z-20 flex h-0 items-start justify-center px-4",children:(0,a.jsxs)("div",{className:"toast-glass-card pointer-events-auto mt-3 flex w-[340px] max-w-[calc(100vw-2rem)] items-start gap-2.5 rounded-[30px] [corner-shape:squircle] squircle-safari-fallback border px-4 py-3 text-left text-popover-foreground shadow-[0_2px_8px_rgba(0,0,0,0.08),0_12px_32px_rgba(0,0,0,0.12)] animate-in fade-in-0 slide-in-from-top-2 duration-200",children:[(0,a.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center squircle avatar-border bg-[#d97757]/15",children:(0,a.jsx)(ug.AgentGlyph,{agent:X,className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("p",{className:"truncate text-[13px] font-semibold",children:[Q," rewrote this page"]}),(0,a.jsx)("p",{className:"mt-0.5 text-[12px] leading-snug text-foreground/80",children:"Keep it, or put back what was here before."}),(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{try{localStorage.setItem(ho,"1")}catch{}Z(!0),G(null)},className:"-ml-2 shrink-0 rounded-full px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:"Always keep"}),(0,a.jsx)("span",{className:"flex-1"}),(0,a.jsx)("button",{type:"button",onClick:()=>{let e=V.previousHtml;G(null),$.current?.setContent(e),g(e),B.current.content_html=""},className:"shrink-0 rounded-full px-2.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:"Undo"}),(0,a.jsx)("button",{type:"button",onClick:()=>G(null),className:"shrink-0 rounded-full bg-[#d97757] px-3 py-1 text-[11px] font-medium text-white transition-colors hover:bg-[#c96745]",children:"Keep"})]})]})]})}),(0,a.jsx)(hp,{docId:e.id,open:C,onOpenChange:S}),(0,a.jsxs)("div",{className:"w-full pt-1 md:pt-12 pb-32 md:px-16 overflow-x-hidden",children:[(0,a.jsx)("div",{className:"px-8 md:pl-16 md:pr-8",children:(0,a.jsx)(hg,{icon:f,onIconChange:el,title:u,onTitleChange:es,titlePlaceholder:n?"Docs":"New page",autoFocus:ep,defaultIcon:n?(0,a.jsx)(li.QuillIcon,{className:"h-16 w-16 text-foreground"}):null,onEnter:()=>$.current?.focus()})}),(0,a.jsx)("div",{ref:H,"data-doc-id":e.id,children:et?(0,a.jsx)(he,{ref:$,docId:e.id,initialHtml:p,onHtmlChange:eh,autoFocus:!e.content_html&&!ep,parentDocId:e.id,onComment:()=>S(!0),templateMode:M,onHistoryChange:E,onHtmlCommit:ei}):(0,a.jsx)(uS,{ref:$,initialContent:p,onHtmlChange:eh,autoFocus:!e.content_html&&!ep,parentDocId:e.id,onComment:()=>S(!0),templateMode:M,onHistoryChange:E,onHtmlCommit:ei})})]}),L&&(0,a.jsx)(ht.SlidePresenter,{slides:L.slides,startIndex:L.startIndex,onClose:()=>R(null)})]})}],22951)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.