@qwanyx/stack 0.2.69 → 0.2.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var Ad=Object.defineProperty;var Td=(r,e,t)=>e in r?Ad(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var St=(r,e,t)=>Td(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react"),ma=require("react-dom");function Nd(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const Ei=Nd(_);class Bd{constructor(e){St(this,"config");St(this,"defaultUploadOptions",{maxSizeMB:10,maxImageDimension:0,imageQuality:.9});if(!e.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=e}async callGraph(e,t={}){const n={coprocessor:"graph",method:e,system_id:this.config.system_id,params:t};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!s.ok){const o=await s.text();throw new Error(`API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("Graph API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(e){return(await this.callGraph("get_children",{parent_id:e})).result||[]}async getNode(e){return(await this.callGraph("get_node",{node_id:e})).result||null}async addNode(e){const t={...e,created:e.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",t);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(e,t){const n={node_id:e,updates:{...t,modified:new Date().toISOString()}},s=await this.callGraph("update_node",n);if(!s.result)throw new Error("Failed to update node");return s.result}async deleteNode(e,t=!1){return(await this.callGraph("delete_node",{node_id:e,cascade:t})).success===!0}async getChildrenWithEdges(e,t="children",n,s){return(await this.callGraph("get_children_with_edges",{node_id:e,display_mode:t,edge_type:n,node_type:s})).result||[]}async addEdge(e,t,n="link",s){return await this.callGraph("add_edge",{source_id:e,target_id:t,edge_type:n,data:s})}async deleteEdge(e,t,n){return await this.callGraph("delete_edge",{source_id:e,target_id:t,edge_type:n})}async getEdges(e,t,n){return(await this.callGraph("get_edges",{source_id:e,edge_type:t,target_id:n})).result||[]}async getAncestors(e){return(await this.callGraph("get_ancestors",{node_id:e})).ancestors||[]}async getTree(e,t=10){return(await this.callGraph("get_tree",{root_id:e,max_depth:t})).tree||[]}async moveNode(e,t){const n=await this.callGraph("move",{node_id:e,new_parent_id:t});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(e,t){return(await this.callGraph("search",{query:e,type:t})).nodes||[]}async getNodesByType(e){return(await this.callGraph("get_nodes_by_type",{type:e})).result||[]}fileToBase64(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const o=s.result.split(",")[1];t(o)},s.onerror=()=>n(new Error("Failed to read file")),s.readAsDataURL(e)})}async resizeImage(e,t,n){return e.type.startsWith("image/")?new Promise(s=>{const i=new Image,o=URL.createObjectURL(e);i.onload=()=>{if(URL.revokeObjectURL(o),i.width<=t&&i.height<=t){s(e);return}let l,a;i.width>i.height?(l=t,a=Math.round(i.height/i.width*t)):(a=t,l=Math.round(i.width/i.height*t));const u=document.createElement("canvas");u.width=l,u.height=a;const c=u.getContext("2d");if(!c){s(e);return}c.drawImage(i,0,0,l,a);const d=e.type==="image/png"?"image/png":"image/jpeg";u.toBlob(f=>{if(f){const p=new File([f],e.name,{type:d});s(p)}else s(e)},d,n)},i.onerror=()=>{URL.revokeObjectURL(o),s(e)},i.src=o}):e}async uploadFile(e,t,n,s={}){const i={...this.defaultUploadOptions,...s};try{let o=n;i.maxImageDimension>0&&n.type.startsWith("image/")&&(o=await this.resizeImage(n,i.maxImageDimension,i.imageQuality));const l=i.maxSizeMB*1024*1024;if(o.size>l)return{success:!1,error:`File too large (${(o.size/1024/1024).toFixed(1)} MB). Max: ${i.maxSizeMB} MB`};const a=await this.fileToBase64(o),u=await this.callGraph("upload_file",{node_id:e,filename:t,content:a});return u.success?{success:!0,path:u.path}:{success:!1,error:u.error||"Upload failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Upload failed"}}}async listFiles(e){var s;return(((s=(await this.callGraph("list_files",{node_id:e})).result)==null?void 0:s.files)||[]).map(i=>({filename:i.name,path:i.path}))}async deleteFile(e,t){return{success:(await this.callGraph("delete_file",{node_id:e,filename:t})).success||!1}}getFileUrl(e,t){return`${this.config.baseUrl}/files/${this.config.system_id}/${e}/${t}`}}const Jr=new TextEncoder,ya="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn=new Uint8Array(256);for(var as=0;as<ya.length;as++)bn[ya.charCodeAt(as)]=as;function Vi(r){let e=Math.ceil(r.length/4)*3;const t=r.length;let n=0;r.length%4===3?e--:r.length%4===2?e-=2:r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);const s=new ArrayBuffer(e),i=new Uint8Array(s);for(let o=0;o<t;o+=4){let l=bn[r.charCodeAt(o)],a=bn[r.charCodeAt(o+1)],u=bn[r.charCodeAt(o+2)],c=bn[r.charCodeAt(o+3)];i[n++]=l<<2|a>>4,i[n++]=(a&15)<<4|u>>2,i[n++]=(u&3)<<6|c&63}return s}function En(r){r=r||"utf8";let e;try{e=new TextDecoder(r)}catch{e=new TextDecoder("windows-1252")}return e}async function ni(r){if("arrayBuffer"in r)return await r.arrayBuffer();const e=new FileReader;return new Promise((t,n)=>{e.onload=function(s){t(s.target.result)},e.onerror=function(s){n(e.error)},e.readAsArrayBuffer(r)})}function xa(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function Fd(r,e,t){let n=r.indexOf("*");n>=0&&(r=r.substr(0,n)),e=e.toUpperCase();let s;if(e==="Q"){t=t.replace(/=\s+([0-9a-fA-F])/g,"=$1").replace(/[_\s]/g," ");let i=Jr.encode(t),o=[];for(let a=0,u=i.length;a<u;a++){let c=i[a];if(a<=u-2&&c===61){let d=xa(i[a+1]),f=xa(i[a+2]);if(d&&f){let p=parseInt(d+f,16);o.push(p),a+=2;continue}}o.push(c)}s=new ArrayBuffer(o.length);let l=new DataView(s);for(let a=0,u=o.length;a<u;a++)l.setUint8(a,o[a])}else e==="B"?s=Vi(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Jr.encode(t);return En(r).decode(s)}function kn(r){let e=!0;for(;;){let t=(r||"").toString().replace(/(=\?([^?]+)\?[Bb]\?([^?]*)\?=)\s*(?==\?([^?]+)\?[Bb]\?[^?]*\?=)/g,(n,s,i,o,l)=>e&&i===l&&o.length%4===0&&!/=$/.test(o)?s+"__\0JOIN\0__":n).replace(/(=\?([^?]+)\?[Qq]\?[^?]*\?=)\s*(?==\?([^?]+)\?[Qq]\?[^?]*\?=)/g,(n,s,i,o)=>e&&i===o?s+"__\0JOIN\0__":n).replace(/(\?=)?__\x00JOIN\x00__(=\?([^?]+)\?[QqBb]\?)?/g,"").replace(/(=\?[^?]+\?[QqBb]\?[^?]*\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]*\?=)/g,"$1").replace(/=\?([\w_\-*]+)\?([QqBb])\?([^?]*)\?=/g,(n,s,i,o)=>Fd(s,i,o));if(e&&t.indexOf("�")>=0)e=!1;else return t}}function Rd(r,e){e=e||"utf-8";let t=[];for(let i=0;i<r.length;i++){let o=r.charAt(i);if(o==="%"&&/^[a-f0-9]{2}/i.test(r.substr(i+1,2))){let l=r.substr(i+1,2);i+=2,t.push(parseInt(l,16))}else if(o.charCodeAt(0)>126){o=Jr.encode(o);for(let l=0;l<o.length;l++)t.push(o[l])}else t.push(o.charCodeAt(0))}const n=new ArrayBuffer(t.length),s=new DataView(n);for(let i=0,o=t.length;i<o;i++)s.setUint8(i,t[i]);return En(e).decode(n)}function Md(r){let e=new Map;Object.keys(r.params).forEach(t=>{let n=t.match(/\*((\d+)\*?)?$/);if(!n)return;let s=t.substr(0,n.index).toLowerCase(),i=Number(n[2])||0,o;e.has(s)?o=e.get(s):(o={charset:!1,values:[]},e.set(s,o));let l=r.params[t];i===0&&n[0].charAt(n[0].length-1)==="*"&&(n=l.match(/^([^']*)'[^']*'(.*)$/))&&(o.charset=n[1]||"utf-8",l=n[2]),o.values.push({nr:i,value:l}),delete r.params[t]}),e.forEach((t,n)=>{r.params[n]=Rd(t.values.sort((s,i)=>s.nr-i.nr).map(s=>s.value).join(""),t.charset)})}class jd{constructor(){this.chunks=[]}update(e){this.chunks.push(e),this.chunks.push(`
2
- `)}finalize(){return ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class Ld{constructor(e){e=e||{},this.decoder=e.decoder||new TextDecoder,this.maxChunkSize=100*1024,this.chunks=[],this.remainder=""}update(e){let t=this.decoder.decode(e);if(/[^a-zA-Z0-9+\/]/.test(t)&&(t=t.replace(/[^a-zA-Z0-9+\/]+/g,"")),this.remainder+=t,this.remainder.length>=this.maxChunkSize){let n=Math.floor(this.remainder.length/4)*4,s;n===this.remainder.length?(s=this.remainder,this.remainder=""):(s=this.remainder.substr(0,n),this.remainder=this.remainder.substr(n)),s.length&&this.chunks.push(Vi(s))}}finalize(){return this.remainder&&!/^=+$/.test(this.remainder)&&this.chunks.push(Vi(this.remainder)),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}const ba=/^=[a-f0-9]{2}$/i,Pd=/(?==[a-f0-9]{2})/i,Od=/=\r?\n/g,Id=/=[a-fA-F0-9]?$/;class zd{constructor(e){e=e||{},this.decoder=e.decoder||new TextDecoder,this.maxChunkSize=100*1024,this.remainder="",this.chunks=[]}decodeQPBytes(e){let t=new ArrayBuffer(e.length),n=new DataView(t);for(let s=0,i=e.length;s<i;s++)n.setUint8(s,parseInt(e[s],16));return t}decodeChunks(e){e=e.replace(Od,"");let t=e.split(Pd),n=[];for(let s of t){if(s.charAt(0)!=="="){n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s);continue}if(s.length===3){ba.test(s)?n.push(s.substr(1)):(n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s));continue}if(s.length>3){const i=s.substr(0,3);ba.test(i)?(n.push(s.substr(1,2)),this.chunks.push(this.decodeQPBytes(n)),n=[],s=s.substr(3),this.chunks.push(s)):(n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s))}}n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[])}update(e){let t=this.decoder.decode(e)+`
3
- `;if(t=this.remainder+t,t.length<this.maxChunkSize){this.remainder=t;return}this.remainder="";let n=t.match(Id);if(n){if(n.index===0){this.remainder=t;return}this.remainder=t.substr(n.index),t=t.substr(0,n.index)}this.decodeChunks(t)}finalize(){return this.remainder.length&&(this.decodeChunks(this.remainder),this.remainder=""),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class _a{constructor(e){if(this.options=e||{},this.postalMime=this.options.postalMime,this.root=!!this.options.parentNode,this.childNodes=[],this.options.parentNode){if(this.parentNode=this.options.parentNode,this.depth=this.parentNode.depth+1,this.depth>this.options.maxNestingDepth)throw new Error(`Maximum MIME nesting depth of ${this.options.maxNestingDepth} levels exceeded`);this.options.parentNode.childNodes.push(this)}else this.depth=0;this.state="header",this.headerLines=[],this.headerSize=0,this.contentType={value:"text/plain",default:!0},this.contentTransferEncoding={value:"8bit"},this.contentDisposition={value:""},this.headers=[],this.contentDecoder=!1}setupContentDecoder(e){/base64/i.test(e)?this.contentDecoder=new Ld:/quoted-printable/i.test(e)?this.contentDecoder=new zd({decoder:En(this.contentType.parsed.params.charset)}):this.contentDecoder=new jd}async finalize(){if(this.state==="finished")return;this.state==="header"&&this.processHeaders();let e=this.postalMime.boundaries;for(let t=e.length-1;t>=0;t--)if(e[t].node===this){e.splice(t,1);break}await this.finalizeChildNodes(),this.content=this.contentDecoder?await this.contentDecoder.finalize():null,this.state="finished"}async finalizeChildNodes(){for(let e of this.childNodes)await e.finalize()}parseStructuredHeader(e){let t={value:!1,params:{}},n=!1,s="",i="value",o=!1,l=!1,a;for(let u=0,c=e.length;u<c;u++)switch(a=e.charAt(u),i){case"key":if(a==="="){n=s.trim().toLowerCase(),i="value",s="";break}s+=a;break;case"value":if(l)s+=a;else if(a==="\\"){l=!0;continue}else o&&a===o?o=!1:!o&&a==='"'?o=a:!o&&a===";"?(n===!1?t.value=s.trim():t.params[n]=s.trim(),i="key",s=""):s+=a;l=!1;break}return s=s.trim(),i==="value"?n===!1?t.value=s:t.params[n]=s:s&&(t.params[s.toLowerCase()]=""),t.value&&(t.value=t.value.toLowerCase()),Md(t),t}decodeFlowedText(e,t){return e.split(/\r?\n/).reduce((n,s)=>/ $/.test(n)&&!/(^|\n)-- $/.test(n)?t?n.slice(0,-1)+s:n+s:n+`
4
- `+s).replace(/^ /gm,"")}getTextContent(){if(!this.content)return"";let e=En(this.contentType.parsed.params.charset).decode(this.content);return/^flowed$/i.test(this.contentType.parsed.params.format)&&(e=this.decodeFlowedText(e,/^yes$/i.test(this.contentType.parsed.params.delsp))),e}processHeaders(){for(let e=this.headerLines.length-1;e>=0;e--){let t=this.headerLines[e];if(e&&/^\s/.test(t))this.headerLines[e-1]+=`
5
- `+t,this.headerLines.splice(e,1);else{t=t.replace(/\s+/g," ");let n=t.indexOf(":"),s=n<0?t.trim():t.substr(0,n).trim(),i=n<0?"":t.substr(n+1).trim();switch(this.headers.push({key:s.toLowerCase(),originalKey:s,value:i}),s.toLowerCase()){case"content-type":this.contentType.default&&(this.contentType={value:i,parsed:{}});break;case"content-transfer-encoding":this.contentTransferEncoding={value:i,parsed:{}};break;case"content-disposition":this.contentDisposition={value:i,parsed:{}};break;case"content-id":this.contentId=i;break;case"content-description":this.contentDescription=i;break}}}this.contentType.parsed=this.parseStructuredHeader(this.contentType.value),this.contentType.multipart=/^multipart\//i.test(this.contentType.parsed.value)?this.contentType.parsed.value.substr(this.contentType.parsed.value.indexOf("/")+1):!1,this.contentType.multipart&&this.contentType.parsed.params.boundary&&this.postalMime.boundaries.push({value:Jr.encode(this.contentType.parsed.params.boundary),node:this}),this.contentDisposition.parsed=this.parseStructuredHeader(this.contentDisposition.value),this.contentTransferEncoding.encoding=this.contentTransferEncoding.value.toLowerCase().split(/[^\w-]/).shift(),this.setupContentDecoder(this.contentTransferEncoding.encoding)}feed(e){switch(this.state){case"header":if(!e.length)return this.state="body",this.processHeaders();if(this.headerSize+=e.length,this.headerSize>this.options.maxHeadersSize)throw new Error(`Maximum header size of ${this.options.maxHeadersSize} bytes exceeded`);this.headerLines.push(En().decode(e));break;case"body":this.contentDecoder.update(e)}}}const va={"&AElig":"Æ","&AElig;":"Æ","&AMP":"&","&AMP;":"&","&Aacute":"Á","&Aacute;":"Á","&Abreve;":"Ă","&Acirc":"Â","&Acirc;":"Â","&Acy;":"А","&Afr;":"𝔄","&Agrave":"À","&Agrave;":"À","&Alpha;":"Α","&Amacr;":"Ā","&And;":"⩓","&Aogon;":"Ą","&Aopf;":"𝔸","&ApplyFunction;":"⁡","&Aring":"Å","&Aring;":"Å","&Ascr;":"𝒜","&Assign;":"≔","&Atilde":"Ã","&Atilde;":"Ã","&Auml":"Ä","&Auml;":"Ä","&Backslash;":"∖","&Barv;":"⫧","&Barwed;":"⌆","&Bcy;":"Б","&Because;":"∵","&Bernoullis;":"ℬ","&Beta;":"Β","&Bfr;":"𝔅","&Bopf;":"𝔹","&Breve;":"˘","&Bscr;":"ℬ","&Bumpeq;":"≎","&CHcy;":"Ч","&COPY":"©","&COPY;":"©","&Cacute;":"Ć","&Cap;":"⋒","&CapitalDifferentialD;":"ⅅ","&Cayleys;":"ℭ","&Ccaron;":"Č","&Ccedil":"Ç","&Ccedil;":"Ç","&Ccirc;":"Ĉ","&Cconint;":"∰","&Cdot;":"Ċ","&Cedilla;":"¸","&CenterDot;":"·","&Cfr;":"ℭ","&Chi;":"Χ","&CircleDot;":"⊙","&CircleMinus;":"⊖","&CirclePlus;":"⊕","&CircleTimes;":"⊗","&ClockwiseContourIntegral;":"∲","&CloseCurlyDoubleQuote;":"”","&CloseCurlyQuote;":"’","&Colon;":"∷","&Colone;":"⩴","&Congruent;":"≡","&Conint;":"∯","&ContourIntegral;":"∮","&Copf;":"ℂ","&Coproduct;":"∐","&CounterClockwiseContourIntegral;":"∳","&Cross;":"⨯","&Cscr;":"𝒞","&Cup;":"⋓","&CupCap;":"≍","&DD;":"ⅅ","&DDotrahd;":"⤑","&DJcy;":"Ђ","&DScy;":"Ѕ","&DZcy;":"Џ","&Dagger;":"‡","&Darr;":"↡","&Dashv;":"⫤","&Dcaron;":"Ď","&Dcy;":"Д","&Del;":"∇","&Delta;":"Δ","&Dfr;":"𝔇","&DiacriticalAcute;":"´","&DiacriticalDot;":"˙","&DiacriticalDoubleAcute;":"˝","&DiacriticalGrave;":"`","&DiacriticalTilde;":"˜","&Diamond;":"⋄","&DifferentialD;":"ⅆ","&Dopf;":"𝔻","&Dot;":"¨","&DotDot;":"⃜","&DotEqual;":"≐","&DoubleContourIntegral;":"∯","&DoubleDot;":"¨","&DoubleDownArrow;":"⇓","&DoubleLeftArrow;":"⇐","&DoubleLeftRightArrow;":"⇔","&DoubleLeftTee;":"⫤","&DoubleLongLeftArrow;":"⟸","&DoubleLongLeftRightArrow;":"⟺","&DoubleLongRightArrow;":"⟹","&DoubleRightArrow;":"⇒","&DoubleRightTee;":"⊨","&DoubleUpArrow;":"⇑","&DoubleUpDownArrow;":"⇕","&DoubleVerticalBar;":"∥","&DownArrow;":"↓","&DownArrowBar;":"⤓","&DownArrowUpArrow;":"⇵","&DownBreve;":"̑","&DownLeftRightVector;":"⥐","&DownLeftTeeVector;":"⥞","&DownLeftVector;":"↽","&DownLeftVectorBar;":"⥖","&DownRightTeeVector;":"⥟","&DownRightVector;":"⇁","&DownRightVectorBar;":"⥗","&DownTee;":"⊤","&DownTeeArrow;":"↧","&Downarrow;":"⇓","&Dscr;":"𝒟","&Dstrok;":"Đ","&ENG;":"Ŋ","&ETH":"Ð","&ETH;":"Ð","&Eacute":"É","&Eacute;":"É","&Ecaron;":"Ě","&Ecirc":"Ê","&Ecirc;":"Ê","&Ecy;":"Э","&Edot;":"Ė","&Efr;":"𝔈","&Egrave":"È","&Egrave;":"È","&Element;":"∈","&Emacr;":"Ē","&EmptySmallSquare;":"◻","&EmptyVerySmallSquare;":"▫","&Eogon;":"Ę","&Eopf;":"𝔼","&Epsilon;":"Ε","&Equal;":"⩵","&EqualTilde;":"≂","&Equilibrium;":"⇌","&Escr;":"ℰ","&Esim;":"⩳","&Eta;":"Η","&Euml":"Ë","&Euml;":"Ë","&Exists;":"∃","&ExponentialE;":"ⅇ","&Fcy;":"Ф","&Ffr;":"𝔉","&FilledSmallSquare;":"◼","&FilledVerySmallSquare;":"▪","&Fopf;":"𝔽","&ForAll;":"∀","&Fouriertrf;":"ℱ","&Fscr;":"ℱ","&GJcy;":"Ѓ","&GT":">","&GT;":">","&Gamma;":"Γ","&Gammad;":"Ϝ","&Gbreve;":"Ğ","&Gcedil;":"Ģ","&Gcirc;":"Ĝ","&Gcy;":"Г","&Gdot;":"Ġ","&Gfr;":"𝔊","&Gg;":"⋙","&Gopf;":"𝔾","&GreaterEqual;":"≥","&GreaterEqualLess;":"⋛","&GreaterFullEqual;":"≧","&GreaterGreater;":"⪢","&GreaterLess;":"≷","&GreaterSlantEqual;":"⩾","&GreaterTilde;":"≳","&Gscr;":"𝒢","&Gt;":"≫","&HARDcy;":"Ъ","&Hacek;":"ˇ","&Hat;":"^","&Hcirc;":"Ĥ","&Hfr;":"ℌ","&HilbertSpace;":"ℋ","&Hopf;":"ℍ","&HorizontalLine;":"─","&Hscr;":"ℋ","&Hstrok;":"Ħ","&HumpDownHump;":"≎","&HumpEqual;":"≏","&IEcy;":"Е","&IJlig;":"IJ","&IOcy;":"Ё","&Iacute":"Í","&Iacute;":"Í","&Icirc":"Î","&Icirc;":"Î","&Icy;":"И","&Idot;":"İ","&Ifr;":"ℑ","&Igrave":"Ì","&Igrave;":"Ì","&Im;":"ℑ","&Imacr;":"Ī","&ImaginaryI;":"ⅈ","&Implies;":"⇒","&Int;":"∬","&Integral;":"∫","&Intersection;":"⋂","&InvisibleComma;":"⁣","&InvisibleTimes;":"⁢","&Iogon;":"Į","&Iopf;":"𝕀","&Iota;":"Ι","&Iscr;":"ℐ","&Itilde;":"Ĩ","&Iukcy;":"І","&Iuml":"Ï","&Iuml;":"Ï","&Jcirc;":"Ĵ","&Jcy;":"Й","&Jfr;":"𝔍","&Jopf;":"𝕁","&Jscr;":"𝒥","&Jsercy;":"Ј","&Jukcy;":"Є","&KHcy;":"Х","&KJcy;":"Ќ","&Kappa;":"Κ","&Kcedil;":"Ķ","&Kcy;":"К","&Kfr;":"𝔎","&Kopf;":"𝕂","&Kscr;":"𝒦","&LJcy;":"Љ","&LT":"<","&LT;":"<","&Lacute;":"Ĺ","&Lambda;":"Λ","&Lang;":"⟪","&Laplacetrf;":"ℒ","&Larr;":"↞","&Lcaron;":"Ľ","&Lcedil;":"Ļ","&Lcy;":"Л","&LeftAngleBracket;":"⟨","&LeftArrow;":"←","&LeftArrowBar;":"⇤","&LeftArrowRightArrow;":"⇆","&LeftCeiling;":"⌈","&LeftDoubleBracket;":"⟦","&LeftDownTeeVector;":"⥡","&LeftDownVector;":"⇃","&LeftDownVectorBar;":"⥙","&LeftFloor;":"⌊","&LeftRightArrow;":"↔","&LeftRightVector;":"⥎","&LeftTee;":"⊣","&LeftTeeArrow;":"↤","&LeftTeeVector;":"⥚","&LeftTriangle;":"⊲","&LeftTriangleBar;":"⧏","&LeftTriangleEqual;":"⊴","&LeftUpDownVector;":"⥑","&LeftUpTeeVector;":"⥠","&LeftUpVector;":"↿","&LeftUpVectorBar;":"⥘","&LeftVector;":"↼","&LeftVectorBar;":"⥒","&Leftarrow;":"⇐","&Leftrightarrow;":"⇔","&LessEqualGreater;":"⋚","&LessFullEqual;":"≦","&LessGreater;":"≶","&LessLess;":"⪡","&LessSlantEqual;":"⩽","&LessTilde;":"≲","&Lfr;":"𝔏","&Ll;":"⋘","&Lleftarrow;":"⇚","&Lmidot;":"Ŀ","&LongLeftArrow;":"⟵","&LongLeftRightArrow;":"⟷","&LongRightArrow;":"⟶","&Longleftarrow;":"⟸","&Longleftrightarrow;":"⟺","&Longrightarrow;":"⟹","&Lopf;":"𝕃","&LowerLeftArrow;":"↙","&LowerRightArrow;":"↘","&Lscr;":"ℒ","&Lsh;":"↰","&Lstrok;":"Ł","&Lt;":"≪","&Map;":"⤅","&Mcy;":"М","&MediumSpace;":" ","&Mellintrf;":"ℳ","&Mfr;":"𝔐","&MinusPlus;":"∓","&Mopf;":"𝕄","&Mscr;":"ℳ","&Mu;":"Μ","&NJcy;":"Њ","&Nacute;":"Ń","&Ncaron;":"Ň","&Ncedil;":"Ņ","&Ncy;":"Н","&NegativeMediumSpace;":"​","&NegativeThickSpace;":"​","&NegativeThinSpace;":"​","&NegativeVeryThinSpace;":"​","&NestedGreaterGreater;":"≫","&NestedLessLess;":"≪","&NewLine;":`
6
- `,"&Nfr;":"𝔑","&NoBreak;":"⁠","&NonBreakingSpace;":" ","&Nopf;":"ℕ","&Not;":"⫬","&NotCongruent;":"≢","&NotCupCap;":"≭","&NotDoubleVerticalBar;":"∦","&NotElement;":"∉","&NotEqual;":"≠","&NotEqualTilde;":"≂̸","&NotExists;":"∄","&NotGreater;":"≯","&NotGreaterEqual;":"≱","&NotGreaterFullEqual;":"≧̸","&NotGreaterGreater;":"≫̸","&NotGreaterLess;":"≹","&NotGreaterSlantEqual;":"⩾̸","&NotGreaterTilde;":"≵","&NotHumpDownHump;":"≎̸","&NotHumpEqual;":"≏̸","&NotLeftTriangle;":"⋪","&NotLeftTriangleBar;":"⧏̸","&NotLeftTriangleEqual;":"⋬","&NotLess;":"≮","&NotLessEqual;":"≰","&NotLessGreater;":"≸","&NotLessLess;":"≪̸","&NotLessSlantEqual;":"⩽̸","&NotLessTilde;":"≴","&NotNestedGreaterGreater;":"⪢̸","&NotNestedLessLess;":"⪡̸","&NotPrecedes;":"⊀","&NotPrecedesEqual;":"⪯̸","&NotPrecedesSlantEqual;":"⋠","&NotReverseElement;":"∌","&NotRightTriangle;":"⋫","&NotRightTriangleBar;":"⧐̸","&NotRightTriangleEqual;":"⋭","&NotSquareSubset;":"⊏̸","&NotSquareSubsetEqual;":"⋢","&NotSquareSuperset;":"⊐̸","&NotSquareSupersetEqual;":"⋣","&NotSubset;":"⊂⃒","&NotSubsetEqual;":"⊈","&NotSucceeds;":"⊁","&NotSucceedsEqual;":"⪰̸","&NotSucceedsSlantEqual;":"⋡","&NotSucceedsTilde;":"≿̸","&NotSuperset;":"⊃⃒","&NotSupersetEqual;":"⊉","&NotTilde;":"≁","&NotTildeEqual;":"≄","&NotTildeFullEqual;":"≇","&NotTildeTilde;":"≉","&NotVerticalBar;":"∤","&Nscr;":"𝒩","&Ntilde":"Ñ","&Ntilde;":"Ñ","&Nu;":"Ν","&OElig;":"Œ","&Oacute":"Ó","&Oacute;":"Ó","&Ocirc":"Ô","&Ocirc;":"Ô","&Ocy;":"О","&Odblac;":"Ő","&Ofr;":"𝔒","&Ograve":"Ò","&Ograve;":"Ò","&Omacr;":"Ō","&Omega;":"Ω","&Omicron;":"Ο","&Oopf;":"𝕆","&OpenCurlyDoubleQuote;":"“","&OpenCurlyQuote;":"‘","&Or;":"⩔","&Oscr;":"𝒪","&Oslash":"Ø","&Oslash;":"Ø","&Otilde":"Õ","&Otilde;":"Õ","&Otimes;":"⨷","&Ouml":"Ö","&Ouml;":"Ö","&OverBar;":"‾","&OverBrace;":"⏞","&OverBracket;":"⎴","&OverParenthesis;":"⏜","&PartialD;":"∂","&Pcy;":"П","&Pfr;":"𝔓","&Phi;":"Φ","&Pi;":"Π","&PlusMinus;":"±","&Poincareplane;":"ℌ","&Popf;":"ℙ","&Pr;":"⪻","&Precedes;":"≺","&PrecedesEqual;":"⪯","&PrecedesSlantEqual;":"≼","&PrecedesTilde;":"≾","&Prime;":"″","&Product;":"∏","&Proportion;":"∷","&Proportional;":"∝","&Pscr;":"𝒫","&Psi;":"Ψ","&QUOT":'"',"&QUOT;":'"',"&Qfr;":"𝔔","&Qopf;":"ℚ","&Qscr;":"𝒬","&RBarr;":"⤐","&REG":"®","&REG;":"®","&Racute;":"Ŕ","&Rang;":"⟫","&Rarr;":"↠","&Rarrtl;":"⤖","&Rcaron;":"Ř","&Rcedil;":"Ŗ","&Rcy;":"Р","&Re;":"ℜ","&ReverseElement;":"∋","&ReverseEquilibrium;":"⇋","&ReverseUpEquilibrium;":"⥯","&Rfr;":"ℜ","&Rho;":"Ρ","&RightAngleBracket;":"⟩","&RightArrow;":"→","&RightArrowBar;":"⇥","&RightArrowLeftArrow;":"⇄","&RightCeiling;":"⌉","&RightDoubleBracket;":"⟧","&RightDownTeeVector;":"⥝","&RightDownVector;":"⇂","&RightDownVectorBar;":"⥕","&RightFloor;":"⌋","&RightTee;":"⊢","&RightTeeArrow;":"↦","&RightTeeVector;":"⥛","&RightTriangle;":"⊳","&RightTriangleBar;":"⧐","&RightTriangleEqual;":"⊵","&RightUpDownVector;":"⥏","&RightUpTeeVector;":"⥜","&RightUpVector;":"↾","&RightUpVectorBar;":"⥔","&RightVector;":"⇀","&RightVectorBar;":"⥓","&Rightarrow;":"⇒","&Ropf;":"ℝ","&RoundImplies;":"⥰","&Rrightarrow;":"⇛","&Rscr;":"ℛ","&Rsh;":"↱","&RuleDelayed;":"⧴","&SHCHcy;":"Щ","&SHcy;":"Ш","&SOFTcy;":"Ь","&Sacute;":"Ś","&Sc;":"⪼","&Scaron;":"Š","&Scedil;":"Ş","&Scirc;":"Ŝ","&Scy;":"С","&Sfr;":"𝔖","&ShortDownArrow;":"↓","&ShortLeftArrow;":"←","&ShortRightArrow;":"→","&ShortUpArrow;":"↑","&Sigma;":"Σ","&SmallCircle;":"∘","&Sopf;":"𝕊","&Sqrt;":"√","&Square;":"□","&SquareIntersection;":"⊓","&SquareSubset;":"⊏","&SquareSubsetEqual;":"⊑","&SquareSuperset;":"⊐","&SquareSupersetEqual;":"⊒","&SquareUnion;":"⊔","&Sscr;":"𝒮","&Star;":"⋆","&Sub;":"⋐","&Subset;":"⋐","&SubsetEqual;":"⊆","&Succeeds;":"≻","&SucceedsEqual;":"⪰","&SucceedsSlantEqual;":"≽","&SucceedsTilde;":"≿","&SuchThat;":"∋","&Sum;":"∑","&Sup;":"⋑","&Superset;":"⊃","&SupersetEqual;":"⊇","&Supset;":"⋑","&THORN":"Þ","&THORN;":"Þ","&TRADE;":"™","&TSHcy;":"Ћ","&TScy;":"Ц","&Tab;":" ","&Tau;":"Τ","&Tcaron;":"Ť","&Tcedil;":"Ţ","&Tcy;":"Т","&Tfr;":"𝔗","&Therefore;":"∴","&Theta;":"Θ","&ThickSpace;":"  ","&ThinSpace;":" ","&Tilde;":"∼","&TildeEqual;":"≃","&TildeFullEqual;":"≅","&TildeTilde;":"≈","&Topf;":"𝕋","&TripleDot;":"⃛","&Tscr;":"𝒯","&Tstrok;":"Ŧ","&Uacute":"Ú","&Uacute;":"Ú","&Uarr;":"↟","&Uarrocir;":"⥉","&Ubrcy;":"Ў","&Ubreve;":"Ŭ","&Ucirc":"Û","&Ucirc;":"Û","&Ucy;":"У","&Udblac;":"Ű","&Ufr;":"𝔘","&Ugrave":"Ù","&Ugrave;":"Ù","&Umacr;":"Ū","&UnderBar;":"_","&UnderBrace;":"⏟","&UnderBracket;":"⎵","&UnderParenthesis;":"⏝","&Union;":"⋃","&UnionPlus;":"⊎","&Uogon;":"Ų","&Uopf;":"𝕌","&UpArrow;":"↑","&UpArrowBar;":"⤒","&UpArrowDownArrow;":"⇅","&UpDownArrow;":"↕","&UpEquilibrium;":"⥮","&UpTee;":"⊥","&UpTeeArrow;":"↥","&Uparrow;":"⇑","&Updownarrow;":"⇕","&UpperLeftArrow;":"↖","&UpperRightArrow;":"↗","&Upsi;":"ϒ","&Upsilon;":"Υ","&Uring;":"Ů","&Uscr;":"𝒰","&Utilde;":"Ũ","&Uuml":"Ü","&Uuml;":"Ü","&VDash;":"⊫","&Vbar;":"⫫","&Vcy;":"В","&Vdash;":"⊩","&Vdashl;":"⫦","&Vee;":"⋁","&Verbar;":"‖","&Vert;":"‖","&VerticalBar;":"∣","&VerticalLine;":"|","&VerticalSeparator;":"❘","&VerticalTilde;":"≀","&VeryThinSpace;":" ","&Vfr;":"𝔙","&Vopf;":"𝕍","&Vscr;":"𝒱","&Vvdash;":"⊪","&Wcirc;":"Ŵ","&Wedge;":"⋀","&Wfr;":"𝔚","&Wopf;":"𝕎","&Wscr;":"𝒲","&Xfr;":"𝔛","&Xi;":"Ξ","&Xopf;":"𝕏","&Xscr;":"𝒳","&YAcy;":"Я","&YIcy;":"Ї","&YUcy;":"Ю","&Yacute":"Ý","&Yacute;":"Ý","&Ycirc;":"Ŷ","&Ycy;":"Ы","&Yfr;":"𝔜","&Yopf;":"𝕐","&Yscr;":"𝒴","&Yuml;":"Ÿ","&ZHcy;":"Ж","&Zacute;":"Ź","&Zcaron;":"Ž","&Zcy;":"З","&Zdot;":"Ż","&ZeroWidthSpace;":"​","&Zeta;":"Ζ","&Zfr;":"ℨ","&Zopf;":"ℤ","&Zscr;":"𝒵","&aacute":"á","&aacute;":"á","&abreve;":"ă","&ac;":"∾","&acE;":"∾̳","&acd;":"∿","&acirc":"â","&acirc;":"â","&acute":"´","&acute;":"´","&acy;":"а","&aelig":"æ","&aelig;":"æ","&af;":"⁡","&afr;":"𝔞","&agrave":"à","&agrave;":"à","&alefsym;":"ℵ","&aleph;":"ℵ","&alpha;":"α","&amacr;":"ā","&amalg;":"⨿","&amp":"&","&amp;":"&","&and;":"∧","&andand;":"⩕","&andd;":"⩜","&andslope;":"⩘","&andv;":"⩚","&ang;":"∠","&ange;":"⦤","&angle;":"∠","&angmsd;":"∡","&angmsdaa;":"⦨","&angmsdab;":"⦩","&angmsdac;":"⦪","&angmsdad;":"⦫","&angmsdae;":"⦬","&angmsdaf;":"⦭","&angmsdag;":"⦮","&angmsdah;":"⦯","&angrt;":"∟","&angrtvb;":"⊾","&angrtvbd;":"⦝","&angsph;":"∢","&angst;":"Å","&angzarr;":"⍼","&aogon;":"ą","&aopf;":"𝕒","&ap;":"≈","&apE;":"⩰","&apacir;":"⩯","&ape;":"≊","&apid;":"≋","&apos;":"'","&approx;":"≈","&approxeq;":"≊","&aring":"å","&aring;":"å","&ascr;":"𝒶","&ast;":"*","&asymp;":"≈","&asympeq;":"≍","&atilde":"ã","&atilde;":"ã","&auml":"ä","&auml;":"ä","&awconint;":"∳","&awint;":"⨑","&bNot;":"⫭","&backcong;":"≌","&backepsilon;":"϶","&backprime;":"‵","&backsim;":"∽","&backsimeq;":"⋍","&barvee;":"⊽","&barwed;":"⌅","&barwedge;":"⌅","&bbrk;":"⎵","&bbrktbrk;":"⎶","&bcong;":"≌","&bcy;":"б","&bdquo;":"„","&becaus;":"∵","&because;":"∵","&bemptyv;":"⦰","&bepsi;":"϶","&bernou;":"ℬ","&beta;":"β","&beth;":"ℶ","&between;":"≬","&bfr;":"𝔟","&bigcap;":"⋂","&bigcirc;":"◯","&bigcup;":"⋃","&bigodot;":"⨀","&bigoplus;":"⨁","&bigotimes;":"⨂","&bigsqcup;":"⨆","&bigstar;":"★","&bigtriangledown;":"▽","&bigtriangleup;":"△","&biguplus;":"⨄","&bigvee;":"⋁","&bigwedge;":"⋀","&bkarow;":"⤍","&blacklozenge;":"⧫","&blacksquare;":"▪","&blacktriangle;":"▴","&blacktriangledown;":"▾","&blacktriangleleft;":"◂","&blacktriangleright;":"▸","&blank;":"␣","&blk12;":"▒","&blk14;":"░","&blk34;":"▓","&block;":"█","&bne;":"=⃥","&bnequiv;":"≡⃥","&bnot;":"⌐","&bopf;":"𝕓","&bot;":"⊥","&bottom;":"⊥","&bowtie;":"⋈","&boxDL;":"╗","&boxDR;":"╔","&boxDl;":"╖","&boxDr;":"╓","&boxH;":"═","&boxHD;":"╦","&boxHU;":"╩","&boxHd;":"╤","&boxHu;":"╧","&boxUL;":"╝","&boxUR;":"╚","&boxUl;":"╜","&boxUr;":"╙","&boxV;":"║","&boxVH;":"╬","&boxVL;":"╣","&boxVR;":"╠","&boxVh;":"╫","&boxVl;":"╢","&boxVr;":"╟","&boxbox;":"⧉","&boxdL;":"╕","&boxdR;":"╒","&boxdl;":"┐","&boxdr;":"┌","&boxh;":"─","&boxhD;":"╥","&boxhU;":"╨","&boxhd;":"┬","&boxhu;":"┴","&boxminus;":"⊟","&boxplus;":"⊞","&boxtimes;":"⊠","&boxuL;":"╛","&boxuR;":"╘","&boxul;":"┘","&boxur;":"└","&boxv;":"│","&boxvH;":"╪","&boxvL;":"╡","&boxvR;":"╞","&boxvh;":"┼","&boxvl;":"┤","&boxvr;":"├","&bprime;":"‵","&breve;":"˘","&brvbar":"¦","&brvbar;":"¦","&bscr;":"𝒷","&bsemi;":"⁏","&bsim;":"∽","&bsime;":"⋍","&bsol;":"\\","&bsolb;":"⧅","&bsolhsub;":"⟈","&bull;":"•","&bullet;":"•","&bump;":"≎","&bumpE;":"⪮","&bumpe;":"≏","&bumpeq;":"≏","&cacute;":"ć","&cap;":"∩","&capand;":"⩄","&capbrcup;":"⩉","&capcap;":"⩋","&capcup;":"⩇","&capdot;":"⩀","&caps;":"∩︀","&caret;":"⁁","&caron;":"ˇ","&ccaps;":"⩍","&ccaron;":"č","&ccedil":"ç","&ccedil;":"ç","&ccirc;":"ĉ","&ccups;":"⩌","&ccupssm;":"⩐","&cdot;":"ċ","&cedil":"¸","&cedil;":"¸","&cemptyv;":"⦲","&cent":"¢","&cent;":"¢","&centerdot;":"·","&cfr;":"𝔠","&chcy;":"ч","&check;":"✓","&checkmark;":"✓","&chi;":"χ","&cir;":"○","&cirE;":"⧃","&circ;":"ˆ","&circeq;":"≗","&circlearrowleft;":"↺","&circlearrowright;":"↻","&circledR;":"®","&circledS;":"Ⓢ","&circledast;":"⊛","&circledcirc;":"⊚","&circleddash;":"⊝","&cire;":"≗","&cirfnint;":"⨐","&cirmid;":"⫯","&cirscir;":"⧂","&clubs;":"♣","&clubsuit;":"♣","&colon;":":","&colone;":"≔","&coloneq;":"≔","&comma;":",","&commat;":"@","&comp;":"∁","&compfn;":"∘","&complement;":"∁","&complexes;":"ℂ","&cong;":"≅","&congdot;":"⩭","&conint;":"∮","&copf;":"𝕔","&coprod;":"∐","&copy":"©","&copy;":"©","&copysr;":"℗","&crarr;":"↵","&cross;":"✗","&cscr;":"𝒸","&csub;":"⫏","&csube;":"⫑","&csup;":"⫐","&csupe;":"⫒","&ctdot;":"⋯","&cudarrl;":"⤸","&cudarrr;":"⤵","&cuepr;":"⋞","&cuesc;":"⋟","&cularr;":"↶","&cularrp;":"⤽","&cup;":"∪","&cupbrcap;":"⩈","&cupcap;":"⩆","&cupcup;":"⩊","&cupdot;":"⊍","&cupor;":"⩅","&cups;":"∪︀","&curarr;":"↷","&curarrm;":"⤼","&curlyeqprec;":"⋞","&curlyeqsucc;":"⋟","&curlyvee;":"⋎","&curlywedge;":"⋏","&curren":"¤","&curren;":"¤","&curvearrowleft;":"↶","&curvearrowright;":"↷","&cuvee;":"⋎","&cuwed;":"⋏","&cwconint;":"∲","&cwint;":"∱","&cylcty;":"⌭","&dArr;":"⇓","&dHar;":"⥥","&dagger;":"†","&daleth;":"ℸ","&darr;":"↓","&dash;":"‐","&dashv;":"⊣","&dbkarow;":"⤏","&dblac;":"˝","&dcaron;":"ď","&dcy;":"д","&dd;":"ⅆ","&ddagger;":"‡","&ddarr;":"⇊","&ddotseq;":"⩷","&deg":"°","&deg;":"°","&delta;":"δ","&demptyv;":"⦱","&dfisht;":"⥿","&dfr;":"𝔡","&dharl;":"⇃","&dharr;":"⇂","&diam;":"⋄","&diamond;":"⋄","&diamondsuit;":"♦","&diams;":"♦","&die;":"¨","&digamma;":"ϝ","&disin;":"⋲","&div;":"÷","&divide":"÷","&divide;":"÷","&divideontimes;":"⋇","&divonx;":"⋇","&djcy;":"ђ","&dlcorn;":"⌞","&dlcrop;":"⌍","&dollar;":"$","&dopf;":"𝕕","&dot;":"˙","&doteq;":"≐","&doteqdot;":"≑","&dotminus;":"∸","&dotplus;":"∔","&dotsquare;":"⊡","&doublebarwedge;":"⌆","&downarrow;":"↓","&downdownarrows;":"⇊","&downharpoonleft;":"⇃","&downharpoonright;":"⇂","&drbkarow;":"⤐","&drcorn;":"⌟","&drcrop;":"⌌","&dscr;":"𝒹","&dscy;":"ѕ","&dsol;":"⧶","&dstrok;":"đ","&dtdot;":"⋱","&dtri;":"▿","&dtrif;":"▾","&duarr;":"⇵","&duhar;":"⥯","&dwangle;":"⦦","&dzcy;":"џ","&dzigrarr;":"⟿","&eDDot;":"⩷","&eDot;":"≑","&eacute":"é","&eacute;":"é","&easter;":"⩮","&ecaron;":"ě","&ecir;":"≖","&ecirc":"ê","&ecirc;":"ê","&ecolon;":"≕","&ecy;":"э","&edot;":"ė","&ee;":"ⅇ","&efDot;":"≒","&efr;":"𝔢","&eg;":"⪚","&egrave":"è","&egrave;":"è","&egs;":"⪖","&egsdot;":"⪘","&el;":"⪙","&elinters;":"⏧","&ell;":"ℓ","&els;":"⪕","&elsdot;":"⪗","&emacr;":"ē","&empty;":"∅","&emptyset;":"∅","&emptyv;":"∅","&emsp13;":" ","&emsp14;":" ","&emsp;":" ","&eng;":"ŋ","&ensp;":" ","&eogon;":"ę","&eopf;":"𝕖","&epar;":"⋕","&eparsl;":"⧣","&eplus;":"⩱","&epsi;":"ε","&epsilon;":"ε","&epsiv;":"ϵ","&eqcirc;":"≖","&eqcolon;":"≕","&eqsim;":"≂","&eqslantgtr;":"⪖","&eqslantless;":"⪕","&equals;":"=","&equest;":"≟","&equiv;":"≡","&equivDD;":"⩸","&eqvparsl;":"⧥","&erDot;":"≓","&erarr;":"⥱","&escr;":"ℯ","&esdot;":"≐","&esim;":"≂","&eta;":"η","&eth":"ð","&eth;":"ð","&euml":"ë","&euml;":"ë","&euro;":"€","&excl;":"!","&exist;":"∃","&expectation;":"ℰ","&exponentiale;":"ⅇ","&fallingdotseq;":"≒","&fcy;":"ф","&female;":"♀","&ffilig;":"ffi","&fflig;":"ff","&ffllig;":"ffl","&ffr;":"𝔣","&filig;":"fi","&fjlig;":"fj","&flat;":"♭","&fllig;":"fl","&fltns;":"▱","&fnof;":"ƒ","&fopf;":"𝕗","&forall;":"∀","&fork;":"⋔","&forkv;":"⫙","&fpartint;":"⨍","&frac12":"½","&frac12;":"½","&frac13;":"⅓","&frac14":"¼","&frac14;":"¼","&frac15;":"⅕","&frac16;":"⅙","&frac18;":"⅛","&frac23;":"⅔","&frac25;":"⅖","&frac34":"¾","&frac34;":"¾","&frac35;":"⅗","&frac38;":"⅜","&frac45;":"⅘","&frac56;":"⅚","&frac58;":"⅝","&frac78;":"⅞","&frasl;":"⁄","&frown;":"⌢","&fscr;":"𝒻","&gE;":"≧","&gEl;":"⪌","&gacute;":"ǵ","&gamma;":"γ","&gammad;":"ϝ","&gap;":"⪆","&gbreve;":"ğ","&gcirc;":"ĝ","&gcy;":"г","&gdot;":"ġ","&ge;":"≥","&gel;":"⋛","&geq;":"≥","&geqq;":"≧","&geqslant;":"⩾","&ges;":"⩾","&gescc;":"⪩","&gesdot;":"⪀","&gesdoto;":"⪂","&gesdotol;":"⪄","&gesl;":"⋛︀","&gesles;":"⪔","&gfr;":"𝔤","&gg;":"≫","&ggg;":"⋙","&gimel;":"ℷ","&gjcy;":"ѓ","&gl;":"≷","&glE;":"⪒","&gla;":"⪥","&glj;":"⪤","&gnE;":"≩","&gnap;":"⪊","&gnapprox;":"⪊","&gne;":"⪈","&gneq;":"⪈","&gneqq;":"≩","&gnsim;":"⋧","&gopf;":"𝕘","&grave;":"`","&gscr;":"ℊ","&gsim;":"≳","&gsime;":"⪎","&gsiml;":"⪐","&gt":">","&gt;":">","&gtcc;":"⪧","&gtcir;":"⩺","&gtdot;":"⋗","&gtlPar;":"⦕","&gtquest;":"⩼","&gtrapprox;":"⪆","&gtrarr;":"⥸","&gtrdot;":"⋗","&gtreqless;":"⋛","&gtreqqless;":"⪌","&gtrless;":"≷","&gtrsim;":"≳","&gvertneqq;":"≩︀","&gvnE;":"≩︀","&hArr;":"⇔","&hairsp;":" ","&half;":"½","&hamilt;":"ℋ","&hardcy;":"ъ","&harr;":"↔","&harrcir;":"⥈","&harrw;":"↭","&hbar;":"ℏ","&hcirc;":"ĥ","&hearts;":"♥","&heartsuit;":"♥","&hellip;":"…","&hercon;":"⊹","&hfr;":"𝔥","&hksearow;":"⤥","&hkswarow;":"⤦","&hoarr;":"⇿","&homtht;":"∻","&hookleftarrow;":"↩","&hookrightarrow;":"↪","&hopf;":"𝕙","&horbar;":"―","&hscr;":"𝒽","&hslash;":"ℏ","&hstrok;":"ħ","&hybull;":"⁃","&hyphen;":"‐","&iacute":"í","&iacute;":"í","&ic;":"⁣","&icirc":"î","&icirc;":"î","&icy;":"и","&iecy;":"е","&iexcl":"¡","&iexcl;":"¡","&iff;":"⇔","&ifr;":"𝔦","&igrave":"ì","&igrave;":"ì","&ii;":"ⅈ","&iiiint;":"⨌","&iiint;":"∭","&iinfin;":"⧜","&iiota;":"℩","&ijlig;":"ij","&imacr;":"ī","&image;":"ℑ","&imagline;":"ℐ","&imagpart;":"ℑ","&imath;":"ı","&imof;":"⊷","&imped;":"Ƶ","&in;":"∈","&incare;":"℅","&infin;":"∞","&infintie;":"⧝","&inodot;":"ı","&int;":"∫","&intcal;":"⊺","&integers;":"ℤ","&intercal;":"⊺","&intlarhk;":"⨗","&intprod;":"⨼","&iocy;":"ё","&iogon;":"į","&iopf;":"𝕚","&iota;":"ι","&iprod;":"⨼","&iquest":"¿","&iquest;":"¿","&iscr;":"𝒾","&isin;":"∈","&isinE;":"⋹","&isindot;":"⋵","&isins;":"⋴","&isinsv;":"⋳","&isinv;":"∈","&it;":"⁢","&itilde;":"ĩ","&iukcy;":"і","&iuml":"ï","&iuml;":"ï","&jcirc;":"ĵ","&jcy;":"й","&jfr;":"𝔧","&jmath;":"ȷ","&jopf;":"𝕛","&jscr;":"𝒿","&jsercy;":"ј","&jukcy;":"є","&kappa;":"κ","&kappav;":"ϰ","&kcedil;":"ķ","&kcy;":"к","&kfr;":"𝔨","&kgreen;":"ĸ","&khcy;":"х","&kjcy;":"ќ","&kopf;":"𝕜","&kscr;":"𝓀","&lAarr;":"⇚","&lArr;":"⇐","&lAtail;":"⤛","&lBarr;":"⤎","&lE;":"≦","&lEg;":"⪋","&lHar;":"⥢","&lacute;":"ĺ","&laemptyv;":"⦴","&lagran;":"ℒ","&lambda;":"λ","&lang;":"⟨","&langd;":"⦑","&langle;":"⟨","&lap;":"⪅","&laquo":"«","&laquo;":"«","&larr;":"←","&larrb;":"⇤","&larrbfs;":"⤟","&larrfs;":"⤝","&larrhk;":"↩","&larrlp;":"↫","&larrpl;":"⤹","&larrsim;":"⥳","&larrtl;":"↢","&lat;":"⪫","&latail;":"⤙","&late;":"⪭","&lates;":"⪭︀","&lbarr;":"⤌","&lbbrk;":"❲","&lbrace;":"{","&lbrack;":"[","&lbrke;":"⦋","&lbrksld;":"⦏","&lbrkslu;":"⦍","&lcaron;":"ľ","&lcedil;":"ļ","&lceil;":"⌈","&lcub;":"{","&lcy;":"л","&ldca;":"⤶","&ldquo;":"“","&ldquor;":"„","&ldrdhar;":"⥧","&ldrushar;":"⥋","&ldsh;":"↲","&le;":"≤","&leftarrow;":"←","&leftarrowtail;":"↢","&leftharpoondown;":"↽","&leftharpoonup;":"↼","&leftleftarrows;":"⇇","&leftrightarrow;":"↔","&leftrightarrows;":"⇆","&leftrightharpoons;":"⇋","&leftrightsquigarrow;":"↭","&leftthreetimes;":"⋋","&leg;":"⋚","&leq;":"≤","&leqq;":"≦","&leqslant;":"⩽","&les;":"⩽","&lescc;":"⪨","&lesdot;":"⩿","&lesdoto;":"⪁","&lesdotor;":"⪃","&lesg;":"⋚︀","&lesges;":"⪓","&lessapprox;":"⪅","&lessdot;":"⋖","&lesseqgtr;":"⋚","&lesseqqgtr;":"⪋","&lessgtr;":"≶","&lesssim;":"≲","&lfisht;":"⥼","&lfloor;":"⌊","&lfr;":"𝔩","&lg;":"≶","&lgE;":"⪑","&lhard;":"↽","&lharu;":"↼","&lharul;":"⥪","&lhblk;":"▄","&ljcy;":"љ","&ll;":"≪","&llarr;":"⇇","&llcorner;":"⌞","&llhard;":"⥫","&lltri;":"◺","&lmidot;":"ŀ","&lmoust;":"⎰","&lmoustache;":"⎰","&lnE;":"≨","&lnap;":"⪉","&lnapprox;":"⪉","&lne;":"⪇","&lneq;":"⪇","&lneqq;":"≨","&lnsim;":"⋦","&loang;":"⟬","&loarr;":"⇽","&lobrk;":"⟦","&longleftarrow;":"⟵","&longleftrightarrow;":"⟷","&longmapsto;":"⟼","&longrightarrow;":"⟶","&looparrowleft;":"↫","&looparrowright;":"↬","&lopar;":"⦅","&lopf;":"𝕝","&loplus;":"⨭","&lotimes;":"⨴","&lowast;":"∗","&lowbar;":"_","&loz;":"◊","&lozenge;":"◊","&lozf;":"⧫","&lpar;":"(","&lparlt;":"⦓","&lrarr;":"⇆","&lrcorner;":"⌟","&lrhar;":"⇋","&lrhard;":"⥭","&lrm;":"‎","&lrtri;":"⊿","&lsaquo;":"‹","&lscr;":"𝓁","&lsh;":"↰","&lsim;":"≲","&lsime;":"⪍","&lsimg;":"⪏","&lsqb;":"[","&lsquo;":"‘","&lsquor;":"‚","&lstrok;":"ł","&lt":"<","&lt;":"<","&ltcc;":"⪦","&ltcir;":"⩹","&ltdot;":"⋖","&lthree;":"⋋","&ltimes;":"⋉","&ltlarr;":"⥶","&ltquest;":"⩻","&ltrPar;":"⦖","&ltri;":"◃","&ltrie;":"⊴","&ltrif;":"◂","&lurdshar;":"⥊","&luruhar;":"⥦","&lvertneqq;":"≨︀","&lvnE;":"≨︀","&mDDot;":"∺","&macr":"¯","&macr;":"¯","&male;":"♂","&malt;":"✠","&maltese;":"✠","&map;":"↦","&mapsto;":"↦","&mapstodown;":"↧","&mapstoleft;":"↤","&mapstoup;":"↥","&marker;":"▮","&mcomma;":"⨩","&mcy;":"м","&mdash;":"—","&measuredangle;":"∡","&mfr;":"𝔪","&mho;":"℧","&micro":"µ","&micro;":"µ","&mid;":"∣","&midast;":"*","&midcir;":"⫰","&middot":"·","&middot;":"·","&minus;":"−","&minusb;":"⊟","&minusd;":"∸","&minusdu;":"⨪","&mlcp;":"⫛","&mldr;":"…","&mnplus;":"∓","&models;":"⊧","&mopf;":"𝕞","&mp;":"∓","&mscr;":"𝓂","&mstpos;":"∾","&mu;":"μ","&multimap;":"⊸","&mumap;":"⊸","&nGg;":"⋙̸","&nGt;":"≫⃒","&nGtv;":"≫̸","&nLeftarrow;":"⇍","&nLeftrightarrow;":"⇎","&nLl;":"⋘̸","&nLt;":"≪⃒","&nLtv;":"≪̸","&nRightarrow;":"⇏","&nVDash;":"⊯","&nVdash;":"⊮","&nabla;":"∇","&nacute;":"ń","&nang;":"∠⃒","&nap;":"≉","&napE;":"⩰̸","&napid;":"≋̸","&napos;":"ʼn","&napprox;":"≉","&natur;":"♮","&natural;":"♮","&naturals;":"ℕ","&nbsp":" ","&nbsp;":" ","&nbump;":"≎̸","&nbumpe;":"≏̸","&ncap;":"⩃","&ncaron;":"ň","&ncedil;":"ņ","&ncong;":"≇","&ncongdot;":"⩭̸","&ncup;":"⩂","&ncy;":"н","&ndash;":"–","&ne;":"≠","&neArr;":"⇗","&nearhk;":"⤤","&nearr;":"↗","&nearrow;":"↗","&nedot;":"≐̸","&nequiv;":"≢","&nesear;":"⤨","&nesim;":"≂̸","&nexist;":"∄","&nexists;":"∄","&nfr;":"𝔫","&ngE;":"≧̸","&nge;":"≱","&ngeq;":"≱","&ngeqq;":"≧̸","&ngeqslant;":"⩾̸","&nges;":"⩾̸","&ngsim;":"≵","&ngt;":"≯","&ngtr;":"≯","&nhArr;":"⇎","&nharr;":"↮","&nhpar;":"⫲","&ni;":"∋","&nis;":"⋼","&nisd;":"⋺","&niv;":"∋","&njcy;":"њ","&nlArr;":"⇍","&nlE;":"≦̸","&nlarr;":"↚","&nldr;":"‥","&nle;":"≰","&nleftarrow;":"↚","&nleftrightarrow;":"↮","&nleq;":"≰","&nleqq;":"≦̸","&nleqslant;":"⩽̸","&nles;":"⩽̸","&nless;":"≮","&nlsim;":"≴","&nlt;":"≮","&nltri;":"⋪","&nltrie;":"⋬","&nmid;":"∤","&nopf;":"𝕟","&not":"¬","&not;":"¬","&notin;":"∉","&notinE;":"⋹̸","&notindot;":"⋵̸","&notinva;":"∉","&notinvb;":"⋷","&notinvc;":"⋶","&notni;":"∌","&notniva;":"∌","&notnivb;":"⋾","&notnivc;":"⋽","&npar;":"∦","&nparallel;":"∦","&nparsl;":"⫽⃥","&npart;":"∂̸","&npolint;":"⨔","&npr;":"⊀","&nprcue;":"⋠","&npre;":"⪯̸","&nprec;":"⊀","&npreceq;":"⪯̸","&nrArr;":"⇏","&nrarr;":"↛","&nrarrc;":"⤳̸","&nrarrw;":"↝̸","&nrightarrow;":"↛","&nrtri;":"⋫","&nrtrie;":"⋭","&nsc;":"⊁","&nsccue;":"⋡","&nsce;":"⪰̸","&nscr;":"𝓃","&nshortmid;":"∤","&nshortparallel;":"∦","&nsim;":"≁","&nsime;":"≄","&nsimeq;":"≄","&nsmid;":"∤","&nspar;":"∦","&nsqsube;":"⋢","&nsqsupe;":"⋣","&nsub;":"⊄","&nsubE;":"⫅̸","&nsube;":"⊈","&nsubset;":"⊂⃒","&nsubseteq;":"⊈","&nsubseteqq;":"⫅̸","&nsucc;":"⊁","&nsucceq;":"⪰̸","&nsup;":"⊅","&nsupE;":"⫆̸","&nsupe;":"⊉","&nsupset;":"⊃⃒","&nsupseteq;":"⊉","&nsupseteqq;":"⫆̸","&ntgl;":"≹","&ntilde":"ñ","&ntilde;":"ñ","&ntlg;":"≸","&ntriangleleft;":"⋪","&ntrianglelefteq;":"⋬","&ntriangleright;":"⋫","&ntrianglerighteq;":"⋭","&nu;":"ν","&num;":"#","&numero;":"№","&numsp;":" ","&nvDash;":"⊭","&nvHarr;":"⤄","&nvap;":"≍⃒","&nvdash;":"⊬","&nvge;":"≥⃒","&nvgt;":">⃒","&nvinfin;":"⧞","&nvlArr;":"⤂","&nvle;":"≤⃒","&nvlt;":"<⃒","&nvltrie;":"⊴⃒","&nvrArr;":"⤃","&nvrtrie;":"⊵⃒","&nvsim;":"∼⃒","&nwArr;":"⇖","&nwarhk;":"⤣","&nwarr;":"↖","&nwarrow;":"↖","&nwnear;":"⤧","&oS;":"Ⓢ","&oacute":"ó","&oacute;":"ó","&oast;":"⊛","&ocir;":"⊚","&ocirc":"ô","&ocirc;":"ô","&ocy;":"о","&odash;":"⊝","&odblac;":"ő","&odiv;":"⨸","&odot;":"⊙","&odsold;":"⦼","&oelig;":"œ","&ofcir;":"⦿","&ofr;":"𝔬","&ogon;":"˛","&ograve":"ò","&ograve;":"ò","&ogt;":"⧁","&ohbar;":"⦵","&ohm;":"Ω","&oint;":"∮","&olarr;":"↺","&olcir;":"⦾","&olcross;":"⦻","&oline;":"‾","&olt;":"⧀","&omacr;":"ō","&omega;":"ω","&omicron;":"ο","&omid;":"⦶","&ominus;":"⊖","&oopf;":"𝕠","&opar;":"⦷","&operp;":"⦹","&oplus;":"⊕","&or;":"∨","&orarr;":"↻","&ord;":"⩝","&order;":"ℴ","&orderof;":"ℴ","&ordf":"ª","&ordf;":"ª","&ordm":"º","&ordm;":"º","&origof;":"⊶","&oror;":"⩖","&orslope;":"⩗","&orv;":"⩛","&oscr;":"ℴ","&oslash":"ø","&oslash;":"ø","&osol;":"⊘","&otilde":"õ","&otilde;":"õ","&otimes;":"⊗","&otimesas;":"⨶","&ouml":"ö","&ouml;":"ö","&ovbar;":"⌽","&par;":"∥","&para":"¶","&para;":"¶","&parallel;":"∥","&parsim;":"⫳","&parsl;":"⫽","&part;":"∂","&pcy;":"п","&percnt;":"%","&period;":".","&permil;":"‰","&perp;":"⊥","&pertenk;":"‱","&pfr;":"𝔭","&phi;":"φ","&phiv;":"ϕ","&phmmat;":"ℳ","&phone;":"☎","&pi;":"π","&pitchfork;":"⋔","&piv;":"ϖ","&planck;":"ℏ","&planckh;":"ℎ","&plankv;":"ℏ","&plus;":"+","&plusacir;":"⨣","&plusb;":"⊞","&pluscir;":"⨢","&plusdo;":"∔","&plusdu;":"⨥","&pluse;":"⩲","&plusmn":"±","&plusmn;":"±","&plussim;":"⨦","&plustwo;":"⨧","&pm;":"±","&pointint;":"⨕","&popf;":"𝕡","&pound":"£","&pound;":"£","&pr;":"≺","&prE;":"⪳","&prap;":"⪷","&prcue;":"≼","&pre;":"⪯","&prec;":"≺","&precapprox;":"⪷","&preccurlyeq;":"≼","&preceq;":"⪯","&precnapprox;":"⪹","&precneqq;":"⪵","&precnsim;":"⋨","&precsim;":"≾","&prime;":"′","&primes;":"ℙ","&prnE;":"⪵","&prnap;":"⪹","&prnsim;":"⋨","&prod;":"∏","&profalar;":"⌮","&profline;":"⌒","&profsurf;":"⌓","&prop;":"∝","&propto;":"∝","&prsim;":"≾","&prurel;":"⊰","&pscr;":"𝓅","&psi;":"ψ","&puncsp;":" ","&qfr;":"𝔮","&qint;":"⨌","&qopf;":"𝕢","&qprime;":"⁗","&qscr;":"𝓆","&quaternions;":"ℍ","&quatint;":"⨖","&quest;":"?","&questeq;":"≟","&quot":'"',"&quot;":'"',"&rAarr;":"⇛","&rArr;":"⇒","&rAtail;":"⤜","&rBarr;":"⤏","&rHar;":"⥤","&race;":"∽̱","&racute;":"ŕ","&radic;":"√","&raemptyv;":"⦳","&rang;":"⟩","&rangd;":"⦒","&range;":"⦥","&rangle;":"⟩","&raquo":"»","&raquo;":"»","&rarr;":"→","&rarrap;":"⥵","&rarrb;":"⇥","&rarrbfs;":"⤠","&rarrc;":"⤳","&rarrfs;":"⤞","&rarrhk;":"↪","&rarrlp;":"↬","&rarrpl;":"⥅","&rarrsim;":"⥴","&rarrtl;":"↣","&rarrw;":"↝","&ratail;":"⤚","&ratio;":"∶","&rationals;":"ℚ","&rbarr;":"⤍","&rbbrk;":"❳","&rbrace;":"}","&rbrack;":"]","&rbrke;":"⦌","&rbrksld;":"⦎","&rbrkslu;":"⦐","&rcaron;":"ř","&rcedil;":"ŗ","&rceil;":"⌉","&rcub;":"}","&rcy;":"р","&rdca;":"⤷","&rdldhar;":"⥩","&rdquo;":"”","&rdquor;":"”","&rdsh;":"↳","&real;":"ℜ","&realine;":"ℛ","&realpart;":"ℜ","&reals;":"ℝ","&rect;":"▭","&reg":"®","&reg;":"®","&rfisht;":"⥽","&rfloor;":"⌋","&rfr;":"𝔯","&rhard;":"⇁","&rharu;":"⇀","&rharul;":"⥬","&rho;":"ρ","&rhov;":"ϱ","&rightarrow;":"→","&rightarrowtail;":"↣","&rightharpoondown;":"⇁","&rightharpoonup;":"⇀","&rightleftarrows;":"⇄","&rightleftharpoons;":"⇌","&rightrightarrows;":"⇉","&rightsquigarrow;":"↝","&rightthreetimes;":"⋌","&ring;":"˚","&risingdotseq;":"≓","&rlarr;":"⇄","&rlhar;":"⇌","&rlm;":"‏","&rmoust;":"⎱","&rmoustache;":"⎱","&rnmid;":"⫮","&roang;":"⟭","&roarr;":"⇾","&robrk;":"⟧","&ropar;":"⦆","&ropf;":"𝕣","&roplus;":"⨮","&rotimes;":"⨵","&rpar;":")","&rpargt;":"⦔","&rppolint;":"⨒","&rrarr;":"⇉","&rsaquo;":"›","&rscr;":"𝓇","&rsh;":"↱","&rsqb;":"]","&rsquo;":"’","&rsquor;":"’","&rthree;":"⋌","&rtimes;":"⋊","&rtri;":"▹","&rtrie;":"⊵","&rtrif;":"▸","&rtriltri;":"⧎","&ruluhar;":"⥨","&rx;":"℞","&sacute;":"ś","&sbquo;":"‚","&sc;":"≻","&scE;":"⪴","&scap;":"⪸","&scaron;":"š","&sccue;":"≽","&sce;":"⪰","&scedil;":"ş","&scirc;":"ŝ","&scnE;":"⪶","&scnap;":"⪺","&scnsim;":"⋩","&scpolint;":"⨓","&scsim;":"≿","&scy;":"с","&sdot;":"⋅","&sdotb;":"⊡","&sdote;":"⩦","&seArr;":"⇘","&searhk;":"⤥","&searr;":"↘","&searrow;":"↘","&sect":"§","&sect;":"§","&semi;":";","&seswar;":"⤩","&setminus;":"∖","&setmn;":"∖","&sext;":"✶","&sfr;":"𝔰","&sfrown;":"⌢","&sharp;":"♯","&shchcy;":"щ","&shcy;":"ш","&shortmid;":"∣","&shortparallel;":"∥","&shy":"­","&shy;":"­","&sigma;":"σ","&sigmaf;":"ς","&sigmav;":"ς","&sim;":"∼","&simdot;":"⩪","&sime;":"≃","&simeq;":"≃","&simg;":"⪞","&simgE;":"⪠","&siml;":"⪝","&simlE;":"⪟","&simne;":"≆","&simplus;":"⨤","&simrarr;":"⥲","&slarr;":"←","&smallsetminus;":"∖","&smashp;":"⨳","&smeparsl;":"⧤","&smid;":"∣","&smile;":"⌣","&smt;":"⪪","&smte;":"⪬","&smtes;":"⪬︀","&softcy;":"ь","&sol;":"/","&solb;":"⧄","&solbar;":"⌿","&sopf;":"𝕤","&spades;":"♠","&spadesuit;":"♠","&spar;":"∥","&sqcap;":"⊓","&sqcaps;":"⊓︀","&sqcup;":"⊔","&sqcups;":"⊔︀","&sqsub;":"⊏","&sqsube;":"⊑","&sqsubset;":"⊏","&sqsubseteq;":"⊑","&sqsup;":"⊐","&sqsupe;":"⊒","&sqsupset;":"⊐","&sqsupseteq;":"⊒","&squ;":"□","&square;":"□","&squarf;":"▪","&squf;":"▪","&srarr;":"→","&sscr;":"𝓈","&ssetmn;":"∖","&ssmile;":"⌣","&sstarf;":"⋆","&star;":"☆","&starf;":"★","&straightepsilon;":"ϵ","&straightphi;":"ϕ","&strns;":"¯","&sub;":"⊂","&subE;":"⫅","&subdot;":"⪽","&sube;":"⊆","&subedot;":"⫃","&submult;":"⫁","&subnE;":"⫋","&subne;":"⊊","&subplus;":"⪿","&subrarr;":"⥹","&subset;":"⊂","&subseteq;":"⊆","&subseteqq;":"⫅","&subsetneq;":"⊊","&subsetneqq;":"⫋","&subsim;":"⫇","&subsub;":"⫕","&subsup;":"⫓","&succ;":"≻","&succapprox;":"⪸","&succcurlyeq;":"≽","&succeq;":"⪰","&succnapprox;":"⪺","&succneqq;":"⪶","&succnsim;":"⋩","&succsim;":"≿","&sum;":"∑","&sung;":"♪","&sup1":"¹","&sup1;":"¹","&sup2":"²","&sup2;":"²","&sup3":"³","&sup3;":"³","&sup;":"⊃","&supE;":"⫆","&supdot;":"⪾","&supdsub;":"⫘","&supe;":"⊇","&supedot;":"⫄","&suphsol;":"⟉","&suphsub;":"⫗","&suplarr;":"⥻","&supmult;":"⫂","&supnE;":"⫌","&supne;":"⊋","&supplus;":"⫀","&supset;":"⊃","&supseteq;":"⊇","&supseteqq;":"⫆","&supsetneq;":"⊋","&supsetneqq;":"⫌","&supsim;":"⫈","&supsub;":"⫔","&supsup;":"⫖","&swArr;":"⇙","&swarhk;":"⤦","&swarr;":"↙","&swarrow;":"↙","&swnwar;":"⤪","&szlig":"ß","&szlig;":"ß","&target;":"⌖","&tau;":"τ","&tbrk;":"⎴","&tcaron;":"ť","&tcedil;":"ţ","&tcy;":"т","&tdot;":"⃛","&telrec;":"⌕","&tfr;":"𝔱","&there4;":"∴","&therefore;":"∴","&theta;":"θ","&thetasym;":"ϑ","&thetav;":"ϑ","&thickapprox;":"≈","&thicksim;":"∼","&thinsp;":" ","&thkap;":"≈","&thksim;":"∼","&thorn":"þ","&thorn;":"þ","&tilde;":"˜","&times":"×","&times;":"×","&timesb;":"⊠","&timesbar;":"⨱","&timesd;":"⨰","&tint;":"∭","&toea;":"⤨","&top;":"⊤","&topbot;":"⌶","&topcir;":"⫱","&topf;":"𝕥","&topfork;":"⫚","&tosa;":"⤩","&tprime;":"‴","&trade;":"™","&triangle;":"▵","&triangledown;":"▿","&triangleleft;":"◃","&trianglelefteq;":"⊴","&triangleq;":"≜","&triangleright;":"▹","&trianglerighteq;":"⊵","&tridot;":"◬","&trie;":"≜","&triminus;":"⨺","&triplus;":"⨹","&trisb;":"⧍","&tritime;":"⨻","&trpezium;":"⏢","&tscr;":"𝓉","&tscy;":"ц","&tshcy;":"ћ","&tstrok;":"ŧ","&twixt;":"≬","&twoheadleftarrow;":"↞","&twoheadrightarrow;":"↠","&uArr;":"⇑","&uHar;":"⥣","&uacute":"ú","&uacute;":"ú","&uarr;":"↑","&ubrcy;":"ў","&ubreve;":"ŭ","&ucirc":"û","&ucirc;":"û","&ucy;":"у","&udarr;":"⇅","&udblac;":"ű","&udhar;":"⥮","&ufisht;":"⥾","&ufr;":"𝔲","&ugrave":"ù","&ugrave;":"ù","&uharl;":"↿","&uharr;":"↾","&uhblk;":"▀","&ulcorn;":"⌜","&ulcorner;":"⌜","&ulcrop;":"⌏","&ultri;":"◸","&umacr;":"ū","&uml":"¨","&uml;":"¨","&uogon;":"ų","&uopf;":"𝕦","&uparrow;":"↑","&updownarrow;":"↕","&upharpoonleft;":"↿","&upharpoonright;":"↾","&uplus;":"⊎","&upsi;":"υ","&upsih;":"ϒ","&upsilon;":"υ","&upuparrows;":"⇈","&urcorn;":"⌝","&urcorner;":"⌝","&urcrop;":"⌎","&uring;":"ů","&urtri;":"◹","&uscr;":"𝓊","&utdot;":"⋰","&utilde;":"ũ","&utri;":"▵","&utrif;":"▴","&uuarr;":"⇈","&uuml":"ü","&uuml;":"ü","&uwangle;":"⦧","&vArr;":"⇕","&vBar;":"⫨","&vBarv;":"⫩","&vDash;":"⊨","&vangrt;":"⦜","&varepsilon;":"ϵ","&varkappa;":"ϰ","&varnothing;":"∅","&varphi;":"ϕ","&varpi;":"ϖ","&varpropto;":"∝","&varr;":"↕","&varrho;":"ϱ","&varsigma;":"ς","&varsubsetneq;":"⊊︀","&varsubsetneqq;":"⫋︀","&varsupsetneq;":"⊋︀","&varsupsetneqq;":"⫌︀","&vartheta;":"ϑ","&vartriangleleft;":"⊲","&vartriangleright;":"⊳","&vcy;":"в","&vdash;":"⊢","&vee;":"∨","&veebar;":"⊻","&veeeq;":"≚","&vellip;":"⋮","&verbar;":"|","&vert;":"|","&vfr;":"𝔳","&vltri;":"⊲","&vnsub;":"⊂⃒","&vnsup;":"⊃⃒","&vopf;":"𝕧","&vprop;":"∝","&vrtri;":"⊳","&vscr;":"𝓋","&vsubnE;":"⫋︀","&vsubne;":"⊊︀","&vsupnE;":"⫌︀","&vsupne;":"⊋︀","&vzigzag;":"⦚","&wcirc;":"ŵ","&wedbar;":"⩟","&wedge;":"∧","&wedgeq;":"≙","&weierp;":"℘","&wfr;":"𝔴","&wopf;":"𝕨","&wp;":"℘","&wr;":"≀","&wreath;":"≀","&wscr;":"𝓌","&xcap;":"⋂","&xcirc;":"◯","&xcup;":"⋃","&xdtri;":"▽","&xfr;":"𝔵","&xhArr;":"⟺","&xharr;":"⟷","&xi;":"ξ","&xlArr;":"⟸","&xlarr;":"⟵","&xmap;":"⟼","&xnis;":"⋻","&xodot;":"⨀","&xopf;":"𝕩","&xoplus;":"⨁","&xotime;":"⨂","&xrArr;":"⟹","&xrarr;":"⟶","&xscr;":"𝓍","&xsqcup;":"⨆","&xuplus;":"⨄","&xutri;":"△","&xvee;":"⋁","&xwedge;":"⋀","&yacute":"ý","&yacute;":"ý","&yacy;":"я","&ycirc;":"ŷ","&ycy;":"ы","&yen":"¥","&yen;":"¥","&yfr;":"𝔶","&yicy;":"ї","&yopf;":"𝕪","&yscr;":"𝓎","&yucy;":"ю","&yuml":"ÿ","&yuml;":"ÿ","&zacute;":"ź","&zcaron;":"ž","&zcy;":"з","&zdot;":"ż","&zeetrf;":"ℨ","&zeta;":"ζ","&zfr;":"𝔷","&zhcy;":"ж","&zigrarr;":"⇝","&zopf;":"𝕫","&zscr;":"𝓏","&zwj;":"‍","&zwnj;":"‌"};function $d(r){return r.replace(/&(#\d+|#x[a-f0-9]+|[a-z]+\d*);?/gi,(e,t)=>{if(typeof va[e]=="string")return va[e];if(t.charAt(0)!=="#"||e.charAt(e.length-1)!==";")return e;let n;t.charAt(1)==="x"?n=parseInt(t.substr(2),16):n=parseInt(t.substr(1),10);var s="";return n>=55296&&n<=57343||n>1114111?"�":(n>65535&&(n-=65536,s+=String.fromCharCode(n>>>10&1023|55296),n=56320|n&1023),s+=String.fromCharCode(n),s)})}function Er(r){return r.trim().replace(/[<>"'?&]/g,e=>{let t=e.charCodeAt(0).toString(16);return t.length<2&&(t="0"+t),"&#x"+t.toUpperCase()+";"})}function qd(r){return"<div>"+Er(r).replace(/\n/g,"<br />")+"</div>"}function Ud(r){return r=r.replace(/\r?\n/g,"").replace(/<\!\-\-.*?\-\->/gi," ").replace(/<br\b[^>]*>/gi,`
1
+ "use strict";var Td=Object.defineProperty;var Nd=(r,e,t)=>e in r?Td(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Et=(r,e,t)=>Nd(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),ya=require("react-dom");function Bd(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const ki=Bd(v);class Rd{constructor(e){Et(this,"config");Et(this,"defaultUploadOptions",{maxSizeMB:10,maxImageDimension:0,imageQuality:.9});if(!e.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=e}async callGraph(e,t={}){const n={coprocessor:"graph",method:e,system_id:this.config.system_id,params:t};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!s.ok){const o=await s.text();throw new Error(`API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("Graph API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(e){return(await this.callGraph("get_children",{parent_id:e})).result||[]}async getNode(e){return(await this.callGraph("get_node",{node_id:e})).result||null}async addNode(e){const t={...e,created:e.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",t);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(e,t){const n={node_id:e,updates:{...t,modified:new Date().toISOString()}},s=await this.callGraph("update_node",n);if(!s.result)throw new Error("Failed to update node");return s.result}async deleteNode(e,t=!1){return(await this.callGraph("delete_node",{node_id:e,cascade:t})).success===!0}async getChildrenWithEdges(e,t="children",n,s){return(await this.callGraph("get_children_with_edges",{node_id:e,display_mode:t,edge_type:n,node_type:s})).result||[]}async addEdge(e,t,n="link",s){return await this.callGraph("add_edge",{source_id:e,target_id:t,edge_type:n,data:s})}async deleteEdge(e,t,n){return await this.callGraph("delete_edge",{source_id:e,target_id:t,edge_type:n})}async getEdges(e,t,n){return(await this.callGraph("get_edges",{source_id:e,edge_type:t,target_id:n})).result||[]}async getAncestors(e){return(await this.callGraph("get_ancestors",{node_id:e})).ancestors||[]}async getTree(e,t=10){return(await this.callGraph("get_tree",{root_id:e,max_depth:t})).tree||[]}async moveNode(e,t){const n=await this.callGraph("move",{node_id:e,new_parent_id:t});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(e,t){return(await this.callGraph("search",{query:e,type:t})).nodes||[]}async getNodesByType(e){return(await this.callGraph("get_nodes_by_type",{type:e})).result||[]}fileToBase64(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const o=s.result.split(",")[1];t(o)},s.onerror=()=>n(new Error("Failed to read file")),s.readAsDataURL(e)})}async resizeImage(e,t,n){return e.type.startsWith("image/")?new Promise(s=>{const i=new Image,o=URL.createObjectURL(e);i.onload=()=>{if(URL.revokeObjectURL(o),i.width<=t&&i.height<=t){s(e);return}let l,a;i.width>i.height?(l=t,a=Math.round(i.height/i.width*t)):(a=t,l=Math.round(i.width/i.height*t));const u=document.createElement("canvas");u.width=l,u.height=a;const c=u.getContext("2d");if(!c){s(e);return}c.drawImage(i,0,0,l,a);const d=e.type==="image/png"?"image/png":"image/jpeg";u.toBlob(f=>{if(f){const p=new File([f],e.name,{type:d});s(p)}else s(e)},d,n)},i.onerror=()=>{URL.revokeObjectURL(o),s(e)},i.src=o}):e}async uploadFile(e,t,n,s={}){const i={...this.defaultUploadOptions,...s};try{let o=n;i.maxImageDimension>0&&n.type.startsWith("image/")&&(o=await this.resizeImage(n,i.maxImageDimension,i.imageQuality));const l=i.maxSizeMB*1024*1024;if(o.size>l)return{success:!1,error:`File too large (${(o.size/1024/1024).toFixed(1)} MB). Max: ${i.maxSizeMB} MB`};const a=await this.fileToBase64(o),u=await this.callGraph("upload_file",{node_id:e,filename:t,content:a});return u.success?{success:!0,path:u.path}:{success:!1,error:u.error||"Upload failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Upload failed"}}}async listFiles(e){var s;return(((s=(await this.callGraph("list_files",{node_id:e})).result)==null?void 0:s.files)||[]).map(i=>({filename:i.name,path:i.path}))}async deleteFile(e,t){return{success:(await this.callGraph("delete_file",{node_id:e,filename:t})).success||!1}}getFileUrl(e,t){return`${this.config.baseUrl}/files/${this.config.system_id}/${e}/${t}`}}const Jr=new TextEncoder,xa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn=new Uint8Array(256);for(var as=0;as<xa.length;as++)bn[xa.charCodeAt(as)]=as;function Hi(r){let e=Math.ceil(r.length/4)*3;const t=r.length;let n=0;r.length%4===3?e--:r.length%4===2?e-=2:r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);const s=new ArrayBuffer(e),i=new Uint8Array(s);for(let o=0;o<t;o+=4){let l=bn[r.charCodeAt(o)],a=bn[r.charCodeAt(o+1)],u=bn[r.charCodeAt(o+2)],c=bn[r.charCodeAt(o+3)];i[n++]=l<<2|a>>4,i[n++]=(a&15)<<4|u>>2,i[n++]=(u&3)<<6|c&63}return s}function kn(r){r=r||"utf8";let e;try{e=new TextDecoder(r)}catch{e=new TextDecoder("windows-1252")}return e}async function ni(r){if("arrayBuffer"in r)return await r.arrayBuffer();const e=new FileReader;return new Promise((t,n)=>{e.onload=function(s){t(s.target.result)},e.onerror=function(s){n(e.error)},e.readAsArrayBuffer(r)})}function ba(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function Md(r,e,t){let n=r.indexOf("*");n>=0&&(r=r.substr(0,n)),e=e.toUpperCase();let s;if(e==="Q"){t=t.replace(/=\s+([0-9a-fA-F])/g,"=$1").replace(/[_\s]/g," ");let i=Jr.encode(t),o=[];for(let a=0,u=i.length;a<u;a++){let c=i[a];if(a<=u-2&&c===61){let d=ba(i[a+1]),f=ba(i[a+2]);if(d&&f){let p=parseInt(d+f,16);o.push(p),a+=2;continue}}o.push(c)}s=new ArrayBuffer(o.length);let l=new DataView(s);for(let a=0,u=o.length;a<u;a++)l.setUint8(a,o[a])}else e==="B"?s=Hi(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Jr.encode(t);return kn(r).decode(s)}function En(r){let e=!0;for(;;){let t=(r||"").toString().replace(/(=\?([^?]+)\?[Bb]\?([^?]*)\?=)\s*(?==\?([^?]+)\?[Bb]\?[^?]*\?=)/g,(n,s,i,o,l)=>e&&i===l&&o.length%4===0&&!/=$/.test(o)?s+"__\0JOIN\0__":n).replace(/(=\?([^?]+)\?[Qq]\?[^?]*\?=)\s*(?==\?([^?]+)\?[Qq]\?[^?]*\?=)/g,(n,s,i,o)=>e&&i===o?s+"__\0JOIN\0__":n).replace(/(\?=)?__\x00JOIN\x00__(=\?([^?]+)\?[QqBb]\?)?/g,"").replace(/(=\?[^?]+\?[QqBb]\?[^?]*\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]*\?=)/g,"$1").replace(/=\?([\w_\-*]+)\?([QqBb])\?([^?]*)\?=/g,(n,s,i,o)=>Md(s,i,o));if(e&&t.indexOf("�")>=0)e=!1;else return t}}function Fd(r,e){e=e||"utf-8";let t=[];for(let i=0;i<r.length;i++){let o=r.charAt(i);if(o==="%"&&/^[a-f0-9]{2}/i.test(r.substr(i+1,2))){let l=r.substr(i+1,2);i+=2,t.push(parseInt(l,16))}else if(o.charCodeAt(0)>126){o=Jr.encode(o);for(let l=0;l<o.length;l++)t.push(o[l])}else t.push(o.charCodeAt(0))}const n=new ArrayBuffer(t.length),s=new DataView(n);for(let i=0,o=t.length;i<o;i++)s.setUint8(i,t[i]);return kn(e).decode(n)}function jd(r){let e=new Map;Object.keys(r.params).forEach(t=>{let n=t.match(/\*((\d+)\*?)?$/);if(!n)return;let s=t.substr(0,n.index).toLowerCase(),i=Number(n[2])||0,o;e.has(s)?o=e.get(s):(o={charset:!1,values:[]},e.set(s,o));let l=r.params[t];i===0&&n[0].charAt(n[0].length-1)==="*"&&(n=l.match(/^([^']*)'[^']*'(.*)$/))&&(o.charset=n[1]||"utf-8",l=n[2]),o.values.push({nr:i,value:l}),delete r.params[t]}),e.forEach((t,n)=>{r.params[n]=Fd(t.values.sort((s,i)=>s.nr-i.nr).map(s=>s.value).join(""),t.charset)})}class Ld{constructor(){this.chunks=[]}update(e){this.chunks.push(e),this.chunks.push(`
2
+ `)}finalize(){return ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class Pd{constructor(e){e=e||{},this.decoder=e.decoder||new TextDecoder,this.maxChunkSize=100*1024,this.chunks=[],this.remainder=""}update(e){let t=this.decoder.decode(e);if(/[^a-zA-Z0-9+\/]/.test(t)&&(t=t.replace(/[^a-zA-Z0-9+\/]+/g,"")),this.remainder+=t,this.remainder.length>=this.maxChunkSize){let n=Math.floor(this.remainder.length/4)*4,s;n===this.remainder.length?(s=this.remainder,this.remainder=""):(s=this.remainder.substr(0,n),this.remainder=this.remainder.substr(n)),s.length&&this.chunks.push(Hi(s))}}finalize(){return this.remainder&&!/^=+$/.test(this.remainder)&&this.chunks.push(Hi(this.remainder)),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}const va=/^=[a-f0-9]{2}$/i,Id=/(?==[a-f0-9]{2})/i,Od=/=\r?\n/g,zd=/=[a-fA-F0-9]?$/;class $d{constructor(e){e=e||{},this.decoder=e.decoder||new TextDecoder,this.maxChunkSize=100*1024,this.remainder="",this.chunks=[]}decodeQPBytes(e){let t=new ArrayBuffer(e.length),n=new DataView(t);for(let s=0,i=e.length;s<i;s++)n.setUint8(s,parseInt(e[s],16));return t}decodeChunks(e){e=e.replace(Od,"");let t=e.split(Id),n=[];for(let s of t){if(s.charAt(0)!=="="){n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s);continue}if(s.length===3){va.test(s)?n.push(s.substr(1)):(n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s));continue}if(s.length>3){const i=s.substr(0,3);va.test(i)?(n.push(s.substr(1,2)),this.chunks.push(this.decodeQPBytes(n)),n=[],s=s.substr(3),this.chunks.push(s)):(n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s))}}n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[])}update(e){let t=this.decoder.decode(e)+`
3
+ `;if(t=this.remainder+t,t.length<this.maxChunkSize){this.remainder=t;return}this.remainder="";let n=t.match(zd);if(n){if(n.index===0){this.remainder=t;return}this.remainder=t.substr(n.index),t=t.substr(0,n.index)}this.decodeChunks(t)}finalize(){return this.remainder.length&&(this.decodeChunks(this.remainder),this.remainder=""),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class _a{constructor(e){if(this.options=e||{},this.postalMime=this.options.postalMime,this.root=!!this.options.parentNode,this.childNodes=[],this.options.parentNode){if(this.parentNode=this.options.parentNode,this.depth=this.parentNode.depth+1,this.depth>this.options.maxNestingDepth)throw new Error(`Maximum MIME nesting depth of ${this.options.maxNestingDepth} levels exceeded`);this.options.parentNode.childNodes.push(this)}else this.depth=0;this.state="header",this.headerLines=[],this.headerSize=0,this.contentType={value:"text/plain",default:!0},this.contentTransferEncoding={value:"8bit"},this.contentDisposition={value:""},this.headers=[],this.contentDecoder=!1}setupContentDecoder(e){/base64/i.test(e)?this.contentDecoder=new Pd:/quoted-printable/i.test(e)?this.contentDecoder=new $d({decoder:kn(this.contentType.parsed.params.charset)}):this.contentDecoder=new Ld}async finalize(){if(this.state==="finished")return;this.state==="header"&&this.processHeaders();let e=this.postalMime.boundaries;for(let t=e.length-1;t>=0;t--)if(e[t].node===this){e.splice(t,1);break}await this.finalizeChildNodes(),this.content=this.contentDecoder?await this.contentDecoder.finalize():null,this.state="finished"}async finalizeChildNodes(){for(let e of this.childNodes)await e.finalize()}parseStructuredHeader(e){let t={value:!1,params:{}},n=!1,s="",i="value",o=!1,l=!1,a;for(let u=0,c=e.length;u<c;u++)switch(a=e.charAt(u),i){case"key":if(a==="="){n=s.trim().toLowerCase(),i="value",s="";break}s+=a;break;case"value":if(l)s+=a;else if(a==="\\"){l=!0;continue}else o&&a===o?o=!1:!o&&a==='"'?o=a:!o&&a===";"?(n===!1?t.value=s.trim():t.params[n]=s.trim(),i="key",s=""):s+=a;l=!1;break}return s=s.trim(),i==="value"?n===!1?t.value=s:t.params[n]=s:s&&(t.params[s.toLowerCase()]=""),t.value&&(t.value=t.value.toLowerCase()),jd(t),t}decodeFlowedText(e,t){return e.split(/\r?\n/).reduce((n,s)=>/ $/.test(n)&&!/(^|\n)-- $/.test(n)?t?n.slice(0,-1)+s:n+s:n+`
4
+ `+s).replace(/^ /gm,"")}getTextContent(){if(!this.content)return"";let e=kn(this.contentType.parsed.params.charset).decode(this.content);return/^flowed$/i.test(this.contentType.parsed.params.format)&&(e=this.decodeFlowedText(e,/^yes$/i.test(this.contentType.parsed.params.delsp))),e}processHeaders(){for(let e=this.headerLines.length-1;e>=0;e--){let t=this.headerLines[e];if(e&&/^\s/.test(t))this.headerLines[e-1]+=`
5
+ `+t,this.headerLines.splice(e,1);else{t=t.replace(/\s+/g," ");let n=t.indexOf(":"),s=n<0?t.trim():t.substr(0,n).trim(),i=n<0?"":t.substr(n+1).trim();switch(this.headers.push({key:s.toLowerCase(),originalKey:s,value:i}),s.toLowerCase()){case"content-type":this.contentType.default&&(this.contentType={value:i,parsed:{}});break;case"content-transfer-encoding":this.contentTransferEncoding={value:i,parsed:{}};break;case"content-disposition":this.contentDisposition={value:i,parsed:{}};break;case"content-id":this.contentId=i;break;case"content-description":this.contentDescription=i;break}}}this.contentType.parsed=this.parseStructuredHeader(this.contentType.value),this.contentType.multipart=/^multipart\//i.test(this.contentType.parsed.value)?this.contentType.parsed.value.substr(this.contentType.parsed.value.indexOf("/")+1):!1,this.contentType.multipart&&this.contentType.parsed.params.boundary&&this.postalMime.boundaries.push({value:Jr.encode(this.contentType.parsed.params.boundary),node:this}),this.contentDisposition.parsed=this.parseStructuredHeader(this.contentDisposition.value),this.contentTransferEncoding.encoding=this.contentTransferEncoding.value.toLowerCase().split(/[^\w-]/).shift(),this.setupContentDecoder(this.contentTransferEncoding.encoding)}feed(e){switch(this.state){case"header":if(!e.length)return this.state="body",this.processHeaders();if(this.headerSize+=e.length,this.headerSize>this.options.maxHeadersSize)throw new Error(`Maximum header size of ${this.options.maxHeadersSize} bytes exceeded`);this.headerLines.push(kn().decode(e));break;case"body":this.contentDecoder.update(e)}}}const wa={"&AElig":"Æ","&AElig;":"Æ","&AMP":"&","&AMP;":"&","&Aacute":"Á","&Aacute;":"Á","&Abreve;":"Ă","&Acirc":"Â","&Acirc;":"Â","&Acy;":"А","&Afr;":"𝔄","&Agrave":"À","&Agrave;":"À","&Alpha;":"Α","&Amacr;":"Ā","&And;":"⩓","&Aogon;":"Ą","&Aopf;":"𝔸","&ApplyFunction;":"⁡","&Aring":"Å","&Aring;":"Å","&Ascr;":"𝒜","&Assign;":"≔","&Atilde":"Ã","&Atilde;":"Ã","&Auml":"Ä","&Auml;":"Ä","&Backslash;":"∖","&Barv;":"⫧","&Barwed;":"⌆","&Bcy;":"Б","&Because;":"∵","&Bernoullis;":"ℬ","&Beta;":"Β","&Bfr;":"𝔅","&Bopf;":"𝔹","&Breve;":"˘","&Bscr;":"ℬ","&Bumpeq;":"≎","&CHcy;":"Ч","&COPY":"©","&COPY;":"©","&Cacute;":"Ć","&Cap;":"⋒","&CapitalDifferentialD;":"ⅅ","&Cayleys;":"ℭ","&Ccaron;":"Č","&Ccedil":"Ç","&Ccedil;":"Ç","&Ccirc;":"Ĉ","&Cconint;":"∰","&Cdot;":"Ċ","&Cedilla;":"¸","&CenterDot;":"·","&Cfr;":"ℭ","&Chi;":"Χ","&CircleDot;":"⊙","&CircleMinus;":"⊖","&CirclePlus;":"⊕","&CircleTimes;":"⊗","&ClockwiseContourIntegral;":"∲","&CloseCurlyDoubleQuote;":"”","&CloseCurlyQuote;":"’","&Colon;":"∷","&Colone;":"⩴","&Congruent;":"≡","&Conint;":"∯","&ContourIntegral;":"∮","&Copf;":"ℂ","&Coproduct;":"∐","&CounterClockwiseContourIntegral;":"∳","&Cross;":"⨯","&Cscr;":"𝒞","&Cup;":"⋓","&CupCap;":"≍","&DD;":"ⅅ","&DDotrahd;":"⤑","&DJcy;":"Ђ","&DScy;":"Ѕ","&DZcy;":"Џ","&Dagger;":"‡","&Darr;":"↡","&Dashv;":"⫤","&Dcaron;":"Ď","&Dcy;":"Д","&Del;":"∇","&Delta;":"Δ","&Dfr;":"𝔇","&DiacriticalAcute;":"´","&DiacriticalDot;":"˙","&DiacriticalDoubleAcute;":"˝","&DiacriticalGrave;":"`","&DiacriticalTilde;":"˜","&Diamond;":"⋄","&DifferentialD;":"ⅆ","&Dopf;":"𝔻","&Dot;":"¨","&DotDot;":"⃜","&DotEqual;":"≐","&DoubleContourIntegral;":"∯","&DoubleDot;":"¨","&DoubleDownArrow;":"⇓","&DoubleLeftArrow;":"⇐","&DoubleLeftRightArrow;":"⇔","&DoubleLeftTee;":"⫤","&DoubleLongLeftArrow;":"⟸","&DoubleLongLeftRightArrow;":"⟺","&DoubleLongRightArrow;":"⟹","&DoubleRightArrow;":"⇒","&DoubleRightTee;":"⊨","&DoubleUpArrow;":"⇑","&DoubleUpDownArrow;":"⇕","&DoubleVerticalBar;":"∥","&DownArrow;":"↓","&DownArrowBar;":"⤓","&DownArrowUpArrow;":"⇵","&DownBreve;":"̑","&DownLeftRightVector;":"⥐","&DownLeftTeeVector;":"⥞","&DownLeftVector;":"↽","&DownLeftVectorBar;":"⥖","&DownRightTeeVector;":"⥟","&DownRightVector;":"⇁","&DownRightVectorBar;":"⥗","&DownTee;":"⊤","&DownTeeArrow;":"↧","&Downarrow;":"⇓","&Dscr;":"𝒟","&Dstrok;":"Đ","&ENG;":"Ŋ","&ETH":"Ð","&ETH;":"Ð","&Eacute":"É","&Eacute;":"É","&Ecaron;":"Ě","&Ecirc":"Ê","&Ecirc;":"Ê","&Ecy;":"Э","&Edot;":"Ė","&Efr;":"𝔈","&Egrave":"È","&Egrave;":"È","&Element;":"∈","&Emacr;":"Ē","&EmptySmallSquare;":"◻","&EmptyVerySmallSquare;":"▫","&Eogon;":"Ę","&Eopf;":"𝔼","&Epsilon;":"Ε","&Equal;":"⩵","&EqualTilde;":"≂","&Equilibrium;":"⇌","&Escr;":"ℰ","&Esim;":"⩳","&Eta;":"Η","&Euml":"Ë","&Euml;":"Ë","&Exists;":"∃","&ExponentialE;":"ⅇ","&Fcy;":"Ф","&Ffr;":"𝔉","&FilledSmallSquare;":"◼","&FilledVerySmallSquare;":"▪","&Fopf;":"𝔽","&ForAll;":"∀","&Fouriertrf;":"ℱ","&Fscr;":"ℱ","&GJcy;":"Ѓ","&GT":">","&GT;":">","&Gamma;":"Γ","&Gammad;":"Ϝ","&Gbreve;":"Ğ","&Gcedil;":"Ģ","&Gcirc;":"Ĝ","&Gcy;":"Г","&Gdot;":"Ġ","&Gfr;":"𝔊","&Gg;":"⋙","&Gopf;":"𝔾","&GreaterEqual;":"≥","&GreaterEqualLess;":"⋛","&GreaterFullEqual;":"≧","&GreaterGreater;":"⪢","&GreaterLess;":"≷","&GreaterSlantEqual;":"⩾","&GreaterTilde;":"≳","&Gscr;":"𝒢","&Gt;":"≫","&HARDcy;":"Ъ","&Hacek;":"ˇ","&Hat;":"^","&Hcirc;":"Ĥ","&Hfr;":"ℌ","&HilbertSpace;":"ℋ","&Hopf;":"ℍ","&HorizontalLine;":"─","&Hscr;":"ℋ","&Hstrok;":"Ħ","&HumpDownHump;":"≎","&HumpEqual;":"≏","&IEcy;":"Е","&IJlig;":"IJ","&IOcy;":"Ё","&Iacute":"Í","&Iacute;":"Í","&Icirc":"Î","&Icirc;":"Î","&Icy;":"И","&Idot;":"İ","&Ifr;":"ℑ","&Igrave":"Ì","&Igrave;":"Ì","&Im;":"ℑ","&Imacr;":"Ī","&ImaginaryI;":"ⅈ","&Implies;":"⇒","&Int;":"∬","&Integral;":"∫","&Intersection;":"⋂","&InvisibleComma;":"⁣","&InvisibleTimes;":"⁢","&Iogon;":"Į","&Iopf;":"𝕀","&Iota;":"Ι","&Iscr;":"ℐ","&Itilde;":"Ĩ","&Iukcy;":"І","&Iuml":"Ï","&Iuml;":"Ï","&Jcirc;":"Ĵ","&Jcy;":"Й","&Jfr;":"𝔍","&Jopf;":"𝕁","&Jscr;":"𝒥","&Jsercy;":"Ј","&Jukcy;":"Є","&KHcy;":"Х","&KJcy;":"Ќ","&Kappa;":"Κ","&Kcedil;":"Ķ","&Kcy;":"К","&Kfr;":"𝔎","&Kopf;":"𝕂","&Kscr;":"𝒦","&LJcy;":"Љ","&LT":"<","&LT;":"<","&Lacute;":"Ĺ","&Lambda;":"Λ","&Lang;":"⟪","&Laplacetrf;":"ℒ","&Larr;":"↞","&Lcaron;":"Ľ","&Lcedil;":"Ļ","&Lcy;":"Л","&LeftAngleBracket;":"⟨","&LeftArrow;":"←","&LeftArrowBar;":"⇤","&LeftArrowRightArrow;":"⇆","&LeftCeiling;":"⌈","&LeftDoubleBracket;":"⟦","&LeftDownTeeVector;":"⥡","&LeftDownVector;":"⇃","&LeftDownVectorBar;":"⥙","&LeftFloor;":"⌊","&LeftRightArrow;":"↔","&LeftRightVector;":"⥎","&LeftTee;":"⊣","&LeftTeeArrow;":"↤","&LeftTeeVector;":"⥚","&LeftTriangle;":"⊲","&LeftTriangleBar;":"⧏","&LeftTriangleEqual;":"⊴","&LeftUpDownVector;":"⥑","&LeftUpTeeVector;":"⥠","&LeftUpVector;":"↿","&LeftUpVectorBar;":"⥘","&LeftVector;":"↼","&LeftVectorBar;":"⥒","&Leftarrow;":"⇐","&Leftrightarrow;":"⇔","&LessEqualGreater;":"⋚","&LessFullEqual;":"≦","&LessGreater;":"≶","&LessLess;":"⪡","&LessSlantEqual;":"⩽","&LessTilde;":"≲","&Lfr;":"𝔏","&Ll;":"⋘","&Lleftarrow;":"⇚","&Lmidot;":"Ŀ","&LongLeftArrow;":"⟵","&LongLeftRightArrow;":"⟷","&LongRightArrow;":"⟶","&Longleftarrow;":"⟸","&Longleftrightarrow;":"⟺","&Longrightarrow;":"⟹","&Lopf;":"𝕃","&LowerLeftArrow;":"↙","&LowerRightArrow;":"↘","&Lscr;":"ℒ","&Lsh;":"↰","&Lstrok;":"Ł","&Lt;":"≪","&Map;":"⤅","&Mcy;":"М","&MediumSpace;":" ","&Mellintrf;":"ℳ","&Mfr;":"𝔐","&MinusPlus;":"∓","&Mopf;":"𝕄","&Mscr;":"ℳ","&Mu;":"Μ","&NJcy;":"Њ","&Nacute;":"Ń","&Ncaron;":"Ň","&Ncedil;":"Ņ","&Ncy;":"Н","&NegativeMediumSpace;":"​","&NegativeThickSpace;":"​","&NegativeThinSpace;":"​","&NegativeVeryThinSpace;":"​","&NestedGreaterGreater;":"≫","&NestedLessLess;":"≪","&NewLine;":`
6
+ `,"&Nfr;":"𝔑","&NoBreak;":"⁠","&NonBreakingSpace;":" ","&Nopf;":"ℕ","&Not;":"⫬","&NotCongruent;":"≢","&NotCupCap;":"≭","&NotDoubleVerticalBar;":"∦","&NotElement;":"∉","&NotEqual;":"≠","&NotEqualTilde;":"≂̸","&NotExists;":"∄","&NotGreater;":"≯","&NotGreaterEqual;":"≱","&NotGreaterFullEqual;":"≧̸","&NotGreaterGreater;":"≫̸","&NotGreaterLess;":"≹","&NotGreaterSlantEqual;":"⩾̸","&NotGreaterTilde;":"≵","&NotHumpDownHump;":"≎̸","&NotHumpEqual;":"≏̸","&NotLeftTriangle;":"⋪","&NotLeftTriangleBar;":"⧏̸","&NotLeftTriangleEqual;":"⋬","&NotLess;":"≮","&NotLessEqual;":"≰","&NotLessGreater;":"≸","&NotLessLess;":"≪̸","&NotLessSlantEqual;":"⩽̸","&NotLessTilde;":"≴","&NotNestedGreaterGreater;":"⪢̸","&NotNestedLessLess;":"⪡̸","&NotPrecedes;":"⊀","&NotPrecedesEqual;":"⪯̸","&NotPrecedesSlantEqual;":"⋠","&NotReverseElement;":"∌","&NotRightTriangle;":"⋫","&NotRightTriangleBar;":"⧐̸","&NotRightTriangleEqual;":"⋭","&NotSquareSubset;":"⊏̸","&NotSquareSubsetEqual;":"⋢","&NotSquareSuperset;":"⊐̸","&NotSquareSupersetEqual;":"⋣","&NotSubset;":"⊂⃒","&NotSubsetEqual;":"⊈","&NotSucceeds;":"⊁","&NotSucceedsEqual;":"⪰̸","&NotSucceedsSlantEqual;":"⋡","&NotSucceedsTilde;":"≿̸","&NotSuperset;":"⊃⃒","&NotSupersetEqual;":"⊉","&NotTilde;":"≁","&NotTildeEqual;":"≄","&NotTildeFullEqual;":"≇","&NotTildeTilde;":"≉","&NotVerticalBar;":"∤","&Nscr;":"𝒩","&Ntilde":"Ñ","&Ntilde;":"Ñ","&Nu;":"Ν","&OElig;":"Œ","&Oacute":"Ó","&Oacute;":"Ó","&Ocirc":"Ô","&Ocirc;":"Ô","&Ocy;":"О","&Odblac;":"Ő","&Ofr;":"𝔒","&Ograve":"Ò","&Ograve;":"Ò","&Omacr;":"Ō","&Omega;":"Ω","&Omicron;":"Ο","&Oopf;":"𝕆","&OpenCurlyDoubleQuote;":"“","&OpenCurlyQuote;":"‘","&Or;":"⩔","&Oscr;":"𝒪","&Oslash":"Ø","&Oslash;":"Ø","&Otilde":"Õ","&Otilde;":"Õ","&Otimes;":"⨷","&Ouml":"Ö","&Ouml;":"Ö","&OverBar;":"‾","&OverBrace;":"⏞","&OverBracket;":"⎴","&OverParenthesis;":"⏜","&PartialD;":"∂","&Pcy;":"П","&Pfr;":"𝔓","&Phi;":"Φ","&Pi;":"Π","&PlusMinus;":"±","&Poincareplane;":"ℌ","&Popf;":"ℙ","&Pr;":"⪻","&Precedes;":"≺","&PrecedesEqual;":"⪯","&PrecedesSlantEqual;":"≼","&PrecedesTilde;":"≾","&Prime;":"″","&Product;":"∏","&Proportion;":"∷","&Proportional;":"∝","&Pscr;":"𝒫","&Psi;":"Ψ","&QUOT":'"',"&QUOT;":'"',"&Qfr;":"𝔔","&Qopf;":"ℚ","&Qscr;":"𝒬","&RBarr;":"⤐","&REG":"®","&REG;":"®","&Racute;":"Ŕ","&Rang;":"⟫","&Rarr;":"↠","&Rarrtl;":"⤖","&Rcaron;":"Ř","&Rcedil;":"Ŗ","&Rcy;":"Р","&Re;":"ℜ","&ReverseElement;":"∋","&ReverseEquilibrium;":"⇋","&ReverseUpEquilibrium;":"⥯","&Rfr;":"ℜ","&Rho;":"Ρ","&RightAngleBracket;":"⟩","&RightArrow;":"→","&RightArrowBar;":"⇥","&RightArrowLeftArrow;":"⇄","&RightCeiling;":"⌉","&RightDoubleBracket;":"⟧","&RightDownTeeVector;":"⥝","&RightDownVector;":"⇂","&RightDownVectorBar;":"⥕","&RightFloor;":"⌋","&RightTee;":"⊢","&RightTeeArrow;":"↦","&RightTeeVector;":"⥛","&RightTriangle;":"⊳","&RightTriangleBar;":"⧐","&RightTriangleEqual;":"⊵","&RightUpDownVector;":"⥏","&RightUpTeeVector;":"⥜","&RightUpVector;":"↾","&RightUpVectorBar;":"⥔","&RightVector;":"⇀","&RightVectorBar;":"⥓","&Rightarrow;":"⇒","&Ropf;":"ℝ","&RoundImplies;":"⥰","&Rrightarrow;":"⇛","&Rscr;":"ℛ","&Rsh;":"↱","&RuleDelayed;":"⧴","&SHCHcy;":"Щ","&SHcy;":"Ш","&SOFTcy;":"Ь","&Sacute;":"Ś","&Sc;":"⪼","&Scaron;":"Š","&Scedil;":"Ş","&Scirc;":"Ŝ","&Scy;":"С","&Sfr;":"𝔖","&ShortDownArrow;":"↓","&ShortLeftArrow;":"←","&ShortRightArrow;":"→","&ShortUpArrow;":"↑","&Sigma;":"Σ","&SmallCircle;":"∘","&Sopf;":"𝕊","&Sqrt;":"√","&Square;":"□","&SquareIntersection;":"⊓","&SquareSubset;":"⊏","&SquareSubsetEqual;":"⊑","&SquareSuperset;":"⊐","&SquareSupersetEqual;":"⊒","&SquareUnion;":"⊔","&Sscr;":"𝒮","&Star;":"⋆","&Sub;":"⋐","&Subset;":"⋐","&SubsetEqual;":"⊆","&Succeeds;":"≻","&SucceedsEqual;":"⪰","&SucceedsSlantEqual;":"≽","&SucceedsTilde;":"≿","&SuchThat;":"∋","&Sum;":"∑","&Sup;":"⋑","&Superset;":"⊃","&SupersetEqual;":"⊇","&Supset;":"⋑","&THORN":"Þ","&THORN;":"Þ","&TRADE;":"™","&TSHcy;":"Ћ","&TScy;":"Ц","&Tab;":" ","&Tau;":"Τ","&Tcaron;":"Ť","&Tcedil;":"Ţ","&Tcy;":"Т","&Tfr;":"𝔗","&Therefore;":"∴","&Theta;":"Θ","&ThickSpace;":"  ","&ThinSpace;":" ","&Tilde;":"∼","&TildeEqual;":"≃","&TildeFullEqual;":"≅","&TildeTilde;":"≈","&Topf;":"𝕋","&TripleDot;":"⃛","&Tscr;":"𝒯","&Tstrok;":"Ŧ","&Uacute":"Ú","&Uacute;":"Ú","&Uarr;":"↟","&Uarrocir;":"⥉","&Ubrcy;":"Ў","&Ubreve;":"Ŭ","&Ucirc":"Û","&Ucirc;":"Û","&Ucy;":"У","&Udblac;":"Ű","&Ufr;":"𝔘","&Ugrave":"Ù","&Ugrave;":"Ù","&Umacr;":"Ū","&UnderBar;":"_","&UnderBrace;":"⏟","&UnderBracket;":"⎵","&UnderParenthesis;":"⏝","&Union;":"⋃","&UnionPlus;":"⊎","&Uogon;":"Ų","&Uopf;":"𝕌","&UpArrow;":"↑","&UpArrowBar;":"⤒","&UpArrowDownArrow;":"⇅","&UpDownArrow;":"↕","&UpEquilibrium;":"⥮","&UpTee;":"⊥","&UpTeeArrow;":"↥","&Uparrow;":"⇑","&Updownarrow;":"⇕","&UpperLeftArrow;":"↖","&UpperRightArrow;":"↗","&Upsi;":"ϒ","&Upsilon;":"Υ","&Uring;":"Ů","&Uscr;":"𝒰","&Utilde;":"Ũ","&Uuml":"Ü","&Uuml;":"Ü","&VDash;":"⊫","&Vbar;":"⫫","&Vcy;":"В","&Vdash;":"⊩","&Vdashl;":"⫦","&Vee;":"⋁","&Verbar;":"‖","&Vert;":"‖","&VerticalBar;":"∣","&VerticalLine;":"|","&VerticalSeparator;":"❘","&VerticalTilde;":"≀","&VeryThinSpace;":" ","&Vfr;":"𝔙","&Vopf;":"𝕍","&Vscr;":"𝒱","&Vvdash;":"⊪","&Wcirc;":"Ŵ","&Wedge;":"⋀","&Wfr;":"𝔚","&Wopf;":"𝕎","&Wscr;":"𝒲","&Xfr;":"𝔛","&Xi;":"Ξ","&Xopf;":"𝕏","&Xscr;":"𝒳","&YAcy;":"Я","&YIcy;":"Ї","&YUcy;":"Ю","&Yacute":"Ý","&Yacute;":"Ý","&Ycirc;":"Ŷ","&Ycy;":"Ы","&Yfr;":"𝔜","&Yopf;":"𝕐","&Yscr;":"𝒴","&Yuml;":"Ÿ","&ZHcy;":"Ж","&Zacute;":"Ź","&Zcaron;":"Ž","&Zcy;":"З","&Zdot;":"Ż","&ZeroWidthSpace;":"​","&Zeta;":"Ζ","&Zfr;":"ℨ","&Zopf;":"ℤ","&Zscr;":"𝒵","&aacute":"á","&aacute;":"á","&abreve;":"ă","&ac;":"∾","&acE;":"∾̳","&acd;":"∿","&acirc":"â","&acirc;":"â","&acute":"´","&acute;":"´","&acy;":"а","&aelig":"æ","&aelig;":"æ","&af;":"⁡","&afr;":"𝔞","&agrave":"à","&agrave;":"à","&alefsym;":"ℵ","&aleph;":"ℵ","&alpha;":"α","&amacr;":"ā","&amalg;":"⨿","&amp":"&","&amp;":"&","&and;":"∧","&andand;":"⩕","&andd;":"⩜","&andslope;":"⩘","&andv;":"⩚","&ang;":"∠","&ange;":"⦤","&angle;":"∠","&angmsd;":"∡","&angmsdaa;":"⦨","&angmsdab;":"⦩","&angmsdac;":"⦪","&angmsdad;":"⦫","&angmsdae;":"⦬","&angmsdaf;":"⦭","&angmsdag;":"⦮","&angmsdah;":"⦯","&angrt;":"∟","&angrtvb;":"⊾","&angrtvbd;":"⦝","&angsph;":"∢","&angst;":"Å","&angzarr;":"⍼","&aogon;":"ą","&aopf;":"𝕒","&ap;":"≈","&apE;":"⩰","&apacir;":"⩯","&ape;":"≊","&apid;":"≋","&apos;":"'","&approx;":"≈","&approxeq;":"≊","&aring":"å","&aring;":"å","&ascr;":"𝒶","&ast;":"*","&asymp;":"≈","&asympeq;":"≍","&atilde":"ã","&atilde;":"ã","&auml":"ä","&auml;":"ä","&awconint;":"∳","&awint;":"⨑","&bNot;":"⫭","&backcong;":"≌","&backepsilon;":"϶","&backprime;":"‵","&backsim;":"∽","&backsimeq;":"⋍","&barvee;":"⊽","&barwed;":"⌅","&barwedge;":"⌅","&bbrk;":"⎵","&bbrktbrk;":"⎶","&bcong;":"≌","&bcy;":"б","&bdquo;":"„","&becaus;":"∵","&because;":"∵","&bemptyv;":"⦰","&bepsi;":"϶","&bernou;":"ℬ","&beta;":"β","&beth;":"ℶ","&between;":"≬","&bfr;":"𝔟","&bigcap;":"⋂","&bigcirc;":"◯","&bigcup;":"⋃","&bigodot;":"⨀","&bigoplus;":"⨁","&bigotimes;":"⨂","&bigsqcup;":"⨆","&bigstar;":"★","&bigtriangledown;":"▽","&bigtriangleup;":"△","&biguplus;":"⨄","&bigvee;":"⋁","&bigwedge;":"⋀","&bkarow;":"⤍","&blacklozenge;":"⧫","&blacksquare;":"▪","&blacktriangle;":"▴","&blacktriangledown;":"▾","&blacktriangleleft;":"◂","&blacktriangleright;":"▸","&blank;":"␣","&blk12;":"▒","&blk14;":"░","&blk34;":"▓","&block;":"█","&bne;":"=⃥","&bnequiv;":"≡⃥","&bnot;":"⌐","&bopf;":"𝕓","&bot;":"⊥","&bottom;":"⊥","&bowtie;":"⋈","&boxDL;":"╗","&boxDR;":"╔","&boxDl;":"╖","&boxDr;":"╓","&boxH;":"═","&boxHD;":"╦","&boxHU;":"╩","&boxHd;":"╤","&boxHu;":"╧","&boxUL;":"╝","&boxUR;":"╚","&boxUl;":"╜","&boxUr;":"╙","&boxV;":"║","&boxVH;":"╬","&boxVL;":"╣","&boxVR;":"╠","&boxVh;":"╫","&boxVl;":"╢","&boxVr;":"╟","&boxbox;":"⧉","&boxdL;":"╕","&boxdR;":"╒","&boxdl;":"┐","&boxdr;":"┌","&boxh;":"─","&boxhD;":"╥","&boxhU;":"╨","&boxhd;":"┬","&boxhu;":"┴","&boxminus;":"⊟","&boxplus;":"⊞","&boxtimes;":"⊠","&boxuL;":"╛","&boxuR;":"╘","&boxul;":"┘","&boxur;":"└","&boxv;":"│","&boxvH;":"╪","&boxvL;":"╡","&boxvR;":"╞","&boxvh;":"┼","&boxvl;":"┤","&boxvr;":"├","&bprime;":"‵","&breve;":"˘","&brvbar":"¦","&brvbar;":"¦","&bscr;":"𝒷","&bsemi;":"⁏","&bsim;":"∽","&bsime;":"⋍","&bsol;":"\\","&bsolb;":"⧅","&bsolhsub;":"⟈","&bull;":"•","&bullet;":"•","&bump;":"≎","&bumpE;":"⪮","&bumpe;":"≏","&bumpeq;":"≏","&cacute;":"ć","&cap;":"∩","&capand;":"⩄","&capbrcup;":"⩉","&capcap;":"⩋","&capcup;":"⩇","&capdot;":"⩀","&caps;":"∩︀","&caret;":"⁁","&caron;":"ˇ","&ccaps;":"⩍","&ccaron;":"č","&ccedil":"ç","&ccedil;":"ç","&ccirc;":"ĉ","&ccups;":"⩌","&ccupssm;":"⩐","&cdot;":"ċ","&cedil":"¸","&cedil;":"¸","&cemptyv;":"⦲","&cent":"¢","&cent;":"¢","&centerdot;":"·","&cfr;":"𝔠","&chcy;":"ч","&check;":"✓","&checkmark;":"✓","&chi;":"χ","&cir;":"○","&cirE;":"⧃","&circ;":"ˆ","&circeq;":"≗","&circlearrowleft;":"↺","&circlearrowright;":"↻","&circledR;":"®","&circledS;":"Ⓢ","&circledast;":"⊛","&circledcirc;":"⊚","&circleddash;":"⊝","&cire;":"≗","&cirfnint;":"⨐","&cirmid;":"⫯","&cirscir;":"⧂","&clubs;":"♣","&clubsuit;":"♣","&colon;":":","&colone;":"≔","&coloneq;":"≔","&comma;":",","&commat;":"@","&comp;":"∁","&compfn;":"∘","&complement;":"∁","&complexes;":"ℂ","&cong;":"≅","&congdot;":"⩭","&conint;":"∮","&copf;":"𝕔","&coprod;":"∐","&copy":"©","&copy;":"©","&copysr;":"℗","&crarr;":"↵","&cross;":"✗","&cscr;":"𝒸","&csub;":"⫏","&csube;":"⫑","&csup;":"⫐","&csupe;":"⫒","&ctdot;":"⋯","&cudarrl;":"⤸","&cudarrr;":"⤵","&cuepr;":"⋞","&cuesc;":"⋟","&cularr;":"↶","&cularrp;":"⤽","&cup;":"∪","&cupbrcap;":"⩈","&cupcap;":"⩆","&cupcup;":"⩊","&cupdot;":"⊍","&cupor;":"⩅","&cups;":"∪︀","&curarr;":"↷","&curarrm;":"⤼","&curlyeqprec;":"⋞","&curlyeqsucc;":"⋟","&curlyvee;":"⋎","&curlywedge;":"⋏","&curren":"¤","&curren;":"¤","&curvearrowleft;":"↶","&curvearrowright;":"↷","&cuvee;":"⋎","&cuwed;":"⋏","&cwconint;":"∲","&cwint;":"∱","&cylcty;":"⌭","&dArr;":"⇓","&dHar;":"⥥","&dagger;":"†","&daleth;":"ℸ","&darr;":"↓","&dash;":"‐","&dashv;":"⊣","&dbkarow;":"⤏","&dblac;":"˝","&dcaron;":"ď","&dcy;":"д","&dd;":"ⅆ","&ddagger;":"‡","&ddarr;":"⇊","&ddotseq;":"⩷","&deg":"°","&deg;":"°","&delta;":"δ","&demptyv;":"⦱","&dfisht;":"⥿","&dfr;":"𝔡","&dharl;":"⇃","&dharr;":"⇂","&diam;":"⋄","&diamond;":"⋄","&diamondsuit;":"♦","&diams;":"♦","&die;":"¨","&digamma;":"ϝ","&disin;":"⋲","&div;":"÷","&divide":"÷","&divide;":"÷","&divideontimes;":"⋇","&divonx;":"⋇","&djcy;":"ђ","&dlcorn;":"⌞","&dlcrop;":"⌍","&dollar;":"$","&dopf;":"𝕕","&dot;":"˙","&doteq;":"≐","&doteqdot;":"≑","&dotminus;":"∸","&dotplus;":"∔","&dotsquare;":"⊡","&doublebarwedge;":"⌆","&downarrow;":"↓","&downdownarrows;":"⇊","&downharpoonleft;":"⇃","&downharpoonright;":"⇂","&drbkarow;":"⤐","&drcorn;":"⌟","&drcrop;":"⌌","&dscr;":"𝒹","&dscy;":"ѕ","&dsol;":"⧶","&dstrok;":"đ","&dtdot;":"⋱","&dtri;":"▿","&dtrif;":"▾","&duarr;":"⇵","&duhar;":"⥯","&dwangle;":"⦦","&dzcy;":"џ","&dzigrarr;":"⟿","&eDDot;":"⩷","&eDot;":"≑","&eacute":"é","&eacute;":"é","&easter;":"⩮","&ecaron;":"ě","&ecir;":"≖","&ecirc":"ê","&ecirc;":"ê","&ecolon;":"≕","&ecy;":"э","&edot;":"ė","&ee;":"ⅇ","&efDot;":"≒","&efr;":"𝔢","&eg;":"⪚","&egrave":"è","&egrave;":"è","&egs;":"⪖","&egsdot;":"⪘","&el;":"⪙","&elinters;":"⏧","&ell;":"ℓ","&els;":"⪕","&elsdot;":"⪗","&emacr;":"ē","&empty;":"∅","&emptyset;":"∅","&emptyv;":"∅","&emsp13;":" ","&emsp14;":" ","&emsp;":" ","&eng;":"ŋ","&ensp;":" ","&eogon;":"ę","&eopf;":"𝕖","&epar;":"⋕","&eparsl;":"⧣","&eplus;":"⩱","&epsi;":"ε","&epsilon;":"ε","&epsiv;":"ϵ","&eqcirc;":"≖","&eqcolon;":"≕","&eqsim;":"≂","&eqslantgtr;":"⪖","&eqslantless;":"⪕","&equals;":"=","&equest;":"≟","&equiv;":"≡","&equivDD;":"⩸","&eqvparsl;":"⧥","&erDot;":"≓","&erarr;":"⥱","&escr;":"ℯ","&esdot;":"≐","&esim;":"≂","&eta;":"η","&eth":"ð","&eth;":"ð","&euml":"ë","&euml;":"ë","&euro;":"€","&excl;":"!","&exist;":"∃","&expectation;":"ℰ","&exponentiale;":"ⅇ","&fallingdotseq;":"≒","&fcy;":"ф","&female;":"♀","&ffilig;":"ffi","&fflig;":"ff","&ffllig;":"ffl","&ffr;":"𝔣","&filig;":"fi","&fjlig;":"fj","&flat;":"♭","&fllig;":"fl","&fltns;":"▱","&fnof;":"ƒ","&fopf;":"𝕗","&forall;":"∀","&fork;":"⋔","&forkv;":"⫙","&fpartint;":"⨍","&frac12":"½","&frac12;":"½","&frac13;":"⅓","&frac14":"¼","&frac14;":"¼","&frac15;":"⅕","&frac16;":"⅙","&frac18;":"⅛","&frac23;":"⅔","&frac25;":"⅖","&frac34":"¾","&frac34;":"¾","&frac35;":"⅗","&frac38;":"⅜","&frac45;":"⅘","&frac56;":"⅚","&frac58;":"⅝","&frac78;":"⅞","&frasl;":"⁄","&frown;":"⌢","&fscr;":"𝒻","&gE;":"≧","&gEl;":"⪌","&gacute;":"ǵ","&gamma;":"γ","&gammad;":"ϝ","&gap;":"⪆","&gbreve;":"ğ","&gcirc;":"ĝ","&gcy;":"г","&gdot;":"ġ","&ge;":"≥","&gel;":"⋛","&geq;":"≥","&geqq;":"≧","&geqslant;":"⩾","&ges;":"⩾","&gescc;":"⪩","&gesdot;":"⪀","&gesdoto;":"⪂","&gesdotol;":"⪄","&gesl;":"⋛︀","&gesles;":"⪔","&gfr;":"𝔤","&gg;":"≫","&ggg;":"⋙","&gimel;":"ℷ","&gjcy;":"ѓ","&gl;":"≷","&glE;":"⪒","&gla;":"⪥","&glj;":"⪤","&gnE;":"≩","&gnap;":"⪊","&gnapprox;":"⪊","&gne;":"⪈","&gneq;":"⪈","&gneqq;":"≩","&gnsim;":"⋧","&gopf;":"𝕘","&grave;":"`","&gscr;":"ℊ","&gsim;":"≳","&gsime;":"⪎","&gsiml;":"⪐","&gt":">","&gt;":">","&gtcc;":"⪧","&gtcir;":"⩺","&gtdot;":"⋗","&gtlPar;":"⦕","&gtquest;":"⩼","&gtrapprox;":"⪆","&gtrarr;":"⥸","&gtrdot;":"⋗","&gtreqless;":"⋛","&gtreqqless;":"⪌","&gtrless;":"≷","&gtrsim;":"≳","&gvertneqq;":"≩︀","&gvnE;":"≩︀","&hArr;":"⇔","&hairsp;":" ","&half;":"½","&hamilt;":"ℋ","&hardcy;":"ъ","&harr;":"↔","&harrcir;":"⥈","&harrw;":"↭","&hbar;":"ℏ","&hcirc;":"ĥ","&hearts;":"♥","&heartsuit;":"♥","&hellip;":"…","&hercon;":"⊹","&hfr;":"𝔥","&hksearow;":"⤥","&hkswarow;":"⤦","&hoarr;":"⇿","&homtht;":"∻","&hookleftarrow;":"↩","&hookrightarrow;":"↪","&hopf;":"𝕙","&horbar;":"―","&hscr;":"𝒽","&hslash;":"ℏ","&hstrok;":"ħ","&hybull;":"⁃","&hyphen;":"‐","&iacute":"í","&iacute;":"í","&ic;":"⁣","&icirc":"î","&icirc;":"î","&icy;":"и","&iecy;":"е","&iexcl":"¡","&iexcl;":"¡","&iff;":"⇔","&ifr;":"𝔦","&igrave":"ì","&igrave;":"ì","&ii;":"ⅈ","&iiiint;":"⨌","&iiint;":"∭","&iinfin;":"⧜","&iiota;":"℩","&ijlig;":"ij","&imacr;":"ī","&image;":"ℑ","&imagline;":"ℐ","&imagpart;":"ℑ","&imath;":"ı","&imof;":"⊷","&imped;":"Ƶ","&in;":"∈","&incare;":"℅","&infin;":"∞","&infintie;":"⧝","&inodot;":"ı","&int;":"∫","&intcal;":"⊺","&integers;":"ℤ","&intercal;":"⊺","&intlarhk;":"⨗","&intprod;":"⨼","&iocy;":"ё","&iogon;":"į","&iopf;":"𝕚","&iota;":"ι","&iprod;":"⨼","&iquest":"¿","&iquest;":"¿","&iscr;":"𝒾","&isin;":"∈","&isinE;":"⋹","&isindot;":"⋵","&isins;":"⋴","&isinsv;":"⋳","&isinv;":"∈","&it;":"⁢","&itilde;":"ĩ","&iukcy;":"і","&iuml":"ï","&iuml;":"ï","&jcirc;":"ĵ","&jcy;":"й","&jfr;":"𝔧","&jmath;":"ȷ","&jopf;":"𝕛","&jscr;":"𝒿","&jsercy;":"ј","&jukcy;":"є","&kappa;":"κ","&kappav;":"ϰ","&kcedil;":"ķ","&kcy;":"к","&kfr;":"𝔨","&kgreen;":"ĸ","&khcy;":"х","&kjcy;":"ќ","&kopf;":"𝕜","&kscr;":"𝓀","&lAarr;":"⇚","&lArr;":"⇐","&lAtail;":"⤛","&lBarr;":"⤎","&lE;":"≦","&lEg;":"⪋","&lHar;":"⥢","&lacute;":"ĺ","&laemptyv;":"⦴","&lagran;":"ℒ","&lambda;":"λ","&lang;":"⟨","&langd;":"⦑","&langle;":"⟨","&lap;":"⪅","&laquo":"«","&laquo;":"«","&larr;":"←","&larrb;":"⇤","&larrbfs;":"⤟","&larrfs;":"⤝","&larrhk;":"↩","&larrlp;":"↫","&larrpl;":"⤹","&larrsim;":"⥳","&larrtl;":"↢","&lat;":"⪫","&latail;":"⤙","&late;":"⪭","&lates;":"⪭︀","&lbarr;":"⤌","&lbbrk;":"❲","&lbrace;":"{","&lbrack;":"[","&lbrke;":"⦋","&lbrksld;":"⦏","&lbrkslu;":"⦍","&lcaron;":"ľ","&lcedil;":"ļ","&lceil;":"⌈","&lcub;":"{","&lcy;":"л","&ldca;":"⤶","&ldquo;":"“","&ldquor;":"„","&ldrdhar;":"⥧","&ldrushar;":"⥋","&ldsh;":"↲","&le;":"≤","&leftarrow;":"←","&leftarrowtail;":"↢","&leftharpoondown;":"↽","&leftharpoonup;":"↼","&leftleftarrows;":"⇇","&leftrightarrow;":"↔","&leftrightarrows;":"⇆","&leftrightharpoons;":"⇋","&leftrightsquigarrow;":"↭","&leftthreetimes;":"⋋","&leg;":"⋚","&leq;":"≤","&leqq;":"≦","&leqslant;":"⩽","&les;":"⩽","&lescc;":"⪨","&lesdot;":"⩿","&lesdoto;":"⪁","&lesdotor;":"⪃","&lesg;":"⋚︀","&lesges;":"⪓","&lessapprox;":"⪅","&lessdot;":"⋖","&lesseqgtr;":"⋚","&lesseqqgtr;":"⪋","&lessgtr;":"≶","&lesssim;":"≲","&lfisht;":"⥼","&lfloor;":"⌊","&lfr;":"𝔩","&lg;":"≶","&lgE;":"⪑","&lhard;":"↽","&lharu;":"↼","&lharul;":"⥪","&lhblk;":"▄","&ljcy;":"љ","&ll;":"≪","&llarr;":"⇇","&llcorner;":"⌞","&llhard;":"⥫","&lltri;":"◺","&lmidot;":"ŀ","&lmoust;":"⎰","&lmoustache;":"⎰","&lnE;":"≨","&lnap;":"⪉","&lnapprox;":"⪉","&lne;":"⪇","&lneq;":"⪇","&lneqq;":"≨","&lnsim;":"⋦","&loang;":"⟬","&loarr;":"⇽","&lobrk;":"⟦","&longleftarrow;":"⟵","&longleftrightarrow;":"⟷","&longmapsto;":"⟼","&longrightarrow;":"⟶","&looparrowleft;":"↫","&looparrowright;":"↬","&lopar;":"⦅","&lopf;":"𝕝","&loplus;":"⨭","&lotimes;":"⨴","&lowast;":"∗","&lowbar;":"_","&loz;":"◊","&lozenge;":"◊","&lozf;":"⧫","&lpar;":"(","&lparlt;":"⦓","&lrarr;":"⇆","&lrcorner;":"⌟","&lrhar;":"⇋","&lrhard;":"⥭","&lrm;":"‎","&lrtri;":"⊿","&lsaquo;":"‹","&lscr;":"𝓁","&lsh;":"↰","&lsim;":"≲","&lsime;":"⪍","&lsimg;":"⪏","&lsqb;":"[","&lsquo;":"‘","&lsquor;":"‚","&lstrok;":"ł","&lt":"<","&lt;":"<","&ltcc;":"⪦","&ltcir;":"⩹","&ltdot;":"⋖","&lthree;":"⋋","&ltimes;":"⋉","&ltlarr;":"⥶","&ltquest;":"⩻","&ltrPar;":"⦖","&ltri;":"◃","&ltrie;":"⊴","&ltrif;":"◂","&lurdshar;":"⥊","&luruhar;":"⥦","&lvertneqq;":"≨︀","&lvnE;":"≨︀","&mDDot;":"∺","&macr":"¯","&macr;":"¯","&male;":"♂","&malt;":"✠","&maltese;":"✠","&map;":"↦","&mapsto;":"↦","&mapstodown;":"↧","&mapstoleft;":"↤","&mapstoup;":"↥","&marker;":"▮","&mcomma;":"⨩","&mcy;":"м","&mdash;":"—","&measuredangle;":"∡","&mfr;":"𝔪","&mho;":"℧","&micro":"µ","&micro;":"µ","&mid;":"∣","&midast;":"*","&midcir;":"⫰","&middot":"·","&middot;":"·","&minus;":"−","&minusb;":"⊟","&minusd;":"∸","&minusdu;":"⨪","&mlcp;":"⫛","&mldr;":"…","&mnplus;":"∓","&models;":"⊧","&mopf;":"𝕞","&mp;":"∓","&mscr;":"𝓂","&mstpos;":"∾","&mu;":"μ","&multimap;":"⊸","&mumap;":"⊸","&nGg;":"⋙̸","&nGt;":"≫⃒","&nGtv;":"≫̸","&nLeftarrow;":"⇍","&nLeftrightarrow;":"⇎","&nLl;":"⋘̸","&nLt;":"≪⃒","&nLtv;":"≪̸","&nRightarrow;":"⇏","&nVDash;":"⊯","&nVdash;":"⊮","&nabla;":"∇","&nacute;":"ń","&nang;":"∠⃒","&nap;":"≉","&napE;":"⩰̸","&napid;":"≋̸","&napos;":"ʼn","&napprox;":"≉","&natur;":"♮","&natural;":"♮","&naturals;":"ℕ","&nbsp":" ","&nbsp;":" ","&nbump;":"≎̸","&nbumpe;":"≏̸","&ncap;":"⩃","&ncaron;":"ň","&ncedil;":"ņ","&ncong;":"≇","&ncongdot;":"⩭̸","&ncup;":"⩂","&ncy;":"н","&ndash;":"–","&ne;":"≠","&neArr;":"⇗","&nearhk;":"⤤","&nearr;":"↗","&nearrow;":"↗","&nedot;":"≐̸","&nequiv;":"≢","&nesear;":"⤨","&nesim;":"≂̸","&nexist;":"∄","&nexists;":"∄","&nfr;":"𝔫","&ngE;":"≧̸","&nge;":"≱","&ngeq;":"≱","&ngeqq;":"≧̸","&ngeqslant;":"⩾̸","&nges;":"⩾̸","&ngsim;":"≵","&ngt;":"≯","&ngtr;":"≯","&nhArr;":"⇎","&nharr;":"↮","&nhpar;":"⫲","&ni;":"∋","&nis;":"⋼","&nisd;":"⋺","&niv;":"∋","&njcy;":"њ","&nlArr;":"⇍","&nlE;":"≦̸","&nlarr;":"↚","&nldr;":"‥","&nle;":"≰","&nleftarrow;":"↚","&nleftrightarrow;":"↮","&nleq;":"≰","&nleqq;":"≦̸","&nleqslant;":"⩽̸","&nles;":"⩽̸","&nless;":"≮","&nlsim;":"≴","&nlt;":"≮","&nltri;":"⋪","&nltrie;":"⋬","&nmid;":"∤","&nopf;":"𝕟","&not":"¬","&not;":"¬","&notin;":"∉","&notinE;":"⋹̸","&notindot;":"⋵̸","&notinva;":"∉","&notinvb;":"⋷","&notinvc;":"⋶","&notni;":"∌","&notniva;":"∌","&notnivb;":"⋾","&notnivc;":"⋽","&npar;":"∦","&nparallel;":"∦","&nparsl;":"⫽⃥","&npart;":"∂̸","&npolint;":"⨔","&npr;":"⊀","&nprcue;":"⋠","&npre;":"⪯̸","&nprec;":"⊀","&npreceq;":"⪯̸","&nrArr;":"⇏","&nrarr;":"↛","&nrarrc;":"⤳̸","&nrarrw;":"↝̸","&nrightarrow;":"↛","&nrtri;":"⋫","&nrtrie;":"⋭","&nsc;":"⊁","&nsccue;":"⋡","&nsce;":"⪰̸","&nscr;":"𝓃","&nshortmid;":"∤","&nshortparallel;":"∦","&nsim;":"≁","&nsime;":"≄","&nsimeq;":"≄","&nsmid;":"∤","&nspar;":"∦","&nsqsube;":"⋢","&nsqsupe;":"⋣","&nsub;":"⊄","&nsubE;":"⫅̸","&nsube;":"⊈","&nsubset;":"⊂⃒","&nsubseteq;":"⊈","&nsubseteqq;":"⫅̸","&nsucc;":"⊁","&nsucceq;":"⪰̸","&nsup;":"⊅","&nsupE;":"⫆̸","&nsupe;":"⊉","&nsupset;":"⊃⃒","&nsupseteq;":"⊉","&nsupseteqq;":"⫆̸","&ntgl;":"≹","&ntilde":"ñ","&ntilde;":"ñ","&ntlg;":"≸","&ntriangleleft;":"⋪","&ntrianglelefteq;":"⋬","&ntriangleright;":"⋫","&ntrianglerighteq;":"⋭","&nu;":"ν","&num;":"#","&numero;":"№","&numsp;":" ","&nvDash;":"⊭","&nvHarr;":"⤄","&nvap;":"≍⃒","&nvdash;":"⊬","&nvge;":"≥⃒","&nvgt;":">⃒","&nvinfin;":"⧞","&nvlArr;":"⤂","&nvle;":"≤⃒","&nvlt;":"<⃒","&nvltrie;":"⊴⃒","&nvrArr;":"⤃","&nvrtrie;":"⊵⃒","&nvsim;":"∼⃒","&nwArr;":"⇖","&nwarhk;":"⤣","&nwarr;":"↖","&nwarrow;":"↖","&nwnear;":"⤧","&oS;":"Ⓢ","&oacute":"ó","&oacute;":"ó","&oast;":"⊛","&ocir;":"⊚","&ocirc":"ô","&ocirc;":"ô","&ocy;":"о","&odash;":"⊝","&odblac;":"ő","&odiv;":"⨸","&odot;":"⊙","&odsold;":"⦼","&oelig;":"œ","&ofcir;":"⦿","&ofr;":"𝔬","&ogon;":"˛","&ograve":"ò","&ograve;":"ò","&ogt;":"⧁","&ohbar;":"⦵","&ohm;":"Ω","&oint;":"∮","&olarr;":"↺","&olcir;":"⦾","&olcross;":"⦻","&oline;":"‾","&olt;":"⧀","&omacr;":"ō","&omega;":"ω","&omicron;":"ο","&omid;":"⦶","&ominus;":"⊖","&oopf;":"𝕠","&opar;":"⦷","&operp;":"⦹","&oplus;":"⊕","&or;":"∨","&orarr;":"↻","&ord;":"⩝","&order;":"ℴ","&orderof;":"ℴ","&ordf":"ª","&ordf;":"ª","&ordm":"º","&ordm;":"º","&origof;":"⊶","&oror;":"⩖","&orslope;":"⩗","&orv;":"⩛","&oscr;":"ℴ","&oslash":"ø","&oslash;":"ø","&osol;":"⊘","&otilde":"õ","&otilde;":"õ","&otimes;":"⊗","&otimesas;":"⨶","&ouml":"ö","&ouml;":"ö","&ovbar;":"⌽","&par;":"∥","&para":"¶","&para;":"¶","&parallel;":"∥","&parsim;":"⫳","&parsl;":"⫽","&part;":"∂","&pcy;":"п","&percnt;":"%","&period;":".","&permil;":"‰","&perp;":"⊥","&pertenk;":"‱","&pfr;":"𝔭","&phi;":"φ","&phiv;":"ϕ","&phmmat;":"ℳ","&phone;":"☎","&pi;":"π","&pitchfork;":"⋔","&piv;":"ϖ","&planck;":"ℏ","&planckh;":"ℎ","&plankv;":"ℏ","&plus;":"+","&plusacir;":"⨣","&plusb;":"⊞","&pluscir;":"⨢","&plusdo;":"∔","&plusdu;":"⨥","&pluse;":"⩲","&plusmn":"±","&plusmn;":"±","&plussim;":"⨦","&plustwo;":"⨧","&pm;":"±","&pointint;":"⨕","&popf;":"𝕡","&pound":"£","&pound;":"£","&pr;":"≺","&prE;":"⪳","&prap;":"⪷","&prcue;":"≼","&pre;":"⪯","&prec;":"≺","&precapprox;":"⪷","&preccurlyeq;":"≼","&preceq;":"⪯","&precnapprox;":"⪹","&precneqq;":"⪵","&precnsim;":"⋨","&precsim;":"≾","&prime;":"′","&primes;":"ℙ","&prnE;":"⪵","&prnap;":"⪹","&prnsim;":"⋨","&prod;":"∏","&profalar;":"⌮","&profline;":"⌒","&profsurf;":"⌓","&prop;":"∝","&propto;":"∝","&prsim;":"≾","&prurel;":"⊰","&pscr;":"𝓅","&psi;":"ψ","&puncsp;":" ","&qfr;":"𝔮","&qint;":"⨌","&qopf;":"𝕢","&qprime;":"⁗","&qscr;":"𝓆","&quaternions;":"ℍ","&quatint;":"⨖","&quest;":"?","&questeq;":"≟","&quot":'"',"&quot;":'"',"&rAarr;":"⇛","&rArr;":"⇒","&rAtail;":"⤜","&rBarr;":"⤏","&rHar;":"⥤","&race;":"∽̱","&racute;":"ŕ","&radic;":"√","&raemptyv;":"⦳","&rang;":"⟩","&rangd;":"⦒","&range;":"⦥","&rangle;":"⟩","&raquo":"»","&raquo;":"»","&rarr;":"→","&rarrap;":"⥵","&rarrb;":"⇥","&rarrbfs;":"⤠","&rarrc;":"⤳","&rarrfs;":"⤞","&rarrhk;":"↪","&rarrlp;":"↬","&rarrpl;":"⥅","&rarrsim;":"⥴","&rarrtl;":"↣","&rarrw;":"↝","&ratail;":"⤚","&ratio;":"∶","&rationals;":"ℚ","&rbarr;":"⤍","&rbbrk;":"❳","&rbrace;":"}","&rbrack;":"]","&rbrke;":"⦌","&rbrksld;":"⦎","&rbrkslu;":"⦐","&rcaron;":"ř","&rcedil;":"ŗ","&rceil;":"⌉","&rcub;":"}","&rcy;":"р","&rdca;":"⤷","&rdldhar;":"⥩","&rdquo;":"”","&rdquor;":"”","&rdsh;":"↳","&real;":"ℜ","&realine;":"ℛ","&realpart;":"ℜ","&reals;":"ℝ","&rect;":"▭","&reg":"®","&reg;":"®","&rfisht;":"⥽","&rfloor;":"⌋","&rfr;":"𝔯","&rhard;":"⇁","&rharu;":"⇀","&rharul;":"⥬","&rho;":"ρ","&rhov;":"ϱ","&rightarrow;":"→","&rightarrowtail;":"↣","&rightharpoondown;":"⇁","&rightharpoonup;":"⇀","&rightleftarrows;":"⇄","&rightleftharpoons;":"⇌","&rightrightarrows;":"⇉","&rightsquigarrow;":"↝","&rightthreetimes;":"⋌","&ring;":"˚","&risingdotseq;":"≓","&rlarr;":"⇄","&rlhar;":"⇌","&rlm;":"‏","&rmoust;":"⎱","&rmoustache;":"⎱","&rnmid;":"⫮","&roang;":"⟭","&roarr;":"⇾","&robrk;":"⟧","&ropar;":"⦆","&ropf;":"𝕣","&roplus;":"⨮","&rotimes;":"⨵","&rpar;":")","&rpargt;":"⦔","&rppolint;":"⨒","&rrarr;":"⇉","&rsaquo;":"›","&rscr;":"𝓇","&rsh;":"↱","&rsqb;":"]","&rsquo;":"’","&rsquor;":"’","&rthree;":"⋌","&rtimes;":"⋊","&rtri;":"▹","&rtrie;":"⊵","&rtrif;":"▸","&rtriltri;":"⧎","&ruluhar;":"⥨","&rx;":"℞","&sacute;":"ś","&sbquo;":"‚","&sc;":"≻","&scE;":"⪴","&scap;":"⪸","&scaron;":"š","&sccue;":"≽","&sce;":"⪰","&scedil;":"ş","&scirc;":"ŝ","&scnE;":"⪶","&scnap;":"⪺","&scnsim;":"⋩","&scpolint;":"⨓","&scsim;":"≿","&scy;":"с","&sdot;":"⋅","&sdotb;":"⊡","&sdote;":"⩦","&seArr;":"⇘","&searhk;":"⤥","&searr;":"↘","&searrow;":"↘","&sect":"§","&sect;":"§","&semi;":";","&seswar;":"⤩","&setminus;":"∖","&setmn;":"∖","&sext;":"✶","&sfr;":"𝔰","&sfrown;":"⌢","&sharp;":"♯","&shchcy;":"щ","&shcy;":"ш","&shortmid;":"∣","&shortparallel;":"∥","&shy":"­","&shy;":"­","&sigma;":"σ","&sigmaf;":"ς","&sigmav;":"ς","&sim;":"∼","&simdot;":"⩪","&sime;":"≃","&simeq;":"≃","&simg;":"⪞","&simgE;":"⪠","&siml;":"⪝","&simlE;":"⪟","&simne;":"≆","&simplus;":"⨤","&simrarr;":"⥲","&slarr;":"←","&smallsetminus;":"∖","&smashp;":"⨳","&smeparsl;":"⧤","&smid;":"∣","&smile;":"⌣","&smt;":"⪪","&smte;":"⪬","&smtes;":"⪬︀","&softcy;":"ь","&sol;":"/","&solb;":"⧄","&solbar;":"⌿","&sopf;":"𝕤","&spades;":"♠","&spadesuit;":"♠","&spar;":"∥","&sqcap;":"⊓","&sqcaps;":"⊓︀","&sqcup;":"⊔","&sqcups;":"⊔︀","&sqsub;":"⊏","&sqsube;":"⊑","&sqsubset;":"⊏","&sqsubseteq;":"⊑","&sqsup;":"⊐","&sqsupe;":"⊒","&sqsupset;":"⊐","&sqsupseteq;":"⊒","&squ;":"□","&square;":"□","&squarf;":"▪","&squf;":"▪","&srarr;":"→","&sscr;":"𝓈","&ssetmn;":"∖","&ssmile;":"⌣","&sstarf;":"⋆","&star;":"☆","&starf;":"★","&straightepsilon;":"ϵ","&straightphi;":"ϕ","&strns;":"¯","&sub;":"⊂","&subE;":"⫅","&subdot;":"⪽","&sube;":"⊆","&subedot;":"⫃","&submult;":"⫁","&subnE;":"⫋","&subne;":"⊊","&subplus;":"⪿","&subrarr;":"⥹","&subset;":"⊂","&subseteq;":"⊆","&subseteqq;":"⫅","&subsetneq;":"⊊","&subsetneqq;":"⫋","&subsim;":"⫇","&subsub;":"⫕","&subsup;":"⫓","&succ;":"≻","&succapprox;":"⪸","&succcurlyeq;":"≽","&succeq;":"⪰","&succnapprox;":"⪺","&succneqq;":"⪶","&succnsim;":"⋩","&succsim;":"≿","&sum;":"∑","&sung;":"♪","&sup1":"¹","&sup1;":"¹","&sup2":"²","&sup2;":"²","&sup3":"³","&sup3;":"³","&sup;":"⊃","&supE;":"⫆","&supdot;":"⪾","&supdsub;":"⫘","&supe;":"⊇","&supedot;":"⫄","&suphsol;":"⟉","&suphsub;":"⫗","&suplarr;":"⥻","&supmult;":"⫂","&supnE;":"⫌","&supne;":"⊋","&supplus;":"⫀","&supset;":"⊃","&supseteq;":"⊇","&supseteqq;":"⫆","&supsetneq;":"⊋","&supsetneqq;":"⫌","&supsim;":"⫈","&supsub;":"⫔","&supsup;":"⫖","&swArr;":"⇙","&swarhk;":"⤦","&swarr;":"↙","&swarrow;":"↙","&swnwar;":"⤪","&szlig":"ß","&szlig;":"ß","&target;":"⌖","&tau;":"τ","&tbrk;":"⎴","&tcaron;":"ť","&tcedil;":"ţ","&tcy;":"т","&tdot;":"⃛","&telrec;":"⌕","&tfr;":"𝔱","&there4;":"∴","&therefore;":"∴","&theta;":"θ","&thetasym;":"ϑ","&thetav;":"ϑ","&thickapprox;":"≈","&thicksim;":"∼","&thinsp;":" ","&thkap;":"≈","&thksim;":"∼","&thorn":"þ","&thorn;":"þ","&tilde;":"˜","&times":"×","&times;":"×","&timesb;":"⊠","&timesbar;":"⨱","&timesd;":"⨰","&tint;":"∭","&toea;":"⤨","&top;":"⊤","&topbot;":"⌶","&topcir;":"⫱","&topf;":"𝕥","&topfork;":"⫚","&tosa;":"⤩","&tprime;":"‴","&trade;":"™","&triangle;":"▵","&triangledown;":"▿","&triangleleft;":"◃","&trianglelefteq;":"⊴","&triangleq;":"≜","&triangleright;":"▹","&trianglerighteq;":"⊵","&tridot;":"◬","&trie;":"≜","&triminus;":"⨺","&triplus;":"⨹","&trisb;":"⧍","&tritime;":"⨻","&trpezium;":"⏢","&tscr;":"𝓉","&tscy;":"ц","&tshcy;":"ћ","&tstrok;":"ŧ","&twixt;":"≬","&twoheadleftarrow;":"↞","&twoheadrightarrow;":"↠","&uArr;":"⇑","&uHar;":"⥣","&uacute":"ú","&uacute;":"ú","&uarr;":"↑","&ubrcy;":"ў","&ubreve;":"ŭ","&ucirc":"û","&ucirc;":"û","&ucy;":"у","&udarr;":"⇅","&udblac;":"ű","&udhar;":"⥮","&ufisht;":"⥾","&ufr;":"𝔲","&ugrave":"ù","&ugrave;":"ù","&uharl;":"↿","&uharr;":"↾","&uhblk;":"▀","&ulcorn;":"⌜","&ulcorner;":"⌜","&ulcrop;":"⌏","&ultri;":"◸","&umacr;":"ū","&uml":"¨","&uml;":"¨","&uogon;":"ų","&uopf;":"𝕦","&uparrow;":"↑","&updownarrow;":"↕","&upharpoonleft;":"↿","&upharpoonright;":"↾","&uplus;":"⊎","&upsi;":"υ","&upsih;":"ϒ","&upsilon;":"υ","&upuparrows;":"⇈","&urcorn;":"⌝","&urcorner;":"⌝","&urcrop;":"⌎","&uring;":"ů","&urtri;":"◹","&uscr;":"𝓊","&utdot;":"⋰","&utilde;":"ũ","&utri;":"▵","&utrif;":"▴","&uuarr;":"⇈","&uuml":"ü","&uuml;":"ü","&uwangle;":"⦧","&vArr;":"⇕","&vBar;":"⫨","&vBarv;":"⫩","&vDash;":"⊨","&vangrt;":"⦜","&varepsilon;":"ϵ","&varkappa;":"ϰ","&varnothing;":"∅","&varphi;":"ϕ","&varpi;":"ϖ","&varpropto;":"∝","&varr;":"↕","&varrho;":"ϱ","&varsigma;":"ς","&varsubsetneq;":"⊊︀","&varsubsetneqq;":"⫋︀","&varsupsetneq;":"⊋︀","&varsupsetneqq;":"⫌︀","&vartheta;":"ϑ","&vartriangleleft;":"⊲","&vartriangleright;":"⊳","&vcy;":"в","&vdash;":"⊢","&vee;":"∨","&veebar;":"⊻","&veeeq;":"≚","&vellip;":"⋮","&verbar;":"|","&vert;":"|","&vfr;":"𝔳","&vltri;":"⊲","&vnsub;":"⊂⃒","&vnsup;":"⊃⃒","&vopf;":"𝕧","&vprop;":"∝","&vrtri;":"⊳","&vscr;":"𝓋","&vsubnE;":"⫋︀","&vsubne;":"⊊︀","&vsupnE;":"⫌︀","&vsupne;":"⊋︀","&vzigzag;":"⦚","&wcirc;":"ŵ","&wedbar;":"⩟","&wedge;":"∧","&wedgeq;":"≙","&weierp;":"℘","&wfr;":"𝔴","&wopf;":"𝕨","&wp;":"℘","&wr;":"≀","&wreath;":"≀","&wscr;":"𝓌","&xcap;":"⋂","&xcirc;":"◯","&xcup;":"⋃","&xdtri;":"▽","&xfr;":"𝔵","&xhArr;":"⟺","&xharr;":"⟷","&xi;":"ξ","&xlArr;":"⟸","&xlarr;":"⟵","&xmap;":"⟼","&xnis;":"⋻","&xodot;":"⨀","&xopf;":"𝕩","&xoplus;":"⨁","&xotime;":"⨂","&xrArr;":"⟹","&xrarr;":"⟶","&xscr;":"𝓍","&xsqcup;":"⨆","&xuplus;":"⨄","&xutri;":"△","&xvee;":"⋁","&xwedge;":"⋀","&yacute":"ý","&yacute;":"ý","&yacy;":"я","&ycirc;":"ŷ","&ycy;":"ы","&yen":"¥","&yen;":"¥","&yfr;":"𝔶","&yicy;":"ї","&yopf;":"𝕪","&yscr;":"𝓎","&yucy;":"ю","&yuml":"ÿ","&yuml;":"ÿ","&zacute;":"ź","&zcaron;":"ž","&zcy;":"з","&zdot;":"ż","&zeetrf;":"ℨ","&zeta;":"ζ","&zfr;":"𝔷","&zhcy;":"ж","&zigrarr;":"⇝","&zopf;":"𝕫","&zscr;":"𝓏","&zwj;":"‍","&zwnj;":"‌"};function qd(r){return r.replace(/&(#\d+|#x[a-f0-9]+|[a-z]+\d*);?/gi,(e,t)=>{if(typeof wa[e]=="string")return wa[e];if(t.charAt(0)!=="#"||e.charAt(e.length-1)!==";")return e;let n;t.charAt(1)==="x"?n=parseInt(t.substr(2),16):n=parseInt(t.substr(1),10);var s="";return n>=55296&&n<=57343||n>1114111?"�":(n>65535&&(n-=65536,s+=String.fromCharCode(n>>>10&1023|55296),n=56320|n&1023),s+=String.fromCharCode(n),s)})}function kr(r){return r.trim().replace(/[<>"'?&]/g,e=>{let t=e.charCodeAt(0).toString(16);return t.length<2&&(t="0"+t),"&#x"+t.toUpperCase()+";"})}function Ud(r){return"<div>"+kr(r).replace(/\n/g,"<br />")+"</div>"}function Wd(r){return r=r.replace(/\r?\n/g,"").replace(/<\!\-\-.*?\-\->/gi," ").replace(/<br\b[^>]*>/gi,`
7
7
  `).replace(/<\/?(p|div|table|tr|td|th)\b[^>]*>/gi,`
8
8
 
9
9
  `).replace(/<script\b[^>]*>.*?<\/script\b[^>]*>/gi," ").replace(/^.*<body\b[^>]*>/i,"").replace(/^.*<\/head\b[^>]*>/i,"").replace(/^.*<\!doctype\b[^>]*>/i,"").replace(/<\/body\b[^>]*>.*$/i,"").replace(/<\/html\b[^>]*>.*$/i,"").replace(/<a\b[^>]*href\s*=\s*["']?([^\s"']+)[^>]*>/gi," ($1) ").replace(/<\/?(span|em|i|strong|b|u|a)\b[^>]*>/gi,"").replace(/<li\b[^>]*>[\n\u0001\s]*/gi,"* ").replace(/<hr\b[^>]*>/g,`
@@ -13,19 +13,19 @@
13
13
 
14
14
  `).replace(/^\n+/,`
15
15
  `).replace(/\n+$/,`
16
- `),r=$d(r),r}function ru(r){return[].concat(r.name||[]).concat(r.name?`<${r.address}>`:r.address).join(" ")}function ki(r){let e=[],t=(n,s)=>{if(s&&e.push(", "),n.group){let i=`${n.name}:`,o=";";e.push(i),n.group.forEach(t),e.push(o)}else e.push(ru(n))};return r.forEach(t),e.join("")}function nu(r){return`<a href="mailto:${Er(r.address)}" class="postal-email-address">${Er(r.name||`<${r.address}>`)}</a>`}function Di(r){let e=[],t=(n,s)=>{if(s&&e.push('<span class="postal-email-address-separator">, </span>'),n.group){let i=`<span class="postal-email-address-group">${Er(n.name)}:</span>`,o='<span class="postal-email-address-group">;</span>';e.push(i),n.group.forEach(t),e.push(o)}else e.push(nu(n))};return r.forEach(t),e.join(" ")}function Wd(r,e,t){r=(r||"").toString(),e=e||76;let n=0,s=r.length,i="",o,l;for(;n<s;){if(o=r.substr(n,e),o.length<e){i+=o;break}if(l=o.match(/^[^\n\r]*(\r?\n|\r)/)){o=l[0],i+=o,n+=o.length;continue}else(l=o.match(/(\s+)[^\s]*$/))&&l[0].length-(l[1]||"").length<o.length?o=o.substr(0,o.length-(l[0].length-(l[1]||"").length)):(l=r.substr(n+o.length).match(/^[^\s]+(\s*)/))&&(o=o+l[0].substr(0,l[0].length-0));i+=o,n+=o.length,n<s&&(i+=`\r
17
- `)}return i}function wa(r){let e=[];if(r.from&&e.push({key:"From",val:ru(r.from)}),r.subject&&e.push({key:"Subject",val:r.subject}),r.date){let o={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},l=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",o).format(new Date(r.date));e.push({key:"Date",val:l})}r.to&&r.to.length&&e.push({key:"To",val:ki(r.to)}),r.cc&&r.cc.length&&e.push({key:"Cc",val:ki(r.cc)}),r.bcc&&r.bcc.length&&e.push({key:"Bcc",val:ki(r.bcc)});let t=e.map(o=>o.key.length).reduce((o,l)=>l>o?l:o,0);e=e.flatMap(o=>{let l=t-o.key.length,a=`${o.key}: ${" ".repeat(l)}`,u=`${" ".repeat(o.key.length+1)} ${" ".repeat(l)}`;return Wd(o.val,80).split(/\r?\n/).map(d=>d.trim()).map((d,f)=>`${f?u:a}${d}`)});let n=e.map(o=>o.length).reduce((o,l)=>l>o?l:o,0),s="-".repeat(n);return`
16
+ `),r=qd(r),r}function nu(r){return[].concat(r.name||[]).concat(r.name?`<${r.address}>`:r.address).join(" ")}function Ei(r){let e=[],t=(n,s)=>{if(s&&e.push(", "),n.group){let i=`${n.name}:`,o=";";e.push(i),n.group.forEach(t),e.push(o)}else e.push(nu(n))};return r.forEach(t),e.join("")}function su(r){return`<a href="mailto:${kr(r.address)}" class="postal-email-address">${kr(r.name||`<${r.address}>`)}</a>`}function Di(r){let e=[],t=(n,s)=>{if(s&&e.push('<span class="postal-email-address-separator">, </span>'),n.group){let i=`<span class="postal-email-address-group">${kr(n.name)}:</span>`,o='<span class="postal-email-address-group">;</span>';e.push(i),n.group.forEach(t),e.push(o)}else e.push(su(n))};return r.forEach(t),e.join(" ")}function Vd(r,e,t){r=(r||"").toString(),e=e||76;let n=0,s=r.length,i="",o,l;for(;n<s;){if(o=r.substr(n,e),o.length<e){i+=o;break}if(l=o.match(/^[^\n\r]*(\r?\n|\r)/)){o=l[0],i+=o,n+=o.length;continue}else(l=o.match(/(\s+)[^\s]*$/))&&l[0].length-(l[1]||"").length<o.length?o=o.substr(0,o.length-(l[0].length-(l[1]||"").length)):(l=r.substr(n+o.length).match(/^[^\s]+(\s*)/))&&(o=o+l[0].substr(0,l[0].length-0));i+=o,n+=o.length,n<s&&(i+=`\r
17
+ `)}return i}function Ca(r){let e=[];if(r.from&&e.push({key:"From",val:nu(r.from)}),r.subject&&e.push({key:"Subject",val:r.subject}),r.date){let o={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},l=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",o).format(new Date(r.date));e.push({key:"Date",val:l})}r.to&&r.to.length&&e.push({key:"To",val:Ei(r.to)}),r.cc&&r.cc.length&&e.push({key:"Cc",val:Ei(r.cc)}),r.bcc&&r.bcc.length&&e.push({key:"Bcc",val:Ei(r.bcc)});let t=e.map(o=>o.key.length).reduce((o,l)=>l>o?l:o,0);e=e.flatMap(o=>{let l=t-o.key.length,a=`${o.key}: ${" ".repeat(l)}`,u=`${" ".repeat(o.key.length+1)} ${" ".repeat(l)}`;return Vd(o.val,80).split(/\r?\n/).map(d=>d.trim()).map((d,f)=>`${f?u:a}${d}`)});let n=e.map(o=>o.length).reduce((o,l)=>l>o?l:o,0),s="-".repeat(n);return`
18
18
  ${s}
19
19
  ${e.join(`
20
20
  `)}
21
21
  ${s}
22
- `}function Ca(r){let e=[];if(r.from&&e.push(`<div class="postal-email-header-key">From</div><div class="postal-email-header-value">${nu(r.from)}</div>`),r.subject&&e.push(`<div class="postal-email-header-key">Subject</div><div class="postal-email-header-value postal-email-header-subject">${Er(r.subject)}</div>`),r.date){let n={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},s=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",n).format(new Date(r.date));e.push(`<div class="postal-email-header-key">Date</div><div class="postal-email-header-value postal-email-header-date" data-date="${Er(r.date)}">${Er(s)}</div>`)}return r.to&&r.to.length&&e.push(`<div class="postal-email-header-key">To</div><div class="postal-email-header-value">${Di(r.to)}</div>`),r.cc&&r.cc.length&&e.push(`<div class="postal-email-header-key">Cc</div><div class="postal-email-header-value">${Di(r.cc)}</div>`),r.bcc&&r.bcc.length&&e.push(`<div class="postal-email-header-key">Bcc</div><div class="postal-email-header-value">${Di(r.bcc)}</div>`),`<div class="postal-email-header">${e.length?'<div class="postal-email-header-row">':""}${e.join(`</div>
23
- <div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function Vd(r,e){let t=!1,n="text",s,i=[],o={address:[],comment:[],group:[],text:[],textWasQuoted:[]},l,a,u=!1;for(l=0,a=r.length;l<a;l++){let c=r[l],d=l?r[l-1]:null;if(c.type==="operator")switch(c.value){case"<":n="address",u=!1;break;case"(":n="comment",u=!1;break;case":":n="group",t=!0,u=!1;break;case'"':u=!u,n="text";break;default:n="text",u=!1;break}else c.value&&(n==="address"&&(c.value=c.value.replace(/^[^<]*<\s*/,"")),d&&d.noBreak&&o[n].length?(o[n][o[n].length-1]+=c.value,n==="text"&&u&&(o.textWasQuoted[o.textWasQuoted.length-1]=!0)):(o[n].push(c.value),n==="text"&&o.textWasQuoted.push(u)))}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),t){o.text=o.text.join(" ");let c=[];o.group.length&&Dn(o.group.join(","),{_depth:e+1}).forEach(f=>{f.group?c=c.concat(f.group):c.push(f)}),i.push({name:kn(o.text||s&&s.name),group:c})}else{if(!o.address.length&&o.text.length){for(l=o.text.length-1;l>=0;l--)if(!o.textWasQuoted[l]&&o.text[l].match(/^[^@\s]+@[^@\s]+$/)){o.address=o.text.splice(l,1),o.textWasQuoted.splice(l,1);break}let c=function(d){return o.address.length?d:(o.address=[d.trim()]," ")};if(!o.address.length)for(l=o.text.length-1;l>=0&&!(!o.textWasQuoted[l]&&(o.text[l]=o.text[l].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/,c).trim(),o.address.length));l--);}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),o.address.length>1&&(o.text=o.text.concat(o.address.splice(1))),o.text=o.text.join(" "),o.address=o.address.join(" "),!o.address&&/^=\?[^=]+?=$/.test(o.text.trim())){const c=Dn(kn(o.text));if(c&&c.length)return c}if(!o.address&&t)return[];s={address:o.address||o.text||"",name:kn(o.text||o.address||"")},s.address===s.name&&((s.address||"").match(/@/)?s.name="":s.address=""),i.push(s)}return i}class Hd{constructor(e){this.str=(e||"").toString(),this.operatorCurrent="",this.operatorExpecting="",this.node=null,this.escaped=!1,this.list=[],this.operators={'"':'"',"(":")","<":">",",":"",":":";",";":""}}tokenize(){let e=[];for(let t=0,n=this.str.length;t<n;t++){let s=this.str.charAt(t),i=t<n-1?this.str.charAt(t+1):null;this.checkChar(s,i)}return this.list.forEach(t=>{t.value=(t.value||"").toString().trim(),t.value&&e.push(t)}),e}checkChar(e,t){if(!this.escaped){if(e===this.operatorExpecting){this.node={type:"operator",value:e},t&&![" "," ","\r",`
22
+ `}function Sa(r){let e=[];if(r.from&&e.push(`<div class="postal-email-header-key">From</div><div class="postal-email-header-value">${su(r.from)}</div>`),r.subject&&e.push(`<div class="postal-email-header-key">Subject</div><div class="postal-email-header-value postal-email-header-subject">${kr(r.subject)}</div>`),r.date){let n={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},s=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",n).format(new Date(r.date));e.push(`<div class="postal-email-header-key">Date</div><div class="postal-email-header-value postal-email-header-date" data-date="${kr(r.date)}">${kr(s)}</div>`)}return r.to&&r.to.length&&e.push(`<div class="postal-email-header-key">To</div><div class="postal-email-header-value">${Di(r.to)}</div>`),r.cc&&r.cc.length&&e.push(`<div class="postal-email-header-key">Cc</div><div class="postal-email-header-value">${Di(r.cc)}</div>`),r.bcc&&r.bcc.length&&e.push(`<div class="postal-email-header-key">Bcc</div><div class="postal-email-header-value">${Di(r.bcc)}</div>`),`<div class="postal-email-header">${e.length?'<div class="postal-email-header-row">':""}${e.join(`</div>
23
+ <div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function Hd(r,e){let t=!1,n="text",s,i=[],o={address:[],comment:[],group:[],text:[],textWasQuoted:[]},l,a,u=!1;for(l=0,a=r.length;l<a;l++){let c=r[l],d=l?r[l-1]:null;if(c.type==="operator")switch(c.value){case"<":n="address",u=!1;break;case"(":n="comment",u=!1;break;case":":n="group",t=!0,u=!1;break;case'"':u=!u,n="text";break;default:n="text",u=!1;break}else c.value&&(n==="address"&&(c.value=c.value.replace(/^[^<]*<\s*/,"")),d&&d.noBreak&&o[n].length?(o[n][o[n].length-1]+=c.value,n==="text"&&u&&(o.textWasQuoted[o.textWasQuoted.length-1]=!0)):(o[n].push(c.value),n==="text"&&o.textWasQuoted.push(u)))}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),t){o.text=o.text.join(" ");let c=[];o.group.length&&Dn(o.group.join(","),{_depth:e+1}).forEach(f=>{f.group?c=c.concat(f.group):c.push(f)}),i.push({name:En(o.text||s&&s.name),group:c})}else{if(!o.address.length&&o.text.length){for(l=o.text.length-1;l>=0;l--)if(!o.textWasQuoted[l]&&o.text[l].match(/^[^@\s]+@[^@\s]+$/)){o.address=o.text.splice(l,1),o.textWasQuoted.splice(l,1);break}let c=function(d){return o.address.length?d:(o.address=[d.trim()]," ")};if(!o.address.length)for(l=o.text.length-1;l>=0&&!(!o.textWasQuoted[l]&&(o.text[l]=o.text[l].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/,c).trim(),o.address.length));l--);}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),o.address.length>1&&(o.text=o.text.concat(o.address.splice(1))),o.text=o.text.join(" "),o.address=o.address.join(" "),!o.address&&/^=\?[^=]+?=$/.test(o.text.trim())){const c=Dn(En(o.text));if(c&&c.length)return c}if(!o.address&&t)return[];s={address:o.address||o.text||"",name:En(o.text||o.address||"")},s.address===s.name&&((s.address||"").match(/@/)?s.name="":s.address=""),i.push(s)}return i}class Gd{constructor(e){this.str=(e||"").toString(),this.operatorCurrent="",this.operatorExpecting="",this.node=null,this.escaped=!1,this.list=[],this.operators={'"':'"',"(":")","<":">",",":"",":":";",";":""}}tokenize(){let e=[];for(let t=0,n=this.str.length;t<n;t++){let s=this.str.charAt(t),i=t<n-1?this.str.charAt(t+1):null;this.checkChar(s,i)}return this.list.forEach(t=>{t.value=(t.value||"").toString().trim(),t.value&&e.push(t)}),e}checkChar(e,t){if(!this.escaped){if(e===this.operatorExpecting){this.node={type:"operator",value:e},t&&![" "," ","\r",`
24
24
  `,",",";"].includes(t)&&(this.node.noBreak=!0),this.list.push(this.node),this.node=null,this.operatorExpecting="",this.escaped=!1;return}else if(!this.operatorExpecting&&e in this.operators){this.node={type:"operator",value:e},this.list.push(this.node),this.node=null,this.operatorExpecting=this.operators[e],this.escaped=!1;return}else if(['"',"'"].includes(this.operatorExpecting)&&e==="\\"){this.escaped=!0;return}}this.node||(this.node={type:"text",value:""},this.list.push(this.node)),e===`
25
- `&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const Gd=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>Gd)return[];let s=new Hd(r).tokenize(),i=[],o=[],l=[];if(s.forEach(a=>{a.type==="operator"&&(a.value===","||a.value===";")?(o.length&&i.push(o),o=[]):o.push(a)}),o.length&&i.push(o),i.forEach(a=>{a=Vd(a,t),a.length&&(l=l.concat(a))}),e.flatten){let a=[],u=c=>{c.forEach(d=>{if(d.group)return u(d.group);a.push(d)})};return u(l),a}return l}function Kd(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,i=s%3,o=s-i,l,a,u,c,d,f=0;f<o;f=f+3)d=n[f]<<16|n[f+1]<<8|n[f+2],l=(d&16515072)>>18,a=(d&258048)>>12,u=(d&4032)>>6,c=d&63,e+=t[l]+t[a]+t[u]+t[c];return i==1?(d=n[o],l=(d&252)>>2,a=(d&3)<<4,e+=t[l]+t[a]+"=="):i==2&&(d=n[o]<<8|n[o+1],l=(d&64512)>>10,a=(d&1008)>>4,u=(d&15)<<2,e+=t[l]+t[a]+t[u]+"="),e}const Yd=256,Qd=2*1024*1024;class Ds{static parse(e,t){return new Ds(t).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||Yd,maxHeadersSize:this.options.maxHeadersSize||Qd},this.root=this.currentNode=new _a({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(e,t){let n=this.boundaries;if(n.length&&e.length>2&&e[0]===45&&e[1]===45)for(let s=n.length-1;s>=0;s--){let i=n[s];if(e.length!==i.value.length+2&&e.length!==i.value.length+4)continue;let o=e.length===i.value.length+4;if(o&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let l=!0;for(let a=0;a<i.value.length;a++)if(e[a+2]!==i.value[a]){l=!1;break}if(l)return o?(await i.node.finalize(),this.currentNode=i.node.parentNode||this.root):(await i.node.finalizeChildNodes(),this.currentNode=new _a({postalMime:this,parentNode:i.node,...this.mimeOptions})),t?this.finalize():void 0}if(this.currentNode.feed(e),t)return this.finalize()}readLine(){let e=this.readPos,t=this.readPos,n=()=>({bytes:new Uint8Array(this.buf,e,t-e),done:this.readPos>=this.av.length});for(;this.readPos<this.av.length;){const s=this.av[this.readPos++];if(s!==13&&s!==10&&(t=this.readPos),s===10)return n()}return n()}async processNodeTree(){let e={},t=new Set,n=this.textMap=new Map,s=this.forceRfc822Attachments(),i=async(o,l,a)=>{if(l=l||!1,a=a||!1,o.contentType.multipart)o.contentType.multipart==="alternative"?l=o:o.contentType.multipart==="related"&&(a=o);else if(this.isInlineMessageRfc822(o)&&!s){const u=new Ds;o.subMessage=await u.parse(o.content),n.has(o)||n.set(o,{});let c=n.get(o);(o.subMessage.text||!o.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:o.subMessage}),t.add("plain")),o.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:o.subMessage}),t.add("html")),u.textMap&&u.textMap.forEach((d,f)=>{n.set(f,d)});for(let d of o.subMessage.attachments||[])this.attachments.push(d)}else if(this.isInlineTextNode(o)){let u=o.contentType.parsed.value.substr(o.contentType.parsed.value.indexOf("/")+1),c=l||o;n.has(c)||n.set(c,{});let d=n.get(c);d[u]=d[u]||[],d[u].push({type:"text",value:o.getTextContent()}),t.add(u)}else if(o.content){const u=o.contentDisposition.parsed.params.filename||o.contentType.parsed.params.name||null,c={filename:u?kn(u):null,mimeType:o.contentType.parsed.value,disposition:o.contentDisposition.parsed.value||null};switch(a&&o.contentId&&(c.related=!0),o.contentDescription&&(c.description=o.contentDescription),o.contentId&&(c.contentId=o.contentId),o.contentType.parsed.value){case"text/calendar":case"application/ics":{o.contentType.parsed.params.method&&(c.method=o.contentType.parsed.params.method.toString().toUpperCase().trim());const d=o.getTextContent().replace(/\r?\n/g,`
25
+ `&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const Kd=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>Kd)return[];let s=new Gd(r).tokenize(),i=[],o=[],l=[];if(s.forEach(a=>{a.type==="operator"&&(a.value===","||a.value===";")?(o.length&&i.push(o),o=[]):o.push(a)}),o.length&&i.push(o),i.forEach(a=>{a=Hd(a,t),a.length&&(l=l.concat(a))}),e.flatten){let a=[],u=c=>{c.forEach(d=>{if(d.group)return u(d.group);a.push(d)})};return u(l),a}return l}function Yd(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,i=s%3,o=s-i,l,a,u,c,d,f=0;f<o;f=f+3)d=n[f]<<16|n[f+1]<<8|n[f+2],l=(d&16515072)>>18,a=(d&258048)>>12,u=(d&4032)>>6,c=d&63,e+=t[l]+t[a]+t[u]+t[c];return i==1?(d=n[o],l=(d&252)>>2,a=(d&3)<<4,e+=t[l]+t[a]+"=="):i==2&&(d=n[o]<<8|n[o+1],l=(d&64512)>>10,a=(d&1008)>>4,u=(d&15)<<2,e+=t[l]+t[a]+t[u]+"="),e}const Qd=256,Xd=2*1024*1024;class Ds{static parse(e,t){return new Ds(t).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||Qd,maxHeadersSize:this.options.maxHeadersSize||Xd},this.root=this.currentNode=new _a({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(e,t){let n=this.boundaries;if(n.length&&e.length>2&&e[0]===45&&e[1]===45)for(let s=n.length-1;s>=0;s--){let i=n[s];if(e.length!==i.value.length+2&&e.length!==i.value.length+4)continue;let o=e.length===i.value.length+4;if(o&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let l=!0;for(let a=0;a<i.value.length;a++)if(e[a+2]!==i.value[a]){l=!1;break}if(l)return o?(await i.node.finalize(),this.currentNode=i.node.parentNode||this.root):(await i.node.finalizeChildNodes(),this.currentNode=new _a({postalMime:this,parentNode:i.node,...this.mimeOptions})),t?this.finalize():void 0}if(this.currentNode.feed(e),t)return this.finalize()}readLine(){let e=this.readPos,t=this.readPos,n=()=>({bytes:new Uint8Array(this.buf,e,t-e),done:this.readPos>=this.av.length});for(;this.readPos<this.av.length;){const s=this.av[this.readPos++];if(s!==13&&s!==10&&(t=this.readPos),s===10)return n()}return n()}async processNodeTree(){let e={},t=new Set,n=this.textMap=new Map,s=this.forceRfc822Attachments(),i=async(o,l,a)=>{if(l=l||!1,a=a||!1,o.contentType.multipart)o.contentType.multipart==="alternative"?l=o:o.contentType.multipart==="related"&&(a=o);else if(this.isInlineMessageRfc822(o)&&!s){const u=new Ds;o.subMessage=await u.parse(o.content),n.has(o)||n.set(o,{});let c=n.get(o);(o.subMessage.text||!o.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:o.subMessage}),t.add("plain")),o.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:o.subMessage}),t.add("html")),u.textMap&&u.textMap.forEach((d,f)=>{n.set(f,d)});for(let d of o.subMessage.attachments||[])this.attachments.push(d)}else if(this.isInlineTextNode(o)){let u=o.contentType.parsed.value.substr(o.contentType.parsed.value.indexOf("/")+1),c=l||o;n.has(c)||n.set(c,{});let d=n.get(c);d[u]=d[u]||[],d[u].push({type:"text",value:o.getTextContent()}),t.add(u)}else if(o.content){const u=o.contentDisposition.parsed.params.filename||o.contentType.parsed.params.name||null,c={filename:u?En(u):null,mimeType:o.contentType.parsed.value,disposition:o.contentDisposition.parsed.value||null};switch(a&&o.contentId&&(c.related=!0),o.contentDescription&&(c.description=o.contentDescription),o.contentId&&(c.contentId=o.contentId),o.contentType.parsed.value){case"text/calendar":case"application/ics":{o.contentType.parsed.params.method&&(c.method=o.contentType.parsed.params.method.toString().toUpperCase().trim());const d=o.getTextContent().replace(/\r?\n/g,`
26
26
  `).replace(/\n*$/,`
27
- `);c.content=Jr.encode(d);break}default:c.content=o.content}this.attachments.push(c)}for(let u of o.childNodes)await i(u,l,a)};await i(this.root,!1,[]),n.forEach(o=>{t.forEach(l=>{if(e[l]||(e[l]=[]),o[l])o[l].forEach(a=>{switch(a.type){case"text":e[l].push(a.value);break;case"subMessage":switch(l){case"html":e[l].push(Ca(a.value));break;case"plain":e[l].push(wa(a.value));break}break}});else{let a;switch(l){case"html":a="plain";break;case"plain":a="html";break}(o[a]||[]).forEach(u=>{switch(u.type){case"text":switch(l){case"html":e[l].push(qd(u.value));break;case"plain":e[l].push(Ud(u.value));break}break;case"subMessage":switch(l){case"html":e[l].push(Ca(u.value));break;case"plain":e[l].push(wa(u.value));break}break}})}})}),Object.keys(e).forEach(o=>{e[o]=e[o].join(`
28
- `)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,t=n=>{n.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(n.contentType.parsed.value)&&(e=!0);for(let s of n.childNodes)t(s)};return t(this.root),e}async resolveStream(e){let t=0,n=[];const s=e.getReader();for(;;){const{done:l,value:a}=await s.read();if(l)break;n.push(a),t+=a.length}const i=new Uint8Array(t);let o=0;for(let l of n)i.set(l,o),o+=l.length;return i}async parse(e){var s,i;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=Jr.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await ni(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const o=this.readLine();await this.processLine(o.bytes,o.done)}await this.processNodeTree();const t={headers:this.root.headers.map(o=>({key:o.key,value:o.value})).reverse()};for(const o of["from","sender"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=Dn(l.value);a&&a.length&&(t[o]=a[0])}}for(const o of["delivered-to","return-path"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=Dn(l.value);if(a&&a.length&&a[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=a[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const l=this.root.headers.filter(u=>u.key===o);let a=[];if(l.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>a=a.concat(u||[])),a&&a.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=a}}for(const o of["subject","message-id","in-reply-to","references"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[a]=kn(l.value)}}let n=this.root.headers.find(o=>o.key==="date");if(n){let o=new Date(n.value);!o||o.toString()==="Invalid Date"?o=n.value:o=o.toISOString(),t.date=o}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(i=this.textContent)!=null&&i.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let l of t.attachments||[])l!=null&&l.content&&(l.content=Kd(l.content),l.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let l of t.attachments||[])l!=null&&l.content&&(l.content=o.decode(l.content),l.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class su{constructor(e){St(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,t,n={}){const s={coprocessor:e,method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("API call failed:",i),i}}async callMail(e,t={}){return this.callCoprocessor("mail",e,t)}async callEmail(e,t={}){return this.callCoprocessor("email",e,t)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,t=150,n){return this.callMail("list_emails",{account_id:e,limit:t,folder:n})}async deleteEmails(e,t,n=!0){return this.callMail("delete_emails",{account_id:e,uids:t,expunge:n})}async imapExec(e,t){return this.callMail("imap_exec",{account_id:e,commands:t})}async trashEmails(e,t,n="INBOX"){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const i of s){const o=[`SELECT "${n}"`,...t.map(u=>`UID MOVE ${u} "${i}"`)],a=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(a>0)return{success:!0,moved:a}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(e){const n=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,t="INBOX",n=150){const s=await this.imapExec(e,[`SELECT ${t}`,"FETCH 1:* (UID INTERNALDATE)"]),i=s.responses.find(p=>p.command==="SELECT");if(!(i!=null&&i.ok))throw new Error(`Failed to select folder: ${(i==null?void 0:i.error)||"Unknown error"}`);const o=s.responses.find(p=>p.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const a=[...o.messages].sort((p,g)=>{const m=p.internalDate?new Date(p.internalDate).getTime():0;return(g.internalDate?new Date(g.internalDate).getTime():0)-m}).slice(0,n).map(p=>p.uid).filter(Boolean);if(a.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${a.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(p=>p.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const d=new Map;for(const p of c.messages)p.uid&&d.set(p.uid,p);const f=a.map(p=>{var C,S,D,w,y;const g=d.get(p);if(!g)return null;const m=((C=g.flags)==null?void 0:C.some(k=>k.includes("Seen")))||!1,x=((D=(S=g.envelope)==null?void 0:S.from)==null?void 0:D.email)||"Unknown",v=((w=g.envelope)==null?void 0:w.subject)||"(No subject)",b=((y=g.envelope)==null?void 0:y.date)||"";return{uid:p,from:x,subject:v,date:b,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:f}}async getEmail(e,t,n="INBOX"){return this.callMail("get_email",{account_id:e,uid:t,folder:n})}async getAttachment(e,t,n,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:t,attachment_index:n,folder:s})}async searchContactEmails(e,t,n=50){return this.callMail("search_contact_emails",{account_id:e,contact_email:t,limit:n})}async getEmailParsed(e,t,n="INBOX"){var g,m,x,v,b,C;const i=(await this.imapExec(e,[`SELECT "${n}"`,`UID FETCH ${t} (FLAGS BODY[])`])).responses.find(S=>S.command==="UID FETCH");if(!(i!=null&&i.ok)||!((g=i.messages)!=null&&g[0]))return console.error("Failed to fetch raw email:",i==null?void 0:i.error),null;const o=i.messages[0],l=o.body||o.raw;if(!l)return console.error("No raw email content in response"),null;const u=await new Ds().parse(l);console.log("[MailClient] Parsed email - attachments count:",((m=u.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=u.attachments)==null?void 0:x.map(S=>({filename:S.filename,mimeType:S.mimeType,contentId:S.contentId})));const c=new Map;for(const S of u.attachments||[])if(S.contentId){const D=this.contentToBase64(S.content),w=`data:${S.mimeType};base64,${D}`,y=S.contentId.replace(/^<|>$/g,"");c.set(y,w),c.set(`<${y}>`,w)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(S,D)=>{const w=c.get(D)||c.get(`<${D}>`);return w?`src="${w}"`:S}));const f=((v=o.flags)==null?void 0:v.some(S=>S.toLowerCase().includes("seen")))||!1,p=((b=u.from)==null?void 0:b.address)||((C=u.from)==null?void 0:C.name)||"Unknown";return{uid:t,from:p,subject:u.subject||"(No subject)",date:u.date||"",body:d||u.text||"",html:d,text:u.text||"",seen:f,attachments:(u.attachments||[]).map(S=>({filename:S.filename||"attachment",mimeType:S.mimeType||"application/octet-stream",size:this.getContentSize(S.content)}))}}async findEmailInAllMail(e,t){var i,o;const n=await this.getSettings(),s=((i=n.accounts)==null?void 0:i.find(l=>l.id===e))||((o=n.accounts)==null?void 0:o[0]);if(!(s!=null&&s.imap))return console.error("[MailClient] No IMAP configuration found for account"),{found:!1};try{return await this.callEmail("findEmailInAllMail",{message_id:t.message_id,from:t.from,subject:t.subject,folder:t.folder,imap_config:{host:s.imap.host,port:parseInt(s.imap.port,10)||993,username:s.imap.user,password:s.imap.password}})}catch(l){return console.error("[MailClient] findEmailInAllMail failed:",l),{found:!1}}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++)n+=String.fromCharCode(t[s]);return btoa(n)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const t={to:e.to,subject:e.subject,body:e.body};return e.html&&(t.html=e.html),e.from&&(t.from=e.from),e.smtpConfig&&(t.smtp_config=e.smtpConfig),this.callEmail("send",t)}async sendEmail(e,t){var n,s;try{const i=await this.getSettings(),o=((n=i.accounts)==null?void 0:n.find(u=>u.id===e))||((s=i.accounts)==null?void 0:s[0]);if(!(o!=null&&o.smtp))return{success:!1,error:"No SMTP configuration found for account"};const l={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:o.email,smtp_config:{host:o.smtp.host,port:parseInt(o.smtp.port,10)||587,username:o.smtp.user,password:o.smtp.password}};t.in_reply_to&&(l.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(l.attachments=t.attachments);const a=await this.callEmail("send",l);return{success:(a==null?void 0:a.sent)??!1,message_id:a==null?void 0:a.message_id,error:a==null?void 0:a.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}}const Ai="qwanyx_auth_token",Ti="qwanyx_refresh_token",Ni="qwanyx_auth_user";class ht{static setToken(e){typeof window<"u"&&localStorage.setItem(Ai,e)}static getToken(){return typeof window<"u"?localStorage.getItem(Ai):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ai),localStorage.removeItem(Ti))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(Ti,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Ti):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}static setUser(e){typeof window<"u"&&localStorage.setItem(Ni,JSON.stringify(e))}static getUser(){if(typeof window<"u"){const e=localStorage.getItem(Ni);if(e)try{return JSON.parse(e)}catch{return null}}return null}static clearUser(){typeof window<"u"&&localStorage.removeItem(Ni)}static clearAll(){this.clearToken(),this.clearUser()}}class To{constructor(e){St(this,"config");this.config=e}async register(e,t,n){var s,i;try{const l=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"register",params:{email:e,password:t,...n}})})).json();return l.success&&((s=l.result)!=null&&s.success)?{success:!0,userId:l.result.user_id,email:l.result.email,requiresVerification:l.result.requiresVerification}:{success:!1,error:((i=l.result)==null?void 0:i.message)||l.error||"Registration failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Network error"}}}async verifyEmail(e,t){var n,s,i,o;try{const a=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"verify_email",params:{email:e,code:t}})})).json();if(a.success&&((n=a.result)!=null&&n.token)){const{token:u,user:c}=a.result;return ht.setToken(u),ht.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=a.result)==null?void 0:o.error)||a.error||"Verification failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async requestPasswordReset(e){var t,n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"request_password_reset",params:{email:e}})})).json();return i.success&&((t=i.result)!=null&&t.success)?{success:!0,message:i.result.message}:{success:!1,error:((n=i.result)==null?void 0:n.message)||i.error||"Request failed"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Network error"}}}async setPasswordWithCode(e,t,n){var s,i,o,l;try{const u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"set_password_with_code",params:{email:e,code:t,password:n}})})).json();if(u.success&&((s=u.result)!=null&&s.token)){const{token:c,user:d}=u.result;return ht.setToken(c),ht.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((l=u.result)==null?void 0:l.message)||u.error||"Password reset failed"}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Network error"}}}async login(e,t){var n,s,i,o,l,a;try{const c=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"login",params:{email:e,password:t}})})).json();if((n=c.result)!=null&&n.requiresVerification||c.requiresVerification)return{success:!1,error:((s=c.result)==null?void 0:s.error)||c.error||"Please verify your email first",requiresVerification:!0};if(c.success&&((i=c.result)!=null&&i.token)){const{token:d,user:f}=c.result;return ht.setToken(d),ht.setUser(f),(l=(o=this.config).onLogin)==null||l.call(o,f),{success:!0,user:f,token:d}}else return{success:!1,error:((a=c.result)==null?void 0:a.error)||c.error||"Login failed"}}catch(u){return{success:!1,error:u instanceof Error?u.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;ht.clearAll(),(t=(e=this.config).onLogout)==null||t.call(e)}async checkRole(e,t){var n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...ht.getAuthHeader()},body:JSON.stringify({system_id:this.config.systemId||"system",coprocessor:"graph",method:"get_user_role",params:{group_id:e,target_user_id:t}})})).json();return i.success&&((n=i.result)!=null&&n.role)?i.result.role:null}catch{return null}}async isAdmin(e){return this.config.systemId?await this.checkRole(`${this.config.systemId}__admins`,e)==="admin":!1}getCurrentUser(){return ht.getUser()}isAuthenticated(){return ht.isAuthenticated()}}let As=null;function Xd(r){return As=new To(r),As}function Jd(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class iu{constructor(e){St(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,i])=>{i!=null&&t.append(s,String(i))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:i,params:o}=t,l=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,a={...this.config.headers,...ht.getAuthHeader(),...s},u={method:n,headers:a};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),f=await fetch(l,{...u,signal:c.signal});if(clearTimeout(d),!f.ok){const p=await f.json().catch(()=>({message:f.statusText}));throw new Error(p.message||`HTTP ${f.status}`)}return await f.json()}catch(c){throw c instanceof Error?c:new Error("An unexpected error occurred")}}async get(e,t){return this.request(e,{method:"GET",params:t})}async post(e,t,n){return this.request(e,{method:"POST",body:t,params:n})}async put(e,t,n){return this.request(e,{method:"PUT",body:t,params:n})}async patch(e,t,n){return this.request(e,{method:"PATCH",body:t,params:n})}async delete(e,t){return this.request(e,{method:"DELETE",params:t})}setBaseUrl(e){this.config.baseUrl=e}getBaseUrl(){return this.config.baseUrl}}let Ts=null;function Zd(r){return Ts=new iu(r),Ts}function No(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Hi={exports:{}},cn={};/**
27
+ `);c.content=Jr.encode(d);break}default:c.content=o.content}this.attachments.push(c)}for(let u of o.childNodes)await i(u,l,a)};await i(this.root,!1,[]),n.forEach(o=>{t.forEach(l=>{if(e[l]||(e[l]=[]),o[l])o[l].forEach(a=>{switch(a.type){case"text":e[l].push(a.value);break;case"subMessage":switch(l){case"html":e[l].push(Sa(a.value));break;case"plain":e[l].push(Ca(a.value));break}break}});else{let a;switch(l){case"html":a="plain";break;case"plain":a="html";break}(o[a]||[]).forEach(u=>{switch(u.type){case"text":switch(l){case"html":e[l].push(Ud(u.value));break;case"plain":e[l].push(Wd(u.value));break}break;case"subMessage":switch(l){case"html":e[l].push(Sa(u.value));break;case"plain":e[l].push(Ca(u.value));break}break}})}})}),Object.keys(e).forEach(o=>{e[o]=e[o].join(`
28
+ `)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,t=n=>{n.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(n.contentType.parsed.value)&&(e=!0);for(let s of n.childNodes)t(s)};return t(this.root),e}async resolveStream(e){let t=0,n=[];const s=e.getReader();for(;;){const{done:l,value:a}=await s.read();if(l)break;n.push(a),t+=a.length}const i=new Uint8Array(t);let o=0;for(let l of n)i.set(l,o),o+=l.length;return i}async parse(e){var s,i;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=Jr.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await ni(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const o=this.readLine();await this.processLine(o.bytes,o.done)}await this.processNodeTree();const t={headers:this.root.headers.map(o=>({key:o.key,value:o.value})).reverse()};for(const o of["from","sender"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=Dn(l.value);a&&a.length&&(t[o]=a[0])}}for(const o of["delivered-to","return-path"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=Dn(l.value);if(a&&a.length&&a[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=a[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const l=this.root.headers.filter(u=>u.key===o);let a=[];if(l.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>a=a.concat(u||[])),a&&a.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=a}}for(const o of["subject","message-id","in-reply-to","references"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[a]=En(l.value)}}let n=this.root.headers.find(o=>o.key==="date");if(n){let o=new Date(n.value);!o||o.toString()==="Invalid Date"?o=n.value:o=o.toISOString(),t.date=o}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(i=this.textContent)!=null&&i.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let l of t.attachments||[])l!=null&&l.content&&(l.content=Yd(l.content),l.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let l of t.attachments||[])l!=null&&l.content&&(l.content=o.decode(l.content),l.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class iu{constructor(e){Et(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,t,n={}){const s={coprocessor:e,method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("API call failed:",i),i}}async callMail(e,t={}){return this.callCoprocessor("mail",e,t)}async callEmail(e,t={}){return this.callCoprocessor("email",e,t)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,t=150,n){return this.callMail("list_emails",{account_id:e,limit:t,folder:n})}async deleteEmails(e,t,n=!0){return this.callMail("delete_emails",{account_id:e,uids:t,expunge:n})}async imapExec(e,t){return this.callMail("imap_exec",{account_id:e,commands:t})}async trashEmails(e,t,n="INBOX"){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const i of s){const o=[`SELECT "${n}"`,...t.map(u=>`UID MOVE ${u} "${i}"`)],a=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(a>0)return{success:!0,moved:a}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:o>0,archived:o}}async listFolders(e){const n=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,t="INBOX",n=150){const s=await this.imapExec(e,[`SELECT ${t}`,"FETCH 1:* (UID INTERNALDATE)"]),i=s.responses.find(p=>p.command==="SELECT");if(!(i!=null&&i.ok))throw new Error(`Failed to select folder: ${(i==null?void 0:i.error)||"Unknown error"}`);const o=s.responses.find(p=>p.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const a=[...o.messages].sort((p,g)=>{const m=p.internalDate?new Date(p.internalDate).getTime():0;return(g.internalDate?new Date(g.internalDate).getTime():0)-m}).slice(0,n).map(p=>p.uid).filter(Boolean);if(a.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${a.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(p=>p.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const d=new Map;for(const p of c.messages)p.uid&&d.set(p.uid,p);const f=a.map(p=>{var C,S,D,_,b;const g=d.get(p);if(!g)return null;const m=((C=g.flags)==null?void 0:C.some(E=>E.includes("Seen")))||!1,x=((D=(S=g.envelope)==null?void 0:S.from)==null?void 0:D.email)||"Unknown",w=((_=g.envelope)==null?void 0:_.subject)||"(No subject)",y=((b=g.envelope)==null?void 0:b.date)||"";return{uid:p,from:x,subject:w,date:y,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:f}}async getEmail(e,t,n="INBOX"){return this.callMail("get_email",{account_id:e,uid:t,folder:n})}async getAttachment(e,t,n,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:t,attachment_index:n,folder:s})}async searchContactEmails(e,t,n=50){return this.callMail("search_contact_emails",{account_id:e,contact_email:t,limit:n})}async getEmailParsed(e,t,n="INBOX"){var g,m,x,w,y,C;const i=(await this.imapExec(e,[`SELECT "${n}"`,`UID FETCH ${t} (FLAGS BODY[])`])).responses.find(S=>S.command==="UID FETCH");if(!(i!=null&&i.ok)||!((g=i.messages)!=null&&g[0]))return console.error("Failed to fetch raw email:",i==null?void 0:i.error),null;const o=i.messages[0],l=o.body||o.raw;if(!l)return console.error("No raw email content in response"),null;const u=await new Ds().parse(l);console.log("[MailClient] Parsed email - attachments count:",((m=u.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=u.attachments)==null?void 0:x.map(S=>({filename:S.filename,mimeType:S.mimeType,contentId:S.contentId})));const c=new Map;for(const S of u.attachments||[])if(S.contentId){const D=this.contentToBase64(S.content),_=`data:${S.mimeType};base64,${D}`,b=S.contentId.replace(/^<|>$/g,"");c.set(b,_),c.set(`<${b}>`,_)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(S,D)=>{const _=c.get(D)||c.get(`<${D}>`);return _?`src="${_}"`:S}));const f=((w=o.flags)==null?void 0:w.some(S=>S.toLowerCase().includes("seen")))||!1,p=((y=u.from)==null?void 0:y.address)||((C=u.from)==null?void 0:C.name)||"Unknown";return{uid:t,from:p,subject:u.subject||"(No subject)",date:u.date||"",body:d||u.text||"",html:d,text:u.text||"",seen:f,attachments:(u.attachments||[]).map(S=>({filename:S.filename||"attachment",mimeType:S.mimeType||"application/octet-stream",size:this.getContentSize(S.content)}))}}async findEmailInAllMail(e,t){var i,o;const n=await this.getSettings(),s=((i=n.accounts)==null?void 0:i.find(l=>l.id===e))||((o=n.accounts)==null?void 0:o[0]);if(!(s!=null&&s.imap))return console.error("[MailClient] No IMAP configuration found for account"),{found:!1};try{return await this.callEmail("findEmailInAllMail",{message_id:t.message_id,from:t.from,subject:t.subject,folder:t.folder,imap_config:{host:s.imap.host,port:parseInt(s.imap.port,10)||993,username:s.imap.user,password:s.imap.password}})}catch(l){return console.error("[MailClient] findEmailInAllMail failed:",l),{found:!1}}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++)n+=String.fromCharCode(t[s]);return btoa(n)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const t={to:e.to,subject:e.subject,body:e.body};return e.html&&(t.html=e.html),e.from&&(t.from=e.from),e.smtpConfig&&(t.smtp_config=e.smtpConfig),this.callEmail("send",t)}async sendEmail(e,t){var n,s;try{const i=await this.getSettings(),o=((n=i.accounts)==null?void 0:n.find(u=>u.id===e))||((s=i.accounts)==null?void 0:s[0]);if(!(o!=null&&o.smtp))return{success:!1,error:"No SMTP configuration found for account"};const l={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:o.email,smtp_config:{host:o.smtp.host,port:parseInt(o.smtp.port,10)||587,username:o.smtp.user,password:o.smtp.password}};t.in_reply_to&&(l.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(l.attachments=t.attachments);const a=await this.callEmail("send",l);return{success:(a==null?void 0:a.sent)??!1,message_id:a==null?void 0:a.message_id,error:a==null?void 0:a.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}}const Ai="qwanyx_auth_token",Ti="qwanyx_refresh_token",Ni="qwanyx_auth_user";class mt{static setToken(e){typeof window<"u"&&localStorage.setItem(Ai,e)}static getToken(){return typeof window<"u"?localStorage.getItem(Ai):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ai),localStorage.removeItem(Ti))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(Ti,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Ti):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}static setUser(e){typeof window<"u"&&localStorage.setItem(Ni,JSON.stringify(e))}static getUser(){if(typeof window<"u"){const e=localStorage.getItem(Ni);if(e)try{return JSON.parse(e)}catch{return null}}return null}static clearUser(){typeof window<"u"&&localStorage.removeItem(Ni)}static clearAll(){this.clearToken(),this.clearUser()}}class No{constructor(e){Et(this,"config");this.config=e}async register(e,t,n){var s,i;try{const l=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"register",params:{email:e,password:t,...n}})})).json();return l.success&&((s=l.result)!=null&&s.success)?{success:!0,userId:l.result.user_id,email:l.result.email,requiresVerification:l.result.requiresVerification}:{success:!1,error:((i=l.result)==null?void 0:i.message)||l.error||"Registration failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Network error"}}}async verifyEmail(e,t){var n,s,i,o;try{const a=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"verify_email",params:{email:e,code:t}})})).json();if(a.success&&((n=a.result)!=null&&n.token)){const{token:u,user:c}=a.result;return mt.setToken(u),mt.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=a.result)==null?void 0:o.error)||a.error||"Verification failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async requestPasswordReset(e){var t,n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"request_password_reset",params:{email:e}})})).json();return i.success&&((t=i.result)!=null&&t.success)?{success:!0,message:i.result.message}:{success:!1,error:((n=i.result)==null?void 0:n.message)||i.error||"Request failed"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Network error"}}}async setPasswordWithCode(e,t,n){var s,i,o,l;try{const u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"set_password_with_code",params:{email:e,code:t,password:n}})})).json();if(u.success&&((s=u.result)!=null&&s.token)){const{token:c,user:d}=u.result;return mt.setToken(c),mt.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((l=u.result)==null?void 0:l.message)||u.error||"Password reset failed"}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Network error"}}}async login(e,t){var n,s,i,o,l,a;try{const c=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"login",params:{email:e,password:t}})})).json();if((n=c.result)!=null&&n.requiresVerification||c.requiresVerification)return{success:!1,error:((s=c.result)==null?void 0:s.error)||c.error||"Please verify your email first",requiresVerification:!0};if(c.success&&((i=c.result)!=null&&i.token)){const{token:d,user:f}=c.result;return mt.setToken(d),mt.setUser(f),(l=(o=this.config).onLogin)==null||l.call(o,f),{success:!0,user:f,token:d}}else return{success:!1,error:((a=c.result)==null?void 0:a.error)||c.error||"Login failed"}}catch(u){return{success:!1,error:u instanceof Error?u.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;mt.clearAll(),(t=(e=this.config).onLogout)==null||t.call(e)}async checkRole(e,t){var n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...mt.getAuthHeader()},body:JSON.stringify({system_id:this.config.systemId||"system",coprocessor:"graph",method:"get_user_role",params:{group_id:e,target_user_id:t}})})).json();return i.success&&((n=i.result)!=null&&n.role)?i.result.role:null}catch{return null}}async isAdmin(e){return this.config.systemId?await this.checkRole(`${this.config.systemId}__admins`,e)==="admin":!1}getCurrentUser(){return mt.getUser()}isAuthenticated(){return mt.isAuthenticated()}}let As=null;function Jd(r){return As=new No(r),As}function Zd(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class ou{constructor(e){Et(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,i])=>{i!=null&&t.append(s,String(i))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:i,params:o}=t,l=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,a={...this.config.headers,...mt.getAuthHeader(),...s},u={method:n,headers:a};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),f=await fetch(l,{...u,signal:c.signal});if(clearTimeout(d),!f.ok){const p=await f.json().catch(()=>({message:f.statusText}));throw new Error(p.message||`HTTP ${f.status}`)}return await f.json()}catch(c){throw c instanceof Error?c:new Error("An unexpected error occurred")}}async get(e,t){return this.request(e,{method:"GET",params:t})}async post(e,t,n){return this.request(e,{method:"POST",body:t,params:n})}async put(e,t,n){return this.request(e,{method:"PUT",body:t,params:n})}async patch(e,t,n){return this.request(e,{method:"PATCH",body:t,params:n})}async delete(e,t){return this.request(e,{method:"DELETE",params:t})}setBaseUrl(e){this.config.baseUrl=e}getBaseUrl(){return this.config.baseUrl}}let Ts=null;function ef(r){return Ts=new ou(r),Ts}function Bo(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Gi={exports:{}},cn={};/**
29
29
  * @license React
30
30
  * react-jsx-runtime.production.min.js
31
31
  *
@@ -33,7 +33,7 @@ ${s}
33
33
  *
34
34
  * This source code is licensed under the MIT license found in the
35
35
  * LICENSE file in the root directory of this source tree.
36
- */var Sa;function ef(){if(Sa)return cn;Sa=1;var r=_,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,u){var c,d={},f=null,p=null;u!==void 0&&(f=""+u),a.key!==void 0&&(f=""+a.key),a.ref!==void 0&&(p=a.ref);for(c in a)n.call(a,c)&&!i.hasOwnProperty(c)&&(d[c]=a[c]);if(l&&l.defaultProps)for(c in a=l.defaultProps,a)d[c]===void 0&&(d[c]=a[c]);return{$$typeof:e,type:l,key:f,ref:p,props:d,_owner:s.current}}return cn.Fragment=t,cn.jsx=o,cn.jsxs=o,cn}var dn={};/**
36
+ */var ka;function tf(){if(ka)return cn;ka=1;var r=v,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,u){var c,d={},f=null,p=null;u!==void 0&&(f=""+u),a.key!==void 0&&(f=""+a.key),a.ref!==void 0&&(p=a.ref);for(c in a)n.call(a,c)&&!i.hasOwnProperty(c)&&(d[c]=a[c]);if(l&&l.defaultProps)for(c in a=l.defaultProps,a)d[c]===void 0&&(d[c]=a[c]);return{$$typeof:e,type:l,key:f,ref:p,props:d,_owner:s.current}}return cn.Fragment=t,cn.jsx=o,cn.jsxs=o,cn}var dn={};/**
37
37
  * @license React
38
38
  * react-jsx-runtime.development.js
39
39
  *
@@ -41,20 +41,20 @@ ${s}
41
41
  *
42
42
  * This source code is licensed under the MIT license found in the
43
43
  * LICENSE file in the root directory of this source tree.
44
- */var Ea;function tf(){return Ea||(Ea=1,process.env.NODE_ENV!=="production"&&function(){var r=_,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var I=g&&A[g]||A[m];return typeof I=="function"?I:null}var v=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var I=arguments.length,Q=new Array(I>1?I-1:0),oe=1;oe<I;oe++)Q[oe-1]=arguments[oe];C("error",A,Q)}}function C(A,I,Q){{var oe=v.ReactDebugCurrentFrame,we=oe.getStackAddendum();we!==""&&(I+="%s",Q=Q.concat([we]));var ke=Q.map(function(xe){return String(xe)});ke.unshift("Warning: "+I),Function.prototype.apply.call(console[A],console,ke)}}var S=!1,D=!1,w=!1,y=!1,k=!1,N;N=Symbol.for("react.module.reference");function F(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||k||A===s||A===u||A===c||y||A===p||S||D||w||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===l||A.$$typeof===a||A.$$typeof===N||A.getModuleId!==void 0))}function T(A,I,Q){var oe=A.displayName;if(oe)return oe;var we=I.displayName||I.name||"";return we!==""?Q+"("+we+")":Q}function M(A){return A.displayName||"Context"}function L(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case l:var I=A;return M(I)+".Consumer";case o:var Q=A;return M(Q._context)+".Provider";case a:return T(A,A.render,"ForwardRef");case d:var oe=A.displayName||null;return oe!==null?oe:L(A.type)||"Memo";case f:{var we=A,ke=we._payload,xe=we._init;try{return L(xe(ke))}catch{return null}}}return null}var E=Object.assign,B=0,R,O,H,U,Z,q,K;function $(){}$.__reactDisabledLog=!0;function re(){{if(B===0){R=console.log,O=console.info,H=console.warn,U=console.error,Z=console.group,q=console.groupCollapsed,K=console.groupEnd;var A={configurable:!0,enumerable:!0,value:$,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}B++}}function ae(){{if(B--,B===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:E({},A,{value:R}),info:E({},A,{value:O}),warn:E({},A,{value:H}),error:E({},A,{value:U}),group:E({},A,{value:Z}),groupCollapsed:E({},A,{value:q}),groupEnd:E({},A,{value:K})})}B<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var le=v.ReactCurrentDispatcher,ce;function ve(A,I,Q){{if(ce===void 0)try{throw Error()}catch(we){var oe=we.stack.trim().match(/\n( *(at )?)/);ce=oe&&oe[1]||""}return`
45
- `+ce+A}}var pe=!1,Fe;{var et=typeof WeakMap=="function"?WeakMap:Map;Fe=new et}function ct(A,I){if(!A||pe)return"";{var Q=Fe.get(A);if(Q!==void 0)return Q}var oe;pe=!0;var we=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ke;ke=le.current,le.current=null,re();try{if(I){var xe=function(){throw Error()};if(Object.defineProperty(xe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(xe,[])}catch(ft){oe=ft}Reflect.construct(A,[],xe)}else{try{xe.call()}catch(ft){oe=ft}A.call(xe.prototype)}}else{try{throw Error()}catch(ft){oe=ft}A()}}catch(ft){if(ft&&oe&&typeof ft.stack=="string"){for(var be=ft.stack.split(`
46
- `),ot=oe.stack.split(`
47
- `),Ue=be.length-1,Ve=ot.length-1;Ue>=1&&Ve>=0&&be[Ue]!==ot[Ve];)Ve--;for(;Ue>=1&&Ve>=0;Ue--,Ve--)if(be[Ue]!==ot[Ve]){if(Ue!==1||Ve!==1)do if(Ue--,Ve--,Ve<0||be[Ue]!==ot[Ve]){var Ct=`
48
- `+be[Ue].replace(" at new "," at ");return A.displayName&&Ct.includes("<anonymous>")&&(Ct=Ct.replace("<anonymous>",A.displayName)),typeof A=="function"&&Fe.set(A,Ct),Ct}while(Ue>=1&&Ve>=0);break}}}finally{pe=!1,le.current=ke,ae(),Error.prepareStackTrace=we}var zr=A?A.displayName||A.name:"",_r=zr?ve(zr):"";return typeof A=="function"&&Fe.set(A,_r),_r}function kt(A,I,Q){return ct(A,!1)}function tt(A){var I=A.prototype;return!!(I&&I.isReactComponent)}function xt(A,I,Q){if(A==null)return"";if(typeof A=="function")return ct(A,tt(A));if(typeof A=="string")return ve(A);switch(A){case u:return ve("Suspense");case c:return ve("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case a:return kt(A.render);case d:return xt(A.type,I,Q);case f:{var oe=A,we=oe._payload,ke=oe._init;try{return xt(ke(we),I,Q)}catch{}}}return""}var dt=Object.prototype.hasOwnProperty,It={},ue=v.ReactDebugCurrentFrame;function _e(A){if(A){var I=A._owner,Q=xt(A.type,A._source,I?I.type:null);ue.setExtraStackFrame(Q)}else ue.setExtraStackFrame(null)}function Te(A,I,Q,oe,we){{var ke=Function.call.bind(dt);for(var xe in A)if(ke(A,xe)){var be=void 0;try{if(typeof A[xe]!="function"){var ot=Error((oe||"React class")+": "+Q+" type `"+xe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[xe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ot.name="Invariant Violation",ot}be=A[xe](I,xe,oe,Q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ue){be=Ue}be&&!(be instanceof Error)&&(_e(we),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",oe||"React class",Q,xe,typeof be),_e(null)),be instanceof Error&&!(be.message in It)&&(It[be.message]=!0,_e(we),b("Failed %s type: %s",Q,be.message),_e(null))}}}var it=Array.isArray;function Je(A){return it(A)}function X(A){{var I=typeof Symbol=="function"&&Symbol.toStringTag,Q=I&&A[Symbol.toStringTag]||A.constructor.name||"Object";return Q}}function Ne(A){try{return Me(A),!1}catch{return!0}}function Me(A){return""+A}function Re(A){if(Ne(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",X(A)),Me(A)}var zt=v.ReactCurrentOwner,$t={key:!0,ref:!0,__self:!0,__source:!0},Jt,ee;function se(A){if(dt.call(A,"ref")){var I=Object.getOwnPropertyDescriptor(A,"ref").get;if(I&&I.isReactWarning)return!1}return A.ref!==void 0}function je(A){if(dt.call(A,"key")){var I=Object.getOwnPropertyDescriptor(A,"key").get;if(I&&I.isReactWarning)return!1}return A.key!==void 0}function $e(A,I){typeof A.ref=="string"&&zt.current}function qe(A,I){{var Q=function(){Jt||(Jt=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",I))};Q.isReactWarning=!0,Object.defineProperty(A,"key",{get:Q,configurable:!0})}}function Dt(A,I){{var Q=function(){ee||(ee=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",I))};Q.isReactWarning=!0,Object.defineProperty(A,"ref",{get:Q,configurable:!0})}}var Y=function(A,I,Q,oe,we,ke,xe){var be={$$typeof:e,type:A,key:I,ref:Q,props:xe,_owner:ke};return be._store={},Object.defineProperty(be._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(be,"_self",{configurable:!1,enumerable:!1,writable:!1,value:oe}),Object.defineProperty(be,"_source",{configurable:!1,enumerable:!1,writable:!1,value:we}),Object.freeze&&(Object.freeze(be.props),Object.freeze(be)),be};function j(A,I,Q,oe,we){{var ke,xe={},be=null,ot=null;Q!==void 0&&(Re(Q),be=""+Q),je(I)&&(Re(I.key),be=""+I.key),se(I)&&(ot=I.ref,$e(I,we));for(ke in I)dt.call(I,ke)&&!$t.hasOwnProperty(ke)&&(xe[ke]=I[ke]);if(A&&A.defaultProps){var Ue=A.defaultProps;for(ke in Ue)xe[ke]===void 0&&(xe[ke]=Ue[ke])}if(be||ot){var Ve=typeof A=="function"?A.displayName||A.name||"Unknown":A;be&&qe(xe,Ve),ot&&Dt(xe,Ve)}return Y(A,be,ot,we,oe,zt.current,xe)}}var ne=v.ReactCurrentOwner,ie=v.ReactDebugCurrentFrame;function W(A){if(A){var I=A._owner,Q=xt(A.type,A._source,I?I.type:null);ie.setExtraStackFrame(Q)}else ie.setExtraStackFrame(null)}var ge;ge=!1;function de(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function fe(){{if(ne.current){var A=L(ne.current.type);if(A)return`
44
+ */var Ea;function rf(){return Ea||(Ea=1,process.env.NODE_ENV!=="production"&&function(){var r=v,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var O=g&&A[g]||A[m];return typeof O=="function"?O:null}var w=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(A){{for(var O=arguments.length,J=new Array(O>1?O-1:0),pe=1;pe<O;pe++)J[pe-1]=arguments[pe];C("error",A,J)}}function C(A,O,J){{var pe=w.ReactDebugCurrentFrame,Be=pe.getStackAddendum();Be!==""&&(O+="%s",J=J.concat([Be]));var je=J.map(function(Ae){return String(Ae)});je.unshift("Warning: "+O),Function.prototype.apply.call(console[A],console,je)}}var S=!1,D=!1,_=!1,b=!1,E=!1,N;N=Symbol.for("react.module.reference");function R(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||E||A===s||A===u||A===c||b||A===p||S||D||_||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===l||A.$$typeof===a||A.$$typeof===N||A.getModuleId!==void 0))}function T(A,O,J){var pe=A.displayName;if(pe)return pe;var Be=O.displayName||O.name||"";return Be!==""?J+"("+Be+")":J}function F(A){return A.displayName||"Context"}function L(A){if(A==null)return null;if(typeof A.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case l:var O=A;return F(O)+".Consumer";case o:var J=A;return F(J._context)+".Provider";case a:return T(A,A.render,"ForwardRef");case d:var pe=A.displayName||null;return pe!==null?pe:L(A.type)||"Memo";case f:{var Be=A,je=Be._payload,Ae=Be._init;try{return L(Ae(je))}catch{return null}}}return null}var k=Object.assign,B=0,M,I,W,$,ee,q,Y;function z(){}z.__reactDisabledLog=!0;function ie(){{if(B===0){M=console.log,I=console.info,W=console.warn,$=console.error,ee=console.group,q=console.groupCollapsed,Y=console.groupEnd;var A={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}B++}}function ce(){{if(B--,B===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:k({},A,{value:M}),info:k({},A,{value:I}),warn:k({},A,{value:W}),error:k({},A,{value:$}),group:k({},A,{value:ee}),groupCollapsed:k({},A,{value:q}),groupEnd:k({},A,{value:Y})})}B<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=w.ReactCurrentDispatcher,me;function X(A,O,J){{if(me===void 0)try{throw Error()}catch(Be){var pe=Be.stack.trim().match(/\n( *(at )?)/);me=pe&&pe[1]||""}return`
45
+ `+me+A}}var oe=!1,G;{var Ee=typeof WeakMap=="function"?WeakMap:Map;G=new Ee}function Ne(A,O){if(!A||oe)return"";{var J=G.get(A);if(J!==void 0)return J}var pe;oe=!0;var Be=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var je;je=de.current,de.current=null,ie();try{if(O){var Ae=function(){throw Error()};if(Object.defineProperty(Ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ae,[])}catch(gt){pe=gt}Reflect.construct(A,[],Ae)}else{try{Ae.call()}catch(gt){pe=gt}A.call(Ae.prototype)}}else{try{throw Error()}catch(gt){pe=gt}A()}}catch(gt){if(gt&&pe&&typeof gt.stack=="string"){for(var Te=gt.stack.split(`
46
+ `),dt=pe.stack.split(`
47
+ `),Qe=Te.length-1,Ze=dt.length-1;Qe>=1&&Ze>=0&&Te[Qe]!==dt[Ze];)Ze--;for(;Qe>=1&&Ze>=0;Qe--,Ze--)if(Te[Qe]!==dt[Ze]){if(Qe!==1||Ze!==1)do if(Qe--,Ze--,Ze<0||Te[Qe]!==dt[Ze]){var kt=`
48
+ `+Te[Qe].replace(" at new "," at ");return A.displayName&&kt.includes("<anonymous>")&&(kt=kt.replace("<anonymous>",A.displayName)),typeof A=="function"&&G.set(A,kt),kt}while(Qe>=1&&Ze>=0);break}}}finally{oe=!1,de.current=je,ce(),Error.prepareStackTrace=Be}var zr=A?A.displayName||A.name:"",vr=zr?X(zr):"";return typeof A=="function"&&G.set(A,vr),vr}function xe(A,O,J){return Ne(A,!1)}function ye(A){var O=A.prototype;return!!(O&&O.isReactComponent)}function ue(A,O,J){if(A==null)return"";if(typeof A=="function")return Ne(A,ye(A));if(typeof A=="string")return X(A);switch(A){case u:return X("Suspense");case c:return X("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case a:return xe(A.render);case d:return ue(A.type,O,J);case f:{var pe=A,Be=pe._payload,je=pe._init;try{return ue(je(Be),O,J)}catch{}}}return""}var ae=Object.prototype.hasOwnProperty,ke={},te=w.ReactDebugCurrentFrame;function ge(A){if(A){var O=A._owner,J=ue(A.type,A._source,O?O.type:null);te.setExtraStackFrame(J)}else te.setExtraStackFrame(null)}function be(A,O,J,pe,Be){{var je=Function.call.bind(ae);for(var Ae in A)if(je(A,Ae)){var Te=void 0;try{if(typeof A[Ae]!="function"){var dt=Error((pe||"React class")+": "+J+" type `"+Ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Ae]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw dt.name="Invariant Violation",dt}Te=A[Ae](O,Ae,pe,J,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Qe){Te=Qe}Te&&!(Te instanceof Error)&&(ge(Be),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",pe||"React class",J,Ae,typeof Te),ge(null)),Te instanceof Error&&!(Te.message in ke)&&(ke[Te.message]=!0,ge(Be),y("Failed %s type: %s",J,Te.message),ge(null))}}}var Xe=Array.isArray;function st(A){return Xe(A)}function Z(A){{var O=typeof Symbol=="function"&&Symbol.toStringTag,J=O&&A[Symbol.toStringTag]||A.constructor.name||"Object";return J}}function Ie(A){try{return $e(A),!1}catch{return!0}}function $e(A){return""+A}function ze(A){if(Ie(A))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Z(A)),$e(A)}var zt=w.ReactCurrentOwner,$t={key:!0,ref:!0,__self:!0,__source:!0},Jt,ne;function fe(A){if(ae.call(A,"ref")){var O=Object.getOwnPropertyDescriptor(A,"ref").get;if(O&&O.isReactWarning)return!1}return A.ref!==void 0}function qe(A){if(ae.call(A,"key")){var O=Object.getOwnPropertyDescriptor(A,"key").get;if(O&&O.isReactWarning)return!1}return A.key!==void 0}function Ke(A,O){typeof A.ref=="string"&&zt.current}function Ye(A,O){{var J=function(){Jt||(Jt=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};J.isReactWarning=!0,Object.defineProperty(A,"key",{get:J,configurable:!0})}}function At(A,O){{var J=function(){ne||(ne=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",O))};J.isReactWarning=!0,Object.defineProperty(A,"ref",{get:J,configurable:!0})}}var Q=function(A,O,J,pe,Be,je,Ae){var Te={$$typeof:e,type:A,key:O,ref:J,props:Ae,_owner:je};return Te._store={},Object.defineProperty(Te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:pe}),Object.defineProperty(Te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Be}),Object.freeze&&(Object.freeze(Te.props),Object.freeze(Te)),Te};function j(A,O,J,pe,Be){{var je,Ae={},Te=null,dt=null;J!==void 0&&(ze(J),Te=""+J),qe(O)&&(ze(O.key),Te=""+O.key),fe(O)&&(dt=O.ref,Ke(O,Be));for(je in O)ae.call(O,je)&&!$t.hasOwnProperty(je)&&(Ae[je]=O[je]);if(A&&A.defaultProps){var Qe=A.defaultProps;for(je in Qe)Ae[je]===void 0&&(Ae[je]=Qe[je])}if(Te||dt){var Ze=typeof A=="function"?A.displayName||A.name||"Unknown":A;Te&&Ye(Ae,Ze),dt&&At(Ae,Ze)}return Q(A,Te,dt,Be,pe,zt.current,Ae)}}var le=w.ReactCurrentOwner,he=w.ReactDebugCurrentFrame;function V(A){if(A){var O=A._owner,J=ue(A.type,A._source,O?O.type:null);he.setExtraStackFrame(J)}else he.setExtraStackFrame(null)}var Ce;Ce=!1;function ve(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function _e(){{if(le.current){var A=L(le.current.type);if(A)return`
49
49
 
50
- Check the render method of \``+A+"`."}return""}}function Se(A){return""}var Be={};function he(A){{var I=fe();if(!I){var Q=typeof A=="string"?A:A.displayName||A.name;Q&&(I=`
50
+ Check the render method of \``+A+"`."}return""}}function Me(A){return""}var Oe={};function we(A){{var O=_e();if(!O){var J=typeof A=="string"?A:A.displayName||A.name;J&&(O=`
51
51
 
52
- Check the top-level render call using <`+Q+">.")}return I}}function me(A,I){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var Q=he(I);if(Be[Q])return;Be[Q]=!0;var oe="";A&&A._owner&&A._owner!==ne.current&&(oe=" It was passed a child from "+L(A._owner.type)+"."),W(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Q,oe),W(null)}}function We(A,I){{if(typeof A!="object")return;if(Je(A))for(var Q=0;Q<A.length;Q++){var oe=A[Q];de(oe)&&me(oe,I)}else if(de(A))A._store&&(A._store.validated=!0);else if(A){var we=x(A);if(typeof we=="function"&&we!==A.entries)for(var ke=we.call(A),xe;!(xe=ke.next()).done;)de(xe.value)&&me(xe.value,I)}}}function Ge(A){{var I=A.type;if(I==null||typeof I=="string")return;var Q;if(typeof I=="function")Q=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===a||I.$$typeof===d))Q=I.propTypes;else return;if(Q){var oe=L(I);Te(Q,A.props,"prop",oe,A)}else if(I.PropTypes!==void 0&&!ge){ge=!0;var we=L(I);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",we||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Le(A){{for(var I=Object.keys(A.props),Q=0;Q<I.length;Q++){var oe=I[Q];if(oe!=="children"&&oe!=="key"){W(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",oe),W(null);break}}A.ref!==null&&(W(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),W(null))}}var De={};function rt(A,I,Q,oe,we,ke){{var xe=F(A);if(!xe){var be="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(be+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ot=Se();ot?be+=ot:be+=fe();var Ue;A===null?Ue="null":Je(A)?Ue="array":A!==void 0&&A.$$typeof===e?(Ue="<"+(L(A.type)||"Unknown")+" />",be=" Did you accidentally export a JSX literal instead of a component?"):Ue=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ue,be)}var Ve=j(A,I,Q,we,ke);if(Ve==null)return Ve;if(xe){var Ct=I.children;if(Ct!==void 0)if(oe)if(Je(Ct)){for(var zr=0;zr<Ct.length;zr++)We(Ct[zr],A);Object.freeze&&Object.freeze(Ct)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else We(Ct,A)}if(dt.call(I,"key")){var _r=L(A),ft=Object.keys(I).filter(function(Dd){return Dd!=="key"}),Si=ft.length>0?"{key: someKey, "+ft.join(": ..., ")+": ...}":"{key: someKey}";if(!De[_r+Si]){var kd=ft.length>0?"{"+ft.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+J+">.")}return O}}function Se(A,O){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var J=we(O);if(Oe[J])return;Oe[J]=!0;var pe="";A&&A._owner&&A._owner!==le.current&&(pe=" It was passed a child from "+L(A._owner.type)+"."),V(A),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',J,pe),V(null)}}function Je(A,O){{if(typeof A!="object")return;if(st(A))for(var J=0;J<A.length;J++){var pe=A[J];ve(pe)&&Se(pe,O)}else if(ve(A))A._store&&(A._store.validated=!0);else if(A){var Be=x(A);if(typeof Be=="function"&&Be!==A.entries)for(var je=Be.call(A),Ae;!(Ae=je.next()).done;)ve(Ae.value)&&Se(Ae.value,O)}}}function tt(A){{var O=A.type;if(O==null||typeof O=="string")return;var J;if(typeof O=="function")J=O.propTypes;else if(typeof O=="object"&&(O.$$typeof===a||O.$$typeof===d))J=O.propTypes;else return;if(J){var pe=L(O);be(J,A.props,"prop",pe,A)}else if(O.PropTypes!==void 0&&!Ce){Ce=!0;var Be=L(O);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Be||"Unknown")}typeof O.getDefaultProps=="function"&&!O.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ue(A){{for(var O=Object.keys(A.props),J=0;J<O.length;J++){var pe=O[J];if(pe!=="children"&&pe!=="key"){V(A),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",pe),V(null);break}}A.ref!==null&&(V(A),y("Invalid attribute `ref` supplied to `React.Fragment`."),V(null))}}var Le={};function lt(A,O,J,pe,Be,je){{var Ae=R(A);if(!Ae){var Te="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Te+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var dt=Me();dt?Te+=dt:Te+=_e();var Qe;A===null?Qe="null":st(A)?Qe="array":A!==void 0&&A.$$typeof===e?(Qe="<"+(L(A.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):Qe=typeof A,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Qe,Te)}var Ze=j(A,O,J,Be,je);if(Ze==null)return Ze;if(Ae){var kt=O.children;if(kt!==void 0)if(pe)if(st(kt)){for(var zr=0;zr<kt.length;zr++)Je(kt[zr],A);Object.freeze&&Object.freeze(kt)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(kt,A)}if(ae.call(O,"key")){var vr=L(A),gt=Object.keys(O).filter(function(Ad){return Ad!=="key"}),Si=gt.length>0?"{key: someKey, "+gt.join(": ..., ")+": ...}":"{key: someKey}";if(!Le[vr+Si]){var Dd=gt.length>0?"{"+gt.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
53
53
  let props = %s;
54
54
  <%s {...props} />
55
55
  React keys must be passed directly to JSX without using spread:
56
56
  let props = %s;
57
- <%s key={someKey} {...props} />`,Si,_r,kd,_r),De[_r+Si]=!0}}return A===n?Le(Ve):Ge(Ve),Ve}}function nt(A,I,Q){return rt(A,I,Q,!0)}function wt(A,I,Q){return rt(A,I,Q,!1)}var Zt=wt,At=nt;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=At}()),dn}process.env.NODE_ENV==="production"?Hi.exports=ef():Hi.exports=tf();var h=Hi.exports;const ou=_.createContext(void 0);function rf({apiUrl:r,systemId:e,children:t}){const[n,s]=_.useState(null),[i,o]=_.useState(null),[l,a]=_.useState(!1),[u,c]=_.useState(!0),[d]=_.useState(()=>new To({apiUrl:r,systemId:e})),f=_.useCallback(async D=>{const w=await d.isAdmin(D);a(w)},[d]),p=_.useCallback(()=>{const D=ht.getToken(),w=ht.getUser();D&&w?(o(D),s(w),f(w._id).finally(()=>c(!1))):c(!1)},[f]);_.useEffect(()=>{p()},[p]);const g=_.useCallback(async(D,w)=>{const y=await d.login(D,w);return y.success&&y.user&&y.token&&(o(y.token),s(y.user),await f(y.user._id)),y},[d,f]),m=_.useCallback(async(D,w,y)=>d.register(D,w,y),[d]),x=_.useCallback(async(D,w)=>{const y=await d.verifyEmail(D,w);return y.success&&y.user&&y.token&&(o(y.token),s(y.user),await f(y.user._id)),y},[d,f]),v=_.useCallback(async D=>d.requestPasswordReset(D),[d]),b=_.useCallback(async(D,w,y)=>{const k=await d.setPasswordWithCode(D,w,y);return k.success&&k.user&&k.token&&(o(k.token),s(k.user),await f(k.user._id)),k},[d,f]),C=_.useCallback(async D=>d.resendVerificationCode(D),[d]),S=_.useCallback(()=>{d.logout(),s(null),o(null),a(!1)},[d]);return h.jsx(ou.Provider,{value:{user:n,token:i,isAdmin:l,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:v,setPasswordWithCode:b,resendVerificationCode:C,logout:S,refreshUser:p},children:t})}function nf(){const r=_.useContext(ou);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const sf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Bo({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:l="Mot de passe",theme:a,className:u="",isModal:c=!1}){const[d,f]=_.useState(""),[p,g]=_.useState(""),[m,x]=_.useState(""),[v,b]=_.useState(!1),C={...sf,...a};async function S(F){F.preventDefault(),b(!0),x("");const T=await r(d,p);T.success?e==null||e():x(T.error||"Connexion impossible"),b(!1)}const D={backgroundColor:C.backgroundColor,borderRadius:C.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...c&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},w={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${C.borderColor}`,borderRadius:C.borderRadius,backgroundColor:C.inputBackground,color:C.textColor,fontSize:"1rem",outline:"none"},y={display:"block",fontSize:"0.875rem",fontWeight:500,color:C.textMutedColor,marginBottom:"0.25rem"},k={width:"100%",padding:"0.75rem",backgroundColor:v?C.textMutedColor:C.primaryColor,color:"#ffffff",border:"none",borderRadius:C.borderRadius,fontSize:"1rem",fontWeight:500,cursor:v?"not-allowed":"pointer",transition:"background-color 0.2s"},N={padding:"0.75rem",backgroundColor:C.errorBackgroundColor,border:`1px solid ${C.errorColor}20`,borderRadius:C.borderRadius,marginBottom:"1rem"};return h.jsxs("div",{style:D,className:u,children:[t&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:C.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:S,children:[m&&h.jsx("div",{style:N,children:h.jsx("p",{style:{fontSize:"0.875rem",color:C.errorColor,margin:0},children:m})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:y,children:o}),h.jsx("input",{type:"email",value:d,onChange:F=>f(F.target.value),required:!0,style:w,onFocus:F=>{F.target.style.borderColor=C.primaryColor,F.target.style.boxShadow=`0 0 0 2px ${C.primaryColor}20`},onBlur:F=>{F.target.style.borderColor=C.borderColor,F.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:y,children:l}),h.jsx("input",{type:"password",value:p,onChange:F=>g(F.target.value),required:!0,style:w,onFocus:F=>{F.target.style.borderColor=C.primaryColor,F.target.style.boxShadow=`0 0 0 2px ${C.primaryColor}20`},onBlur:F=>{F.target.style.borderColor=C.borderColor,F.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:v,style:k,onMouseEnter:F=>{v||(F.target.style.backgroundColor=C.primaryHoverColor)},onMouseLeave:F=>{v||(F.target.style.backgroundColor=C.primaryColor)},children:v?i:s})]})]})}function of({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){if(!r)return null;const s={position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},i={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},o={position:"relative",animation:"slideUp 0.2s ease-out"};return h.jsxs("div",{style:s,children:[h.jsx("div",{style:i,onClick:e}),h.jsxs("div",{style:o,children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},onMouseEnter:l=>{l.target.style.color="#4B5563"},onMouseLeave:l=>{l.target.style.color="#9CA3AF"},children:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(Bo,{...n,isModal:!0})]}),h.jsx("style",{children:`
57
+ <%s key={someKey} {...props} />`,Si,vr,Dd,vr),Le[vr+Si]=!0}}return A===n?Ue(Ze):tt(Ze),Ze}}function ut(A,O,J){return lt(A,O,J,!0)}function St(A,O,J){return lt(A,O,J,!1)}var Zt=St,Tt=ut;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=Tt}()),dn}process.env.NODE_ENV==="production"?Gi.exports=tf():Gi.exports=rf();var h=Gi.exports;const au=v.createContext(void 0);function nf({apiUrl:r,systemId:e,children:t}){const[n,s]=v.useState(null),[i,o]=v.useState(null),[l,a]=v.useState(!1),[u,c]=v.useState(!0),[d]=v.useState(()=>new No({apiUrl:r,systemId:e})),f=v.useCallback(async D=>{const _=await d.isAdmin(D);a(_)},[d]),p=v.useCallback(()=>{const D=mt.getToken(),_=mt.getUser();D&&_?(o(D),s(_),f(_._id).finally(()=>c(!1))):c(!1)},[f]);v.useEffect(()=>{p()},[p]);const g=v.useCallback(async(D,_)=>{const b=await d.login(D,_);return b.success&&b.user&&b.token&&(o(b.token),s(b.user),await f(b.user._id)),b},[d,f]),m=v.useCallback(async(D,_,b)=>d.register(D,_,b),[d]),x=v.useCallback(async(D,_)=>{const b=await d.verifyEmail(D,_);return b.success&&b.user&&b.token&&(o(b.token),s(b.user),await f(b.user._id)),b},[d,f]),w=v.useCallback(async D=>d.requestPasswordReset(D),[d]),y=v.useCallback(async(D,_,b)=>{const E=await d.setPasswordWithCode(D,_,b);return E.success&&E.user&&E.token&&(o(E.token),s(E.user),await f(E.user._id)),E},[d,f]),C=v.useCallback(async D=>d.resendVerificationCode(D),[d]),S=v.useCallback(()=>{d.logout(),s(null),o(null),a(!1)},[d]);return h.jsx(au.Provider,{value:{user:n,token:i,isAdmin:l,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:w,setPasswordWithCode:y,resendVerificationCode:C,logout:S,refreshUser:p},children:t})}function sf(){const r=v.useContext(au);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const of={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Ro({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:l="Mot de passe",theme:a,className:u="",isModal:c=!1}){const[d,f]=v.useState(""),[p,g]=v.useState(""),[m,x]=v.useState(""),[w,y]=v.useState(!1),C={...of,...a};async function S(R){R.preventDefault(),y(!0),x("");const T=await r(d,p);T.success?e==null||e():x(T.error||"Connexion impossible"),y(!1)}const D={backgroundColor:C.backgroundColor,borderRadius:C.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...c&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},_={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${C.borderColor}`,borderRadius:C.borderRadius,backgroundColor:C.inputBackground,color:C.textColor,fontSize:"1rem",outline:"none"},b={display:"block",fontSize:"0.875rem",fontWeight:500,color:C.textMutedColor,marginBottom:"0.25rem"},E={width:"100%",padding:"0.75rem",backgroundColor:w?C.textMutedColor:C.primaryColor,color:"#ffffff",border:"none",borderRadius:C.borderRadius,fontSize:"1rem",fontWeight:500,cursor:w?"not-allowed":"pointer",transition:"background-color 0.2s"},N={padding:"0.75rem",backgroundColor:C.errorBackgroundColor,border:`1px solid ${C.errorColor}20`,borderRadius:C.borderRadius,marginBottom:"1rem"};return h.jsxs("div",{style:D,className:u,children:[t&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:C.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:S,children:[m&&h.jsx("div",{style:N,children:h.jsx("p",{style:{fontSize:"0.875rem",color:C.errorColor,margin:0},children:m})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:b,children:o}),h.jsx("input",{type:"email",value:d,onChange:R=>f(R.target.value),required:!0,style:_,onFocus:R=>{R.target.style.borderColor=C.primaryColor,R.target.style.boxShadow=`0 0 0 2px ${C.primaryColor}20`},onBlur:R=>{R.target.style.borderColor=C.borderColor,R.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:b,children:l}),h.jsx("input",{type:"password",value:p,onChange:R=>g(R.target.value),required:!0,style:_,onFocus:R=>{R.target.style.borderColor=C.primaryColor,R.target.style.boxShadow=`0 0 0 2px ${C.primaryColor}20`},onBlur:R=>{R.target.style.borderColor=C.borderColor,R.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:w,style:E,onMouseEnter:R=>{w||(R.target.style.backgroundColor=C.primaryHoverColor)},onMouseLeave:R=>{w||(R.target.style.backgroundColor=C.primaryColor)},children:w?i:s})]})]})}function af({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){if(!r)return null;const s={position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},i={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},o={position:"relative",animation:"slideUp 0.2s ease-out"};return h.jsxs("div",{style:s,children:[h.jsx("div",{style:i,onClick:e}),h.jsxs("div",{style:o,children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},onMouseEnter:l=>{l.target.style.color="#4B5563"},onMouseLeave:l=>{l.target.style.color="#9CA3AF"},children:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(Ro,{...n,isModal:!0})]}),h.jsx("style",{children:`
58
58
  @keyframes slideUp {
59
59
  from {
60
60
  opacity: 0;
@@ -65,7 +65,7 @@ React keys must be passed directly to JSX without using spread:
65
65
  transform: translateY(0);
66
66
  }
67
67
  }
68
- `})]})}const af={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function au({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:l="Email",passwordLabel:a="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:f="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[v,b]=_.useState(""),[C,S]=_.useState(""),[D,w]=_.useState(""),[y,k]=_.useState(""),[N,F]=_.useState(""),[T,M]=_.useState(""),[L,E]=_.useState(!1),B={...af,...g};async function R($){if($.preventDefault(),M(""),C!==D){M("Les mots de passe ne correspondent pas");return}if(C.length<8){M("Le mot de passe doit contenir au moins 8 caractères");return}E(!0);const ae=await r(v,C,p?{firstName:y,lastName:N}:void 0);ae.success?e==null||e(v):M(ae.error||"Erreur lors de l'inscription"),E(!1)}const O={backgroundColor:B.backgroundColor,borderRadius:B.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},H={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${B.borderColor}`,borderRadius:B.borderRadius,backgroundColor:B.inputBackground,color:B.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},U={display:"block",fontSize:"0.875rem",fontWeight:500,color:B.textMutedColor,marginBottom:"0.25rem"},Z={width:"100%",padding:"0.75rem",backgroundColor:L?B.textMutedColor:B.primaryColor,color:"#ffffff",border:"none",borderRadius:B.borderRadius,fontSize:"1rem",fontWeight:500,cursor:L?"not-allowed":"pointer",transition:"background-color 0.2s"},q={padding:"0.75rem",backgroundColor:B.errorBackgroundColor,border:`1px solid ${B.errorColor}20`,borderRadius:B.borderRadius,marginBottom:"1rem"},K={color:B.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return h.jsxs("div",{style:O,className:m,children:[n&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:B.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:R,children:[T&&h.jsx("div",{style:q,children:h.jsx("p",{style:{fontSize:"0.875rem",color:B.errorColor,margin:0},children:T})}),p&&h.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:U,children:c}),h.jsx("input",{type:"text",value:y,onChange:$=>k($.target.value),style:H})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:U,children:d}),h.jsx("input",{type:"text",value:N,onChange:$=>F($.target.value),style:H})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:U,children:l}),h.jsx("input",{type:"email",value:v,onChange:$=>b($.target.value),required:!0,style:H})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:U,children:a}),h.jsx("input",{type:"password",value:C,onChange:$=>S($.target.value),required:!0,minLength:8,style:H})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:U,children:u}),h.jsx("input",{type:"password",value:D,onChange:$=>w($.target.value),required:!0,style:H})]}),h.jsx("button",{type:"submit",disabled:L,style:Z,onMouseEnter:$=>{L||($.target.style.backgroundColor=B.primaryHoverColor)},onMouseLeave:$=>{L||($.target.style.backgroundColor=B.primaryColor)},children:L?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:K,onClick:t,children:f})})]})]})}const lf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:l="Vérifier",loadingText:a="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:f=6,theme:p,className:g="",isModal:m=!1}){const[x,v]=_.useState(Array(f).fill("")),[b,C]=_.useState(""),[S,D]=_.useState(!1),[w,y]=_.useState(!1),[k,N]=_.useState(!1),F=_.useRef([]),T={...lf,...p};_.useEffect(()=>{var q;(q=F.current[0])==null||q.focus()},[]);const M=(q,K)=>{var ae;const $=K.replace(/\D/g,"").slice(-1),re=[...x];if(re[q]=$,v(re),C(""),$&&q<f-1&&((ae=F.current[q+1])==null||ae.focus()),$&&q===f-1){const le=re.join("");le.length===f&&B(le)}},L=(q,K)=>{var $;K.key==="Backspace"&&!x[q]&&q>0&&(($=F.current[q-1])==null||$.focus())},E=q=>{var ae;q.preventDefault();const K=q.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),$=[...x];K.split("").forEach((le,ce)=>{ce<f&&($[ce]=le)}),v($);const re=Math.min(K.length,f)-1;re>=0&&((ae=F.current[re])==null||ae.focus()),K.length===f&&B(K)};async function B(q){var re;const K=q||x.join("");if(K.length!==f){C("Veuillez entrer le code complet");return}D(!0),C("");const $=await e(r,K);$.success?t==null||t():(C($.error||"Code invalide"),v(Array(f).fill("")),(re=F.current[0])==null||re.focus()),D(!1)}async function R(){if(!n)return;y(!0),N(!1),C("");const q=await n(r);q.success?(N(!0),setTimeout(()=>N(!1),3e3)):C(q.error||"Erreur lors de l'envoi"),y(!1)}const O={backgroundColor:T.backgroundColor,borderRadius:T.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},H={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${T.borderColor}`,borderRadius:T.borderRadius,backgroundColor:T.inputBackground,color:T.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},U={width:"100%",padding:"0.75rem",backgroundColor:S?T.textMutedColor:T.primaryColor,color:"#ffffff",border:"none",borderRadius:T.borderRadius,fontSize:"1rem",fontWeight:500,cursor:S?"not-allowed":"pointer",transition:"background-color 0.2s"},Z={color:T.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:O,className:g,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:T.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),h.jsx("p",{style:{fontSize:"0.875rem",color:T.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),b&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:T.errorBackgroundColor,border:`1px solid ${T.errorColor}20`,borderRadius:T.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:T.errorColor,margin:0,textAlign:"center"},children:b})}),k&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${T.successColor}20`,borderRadius:T.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:T.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),h.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((q,K)=>h.jsx("input",{ref:$=>{F.current[K]=$},type:"text",inputMode:"numeric",maxLength:1,value:q,onChange:$=>M(K,$.target.value),onKeyDown:$=>L(K,$),onPaste:E,disabled:S,style:{...H,borderColor:q?T.primaryColor:T.borderColor},onFocus:$=>{$.target.style.borderColor=T.primaryColor,$.target.style.boxShadow=`0 0 0 3px ${T.primaryColor}20`},onBlur:$=>{$.target.style.borderColor=q?T.primaryColor:T.borderColor,$.target.style.boxShadow="none"}},K))}),h.jsx("button",{type:"button",onClick:()=>B(),disabled:S||x.join("").length!==f,style:{...U,opacity:x.join("").length!==f?.5:1},children:S?a:l}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:R,disabled:w,style:{...Z,opacity:w?.5:1},children:w?c:u})}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:Z,children:d})})]})}const uf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function lu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:l="Email",backText:a="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[f,p]=_.useState(""),[g,m]=_.useState(""),[x,v]=_.useState(!1),b={...uf,...u};async function C(N){N.preventDefault(),v(!0),m("");const F=await r(f);F.success?e==null||e(f):m(F.error||"Erreur lors de l'envoi"),v(!1)}const S={backgroundColor:b.backgroundColor,borderRadius:b.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},D={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},w={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},y={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},k={color:b.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:S,className:c,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),h.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),h.jsxs("form",{onSubmit:C,children:[g&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:w,children:l}),h.jsx("input",{type:"email",value:f,onChange:N=>p(N.target.value),required:!0,style:D})]}),h.jsx("button",{type:"submit",disabled:x,style:y,onMouseEnter:N=>{x||(N.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:N=>{x||(N.target.style.backgroundColor=b.primaryColor)},children:x?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:t,style:k,children:a})})]})]})}const cf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:l="Réinitialiser",loadingText:a="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:f,className:p="",isModal:g=!1}){const[m,x]=_.useState(""),[v,b]=_.useState(""),[C,S]=_.useState(""),[D,w]=_.useState(!1),y={...cf,...f};async function k(E){if(E.preventDefault(),S(""),m!==v){S("Les mots de passe ne correspondent pas");return}if(m.length<8){S("Le mot de passe doit contenir au moins 8 caractères");return}w(!0);const B=await t(r,e,m);B.success?n==null||n():S(B.error||"Erreur lors de la réinitialisation"),w(!1)}const N={backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},F={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${y.borderColor}`,borderRadius:y.borderRadius,backgroundColor:y.inputBackground,color:y.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},T={display:"block",fontSize:"0.875rem",fontWeight:500,color:y.textMutedColor,marginBottom:"0.25rem"},M={width:"100%",padding:"0.75rem",backgroundColor:D?y.textMutedColor:y.primaryColor,color:"#ffffff",border:"none",borderRadius:y.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},L={color:y.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:N,className:p,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:y.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&h.jsx("p",{style:{fontSize:"0.875rem",color:y.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),h.jsxs("form",{onSubmit:k,children:[C&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:y.errorBackgroundColor,border:`1px solid ${y.errorColor}20`,borderRadius:y.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:y.errorColor,margin:0},children:C})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:T,children:u}),h.jsx("input",{type:"password",value:m,onChange:E=>x(E.target.value),required:!0,minLength:8,style:F})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:v,onChange:E=>b(E.target.value),required:!0,style:F})]}),h.jsx("button",{type:"submit",disabled:D,style:M,onMouseEnter:E=>{D||(E.target.style.backgroundColor=y.primaryHoverColor)},onMouseLeave:E=>{D||(E.target.style.backgroundColor=y.primaryColor)},children:D?a:l}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:L,children:d})})]})]})}function cu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:l="login",logo:a,theme:u,showNameFields:c=!1,className:d="",isModal:f=!1,labels:p={}}){const[g,m]=_.useState(l),[x,v]=_.useState(""),[b,C]=_.useState("");async function S(F,T){const M=await r(F,T);return M.requiresVerification?(v(F),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):M}async function D(F,T,M){const L=await e(F,T,M);return L.success&&L.requiresVerification&&(v(F),m("verify-email")),L}async function w(F){const T=await n(F);return T.success&&(v(F),m("verify-reset-code")),T}async function y(F,T){return C(T),m("reset-password"),{success:!0}}const k=()=>{switch(g){case"login":return h.jsx(Bo,{onLogin:S,onSuccess:o,logo:a,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(au,{onRegister:D,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:a,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:f});case"verify-email":return h.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:f});case"forgot-password":return h.jsx(lu,{onRequestReset:w,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:f});case"verify-reset-code":return h.jsx(Gi,{email:x,onVerify:y,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:f});case"reset-password":return h.jsx(uu,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},N=()=>{const F={color:(u==null?void 0:u.primaryColor)||"#1877F2",textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return g==="login"?h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1rem",padding:"0 1.5rem",maxWidth:"24rem",width:"100%"},children:[h.jsx("button",{type:"button",onClick:()=>m("forgot-password"),style:F,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:F,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[k(),N()]})}function df({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?h.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[h.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),h.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},children:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(cu,{...n,isModal:!0})]}),h.jsx("style",{children:`
68
+ `})]})}const lf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function lu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:l="Email",passwordLabel:a="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:f="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[w,y]=v.useState(""),[C,S]=v.useState(""),[D,_]=v.useState(""),[b,E]=v.useState(""),[N,R]=v.useState(""),[T,F]=v.useState(""),[L,k]=v.useState(!1),B={...lf,...g};async function M(z){if(z.preventDefault(),F(""),C!==D){F("Les mots de passe ne correspondent pas");return}if(C.length<8){F("Le mot de passe doit contenir au moins 8 caractères");return}k(!0);const ce=await r(w,C,p?{firstName:b,lastName:N}:void 0);ce.success?e==null||e(w):F(ce.error||"Erreur lors de l'inscription"),k(!1)}const I={backgroundColor:B.backgroundColor,borderRadius:B.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},W={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${B.borderColor}`,borderRadius:B.borderRadius,backgroundColor:B.inputBackground,color:B.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},$={display:"block",fontSize:"0.875rem",fontWeight:500,color:B.textMutedColor,marginBottom:"0.25rem"},ee={width:"100%",padding:"0.75rem",backgroundColor:L?B.textMutedColor:B.primaryColor,color:"#ffffff",border:"none",borderRadius:B.borderRadius,fontSize:"1rem",fontWeight:500,cursor:L?"not-allowed":"pointer",transition:"background-color 0.2s"},q={padding:"0.75rem",backgroundColor:B.errorBackgroundColor,border:`1px solid ${B.errorColor}20`,borderRadius:B.borderRadius,marginBottom:"1rem"},Y={color:B.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return h.jsxs("div",{style:I,className:m,children:[n&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:B.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:M,children:[T&&h.jsx("div",{style:q,children:h.jsx("p",{style:{fontSize:"0.875rem",color:B.errorColor,margin:0},children:T})}),p&&h.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:$,children:c}),h.jsx("input",{type:"text",value:b,onChange:z=>E(z.target.value),style:W})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:$,children:d}),h.jsx("input",{type:"text",value:N,onChange:z=>R(z.target.value),style:W})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:$,children:l}),h.jsx("input",{type:"email",value:w,onChange:z=>y(z.target.value),required:!0,style:W})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:$,children:a}),h.jsx("input",{type:"password",value:C,onChange:z=>S(z.target.value),required:!0,minLength:8,style:W})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:$,children:u}),h.jsx("input",{type:"password",value:D,onChange:z=>_(z.target.value),required:!0,style:W})]}),h.jsx("button",{type:"submit",disabled:L,style:ee,onMouseEnter:z=>{L||(z.target.style.backgroundColor=B.primaryHoverColor)},onMouseLeave:z=>{L||(z.target.style.backgroundColor=B.primaryColor)},children:L?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:Y,onClick:t,children:f})})]})]})}const uf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Ki({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:l="Vérifier",loadingText:a="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:f=6,theme:p,className:g="",isModal:m=!1}){const[x,w]=v.useState(Array(f).fill("")),[y,C]=v.useState(""),[S,D]=v.useState(!1),[_,b]=v.useState(!1),[E,N]=v.useState(!1),R=v.useRef([]),T={...uf,...p};v.useEffect(()=>{var q;(q=R.current[0])==null||q.focus()},[]);const F=(q,Y)=>{var ce;const z=Y.replace(/\D/g,"").slice(-1),ie=[...x];if(ie[q]=z,w(ie),C(""),z&&q<f-1&&((ce=R.current[q+1])==null||ce.focus()),z&&q===f-1){const de=ie.join("");de.length===f&&B(de)}},L=(q,Y)=>{var z;Y.key==="Backspace"&&!x[q]&&q>0&&((z=R.current[q-1])==null||z.focus())},k=q=>{var ce;q.preventDefault();const Y=q.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),z=[...x];Y.split("").forEach((de,me)=>{me<f&&(z[me]=de)}),w(z);const ie=Math.min(Y.length,f)-1;ie>=0&&((ce=R.current[ie])==null||ce.focus()),Y.length===f&&B(Y)};async function B(q){var ie;const Y=q||x.join("");if(Y.length!==f){C("Veuillez entrer le code complet");return}D(!0),C("");const z=await e(r,Y);z.success?t==null||t():(C(z.error||"Code invalide"),w(Array(f).fill("")),(ie=R.current[0])==null||ie.focus()),D(!1)}async function M(){if(!n)return;b(!0),N(!1),C("");const q=await n(r);q.success?(N(!0),setTimeout(()=>N(!1),3e3)):C(q.error||"Erreur lors de l'envoi"),b(!1)}const I={backgroundColor:T.backgroundColor,borderRadius:T.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},W={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${T.borderColor}`,borderRadius:T.borderRadius,backgroundColor:T.inputBackground,color:T.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},$={width:"100%",padding:"0.75rem",backgroundColor:S?T.textMutedColor:T.primaryColor,color:"#ffffff",border:"none",borderRadius:T.borderRadius,fontSize:"1rem",fontWeight:500,cursor:S?"not-allowed":"pointer",transition:"background-color 0.2s"},ee={color:T.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:I,className:g,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:T.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),h.jsx("p",{style:{fontSize:"0.875rem",color:T.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),y&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:T.errorBackgroundColor,border:`1px solid ${T.errorColor}20`,borderRadius:T.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:T.errorColor,margin:0,textAlign:"center"},children:y})}),E&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${T.successColor}20`,borderRadius:T.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:T.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),h.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((q,Y)=>h.jsx("input",{ref:z=>{R.current[Y]=z},type:"text",inputMode:"numeric",maxLength:1,value:q,onChange:z=>F(Y,z.target.value),onKeyDown:z=>L(Y,z),onPaste:k,disabled:S,style:{...W,borderColor:q?T.primaryColor:T.borderColor},onFocus:z=>{z.target.style.borderColor=T.primaryColor,z.target.style.boxShadow=`0 0 0 3px ${T.primaryColor}20`},onBlur:z=>{z.target.style.borderColor=q?T.primaryColor:T.borderColor,z.target.style.boxShadow="none"}},Y))}),h.jsx("button",{type:"button",onClick:()=>B(),disabled:S||x.join("").length!==f,style:{...$,opacity:x.join("").length!==f?.5:1},children:S?a:l}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:M,disabled:_,style:{...ee,opacity:_?.5:1},children:_?c:u})}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:ee,children:d})})]})}const cf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:l="Email",backText:a="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[f,p]=v.useState(""),[g,m]=v.useState(""),[x,w]=v.useState(!1),y={...cf,...u};async function C(N){N.preventDefault(),w(!0),m("");const R=await r(f);R.success?e==null||e(f):m(R.error||"Erreur lors de l'envoi"),w(!1)}const S={backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},D={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${y.borderColor}`,borderRadius:y.borderRadius,backgroundColor:y.inputBackground,color:y.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},_={display:"block",fontSize:"0.875rem",fontWeight:500,color:y.textMutedColor,marginBottom:"0.25rem"},b={width:"100%",padding:"0.75rem",backgroundColor:x?y.textMutedColor:y.primaryColor,color:"#ffffff",border:"none",borderRadius:y.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},E={color:y.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:S,className:c,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:y.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),h.jsx("p",{style:{fontSize:"0.875rem",color:y.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),h.jsxs("form",{onSubmit:C,children:[g&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:y.errorBackgroundColor,border:`1px solid ${y.errorColor}20`,borderRadius:y.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:y.errorColor,margin:0},children:g})}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:_,children:l}),h.jsx("input",{type:"email",value:f,onChange:N=>p(N.target.value),required:!0,style:D})]}),h.jsx("button",{type:"submit",disabled:x,style:b,onMouseEnter:N=>{x||(N.target.style.backgroundColor=y.primaryHoverColor)},onMouseLeave:N=>{x||(N.target.style.backgroundColor=y.primaryColor)},children:x?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:t,style:E,children:a})})]})]})}const df={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:l="Réinitialiser",loadingText:a="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:f,className:p="",isModal:g=!1}){const[m,x]=v.useState(""),[w,y]=v.useState(""),[C,S]=v.useState(""),[D,_]=v.useState(!1),b={...df,...f};async function E(k){if(k.preventDefault(),S(""),m!==w){S("Les mots de passe ne correspondent pas");return}if(m.length<8){S("Le mot de passe doit contenir au moins 8 caractères");return}_(!0);const B=await t(r,e,m);B.success?n==null||n():S(B.error||"Erreur lors de la réinitialisation"),_(!1)}const N={backgroundColor:b.backgroundColor,borderRadius:b.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},R={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},T={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},F={width:"100%",padding:"0.75rem",backgroundColor:D?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},L={color:b.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:N,className:p,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&h.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),h.jsxs("form",{onSubmit:E,children:[C&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:C})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:T,children:u}),h.jsx("input",{type:"password",value:m,onChange:k=>x(k.target.value),required:!0,minLength:8,style:R})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:w,onChange:k=>y(k.target.value),required:!0,style:R})]}),h.jsx("button",{type:"submit",disabled:D,style:F,onMouseEnter:k=>{D||(k.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:k=>{D||(k.target.style.backgroundColor=b.primaryColor)},children:D?a:l}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:L,children:d})})]})]})}function du({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:l="login",logo:a,theme:u,showNameFields:c=!1,className:d="",isModal:f=!1,labels:p={}}){const[g,m]=v.useState(l),[x,w]=v.useState(""),[y,C]=v.useState("");async function S(R,T){const F=await r(R,T);return F.requiresVerification?(w(R),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):F}async function D(R,T,F){const L=await e(R,T,F);return L.success&&L.requiresVerification&&(w(R),m("verify-email")),L}async function _(R){const T=await n(R);return T.success&&(w(R),m("verify-reset-code")),T}async function b(R,T){return C(T),m("reset-password"),{success:!0}}const E=()=>{switch(g){case"login":return h.jsx(Ro,{onLogin:S,onSuccess:o,logo:a,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(lu,{onRegister:D,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:a,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:f});case"verify-email":return h.jsx(Ki,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:f});case"forgot-password":return h.jsx(uu,{onRequestReset:_,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:f});case"verify-reset-code":return h.jsx(Ki,{email:x,onVerify:b,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:f});case"reset-password":return h.jsx(cu,{email:x,code:y,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},N=()=>{const R={color:(u==null?void 0:u.primaryColor)||"#1877F2",textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return g==="login"?h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1rem",padding:"0 1.5rem",maxWidth:"24rem",width:"100%"},children:[h.jsx("button",{type:"button",onClick:()=>m("forgot-password"),style:R,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:R,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[E(),N()]})}function ff({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?h.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[h.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),h.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},children:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(du,{...n,isModal:!0})]}),h.jsx("style",{children:`
69
69
  @keyframes authFlowSlideUp {
70
70
  from {
71
71
  opacity: 0;
@@ -76,36 +76,36 @@ React keys must be passed directly to JSX without using spread:
76
76
  transform: translateY(0);
77
77
  }
78
78
  }
79
- `})]}):null}function du(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[l,a]=_.useState(null),[u,c]=_.useState(n),[d,f]=_.useState(null),p=_.useCallback(async()=>{if(n){c(!0),f(null);try{const m=await No().get(r,e);a(m),i==null||i(m)}catch(g){const m=g instanceof Error?g:new Error("Unknown error");f(m),o==null||o(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,i,o]);return _.useEffect(()=>{s&&p()},[p,s]),{data:l,loading:u,error:d,refetch:p}}function ff(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=_.useState(null),[l,a]=_.useState(!1),[u,c]=_.useState(null),d=_.useCallback(async p=>{a(!0),c(null);try{const g=No();let m;switch(e){case"POST":m=await g.post(r,p);break;case"PUT":m=await g.put(r,p);break;case"PATCH":m=await g.patch(r,p);break;case"DELETE":m=await g.delete(r);break;default:throw new Error(`Unsupported method: ${e}`)}return o(m),n==null||n(m,p),m}catch(g){const m=g instanceof Error?g:new Error("Unknown error");return c(m),s==null||s(m,p),null}finally{a(!1)}},[r,e,n,s]),f=_.useCallback(()=>{o(null),c(null),a(!1)},[]);return{data:i,loading:l,error:u,mutate:d,reset:f}}class _s{static filter(e,t){return e.filter(t)}static filterBy(e,t,n){return e.filter(s=>s[t]===n)}static filterByFields(e,t){return e.filter(n=>Object.entries(t).every(([s,i])=>n[s]===i))}static sort(e,t,n="asc"){return[...e].sort((s,i)=>{const o=s[t],l=i[t];if(o===l)return 0;let a=0;return o>l&&(a=1),o<l&&(a=-1),n==="asc"?a:-a})}static search(e,t,n){if(!t.trim())return e;const s=t.toLowerCase();return e.filter(i=>n.some(o=>{const l=i[o];return l==null?!1:String(l).toLowerCase().includes(s)}))}static paginate(e,t,n){const s=(t-1)*n,i=s+n;return{data:e.slice(s,i),total:e.length,page:t,totalPages:Math.ceil(e.length/n)}}static groupBy(e,t){return e.reduce((n,s)=>{const i=String(s[t]);return n[i]||(n[i]=[]),n[i].push(s),n},{})}static unique(e,t){const n=e.map(s=>s[t]);return[...new Set(n)]}static countBy(e,t){return e.reduce((n,s)=>{const i=String(s[t]);return n[i]=(n[i]||0)+1,n},{})}static pipe(e,t){return t.reduce((n,s)=>s(n),e)}}function hf({endpoint:r,params:e,layout:t="list",title:n,emptyMessage:s="No items found",renderItem:i,keyExtractor:o=(m,x)=>m.id||m._id||String(x),searchable:l=!1,searchFields:a=[],searchPlaceholder:u="Search...",filters:c=[],pageSize:d=20,onItemClick:f,onRefresh:p,theme:g={}}){const{data:m,loading:x,error:v,refetch:b}=du(r,e),[C,S]=_.useState(""),[D,w]=_.useState({}),[y,k]=_.useState(1),N=_.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let E=m;return l&&C&&a.length>0&&(E=_s.search(E,C,a)),Object.keys(D).length>0&&(E=_s.filterByFields(E,D)),_s.paginate(E,y,d)},[m,C,D,y,d,l,a]);_.useEffect(()=>{k(1)},[C,D]);const F=()=>{S(""),w({}),k(1),b(),p==null||p()},T={background:g.background||"#ffffff",cardBackground:g.cardBackground||"#f9fafb",text:g.text||"#111827",textSecondary:g.textSecondary||"#6b7280",border:g.border||"#e5e7eb",primary:g.primary||"#3b82f6"},L=i||(E=>h.jsxs("div",{style:{padding:"16px",cursor:f?"pointer":"default"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:T.text},children:E.title||E.name||E.label||"Untitled"}),E.description&&h.jsx("div",{style:{fontSize:"13px",color:T.textSecondary,marginTop:"4px"},children:E.description})]}));return x&&!m?h.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:T.textSecondary},children:"Loading..."}):v?h.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[h.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),h.jsx("div",{style:{fontSize:"14px"},children:v.message}),h.jsx("button",{onClick:F,style:{marginTop:"16px",padding:"8px 16px",background:T.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):h.jsxs("div",{style:{background:T.background,borderRadius:"12px",overflow:"hidden"},children:[(n||l||c.length>0)&&h.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${T.border}`},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:l||c.length>0?"12px":"0"},children:[n&&h.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:T.text},children:n}),h.jsx("button",{onClick:F,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${T.border}`,borderRadius:"6px",color:T.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),l&&h.jsx("input",{type:"text",placeholder:u,value:C,onChange:E=>S(E.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${T.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),h.jsx("div",{style:{display:t==="grid"?"grid":"flex",flexDirection:t==="list"?"column":void 0,gridTemplateColumns:t==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:t==="list"?"0":"16px",padding:t==="list"?"0":"16px"},children:N.data.length===0?h.jsx("div",{style:{padding:"48px",textAlign:"center",color:T.textSecondary},children:s}):N.data.map((E,B)=>h.jsx("div",{onClick:()=>f==null?void 0:f(E),style:{background:T.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${T.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:R=>{f&&(R.currentTarget.style.background=T.border)},onMouseLeave:R=>{R.currentTarget.style.background=T.cardBackground},children:L(E,B)},o(E,B)))}),N.totalPages>1&&h.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${T.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{fontSize:"13px",color:T.textSecondary},children:["Page ",y," of ",N.totalPages]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>k(E=>Math.max(1,E-1)),disabled:y===1,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:y===1?"not-allowed":"pointer",opacity:y===1?.5:1},children:"Previous"}),h.jsx("button",{onClick:()=>k(E=>Math.min(N.totalPages,E+1)),disabled:y===N.totalPages,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:y===N.totalPages?"not-allowed":"pointer",opacity:y===N.totalPages?.5:1},children:"Next"})]})]})]})}function pf({item:r,onClick:e,title:t=o=>o.title||o.name||o.label||"Untitled",subtitle:n=o=>o.description||o.subtitle||"",image:s=o=>o.image||o.thumbnail||o.photo,badge:i=o=>o.badge||o.tag||o.type}){const o=t(r),l=n(r),a=s(r),u=i(r);return h.jsxs("div",{onClick:e,className:`
79
+ `})]}):null}function fu(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[l,a]=v.useState(null),[u,c]=v.useState(n),[d,f]=v.useState(null),p=v.useCallback(async()=>{if(n){c(!0),f(null);try{const m=await Bo().get(r,e);a(m),i==null||i(m)}catch(g){const m=g instanceof Error?g:new Error("Unknown error");f(m),o==null||o(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,i,o]);return v.useEffect(()=>{s&&p()},[p,s]),{data:l,loading:u,error:d,refetch:p}}function hf(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=v.useState(null),[l,a]=v.useState(!1),[u,c]=v.useState(null),d=v.useCallback(async p=>{a(!0),c(null);try{const g=Bo();let m;switch(e){case"POST":m=await g.post(r,p);break;case"PUT":m=await g.put(r,p);break;case"PATCH":m=await g.patch(r,p);break;case"DELETE":m=await g.delete(r);break;default:throw new Error(`Unsupported method: ${e}`)}return o(m),n==null||n(m,p),m}catch(g){const m=g instanceof Error?g:new Error("Unknown error");return c(m),s==null||s(m,p),null}finally{a(!1)}},[r,e,n,s]),f=v.useCallback(()=>{o(null),c(null),a(!1)},[]);return{data:i,loading:l,error:u,mutate:d,reset:f}}class vs{static filter(e,t){return e.filter(t)}static filterBy(e,t,n){return e.filter(s=>s[t]===n)}static filterByFields(e,t){return e.filter(n=>Object.entries(t).every(([s,i])=>n[s]===i))}static sort(e,t,n="asc"){return[...e].sort((s,i)=>{const o=s[t],l=i[t];if(o===l)return 0;let a=0;return o>l&&(a=1),o<l&&(a=-1),n==="asc"?a:-a})}static search(e,t,n){if(!t.trim())return e;const s=t.toLowerCase();return e.filter(i=>n.some(o=>{const l=i[o];return l==null?!1:String(l).toLowerCase().includes(s)}))}static paginate(e,t,n){const s=(t-1)*n,i=s+n;return{data:e.slice(s,i),total:e.length,page:t,totalPages:Math.ceil(e.length/n)}}static groupBy(e,t){return e.reduce((n,s)=>{const i=String(s[t]);return n[i]||(n[i]=[]),n[i].push(s),n},{})}static unique(e,t){const n=e.map(s=>s[t]);return[...new Set(n)]}static countBy(e,t){return e.reduce((n,s)=>{const i=String(s[t]);return n[i]=(n[i]||0)+1,n},{})}static pipe(e,t){return t.reduce((n,s)=>s(n),e)}}function pf({endpoint:r,params:e,layout:t="list",title:n,emptyMessage:s="No items found",renderItem:i,keyExtractor:o=(m,x)=>m.id||m._id||String(x),searchable:l=!1,searchFields:a=[],searchPlaceholder:u="Search...",filters:c=[],pageSize:d=20,onItemClick:f,onRefresh:p,theme:g={}}){const{data:m,loading:x,error:w,refetch:y}=fu(r,e),[C,S]=v.useState(""),[D,_]=v.useState({}),[b,E]=v.useState(1),N=v.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let k=m;return l&&C&&a.length>0&&(k=vs.search(k,C,a)),Object.keys(D).length>0&&(k=vs.filterByFields(k,D)),vs.paginate(k,b,d)},[m,C,D,b,d,l,a]);v.useEffect(()=>{E(1)},[C,D]);const R=()=>{S(""),_({}),E(1),y(),p==null||p()},T={background:g.background||"#ffffff",cardBackground:g.cardBackground||"#f9fafb",text:g.text||"#111827",textSecondary:g.textSecondary||"#6b7280",border:g.border||"#e5e7eb",primary:g.primary||"#3b82f6"},L=i||(k=>h.jsxs("div",{style:{padding:"16px",cursor:f?"pointer":"default"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:T.text},children:k.title||k.name||k.label||"Untitled"}),k.description&&h.jsx("div",{style:{fontSize:"13px",color:T.textSecondary,marginTop:"4px"},children:k.description})]}));return x&&!m?h.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:T.textSecondary},children:"Loading..."}):w?h.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[h.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),h.jsx("div",{style:{fontSize:"14px"},children:w.message}),h.jsx("button",{onClick:R,style:{marginTop:"16px",padding:"8px 16px",background:T.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):h.jsxs("div",{style:{background:T.background,borderRadius:"12px",overflow:"hidden"},children:[(n||l||c.length>0)&&h.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${T.border}`},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:l||c.length>0?"12px":"0"},children:[n&&h.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:T.text},children:n}),h.jsx("button",{onClick:R,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${T.border}`,borderRadius:"6px",color:T.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),l&&h.jsx("input",{type:"text",placeholder:u,value:C,onChange:k=>S(k.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${T.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),h.jsx("div",{style:{display:t==="grid"?"grid":"flex",flexDirection:t==="list"?"column":void 0,gridTemplateColumns:t==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:t==="list"?"0":"16px",padding:t==="list"?"0":"16px"},children:N.data.length===0?h.jsx("div",{style:{padding:"48px",textAlign:"center",color:T.textSecondary},children:s}):N.data.map((k,B)=>h.jsx("div",{onClick:()=>f==null?void 0:f(k),style:{background:T.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${T.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:M=>{f&&(M.currentTarget.style.background=T.border)},onMouseLeave:M=>{M.currentTarget.style.background=T.cardBackground},children:L(k,B)},o(k,B)))}),N.totalPages>1&&h.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${T.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{fontSize:"13px",color:T.textSecondary},children:["Page ",b," of ",N.totalPages]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>E(k=>Math.max(1,k-1)),disabled:b===1,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:b===1?"not-allowed":"pointer",opacity:b===1?.5:1},children:"Previous"}),h.jsx("button",{onClick:()=>E(k=>Math.min(N.totalPages,k+1)),disabled:b===N.totalPages,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:b===N.totalPages?"not-allowed":"pointer",opacity:b===N.totalPages?.5:1},children:"Next"})]})]})]})}function gf({item:r,onClick:e,title:t=o=>o.title||o.name||o.label||"Untitled",subtitle:n=o=>o.description||o.subtitle||"",image:s=o=>o.image||o.thumbnail||o.photo,badge:i=o=>o.badge||o.tag||o.type}){const o=t(r),l=n(r),a=s(r),u=i(r);return h.jsxs("div",{onClick:e,className:`
80
80
  flex items-center gap-4 p-4 border-b border-gray-200
81
81
  hover:bg-gray-50 transition-colors
82
82
  ${e?"cursor-pointer":""}
83
- `,children:[a&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&h.jsx("div",{className:"flex-shrink-0 text-gray-400",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function gf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return h.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:h.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&h.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"p-6",children:[o&&h.jsx("div",{className:"mb-6",children:h.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&h.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&h.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&h.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:h.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const mf={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function yf({nodes:r,cardCount:e=2,minInterval:t=1e3,maxInterval:n=3e3,onCardClick:s,cardSize:i="medium",className:o=""}){const l=Math.min(Math.max(e,1),5),[a,u]=_.useState([]),[c,d]=_.useState([]),[f,p]=_.useState(Array(l).fill(!1)),[g,m]=_.useState(Array(l).fill(!1)),x=_.useRef([]),v=_.useCallback(w=>{const y=r.filter(N=>!w.includes(N._id));if(y.length===0)return null;const k=Math.floor(Math.random()*y.length);return y[k]},[r]),b=_.useCallback(()=>Math.random()*(n-t)+t,[t,n]);_.useEffect(()=>{if(r.length===0){u([]),d([]);return}const w=[],y=[],k=[];for(let N=0;N<l&&N<r.length;N++){const F=v(k);F&&(w.push(F),k.push(F._id))}for(let N=0;N<w.length;N++){const F=[w[N]._id,...w.filter((M,L)=>L!==N).map(M=>M._id)],T=v(F);T?y.push(T):y.push(w[N])}u(w),d(y)},[r,l,v]);const C=_.useCallback(w=>{const y=b(),k=setTimeout(()=>{p(N=>{const F=[...N];return F[w]=!F[w],F}),setTimeout(()=>{m(N=>{const F=[...N];return F[w]=!F[w],F}),setTimeout(()=>{const N=!g[w];N&&u(F=>{const T=[...F];return T[w]=c[w],T}),d(F=>{const T=[...F],L=[(N?c[w]:a[w])._id,...a.filter((B,R)=>R!==w).map(B=>B._id),...F.filter((B,R)=>R!==w).map(B=>B._id)],E=v(L);return E&&(T[w]=E),T}),setTimeout(()=>{C(w)},150)},200)},150)},y);x.current[w]=k},[b,v,a,c,g]),S=_.useRef(!1);_.useEffect(()=>{if(!(a.length===0||r.length<=1)&&!S.current){S.current=!0;for(let w=0;w<a.length;w++)C(w);return()=>{x.current.forEach(w=>clearTimeout(w)),x.current=[],S.current=!1}}},[a.length,r.length]);const D=w=>{s&&s(w)};return r.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):a.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"Loading..."})}):h.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${o}`,children:a.map((w,y)=>{const k=c[y],N=g[y];return h.jsx("div",{className:`relative ${mf[i]}`,style:{perspective:"1000px"},onClick:()=>D(N?k:w),children:h.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${f[y]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:N?0:1},children:h.jsxs("div",{style:{transform:f[y]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:w.data.image,alt:w.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:w.title})})]})}),k&&h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:N?1:0},children:h.jsxs("div",{style:{transform:f[y]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:k.data.image,alt:k.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:k.title})})]})})]})},`slot-${y}`)})})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,a)=>String.fromCharCode(parseInt(a,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const xf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function bf({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:l=!0,searchQuery:a,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:b,renderActions:C,renderEmpty:S,renderLoading:D,theme:w={}}){const y={...xf,...w},[k,N]=_.useState([]),[F,T]=_.useState(!1),[M,L]=_.useState(null),[E,B]=_.useState(new Set),[R,O]=_.useState(null),[H,U]=_.useState(null),[Z,q]=_.useState(null),[K,$]=_.useState(!1),[re,ae]=_.useState(""),le=a!==void 0?a:re,ce=ee=>{u?u(ee):ae(ee)},ve=_.useMemo(()=>{if(!le.trim())return k;const ee=le.toLowerCase();return k.filter(se=>$r(se.from).toLowerCase().includes(ee)||$r(se.subject).toLowerCase().includes(ee))},[k,le]),pe=_.useMemo(()=>e?new su({baseUrl:r,system_id:e}):null,[r,e]),Fe=_.useCallback(async()=>{if(pe){T(!0),L(null);try{const ee=await pe.listEmails(t,n,s);ee!=null&&ee.messages&&(N(ee.messages),x==null||x(ee.messages))}catch(ee){const se=ee instanceof Error?ee:new Error("Failed to fetch emails");L(se.message),m==null||m(se)}T(!1)}},[pe,t,n,s,m,x]);_.useEffect(()=>{N([]),B(new Set),U(null),L(null),a===void 0&&ae(""),d&&Fe()},[s,d]);const et=_.useCallback(async ee=>{if(pe){U(ee),q(null),$(!0);try{const se=await pe.getEmailParsed(t,ee.uid,s||"INBOX");se!=null&&se.body&&q(se.body)}catch(se){console.error("Failed to fetch email body:",se)}$(!1)}},[pe,t,s]),ct=_.useCallback(ee=>{f==null||f(ee),o&&et(ee)},[f,o,et]),kt=_.useCallback((ee,se,je)=>{if(!i){f==null||f(ee),o&&et(ee);return}const $e=ee.uid;if(je.shiftKey&&R!==null){const qe=Math.min(R,se),Dt=Math.max(R,se),Y=k.slice(qe,Dt+1).map(ne=>ne.uid),j=new Set(Y);B(j),p==null||p(Array.from(j))}else if(je.ctrlKey||je.metaKey)B(qe=>{const Dt=new Set(qe);return Dt.has($e)?Dt.delete($e):Dt.add($e),p==null||p(Array.from(Dt)),Dt}),O(se);else{const qe=new Set([$e]);B(qe),O(se),p==null||p(Array.from(qe))}},[i,R,k,E,f,p,o]),tt=_.useCallback(async()=>{if(!pe||E.size===0)return;const ee=s||"INBOX";try{const se=await pe.trashEmails(t,Array.from(E),ee);if(console.log("Trash result:",se),se.success&&se.moved>0){N($e=>$e.filter(qe=>!E.has(qe.uid)));const je=Array.from(E);B(new Set),g==null||g(je)}else L("Failed to move emails to trash")}catch(se){const je=se instanceof Error?se:new Error("Trash failed");console.error("Trash error:",je),L(je.message),m==null||m(je)}},[pe,t,E,s,g,m]),xt=_.useCallback(async()=>{if(!pe||E.size===0)return;const ee=s||"INBOX";try{const se=await pe.archiveEmails(t,Array.from(E),ee);if(console.log("Archive result:",se),se.success&&se.archived>0){N($e=>$e.filter(qe=>!E.has(qe.uid)));const je=Array.from(E);B(new Set),g==null||g(je)}else L("Failed to archive emails")}catch(se){const je=se instanceof Error?se:new Error("Archive failed");console.error("Archive error:",je),L(je.message),m==null||m(je)}},[pe,t,E,s,g,m]),dt=_.useCallback(()=>{if(E.size===k.length)B(new Set),p==null||p([]);else{const ee=new Set(k.map(se=>se.uid));B(ee),p==null||p(Array.from(ee))}},[k,E.size,p]),It=_.useCallback(()=>{B(new Set),p==null||p([])},[p]),ue={delete:tt,archive:xt,refresh:Fe,selectAll:dt,clearSelection:It},_e=ee=>{if(!ee)return"";const se=new Date(ee),je=new Date;return se.toDateString()===je.toDateString()?se.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):se.toLocaleDateString([],{month:"short",day:"numeric"})},Te=(ee,se)=>h.jsx("div",{style:{padding:"12px 16px",background:se?y.selectedBackground:ee.seen?y.cardBackground:y.unreadBackground,borderBottom:`1px solid ${y.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:ee.seen?400:600,color:y.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ee.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ee.seen?400:500,color:ee.seen?y.textSecondary:y.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ee.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:y.textSecondary,flexShrink:0},children:_e(ee.date)})]})}),it=ee=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:y.text},children:$r(ee.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:y.textSecondary,marginBottom:"16px"},children:["From: ",$r(ee.from)," • ",new Date(ee.date).toLocaleString()]}),K?h.jsx("div",{style:{fontSize:"14px",color:y.textSecondary},children:"Loading..."}):Z?h.jsx("div",{style:{fontSize:"14px",color:y.text},dangerouslySetInnerHTML:{__html:Z}}):h.jsx("div",{style:{fontSize:"14px",color:y.textSecondary},children:"No content available"})]}),Je=(ee,se)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:y.cardBackground,borderBottom:`1px solid ${y.border}`},children:[h.jsx("button",{onClick:se.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${y.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:y.text},children:ee.length===k.length?"Deselect All":"Select All"}),ee.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:y.textSecondary},children:[ee.length," selected"]}),h.jsx("button",{onClick:se.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${y.border}`,borderRadius:"6px",cursor:"pointer",color:y.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:se.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${y.border}`,borderRadius:"6px",cursor:"pointer",color:y.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:se.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${y.border}`,borderRadius:"6px",cursor:"pointer",color:y.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),X=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:y.textSecondary},children:c}),Ne=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:y.textSecondary},children:"Loading..."}),Me=v||Te,Re=b||it,zt=C||Je,$t=S||X,Jt=D||Ne;return F&&k.length===0?h.jsx("div",{style:{background:y.background,width:"100%",height:"100%"},children:Jt()}):h.jsxs("div",{style:{display:"flex",background:y.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&H?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&H?`1px solid ${y.border}`:"none",overflow:"hidden"},children:[i&&zt(Array.from(E),ue),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${y.border}`,background:y.background},children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:y.textSecondary,strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"8"}),h.jsx("path",{d:"M21 21l-4.35-4.35"})]}),h.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:le,onChange:ee=>ce(ee.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:y.text}}),le&&h.jsx("button",{onClick:()=>ce(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:y.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),M&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:y.danger,fontSize:"14px",borderBottom:`1px solid ${y.border}`},children:M}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ve.length===0?$t():ve.map((ee,se)=>h.jsx("div",{onClick:je=>kt(ee,se,je),onDoubleClick:()=>ct(ee),children:Me(ee,E.has(ee.uid))},ee.uid))})]}),o&&H&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:Re(H)})]})}function _f({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=_.useState(new Set),[d,f]=_.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=_.useCallback(S=>{c(D=>{const w=new Set(D);return w.has(S)?w.delete(S):w.add(S),t==null||t(Array.from(w)),w})},[t]),x=_.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(D=>D.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(D=>D.id))}},[r,u.size,t,n]),v=_.useCallback(()=>{if(p.length===0)return;const S=d<=0?p.length-1:d-1;f(S),n==null||n(p[S],S)},[p,d,n]),b=_.useCallback(()=>{if(p.length===0)return;const S=d>=p.length-1?0:d+1;f(S),n==null||n(p[S],S)},[p,d,n]),C=_.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return _.useEffect(()=>{p.length===0?f(-1):d>=p.length?f(p.length-1):d<0&&p.length>0&&(f(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?h.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):h.jsxs("div",{className:`space-y-2 ${a}`,children:[h.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[l&&h.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[h.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),h.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&h.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:v,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),h.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),h.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),h.jsx("div",{className:"space-y-1",children:r.map(S=>{const D=u.has(S.id),w=(g==null?void 0:g.id)===S.id;return h.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${w?"bg-blue-50 ring-1 ring-blue-200":D?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.id),children:[h.jsx("span",{className:`material-icons text-lg ${D?"text-blue-500":"text-neutral-300"}`,children:D?"check_box":"check_box_outline_blank"}),h.jsx("div",{className:"flex-1 min-w-0",children:e(S,D,w)})]},S.id)})}),i.length>0&&u.size>0&&h.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(S=>{var w;const D=((w=S.disabled)==null?void 0:w.call(S,p))??!1;return h.jsxs("button",{onClick:()=>C(S.id),disabled:D,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${D?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function vf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var wf=vf(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const fu=_.createContext(null);function Cf(r,e){return{getTheme:function(){return e??null}}}function Lt(){const r=_.useContext(fu);return r==null&&wf(8),r}function Hn(r){return{}}const Fo={},Sf={},hu={},kr={},Kr={},Mn={},Yr={},si={},Ki={},jn={},Ln={},Mt={},Ro={},Mo={},Ef={},pu={},kf={},gu={},Df={},mu={},yu={},Ns={},Af={},xu={},bu={},_u={},Tf={},Nf={},Bf={},ka={},vu={},Ff={},wu={},Cu={},Rf={},ii={},jo={},Yi={},Mf={},jf={},ls={},us={},Lf={},Pf={},Of={},Pt=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,If=Pt&&"documentMode"in document?document.documentMode:null,Tt=Pt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=Pt&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!Pt||!("InputEvent"in window)||If)&&"getTargetRanges"in new window.InputEvent("input"),oi=Pt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Gn=Pt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,zf=Pt&&/Android/.test(navigator.userAgent),Su=Pt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),$f=Pt&&zf&&Su,Lo=Pt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Su,Kn=1,xr=3,Nr=0,Eu=1,Zr=2,qf=0,Uf=1,Wf=2,Fs=4,Rs=8,Po=128,Vf=112|(3|Fs|Rs)|Po,Oo=1,Io=2,zo=3,$o=4,qo=5,Uo=6,ai=oi||Gn||Lo?" ":"​",sr=`
83
+ `,children:[a&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&h.jsx("div",{className:"flex-shrink-0 text-gray-400",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function mf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return h.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:h.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&h.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"p-6",children:[o&&h.jsx("div",{className:"mb-6",children:h.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&h.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&h.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&h.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:h.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const yf={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function xf({nodes:r,cardCount:e=2,minInterval:t=1e3,maxInterval:n=3e3,onCardClick:s,cardSize:i="medium",className:o=""}){const l=Math.min(Math.max(e,1),5),[a,u]=v.useState([]),[c,d]=v.useState([]),[f,p]=v.useState(Array(l).fill(!1)),[g,m]=v.useState(Array(l).fill(!1)),x=v.useRef([]),w=v.useCallback(_=>{const b=r.filter(N=>!_.includes(N._id));if(b.length===0)return null;const E=Math.floor(Math.random()*b.length);return b[E]},[r]),y=v.useCallback(()=>Math.random()*(n-t)+t,[t,n]);v.useEffect(()=>{if(r.length===0){u([]),d([]);return}const _=[],b=[],E=[];for(let N=0;N<l&&N<r.length;N++){const R=w(E);R&&(_.push(R),E.push(R._id))}for(let N=0;N<_.length;N++){const R=[_[N]._id,..._.filter((F,L)=>L!==N).map(F=>F._id)],T=w(R);T?b.push(T):b.push(_[N])}u(_),d(b)},[r,l,w]);const C=v.useCallback(_=>{const b=y(),E=setTimeout(()=>{p(N=>{const R=[...N];return R[_]=!R[_],R}),setTimeout(()=>{m(N=>{const R=[...N];return R[_]=!R[_],R}),setTimeout(()=>{const N=!g[_];N&&u(R=>{const T=[...R];return T[_]=c[_],T}),d(R=>{const T=[...R],L=[(N?c[_]:a[_])._id,...a.filter((B,M)=>M!==_).map(B=>B._id),...R.filter((B,M)=>M!==_).map(B=>B._id)],k=w(L);return k&&(T[_]=k),T}),setTimeout(()=>{C(_)},150)},200)},150)},b);x.current[_]=E},[y,w,a,c,g]),S=v.useRef(!1);v.useEffect(()=>{if(!(a.length===0||r.length<=1)&&!S.current){S.current=!0;for(let _=0;_<a.length;_++)C(_);return()=>{x.current.forEach(_=>clearTimeout(_)),x.current=[],S.current=!1}}},[a.length,r.length]);const D=_=>{s&&s(_)};return r.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):a.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"Loading..."})}):h.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${o}`,children:a.map((_,b)=>{const E=c[b],N=g[b];return h.jsx("div",{className:`relative ${yf[i]}`,style:{perspective:"1000px"},onClick:()=>D(N?E:_),children:h.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${f[b]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:N?0:1},children:h.jsxs("div",{style:{transform:f[b]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:_.data.image,alt:_.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:_.title})})]})}),E&&h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:N?1:0},children:h.jsxs("div",{style:{transform:f[b]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:E.data.image,alt:E.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:E.title})})]})})]})},`slot-${b}`)})})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,a)=>String.fromCharCode(parseInt(a,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const bf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function vf({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:l=!0,searchQuery:a,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:w,renderDetail:y,renderActions:C,renderEmpty:S,renderLoading:D,theme:_={}}){const b={...bf,..._},[E,N]=v.useState([]),[R,T]=v.useState(!1),[F,L]=v.useState(null),[k,B]=v.useState(new Set),[M,I]=v.useState(null),[W,$]=v.useState(null),[ee,q]=v.useState(null),[Y,z]=v.useState(!1),[ie,ce]=v.useState(""),de=a!==void 0?a:ie,me=ne=>{u?u(ne):ce(ne)},X=v.useMemo(()=>{if(!de.trim())return E;const ne=de.toLowerCase();return E.filter(fe=>$r(fe.from).toLowerCase().includes(ne)||$r(fe.subject).toLowerCase().includes(ne))},[E,de]),oe=v.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),G=v.useCallback(async()=>{if(oe){T(!0),L(null);try{const ne=await oe.listEmails(t,n,s);ne!=null&&ne.messages&&(N(ne.messages),x==null||x(ne.messages))}catch(ne){const fe=ne instanceof Error?ne:new Error("Failed to fetch emails");L(fe.message),m==null||m(fe)}T(!1)}},[oe,t,n,s,m,x]);v.useEffect(()=>{N([]),B(new Set),$(null),L(null),a===void 0&&ce(""),d&&G()},[s,d]);const Ee=v.useCallback(async ne=>{if(oe){$(ne),q(null),z(!0);try{const fe=await oe.getEmailParsed(t,ne.uid,s||"INBOX");fe!=null&&fe.body&&q(fe.body)}catch(fe){console.error("Failed to fetch email body:",fe)}z(!1)}},[oe,t,s]),Ne=v.useCallback(ne=>{f==null||f(ne),o&&Ee(ne)},[f,o,Ee]),xe=v.useCallback((ne,fe,qe)=>{if(!i){f==null||f(ne),o&&Ee(ne);return}const Ke=ne.uid;if(qe.shiftKey&&M!==null){const Ye=Math.min(M,fe),At=Math.max(M,fe),Q=E.slice(Ye,At+1).map(le=>le.uid),j=new Set(Q);B(j),p==null||p(Array.from(j))}else if(qe.ctrlKey||qe.metaKey)B(Ye=>{const At=new Set(Ye);return At.has(Ke)?At.delete(Ke):At.add(Ke),p==null||p(Array.from(At)),At}),I(fe);else{const Ye=new Set([Ke]);B(Ye),I(fe),p==null||p(Array.from(Ye))}},[i,M,E,k,f,p,o]),ye=v.useCallback(async()=>{if(!oe||k.size===0)return;const ne=s||"INBOX";try{const fe=await oe.trashEmails(t,Array.from(k),ne);if(console.log("Trash result:",fe),fe.success&&fe.moved>0){N(Ke=>Ke.filter(Ye=>!k.has(Ye.uid)));const qe=Array.from(k);B(new Set),g==null||g(qe)}else L("Failed to move emails to trash")}catch(fe){const qe=fe instanceof Error?fe:new Error("Trash failed");console.error("Trash error:",qe),L(qe.message),m==null||m(qe)}},[oe,t,k,s,g,m]),ue=v.useCallback(async()=>{if(!oe||k.size===0)return;const ne=s||"INBOX";try{const fe=await oe.archiveEmails(t,Array.from(k),ne);if(console.log("Archive result:",fe),fe.success&&fe.archived>0){N(Ke=>Ke.filter(Ye=>!k.has(Ye.uid)));const qe=Array.from(k);B(new Set),g==null||g(qe)}else L("Failed to archive emails")}catch(fe){const qe=fe instanceof Error?fe:new Error("Archive failed");console.error("Archive error:",qe),L(qe.message),m==null||m(qe)}},[oe,t,k,s,g,m]),ae=v.useCallback(()=>{if(k.size===E.length)B(new Set),p==null||p([]);else{const ne=new Set(E.map(fe=>fe.uid));B(ne),p==null||p(Array.from(ne))}},[E,k.size,p]),ke=v.useCallback(()=>{B(new Set),p==null||p([])},[p]),te={delete:ye,archive:ue,refresh:G,selectAll:ae,clearSelection:ke},ge=ne=>{if(!ne)return"";const fe=new Date(ne),qe=new Date;return fe.toDateString()===qe.toDateString()?fe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):fe.toLocaleDateString([],{month:"short",day:"numeric"})},be=(ne,fe)=>h.jsx("div",{style:{padding:"12px 16px",background:fe?b.selectedBackground:ne.seen?b.cardBackground:b.unreadBackground,borderBottom:`1px solid ${b.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:ne.seen?400:600,color:b.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ne.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ne.seen?400:500,color:ne.seen?b.textSecondary:b.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ne.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:b.textSecondary,flexShrink:0},children:ge(ne.date)})]})}),Xe=ne=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:b.text},children:$r(ne.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:b.textSecondary,marginBottom:"16px"},children:["From: ",$r(ne.from)," • ",new Date(ne.date).toLocaleString()]}),Y?h.jsx("div",{style:{fontSize:"14px",color:b.textSecondary},children:"Loading..."}):ee?h.jsx("div",{style:{fontSize:"14px",color:b.text},dangerouslySetInnerHTML:{__html:ee}}):h.jsx("div",{style:{fontSize:"14px",color:b.textSecondary},children:"No content available"})]}),st=(ne,fe)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:b.cardBackground,borderBottom:`1px solid ${b.border}`},children:[h.jsx("button",{onClick:fe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:b.text},children:ne.length===E.length?"Deselect All":"Select All"}),ne.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:b.textSecondary},children:[ne.length," selected"]}),h.jsx("button",{onClick:fe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:fe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:fe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),Z=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:b.textSecondary},children:c}),Ie=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:b.textSecondary},children:"Loading..."}),$e=w||be,ze=y||Xe,zt=C||st,$t=S||Z,Jt=D||Ie;return R&&E.length===0?h.jsx("div",{style:{background:b.background,width:"100%",height:"100%"},children:Jt()}):h.jsxs("div",{style:{display:"flex",background:b.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&W?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&W?`1px solid ${b.border}`:"none",overflow:"hidden"},children:[i&&zt(Array.from(k),te),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${b.border}`,background:b.background},children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:b.textSecondary,strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"8"}),h.jsx("path",{d:"M21 21l-4.35-4.35"})]}),h.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:de,onChange:ne=>me(ne.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:b.text}}),de&&h.jsx("button",{onClick:()=>me(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:b.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),F&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:b.danger,fontSize:"14px",borderBottom:`1px solid ${b.border}`},children:F}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:X.length===0?$t():X.map((ne,fe)=>h.jsx("div",{onClick:qe=>xe(ne,fe,qe),onDoubleClick:()=>Ne(ne),children:$e(ne,k.has(ne.uid))},ne.uid))})]}),o&&W&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ze(W)})]})}function _f({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=v.useState(new Set),[d,f]=v.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=v.useCallback(S=>{c(D=>{const _=new Set(D);return _.has(S)?_.delete(S):_.add(S),t==null||t(Array.from(_)),_})},[t]),x=v.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(D=>D.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(D=>D.id))}},[r,u.size,t,n]),w=v.useCallback(()=>{if(p.length===0)return;const S=d<=0?p.length-1:d-1;f(S),n==null||n(p[S],S)},[p,d,n]),y=v.useCallback(()=>{if(p.length===0)return;const S=d>=p.length-1?0:d+1;f(S),n==null||n(p[S],S)},[p,d,n]),C=v.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return v.useEffect(()=>{p.length===0?f(-1):d>=p.length?f(p.length-1):d<0&&p.length>0&&(f(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?h.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):h.jsxs("div",{className:`space-y-2 ${a}`,children:[h.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[l&&h.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[h.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),h.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&h.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:w,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),h.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),h.jsx("button",{onClick:y,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),h.jsx("div",{className:"space-y-1",children:r.map(S=>{const D=u.has(S.id),_=(g==null?void 0:g.id)===S.id;return h.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${_?"bg-blue-50 ring-1 ring-blue-200":D?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.id),children:[h.jsx("span",{className:`material-icons text-lg ${D?"text-blue-500":"text-neutral-300"}`,children:D?"check_box":"check_box_outline_blank"}),h.jsx("div",{className:"flex-1 min-w-0",children:e(S,D,_)})]},S.id)})}),i.length>0&&u.size>0&&h.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(S=>{var _;const D=((_=S.disabled)==null?void 0:_.call(S,p))??!1;return h.jsxs("button",{onClick:()=>C(S.id),disabled:D,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${D?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function wf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Cf=wf(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const hu=v.createContext(null);function Sf(r,e){return{getTheme:function(){return e??null}}}function Pt(){const r=v.useContext(hu);return r==null&&Cf(8),r}function Hn(r){return{}}const Mo={},kf={},pu={},Er={},Kr={},Fn={},Yr={},si={},Yi={},jn={},Ln={},jt={},Fo={},jo={},Ef={},gu={},Df={},mu={},Af={},yu={},xu={},Ns={},Tf={},bu={},vu={},_u={},Nf={},Bf={},Rf={},Da={},wu={},Mf={},Cu={},Su={},Ff={},ii={},Lo={},Qi={},jf={},Lf={},ls={},us={},Pf={},If={},Of={},It=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,zf=It&&"documentMode"in document?document.documentMode:null,Nt=It&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=It&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!It||!("InputEvent"in window)||zf)&&"getTargetRanges"in new window.InputEvent("input"),oi=It&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Gn=It&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,$f=It&&/Android/.test(navigator.userAgent),ku=It&&/^(?=.*Chrome).*/i.test(navigator.userAgent),qf=It&&$f&&ku,Po=It&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!ku,Kn=1,xr=3,Nr=0,Eu=1,Zr=2,Uf=0,Wf=1,Vf=2,Rs=4,Ms=8,Io=128,Hf=112|(3|Rs|Ms)|Io,Oo=1,zo=2,$o=3,qo=4,Uo=5,Wo=6,ai=oi||Gn||Po?" ":"​",sr=`
84
84
 
85
- `,Hf=mr?" ":ai,ku="֑-߿יִ-﷽ﹰ-ﻼ",Du="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Gf=new RegExp("^[^"+Du+"]*["+ku+"]"),Kf=new RegExp("^[^"+ku+"]*["+Du+"]"),Br={bold:1,code:16,highlight:Po,italic:2,strikethrough:Fs,subscript:32,superscript:64,underline:Rs},Yf={directionless:1,unmergeable:2},Da={center:Io,end:Uo,justify:$o,left:Oo,right:zo,start:qo},Qf={[Io]:"center",[Uo]:"end",[$o]:"justify",[Oo]:"left",[zo]:"right",[qo]:"start"},Xf={normal:0,segmented:2,token:1},Jf={[qf]:"normal",[Wf]:"segmented",[Uf]:"token"};function Zf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var V=Zf(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Ms(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const eh=100;let Qi=!1,Wo=0;function th(r){Wo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function rh(r,e,t){const n=Et(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Yo(e,o,s,i,!1)}function nh(r,e,t){if(z(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function sh(r,e,t,n){for(let s=r;s&&!yh(s);s=Qn(s)){const i=ui(s,e);if(i!==void 0){const o=st(i,t);if(o)return Ae(o)?void 0:[s,o]}else if(s===n)return[n,Lu(t)]}}function Au(r,e,t){Qi=!0;const n=performance.now()-Wo>eh;try{bt(r,()=>{const s=te()||function(f){return f.getEditorState().read(()=>{const p=te();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),l=r._editorState,a=r._blockCursorElement;let u=!1,c="";for(let f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=sh(m,r,l,o);if(!x)continue;const[v,b]=x;if(g==="characterData")n&&G(b)&&nh(s,m,b)&&rh(m,b,r);else if(g==="childList"){u=!0;const C=p.addedNodes;for(let w=0;w<C.length;w++){const y=C[w],k=Mu(y),N=y.parentNode;if(N!=null&&y!==a&&k===null&&!Bi(y,N,r)){if(mr){const F=y.innerText||y.nodeValue;F&&(c+=F)}N.removeChild(y)}}const S=p.removedNodes,D=S.length;if(D>0){let w=0;for(let y=0;y<D;y++){const k=S[y];(Bi(k,m,r)||a===k)&&(m.appendChild(k),w++)}D!==w&&i.set(v,b)}}}if(i.size>0)for(const[f,p]of i)p.reconcileObservedMutation(f,r);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const p=d[f],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const v=g[x],b=v.parentNode;b==null||v.nodeName!=="BR"||Bi(v,m,r)||b.removeChild(v)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Gt(s)),mr&&zu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Tu(r){const e=r._observer;e!==null&&Au(r,e.takeRecords(),e)}function Nu(r){(function(e){Wo===0&&di(e).addEventListener("textInput",th,!0)})(r),r._observer=new MutationObserver((e,t)=>{Au(r,e,t)})}function Aa(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,l=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==l)}function Ta(r,e){const t=r.mergeWithSibling(e),n=ze()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Na(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&G(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Aa(e,n)){n=Ta(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&G(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Aa(n,t)){n=Ta(n,t);break}break}t.remove()}}else n.remove()}function Bu(r){return Ba(r.anchor),Ba(r.focus),r}function Ba(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),G(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!P(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let ih=1;const oh=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Vo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Ae(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Yn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Vo(e)&&Fu(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Fu(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Qn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function ah(r){return r.nodeType===xr}function js(r){let e=r;for(;e!=null;){if(ah(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Ru(r){return G(r)||Ar(r)||Ae(r)}function lh(r,e){if(e!=null)return void(r.__key=e);pt(),ac();const t=ze(),n=ar(),s=""+ih++;n._nodeMap.set(s,r),P(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Eu,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const l=i.getWritable();l.__prev=o.__key,o.__next=l.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const l=s.getWritable();l.__next=o.__key,o.__prev=l.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){ac();const e=r.getLatest(),t=e.__parent,n=ar(),s=ze(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const f=u.get(d);if(f===void 0)break;c.set(d,!1),d=f.__parent}}(t,i,o);const l=e.__key;s._dirtyType=Eu,P(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function Ze(r){pt();const e=ze(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=st(t);n!==null&&n.getWritable()}if(r!==null){const n=st(r);n!==null&&n.getWritable()}}}function hr(){return ts()?null:ze()._compositionKey}function st(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Mu(r,e){const t=ui(r,ze());return t!==void 0?st(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Mu(t,e);if(n!==null)return n;t=Qn(t)}return null}function ju(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Fa(r){return r.read(()=>Pe().getTextContent())}function Pe(){return Lu(ar())}function Lu(r){return r._nodeMap.get("root")}function Gt(r){pt();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Vr(r){const e=ze(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Qn(i)}return null}(r,e);return t===null?r===e.getRootElement()?st("root"):null:st(t)}function Ra(r,e){return e?r.getTextContentSize():0}function Pu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Go(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Iu(r){return r.nodeType===xr?r.nodeValue:null}function Ko(r,e,t){const n=Et(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=Iu(s);const a=en(s);if(l!==null&&G(a)){if(l===ai&&t){const u=t.length;l=t,i=u,o=u}l!==null&&Yo(a,l,i,o,r)}}}function Yo(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let l=e;(o||s)&&e[e.length-1]===ai&&(l=e.slice(0,-1));const a=i.getTextContent();if(s||l!==a){if(l===""){if(Ze(null),oi||Gn||Lo)i.remove();else{const m=ze();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=es(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||z(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=te();if(!z(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=Ke(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function uh(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(G(o)||P(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Ma(r){return r==="ArrowLeft"}function ja(r){return r==="ArrowRight"}function _n(r,e){return Tt?r:e}function La(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Pa(r,e,t){return r.toLowerCase()==="a"&&_n(e,t)}function ch(){const r=Pe();Gt(Bu(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Ms(s);return t[e]=i,i}return s}function Qo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,l=e.get(i);l===void 0&&V(33,i);const a=l.klass;let u=r.get(a);u===void 0&&(u=new Map,r.set(a,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function Oa(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return Oa(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?Oa(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function zu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function J(r,e,t){return cc(r,e,t)}function ci(r){return!lt(r)&&!r.isLastChild()&&!r.isInline()}function Os(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&V(75,e),t}function Qn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&V(78),e}function dh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Kt(e))return e;e=e.getParentOrThrow()}return e}function Kt(r){return lt(r)||P(r)&&r.isShadowRoot()}function Qt(r){const e=ze(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&V(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),l=o.constructor;return i!==null?o instanceof i||V(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||V(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&V(203,r.constructor.name,t,l.name,l.getType()),o}return r}function Fi(r,e){!lt(r.getParent())||P(e)||Ae(e)||V(99)}function Ri(r){return(Ae(r)||P(r)&&!r.canBeEmpty())&&!r.isInline()}function Xo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function fh(r,e,t){let n=r._blockCursorElement;if(z(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let l=!1,a=null;if(o===i.getChildrenSize())Ri(i.getChildAtIndex(o-1))&&(l=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Ri(u)){const c=u.getPreviousSibling();(c===null||Ri(c))&&(l=!0,a=r.getElementByKey(u.__key))}}if(l){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,f=document.createElement("div");f.contentEditable="false",f.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Ms(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Xo(n,r,e)}function Et(r){return Pt?(r||window).getSelection():null}function hh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Ia(r){return r.nodeType===11}function Xi(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function Is(r){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return r.nodeName.match(e)!==null}function cr(r){if(Ae(r)&&!r.isInline())return!0;if(!P(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||G(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function ph(){return ze()}const za=new WeakMap,gh=new Map;function mh(r){if(!r._readOnly&&r.isEmpty())return gh;r._readOnly||V(192);let e=za.get(r);if(!e){e=new Map,za.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Zo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function yh(r){return r.__lexicalUnmanaged===!0}function $u(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(P(o)&&$u(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,ut,On,fi,Ji,Zi,Fr,jt,eo,In,Ye="",at="",qt=null,Nt="",rr="",qu=!1,zn=!1,vs=null;function zs(r,e){const t=Fr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(jt.has(r)||ut._keyToDOMMap.delete(r),P(t)){const n=qs(t,Fr);to(n,0,n.length-1,null)}t!==void 0&&Qo(In,On,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&zs(i,n)}}function vr(r,e){r.setProperty("text-align",e)}const xh="40px";function Uu(r,e){const t=yr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||xh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Wu(r,e){const t=r.style;e===0?vr(t,""):e===Oo?vr(t,"left"):e===Io?vr(t,"center"):e===zo?vr(t,"right"):e===$o?vr(t,"justify"):e===qo?vr(t,"start"):e===Uo&&vr(t,"end")}function $s(r,e){const t=jt.get(r);t===void 0&&V(60);const n=t.createDOM(yr,ut);if(function(s,i,o){const l=o._keyToDOMMap;(function(a,u,c){a[`__lexicalKey_${u._key}`]=c})(i,o,s),l.set(s,i)}(r,n,ut),G(t)?n.setAttribute("data-lexical-text","true"):Ae(t)&&n.setAttribute("data-lexical-decorator","true"),P(t)){const s=t.__indent,i=t.__size;if(s!==0&&Uu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=at;at="",ro(a,c,0,u,c.getDOMSlot(d)),Hu(c,d),at=f})(qs(t,jt),l,t,n)}const o=t.__format;o!==0&&Wu(n,o),t.isInline()||Vu(null,t,n),ci(t)&&(Ye+=sr,rr+=sr)}else{const s=t.getTextContent();if(Ae(t)){const i=t.decorate(ut,yr);i!==null&&Gu(r,i),n.contentEditable="false"}else G(t)&&(t.isDirectionless()||(at+=s));Ye+=s,rr+=s}return e!==null&&e.insertChild(n),Qo(In,On,fi,t,"created"),n}function ro(r,e,t,n,s){const i=Ye;Ye="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=jt.get(r[o]);l!==null&&G(l)&&(qt===null&&(qt=l.getFormat()),Nt===""&&(Nt=l.getStyle()))}ci(e)&&(Ye+=sr),s.element.__lexicalTextContent=Ye,Ye=i+Ye}function $a(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Ae(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Vu(r,e,t){const n=$a(r,Fr),s=$a(e,jt);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Hu(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==at||n!==vs){const i=at==="",o=i?vs:(s=at,Gf.test(s)?"rtl":Kf.test(s)?"ltr":null);if(o!==n){const l=e.classList,a=yr.theme;let u=n!==null?a[n]:void 0,c=o!==null?a[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Ms(u);u=a[n]=d}l.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Ms(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}vs=o,e.__lexicalDirTextContent=at,e.__lexicalDir=o}var s}function bh(r,e,t){const n=at;var s;at="",qt=null,Nt="",function(i,o,l){const a=Ye,u=i.__size,c=o.__size;Ye="";const d=l.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)vn(f,d);else{const m=no(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(v){if(typeof v=="object"&&v!=null){const b=`${v.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(b)}throw v}zs(f,null)}const g=jt.get(p);G(g)&&(qt===null&&(qt=g.getFormat()),Nt===""&&(Nt=g.getStyle()))}else{const f=qs(i,Fr),p=qs(o,jt);if(f.length!==u&&V(227),p.length!==c&&V(228),u===0)c!==0&&ro(p,o,0,c-1,l);else if(c===0){if(u!==0){const g=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;to(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,b,C){const S=v-1,D=b-1;let w,y,k=C.getFirstChild(),N=0,F=0;for(;N<=S&&F<=D;){const L=m[N],E=x[F];if(L===E)k=Mi(vn(E,C.element)),N++,F++;else{w===void 0&&(w=new Set(m)),y===void 0&&(y=new Set(x));const R=y.has(L),O=w.has(E);if(R)if(O){const H=Os(ut,E);H===k?k=Mi(vn(E,C.element)):(C.withBefore(k).insertChild(H),vn(E,C.element)),N++,F++}else $s(E,C.withBefore(k)),F++;else k=Mi(no(L)),zs(L,C.element),N++}const B=jt.get(E);B!==null&&G(B)&&(qt===null&&(qt=B.getFormat()),Nt===""&&(Nt=B.getStyle()))}const T=N>S,M=F>D;if(T&&!M){const L=x[D+1],E=L===void 0?null:ut.getElementByKey(L);ro(x,g,F,D,C.withBefore(E))}else M&&!T&&to(m,N,S,C.element)})(o,f,p,u,c,l)}ci(o)&&(Ye+=sr),d.__lexicalTextContent=Ye,Ye=a+Ye}(r,e,e.getDOMSlot(t)),Hu(e,t),tn(s=e)&&qt!=null&&qt!==s.__textFormat&&!zn&&(s.setTextFormat(qt),s.setTextStyle(Nt)),function(i){tn(i)&&Nt!==""&&Nt!==i.__textStyle&&!zn&&i.setTextStyle(Nt)}(e),at=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&V(101),t.push(n),n=s.__next}return t}function vn(r,e){const t=Fr.get(r);let n=jt.get(r);t!==void 0&&n!==void 0||V(61);const s=qu||Zi.has(r)||Ji.has(r),i=Os(ut,r);if(t===n&&!s){if(P(t)){const o=i.__lexicalTextContent;o!==void 0&&(Ye+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(at+=l)}else{const o=t.getTextContent();G(t)&&!t.isDirectionless()&&(at+=o),rr+=o,Ye+=o}return i}if(t!==n&&s&&Qo(In,On,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&V(62),e.replaceChild(o,i),zs(r,null),o}if(P(t)&&P(n)){const o=n.__indent;o!==t.__indent&&Uu(i,o);const l=n.__format;l!==t.__format&&Wu(i,l),s&&(bh(t,n,i),lt(n)||n.isInline()||Vu(t,n,i)),ci(n)&&(Ye+=sr,rr+=sr)}else{const o=n.getTextContent();if(Ae(n)){const l=n.decorate(ut,yr);l!==null&&Gu(r,l)}else G(n)&&!n.isDirectionless()&&(at+=o);Ye+=o,rr+=o}if(!zn&&lt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Gu(r,e){let t=ut._pendingDecorators;const n=ut._decorators;if(t===null){if(n[r]===e)return;t=ju(ut)}t[r]=e}function Mi(r){let e=r.nextSibling;return e!==null&&e===ut._blockCursorElement&&(e=e.nextSibling),e}function _h(r,e,t,n,s,i){Ye="",rr="",at="",qu=n===Zr,vs=null,ut=t,yr=t._config,On=t._nodes,fi=ut._listeners.mutation,Ji=s,Zi=i,Fr=r._nodeMap,jt=e._nodeMap,zn=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return In=o,vn("root",null),ut=void 0,On=void 0,Ji=void 0,Zi=void 0,Fr=void 0,jt=void 0,yr=void 0,eo=void 0,In=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&V(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Ku=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!J(e,Ef,r)&&t!=null){if(function(l,a,u,c){return ja(l)&&!a&&!c&&!u}(t,s,o,i))J(e,pu,r);else if(function(l,a,u,c,d){return ja(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))J(e,kf,r);else if(function(l,a,u,c){return Ma(l)&&!a&&!c&&!u}(t,s,o,i))J(e,gu,r);else if(function(l,a,u,c,d){return Ma(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))J(e,Df,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))J(e,mu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))J(e,yu,r);else if(function(l,a){return La(l)&&a}(t,n))Bn=!0,J(e,Ns,r);else if(function(l){return l===" "}(t))J(e,Af,r);else if(function(l,a){return Tt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,J(e,Kr,!0);else if(function(l,a){return La(l)&&!a}(t,n))Bn=!1,J(e,Ns,r);else if(function(l,a,u,c){return Tt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?J(e,xu,r):(r.preventDefault(),J(e,kr,!0));else if(function(l){return l==="Escape"}(t))J(e,bu,r);else if(function(l,a,u,c,d){return Tt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?J(e,_u,r):(r.preventDefault(),J(e,kr,!1));else if(function(l,a,u){return fn(l)&&(Tt?a:u)}(t,o,s))r.preventDefault(),J(e,jn,!0);else if(function(l,a,u){return hn(l)&&(Tt?a:u)}(t,o,s))r.preventDefault(),J(e,jn,!1);else if(function(l,a){return Tt&&a&&fn(l)}(t,i))r.preventDefault(),J(e,Ln,!0);else if(function(l,a){return Tt&&a&&hn(l)}(t,i))r.preventDefault(),J(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&_n(u,c)}(t,o,i,s))r.preventDefault(),J(e,Mt,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&_n(u,c)}(t,o,i,s))r.preventDefault(),J(e,Mt,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&_n(u,c)}(t,o,i,s))r.preventDefault(),J(e,Mt,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))J(e,Tf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&_n(u,c)}(t,n,i,s))r.preventDefault(),J(e,Ro,void 0);else if(function(l,a,u,c){return Tt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),J(e,Mo,void 0);else{const l=e._editorState._selection;l===null||z(l)?!mr&&Pa(t,i,s)&&(r.preventDefault(),J(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Tt?c:d)}(t,n,i,s)?(r.preventDefault(),J(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Tt?c:d)}(t,n,i,s)?(r.preventDefault(),J(e,jo,r)):Pa(t,i,s)&&(r.preventDefault(),J(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&J(e,Of,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&bt(e,()=>{Ae(en(t))||(ao=!0)})}],["compositionstart",function(r,e){bt(e,()=>{const t=te();if(z(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();Ze(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||G(s)&&s.getStyle()!==t.style)&&J(e,Yr,Hf)}})}],["compositionend",function(r,e){mr?gn=!0:bt(e,()=>{ji(e,r.data)})}],["input",function(r,e){r.stopPropagation(),bt(e,()=>{const t=te(),n=r.data,s=Ju(r);if(n!=null&&z(t)&&Xu(t,s,n,r.timeStamp,!1)){gn&&(ji(e,n),gn=!1);const i=t.anchor.getNode(),o=Et(e._window);if(o===null)return;const l=t.isBackward(),a=l?t.anchor.offset:t.focus.offset,u=l?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&G(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===Iu(o.anchorNode)||J(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Gn||Lo||!e.isComposing()||(Nn=0,Ze(null))}else Ko(!1,e,n!==null?n:void 0),gn&&(ji(e,n||void 0),gn=!1);pt(),Tu(ze())}),Wr=null}],["click",function(r,e){bt(e,()=>{const t=te(),n=Et(e._window),s=es();if(n){if(z(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!lt(o)&&Pe().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(P(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Kn||o===xr)&&Gt(ta(s,n,e,r))}}}J(e,hu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=Ju(t);s==="deleteCompositionText"||mr&&zu(n)||s!=="insertCompositionText"&&bt(n,()=>{const o=te();if(s==="deleteContentBackward"){if(o===null){const p=es();if(!z(p))return;Gt(p.clone())}if(z(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Ku==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(Ze(null),Nn=0,setTimeout(()=>{bt(n,()=>{Ze(null)})},so),z(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),G(g)||V(142),o.style=g.getStyle()}}else{Ze(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;$f&&p&&!v&&x||J(n,kr,!0)}return}}var l;if(!z(o))return;const a=t.data;Wr!==null&&Ko(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||lt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":J(n,Yr,t);break;case"insertFromComposition":Ze(null),J(n,Yr,t);break;case"insertLineBreak":Ze(null),J(n,Kr,!1);break;case"insertParagraph":Ze(null),Bn&&!Gn?(Bn=!1,J(n,Kr,!1)):J(n,Mn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":J(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||P(p)||P(g)||!p.isToken()||!g.isToken()})(d,f)&&J(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":J(n,Ki,t);break;case"deleteContent":J(n,kr,!1);break;case"deleteWordBackward":J(n,jn,!0);break;case"deleteWordForward":J(n,jn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":J(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":J(n,Ln,!1);break;case"formatStrikeThrough":J(n,Mt,"strikethrough");break;case"formatBold":J(n,Mt,"bold");break;case"formatItalic":J(n,Mt,"italic");break;case"formatUnderline":J(n,Mt,"underline");break;case"historyUndo":J(n,Ro,void 0);break;case"historyRedo":J(n,Mo,void 0)}else{if(a===`
86
- `)t.preventDefault(),J(n,Kr,!1);else if(a===sr)t.preventDefault(),J(n,Mn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Xu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),J(n,Yr,a)):Wr=a;Yu=t.timeStamp}})}(r,e)]);let Nn=0,Ku=null,Yu=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Qu=[0,"",0,"root",0];function Xu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=ze(),u=Et(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!G(l)||(!s&&(!Bs||Yu<n+50)||l.isDirty()&&p<2||Pu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==js(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||uh(r,l)}function qa(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Ua(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,qa(n,s)&&qa(i,o))||bt(e,()=>{if(!t)return void Gt(null);if(!Yn(e,n,i))return;const l=te();if(z(l)){const a=l.anchor,u=a.getNode();if(l.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(l.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[f,p,g,m,x]=Qu,v=Pe(),b=e.isComposing()===!1&&v.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")G(u)||V(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!b){const C=a.getNode();l.style="",C instanceof on&&C.getChildrenSize()===0?(l.format=C.getTextFormat(),l.style=C.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,f=l.getNodes(),p=f.length,g=l.isBackward(),m=g?o:s,x=g?s:o,v=g?d:c,b=g?c:d;let C=Vf,S=!1;for(let D=0;D<p;D++){const w=f[D],y=w.getTextContentSize();if(G(w)&&y!==0&&!(D===0&&w.__key===v&&m===y||D===p-1&&w.__key===b&&x===0)&&(S=!0,C&=w.getFormat(),C===0))break}l.format=S?C:0}}J(e,Fo,void 0)})}function Ju(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function ji(r,e){const t=r._compositionKey;if(Ze(null),t!==null&&e!=null){if(e===""){const n=st(t),s=js(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&G(n)&&Yo(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
- `){const n=te();if(z(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void J(r,Ns,null)}}}Ko(!0,r,e)}function Zu(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function ec(r){const e=r.target,t=Et(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Fu(t.anchorNode);if(n===null)return;ao&&(ao=!1,bt(n,()=>{const u=es(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Kn&&d!==xr||Gt(ta(u,t,n,r))}));const s=Go(n),i=s[s.length-1],o=i._key,l=Qr.get(o),a=l||i;a!==n&&Ua(t,a,!1),Ua(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Wa(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function vh(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&V(162);const n=t-1;n>=0||V(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",ec);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const l=Go(o),a=l[l.length-1]._key;Qr.get(a)===o&&Qr.delete(a)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&V(198);const i=Zu(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){pt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=te();if(!z(a)||!P(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),f=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(f,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(z(i)&&e){const l=i.anchor,a=i.focus;l.key===n&&(Vs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),a.key===n&&(Vs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Ut(i)&&e&&r.isSelected()&&r.selectPrevious();if(z(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Kt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&lt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){V(64,this.name)}static clone(e){V(65,this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,lh(this,e)}getType(){return this.__type}isInline(){V(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=st(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||te();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(G(this))return n;if(z(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Ae(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:st(e)}getParentOrThrow(){const e=this.getParent();return e===null&&V(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Kt(t))return P(e)||e===this&&Ae(e)||V(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&V(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:st(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:st(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();P(this)&&t.unshift(this),P(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let l=0;l<s;l++){const a=t[l];if(o.has(a))return a}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const l=P(i)?t?i.getFirstChild():i.getLastChild():null;if(l!==null){i=l;continue}const a=t?i.getNextSibling():i.getPreviousSibling();if(a!==null){i=a;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&V(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=ze()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=st(this.__key);return e===null&&V(113),e}getWritable(){pt();const e=ar(),t=ze(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=te();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Jo(i);return o.add(s),Ps(a),n.set(s,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){V(70)}updateDOM(e,t,n){V(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){V(72)}static importJSON(e){V(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){pt();let n=te();n!==null&&(n=n.clone()),Fi(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,l=e.getWritable(),a=this.getParentOrThrow().getWritable(),u=a.__size;Dr(l);const c=s.getPreviousSibling(),d=s.getNextSibling(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=f,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(P(this)&&P(l)||V(139),this.getChildren().forEach(m=>{l.append(m)})),z(n)){Gt(n);const m=n.anchor,x=n.focus;m.key===i&&Ya(m,l),x.key===i&&Ya(x,l)}return hr()===i&&Ze(o),l}insertAfter(e,t=!0){pt(),Fi(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=te();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),z(o)){const g=i.__key,m=o.anchor,x=o.focus;l=m.type==="element"&&m.key===g&&m.offset===p+1,a=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,f=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=f,s.__prev=n.__key,s.__parent=n.__parent,t&&z(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;l&&o.anchor.set(g,p+2,"element"),a&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){pt(),Fi(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=n.__prev,u=this.getIndexWithinParent();o===null?l.__first=i:o.getWritable().__next=i,l.__size++,n.__prev=i,s.__prev=a,s.__next=n.__key,s.__parent=n.__parent;const c=te();return t&&z(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return He()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){pt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(P(n))return n.select();if(!G(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){pt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(P(n))return n.select(0,0);if(!G(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Xn extends hi{static getType(){return"linebreak"}static clone(e){return new Xn(e.__key)}constructor(e){super(e)}getTextContent(){return`
88
- `}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&Is(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&cs(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&cs(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&Is(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&cs(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&cs(i))return!0}return!1}(e)?null:{conversion:wh,priority:0}}}static importJSON(e){return Rr()}exportJSON(){return{type:"linebreak",version:1}}}function wh(r){return{node:Rr()}}function Rr(){return Qt(new Xn)}function Ar(r){return r instanceof Xn}function cs(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Po?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function tc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let l=!1;const a=e&Rs&&e&Fs;o!==void 0&&(t&Rs&&t&Fs?(l=!0,a||i.add(...o)):a&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(l&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!a||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function rc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||mr){const[l,a,u]=function(c,d){const f=c.length,p=d.length;let g=0,m=0;for(;g<f&&g<p&&c[g]===d[g];)g++;for(;m+g<f&&m+g<p&&c[f-m-1]===d[p-m-1];)m++;return[g,f-g-m,d.slice(g,p-m)]}(o,i);a!==0&&n.deleteData(l,a),n.insertData(l,u)}else n.nodeValue=i}}function Ha(r,e,t,n,s,i){rc(s,r,e);const o=i.theme.text;o!==void 0&&tc(0,0,n,r,o)}function ds(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return Jf[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===hr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,l=document.createElement(o);let a=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),s!==null&&(a=document.createElement(i),l.appendChild(a)),Ha(a,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(l.style.cssText=u),l}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,l=Li(0,i),a=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((l===null?u:l)!==(a===null?c:a))return!0;if(l===a&&u!==c){const m=t.firstChild;m==null&&V(48);const x=document.createElement(c);return Ha(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;a!==null&&l!==null&&(d=t.firstChild,d==null&&V(49)),rc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&tc(0,i,o,d,f);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:kh,priority:0}),b:()=>({conversion:Sh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Ch,priority:0}),strong:()=>({conversion:ur,priority:0}),sub:()=>({conversion:ur,priority:0}),sup:()=>({conversion:ur,priority:0}),u:()=>({conversion:ur,priority:0})}}static importJSON(e){const t=Ke(e.text);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportDOM(e){let{element:t}=super.exportDOM(e);return t!==null&&or(t)||V(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=ds(t,"b")),this.hasFormat("italic")&&(t=ds(t,"i")),this.hasFormat("strikethrough")&&(t=ds(t,"s")),this.hasFormat("underline")&&(t=ds(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format=typeof e=="string"?Br[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?Yf[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Ls(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=Xf[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){pt();let n=e,s=t;const i=te(),o=this.getTextContent(),l=this.__key;if(typeof o=="string"){const a=o.length;n===void 0&&(n=a),s===void 0&&(s=a)}else n=0,s=0;if(!z(i))return ic(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||Ze(l),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,l=n.length;let a=e;a<0&&(a=l+a,a<0&&(a=0));const u=te();if(s&&z(u)){const d=e+l;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,a)+n+o.slice(a+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){pt();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),l=[],a=n.length;let u="";for(let D=0;D<a;D++)u!==""&&o.has(D)&&(l.push(u),u=""),u+=n[D];u!==""&&l.push(u);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const d=l[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let v=!1;t.isSegmented()?(p=Ke(d),p.__format=g,p.__style=m,p.__detail=x,v=!0):(p=t.getWritable(),p.__text=d);const b=te(),C=[p];let S=d.length;for(let D=1;D<c;D++){const w=l[D],y=w.length,k=Ke(w).getWritable();k.__format=g,k.__style=m,k.__detail=x;const N=k.__key,F=S+y;if(z(b)){const T=b.anchor,M=b.focus;T.key===s&&T.type==="text"&&T.offset>S&&T.offset<=F&&(T.key=N,T.offset-=S,b.dirty=!0),M.key===s&&M.type==="text"&&M.offset>S&&M.offset<=F&&(M.key=N,M.offset-=S,b.dirty=!0)}i===s&&Ze(N),S=F,C.push(k)}if(f!==null){(function(y){const k=y.getPreviousSibling(),N=y.getNextSibling();k!==null&&Ps(k),N!==null&&Ps(N)})(this);const D=f.getWritable(),w=this.getIndexWithinParent();v?(D.splice(w,0,C),this.remove()):D.splice(w,1,C),z(b)&&Ws(b,f,w,c-1)}return C}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||V(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&Ze(n);const l=te();if(z(l)){const d=l.anchor,f=l.focus;d!==null&&d.key===s&&(rl(d,t,n,e,o),l.dirty=!0),f!==null&&f.key===s&&(rl(f,t,n,e,o),l.dirty=!0)}const a=e.__text,u=t?a+i:i+a;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Ch(r){return{forChild:ea(r.style),node:null}}function Sh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:ea(e.style,t?void 0:"bold"),node:null}}const Ga=new WeakMap;function Eh(r){return r.nodeName==="PRE"||r.nodeType===Kn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function kh(r){const e=r;r.parentElement===null&&V(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ga.get(i))===void 0&&!Eh(i);)o.push(i),i=i.parentNode;const l=s===void 0?i:s;for(let a=0;a<o.length;a++)Ga.set(o[a],l);return l}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const l=n[o];l===`
85
+ `,Gf=mr?" ":ai,Du="֑-߿יִ-﷽ﹰ-ﻼ",Au="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Kf=new RegExp("^[^"+Au+"]*["+Du+"]"),Yf=new RegExp("^[^"+Du+"]*["+Au+"]"),Br={bold:1,code:16,highlight:Io,italic:2,strikethrough:Rs,subscript:32,superscript:64,underline:Ms},Qf={directionless:1,unmergeable:2},Aa={center:zo,end:Wo,justify:qo,left:Oo,right:$o,start:Uo},Xf={[zo]:"center",[Wo]:"end",[qo]:"justify",[Oo]:"left",[$o]:"right",[Uo]:"start"},Jf={normal:0,segmented:2,token:1},Zf={[Uf]:"normal",[Vf]:"segmented",[Wf]:"token"};function eh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var H=eh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Fs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const th=100;let Xi=!1,Vo=0;function rh(r){Vo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function nh(r,e,t){const n=Dt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Qo(e,o,s,i,!1)}function sh(r,e,t){if(U(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function ih(r,e,t,n){for(let s=r;s&&!xh(s);s=Qn(s)){const i=ui(s,e);if(i!==void 0){const o=ct(i,t);if(o)return Pe(o)?void 0:[s,o]}else if(s===n)return[n,Pu(t)]}}function Tu(r,e,t){Xi=!0;const n=performance.now()-Vo>th;try{_t(r,()=>{const s=se()||function(f){return f.getEditorState().read(()=>{const p=se();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),l=r._editorState,a=r._blockCursorElement;let u=!1,c="";for(let f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=ih(m,r,l,o);if(!x)continue;const[w,y]=x;if(g==="characterData")n&&K(y)&&sh(s,m,y)&&nh(m,y,r);else if(g==="childList"){u=!0;const C=p.addedNodes;for(let _=0;_<C.length;_++){const b=C[_],E=ju(b),N=b.parentNode;if(N!=null&&b!==a&&E===null&&!Bi(b,N,r)){if(mr){const R=b.innerText||b.nodeValue;R&&(c+=R)}N.removeChild(b)}}const S=p.removedNodes,D=S.length;if(D>0){let _=0;for(let b=0;b<D;b++){const E=S[b];(Bi(E,m,r)||a===E)&&(m.appendChild(E),_++)}D!==_&&i.set(w,y)}}}if(i.size>0)for(const[f,p]of i)p.reconcileObservedMutation(f,r);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const p=d[f],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const w=g[x],y=w.parentNode;y==null||w.nodeName!=="BR"||Bi(w,m,r)||y.removeChild(w)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Gt(s)),mr&&$u(r)&&s.insertRawText(c))})}finally{Xi=!1}}function Nu(r){const e=r._observer;e!==null&&Tu(r,e.takeRecords(),e)}function Bu(r){(function(e){Vo===0&&di(e).addEventListener("textInput",rh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Tu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,l=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==l)}function Na(r,e){const t=r.mergeWithSibling(e),n=Ge()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&K(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&K(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Ru(r){return Ra(r.anchor),Ra(r.focus),r}function Ra(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),K(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!P(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let oh=1;const ah=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Ho(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Pe(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Yn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Ho(e)&&Mu(e)===r}catch{return!1}}function Go(r){return r instanceof mi}function Mu(r){let e=r;for(;e!=null;){const t=li(e);if(Go(t))return t;e=Qn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function lh(r){return r.nodeType===xr}function js(r){let e=r;for(;e!=null;){if(lh(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Fu(r){return K(r)||Ar(r)||Pe(r)}function uh(r,e){if(e!=null)return void(r.__key=e);yt(),lc();const t=Ge(),n=ar(),s=""+oh++;n._nodeMap.set(s,r),P(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Eu,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const l=i.getWritable();l.__prev=o.__key,o.__next=l.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const l=s.getWritable();l.__next=o.__key,o.__prev=l.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){lc();const e=r.getLatest(),t=e.__parent,n=ar(),s=Ge(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const f=u.get(d);if(f===void 0)break;c.set(d,!1),d=f.__parent}}(t,i,o);const l=e.__key;s._dirtyType=Eu,P(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function at(r){yt();const e=Ge(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=ct(t);n!==null&&n.getWritable()}if(r!==null){const n=ct(r);n!==null&&n.getWritable()}}}function hr(){return ts()?null:Ge()._compositionKey}function ct(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function ju(r,e){const t=ui(r,Ge());return t!==void 0?ct(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=ju(t,e);if(n!==null)return n;t=Qn(t)}return null}function Lu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>We().getTextContent())}function We(){return Pu(ar())}function Pu(r){return r._nodeMap.get("root")}function Gt(r){yt();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Vr(r){const e=Ge(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Qn(i)}return null}(r,e);return t===null?r===e.getRootElement()?ct("root"):null:ct(t)}function Fa(r,e){return e?r.getTextContentSize():0}function Iu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Ko(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function zu(r){return r.nodeType===xr?r.nodeValue:null}function Yo(r,e,t){const n=Dt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=zu(s);const a=en(s);if(l!==null&&K(a)){if(l===ai&&t){const u=t.length;l=t,i=u,o=u}l!==null&&Qo(a,l,i,o,r)}}}function Qo(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let l=e;(o||s)&&e[e.length-1]===ai&&(l=e.slice(0,-1));const a=i.getTextContent();if(s||l!==a){if(l===""){if(at(null),oi||Gn||Po)i.remove();else{const m=Ge();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=es(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||U(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=se();if(!U(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=rt(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function ch(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(i){const o=i.getPreviousSibling();return(K(o)||P(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function ja(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Nt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function dh(){const r=We();Gt(Ru(r.select(0,r.getChildrenSize())))}function An(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const i=Fs(s);return t[e]=i,i}return s}function Xo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,l=e.get(i);l===void 0&&H(33,i);const a=l.klass;let u=r.get(a);u===void 0&&(u=new Map,r.set(a,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function Oa(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return Oa(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?Oa(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function $u(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function re(r,e,t){return dc(r,e,t)}function ci(r){return!ht(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&H(75,e),t}function Qn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&H(78),e}function fh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Kt(e))return e;e=e.getParentOrThrow()}return e}function Kt(r){return ht(r)||P(r)&&r.isShadowRoot()}function Qt(r){const e=Ge(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&H(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),l=o.constructor;return i!==null?o instanceof i||H(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||H(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&H(203,r.constructor.name,t,l.name,l.getType()),o}return r}function Ri(r,e){!ht(r.getParent())||P(e)||Pe(e)||H(99)}function Mi(r){return(Pe(r)||P(r)&&!r.canBeEmpty())&&!r.isInline()}function Jo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function hh(r,e,t){let n=r._blockCursorElement;if(U(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let l=!1,a=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(l=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(l=!0,a=r.getElementByKey(u.__key))}}if(l){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,f=document.createElement("div");f.contentEditable="false",f.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Fs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Jo(n,r,e)}function Dt(r){return It?(r||window).getSelection():null}function ph(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function za(r){return r.nodeType===11}function Ji(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function Os(r){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return r.nodeName.match(e)!==null}function cr(r){if(Pe(r)&&!r.isInline())return!0;if(!P(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||K(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function gh(){return Ge()}const $a=new WeakMap,mh=new Map;function yh(r){if(!r._readOnly&&r.isEmpty())return mh;r._readOnly||H(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Zo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function ea(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function xh(r){return r.__lexicalUnmanaged===!0}function qu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(P(o)&&qu(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,pt,In,fi,Zi,eo,Rr,Lt,to,On,nt="",ft="",qt=null,Bt="",rr="",Uu=!1,zn=!1,_s=null;function zs(r,e){const t=Rr.get(r);if(e!==null){const n=so(r);n.parentNode===e&&e.removeChild(n)}if(Lt.has(r)||pt._keyToDOMMap.delete(r),P(t)){const n=qs(t,Rr);ro(n,0,n.length-1,null)}t!==void 0&&Xo(On,In,fi,t,"destroyed")}function ro(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&zs(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const bh="40px";function Wu(r,e){const t=yr.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||bh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Oo?_r(t,"left"):e===zo?_r(t,"center"):e===$o?_r(t,"right"):e===qo?_r(t,"justify"):e===Uo?_r(t,"start"):e===Wo&&_r(t,"end")}function $s(r,e){const t=Lt.get(r);t===void 0&&H(60);const n=t.createDOM(yr,pt);if(function(s,i,o){const l=o._keyToDOMMap;(function(a,u,c){a[`__lexicalKey_${u._key}`]=c})(i,o,s),l.set(s,i)}(r,n,pt),K(t)?n.setAttribute("data-lexical-text","true"):Pe(t)&&n.setAttribute("data-lexical-decorator","true"),P(t)){const s=t.__indent,i=t.__size;if(s!==0&&Wu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=ft;ft="",no(a,c,0,u,c.getDOMSlot(d)),Gu(c,d),ft=f})(qs(t,Lt),l,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Hu(null,t,n),ci(t)&&(nt+=sr,rr+=sr)}else{const s=t.getTextContent();if(Pe(t)){const i=t.decorate(pt,yr);i!==null&&Ku(r,i),n.contentEditable="false"}else K(t)&&(t.isDirectionless()||(ft+=s));nt+=s,rr+=s}return e!==null&&e.insertChild(n),Xo(On,In,fi,t,"created"),n}function no(r,e,t,n,s){const i=nt;nt="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=Lt.get(r[o]);l!==null&&K(l)&&(qt===null&&(qt=l.getFormat()),Bt===""&&(Bt=l.getStyle()))}ci(e)&&(nt+=sr),s.element.__lexicalTextContent=nt,nt=i+nt}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Pe(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Hu(r,e,t){const n=qa(r,Rr),s=qa(e,Lt);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Gu(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==ft||n!==_s){const i=ft==="",o=i?_s:(s=ft,Kf.test(s)?"rtl":Yf.test(s)?"ltr":null);if(o!==n){const l=e.classList,a=yr.theme;let u=n!==null?a[n]:void 0,c=o!==null?a[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Fs(u);u=a[n]=d}l.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Fs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=ft,e.__lexicalDir=o}var s}function vh(r,e,t){const n=ft;var s;ft="",qt=null,Bt="",function(i,o,l){const a=nt,u=i.__size,c=o.__size;nt="";const d=l.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)_n(f,d);else{const m=so(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(w){if(typeof w=="object"&&w!=null){const y=`${w.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(y)}throw w}zs(f,null)}const g=Lt.get(p);K(g)&&(qt===null&&(qt=g.getFormat()),Bt===""&&(Bt=g.getStyle()))}else{const f=qs(i,Rr),p=qs(o,Lt);if(f.length!==u&&H(227),p.length!==c&&H(228),u===0)c!==0&&no(p,o,0,c-1,l);else if(c===0){if(u!==0){const g=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;ro(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,w,y,C){const S=w-1,D=y-1;let _,b,E=C.getFirstChild(),N=0,R=0;for(;N<=S&&R<=D;){const L=m[N],k=x[R];if(L===k)E=Fi(_n(k,C.element)),N++,R++;else{_===void 0&&(_=new Set(m)),b===void 0&&(b=new Set(x));const M=b.has(L),I=_.has(k);if(M)if(I){const W=Is(pt,k);W===E?E=Fi(_n(k,C.element)):(C.withBefore(E).insertChild(W),_n(k,C.element)),N++,R++}else $s(k,C.withBefore(E)),R++;else E=Fi(so(L)),zs(L,C.element),N++}const B=Lt.get(k);B!==null&&K(B)&&(qt===null&&(qt=B.getFormat()),Bt===""&&(Bt=B.getStyle()))}const T=N>S,F=R>D;if(T&&!F){const L=x[D+1],k=L===void 0?null:pt.getElementByKey(L);no(x,g,R,D,C.withBefore(k))}else F&&!T&&ro(m,N,S,C.element)})(o,f,p,u,c,l)}ci(o)&&(nt+=sr),d.__lexicalTextContent=nt,nt=a+nt}(r,e,e.getDOMSlot(t)),Gu(e,t),tn(s=e)&&qt!=null&&qt!==s.__textFormat&&!zn&&(s.setTextFormat(qt),s.setTextStyle(Bt)),function(i){tn(i)&&Bt!==""&&Bt!==i.__textStyle&&!zn&&i.setTextStyle(Bt)}(e),ft=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&H(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=Rr.get(r);let n=Lt.get(r);t!==void 0&&n!==void 0||H(61);const s=Uu||eo.has(r)||Zi.has(r),i=Is(pt,r);if(t===n&&!s){if(P(t)){const o=i.__lexicalTextContent;o!==void 0&&(nt+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(ft+=l)}else{const o=t.getTextContent();K(t)&&!t.isDirectionless()&&(ft+=o),rr+=o,nt+=o}return i}if(t!==n&&s&&Xo(On,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&H(62),e.replaceChild(o,i),zs(r,null),o}if(P(t)&&P(n)){const o=n.__indent;o!==t.__indent&&Wu(i,o);const l=n.__format;l!==t.__format&&Vu(i,l),s&&(vh(t,n,i),ht(n)||n.isInline()||Hu(t,n,i)),ci(n)&&(nt+=sr,rr+=sr)}else{const o=n.getTextContent();if(Pe(n)){const l=n.decorate(pt,yr);l!==null&&Ku(r,l)}else K(n)&&!n.isDirectionless()&&(ft+=o);nt+=o,rr+=o}if(!zn&&ht(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Ku(r,e){let t=pt._pendingDecorators;const n=pt._decorators;if(t===null){if(n[r]===e)return;t=Lu(pt)}t[r]=e}function Fi(r){let e=r.nextSibling;return e!==null&&e===pt._blockCursorElement&&(e=e.nextSibling),e}function _h(r,e,t,n,s,i){nt="",rr="",ft="",Uu=n===Zr,_s=null,pt=t,yr=t._config,In=t._nodes,fi=pt._listeners.mutation,Zi=s,eo=i,Rr=r._nodeMap,Lt=e._nodeMap,zn=e._readOnly,to=new Map(t._keyToDOMMap);const o=new Map;return On=o,_n("root",null),pt=void 0,In=void 0,Zi=void 0,eo=void 0,Rr=void 0,Lt=void 0,yr=void 0,to=void 0,On=void 0,o}function so(r){const e=to.get(r);return e===void 0&&H(75,r),e}const er=Object.freeze({}),io=30,oo=[["keydown",function(r,e){if(Nn=r.timeStamp,Yu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!re(e,Ef,r)&&t!=null){if(function(l,a,u,c){return La(l)&&!a&&!c&&!u}(t,s,o,i))re(e,gu,r);else if(function(l,a,u,c,d){return La(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))re(e,Df,r);else if(function(l,a,u,c){return ja(l)&&!a&&!c&&!u}(t,s,o,i))re(e,mu,r);else if(function(l,a,u,c,d){return ja(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))re(e,Af,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))re(e,yu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))re(e,xu,r);else if(function(l,a){return Pa(l)&&a}(t,n))Bn=!0,re(e,Ns,r);else if(function(l){return l===" "}(t))re(e,Tf,r);else if(function(l,a){return Nt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,re(e,Kr,!0);else if(function(l,a){return Pa(l)&&!a}(t,n))Bn=!1,re(e,Ns,r);else if(function(l,a,u,c){return Nt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?re(e,bu,r):(r.preventDefault(),re(e,Er,!0));else if(function(l){return l==="Escape"}(t))re(e,vu,r);else if(function(l,a,u,c,d){return Nt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?re(e,_u,r):(r.preventDefault(),re(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Nt?a:u)}(t,o,s))r.preventDefault(),re(e,jn,!0);else if(function(l,a,u){return hn(l)&&(Nt?a:u)}(t,o,s))r.preventDefault(),re(e,jn,!1);else if(function(l,a){return Nt&&a&&fn(l)}(t,i))r.preventDefault(),re(e,Ln,!0);else if(function(l,a){return Nt&&a&&hn(l)}(t,i))r.preventDefault(),re(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,jt,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,jt,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,jt,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))re(e,Nf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),re(e,Fo,void 0);else if(function(l,a,u,c){return Nt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),re(e,jo,void 0);else{const l=e._editorState._selection;l===null||U(l)?!mr&&Ia(t,i,s)&&(r.preventDefault(),re(e,Qi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Nt?c:d)}(t,n,i,s)?(r.preventDefault(),re(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Nt?c:d)}(t,n,i,s)?(r.preventDefault(),re(e,Lo,r)):Ia(t,i,s)&&(r.preventDefault(),re(e,Qi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&re(e,Of,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&_t(e,()=>{Pe(en(t))||(lo=!0)})}],["compositionstart",function(r,e){_t(e,()=>{const t=se();if(U(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();at(n.key),(r.timeStamp<Nn+io||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||K(s)&&s.getStyle()!==t.style)&&re(e,Yr,Gf)}})}],["compositionend",function(r,e){mr?gn=!0:_t(e,()=>{ji(e,r.data)})}],["input",function(r,e){r.stopPropagation(),_t(e,()=>{const t=se(),n=r.data,s=Zu(r);if(n!=null&&U(t)&&Ju(t,s,n,r.timeStamp,!1)){gn&&(ji(e,n),gn=!1);const i=t.anchor.getNode(),o=Dt(e._window);if(o===null)return;const l=t.isBackward(),a=l?t.anchor.offset:t.focus.offset,u=l?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&K(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===zu(o.anchorNode)||re(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Gn||Po||!e.isComposing()||(Nn=0,at(null))}else Yo(!1,e,n!==null?n:void 0),gn&&(ji(e,n||void 0),gn=!1);yt(),Nu(Ge())}),Wr=null}],["click",function(r,e){_t(e,()=>{const t=se(),n=Dt(e._window),s=es();if(n){if(U(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!ht(o)&&We().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(P(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Kn||o===xr)&&Gt(ra(s,n,e,r))}}}re(e,pu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&oo.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=Zu(t);s==="deleteCompositionText"||mr&&$u(n)||s!=="insertCompositionText"&&_t(n,()=>{const o=se();if(s==="deleteContentBackward"){if(o===null){const p=es();if(!U(p))return;Gt(p.clone())}if(U(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Yu==="MediaLast"&&l<Nn+io&&n.isComposing()&&p){if(at(null),Nn=0,setTimeout(()=>{_t(n,()=>{at(null)})},io),U(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),K(g)||H(142),o.style=g.getStyle()}}else{at(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),w=o.anchor.offset===0&&o.focus.offset===m.length;qf&&p&&!w&&x||re(n,Er,!0)}return}}var l;if(!U(o))return;const a=t.data;Wr!==null&&Yo(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||ht(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":re(n,Yr,t);break;case"insertFromComposition":at(null),re(n,Yr,t);break;case"insertLineBreak":at(null),re(n,Kr,!1);break;case"insertParagraph":at(null),Bn&&!Gn?(Bn=!1,re(n,Kr,!1)):re(n,Fn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":re(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||P(p)||P(g)||!p.isToken()||!g.isToken()})(d,f)&&re(n,Yi,t);break;case"deleteByDrag":case"deleteByCut":re(n,Yi,t);break;case"deleteContent":re(n,Er,!1);break;case"deleteWordBackward":re(n,jn,!0);break;case"deleteWordForward":re(n,jn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":re(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":re(n,Ln,!1);break;case"formatStrikeThrough":re(n,jt,"strikethrough");break;case"formatBold":re(n,jt,"bold");break;case"formatItalic":re(n,jt,"italic");break;case"formatUnderline":re(n,jt,"underline");break;case"historyUndo":re(n,Fo,void 0);break;case"historyRedo":re(n,jo,void 0)}else{if(a===`
86
+ `)t.preventDefault(),re(n,Kr,!1);else if(a===sr)t.preventDefault(),re(n,Fn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Ju(o,i,a,t.timeStamp,!0)?(t.preventDefault(),re(n,Yr,a)):Wr=a;Qu=t.timeStamp}})}(r,e)]);let Nn=0,Yu=null,Qu=0,Wr=null;const Us=new WeakMap;let ao=!1,lo=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Ju(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=Ge(),u=Dt(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!K(l)||(!s&&(!Bs||Qu<n+50)||l.isDirty()&&p<2||Iu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==js(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||ch(r,l)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;ao&&(ao=!1,Ua(n,s)&&Ua(i,o))||_t(e,()=>{if(!t)return void Gt(null);if(!Yn(e,n,i))return;const l=se();if(U(l)){const a=l.anchor,u=a.getNode();if(l.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(l.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[f,p,g,m,x]=Xu,w=We(),y=e.isComposing()===!1&&w.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")K(u)||H(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!y){const C=a.getNode();l.style="",C instanceof on&&C.getChildrenSize()===0?(l.format=C.getTextFormat(),l.style=C.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,f=l.getNodes(),p=f.length,g=l.isBackward(),m=g?o:s,x=g?s:o,w=g?d:c,y=g?c:d;let C=Hf,S=!1;for(let D=0;D<p;D++){const _=f[D],b=_.getTextContentSize();if(K(_)&&b!==0&&!(D===0&&_.__key===w&&m===b||D===p-1&&_.__key===y&&x===0)&&(S=!0,C&=_.getFormat(),C===0))break}l.format=S?C:0}}re(e,Mo,void 0)})}function Zu(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function ji(r,e){const t=r._compositionKey;if(at(null),t!==null&&e!=null){if(e===""){const n=ct(t),s=js(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&K(n)&&Qo(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
+ `){const n=se();if(U(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void re(r,Ns,null)}}}Yo(!0,r,e)}function ec(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function tc(r){const e=r.target,t=Dt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Mu(t.anchorNode);if(n===null)return;lo&&(lo=!1,_t(n,()=>{const u=es(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Kn&&d!==xr||Gt(ra(u,t,n,r))}));const s=Ko(n),i=s[s.length-1],o=i._key,l=Qr.get(o),a=l||i;a!==n&&Wa(t,a,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Va(r){r._lexicalHandled=!0}function Ha(r){return r._lexicalHandled===!0}function wh(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&H(162);const n=t-1;n>=0||H(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",tc);const s=li(r);Go(s)?(function(o){if(o._parentEditor!==null){const l=Ko(o),a=l[l.length-1]._key;Qr.get(a)===o&&Qr.delete(a)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&H(198);const i=ec(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function uo(r,e,t){yt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=se();if(!U(a)||!P(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),f=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(f,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(U(i)&&e){const l=i.anchor,a=i.focus;l.key===n&&(Vs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),a.key===n&&(Vs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Ut(i)&&e&&r.isSelected()&&r.selectPrevious();if(U(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Kt(s)||s.canBeEmpty()||!s.isEmpty()||uo(s,e),e&&ht(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){H(64,this.name)}static clone(e){H(65,this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,uh(this,e)}getType(){return this.__type}isInline(){H(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=ct(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||se();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(K(this))return n;if(U(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Pe(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:ct(e)}getParentOrThrow(){const e=this.getParent();return e===null&&H(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Kt(t))return P(e)||e===this&&Pe(e)||H(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&H(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:ct(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:ct(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();P(this)&&t.unshift(this),P(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let l=0;l<s;l++){const a=t[l];if(o.has(a))return a}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const l=P(i)?t?i.getFirstChild():i.getLastChild():null;if(l!==null){i=l;continue}const a=t?i.getNextSibling():i.getPreviousSibling();if(a!==null){i=a;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&H(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=Ge()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=ct(this.__key);return e===null&&H(113),e}getWritable(){yt();const e=ar(),t=Ge(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=se();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Zo(i);return o.add(s),Ps(a),n.set(s,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){H(70)}updateDOM(e,t,n){H(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){H(72)}static importJSON(e){H(18,this.name)}static transform(){return null}remove(e){uo(this,!0,e)}replace(e,t){yt();let n=se();n!==null&&(n=n.clone()),Ri(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,l=e.getWritable(),a=this.getParentOrThrow().getWritable(),u=a.__size;Dr(l);const c=s.getPreviousSibling(),d=s.getNextSibling(),f=s.__prev,p=s.__next,g=s.__parent;if(uo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=f,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(P(this)&&P(l)||H(139),this.getChildren().forEach(m=>{l.append(m)})),U(n)){Gt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,l),x.key===i&&Qa(x,l)}return hr()===i&&at(o),l}insertAfter(e,t=!0){yt(),Ri(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=se();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),U(o)){const g=i.__key,m=o.anchor,x=o.focus;l=m.type==="element"&&m.key===g&&m.offset===p+1,a=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,f=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=f,s.__prev=n.__key,s.__parent=n.__parent,t&&U(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;l&&o.anchor.set(g,p+2,"element"),a&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){yt(),Ri(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=n.__prev,u=this.getIndexWithinParent();o===null?l.__first=i:o.getWritable().__next=i,l.__size++,n.__prev=i,s.__prev=a,s.__next=n.__key,s.__parent=n.__parent;const c=se();return t&&U(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return et()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){yt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(P(n))return n.select();if(!K(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){yt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(P(n))return n.select(0,0);if(!K(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Xn extends hi{static getType(){return"linebreak"}static clone(e){return new Xn(e.__key)}constructor(e){super(e)}getTextContent(){return`
88
+ `}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&Os(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&cs(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&cs(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&Os(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&cs(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&cs(i))return!0}return!1}(e)?null:{conversion:Ch,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Ch(r){return{node:Mr()}}function Mr(){return Qt(new Xn)}function Ar(r){return r instanceof Xn}function cs(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Io?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function rc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let l=!1;const a=e&Ms&&e&Rs;o!==void 0&&(t&Ms&&t&Rs?(l=!0,a||i.add(...o)):a&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(l&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!a||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function nc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||mr){const[l,a,u]=function(c,d){const f=c.length,p=d.length;let g=0,m=0;for(;g<f&&g<p&&c[g]===d[g];)g++;for(;m+g<f&&m+g<p&&c[f-m-1]===d[p-m-1];)m++;return[g,f-g-m,d.slice(g,p-m)]}(o,i);a!==0&&n.deleteData(l,a),n.insertData(l,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){nc(s,r,e);const o=i.theme.text;o!==void 0&&rc(0,0,n,r,o)}function ds(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return Zf[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===hr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,l=document.createElement(o);let a=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),s!==null&&(a=document.createElement(i),l.appendChild(a)),Ga(a,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(l.style.cssText=u),l}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,l=Li(0,i),a=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((l===null?u:l)!==(a===null?c:a))return!0;if(l===a&&u!==c){const m=t.firstChild;m==null&&H(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;a!==null&&l!==null&&(d=t.firstChild,d==null&&H(49)),nc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&rc(0,i,o,d,f);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Dh,priority:0}),b:()=>({conversion:kh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Sh,priority:0}),strong:()=>({conversion:ur,priority:0}),sub:()=>({conversion:ur,priority:0}),sup:()=>({conversion:ur,priority:0}),u:()=>({conversion:ur,priority:0})}}static importJSON(e){const t=rt(e.text);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportDOM(e){let{element:t}=super.exportDOM(e);return t!==null&&or(t)||H(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=ds(t,"b")),this.hasFormat("italic")&&(t=ds(t,"i")),this.hasFormat("strikethrough")&&(t=ds(t,"s")),this.hasFormat("underline")&&(t=ds(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format=typeof e=="string"?Br[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?Qf[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Ls(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=Jf[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){yt();let n=e,s=t;const i=se(),o=this.getTextContent(),l=this.__key;if(typeof o=="string"){const a=o.length;n===void 0&&(n=a),s===void 0&&(s=a)}else n=0,s=0;if(!U(i))return oc(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||at(l),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,l=n.length;let a=e;a<0&&(a=l+a,a<0&&(a=0));const u=se();if(s&&U(u)){const d=e+l;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,a)+n+o.slice(a+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){yt();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),l=[],a=n.length;let u="";for(let D=0;D<a;D++)u!==""&&o.has(D)&&(l.push(u),u=""),u+=n[D];u!==""&&l.push(u);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const d=l[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let w=!1;t.isSegmented()?(p=rt(d),p.__format=g,p.__style=m,p.__detail=x,w=!0):(p=t.getWritable(),p.__text=d);const y=se(),C=[p];let S=d.length;for(let D=1;D<c;D++){const _=l[D],b=_.length,E=rt(_).getWritable();E.__format=g,E.__style=m,E.__detail=x;const N=E.__key,R=S+b;if(U(y)){const T=y.anchor,F=y.focus;T.key===s&&T.type==="text"&&T.offset>S&&T.offset<=R&&(T.key=N,T.offset-=S,y.dirty=!0),F.key===s&&F.type==="text"&&F.offset>S&&F.offset<=R&&(F.key=N,F.offset-=S,y.dirty=!0)}i===s&&at(N),S=R,C.push(E)}if(f!==null){(function(b){const E=b.getPreviousSibling(),N=b.getNextSibling();E!==null&&Ps(E),N!==null&&Ps(N)})(this);const D=f.getWritable(),_=this.getIndexWithinParent();w?(D.splice(_,0,C),this.remove()):D.splice(_,1,C),U(y)&&Ws(y,f,_,c-1)}return C}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||H(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&at(n);const l=se();if(U(l)){const d=l.anchor,f=l.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),l.dirty=!0),f!==null&&f.key===s&&(nl(f,t,n,e,o),l.dirty=!0)}const a=e.__text,u=t?a+i:i+a;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Sh(r){return{forChild:ta(r.style),node:null}}function kh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:ta(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function Eh(r){return r.nodeName==="PRE"||r.nodeType===Kn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Dh(r){const e=r;r.parentElement===null&&H(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!Eh(i);)o.push(i),i=i.parentNode;const l=s===void 0?i:s;for(let a=0;a<o.length;a++)Ka.set(o[a],l);return l}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const l=n[o];l===`
89
89
  `||l===`\r
90
- `?s.push(Rr()):l===" "?s.push(Zn()):l!==""&&s.push(Ke(l))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ka(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ka(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:Ke(t)}}function Ka(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Kn){const i=t.style.display;if(i===""&&!Xi(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Dh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Dh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:ea(r.style,e),node:null}}function Ke(r=""){return Qt(new sn(r))}function G(r){return r instanceof sn}function ea(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",l=n.includes("underline"),a=r.verticalAlign;return u=>(G(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),l&&!u.hasFormat("underline")&&u.toggleFormat("underline"),a!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),a!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Zn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){V(126)}setDetail(e){V(127)}setMode(e){V(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Zn(){return Qt(new Jn)}function Ah(r){return r instanceof Jn}class Th{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode();const s=this.offset,i=e.offset;if(P(t)){const o=t.getDescendantByIndex(s);t=o??t}if(P(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=st(this.key);return e===null&&V(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,ts()||(hr()===i&&Ze(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Yt(r,e,t){return new Th(r,e,t)}function Oi(r,e){let t=e.__key,n=r.offset,s="element";if(G(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!P(e)){const i=e.getNextSibling();if(G(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Ya(r,e){if(P(e)){const t=e.getLastDescendant();P(t)||G(t)?Oi(r,t):Oi(r,e)}else Oi(r,e)}function dr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ut(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(s=>n.has(s))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new pi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,s=t[n-1];let i;if(G(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=st(s);i!==null&&n.push(i)}return ts()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function z(r){return r instanceof br}class br{constructor(e,t,n,s){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=s,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!z(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let l=i.getNode(),a=o.getNode();const u=i.offset,c=o.offset;if(P(l)){const f=l.getDescendantByIndex(u);l=f??l}if(P(a)){let f=a.getDescendantByIndex(c);f!==null&&f!==l&&a.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),a=f??a}let d;return d=l.is(a)?P(l)&&l.getChildrenSize()>0?[]:[l]:l.getNodesBetween(a),ts()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){dr(this.anchor,e.__key,t,"text"),dr(this.focus,n.__key,s,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const e=this.getNodes();if(e.length===0)return"";const t=e[0],n=e[e.length-1],s=this.anchor,i=this.focus,o=s.isBefore(i),[l,a]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const f=e[d];if(P(f)&&!f.isInline())c||(u+=`
91
- `),c=!f.isEmpty();else if(c=!1,G(f)){let p=f.getTextContent();f===t?f===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=l<a?p.slice(l,a):p.slice(a,l)):p=o?p.slice(l):p.slice(a):f===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!Ae(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=ze(),n=t.getEditorState()._selection,s=sc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(Yt(e.key,e.offset,e.type),Yt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
90
+ `?s.push(Mr()):l===" "?s.push(Zn()):l!==""&&s.push(rt(l))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=Ya(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:rt(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Kn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Ah={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Ah[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:ta(r.style,e),node:null}}function rt(r=""){return Qt(new sn(r))}function K(r){return r instanceof sn}function ta(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",l=n.includes("underline"),a=r.verticalAlign;return u=>(K(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),l&&!u.hasFormat("underline")&&u.toggleFormat("underline"),a!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),a!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Zn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){H(126)}setDetail(e){H(127)}setMode(e){H(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Zn(){return Qt(new Jn)}function Th(r){return r instanceof Jn}class Nh{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode();const s=this.offset,i=e.offset;if(P(t)){const o=t.getDescendantByIndex(s);t=o??t}if(P(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=ct(this.key);return e===null&&H(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,ts()||(hr()===i&&at(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Yt(r,e,t){return new Nh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(K(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!P(e)){const i=e.getNextSibling();if(K(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if(P(e)){const t=e.getLastDescendant();P(t)||K(t)?Ii(r,t):Ii(r,e)}else Ii(r,e)}function dr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ut(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(s=>n.has(s))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new pi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,s=t[n-1];let i;if(K(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=ct(s);i!==null&&n.push(i)}return ts()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function U(r){return r instanceof br}class br{constructor(e,t,n,s){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=s,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!U(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),i=s?t:n,o=s?n:t;let l=i.getNode(),a=o.getNode();const u=i.offset,c=o.offset;if(P(l)){const f=l.getDescendantByIndex(u);l=f??l}if(P(a)){let f=a.getDescendantByIndex(c);f!==null&&f!==l&&a.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),a=f??a}let d;return d=l.is(a)?P(l)&&l.getChildrenSize()>0?[]:[l]:l.getNodesBetween(a),ts()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){dr(this.anchor,e.__key,t,"text"),dr(this.focus,n.__key,s,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const e=this.getNodes();if(e.length===0)return"";const t=e[0],n=e[e.length-1],s=this.anchor,i=this.focus,o=s.isBefore(i),[l,a]=co(this);let u="",c=!0;for(let d=0;d<e.length;d++){const f=e[d];if(P(f)&&!f.isInline())c||(u+=`
91
+ `),c=!f.isEmpty();else if(c=!1,K(f)){let p=f.getTextContent();f===t?f===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=l<a?p.slice(l,a):p.slice(a,l)):p=o?p.slice(l):p.slice(a):f===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!Pe(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Ge(),n=t.getEditorState()._selection,s=ic(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(Yt(e.key,e.offset,e.type),Yt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
92
92
  `||o===`\r
93
- `?n.push(Rr()):o===" "?n.push(Zn()):n.push(Ke(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,l=t),o.type==="element"&&function(x,v,b,C){const S=x.getNode(),D=S.getChildAtIndex(x.offset),w=Ke(),y=lt(S)?He().append(w):w;w.setFormat(b),w.setStyle(C),D===null?S.append(y):D.insertBefore(y),x.is(v)&&v.set(w.__key,0,"text"),x.set(w.__key,0,"text")}(o,l,s,i);const a=o.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let f=c[0];G(f)||V(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(G(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=Ke(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?f.insertAfter(x):g.insertAfter(x)),x.select(0,0),f=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(G(x)&&!Cr(x)||(x=Ke(),x.setFormat(s),g.canInsertTextBefore()?f.insertBefore(x):g.insertBefore(x)),x.select(),f=x,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==p){const x=Ke(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||P(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),nc(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const C=Ke(e);return C.select(),void f.replace(C)}const x=f.getFormat(),v=f.getStyle();if(a!==u||x===s&&v===i){if(Ah(f)){const C=Ke(e);return C.setFormat(s),C.setStyle(i),C.select(),void f.replace(C)}}else{if(f.getTextContent()!==""){const C=Ke(e);if(C.setFormat(s),C.setStyle(i),C.select(),a===0)f.insertBefore(C,!1);else{const[S]=f.splitText(a);S.insertAfter(C,!1)}return void(C.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const b=u-a;f=f.spliceText(a,b,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=v))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),v=P(f)?f:f.getParentOrThrow();let b=P(m)?m:m.getParentOrThrow(),C=m;if(!v.is(b)&&b.isInline())do C=b,b=b.getParentOrThrow();while(b.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(G(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const k=Ke(m.getTextContent());m.replace(k),m=k}lt(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const k=m.getParentOrThrow();k.canBeEmpty()||k.getChildrenSize()!==1?m.remove():k.remove()}else x.add(m.__key);const S=b.getChildren(),D=new Set(c),w=v.is(b),y=v.isInline()&&f.getNextSibling()===null?v:f;for(let k=S.length-1;k>=0;k--){const N=S[k];if(N.is(f)||P(N)&&N.isParentOf(f))break;N.isAttached()&&(!D.has(N)||N.is(C)?w||y.insertAfter(N,!1):N.remove())}if(!w){let k=b,N=null;for(;k!==null;){const F=k.getChildren(),T=F.length;(T===0||F[T-1].is(N))&&(x.delete(k.__key),N=k),k=k.getParent()}}if(f.isToken())if(a===p)f.select();else{const k=Ke(e);k.select(),f.replace(k)}else f=f.spliceText(a,p-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let k=1;k<d;k++){const N=c[k],F=N.__key;x.has(F)||N.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),l=i.getNode();const a=pn(o,cr),u=pn(l,cr);G(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&G(l)&&l.isToken()&&(i.offset=l.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(l,d)||d.getKey()===o.getKey()||d.getKey()===l.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=Ke(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&G(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(G(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}G(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&G(o)?o.selectEnd():l.isAttached()&&G(l)&&l.selectStart(),P(a)&&P(u)&&a!==u&&(a.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void Ze(null);const n=this.getNodes(),s=[];for(const S of n)G(S)&&s.push(S);const i=S=>{n.forEach(D=>{if(tn(D)){const w=D.getFormatFlags(e,S);D.setTextFormat(w)}})},o=s.length;if(o===0)return this.toggleFormat(e),Ze(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(f=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let v=s[x];const b=d.type==="text"?d.offset:v.getTextContentSize();if(p.is(v)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,b),D=g===0?S[0]:S[1];D.setFormat(m),c.type==="text"&&c.set(D.__key,0,"text"),d.type==="text"&&d.set(D.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const C=v.getFormatFlags(e,m);b>0&&(b===v.getTextContentSize()||Cr(v)||([v]=v.splitText(b)),v.setFormat(C));for(let S=f+1;S<x;S++){const D=s[S],w=D.getFormatFlags(e,C);D.setFormat(w)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,b,"text"),this.format=m|C}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=te();return z(g)||V(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(P(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=Ii(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(P(g)||Ae(g))&&!g.isInline())){P(n)||V(211,t.constructor.name,t.getType());const g=Ii(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=He();let x=null;for(let v=0;v<g.length;v++){const b=g[v],C=Ar(b);if(C||Ae(b)&&b.isInline()||P(b)&&b.isInline()||G(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),C))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),l=i.getChildren(),a=!P(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;P(d=c)&&cr(d)&&!d.isEmpty()&&P(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(P(n)||V(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&V(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let b=m;const C=[m];for(;b!==v;)b.getNextSibling()||V(140),b=b.getNextSibling(),C.push(b);let S=g;for(const D of C)S=S.insertAfter(D)}(n,c));const f=pn(o,cr);a&&P(f)&&(a.canMergeWhenEmpty()||cr(u))&&(f.append(...a.getChildren()),a.remove()),P(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=P(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=He();return Pe().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Ii(this),t=pn(this.anchor.getNode(),cr);P(t)||V(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Rr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],l=e[n];const[a,u]=uo(this);if(t===0)return[];if(t===1){if(G(o)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,p=o.splitText(d,f),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(G(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(G(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if(Ae(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=el();return p.add(l.__key),void Gt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(G(f)){const p=f.__key,g=t?f.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=l.getParentOrThrow();let g,m;return P(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=ze(),u=Et(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!P(l)||l.isInline()||l.canBeEmpty()||Xo(c,a,d),function(f,p,g,m){f.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),p=this.anchor.getNode(),g=lt(p)?p:dh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let v=!1;for(let b=0;b<m.length;b++){const C=m[b];Tn(C,g)?x.push(C):v=!0}if(v&&x.length>0)if(t){const b=x[0];P(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];P(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(b){const C=b.focus,S=b.anchor,D=S.key,w=S.offset,y=S.type;dr(S,C.key,C.offset,C.type),dr(C,D,w,y),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&P(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if(P(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const i=this.focus,o=Pn(i,e);if(Ae(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&P(s)&&s.getChildrenSize()===0){s.remove();const l=el();l.add(o.__key),Gt(l)}else o.remove(),ze().dispatchCommand(Fo,void 0);return}if(!e&&P(o)&&P(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const a=i.offset,u=l.getTextContentSize();if(l.is(s)||e&&a!==u||!e&&a!==0)return void Xa(l,e,a)}else if(s!==null&&s.isSegmented()){const a=n.offset,u=s.getTextContentSize();if(s.is(l)||e&&a!==0||!e&&a!==u)return void Xa(s,e,a)}(function(a,u){const c=a.anchor,d=a.focus,f=c.getNode(),p=d.getNode();if(f===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,v=x?g:m,b=x?m:g,C=b-1;v!==C&&(Pu(f.getTextContent().slice(v,b))||(u?d.offset=C:c.offset=C))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&lt(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Ut(r){return r instanceof pi}function Qa(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Qa(t),Qa(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,l=0;for(let u=0;u<i;u++){const c=u===i-1;if(l=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(l=void 0);break}}const a=s.join("").trim();a===""?n.remove():(n.setTextContent(a),n.select(l,l))}function Ja(r,e,t,n){let s,i=e;if(r.nodeType===Kn){let o=!1;const l=r.childNodes,a=l.length,u=n._blockCursorElement;i===a&&(o=!0,i=a-1);let c=l[i],d=!1;if(c===u)c=l[i+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Vr(c),G(s))i=Ra(s,o);else{let f=Vr(r);if(f===null)return null;if(P(f)){const p=n.getElementByKey(f.getKey());p===null&&V(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),P(f)||V(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(P(m)&&function(x,v,b){const C=x.getParent();return b===null||C===null||!C.canBeEmpty()||C!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=P(m)?m:m.getParentOrThrow()),i=0}G(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(P(f)||V(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&Ae(f)&&Vr(r)===f?p:p+1,f=f.getParentOrThrow()}if(P(f))return Yt(f.__key,i,"element")}}else s=Vr(r);return G(s)?Yt(s.__key,i,"text"):null}function Za(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&P(o)&&o.isInline()){const l=o.getPreviousSibling();G(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else P(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):G(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&P(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&P(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();G(l)&&(r.key=l.__key,r.offset=0)}}}function nc(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);Za(r,n,s),Za(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=ze();if(i.isComposing()&&i._compositionKey!==r.key&&z(t)){const o=t.anchor,l=t.focus;dr(r,o.key,o.offset,o.type),dr(e,l.key,l.offset,l.type)}}}function sc(r,e,t,n,s,i){if(r===null||t===null||!Yn(s,r,t))return null;const o=Ja(r,e,z(i)?i.anchor:null,s);if(o===null)return null;const l=Ja(t,n,z(i)?i.focus:null,s);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=Vr(r),u=Vr(t);if(Ae(a)&&Ae(u))return null}return nc(o,l,i),[o,l]}function co(r){return P(r)&&!r.isInline()}function ic(r,e,t,n,s,i){const o=ar(),l=new br(Yt(r,e,s),Yt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Nh(){const r=Yt("root",0,"element"),e=Yt("root",0,"element");return new br(r,e,0,"")}function el(){return new pi(new Set)}function ta(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,l=o==="selectionchange",a=!Qi&&(l||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(z(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&z(r)&&!Yn(t,u,c))return r.clone();const p=sc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,z(r)?r.format:0,z(r)?r.style:"")}function te(){return ar()._selection}function es(){return ze()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),l=i.getNode();if(!e.is(o)&&!e.is(l))return;const a=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(a,c,"element"),i.set(a,c,"element"),tl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),f=u?s:i,p=f.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(a,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}tl(r)}function tl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!P(i))return;const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(G(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(P(i)){const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(G(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(P(o)){const l=o.getChildrenSize(),a=s>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(s);if(G(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Vs(r,e,t,n,s){let i=null,o=0,l=null;n!==null?(i=n.__key,G(n)?(o=n.getTextContentSize(),l="text"):P(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,G(s)?l="text":P(s)&&(l="element")),i!==null&&l!==null?r.set(i,o,l):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function rl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Bh(r,e,t,n,s,i,o){const l=n.anchorNode,a=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Vo(d))return;if(!z(e))return void(r!==null&&Yn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Os(t,g),v=Os(t,m),b=f.offset,C=p.offset,S=e.format,D=e.style,w=e.isCollapsed();let y=x,k=v,N=!1;if(f.type==="text"){y=js(x);const B=f.getNode();N=B.getFormat()!==S||B.getStyle()!==D}else z(r)&&r.anchor.type==="text"&&(N=!0);var F,T,M,L,E;if(p.type==="text"&&(k=js(v)),y!==null&&k!==null&&(w&&(r===null||N||z(r)&&(r.format!==S||r.style!==D))&&(F=S,T=D,M=b,L=g,E=performance.now(),Qu=[F,T,M,L,E]),u!==b||c!==C||l!==y||a!==k||n.type==="Range"&&w||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(y,b,k,C)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const B=e instanceof br&&e.anchor.type==="element"?y.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(B!==null){let R;if(B instanceof Text){const O=document.createRange();O.selectNode(B),R=O.getBoundingClientRect()}else R=B.getBoundingClientRect();(function(O,H,U){const Z=U.ownerDocument,q=Z.defaultView;if(q===null)return;let{top:K,bottom:$}=H,re=0,ae=0,le=U;for(;le!==null;){const ce=le===Z.body;if(ce)re=0,ae=di(O).innerHeight;else{const pe=le.getBoundingClientRect();re=pe.top,ae=pe.bottom}let ve=0;if(K<re?ve=-(re-K):$>ae&&(ve=$-ae),ve!==0)if(ce)q.scrollBy(0,ve);else{const pe=le.scrollTop;le.scrollTop+=ve;const Fe=le.scrollTop-pe;K-=Fe,$-=Fe}if(ce)break;le=Qn(le)}})(t,R,i)}}oo=!0}}function oc(r){let e=te()||es();e===null&&(e=Pe().selectEnd()),e.insertNodes(r)}function Ii(r){let e=r;r.isCollapsed()||e.removeText();const t=te();z(t)&&(e=t),z(e)||V(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Fh(s,i);return i}function Fh(r,e){const t=r.getParent();if(!t){const s=He();return Pe().append(s),s.select(),[Pe(),0]}if(G(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!P(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new br(Yt(r.__key,e,"element"),Yt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let Qe=null,Xe=null,mt=!1,zi=!1,ws=0;const nl={characterData:!0,childList:!0,subtree:!0};function ts(){return mt||Qe!==null&&Qe._readOnly}function pt(){mt&&V(13)}function ac(){ws>99&&V(14)}function ar(){return Qe===null&&V(195,lc()),Qe}function ze(){return Xe===null&&V(196,lc()),Xe}function lc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Rh(){return Xe}function sl(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&V(30,a),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let l=0;l<o&&(i[l](e),e.isAttached());l++);}function il(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function uc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function Mh(r){return ra(r,ze()._nodes)}function ra(r,e){const t=r.type,n=e.get(t);n===void 0&&V(17,t);const s=n.klass;r.type!==s.getType()&&V(18,s.name);const i=s.importJSON(r),o=r.children;if(P(i)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=ra(o[l],e);i.append(a)}return i}function ol(r,e,t){const n=Qe,s=mt,i=Xe;Qe=e,mt=!0,Xe=r;try{return t()}finally{Qe=n,mt=s,Xe=i}}function pr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,l=t._selection,a=r._dirtyType!==Nr,u=Qe,c=mt,d=Xe,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){Xe=r,Qe=t,mt=!1,r._updating=!0;try{const w=r._dirtyType,y=r._dirtyElements,k=r._dirtyLeaves;p.disconnect(),g=_h(i,t,r,w,y,k)}catch(w){if(w instanceof Error&&r._onError(w),zi)throw w;return pc(r,null,n,t),Nu(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,nl),r._updating=f,Qe=u,mt=c,Xe=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,b=r._updateTags,C=r._deferred;a&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(w,y){const k=w._decorators;let N=w._pendingDecorators||k;const F=y._nodeMap;let T;for(T in N)F.has(T)||(N===k&&(N=ju(w)),delete N[T])}(r,t);const S=s?null:Et(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){Xe=r,Qe=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const w=r._blockCursorElement;w!==null&&Xo(w,r,n),Bh(o,l,r,S,b,n)}fh(r,n,l),p!==null&&p.observe(n,nl)}finally{Xe=d,Qe=u}}g!==null&&function(w,y,k,N,F){const T=Array.from(w._listeners.mutation),M=T.length;for(let L=0;L<M;L++){const[E,B]=T[L],R=y.get(B);R!==void 0&&E(R,{dirtyLeaves:N,prevEditorState:F,updateTags:k})}}(r,g,b,m,i),z(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Fo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,Fn("decorator",r,!0,D)),function(w,y,k){const N=Fa(y),F=Fa(k);N!==F&&Fn("textcontent",w,!0,F)}(r,e||i,t),Fn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:b}),function(w,y){if(w._deferred=[],y.length!==0){const k=w._updating;w._updating=!0;try{for(let N=0;N<y.length;N++)y[N]()}finally{w._updating=k}}}(r,C),function(w){const y=w._updates;if(y.length!==0){const k=y.shift();if(k){const[N,F]=k;dc(w,N,F)}}}(r)}function Fn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function cc(r,e,t){if(r._updating===!1||Xe!==r){let s=!1;return r.update(()=>{s=cc(r,e,t)}),s}const n=Go(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const l=o[s];if(l!==void 0){const a=Array.from(l),u=a.length;for(let c=0;c<u;c++)if(a[c](t,r)===!0)return!0}}}return!1}function al(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let l;if(o!==void 0){if(l=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const a=r._pendingEditorState;a===null&&V(191),a._flushSync=!0}l&&r._deferred.push(l),uc(r,o.tag)}i()}}return n}function dc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,uc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let a=r._pendingEditorState,u=!1;(a===null||a._readOnly)&&(a=r._pendingEditorState=fc(a||l),u=!0),a._flushSync=o;const c=Qe,d=mt,f=Xe,p=r._updating;Qe=a,mt=!1,r._updating=!0,Xe=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(v){const b=v.getEditorState()._selection,C=Et(v._window);return z(b)||b==null?ta(b,C,v,null):b.clone()}(r));const m=r._compositionKey;e(),i=al(r,i),function(v,b){const C=b.getEditorState()._selection,S=v._selection;if(z(S)){const D=S.anchor,w=S.focus;let y;if(D.type==="text"&&(y=D.getNode(),y.selectionTransform(C,S)),w.type==="text"){const k=w.getNode();y!==k&&k.selectionTransform(C,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(v,b){const C=b._dirtyLeaves,S=v._nodeMap;for(const D of C){const w=S.get(D);G(w)&&w.isAttached()&&w.isSimpleText()&&!w.isUnmergeable()&&Na(w)}}(a,r):function(v,b){const C=b._dirtyLeaves,S=b._dirtyElements,D=v._nodeMap,w=hr(),y=new Map;let k=C,N=k.size,F=S,T=F.size;for(;N>0||T>0;){if(N>0){b._dirtyLeaves=new Set;for(const M of k){const L=D.get(M);G(L)&&L.isAttached()&&L.isSimpleText()&&!L.isUnmergeable()&&Na(L),L!==void 0&&il(L,w)&&sl(b,L,y),C.add(M)}if(k=b._dirtyLeaves,N=k.size,N>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const M of F){const L=M[0],E=M[1];if(L!=="root"&&!E)continue;const B=D.get(L);B!==void 0&&il(B,w)&&sl(b,B,y),S.set(L,E)}k=b._dirtyLeaves,N=k.size,F=b._dirtyElements,T=F.size,ws++}b._dirtyLeaves=C,b._dirtyElements=S}(a,r),al(r),function(v,b,C,S){const D=v._nodeMap,w=b._nodeMap,y=[];for(const[k]of S){const N=w.get(k);N!==void 0&&(N.isAttached()||(P(N)&&$u(N,k,D,w,y,S),D.has(k)||S.delete(k),y.push(k)))}for(const k of y)w.delete(k);for(const k of C){const N=w.get(k);N===void 0||N.isAttached()||(D.has(k)||C.delete(k),w.delete(k))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(z(x)){const v=a._nodeMap,b=x.anchor.key,C=x.focus.key;v.get(b)!==void 0&&v.get(C)!==void 0||V(19)}else Ut(x)&&x._nodes.size===0&&(a._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{Qe=c,mt=d,Xe=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const v=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(v))return!0}else if(v!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&oh(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function bt(r,e,t){r._updating?r._updates.push([e,t]):dc(r,e,t)}class Rn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Rn(this.element,e,this.after)}withAfter(e){return new Rn(this.element,this.before,e)}withElement(e){return new Rn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&V(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&V(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&V(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Gn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ll(t,n);i.push(s);const o=ll(t,this.element);let l=e.getIndexWithinParent();for(let a=0;a<o.length;a++){const u=i[a],c=o[a];if(u===void 0||u<c)break;if(u>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function ll(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&V(225),t.reverse()}class lr extends hi{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return Qf[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=ze()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(G(t)&&e.push(t),P(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;P(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;P(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const i=t[n-1];return P(i)&&i.getLastDescendant()||i||null}const s=t[e];return P(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:st(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&V(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:st(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&V(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContent(),P(i)&&s!==n-1&&!i.isInline()&&(e+=sr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),P(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Da[e];return!!(this.getFormat()&t)}return!1}select(e,t){pt();const n=te();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(G(a)||P(a))return a.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const a=this.getLastChild();if(G(a)||P(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return z(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ic(l,s,l,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Da[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||V(226,String(e),String(t),String(i));const l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&V(100);const x=g.getNextSibling(),v=g.__key;Dr(g.getWritable()),u.push(v),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===l&&f--,Dr(x);const v=m.__key;if(p===null)o.__first=v,x.__prev=null;else{const b=p.getWritable();b.__next=v,x.__prev=b.__key}m.__key===l&&V(76),x.__parent=l,a.push(v),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=f,u.length){const g=te();if(z(g)){const m=new Set(u),x=new Set(a),{anchor:v,focus:b}=g;ul(v,m,x)&&Vs(v,v.getNode(),this,d,c),ul(b,m,x)&&Vs(b,b.getNode(),this,d,c),f!==0||this.canBeEmpty()||Kt(this)||this.remove()}}return o}getDOMSlot(e){return new Rn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function P(r){return r instanceof lr}function ul(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class na extends hi{constructor(e){super(e)}decorate(e,t){V(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ae(r){return r instanceof na}class rs extends lr{static getType(){return"root"}static clone(){return new rs}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){V(51)}getTextContent(){const e=this.__cachedText;return!ts()&&ze()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){V(52)}replace(e){V(53)}insertBefore(e){V(54)}insertAfter(e){V(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];P(n)||Ae(n)||V(56)}return super.append(...e)}static importJSON(e){const t=Pe();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function lt(r){return r instanceof rs}function fc(r){return new gi(new Map(r._nodeMap))}function sa(){return new gi(new Map([["root",new rs]]))}function hc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&V(130,t.name),P(r)){const n=e.children;Array.isArray(n)||V(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=hc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return ol(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return ol(null,this,()=>({root:hc(Pe())}))}}class ia extends lr{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends lr{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:jh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=He();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=He();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||G(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function jh(r){const e=He();return r.style&&(e.setFormat(r.style.textAlign),Zo(r,e)),{node:e}}function He(){return Qt(new on)}function tn(r){return r instanceof on}const Ee=0,Hr=1,Lh=4;function pc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=sa(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Ph(r){const e=r||{},t=Rh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=sa(),l=e.namespace||(s!==null?s._config.namespace:Ou()),a=e.editorState,u=[rs,sn,Xn,Jn,on,ia,...e.nodes||[]],{onError:c,html:d}=e,f=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],v=null,b=null;if(typeof x!="function"){const w=x;x=w.replace,v=w.with,b=w.withKlass||null}const C=x.getType(),S=x.transform(),D=new Set;S!==null&&D.add(S),p.set(C,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:v,replaceWithKlass:b,transforms:D})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const v=new Map,b=new Set,C=S=>{Object.keys(S).forEach(D=>{let w=v.get(D);w===void 0&&(w=[],v.set(D,w)),w.push(S[D])})};return m.forEach(S=>{const D=S.klass.importDOM;if(D==null||b.has(D))return;b.add(D);const w=D.call(S.klass);w!==null&&C(w)}),x&&C(x),v}(p,d?d.import:void 0),f);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ou(),this._onError=i,this._htmlConversions=o,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&V(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&V(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&V(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=mh(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const a=this.registerNodeTransformToKlass(i,t);s.push(a)}var o,l;return o=this,l=e.getType(),bt(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void Pe().markDirty();const u=a._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(a=>a.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return J(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,pc(this,t,e,s),t!==null&&(this._config.disableEvents||vh(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(l){const a=l.ownerDocument;return a&&a.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,Nu(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(l,a){const u=l.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",ec),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=Zu(l);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Wa(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Va(x))return;Wa(x);const v=a.isEditable();switch(p){case"cut":return v&&J(a,jo,x);case"copy":return J(a,ii,x);case"paste":return v&&J(a,si,x);case"dragstart":return v&&J(a,wu,x);case"dragover":return v&&J(a,Cu,x);case"dragend":return v&&J(a,Rf,x);case"focus":return v&&J(a,Lf,x);case"blur":return v&&J(a,Pf,x);case"drop":return v&&J(a,vu,x)}};l.addEventListener(p,m),d.push(()=>{l.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;Fn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&V(38);let n=e;n._readOnly&&(n=fc(e),n._selection=e._selection?e._selection.clone():null),Tu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=sa(),l=Qe,a=mt,u=Xe,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,Qe=o,mt=!1,Xe=s;try{const g=s._nodes;ra(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=f,s._dirtyType=p,Qe=l,mt=a,Xe=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return pr(this),this.getEditorState().read(e,{editor:this})}update(e,t){bt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),bt(this,()=>{const s=te(),i=Pe();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Et(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Fn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const gc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Oh=gc?_.useLayoutEffect:_.useEffect,fs={tag:"history-merge"};function Ih({initialConfig:r,children:e}){const t=_.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=Cf(null,n),c=Ph({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const p=Pe();if(p.isEmpty()){const g=He();p.append(g);const m=gc?document.activeElement:null;(te()!==null||m!==null&&m===d.getRootElement())&&g.select()}},fs);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,fs);break}case"object":d.setEditorState(f,fs);break;case"function":d.update(()=>{Pe().isEmpty()&&f(d)},fs)}}}(c,l),[c,u]},[]);return Oh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(fu.Provider,{value:t,children:e})}const zh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?_.useLayoutEffect:_.useEffect;function $h(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function qh(){return function(r){const[e]=Lt(),t=_.useMemo(()=>r(e),[e,r]),[n,s]=_.useState(()=>t.initialValueFn()),i=_.useRef(n);return zh(()=>{const{initialValueFn:o,subscribe:l}=t,a=o();return i.current!==a&&(i.current=a,s(a)),l(u=>{i.current=u,s(u)})},[t,r]),n}($h)}function Uh(){return Pe().getTextContent()}function Wh(r,e=!0){if(r)return!1;let t=Uh();return e&&(t=t.trim()),t===""}function Vh(r){if(!Wh(r,!1))return!1;const e=Pe().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Ae(s))return!1;if(P(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let l=0;l<o;l++){const a=i[n];if(!G(a))return!1}}}return!0}function mc(r){return()=>Vh(r)}function Hh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Hh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Gh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Kh=Gh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const Yh=new Map;function Qh(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function yc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),l=s.getNode(),a=e.is(o),u=e.is(l);if(a||u){const[c,d]=uo(r),f=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return f?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function Xh(r){const e=r.getStyle(),t=Qh(e);Yh.set(e,t)}function Jh(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),l=Pe(),a=l.getFirstChild();return void(a?a.replace(o,!0):l.append(o))}const s=r.getNodes(),i=n!==null&&function(o,l){let a=o;for(;a!==null&&a.getParent()!==null&&!l(a);)a=a.getParentOrThrow();return l(a)?a:null}(n.getNode(),fl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!fl(l))continue;P(l)||Kh(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function cl(r,e){const t=Pn(r.focus,e);return Ae(t)&&!t.isIsolated()||P(t)&&!t.isInline()&&!t.canBeEmpty()}function Zh(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ep(r){const e=r.anchor.getNode();return(lt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function dl(r,e,t){const n=ep(r);Zh(r,e,t?!n:n,"character")}function fl(r){if(Ae(r)||!P(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||G(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function tp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var rp=tp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const xc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,np=xc&&"documentMode"in document?document.documentMode:null;!(!xc||!("InputEvent"in window)||np)&&"getTargetRanges"in new window.InputEvent("input");function bc(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function ns(r,...e){const t=bc(...e);t.length>0&&r.classList.add(...t)}function _c(r,...e){const t=bc(...e);t.length>0&&r.classList.remove(...t)}function sp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function ip(r){const e=yi(r,t=>P(t)&&!t.isInline());return P(e)||rp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Pe()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function gr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function op(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const l=o.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[u,c,d,f,p,g]=a;r.update(()=>{const m=te();if(z(m)){const x=m.anchor;let v=x.getNode(),b=0,C=0;if(G(v)&&u>=0&&c>=0&&(b=u,C=u+c,m.setTextNodeRange(v,b,v,C)),b===C&&d===""||(m.insertRawText(d),v=x.getNode()),G(v)){b=f,C=f+p;const S=v.getTextContentSize();b=b>S?S:b,C=C>S?S:C,m.setTextNodeRange(v,b,v,C)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function vc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Sc.has(o.nodeName)){const l=Ec(o,r,s,!1);l!==null&&(n=n.concat(l))}}return function(i){for(const o of i)o.getNextSibling()instanceof ia&&o.insertAfter(Rr());for(const o of i){const l=o.getChildren();for(const a of l)o.insertBefore(a);o.remove()}}(s),n}function wc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=Pe().getChildren();for(let s=0;s<n.length;s++)Cc(r,n[s],t,e);return t.innerHTML}function Cc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=P(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=G(p)&&n!==null?yc(n,p):p,o=p}const l=P(o)?o.getChildren():[],a=r._nodes.get(o.getType());let u;u=a&&a.exportDOM!==void 0?a.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=Cc(r,g,f,n);!s&&P(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Ia(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(Ia(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Sc=new Set(["STYLE","SCRIPT"]);function Ec(r,e,t,n,s=new Map,i){let o=[];if(Sc.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let b=null;if(v!==void 0)for(const C of v){const S=C(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=a?a(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,m]of s)if(l=m(l,i),!l)break;l&&o.push(...Array.isArray(g)?g:[l])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(l==null||!Kt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)f.push(...Ec(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),Is(r)&&(f=ap(r,f,p?()=>{const g=new ia;return t.push(g),g}:He)),l==null?f.length>0?o=o.concat(f):Is(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Xi(g.nextSibling)&&Xi(g.previousSibling)}(r)&&(o=o.concat(Rr())):P(l)&&l.append(...f),o}function ap(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const l=e[o];if(co(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(i.push(l),o===e.length-1||o<e.length-1&&co(e[o+1])){const a=t();a.setFormat(n),a.append(...i),s.push(a),i=[]}}return s}function lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Hs=lp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function up(r,e=te()){return e==null&&Hs(166),z(e)&&e.isCollapsed()||e.getNodes().length===0?"":wc(r,e)}function cp(r,e=te()){return e==null&&Hs(166),z(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(dp(r,e))}function hl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return pl(t,fp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:a=>a}).createHTML(l):l}(s),"text/html");return pl(t,vc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(z(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=te();if(z(a)){const u=o[l];u===`
93
+ `?n.push(Mr()):o===" "?n.push(Zn()):n.push(rt(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,l=t),o.type==="element"&&function(x,w,y,C){const S=x.getNode(),D=S.getChildAtIndex(x.offset),_=rt(),b=ht(S)?et().append(_):_;_.setFormat(y),_.setStyle(C),D===null?S.append(b):D.insertBefore(b),x.is(w)&&w.set(_.__key,0,"text"),x.set(_.__key,0,"text")}(o,l,s,i);const a=o.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let f=c[0];K(f)||H(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(K(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=rt(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?f.insertAfter(x):g.insertAfter(x)),x.select(0,0),f=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(K(x)&&!Cr(x)||(x=rt(),x.setFormat(s),g.canInsertTextBefore()?f.insertBefore(x):g.insertBefore(x)),x.select(),f=x,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==p){const x=rt(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||P(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),sc(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const C=rt(e);return C.select(),void f.replace(C)}const x=f.getFormat(),w=f.getStyle();if(a!==u||x===s&&w===i){if(Th(f)){const C=rt(e);return C.setFormat(s),C.setStyle(i),C.select(),void f.replace(C)}}else{if(f.getTextContent()!==""){const C=rt(e);if(C.setFormat(s),C.setStyle(i),C.select(),a===0)f.insertBefore(C,!1);else{const[S]=f.splitText(a);S.insertAfter(C,!1)}return void(C.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const y=u-a;f=f.spliceText(a,y,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=w))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),w=P(f)?f:f.getParentOrThrow();let y=P(m)?m:m.getParentOrThrow(),C=m;if(!w.is(y)&&y.isInline())do C=y,y=y.getParentOrThrow();while(y.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(K(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const E=rt(m.getTextContent());m.replace(E),m=E}ht(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const E=m.getParentOrThrow();E.canBeEmpty()||E.getChildrenSize()!==1?m.remove():E.remove()}else x.add(m.__key);const S=y.getChildren(),D=new Set(c),_=w.is(y),b=w.isInline()&&f.getNextSibling()===null?w:f;for(let E=S.length-1;E>=0;E--){const N=S[E];if(N.is(f)||P(N)&&N.isParentOf(f))break;N.isAttached()&&(!D.has(N)||N.is(C)?_||b.insertAfter(N,!1):N.remove())}if(!_){let E=y,N=null;for(;E!==null;){const R=E.getChildren(),T=R.length;(T===0||R[T-1].is(N))&&(x.delete(E.__key),N=E),E=E.getParent()}}if(f.isToken())if(a===p)f.select();else{const E=rt(e);E.select(),f.replace(E)}else f=f.spliceText(a,p-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let E=1;E<d;E++){const N=c[E],R=N.__key;x.has(R)||N.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),l=i.getNode();const a=pn(o,cr),u=pn(l,cr);K(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&K(l)&&l.isToken()&&(i.offset=l.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(l,d)||d.getKey()===o.getKey()||d.getKey()===l.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=rt(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&K(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(K(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}K(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&K(o)?o.selectEnd():l.isAttached()&&K(l)&&l.selectStart(),P(a)&&P(u)&&a!==u&&(a.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void at(null);const n=this.getNodes(),s=[];for(const S of n)K(S)&&s.push(S);const i=S=>{n.forEach(D=>{if(tn(D)){const _=D.getFormatFlags(e,S);D.setTextFormat(_)}})},o=s.length;if(o===0)return this.toggleFormat(e),at(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(f=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let w=s[x];const y=d.type==="text"?d.offset:w.getTextContentSize();if(p.is(w)){if(g===y)return;if(Cr(p)||g===0&&y===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,y),D=g===0?S[0]:S[1];D.setFormat(m),c.type==="text"&&c.set(D.__key,0,"text"),d.type==="text"&&d.set(D.__key,y-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const C=w.getFormatFlags(e,m);y>0&&(y===w.getTextContentSize()||Cr(w)||([w]=w.splitText(y)),w.setFormat(C));for(let S=f+1;S<x;S++){const D=s[S],_=D.getFormatFlags(e,C);D.setFormat(_)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(w.__key,y,"text"),this.format=m|C}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=se();return U(g)||H(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(P(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=Oi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(P(g)||Pe(g))&&!g.isInline())){P(n)||H(211,t.constructor.name,t.getType());const g=Oi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=et();let x=null;for(let w=0;w<g.length;w++){const y=g[w],C=Ar(y);if(C||Pe(y)&&y.isInline()||P(y)&&y.isInline()||K(y)||y.isParentRequired()){if(x===null&&(x=y.createParentElementNode(),m.append(x),C))continue;x!==null&&x.append(y)}else m.append(y),x=null}return m}(e),o=i.getLastDescendant(),l=i.getChildren(),a=!P(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;P(d=c)&&cr(d)&&!d.isEmpty()&&P(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(P(n)||H(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&H(212,t.constructor.name,t.getType()),function(g,m,x){const w=m.getParentOrThrow().getLastChild();let y=m;const C=[m];for(;y!==w;)y.getNextSibling()||H(140),y=y.getNextSibling(),C.push(y);let S=g;for(const D of C)S=S.insertAfter(D)}(n,c));const f=pn(o,cr);a&&P(f)&&(a.canMergeWhenEmpty()||cr(u))&&(f.append(...a.getChildren()),a.remove()),P(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=P(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=et();return We().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Oi(this),t=pn(this.anchor.getNode(),cr);P(t)||H(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,i=this.focus;let o=e[0],l=e[n];const[a,u]=co(this);if(t===0)return[];if(t===1){if(K(o)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,p=o.splitText(d,f),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(K(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(K(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if(Pe(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=tl();return p.add(l.__key),void Gt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(K(f)){const p=f.__key,g=t?f.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=l.getParentOrThrow();let g,m;return P(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=Ge(),u=Dt(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!P(l)||l.isInline()||l.canBeEmpty()||Jo(c,a,d),function(f,p,g,m){f.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),p=this.anchor.getNode(),g=ht(p)?p:fh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let w=!1;for(let y=0;y<m.length;y++){const C=m[y];Tn(C,g)?x.push(C):w=!0}if(w&&x.length>0)if(t){const y=x[0];P(y)?y.selectStart():y.getParentOrThrow().selectStart()}else{const y=x[x.length-1];P(y)?y.selectEnd():y.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(y){const C=y.focus,S=y.anchor,D=S.key,_=S.offset,b=S.type;dr(S,C.key,C.offset,C.type),dr(C,D,_,b),y._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&P(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if(P(i)&&i.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const i=this.focus,o=Pn(i,e);if(Pe(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&P(s)&&s.getChildrenSize()===0){s.remove();const l=tl();l.add(o.__key),Gt(l)}else o.remove(),Ge().dispatchCommand(Mo,void 0);return}if(!e&&P(o)&&P(s)&&s.isEmpty())return s.remove(),void o.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const a=i.offset,u=l.getTextContentSize();if(l.is(s)||e&&a!==u||!e&&a!==0)return void Ja(l,e,a)}else if(s!==null&&s.isSegmented()){const a=n.offset,u=s.getTextContentSize();if(s.is(l)||e&&a!==0||!e&&a!==u)return void Ja(s,e,a)}(function(a,u){const c=a.anchor,d=a.focus,f=c.getNode(),p=d.getNode();if(f===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,w=x?g:m,y=x?m:g,C=y-1;w!==C&&(Iu(f.getTextContent().slice(w,y))||(u?d.offset=C:c.offset=C))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&ht(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Ut(r){return r instanceof pi}function Xa(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function co(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[Xa(t),Xa(n)]}function Ja(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,l=0;for(let u=0;u<i;u++){const c=u===i-1;if(l=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(l=void 0);break}}const a=s.join("").trim();a===""?n.remove():(n.setTextContent(a),n.select(l,l))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Kn){let o=!1;const l=r.childNodes,a=l.length,u=n._blockCursorElement;i===a&&(o=!0,i=a-1);let c=l[i],d=!1;if(c===u)c=l[i+1],d=!0;else if(u!==null){const f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Vr(c),K(s))i=Fa(s,o);else{let f=Vr(r);if(f===null)return null;if(P(f)){const p=n.getElementByKey(f.getKey());p===null&&H(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),P(f)||H(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(P(m)&&function(x,w,y){const C=x.getParent();return y===null||C===null||!C.canBeEmpty()||C!==y.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=P(m)?m:m.getParentOrThrow()),i=0}K(m)?(s=m,f=null,i=Fa(m,o)):m!==f&&o&&!d&&(P(f)||H(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&Pe(f)&&Vr(r)===f?p:p+1,f=f.getParentOrThrow()}if(P(f))return Yt(f.__key,i,"element")}}else s=Vr(r);return K(s)?Yt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&P(o)&&o.isInline()){const l=o.getPreviousSibling();K(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else P(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):K(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&P(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&P(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();K(l)&&(r.key=l.__key,r.offset=0)}}}function sc(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Ge();if(i.isComposing()&&i._compositionKey!==r.key&&U(t)){const o=t.anchor,l=t.focus;dr(r,o.key,o.offset,o.type),dr(e,l.key,l.offset,l.type)}}}function ic(r,e,t,n,s,i){if(r===null||t===null||!Yn(s,r,t))return null;const o=Za(r,e,U(i)?i.anchor:null,s);if(o===null)return null;const l=Za(t,n,U(i)?i.focus:null,s);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=Vr(r),u=Vr(t);if(Pe(a)&&Pe(u))return null}return sc(o,l,i),[o,l]}function fo(r){return P(r)&&!r.isInline()}function oc(r,e,t,n,s,i){const o=ar(),l=new br(Yt(r,e,s),Yt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Bh(){const r=Yt("root",0,"element"),e=Yt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ra(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,l=o==="selectionchange",a=!Xi&&(l||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(U(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&U(r)&&!Yn(t,u,c))return r.clone();const p=ic(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,U(r)?r.format:0,U(r)?r.style:"")}function se(){return ar()._selection}function es(){return Ge()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),l=i.getNode();if(!e.is(o)&&!e.is(l))return;const a=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(a,c,"element"),i.set(a,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),f=u?s:i,p=f.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(a,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!P(i))return;const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(K(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(P(i)){const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(K(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(P(o)){const l=o.getChildrenSize(),a=s>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(s);if(K(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Vs(r,e,t,n,s){let i=null,o=0,l=null;n!==null?(i=n.__key,K(n)?(o=n.getTextContentSize(),l="text"):P(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,K(s)?l="text":P(s)&&(l="element")),i!==null&&l!==null?r.set(i,o,l):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Rh(r,e,t,n,s,i,o){const l=n.anchorNode,a=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Ho(d))return;if(!U(e))return void(r!==null&&Yn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),w=Is(t,m),y=f.offset,C=p.offset,S=e.format,D=e.style,_=e.isCollapsed();let b=x,E=w,N=!1;if(f.type==="text"){b=js(x);const B=f.getNode();N=B.getFormat()!==S||B.getStyle()!==D}else U(r)&&r.anchor.type==="text"&&(N=!0);var R,T,F,L,k;if(p.type==="text"&&(E=js(w)),b!==null&&E!==null&&(_&&(r===null||N||U(r)&&(r.format!==S||r.style!==D))&&(R=S,T=D,F=y,L=g,k=performance.now(),Xu=[R,T,F,L,k]),u!==y||c!==C||l!==b||a!==E||n.type==="Range"&&_||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(b,y,E,C)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const B=e instanceof br&&e.anchor.type==="element"?b.childNodes[y]||null:n.rangeCount>0?n.getRangeAt(0):null;if(B!==null){let M;if(B instanceof Text){const I=document.createRange();I.selectNode(B),M=I.getBoundingClientRect()}else M=B.getBoundingClientRect();(function(I,W,$){const ee=$.ownerDocument,q=ee.defaultView;if(q===null)return;let{top:Y,bottom:z}=W,ie=0,ce=0,de=$;for(;de!==null;){const me=de===ee.body;if(me)ie=0,ce=di(I).innerHeight;else{const oe=de.getBoundingClientRect();ie=oe.top,ce=oe.bottom}let X=0;if(Y<ie?X=-(ie-Y):z>ce&&(X=z-ce),X!==0)if(me)q.scrollBy(0,X);else{const oe=de.scrollTop;de.scrollTop+=X;const G=de.scrollTop-oe;Y-=G,z-=G}if(me)break;de=Qn(de)}})(t,M,i)}}ao=!0}}function ac(r){let e=se()||es();e===null&&(e=We().selectEnd()),e.insertNodes(r)}function Oi(r){let e=r;r.isCollapsed()||e.removeText();const t=se();U(t)&&(e=t),U(e)||H(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Mh(s,i);return i}function Mh(r,e){const t=r.getParent();if(!t){const s=et();return We().append(s),s.select(),[We(),0]}if(K(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!P(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new br(Yt(r.__key,e,"element"),Yt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let it=null,ot=null,bt=!1,zi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function ts(){return bt||it!==null&&it._readOnly}function yt(){bt&&H(13)}function lc(){ws>99&&H(14)}function ar(){return it===null&&H(195,uc()),it}function Ge(){return ot===null&&H(196,uc()),ot}function uc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Go(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Fh(){return ot}function il(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&H(30,a),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let l=0;l<o&&(i[l](e),e.isAttached());l++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function cc(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function jh(r){return na(r,Ge()._nodes)}function na(r,e){const t=r.type,n=e.get(t);n===void 0&&H(17,t);const s=n.klass;r.type!==s.getType()&&H(18,s.name);const i=s.importJSON(r),o=r.children;if(P(i)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=na(o[l],e);i.append(a)}return i}function al(r,e,t){const n=it,s=bt,i=ot;it=e,bt=!0,ot=r;try{return t()}finally{it=n,bt=s,ot=i}}function pr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,l=t._selection,a=r._dirtyType!==Nr,u=it,c=bt,d=ot,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){ot=r,it=t,bt=!1,r._updating=!0;try{const _=r._dirtyType,b=r._dirtyElements,E=r._dirtyLeaves;p.disconnect(),g=_h(i,t,r,_,b,E)}catch(_){if(_ instanceof Error&&r._onError(_),zi)throw _;return gc(r,null,n,t),Bu(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,sl),r._updating=f,it=u,bt=c,ot=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,w=r._normalizedNodes,y=r._updateTags,C=r._deferred;a&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(_,b){const E=_._decorators;let N=_._pendingDecorators||E;const R=b._nodeMap;let T;for(T in N)R.has(T)||(N===E&&(N=Lu(_)),delete N[T])}(r,t);const S=s?null:Dt(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){ot=r,it=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const _=r._blockCursorElement;_!==null&&Jo(_,r,n),Rh(o,l,r,S,y,n)}hh(r,n,l),p!==null&&p.observe(n,sl)}finally{ot=d,it=u}}g!==null&&function(_,b,E,N,R){const T=Array.from(_._listeners.mutation),F=T.length;for(let L=0;L<F;L++){const[k,B]=T[L],M=b.get(B);M!==void 0&&k(M,{dirtyLeaves:N,prevEditorState:R,updateTags:E})}}(r,g,y,m,i),U(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Mo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,Rn("decorator",r,!0,D)),function(_,b,E){const N=Ma(b),R=Ma(E);N!==R&&Rn("textcontent",_,!0,R)}(r,e||i,t),Rn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:w,prevEditorState:e||i,tags:y}),function(_,b){if(_._deferred=[],b.length!==0){const E=_._updating;_._updating=!0;try{for(let N=0;N<b.length;N++)b[N]()}finally{_._updating=E}}}(r,C),function(_){const b=_._updates;if(b.length!==0){const E=b.shift();if(E){const[N,R]=E;fc(_,N,R)}}}(r)}function Rn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function dc(r,e,t){if(r._updating===!1||ot!==r){let s=!1;return r.update(()=>{s=dc(r,e,t)}),s}const n=Ko(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const l=o[s];if(l!==void 0){const a=Array.from(l),u=a.length;for(let c=0;c<u;c++)if(a[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let l;if(o!==void 0){if(l=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const a=r._pendingEditorState;a===null&&H(191),a._flushSync=!0}l&&r._deferred.push(l),cc(r,o.tag)}i()}}return n}function fc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,cc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let a=r._pendingEditorState,u=!1;(a===null||a._readOnly)&&(a=r._pendingEditorState=hc(a||l),u=!0),a._flushSync=o;const c=it,d=bt,f=ot,p=r._updating;it=a,bt=!1,r._updating=!0,ot=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(w){const y=w.getEditorState()._selection,C=Dt(w._window);return U(y)||y==null?ra(y,C,w,null):y.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(w,y){const C=y.getEditorState()._selection,S=w._selection;if(U(S)){const D=S.anchor,_=S.focus;let b;if(D.type==="text"&&(b=D.getNode(),b.selectionTransform(C,S)),_.type==="text"){const E=_.getNode();b!==E&&E.selectionTransform(C,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(w,y){const C=y._dirtyLeaves,S=w._nodeMap;for(const D of C){const _=S.get(D);K(_)&&_.isAttached()&&_.isSimpleText()&&!_.isUnmergeable()&&Ba(_)}}(a,r):function(w,y){const C=y._dirtyLeaves,S=y._dirtyElements,D=w._nodeMap,_=hr(),b=new Map;let E=C,N=E.size,R=S,T=R.size;for(;N>0||T>0;){if(N>0){y._dirtyLeaves=new Set;for(const F of E){const L=D.get(F);K(L)&&L.isAttached()&&L.isSimpleText()&&!L.isUnmergeable()&&Ba(L),L!==void 0&&ol(L,_)&&il(y,L,b),C.add(F)}if(E=y._dirtyLeaves,N=E.size,N>0){ws++;continue}}y._dirtyLeaves=new Set,y._dirtyElements=new Map;for(const F of R){const L=F[0],k=F[1];if(L!=="root"&&!k)continue;const B=D.get(L);B!==void 0&&ol(B,_)&&il(y,B,b),S.set(L,k)}E=y._dirtyLeaves,N=E.size,R=y._dirtyElements,T=R.size,ws++}y._dirtyLeaves=C,y._dirtyElements=S}(a,r),ll(r),function(w,y,C,S){const D=w._nodeMap,_=y._nodeMap,b=[];for(const[E]of S){const N=_.get(E);N!==void 0&&(N.isAttached()||(P(N)&&qu(N,E,D,_,b,S),D.has(E)||S.delete(E),b.push(E)))}for(const E of b)_.delete(E);for(const E of C){const N=_.get(E);N===void 0||N.isAttached()||(D.has(E)||C.delete(E),_.delete(E))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(U(x)){const w=a._nodeMap,y=x.anchor.key,C=x.focus.key;w.get(y)!==void 0&&w.get(C)!==void 0||H(19)}else Ut(x)&&x._nodes.size===0&&(a._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{it=c,bt=d,ot=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const w=x.getEditorState()._selection,y=m._selection;if(y!==null){if(y.dirty||!y.is(w))return!0}else if(w!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&ah(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function _t(r,e,t){r._updating?r._updates.push([e,t]):fc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&H(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&H(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&H(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Gn||oi);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let l=e.getIndexWithinParent();for(let a=0;a<o.length;a++){const u=i[a],c=o[a];if(u===void 0||u<c)break;if(u>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&H(225),t.reverse()}class lr extends hi{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return Xf[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=Ge()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(K(t)&&e.push(t),P(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;P(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;P(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const i=t[n-1];return P(i)&&i.getLastDescendant()||i||null}const s=t[e];return P(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:ct(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&H(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ct(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&H(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContent(),P(i)&&s!==n-1&&!i.isInline()&&(e+=sr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),P(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){yt();const n=se();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(K(a)||P(a))return a.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const a=this.getLastChild();if(K(a)||P(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return U(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):oc(l,s,l,i,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?Aa[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||H(226,String(e),String(t),String(i));const l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&H(100);const x=g.getNextSibling(),w=g.__key;Dr(g.getWritable()),u.push(w),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===l&&f--,Dr(x);const w=m.__key;if(p===null)o.__first=w,x.__prev=null;else{const y=p.getWritable();y.__next=w,x.__prev=y.__key}m.__key===l&&H(76),x.__parent=l,a.push(w),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=f,u.length){const g=se();if(U(g)){const m=new Set(u),x=new Set(a),{anchor:w,focus:y}=g;cl(w,m,x)&&Vs(w,w.getNode(),this,d,c),cl(y,m,x)&&Vs(y,y.getNode(),this,d,c),f!==0||this.canBeEmpty()||Kt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function P(r){return r instanceof lr}function cl(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class sa extends hi{constructor(e){super(e)}decorate(e,t){H(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Pe(r){return r instanceof sa}class rs extends lr{static getType(){return"root"}static clone(){return new rs}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){H(51)}getTextContent(){const e=this.__cachedText;return!ts()&&Ge()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){H(52)}replace(e){H(53)}insertBefore(e){H(54)}insertAfter(e){H(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];P(n)||Pe(n)||H(56)}return super.append(...e)}static importJSON(e){const t=We();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function ht(r){return r instanceof rs}function hc(r){return new gi(new Map(r._nodeMap))}function ia(){return new gi(new Map([["root",new rs]]))}function pc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&H(130,t.name),P(r)){const n=e.children;Array.isArray(n)||H(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=pc(s[i]);n.push(o)}}return e}class gi{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:pc(We())}))}}class oa extends lr{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends lr{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Lh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=et();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=et();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||K(e[0])&&e[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function Lh(r){const e=et();return r.style&&(e.setFormat(r.style.textAlign),ea(r,e)),{node:e}}function et(){return Qt(new on)}function tn(r){return r instanceof on}const Fe=0,Hr=1,Ph=4;function gc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=ia(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Ih(r){const e=r||{},t=Fh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=ia(),l=e.namespace||(s!==null?s._config.namespace:Ou()),a=e.editorState,u=[rs,sn,Xn,Jn,on,oa,...e.nodes||[]],{onError:c,html:d}=e,f=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],w=null,y=null;if(typeof x!="function"){const _=x;x=_.replace,w=_.with,y=_.withKlass||null}const C=x.getType(),S=x.transform(),D=new Set;S!==null&&D.add(S),p.set(C,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:w,replaceWithKlass:y,transforms:D})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const w=new Map,y=new Set,C=S=>{Object.keys(S).forEach(D=>{let _=w.get(D);_===void 0&&(_=[],w.set(D,_)),_.push(S[D])})};return m.forEach(S=>{const D=S.klass.importDOM;if(D==null||y.has(D))return;y.add(D);const _=D.call(S.klass);_!==null&&C(_)}),x&&C(x),w}(p,d?d.import:void 0),f);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Nr,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ou(),this._onError=i,this._htmlConversions=o,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&H(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&H(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&H(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=yh(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],i=n.replaceWithKlass;if(i!=null){const a=this.registerNodeTransformToKlass(i,t);s.push(a)}var o,l;return o=this,l=e.getType(),_t(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void We().markDirty();const u=a._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(a=>a.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return re(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,gc(this,t,e,s),t!==null&&(this._config.disableEvents||wh(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(l){const a=l.ownerDocument;return a&&a.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,Bu(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(l,a){const u=l.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",tc),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=ec(l);for(let f=0;f<oo.length;f++){const[p,g]=oo[f],m=typeof g=="function"?x=>{Ha(x)||(Va(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Ha(x))return;Va(x);const w=a.isEditable();switch(p){case"cut":return w&&re(a,Lo,x);case"copy":return re(a,ii,x);case"paste":return w&&re(a,si,x);case"dragstart":return w&&re(a,Cu,x);case"dragover":return w&&re(a,Su,x);case"dragend":return w&&re(a,Ff,x);case"focus":return w&&re(a,Pf,x);case"blur":return w&&re(a,If,x);case"drop":return w&&re(a,wu,x)}};l.addEventListener(p,m),d.push(()=>{l.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;Rn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&H(38);let n=e;n._readOnly&&(n=hc(e),n._selection=e._selection?e._selection.clone():null),Nu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=ia(),l=it,a=bt,u=ot,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,it=o,bt=!1,ot=s;try{const g=s._nodes;na(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=f,s._dirtyType=p,it=l,bt=a,ot=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return pr(this),this.getEditorState().read(e,{editor:this})}update(e,t){_t(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),_t(this,()=>{const s=se(),i=We();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Dt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Rn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const mc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Oh=mc?v.useLayoutEffect:v.useEffect,fs={tag:"history-merge"};function zh({initialConfig:r,children:e}){const t=v.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=Sf(null,n),c=Ih({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const p=We();if(p.isEmpty()){const g=et();p.append(g);const m=mc?document.activeElement:null;(se()!==null||m!==null&&m===d.getRootElement())&&g.select()}},fs);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,fs);break}case"object":d.setEditorState(f,fs);break;case"function":d.update(()=>{We().isEmpty()&&f(d)},fs)}}}(c,l),[c,u]},[]);return Oh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(hu.Provider,{value:t,children:e})}const $h=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?v.useLayoutEffect:v.useEffect;function qh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Uh(){return function(r){const[e]=Pt(),t=v.useMemo(()=>r(e),[e,r]),[n,s]=v.useState(()=>t.initialValueFn()),i=v.useRef(n);return $h(()=>{const{initialValueFn:o,subscribe:l}=t,a=o();return i.current!==a&&(i.current=a,s(a)),l(u=>{i.current=u,s(u)})},[t,r]),n}(qh)}function Wh(){return We().getTextContent()}function Vh(r,e=!0){if(r)return!1;let t=Wh();return e&&(t=t.trim()),t===""}function Hh(r){if(!Vh(r,!1))return!1;const e=We().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Pe(s))return!1;if(P(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let l=0;l<o;l++){const a=i[n];if(!K(a))return!1}}}return!0}function yc(r){return()=>Hh(r)}function Gh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Gh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Kh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Yh=Kh(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const Qh=new Map;function Xh(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function xc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),l=s.getNode(),a=e.is(o),u=e.is(l);if(a||u){const[c,d]=co(r),f=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return f?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function Jh(r){const e=r.getStyle(),t=Xh(e);Qh.set(e,t)}function Zh(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),l=We(),a=l.getFirstChild();return void(a?a.replace(o,!0):l.append(o))}const s=r.getNodes(),i=n!==null&&function(o,l){let a=o;for(;a!==null&&a.getParent()!==null&&!l(a);)a=a.getParentOrThrow();return l(a)?a:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!hl(l))continue;P(l)||Yh(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function dl(r,e){const t=Pn(r.focus,e);return Pe(t)&&!t.isIsolated()||P(t)&&!t.isInline()&&!t.canBeEmpty()}function ep(r,e,t,n){r.modify(e?"extend":"move",t,n)}function tp(r){const e=r.anchor.getNode();return(ht(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=tp(r);ep(r,e,t?!n:n,"character")}function hl(r){if(Pe(r)||!P(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||K(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function rp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var np=rp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const bc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,sp=bc&&"documentMode"in document?document.documentMode:null;!(!bc||!("InputEvent"in window)||sp)&&"getTargetRanges"in new window.InputEvent("input");function vc(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function ns(r,...e){const t=vc(...e);t.length>0&&r.classList.add(...t)}function _c(r,...e){const t=vc(...e);t.length>0&&r.classList.remove(...t)}function ip(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function op(r){const e=yi(r,t=>P(t)&&!t.isInline());return P(e)||np(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==We()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function gr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function ap(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const l=o.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[u,c,d,f,p,g]=a;r.update(()=>{const m=se();if(U(m)){const x=m.anchor;let w=x.getNode(),y=0,C=0;if(K(w)&&u>=0&&c>=0&&(y=u,C=u+c,m.setTextNodeRange(w,y,w,C)),y===C&&d===""||(m.insertRawText(d),w=x.getNode()),K(w)){y=f,C=f+p;const S=w.getTextContentSize();y=y>S?S:y,C=C>S?S:C,m.setTextNodeRange(w,y,w,C)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function wc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!kc.has(o.nodeName)){const l=Ec(o,r,s,!1);l!==null&&(n=n.concat(l))}}return function(i){for(const o of i)o.getNextSibling()instanceof oa&&o.insertAfter(Mr());for(const o of i){const l=o.getChildren();for(const a of l)o.insertBefore(a);o.remove()}}(s),n}function Cc(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=We().getChildren();for(let s=0;s<n.length;s++)Sc(r,n[s],t,e);return t.innerHTML}function Sc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=P(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Zo(e);p=K(p)&&n!==null?xc(n,p):p,o=p}const l=P(o)?o.getChildren():[],a=r._nodes.get(o.getType());let u;u=a&&a.exportDOM!==void 0?a.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const f=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=Sc(r,g,f,n);!s&&P(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||za(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(za(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const kc=new Set(["STYLE","SCRIPT"]);function Ec(r,e,t,n,s=new Map,i){let o=[];if(kc.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,w=m._htmlConversions.get(x.toLowerCase());let y=null;if(w!==void 0)for(const C of w){const S=C(g);S!==null&&(y===null||(y.priority||0)<=(S.priority||0))&&(y=S)}return y!==null?y.conversion:null}(r,e),u=a?a(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,m]of s)if(l=m(l,i),!l)break;l&&o.push(...Array.isArray(g)?g:[l])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(l==null||!Kt(l))&&(l!=null&&fo(l)||n);for(let g=0;g<d.length;g++)f.push(...Ec(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),Os(r)&&(f=lp(r,f,p?()=>{const g=new oa;return t.push(g),g}:et)),l==null?f.length>0?o=o.concat(f):Os(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):P(l)&&l.append(...f),o}function lp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const l=e[o];if(fo(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(i.push(l),o===e.length-1||o<e.length-1&&fo(e[o+1])){const a=t();a.setFormat(n),a.append(...i),s.push(a),i=[]}}return s}function up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Hs=up(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function cp(r,e=se()){return e==null&&Hs(166),U(e)&&e.isCollapsed()||e.getNodes().length===0?"":Cc(r,e)}function dp(r,e=se()){return e==null&&Hs(166),U(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(fp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,hp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:a=>a}).createHTML(l):l}(s),"text/html");return gl(t,wc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(U(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=se();if(U(a)){const u=o[l];u===`
94
94
  `||u===`\r
95
- `?a.insertParagraph():u===" "?a.insertNodes([Zn()]):a.insertText(u)}}}else e.insertRawText(i)}function pl(r,e,t){r.dispatchCommand(Sf,{nodes:e,selection:t})||t.insertNodes(e)}function kc(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=P(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=G(u)&&e!==null?yc(e,u):u,o=u}const l=P(o)?o.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Hs(58,d.name),P(u)){const f=c.children;Array.isArray(f)||Hs(59,d.name)}return c}(o);if(G(o)){const u=o.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=kc(r,e,c,a.children);!s&&P(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function dp(r,e){const t=[],n=Pe().getChildren();for(let s=0;s<n.length;s++)kc(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function fp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=Mh(n);G(s)&&Xh(s),e.push(s)}return e}let qr=null;async function gl(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(ml(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Et(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const l=new Range;return l.setStart(o,0),l.setEnd(o,1),i.removeAllRanges(),i.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),a(ml(r,d,t))),!0),Lh);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function ml(r,e,t){if(t===void 0){const s=Et(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Yn(r,i,o))return!1;const l=te();if(l===null)return!1;t=pp(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(gp(n,t),!0)}const hp=[["text/html",up],["application/x-lexical-editor",cp]];function pp(r=te()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=ph();for(const[n,s]of hp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function gp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function yl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,mp=an&&"documentMode"in document?document.documentMode:null,yp=!(!an||!("InputEvent"in window)||mp)&&"getTargetRanges"in new window.InputEvent("input"),xp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,bp=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),_p=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!bp,bl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return ns(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:vp,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=oa();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=He(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=He();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function oa(){return Qt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];ns(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?He():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=He();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?He():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Zo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function vp(r){const e=oa();return r.style!==null&&(e.setFormat(r.style.textAlign),Zo(r,e)),{node:e}}function wn(r){return Qt(new bi(r))}function hs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function vl(r){const e=te();if(!z(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const l=yi(i,u=>P(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function ps(r){const e=en(r);return Ae(e)}function wp(r){return Pr(r.registerCommand(hu,e=>{const t=te();return!!Ut(t)&&(t.clear(),!0)},0),r.registerCommand(kr,e=>{const t=te();return!!z(t)&&(t.deleteCharacter(e),!0)},Ee),r.registerCommand(jn,e=>{const t=te();return!!z(t)&&(t.deleteWord(e),!0)},Ee),r.registerCommand(Ln,e=>{const t=te();return!!z(t)&&(t.deleteLine(e),!0)},Ee),r.registerCommand(Yr,e=>{const t=te();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)hl(n,t,r);else if(z(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Ee),r.registerCommand(Ki,()=>{const e=te();return!!z(e)&&(e.removeText(),!0)},Ee),r.registerCommand(Mt,e=>{const t=te();return!!z(t)&&(t.formatText(e),!0)},Ee),r.registerCommand(Ff,e=>{const t=te();if(!z(t)&&!Ut(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>P(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},Ee),r.registerCommand(Kr,e=>{const t=te();return!!z(t)&&(t.insertLineBreak(e),!0)},Ee),r.registerCommand(Mn,()=>{const e=te();return!!z(e)&&(e.insertParagraph(),!0)},Ee),r.registerCommand(Nf,()=>(oc([Zn()]),!0),Ee),r.registerCommand(Bf,()=>vl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Ee),r.registerCommand(ka,()=>vl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Ee),r.registerCommand(mu,e=>{const t=te();if(Ut(t)&&!ps(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(z(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Ae(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Ee),r.registerCommand(yu,e=>{const t=te();if(Ut(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(z(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Pe().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Ae(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Ee),r.registerCommand(gu,e=>{const t=te();if(Ut(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!z(t))return!1;if(cl(t,!0)){const n=e.shiftKey;return e.preventDefault(),dl(t,n,!0),!0}return!1},Ee),r.registerCommand(pu,e=>{const t=te();if(Ut(t)&&!ps(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!z(t))return!1;const n=e.shiftKey;return!!cl(t,!1)&&(e.preventDefault(),dl(t,n,!1),!0)},Ee),r.registerCommand(xu,e=>{if(ps(e.target))return!1;const t=te();if(!z(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!lt(s)&&ip(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(ka,void 0)):(!xl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(kr,!0))},Ee),r.registerCommand(_u,e=>{if(ps(e.target))return!1;const t=te();return!!z(t)&&(e.preventDefault(),r.dispatchCommand(kr,!1))},Ee),r.registerCommand(Ns,e=>{const t=te();if(!z(t))return!1;if(e!==null){if((xl||xp||_p)&&yp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Mn,void 0)},Ee),r.registerCommand(bu,()=>{const e=te();return!!z(e)&&(r.blur(),!0)},Ee),r.registerCommand(vu,e=>{const[,t]=hs(e);if(t.length>0){const s=yl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Nh();if(G(l))a.anchor.set(l.getKey(),i,"text"),a.focus.set(l.getKey(),i,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=Bu(a);Gt(u)}r.dispatchCommand(bl,t)}return e.preventDefault(),!0}const n=te();return!!z(n)},Ee),r.registerCommand(wu,e=>{const[t]=hs(e),n=te();return!(t&&!z(n))},Ee),r.registerCommand(Cu,e=>{const[t]=hs(e),n=te();if(t&&!z(n))return!1;const s=yl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Ae(i)&&e.preventDefault()}return!0},Ee),r.registerCommand(Yi,()=>(ch(),!0),Ee),r.registerCommand(ii,e=>(gl(r,gr(e,ClipboardEvent)?e:null),!0),Ee),r.registerCommand(jo,e=>(async function(t,n){await gl(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=te();z(s)?s.removeText():Ut(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Ee),r.registerCommand(si,e=>{const[,t,n]=hs(e);return t.length>0&&!n?(r.dispatchCommand(bl,t),!0):Vo(e.target)?!1:te()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=te(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&hl(l,o,i)},{tag:"paste"})}(e,r),!0)},Ee))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?_.useLayoutEffect:_.useEffect;function wl(r){return r.getEditorState().read(mc(r.isComposing()))}function Cp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=Lt(),s=function(i,o){const[l,a]=_.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),_.useEffect(()=>{a(i.getDecorators())},[i]),_.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(_.Suspense,{fallback:null,children:l[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,l,i])}(n,t);return function(i){fo(()=>Pr(wp(i),op(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Sp,{content:e}),s]})}function Sp({content:r}){const[e]=Lt(),t=function(s){const[i,o]=_.useState(()=>wl(s));return fo(()=>{function l(){const a=wl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=qh();return t?typeof r=="function"?r(n):r:null}const Dc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?_.useLayoutEffect:_.useEffect;function Ep({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:b,tabIndex:C,"data-testid":S,...D},w){const[y,k]=_.useState(r.isEditable()),N=_.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),F=_.useMemo(()=>function(...T){return M=>{T.forEach(L=>{typeof L=="function"?L(M):L!=null&&(L.current=M)})}}(w,N),[N,w]);return Dc(()=>(k(r.isEditable()),r.registerEditableListener(T=>{k(T)})),[r]),h.jsx("div",{"aria-activedescendant":y?e:void 0,"aria-autocomplete":y?t:"none","aria-controls":y?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":y&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":y?d:void 0,"aria-readonly":!y||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:y,"data-testid":S,id:m,ref:F,role:y?x:void 0,spellCheck:v,style:b,tabIndex:C,...D})}const kp=_.forwardRef(Ep);function Cl(r){return r.getEditorState().read(mc(r.isComposing()))}const Dp=_.forwardRef(Ap);function Ap(r,e){const{placeholder:t,...n}=r,[s]=Lt();return h.jsxs(h.Fragment,{children:[h.jsx(kp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Tp,{editor:s,content:t})]})}function Tp({content:r,editor:e}){const t=function(o){const[l,a]=_.useState(()=>Cl(o));return Dc(()=>{function u(){const c=Cl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=_.useState(e.isEditable());if(_.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:h.jsx("div",{"aria-hidden":!0,children:i})}const gs=0,ho=1,po=2,Bt=0,Np=1,Sl=2,Bp=3,Fp=4;function Rp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Bt;const i=e._selection,o=r._selection;if(s)return Np;if(!(z(i)&&z(o)&&o.isCollapsed()&&i.isCollapsed()))return Bt;const l=function(v,b,C){const S=v._nodeMap,D=[];for(const w of b){const y=S.get(w);y!==void 0&&D.push(y)}for(const[w,y]of C){if(!y)continue;const k=S.get(w);k===void 0||lt(k)||D.push(k)}return D}(e,t,n);if(l.length===0)return Bt;if(l.length>1){const v=e._nodeMap,b=v.get(i.anchor.key),C=v.get(o.anchor.key);return b&&C&&!r._nodeMap.has(b.__key)&&G(b)&&b.__text.length===1&&i.anchor.offset===1?Sl:Bt}const a=l[0],u=r._nodeMap.get(a.__key);if(!G(u)||!G(a)||u.__mode!==a.__mode)return Bt;const c=u.__text,d=a.__text;if(c===d)return Bt;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Bt;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?Sl:x===-1&&m===g+1?Bp:x===-1&&m===g?Fp:Bt}function Mp(r,e){let t=Date.now(),n=Bt;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=Bt,t=c,po;const d=Rp(s,i,l,a,r.isComposing()),f=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return gs;if(s===null)return ho;const m=i._selection;return l.size>0||a.size>0?g===!1&&d!==Bt&&d===n&&c<t+e&&p||l.size===1&&function(x,v,b){const C=v._nodeMap.get(x),S=b._nodeMap.get(x),D=v._selection,w=b._selection;return!(z(D)&&z(w)&&D.anchor.type==="element"&&D.focus.type==="element"&&w.anchor.type==="text"&&w.focus.type==="text"||!G(C)||!G(S)||C.__parent!==S.__parent)&&JSON.stringify(v.read(()=>C.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?gs:ho:m!==null?gs:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function jp(r,e,t){const n=Mp(r,t);return Pr(r.registerCommand(Ro,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(a.length!==0){const u=o.current,c=a.pop();u!==null&&(l.push(u),i.dispatchCommand(ls,!0)),a.length===0&&i.dispatchCommand(us,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ee),r.registerCommand(Mo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(l.length!==0){const u=o.current;u!==null&&(a.push(u),i.dispatchCommand(us,!0));const c=l.pop();l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ee),r.registerCommand(Mf,()=>(El(e),!1),Ee),r.registerCommand(jf,()=>(El(e),r.dispatchCommand(ls,!1),r.dispatchCommand(us,!1),!0),Ee),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,l,a,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(ls,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(us,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Lp(){return{current:null,redoStack:[],undoStack:[]}}function Pp({delay:r,externalHistoryState:e}){const[t]=Lt();return function(n,s,i=1e3){const o=_.useMemo(()=>s||Lp(),[s]);_.useEffect(()=>jp(n,o,i),[i,n,o])}(t,e,r),null}const Op=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?_.useLayoutEffect:_.useEffect;function Ip({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=Lt();return Op(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:l,tags:a})=>{e&&i.size===0&&o.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var kl={error:null},zp=function(r){var e,t;function n(){for(var i,o=arguments.length,l=new Array(o),a=0;a<o;a++)l[a]=arguments[a];return(i=r.call.apply(r,[this].concat(l))||this).state=kl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(kl)},s.componentDidCatch=function(i,o){var l,a;(l=(a=this.props).onError)==null||l.call(a,i,o)},s.componentDidUpdate=function(i,o){var l,a,u,c,d=this.state.error,f=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=f)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,l=o.fallbackRender,a=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(Ei.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return Ei.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(Ei.Component);function $p({children:r,onError:e}){return h.jsx(zp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function qp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wt=qp(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Up(r){let e=1,t=r.getParent();for(;t!=null;){if(Ie(t)){const n=t.getParent();if(Ce(n)){e++,t=n.getParent();continue}Wt(40)}return e}return e}function mo(r){let e=r.getParent();Ce(e)||Wt(40);let t=e;for(;t!==null;)t=t.getParent(),Ce(t)&&(e=t);return e}function Ac(r){let e=[];const t=r.getChildren().filter(Ie);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Ce(i)?e=e.concat(Ac(i)):e.push(s)}return e}function Vt(r){return Ie(r)&&Ce(r.getFirstChild())}function Dl(r){return _t().append(r)}function Tc(r,e){return Ie(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Al(r,e){r.update(()=>{const t=te();if(t!==null){const n=t.getNodes();if(z(t)){const i=t.getStartEndPoints();i===null&&Wt(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Tc(l,n)){const u=yt(e);if(Kt(a)){l.replace(u);const c=_t();P(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Ie(l)){const c=l.getParentOrThrow();Mr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!P(o)||!o.isEmpty()||Ie(o)||s.has(o.getKey())){if(Ru(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Ce(l)){if(!s.has(a)){const u=yt(e);Mr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Kt(u)&&!s.has(a)){s.add(a),Tl(l,e);break}l=u}}}}else Tl(o,e)}}})}function Mr(r,e){r.splice(r.getChildrenSize(),0,e)}function Tl(r,e){if(Ce(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=_t();let i;if(Mr(s,r.getChildren()),Ce(t)&&e===t.getListType())t.append(s),Ce(n)&&e===n.getListType()&&(Mr(t,n.getChildren()),n.remove()),i=t;else if(Ce(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=yt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function aa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Vt(t)&&Vt(n)&&(aa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Wp(r){r.update(()=>{const e=te();if(z(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Tc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Ru(o)){const l=sp(o,Or);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Ac(i);for(const a of l){const u=He();Mr(u,a.getChildren()),o.insertAfter(u),o=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}i.remove()}}})}function Vp(r){const e=new Set;if(Vt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Vt(n)&&Vt(s)){const i=s.getFirstChild();if(Ce(i)){i.append(r);const o=n.getFirstChild();Ce(o)&&(Mr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Ce(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Ce(i)&&i.append(r)}else if(Ce(t)){const i=_t(),o=yt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Hp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Ce(t?t.getParent():void 0)&&Ie(t)&&Ce(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const i=e.getListType(),o=_t(),l=yt(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=_t(),u=yt(i);a.append(u),Mr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function Gp(){const r=te();if(!z(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Ie(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Ce(n)||Wt(40);const s=n.getParent();let i;if(Kt(s))i=He(),t.insertAfter(i);else{if(!Ie(s))return!1;i=_t(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=yt(n.getListType());if(tn(i))i.insertAfter(l);else{const a=_t();a.append(l),i.insertAfter(a)}o.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!Ie(a)&&!Ce(a))break;a=u}a.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Or extends lr{static getType(){return"listitem"}static clone(e){return new Or(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Ce(n)&&n.getListType()==="check"&&Bl(t,this,null),t.value=this.__value,Nl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Ce(s)&&s.getListType()==="check"&&Bl(t,this,e),t.value=this.__value,Nl(t,n.theme,this),!1}static transform(){return e=>{if(Ie(e)||Wt(144),e.__checked==null)return;const t=e.getParent();Ce(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Kp,priority:0})}}static importJSON(e){const t=_t();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(P(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Ie(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Ce(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=yt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&(P(e)||Wt(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Ce(n)||Wt(39),Ie(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=yt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Vt(t)&&Vt(n)&&(aa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=_t(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=He();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Ie(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,l=e.focus,a=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(a,o.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Ce(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;Ie(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Wt(117),(e=Math.floor(e))>=0||Wt(199);let t=this.getIndent();for(;t!==e;)t<e?(Vp(this),t++):(Hp(this),t--);return this}canInsertAfter(e){return Ie(e)}canReplaceWith(e){return Ie(e)}canMergeWith(e){return tn(e)||Ie(e)}extractWithChild(e,t){if(!z(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return yt("bullet")}canMergeWhenEmpty(){return!0}}function Nl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let l;if(i&&i.nested&&(l=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const a=t.getParent(),u=Ce(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(l!==void 0){const a=Gs(l);t.getChildren().some(u=>Ce(u))?n.push(...a):s.push(...a)}s.length>0&&_c(r,...s),n.length>0&&ns(r,...n)}function Bl(r,e,t,n){Ce(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Kp(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Yp(t)}const e=r.getAttribute("aria-checked");return{node:_t(e==="true"||e!=="false"&&void 0)}}function Yp(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:_t(r.hasAttribute("checked"))}}function _t(r){return Qt(new Or(void 0,r))}function Ie(r){return r instanceof Or}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Ml[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Ml[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Fl(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Fl(t,n.theme,this),!1)}static transform(){return e=>{Ce(e)||Wt(163),function(t){const n=t.getNextSibling();Ce(n)&&t.getListType()===n.getListType()&&aa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())Ie(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Ce(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=yt(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&or(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(Ie(n))super.append(n);else{const s=_t();if(Ce(n))s.append(n);else if(P(n))if(n.isInline())s.append(n);else{const i=Ke(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Ie(e)}}function Fl(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Up(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const f=i.nested,p=i.checklist;if(f!==void 0&&f.list&&(d=f.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&_c(r,...s),n.length>0&&ns(r,...n)}function Qp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Ie(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Ce(i)&&e.push(Dl(i))})}else e.push(Dl(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=yt("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(or(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?yt("check"):yt("bullet")),{after:Qp,node:t}}const Ml={ol:"number",ul:"bullet"};function yt(r,e=1){return Qt(new ln(r,e))}function Ce(r){return r instanceof ln}const Nc=Hn(),Bc=Hn(),Xp=Hn();function Jp(r){return Pr(r.registerCommand(Bc,()=>(Al(r,"number"),!0),Hr),r.registerCommand(Nc,()=>(Al(r,"bullet"),!0),Hr),r.registerCommand(Xp,()=>(Wp(r),!0),Hr),r.registerCommand(Mn,()=>!!Gp(),Hr))}function Zp(){const[r]=Lt();return _.useEffect(()=>{if(!r.hasNodes([ln,Or]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){_.useEffect(()=>Jp(e),[e])}(r),null}const eg=new Set(["http:","https:","mailto:","sms:","tel:"]);class Ir extends lr{static getType(){return"link"}static clone(e){return new Ir(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),ns(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:tg,priority:1})}}static importJSON(e){const t=Ks(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!eg.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Ks(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!z(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function tg(r){let e=null;if(hh(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Qt(new Ir(r,e))}function mn(r){return r instanceof Ir}class ss extends Ir{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new ss(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=jl(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(P(n)){const s=jl(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function jl(r,e){return Qt(new ss(r,e))}function rg(r){return r instanceof ss}const Ll=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=te();if(!z(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!rg(u)&&mn(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(o.length===1){const u=function(c,d){let f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;o.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!P(u)||u.isInline())){if(mn(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),mn(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function ng({validateUrl:r,attributes:e}){const[t]=Lt();return _.useEffect(()=>{if(!t.hasNodes([Ir]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Ll,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:l}=n;return $i(s,{...e,rel:o,target:i,title:l}),!0}},Hr),r!==void 0?t.registerCommand(si,n=>{const s=te();if(!z(s)||s.isCollapsed()||!gr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(l=>P(l))&&(t.dispatchCommand(Ll,{...e,url:o}),n.preventDefault(),!0)},Hr):()=>{})},[t,r,e]),null}function sg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Fc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function ig({src:r,alt:e,width:t,height:n}){return h.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class _i extends na{constructor(t,n,s,i,o){super(o);St(this,"__src");St(this,"__altText");St(this,"__width");St(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new _i(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Fc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:sg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return h.jsx(ig,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Fc(r){return new _i(r.src,r.altText,r.width,r.height)}var og=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Rc=Object.prototype.hasOwnProperty,Mc=Object.prototype.propertyIsEnumerable,Pl=(r,e,t)=>e in r?og(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Rc.call(e,t)&&Pl(r,t,e[t]);if(Ys)for(var t of Ys(e))Mc.call(e,t)&&Pl(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Rc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Mc.call(r,n)&&(t[n]=r[n]);return t};/**
95
+ `?a.insertParagraph():u===" "?a.insertNodes([Zn()]):a.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(kf,{nodes:e,selection:t})||t.insertNodes(e)}function Dc(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=P(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Zo(t);u=K(u)&&e!==null?xc(e,u):u,o=u}const l=P(o)?o.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Hs(58,d.name),P(u)){const f=c.children;Array.isArray(f)||Hs(59,d.name)}return c}(o);if(K(o)){const u=o.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=Dc(r,e,c,a.children);!s&&P(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function fp(r,e){const t=[],n=We().getChildren();for(let s=0;s<n.length;s++)Dc(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function hp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=jh(n);K(s)&&Jh(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Dt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const l=new Range;return l.setStart(o,0),l.setEnd(o,1),i.removeAllRanges(),i.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),a(yl(r,d,t))),!0),Ph);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Dt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Yn(r,i,o))return!1;const l=se();if(l===null)return!1;t=gp(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(mp(n,t),!0)}const pp=[["text/html",cp],["application/x-lexical-editor",dp]];function gp(r=se()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=gh();for(const[n,s]of pp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function mp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,yp=an&&"documentMode"in document?document.documentMode:null,xp=!(!an||!("InputEvent"in window)||yp)&&"getTargetRanges"in new window.InputEvent("input"),bp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,vp=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),_p=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!vp,vl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return ns(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:wp,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=aa();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=et(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=et();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function aa(){return Qt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const i=s[t];ns(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=wn(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?et():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=et();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?et():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(ea(r,t),t.setFormat(r.style.textAlign))),{node:t}}function wp(r){const e=aa();return r.style!==null&&(e.setFormat(r.style.textAlign),ea(r,e)),{node:e}}function wn(r){return Qt(new bi(r))}function hs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function wl(r){const e=se();if(!U(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const l=yi(i,u=>P(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function ps(r){const e=en(r);return Pe(e)}function Cp(r){return Pr(r.registerCommand(pu,e=>{const t=se();return!!Ut(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=se();return!!U(t)&&(t.deleteCharacter(e),!0)},Fe),r.registerCommand(jn,e=>{const t=se();return!!U(t)&&(t.deleteWord(e),!0)},Fe),r.registerCommand(Ln,e=>{const t=se();return!!U(t)&&(t.deleteLine(e),!0)},Fe),r.registerCommand(Yr,e=>{const t=se();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(U(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Fe),r.registerCommand(Yi,()=>{const e=se();return!!U(e)&&(e.removeText(),!0)},Fe),r.registerCommand(jt,e=>{const t=se();return!!U(t)&&(t.formatText(e),!0)},Fe),r.registerCommand(Mf,e=>{const t=se();if(!U(t)&&!Ut(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>P(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},Fe),r.registerCommand(Kr,e=>{const t=se();return!!U(t)&&(t.insertLineBreak(e),!0)},Fe),r.registerCommand(Fn,()=>{const e=se();return!!U(e)&&(e.insertParagraph(),!0)},Fe),r.registerCommand(Bf,()=>(ac([Zn()]),!0),Fe),r.registerCommand(Rf,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Fe),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Fe),r.registerCommand(yu,e=>{const t=se();if(Ut(t)&&!ps(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(U(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Pe(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Fe),r.registerCommand(xu,e=>{const t=se();if(Ut(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(U(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===We().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Pe(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Fe),r.registerCommand(mu,e=>{const t=se();if(Ut(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!U(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Fe),r.registerCommand(gu,e=>{const t=se();if(Ut(t)&&!ps(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!U(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Fe),r.registerCommand(bu,e=>{if(ps(e.target))return!1;const t=se();if(!U(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!ht(s)&&op(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Fe),r.registerCommand(_u,e=>{if(ps(e.target))return!1;const t=se();return!!U(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Fe),r.registerCommand(Ns,e=>{const t=se();if(!U(t))return!1;if(e!==null){if((bl||bp||_p)&&xp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Fn,void 0)},Fe),r.registerCommand(vu,()=>{const e=se();return!!U(e)&&(r.blur(),!0)},Fe),r.registerCommand(wu,e=>{const[,t]=hs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Bh();if(K(l))a.anchor.set(l.getKey(),i,"text"),a.focus.set(l.getKey(),i,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=Ru(a);Gt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=se();return!!U(n)},Fe),r.registerCommand(Cu,e=>{const[t]=hs(e),n=se();return!(t&&!U(n))},Fe),r.registerCommand(Su,e=>{const[t]=hs(e),n=se();if(t&&!U(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Pe(i)&&e.preventDefault()}return!0},Fe),r.registerCommand(Qi,()=>(dh(),!0),Fe),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),Fe),r.registerCommand(Lo,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=se();U(s)?s.removeText():Ut(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Fe),r.registerCommand(si,e=>{const[,t,n]=hs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Ho(e.target)?!1:se()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=se(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&pl(l,o,i)},{tag:"paste"})}(e,r),!0)},Fe))}const ho=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?v.useLayoutEffect:v.useEffect;function Cl(r){return r.getEditorState().read(yc(r.isComposing()))}function Sp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=Pt(),s=function(i,o){const[l,a]=v.useState(()=>i.getDecorators());return ho(()=>i.registerDecoratorListener(u=>{ya.flushSync(()=>{a(u)})}),[i]),v.useEffect(()=>{a(i.getDecorators())},[i]),v.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(v.Suspense,{fallback:null,children:l[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ya.createPortal(p,g,f))}return u},[o,l,i])}(n,t);return function(i){ho(()=>Pr(Cp(i),ap(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(kp,{content:e}),s]})}function kp({content:r}){const[e]=Pt(),t=function(s){const[i,o]=v.useState(()=>Cl(s));return ho(()=>{function l(){const a=Cl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Uh();return t?typeof r=="function"?r(n):r:null}const Ac=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?v.useLayoutEffect:v.useEffect;function Ep({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:w=!0,style:y,tabIndex:C,"data-testid":S,...D},_){const[b,E]=v.useState(r.isEditable()),N=v.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),R=v.useMemo(()=>function(...T){return F=>{T.forEach(L=>{typeof L=="function"?L(F):L!=null&&(L.current=F)})}}(_,N),[N,_]);return Ac(()=>(E(r.isEditable()),r.registerEditableListener(T=>{E(T)})),[r]),h.jsx("div",{"aria-activedescendant":b?e:void 0,"aria-autocomplete":b?t:"none","aria-controls":b?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":b&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":b?d:void 0,"aria-readonly":!b||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:b,"data-testid":S,id:m,ref:R,role:b?x:void 0,spellCheck:w,style:y,tabIndex:C,...D})}const Dp=v.forwardRef(Ep);function Sl(r){return r.getEditorState().read(yc(r.isComposing()))}const Ap=v.forwardRef(Tp);function Tp(r,e){const{placeholder:t,...n}=r,[s]=Pt();return h.jsxs(h.Fragment,{children:[h.jsx(Dp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Np,{editor:s,content:t})]})}function Np({content:r,editor:e}){const t=function(o){const[l,a]=v.useState(()=>Sl(o));return Ac(()=>{function u(){const c=Sl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=v.useState(e.isEditable());if(v.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:h.jsx("div",{"aria-hidden":!0,children:i})}const gs=0,po=1,go=2,Rt=0,Bp=1,kl=2,Rp=3,Mp=4;function Fp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Rt;const i=e._selection,o=r._selection;if(s)return Bp;if(!(U(i)&&U(o)&&o.isCollapsed()&&i.isCollapsed()))return Rt;const l=function(w,y,C){const S=w._nodeMap,D=[];for(const _ of y){const b=S.get(_);b!==void 0&&D.push(b)}for(const[_,b]of C){if(!b)continue;const E=S.get(_);E===void 0||ht(E)||D.push(E)}return D}(e,t,n);if(l.length===0)return Rt;if(l.length>1){const w=e._nodeMap,y=w.get(i.anchor.key),C=w.get(o.anchor.key);return y&&C&&!r._nodeMap.has(y.__key)&&K(y)&&y.__text.length===1&&i.anchor.offset===1?kl:Rt}const a=l[0],u=r._nodeMap.get(a.__key);if(!K(u)||!K(a)||u.__mode!==a.__mode)return Rt;const c=u.__text,d=a.__text;if(c===d)return Rt;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Rt;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Rp:x===-1&&m===g?Mp:Rt}function jp(r,e){let t=Date.now(),n=Rt;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=Rt,t=c,go;const d=Fp(s,i,l,a,r.isComposing()),f=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return gs;if(s===null)return po;const m=i._selection;return l.size>0||a.size>0?g===!1&&d!==Rt&&d===n&&c<t+e&&p||l.size===1&&function(x,w,y){const C=w._nodeMap.get(x),S=y._nodeMap.get(x),D=w._selection,_=y._selection;return!(U(D)&&U(_)&&D.anchor.type==="element"&&D.focus.type==="element"&&_.anchor.type==="text"&&_.focus.type==="text"||!K(C)||!K(S)||C.__parent!==S.__parent)&&JSON.stringify(w.read(()=>C.exportJSON()))===JSON.stringify(y.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?gs:po:m!==null?gs:go})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function Lp(r,e,t){const n=jp(r,t);return Pr(r.registerCommand(Fo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(a.length!==0){const u=o.current,c=a.pop();u!==null&&(l.push(u),i.dispatchCommand(ls,!0)),a.length===0&&i.dispatchCommand(us,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Fe),r.registerCommand(jo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(l.length!==0){const u=o.current;u!==null&&(a.push(u),i.dispatchCommand(us,!0));const c=l.pop();l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Fe),r.registerCommand(jf,()=>(El(e),!1),Fe),r.registerCommand(Lf,()=>(El(e),r.dispatchCommand(ls,!1),r.dispatchCommand(us,!1),!0),Fe),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,l,a,u);if(g===po)d.length!==0&&(e.redoStack=[],r.dispatchCommand(ls,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(us,!0));else if(g===go)return;e.current={editor:r,editorState:i}}))}function Pp(){return{current:null,redoStack:[],undoStack:[]}}function Ip({delay:r,externalHistoryState:e}){const[t]=Pt();return function(n,s,i=1e3){const o=v.useMemo(()=>s||Pp(),[s]);v.useEffect(()=>Lp(n,o,i),[i,n,o])}(t,e,r),null}const Op=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?v.useLayoutEffect:v.useEffect;function zp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=Pt();return Op(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:l,tags:a})=>{e&&i.size===0&&o.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function mo(r,e){return mo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},mo(r,e)}var Dl={error:null},$p=function(r){var e,t;function n(){for(var i,o=arguments.length,l=new Array(o),a=0;a<o;a++)l[a]=arguments[a];return(i=r.call.apply(r,[this].concat(l))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,mo(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var l,a;(l=(a=this.props).onError)==null||l.call(a,i,o)},s.componentDidUpdate=function(i,o){var l,a,u,c,d=this.state.error,f=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=f)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,l=o.fallbackRender,a=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return ki.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function qp({children:r,onError:e}){return h.jsx($p,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wt=Up(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Wp(r){let e=1,t=r.getParent();for(;t!=null;){if(He(t)){const n=t.getParent();if(Re(n)){e++,t=n.getParent();continue}Wt(40)}return e}return e}function yo(r){let e=r.getParent();Re(e)||Wt(40);let t=e;for(;t!==null;)t=t.getParent(),Re(t)&&(e=t);return e}function Tc(r){let e=[];const t=r.getChildren().filter(He);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Re(i)?e=e.concat(Tc(i)):e.push(s)}return e}function Vt(r){return He(r)&&Re(r.getFirstChild())}function Al(r){return wt().append(r)}function Nc(r,e){return He(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=se();if(t!==null){const n=t.getNodes();if(U(t)){const i=t.getStartEndPoints();i===null&&Wt(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Nc(l,n)){const u=vt(e);if(Kt(a)){l.replace(u);const c=wt();P(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(He(l)){const c=l.getParentOrThrow();Fr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!P(o)||!o.isEmpty()||He(o)||s.has(o.getKey())){if(Fu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Re(l)){if(!s.has(a)){const u=vt(e);Fr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Kt(u)&&!s.has(a)){s.add(a),Nl(l,e);break}l=u}}}}else Nl(o,e)}}})}function Fr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Re(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=wt();let i;if(Fr(s,r.getChildren()),Re(t)&&e===t.getListType())t.append(s),Re(n)&&e===n.getListType()&&(Fr(t,n.getChildren()),n.remove()),i=t;else if(Re(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=vt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function la(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Vt(t)&&Vt(n)&&(la(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Vp(r){r.update(()=>{const e=se();if(U(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Nc(s,n))t.add(yo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const l=ip(o,Ir);l!=null&&t.add(yo(l))}}for(const i of t){let o=i;const l=Tc(i);for(const a of l){const u=et();Fr(u,a.getChildren()),o.insertAfter(u),o=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}i.remove()}}})}function Hp(r){const e=new Set;if(Vt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Vt(n)&&Vt(s)){const i=s.getFirstChild();if(Re(i)){i.append(r);const o=n.getFirstChild();Re(o)&&(Fr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Re(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Re(i)&&i.append(r)}else if(Re(t)){const i=wt(),o=vt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Gp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Re(t?t.getParent():void 0)&&He(t)&&Re(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const i=e.getListType(),o=wt(),l=vt(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=wt(),u=vt(i);a.append(u),Fr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function Kp(){const r=se();if(!U(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!He(e)||e.getChildrenSize()!==0)return!1;const t=yo(e),n=e.getParent();Re(n)||Wt(40);const s=n.getParent();let i;if(Kt(s))i=et(),t.insertAfter(i);else{if(!He(s))return!1;i=wt(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=vt(n.getListType());if(tn(i))i.insertAfter(l);else{const a=wt();a.append(l),i.insertAfter(a)}o.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!He(a)&&!Re(a))break;a=u}a.remove()}(e),!0}function Gs(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Ir extends lr{static getType(){return"listitem"}static clone(e){return new Ir(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Re(n)&&n.getListType()==="check"&&Rl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Re(s)&&s.getListType()==="check"&&Rl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(He(e)||Wt(144),e.__checked==null)return;const t=e.getParent();Re(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Yp,priority:0})}}static importJSON(e){const t=wt();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(P(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(He(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Re(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=vt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&(P(e)||Wt(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Re(n)||Wt(39),He(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=vt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Vt(t)&&Vt(n)&&(la(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=wt(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=et();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=He(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,l=e.focus,a=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(a,o.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Re(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;He(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Wt(117),(e=Math.floor(e))>=0||Wt(199);let t=this.getIndent();for(;t!==e;)t<e?(Hp(this),t++):(Gp(this),t--);return this}canInsertAfter(e){return He(e)}canReplaceWith(e){return He(e)}canMergeWith(e){return tn(e)||He(e)}extractWithChild(e,t){if(!U(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return vt("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let l;if(i&&i.nested&&(l=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const a=t.getParent(),u=Re(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(l!==void 0){const a=Gs(l);t.getChildren().some(u=>Re(u))?n.push(...a):s.push(...a)}s.length>0&&_c(r,...s),n.length>0&&ns(r,...n)}function Rl(r,e,t,n){Re(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Yp(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Qp(t)}const e=r.getAttribute("aria-checked");return{node:wt(e==="true"||e!=="false"&&void 0)}}function Qp(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:wt(r.hasAttribute("checked"))}}function wt(r){return Qt(new Ir(void 0,r))}function He(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||jl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=jl[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{Re(e)||Wt(163),function(t){const n=t.getNextSibling();Re(n)&&t.getListType()===n.getListType()&&la(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())He(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Re(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Fl,priority:0}),ul:()=>({conversion:Fl,priority:0})}}static importJSON(e){const t=vt(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&or(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(He(n))super.append(n);else{const s=wt();if(Re(n))s.append(n);else if(P(n))if(n.isInline())s.append(n);else{const i=rt(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return He(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Wp(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const f=i.nested,p=i.checklist;if(f!==void 0&&f.list&&(d=f.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&_c(r,...s),n.length>0&&ns(r,...n)}function Xp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(He(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Re(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Fl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=vt("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(or(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?vt("check"):vt("bullet")),{after:Xp,node:t}}const jl={ol:"number",ul:"bullet"};function vt(r,e=1){return Qt(new ln(r,e))}function Re(r){return r instanceof ln}const Bc=Hn(),Rc=Hn(),Jp=Hn();function Zp(r){return Pr(r.registerCommand(Rc,()=>(Tl(r,"number"),!0),Hr),r.registerCommand(Bc,()=>(Tl(r,"bullet"),!0),Hr),r.registerCommand(Jp,()=>(Vp(r),!0),Hr),r.registerCommand(Fn,()=>!!Kp(),Hr))}function eg(){const[r]=Pt();return v.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){v.useEffect(()=>Zp(e),[e])}(r),null}const tg=new Set(["http:","https:","mailto:","sms:","tel:"]);class Or extends lr{static getType(){return"link"}static clone(e){return new Or(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),ns(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:rg,priority:1})}}static importJSON(e){const t=Ks(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!tg.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Ks(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!U(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function rg(r){let e=null;if(ph(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Qt(new Or(r,e))}function mn(r){return r instanceof Or}class ss extends Or{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new ss(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Ll(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(P(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Qt(new ss(r,e))}function ng(r){return r instanceof ss}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=se();if(!U(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!ng(u)&&mn(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(o.length===1){const u=function(c,d){let f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;o.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!P(u)||u.isInline())){if(mn(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),mn(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function sg({validateUrl:r,attributes:e}){const[t]=Pt();return v.useEffect(()=>{if(!t.hasNodes([Or]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:l}=n;return $i(s,{...e,rel:o,target:i,title:l}),!0}},Hr),r!==void 0?t.registerCommand(si,n=>{const s=se();if(!U(s)||s.isCollapsed()||!gr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(l=>P(l))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Hr):()=>{})},[t,r,e]),null}function ig(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Mc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function og({src:r,alt:e,width:t,height:n}){return h.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends sa{constructor(t,n,s,i,o){super(o);Et(this,"__src");Et(this,"__altText");Et(this,"__width");Et(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Mc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:ig,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return h.jsx(og,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Mc(r){return new vi(r.src,r.altText,r.width,r.height)}var ag=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,jc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?ag(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,xo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))jc.call(e,t)&&Il(r,t,e[t]);return r},bo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&jc.call(r,n)&&(t[n]=r[n]);return t};/**
96
96
  * @license QR Code generator library (TypeScript)
97
97
  * Copyright (c) Project Nayuki.
98
98
  * SPDX-License-Identifier: MIT
99
- */var jr;(r=>{const e=class ye{constructor(a,u,c,d){if(this.version=a,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],a<ye.MIN_VERSION||a>ye.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=a*4+17;let f=[];for(let g=0;g<this.size;g++)f.push(!1);for(let g=0;g<this.size;g++)this.modules.push(f.slice()),this.isFunction.push(f.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(c);if(this.drawCodewords(p),d==-1){let g=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const x=this.getPenaltyScore();x<g&&(d=m,g=x),this.applyMask(m)}}s(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(a,u){const c=r.QrSegment.makeSegments(a);return ye.encodeSegments(c,u)}static encodeBinary(a,u){const c=r.QrSegment.makeBytes(a);return ye.encodeSegments([c],u)}static encodeSegments(a,u,c=1,d=40,f=-1,p=!0){if(!(ye.MIN_VERSION<=c&&c<=d&&d<=ye.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const C=ye.getNumDataCodewords(g,u)*8,S=o.getTotalBits(a,g);if(S<=C){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const C of[ye.Ecc.MEDIUM,ye.Ecc.QUARTILE,ye.Ecc.HIGH])p&&m<=ye.getNumDataCodewords(g,C)*8&&(u=C);let x=[];for(const C of a){t(C.mode.modeBits,4,x),t(C.numChars,C.mode.numCharCountBits(g),x);for(const S of C.getData())x.push(S)}s(x.length==m);const v=ye.getNumDataCodewords(g,u)*8;s(x.length<=v),t(0,Math.min(4,v-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let C=236;x.length<v;C^=253)t(C,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((C,S)=>b[S>>>3]|=C<<7-(S&7)),new ye(g,u,b,f)}getModule(a,u){return 0<=a&&a<this.size&&0<=u&&u<this.size&&this.modules[u][a]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const a=this.getAlignmentPatternPositions(),u=a.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(a[c],a[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(a){const u=this.errorCorrectionLevel.formatBits<<3|a;let c=u;for(let f=0;f<10;f++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let f=0;f<=5;f++)this.setFunctionModule(8,f,n(d,f));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let f=9;f<15;f++)this.setFunctionModule(14-f,8,n(d,f));for(let f=0;f<8;f++)this.setFunctionModule(this.size-1-f,8,n(d,f));for(let f=8;f<15;f++)this.setFunctionModule(8,this.size-15+f,n(d,f));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let a=this.version;for(let c=0;c<12;c++)a=a<<1^(a>>>11)*7973;const u=this.version<<12|a;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),f=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(f,p,d),this.setFunctionModule(p,f,d)}}drawFinderPattern(a,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const f=Math.max(Math.abs(d),Math.abs(c)),p=a+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,f!=2&&f!=4)}}drawAlignmentPattern(a,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(a+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(a,u,c){this.modules[u][a]=c,this.isFunction[u][a]=!0}addEccAndInterleave(a){const u=this.version,c=this.errorCorrectionLevel;if(a.length!=ye.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=ye.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=ye.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(ye.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const v=ye.reedSolomonComputeDivisor(f);for(let C=0,S=0;C<d;C++){let D=a.slice(S,S+m-f+(C<g?0:1));S+=D.length;const w=ye.reedSolomonComputeRemainder(D,v);C<g&&D.push(0),x.push(D.concat(w))}let b=[];for(let C=0;C<x[0].length;C++)x.forEach((S,D)=>{(C!=m-f||D>=g)&&b.push(S[C])});return s(b.length==p),b}drawCodewords(a){if(a.length!=Math.floor(ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let d=0;d<this.size;d++)for(let f=0;f<2;f++){const p=c-f,m=(c+1&2)==0?this.size-1-d:d;!this.isFunction[m][p]&&u<a.length*8&&(this.modules[m][p]=n(a[u>>>3],7-(u&7)),u++)}}s(u==a.length*8)}applyMask(a){if(a<0||a>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(a){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let a=0;for(let f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[f][x]==p?(g++,g==5?a+=ye.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*ye.PENALTY_N3),p=this.modules[f][x],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*ye.PENALTY_N3}for(let f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][f]==p?(g++,g==5?a+=ye.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*ye.PENALTY_N3),p=this.modules[x][f],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*ye.PENALTY_N3}for(let f=0;f<this.size-1;f++)for(let p=0;p<this.size-1;p++){const g=this.modules[f][p];g==this.modules[f][p+1]&&g==this.modules[f+1][p]&&g==this.modules[f+1][p+1]&&(a+=ye.PENALTY_N2)}let u=0;for(const f of this.modules)u=f.reduce((p,g)=>p+(g?1:0),u);const c=this.size*this.size,d=Math.ceil(Math.abs(u*20-c*10)/c)-1;return s(0<=d&&d<=9),a+=d*ye.PENALTY_N4,s(0<=a&&a<=2568888),a}getAlignmentPatternPositions(){if(this.version==1)return[];{const a=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(a*2-2))*2;let c=[6];for(let d=this.size-7;c.length<a;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(a){if(a<ye.MIN_VERSION||a>ye.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*a+128)*a+64;if(a>=2){const c=Math.floor(a/7)+2;u-=(25*c-10)*c-55,a>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(a,u){return Math.floor(ye.getNumRawDataModules(a)/8)-ye.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a]*ye.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][a]}static reedSolomonComputeDivisor(a){if(a<1||a>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<a-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<a;d++){for(let f=0;f<u.length;f++)u[f]=ye.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=ye.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(a,u){let c=u.map(d=>0);for(const d of a){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=ye.reedSolomonMultiply(p,f))}return c}static reedSolomonMultiply(a,u){if(a>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*a;return s(c>>>8==0),c}finderPenaltyCountPatterns(a){const u=a[1];s(u<=this.size*3);const c=u>0&&a[2]==u&&a[3]==u*3&&a[4]==u&&a[5]==u;return(c&&a[0]>=u*4&&a[6]>=u?1:0)+(c&&a[6]>=u*4&&a[0]>=u?1:0)}finderPenaltyTerminateAndCount(a,u,c){return a&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(a,u){u[0]==0&&(a+=this.size),u.pop(),u.unshift(a)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(l,a,u){if(a<0||a>31||l>>>a)throw new RangeError("Value out of range");for(let c=a-1;c>=0;c--)u.push(l>>>c&1)}function n(l,a){return(l>>>a&1)!=0}function s(l){if(!l)throw new Error("Assertion error")}const i=class Oe{constructor(a,u,c){if(this.mode=a,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(a){let u=[];for(const c of a)t(c,8,u);return new Oe(Oe.Mode.BYTE,a.length,u)}static makeNumeric(a){if(!Oe.isNumeric(a))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<a.length;){const d=Math.min(a.length-c,3);t(parseInt(a.substring(c,c+d),10),d*3+1,u),c+=d}return new Oe(Oe.Mode.NUMERIC,a.length,u)}static makeAlphanumeric(a){if(!Oe.isAlphanumeric(a))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=a.length;c+=2){let d=Oe.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c))*45;d+=Oe.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c+1)),t(d,11,u)}return c<a.length&&t(Oe.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c)),6,u),new Oe(Oe.Mode.ALPHANUMERIC,a.length,u)}static makeSegments(a){return a==""?[]:Oe.isNumeric(a)?[Oe.makeNumeric(a)]:Oe.isAlphanumeric(a)?[Oe.makeAlphanumeric(a)]:[Oe.makeBytes(Oe.toUtf8ByteArray(a))]}static makeEci(a){let u=[];if(a<0)throw new RangeError("ECI assignment value out of range");if(a<128)t(a,8,u);else if(a<16384)t(2,2,u),t(a,14,u);else if(a<1e6)t(6,3,u),t(a,21,u);else throw new RangeError("ECI assignment value out of range");return new Oe(Oe.Mode.ECI,0,u)}static isNumeric(a){return Oe.NUMERIC_REGEX.test(a)}static isAlphanumeric(a){return Oe.ALPHANUMERIC_REGEX.test(a)}getData(){return this.bitData.slice()}static getTotalBits(a,u){let c=0;for(const d of a){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+d.bitData.length}return c}static toUtf8ByteArray(a){a=encodeURI(a);let u=[];for(let c=0;c<a.length;c++)a.charAt(c)!="%"?u.push(a.charCodeAt(c)):(u.push(parseInt(a.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(jr||(jr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(jr||(jr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(jr||(jr={}));var Gr=jr;/**
99
+ */var jr;(r=>{const e=class De{constructor(a,u,c,d){if(this.version=a,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],a<De.MIN_VERSION||a>De.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=a*4+17;let f=[];for(let g=0;g<this.size;g++)f.push(!1);for(let g=0;g<this.size;g++)this.modules.push(f.slice()),this.isFunction.push(f.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(c);if(this.drawCodewords(p),d==-1){let g=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const x=this.getPenaltyScore();x<g&&(d=m,g=x),this.applyMask(m)}}s(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(a,u){const c=r.QrSegment.makeSegments(a);return De.encodeSegments(c,u)}static encodeBinary(a,u){const c=r.QrSegment.makeBytes(a);return De.encodeSegments([c],u)}static encodeSegments(a,u,c=1,d=40,f=-1,p=!0){if(!(De.MIN_VERSION<=c&&c<=d&&d<=De.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const C=De.getNumDataCodewords(g,u)*8,S=o.getTotalBits(a,g);if(S<=C){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const C of[De.Ecc.MEDIUM,De.Ecc.QUARTILE,De.Ecc.HIGH])p&&m<=De.getNumDataCodewords(g,C)*8&&(u=C);let x=[];for(const C of a){t(C.mode.modeBits,4,x),t(C.numChars,C.mode.numCharCountBits(g),x);for(const S of C.getData())x.push(S)}s(x.length==m);const w=De.getNumDataCodewords(g,u)*8;s(x.length<=w),t(0,Math.min(4,w-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let C=236;x.length<w;C^=253)t(C,8,x);let y=[];for(;y.length*8<x.length;)y.push(0);return x.forEach((C,S)=>y[S>>>3]|=C<<7-(S&7)),new De(g,u,y,f)}getModule(a,u){return 0<=a&&a<this.size&&0<=u&&u<this.size&&this.modules[u][a]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const a=this.getAlignmentPatternPositions(),u=a.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(a[c],a[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(a){const u=this.errorCorrectionLevel.formatBits<<3|a;let c=u;for(let f=0;f<10;f++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let f=0;f<=5;f++)this.setFunctionModule(8,f,n(d,f));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let f=9;f<15;f++)this.setFunctionModule(14-f,8,n(d,f));for(let f=0;f<8;f++)this.setFunctionModule(this.size-1-f,8,n(d,f));for(let f=8;f<15;f++)this.setFunctionModule(8,this.size-15+f,n(d,f));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let a=this.version;for(let c=0;c<12;c++)a=a<<1^(a>>>11)*7973;const u=this.version<<12|a;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),f=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(f,p,d),this.setFunctionModule(p,f,d)}}drawFinderPattern(a,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const f=Math.max(Math.abs(d),Math.abs(c)),p=a+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,f!=2&&f!=4)}}drawAlignmentPattern(a,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(a+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(a,u,c){this.modules[u][a]=c,this.isFunction[u][a]=!0}addEccAndInterleave(a){const u=this.version,c=this.errorCorrectionLevel;if(a.length!=De.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=De.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=De.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(De.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const w=De.reedSolomonComputeDivisor(f);for(let C=0,S=0;C<d;C++){let D=a.slice(S,S+m-f+(C<g?0:1));S+=D.length;const _=De.reedSolomonComputeRemainder(D,w);C<g&&D.push(0),x.push(D.concat(_))}let y=[];for(let C=0;C<x[0].length;C++)x.forEach((S,D)=>{(C!=m-f||D>=g)&&y.push(S[C])});return s(y.length==p),y}drawCodewords(a){if(a.length!=Math.floor(De.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let d=0;d<this.size;d++)for(let f=0;f<2;f++){const p=c-f,m=(c+1&2)==0?this.size-1-d:d;!this.isFunction[m][p]&&u<a.length*8&&(this.modules[m][p]=n(a[u>>>3],7-(u&7)),u++)}}s(u==a.length*8)}applyMask(a){if(a<0||a>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(a){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let a=0;for(let f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[f][x]==p?(g++,g==5?a+=De.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*De.PENALTY_N3),p=this.modules[f][x],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*De.PENALTY_N3}for(let f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][f]==p?(g++,g==5?a+=De.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*De.PENALTY_N3),p=this.modules[x][f],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*De.PENALTY_N3}for(let f=0;f<this.size-1;f++)for(let p=0;p<this.size-1;p++){const g=this.modules[f][p];g==this.modules[f][p+1]&&g==this.modules[f+1][p]&&g==this.modules[f+1][p+1]&&(a+=De.PENALTY_N2)}let u=0;for(const f of this.modules)u=f.reduce((p,g)=>p+(g?1:0),u);const c=this.size*this.size,d=Math.ceil(Math.abs(u*20-c*10)/c)-1;return s(0<=d&&d<=9),a+=d*De.PENALTY_N4,s(0<=a&&a<=2568888),a}getAlignmentPatternPositions(){if(this.version==1)return[];{const a=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(a*2-2))*2;let c=[6];for(let d=this.size-7;c.length<a;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(a){if(a<De.MIN_VERSION||a>De.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*a+128)*a+64;if(a>=2){const c=Math.floor(a/7)+2;u-=(25*c-10)*c-55,a>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(a,u){return Math.floor(De.getNumRawDataModules(a)/8)-De.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a]*De.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][a]}static reedSolomonComputeDivisor(a){if(a<1||a>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<a-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<a;d++){for(let f=0;f<u.length;f++)u[f]=De.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=De.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(a,u){let c=u.map(d=>0);for(const d of a){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=De.reedSolomonMultiply(p,f))}return c}static reedSolomonMultiply(a,u){if(a>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*a;return s(c>>>8==0),c}finderPenaltyCountPatterns(a){const u=a[1];s(u<=this.size*3);const c=u>0&&a[2]==u&&a[3]==u*3&&a[4]==u&&a[5]==u;return(c&&a[0]>=u*4&&a[6]>=u?1:0)+(c&&a[6]>=u*4&&a[0]>=u?1:0)}finderPenaltyTerminateAndCount(a,u,c){return a&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(a,u){u[0]==0&&(a+=this.size),u.pop(),u.unshift(a)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(l,a,u){if(a<0||a>31||l>>>a)throw new RangeError("Value out of range");for(let c=a-1;c>=0;c--)u.push(l>>>c&1)}function n(l,a){return(l>>>a&1)!=0}function s(l){if(!l)throw new Error("Assertion error")}const i=class Ve{constructor(a,u,c){if(this.mode=a,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(a){let u=[];for(const c of a)t(c,8,u);return new Ve(Ve.Mode.BYTE,a.length,u)}static makeNumeric(a){if(!Ve.isNumeric(a))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<a.length;){const d=Math.min(a.length-c,3);t(parseInt(a.substring(c,c+d),10),d*3+1,u),c+=d}return new Ve(Ve.Mode.NUMERIC,a.length,u)}static makeAlphanumeric(a){if(!Ve.isAlphanumeric(a))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=a.length;c+=2){let d=Ve.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c))*45;d+=Ve.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c+1)),t(d,11,u)}return c<a.length&&t(Ve.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c)),6,u),new Ve(Ve.Mode.ALPHANUMERIC,a.length,u)}static makeSegments(a){return a==""?[]:Ve.isNumeric(a)?[Ve.makeNumeric(a)]:Ve.isAlphanumeric(a)?[Ve.makeAlphanumeric(a)]:[Ve.makeBytes(Ve.toUtf8ByteArray(a))]}static makeEci(a){let u=[];if(a<0)throw new RangeError("ECI assignment value out of range");if(a<128)t(a,8,u);else if(a<16384)t(2,2,u),t(a,14,u);else if(a<1e6)t(6,3,u),t(a,21,u);else throw new RangeError("ECI assignment value out of range");return new Ve(Ve.Mode.ECI,0,u)}static isNumeric(a){return Ve.NUMERIC_REGEX.test(a)}static isAlphanumeric(a){return Ve.ALPHANUMERIC_REGEX.test(a)}getData(){return this.bitData.slice()}static getTotalBits(a,u){let c=0;for(const d of a){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+d.bitData.length}return c}static toUtf8ByteArray(a){a=encodeURI(a);let u=[];for(let c=0;c<a.length;c++)a.charAt(c)!="%"?u.push(a.charCodeAt(c)):(u.push(parseInt(a.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(jr||(jr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(jr||(jr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(jr||(jr={}));var Gr=jr;/**
100
100
  * @license qrcode.react
101
101
  * Copyright (c) Paul O'Shannessy
102
102
  * SPDX-License-Identifier: ISC
103
- */var ag={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},jc=128,Lc="L",Pc="#FFFFFF",Oc="#000000",Ic=!1,zc=1,lg=4,ug=0,cg=.1;function $c(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,l){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${l-i}v1H${i+e}z`),i=null;return}if(l===n.length-1){if(!o)return;i===null?t.push(`M${l+e},${s+e} h1v1H${l+e}z`):t.push(`M${i+e},${s+e} h${l+1-i}v1H${i+e}z`);return}o&&i===null&&(i=l)})}),t.join("")}function qc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function dg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*cg),o=s/e,l=(n.width||i)*o,a=(n.height||i)*o,u=n.x==null?r.length/2-l/2:n.x*o,c=n.y==null?r.length/2-a/2:n.y*o,d=n.opacity==null?1:n.opacity;let f=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(l+u-g),v=Math.ceil(a+c-m);f={x:g,y:m,w:x,h:v}}const p=n.crossOrigin;return{x:u,y:c,h:a,w:l,excavation:f,opacity:d,crossOrigin:p}}function fg(r,e){return e!=null?Math.max(Math.floor(e),0):r?lg:ug}function Uc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:l}){let a=_.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,ag[e],t,void 0,void 0,l)},[r,e,t,l]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=_.useMemo(()=>{let p=a.getModules();const g=fg(n,s),m=p.length+g*2,x=dg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[a,o,i,n,s]);return{qrcode:a,margin:c,cells:u,numCells:d,calculatedImageSettings:f}}var hg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),pg=_.forwardRef(function(e,t){const n=e,{value:s,size:i=jc,level:o=Lc,bgColor:l=Pc,fgColor:a=Oc,includeMargin:u=Ic,minVersion:c=zc,boostLevel:d,marginSize:f,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,v=xo(m,["style"]),b=p==null?void 0:p.src,C=_.useRef(null),S=_.useRef(null),D=_.useCallback(E=>{C.current=E,typeof t=="function"?t(E):t&&(t.current=E)},[t]),[w,y]=_.useState(!1),{margin:k,cells:N,numCells:F,calculatedImageSettings:T}=Uc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});_.useEffect(()=>{if(C.current!=null){const E=C.current,B=E.getContext("2d");if(!B)return;let R=N;const O=S.current,H=T!=null&&O!==null&&O.complete&&O.naturalHeight!==0&&O.naturalWidth!==0;H&&T.excavation!=null&&(R=qc(N,T.excavation));const U=window.devicePixelRatio||1;E.height=E.width=i*U;const Z=i/F*U;B.scale(Z,Z),B.fillStyle=l,B.fillRect(0,0,F,F),B.fillStyle=a,hg?B.fill(new Path2D($c(R,k))):N.forEach(function(q,K){q.forEach(function($,re){$&&B.fillRect(re+k,K+k,1,1)})}),T&&(B.globalAlpha=T.opacity),H&&B.drawImage(O,T.x+k,T.y+k,T.w,T.h)}}),_.useEffect(()=>{y(!1)},[b]);const M=yo({height:i,width:i},x);let L=null;return b!=null&&(L=_.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{y(!0)},ref:S,crossOrigin:T==null?void 0:T.crossOrigin})),_.createElement(_.Fragment,null,_.createElement("canvas",yo({style:M,height:i,width:i,ref:D,role:"img"},v)),L)});pg.displayName="QRCodeCanvas";var Wc=_.forwardRef(function(e,t){const n=e,{value:s,size:i=jc,level:o=Lc,bgColor:l=Pc,fgColor:a=Oc,includeMargin:u=Ic,minVersion:c=zc,boostLevel:d,title:f,marginSize:p,imageSettings:g}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:v,numCells:b,calculatedImageSettings:C}=Uc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=v,D=null;g!=null&&C!=null&&(C.excavation!=null&&(S=qc(v,C.excavation)),D=_.createElement("image",{href:g.src,height:C.h,width:C.w,x:C.x+x,y:C.y+x,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const w=$c(S,x);return _.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!f&&_.createElement("title",null,f),_.createElement("path",{fill:l,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),_.createElement("path",{fill:a,d:w,shapeRendering:"crispEdges"}),D)});Wc.displayName="QRCodeSVG";function gg(r){if(r instanceof HTMLElement&&r.dataset.qrcodeData){const e=r.dataset.qrcodeData,t=r.dataset.qrcodeSize?parseInt(r.dataset.qrcodeSize,10):void 0;return{node:la({data:e,size:t})}}return null}function mg({data:r,size:e=150}){return h.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:h.jsx(Wc,{value:r,size:e,level:"M"})})}class un extends na{constructor(t,n=150,s){super(s);St(this,"__data");St(this,"__size");this.__data=t,this.__size=n}static getType(){return"qrcode"}static clone(t){return new un(t.__data,t.__size,t.__key)}static importJSON(t){const{data:n,size:s}=t;return la({data:n,size:s})}exportJSON(){return{type:"qrcode",version:1,data:this.__data,size:this.__size}}static importDOM(){return{div:t=>t.dataset.qrcodeData?{conversion:gg,priority:1}:null}}exportDOM(){const t=document.createElement("div");return t.dataset.qrcodeData=this.__data,t.dataset.qrcodeSize=String(this.__size),t.style.display="inline-block",t.style.background="#f9f9f9",t.style.padding="12px",t.style.borderRadius="8px",t.textContent="[QR Code]",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return h.jsx(mg,{data:this.__data,size:this.__size})}getData(){return this.__data}getSize(){return this.__size}}function la(r){return new un(r.data,r.size)}function yg(r){return r instanceof un}const xg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},bg={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function _g({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:l,hasContent:a}){const[u]=Lt(),[c,d]=_.useState(!1),f=_.useRef(null),p=t||n||s,g=_.useCallback(()=>{u.dispatchCommand(Mt,"bold")},[u]),m=_.useCallback(()=>{u.dispatchCommand(Mt,"italic")},[u]),x=_.useCallback(()=>{u.dispatchCommand(Mt,"underline")},[u]),v=_.useCallback(()=>{u.dispatchCommand(Nc,void 0)},[u]),b=_.useCallback(()=>{u.dispatchCommand(Bc,void 0)},[u]),C=_.useCallback(()=>{u.update(()=>{const y=te();z(y)&&Jh(y,()=>oa())})},[u]),S={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},D=`
103
+ */var lg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Lc=128,Pc="L",Ic="#FFFFFF",Oc="#000000",zc=!1,$c=1,ug=4,cg=0,dg=.1;function qc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,l){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${l-i}v1H${i+e}z`),i=null;return}if(l===n.length-1){if(!o)return;i===null?t.push(`M${l+e},${s+e} h1v1H${l+e}z`):t.push(`M${i+e},${s+e} h${l+1-i}v1H${i+e}z`);return}o&&i===null&&(i=l)})}),t.join("")}function Uc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function fg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*dg),o=s/e,l=(n.width||i)*o,a=(n.height||i)*o,u=n.x==null?r.length/2-l/2:n.x*o,c=n.y==null?r.length/2-a/2:n.y*o,d=n.opacity==null?1:n.opacity;let f=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(l+u-g),w=Math.ceil(a+c-m);f={x:g,y:m,w:x,h:w}}const p=n.crossOrigin;return{x:u,y:c,h:a,w:l,excavation:f,opacity:d,crossOrigin:p}}function hg(r,e){return e!=null?Math.max(Math.floor(e),0):r?ug:cg}function Wc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:l}){let a=v.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,lg[e],t,void 0,void 0,l)},[r,e,t,l]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=v.useMemo(()=>{let p=a.getModules();const g=hg(n,s),m=p.length+g*2,x=fg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[a,o,i,n,s]);return{qrcode:a,margin:c,cells:u,numCells:d,calculatedImageSettings:f}}var pg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),gg=v.forwardRef(function(e,t){const n=e,{value:s,size:i=Lc,level:o=Pc,bgColor:l=Ic,fgColor:a=Oc,includeMargin:u=zc,minVersion:c=$c,boostLevel:d,marginSize:f,imageSettings:p}=n,m=bo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,w=bo(m,["style"]),y=p==null?void 0:p.src,C=v.useRef(null),S=v.useRef(null),D=v.useCallback(k=>{C.current=k,typeof t=="function"?t(k):t&&(t.current=k)},[t]),[_,b]=v.useState(!1),{margin:E,cells:N,numCells:R,calculatedImageSettings:T}=Wc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});v.useEffect(()=>{if(C.current!=null){const k=C.current,B=k.getContext("2d");if(!B)return;let M=N;const I=S.current,W=T!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;W&&T.excavation!=null&&(M=Uc(N,T.excavation));const $=window.devicePixelRatio||1;k.height=k.width=i*$;const ee=i/R*$;B.scale(ee,ee),B.fillStyle=l,B.fillRect(0,0,R,R),B.fillStyle=a,pg?B.fill(new Path2D(qc(M,E))):N.forEach(function(q,Y){q.forEach(function(z,ie){z&&B.fillRect(ie+E,Y+E,1,1)})}),T&&(B.globalAlpha=T.opacity),W&&B.drawImage(I,T.x+E,T.y+E,T.w,T.h)}}),v.useEffect(()=>{b(!1)},[y]);const F=xo({height:i,width:i},x);let L=null;return y!=null&&(L=v.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{b(!0)},ref:S,crossOrigin:T==null?void 0:T.crossOrigin})),v.createElement(v.Fragment,null,v.createElement("canvas",xo({style:F,height:i,width:i,ref:D,role:"img"},w)),L)});gg.displayName="QRCodeCanvas";var Vc=v.forwardRef(function(e,t){const n=e,{value:s,size:i=Lc,level:o=Pc,bgColor:l=Ic,fgColor:a=Oc,includeMargin:u=zc,minVersion:c=$c,boostLevel:d,title:f,marginSize:p,imageSettings:g}=n,m=bo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:w,numCells:y,calculatedImageSettings:C}=Wc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=w,D=null;g!=null&&C!=null&&(C.excavation!=null&&(S=Uc(w,C.excavation)),D=v.createElement("image",{href:g.src,height:C.h,width:C.w,x:C.x+x,y:C.y+x,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const _=qc(S,x);return v.createElement("svg",xo({height:i,width:i,viewBox:`0 0 ${y} ${y}`,ref:t,role:"img"},m),!!f&&v.createElement("title",null,f),v.createElement("path",{fill:l,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),v.createElement("path",{fill:a,d:_,shapeRendering:"crispEdges"}),D)});Vc.displayName="QRCodeSVG";function mg(r){if(r instanceof HTMLElement&&r.dataset.qrcodeData){const e=r.dataset.qrcodeData,t=r.dataset.qrcodeSize?parseInt(r.dataset.qrcodeSize,10):void 0;return{node:ua({data:e,size:t})}}return null}function yg({data:r,size:e=150}){return h.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:h.jsx(Vc,{value:r,size:e,level:"M"})})}class un extends sa{constructor(t,n=150,s){super(s);Et(this,"__data");Et(this,"__size");this.__data=t,this.__size=n}static getType(){return"qrcode"}static clone(t){return new un(t.__data,t.__size,t.__key)}static importJSON(t){const{data:n,size:s}=t;return ua({data:n,size:s})}exportJSON(){return{type:"qrcode",version:1,data:this.__data,size:this.__size}}static importDOM(){return{div:t=>t.dataset.qrcodeData?{conversion:mg,priority:1}:null}}exportDOM(){const t=document.createElement("div");return t.dataset.qrcodeData=this.__data,t.dataset.qrcodeSize=String(this.__size),t.style.display="inline-block",t.style.background="#f9f9f9",t.style.padding="12px",t.style.borderRadius="8px",t.textContent="[QR Code]",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return h.jsx(yg,{data:this.__data,size:this.__size})}getData(){return this.__data}getSize(){return this.__size}}function ua(r){return new un(r.data,r.size)}function xg(r){return r instanceof un}const bg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},vg={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function _g({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:l,hasContent:a}){const[u]=Pt(),[c,d]=v.useState(!1),f=v.useRef(null),p=t||n||s,g=v.useCallback(()=>{u.dispatchCommand(jt,"bold")},[u]),m=v.useCallback(()=>{u.dispatchCommand(jt,"italic")},[u]),x=v.useCallback(()=>{u.dispatchCommand(jt,"underline")},[u]),w=v.useCallback(()=>{u.dispatchCommand(Bc,void 0)},[u]),y=v.useCallback(()=>{u.dispatchCommand(Rc,void 0)},[u]),C=v.useCallback(()=>{u.update(()=>{const b=se();U(b)&&Zh(b,()=>aa())})},[u]),S={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},D=`
104
104
  .mail-editor-toolbar-btn:hover:not(:disabled) {
105
105
  background: ${r.border};
106
106
  }
107
- `,w=()=>{setTimeout(()=>{var y;(y=f.current)!=null&&y.contains(document.activeElement)||d(!1)},150)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[h.jsx("style",{children:D}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:S,title:"Bold (Ctrl+B)",children:"B"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...S,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...S,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:v,disabled:e,style:S,title:"Bullet List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("circle",{cx:"4",cy:"6",r:"2"}),h.jsx("circle",{cx:"4",cy:"12",r:"2"}),h.jsx("circle",{cx:"4",cy:"18",r:"2"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:S,title:"Numbered List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),h.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),h.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:C,disabled:e,style:S,title:"Quote",children:h.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&h.jsxs("div",{style:{position:"relative"},ref:f,children:[h.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!a||e,onBlur:w,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!a?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!a||e?"not-allowed":"pointer",opacity:i||!a?.5:1},children:i?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),o==="restructure"&&"Restructuring...",o==="proofread"&&"Proofreading...",o==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&h.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&h.jsxs("button",{type:"button",onClick:()=>{l==null||l("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:y=>y.currentTarget.style.background="#f3f4f6",onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Restructure"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&h.jsxs("button",{type:"button",onClick:()=>{l==null||l("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:y=>y.currentTarget.style.background="#f3f4f6",onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Proofread"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&h.jsxs("button",{type:"button",onClick:()=>{l==null||l("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:y=>y.currentTarget.style.background="#f3f4f6",onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function vg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=Lt(),s=_.useRef(!1);return _.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Pe();i.clear();const o=He();i.append(o),o.select();const a=new DOMParser().parseFromString(r,"text/html"),c=vc(n,a).filter(d=>d.getParent()===null);c.length>0&&oc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function wg({text:r,trigger:e}){const[t]=Lt(),n=_.useRef(void 0);return _.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=te();if(z(i))i.insertText(s);else{const o=Pe(),l=o.getLastChild();if(l){l.selectEnd();const a=te();z(a)&&a.insertText(s)}else{const a=He(),u=Ke(s);a.append(u),o.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Cg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return h.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[h.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),h.jsx("blockquote",{style:{margin:0,padding:"12px 16px",borderLeft:`3px solid ${e.quoteBorder}`,background:e.quoteBackground,fontSize:"14px",color:e.textSecondary,maxHeight:"200px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:r.body}})]})}function Vc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:l="200px",externalUpdate:a,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const v={...xg,...s},[b,C]=_.useState(!1),S=_.useRef(void 0),[D,w]=_.useState(r),[y,k]=_.useState(!1),[N,F]=_.useState(null),T=g??y,M=m??N;_.useEffect(()=>{a!==void 0&&a!==S.current&&(S.current=a,C(!0))},[a]);const L=_.useCallback(()=>{C(!1)},[]),E=q=>q.replace(/<[^>]*>/g,"").trim(),B=q=>q.split(`
108
- `).map(K=>`<p>${K||"<br>"}</p>`).join(""),R=async q=>{const K=E(D);if(!K)return;const $=q==="restructure"?d:q==="proofread"?f:p;if($){k(!0),F(q);try{const re=await $(K),ae=B(re);w(ae),e==null||e(ae),S.current=Date.now(),C(!0)}catch(re){console.error(`AI ${q} failed:`,re)}finally{k(!1),F(null)}}},O=E(D).length>0,H={namespace:"MailEditor",theme:bg,onError:q=>{console.error("Lexical error:",q)},nodes:[ln,Or,Ir,ss,bi,xi,_i,un],editable:!i},U=_.useCallback((q,K)=>{q.read(()=>{const $=wc(K,null);w($),e==null||e($)})},[e]),Z=`
107
+ `,_=()=>{setTimeout(()=>{var b;(b=f.current)!=null&&b.contains(document.activeElement)||d(!1)},150)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[h.jsx("style",{children:D}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:S,title:"Bold (Ctrl+B)",children:"B"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...S,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...S,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:w,disabled:e,style:S,title:"Bullet List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("circle",{cx:"4",cy:"6",r:"2"}),h.jsx("circle",{cx:"4",cy:"12",r:"2"}),h.jsx("circle",{cx:"4",cy:"18",r:"2"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:y,disabled:e,style:S,title:"Numbered List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),h.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),h.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:C,disabled:e,style:S,title:"Quote",children:h.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&h.jsxs("div",{style:{position:"relative"},ref:f,children:[h.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!a||e,onBlur:_,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!a?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!a||e?"not-allowed":"pointer",opacity:i||!a?.5:1},children:i?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),o==="restructure"&&"Restructuring...",o==="proofread"&&"Proofreading...",o==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&h.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&h.jsxs("button",{type:"button",onClick:()=>{l==null||l("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:b=>b.currentTarget.style.background="#f3f4f6",onMouseLeave:b=>b.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Restructure"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&h.jsxs("button",{type:"button",onClick:()=>{l==null||l("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:b=>b.currentTarget.style.background="#f3f4f6",onMouseLeave:b=>b.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Proofread"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&h.jsxs("button",{type:"button",onClick:()=>{l==null||l("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:b=>b.currentTarget.style.background="#f3f4f6",onMouseLeave:b=>b.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function wg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=Pt(),s=v.useRef(!1);return v.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=We();i.clear();const o=et();i.append(o),o.select();const a=new DOMParser().parseFromString(r,"text/html"),c=wc(n,a).filter(d=>d.getParent()===null);c.length>0&&ac(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Cg({text:r,trigger:e}){const[t]=Pt(),n=v.useRef(void 0);return v.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=se();if(U(i))i.insertText(s);else{const o=We(),l=o.getLastChild();if(l){l.selectEnd();const a=se();U(a)&&a.insertText(s)}else{const a=et(),u=rt(s);a.append(u),o.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Sg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return h.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[h.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),h.jsx("blockquote",{style:{margin:0,padding:"12px 16px",borderLeft:`3px solid ${e.quoteBorder}`,background:e.quoteBackground,fontSize:"14px",color:e.textSecondary,maxHeight:"200px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:r.body}})]})}function Hc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:l="200px",externalUpdate:a,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const w={...bg,...s},[y,C]=v.useState(!1),S=v.useRef(void 0),[D,_]=v.useState(r),[b,E]=v.useState(!1),[N,R]=v.useState(null),T=g??b,F=m??N;v.useEffect(()=>{a!==void 0&&a!==S.current&&(S.current=a,C(!0))},[a]);const L=v.useCallback(()=>{C(!1)},[]),k=q=>q.replace(/<[^>]*>/g,"").trim(),B=q=>q.split(`
108
+ `).map(Y=>`<p>${Y||"<br>"}</p>`).join(""),M=async q=>{const Y=k(D);if(!Y)return;const z=q==="restructure"?d:q==="proofread"?f:p;if(z){E(!0),R(q);try{const ie=await z(Y),ce=B(ie);_(ce),e==null||e(ce),S.current=Date.now(),C(!0)}catch(ie){console.error(`AI ${q} failed:`,ie)}finally{E(!1),R(null)}}},I=k(D).length>0,W={namespace:"MailEditor",theme:vg,onError:q=>{console.error("Lexical error:",q)},nodes:[ln,Ir,Or,ss,bi,xi,vi,un],editable:!i},$=v.useCallback((q,Y)=>{q.read(()=>{const z=Cc(Y,null);_(z),e==null||e(z)})},[e]),ee=`
109
109
  .mail-editor-paragraph {
110
110
  margin: 0 0 8px 0;
111
111
  line-height: 1.5;
@@ -127,15 +127,15 @@ React keys must be passed directly to JSX without using spread:
127
127
  margin: 4px 0;
128
128
  }
129
129
  .mail-editor-link {
130
- color: ${v.primary};
130
+ color: ${w.primary};
131
131
  text-decoration: underline;
132
132
  }
133
133
  .mail-editor-quote {
134
134
  margin: 8px 0;
135
135
  padding: 8px 16px;
136
- border-left: 3px solid ${v.quoteBorder};
137
- background: ${v.quoteBackground};
138
- color: ${v.textSecondary};
136
+ border-left: 3px solid ${w.quoteBorder};
137
+ background: ${w.quoteBackground};
138
+ color: ${w.textSecondary};
139
139
  }
140
140
  .mail-editor-h1 {
141
141
  font-size: 24px;
@@ -158,7 +158,7 @@ React keys must be passed directly to JSX without using spread:
158
158
  padding: 16px;
159
159
  font-size: 14px;
160
160
  line-height: 1.6;
161
- color: ${v.text};
161
+ color: ${w.text};
162
162
  }
163
163
  .mail-editor-content:focus {
164
164
  outline: none;
@@ -167,7 +167,7 @@ React keys must be passed directly to JSX without using spread:
167
167
  position: absolute;
168
168
  top: 16px;
169
169
  left: 16px;
170
- color: ${v.textSecondary};
170
+ color: ${w.textSecondary};
171
171
  pointer-events: none;
172
172
  font-size: 14px;
173
173
  }
@@ -175,14 +175,14 @@ React keys must be passed directly to JSX without using spread:
175
175
  from { transform: rotate(0deg); }
176
176
  to { transform: rotate(360deg); }
177
177
  }
178
- `;return h.jsxs("div",{className:o,style:{border:`1px solid ${v.border}`,borderRadius:"8px",background:v.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:Z}),x,h.jsxs(Ih,{initialConfig:H,children:[h.jsx(_g,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:M,onAiAction:R,hasContent:O}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Cp,{contentEditable:h.jsx(Dp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:v.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:$p})}),h.jsx(Zp,{}),h.jsx(ng,{}),h.jsx(Pp,{}),h.jsx(Ip,{onChange:U}),h.jsx(vg,{html:b?D:r,isExternalUpdate:b,onImportComplete:L}),h.jsx(wg,{text:u,trigger:c})]}),n&&h.jsx(Cg,{replyTo:n,theme:v})]})}const Sg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function Eg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:l,insertText:a,insertTextTrigger:u,theme:c={},disabled:d=!1,showCcBcc:f=!1,placeholder:p="Write your message...",className:g="",minHeight:m="200px",sendButtonText:x="Send",hideCancelButton:v=!1,onAiRestructure:b,onAiProofread:C,onAiRewrite:S,renderAboveToolbar:D}){const w={...Sg,...c},[y,k]=_.useState(r),[N,F]=_.useState(""),[T,M]=_.useState(""),[L,E]=_.useState(e),[B,R]=_.useState(t),[O,H]=_.useState([]),[U,Z]=_.useState(!1),[q,K]=_.useState(""),[$,re]=_.useState(f),[ae,le]=_.useState(!1),ce=_.useRef(void 0);_.useEffect(()=>{l!==void 0&&l!==ce.current&&(ce.current=l,R(t),le(!0))},[l,t]);const ve=X=>{R(X),le(!1),o==null||o(X)},pe=_.useRef(null),[Fe,et]=_.useState(!1),ct=X=>{const Ne=X.target.files;if(Ne){const Me=Array.from(Ne);console.log("[MailComposer] Files selected:",Me.map(Re=>({name:Re.name,size:Re.size,type:Re.type}))),H(Re=>[...Re,...Me])}pe.current&&(pe.current.value="")},kt=X=>{X.preventDefault(),X.stopPropagation(),et(!0)},tt=X=>{X.preventDefault(),X.stopPropagation(),et(!1)},xt=X=>{if(X.preventDefault(),X.stopPropagation(),et(!1),X.dataTransfer.files&&X.dataTransfer.files.length>0){const Ne=Array.from(X.dataTransfer.files);console.log("[MailComposer] Files dropped:",Ne.map(Me=>({name:Me.name,size:Me.size,type:Me.type}))),H(Me=>[...Me,...Ne])}else console.log("[MailComposer] Drop event but no files:",X.dataTransfer.types)},dt=X=>X.type.startsWith("image/")?"image":X.type==="application/pdf"?"picture_as_pdf":X.type.includes("spreadsheet")||X.type.includes("excel")?"table_chart":X.type.includes("document")||X.type.includes("word")?"description":"attach_file",It=X=>{H(Ne=>Ne.filter((Me,Re)=>Re!==X))},ue=X=>X<1024?`${X} B`:X<1024*1024?`${(X/1024).toFixed(1)} KB`:`${(X/(1024*1024)).toFixed(1)} MB`,_e=async()=>{if(!y.trim()){K("Recipient email is required");return}if(!L.trim()){K("Subject is required");return}Z(!0),K("");try{const X=await Promise.all(O.map(async Re=>{const zt=await Re.arrayBuffer(),$t=btoa(new Uint8Array(zt).reduce((Jt,ee)=>Jt+String.fromCharCode(ee),""));return{filename:Re.name,content_type:Re.type||"application/octet-stream",data:$t,size:Re.size}})),Ne=B.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),Me={to:y.trim(),cc:N.trim()||void 0,bcc:T.trim()||void 0,subject:L.trim(),html:Ne,attachments:X,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",Me.to,"subject:",Me.subject,"attachmentsCount:",Me.attachments.length),Me.attachments.length>0&&Me.attachments.forEach((Re,zt)=>{var $t;console.log(`[MailComposer] Attachment ${zt+1}:`,Re.filename,"size:",Re.size,"type:",Re.content_type,"data length:",(($t=Re.data)==null?void 0:$t.length)||0)}),await s(Me),k(""),F(""),M(""),E(""),R(""),H([])}catch(X){K(X instanceof Error?X.message:"Failed to send email")}finally{Z(!1)}},Te={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${w.inputBorder}`,borderRadius:"6px",background:w.inputBackground,color:w.text,outline:"none"},it={display:"block",fontSize:"12px",fontWeight:500,color:w.textSecondary,marginBottom:"4px",textTransform:"uppercase"},Je=(X,Ne=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:Ne?"not-allowed":"pointer",opacity:Ne?.6:1,background:X?w.buttonPrimary:w.buttonSecondary,color:X?"#ffffff":w.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:w.background},children:[q&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:q}),h.jsxs("div",{children:[h.jsx("label",{style:it,children:"To"}),h.jsx("input",{type:"email",value:y,onChange:X=>k(X.target.value),placeholder:"recipient@example.com",disabled:d||U,style:Te})]}),!$&&h.jsx("button",{type:"button",onClick:()=>re(!0),disabled:d||U,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:w.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),$&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:it,children:"CC"}),h.jsx("input",{type:"email",value:N,onChange:X=>F(X.target.value),placeholder:"cc@example.com",disabled:d||U,style:Te})]}),h.jsxs("div",{children:[h.jsx("label",{style:it,children:"BCC"}),h.jsx("input",{type:"email",value:T,onChange:X=>M(X.target.value),placeholder:"bcc@example.com",disabled:d||U,style:Te})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:it,children:"Subject"}),h.jsx("input",{type:"text",value:L,onChange:X=>E(X.target.value),placeholder:"Email subject",disabled:d||U,style:Te})]}),h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Vc,{value:B,onChange:ve,placeholder:p,replyTo:n,theme:w,disabled:d||U,minHeight:m,externalUpdate:ae?l:void 0,insertText:a,insertTextTrigger:u,onAiRestructure:b,onAiProofread:C,onAiRewrite:S,renderAboveToolbar:D})})}),h.jsxs("div",{children:[h.jsx("label",{style:{...it,marginBottom:"8px"},children:"Attachments"}),h.jsx("input",{ref:pe,type:"file",multiple:!0,onChange:ct,style:{display:"none"}}),h.jsxs("div",{onClick:()=>{var X;return(X=pe.current)==null?void 0:X.click()},onDragOver:kt,onDragLeave:tt,onDrop:xt,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${Fe?w.primary:w.border}`,borderRadius:"8px",background:Fe?`${w.primary}10`:"transparent",color:Fe?w.primary:w.textSecondary,cursor:d||U?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:O.length>0?"12px":0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:Fe?"file_download":"attach_file"}),h.jsx("span",{style:{fontSize:"14px"},children:Fe?"Drop files here":"Drop files or click to add"})]}),O.length>0&&h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:O.map((X,Ne)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:w.attachmentBackground,borderRadius:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w.textSecondary},children:dt(X)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:w.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:X.name}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary},children:ue(X.size)})]}),h.jsx("button",{type:"button",onClick:()=>It(Ne),disabled:d||U,style:{background:"none",border:"none",padding:"4px",cursor:"pointer",color:w.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${X.name}-${Ne}`))})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!v&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||U,style:Je(!1,d||U),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:_e,disabled:d||U||!y.trim()||!L.trim(),style:Je(!0,d||U||!y.trim()||!L.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:U?"spin 1s linear infinite":"none"},children:U?"sync":"send"}),U?"Sending...":x]})]}),h.jsx("style",{children:`
178
+ `;return h.jsxs("div",{className:o,style:{border:`1px solid ${w.border}`,borderRadius:"8px",background:w.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:ee}),x,h.jsxs(zh,{initialConfig:W,children:[h.jsx(_g,{theme:w,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:F,onAiAction:M,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Sp,{contentEditable:h.jsx(Ap,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:w.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:qp})}),h.jsx(eg,{}),h.jsx(sg,{}),h.jsx(Ip,{}),h.jsx(zp,{onChange:$}),h.jsx(wg,{html:y?D:r,isExternalUpdate:y,onImportComplete:L}),h.jsx(Cg,{text:u,trigger:c})]}),n&&h.jsx(Sg,{replyTo:n,theme:w})]})}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function Eg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:l,insertText:a,insertTextTrigger:u,theme:c={},disabled:d=!1,showCcBcc:f=!1,placeholder:p="Write your message...",className:g="",minHeight:m="200px",sendButtonText:x="Send",hideCancelButton:w=!1,onAiRestructure:y,onAiProofread:C,onAiRewrite:S,renderAboveToolbar:D}){const _={...kg,...c},[b,E]=v.useState(r),[N,R]=v.useState(""),[T,F]=v.useState(""),[L,k]=v.useState(e),[B,M]=v.useState(t),[I,W]=v.useState([]),[$,ee]=v.useState(!1),[q,Y]=v.useState(""),[z,ie]=v.useState(f),[ce,de]=v.useState(!1),me=v.useRef(void 0);v.useEffect(()=>{l!==void 0&&l!==me.current&&(me.current=l,M(t),de(!0))},[l,t]);const X=Z=>{M(Z),de(!1),o==null||o(Z)},oe=v.useRef(null),[G,Ee]=v.useState(!1),Ne=Z=>{const Ie=Z.target.files;if(Ie){const $e=Array.from(Ie);console.log("[MailComposer] Files selected:",$e.map(ze=>({name:ze.name,size:ze.size,type:ze.type}))),W(ze=>[...ze,...$e])}oe.current&&(oe.current.value="")},xe=Z=>{Z.preventDefault(),Z.stopPropagation(),Ee(!0)},ye=Z=>{Z.preventDefault(),Z.stopPropagation(),Ee(!1)},ue=Z=>{if(Z.preventDefault(),Z.stopPropagation(),Ee(!1),Z.dataTransfer.files&&Z.dataTransfer.files.length>0){const Ie=Array.from(Z.dataTransfer.files);console.log("[MailComposer] Files dropped:",Ie.map($e=>({name:$e.name,size:$e.size,type:$e.type}))),W($e=>[...$e,...Ie])}else console.log("[MailComposer] Drop event but no files:",Z.dataTransfer.types)},ae=Z=>Z.type.startsWith("image/")?"image":Z.type==="application/pdf"?"picture_as_pdf":Z.type.includes("spreadsheet")||Z.type.includes("excel")?"table_chart":Z.type.includes("document")||Z.type.includes("word")?"description":"attach_file",ke=Z=>{W(Ie=>Ie.filter(($e,ze)=>ze!==Z))},te=Z=>Z<1024?`${Z} B`:Z<1024*1024?`${(Z/1024).toFixed(1)} KB`:`${(Z/(1024*1024)).toFixed(1)} MB`,ge=async()=>{if(!b.trim()){Y("Recipient email is required");return}if(!L.trim()){Y("Subject is required");return}ee(!0),Y("");try{const Z=await Promise.all(I.map(async ze=>{const zt=await ze.arrayBuffer(),$t=btoa(new Uint8Array(zt).reduce((Jt,ne)=>Jt+String.fromCharCode(ne),""));return{filename:ze.name,content_type:ze.type||"application/octet-stream",data:$t,size:ze.size}})),Ie=B.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),$e={to:b.trim(),cc:N.trim()||void 0,bcc:T.trim()||void 0,subject:L.trim(),html:Ie,attachments:Z,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",$e.to,"subject:",$e.subject,"attachmentsCount:",$e.attachments.length),$e.attachments.length>0&&$e.attachments.forEach((ze,zt)=>{var $t;console.log(`[MailComposer] Attachment ${zt+1}:`,ze.filename,"size:",ze.size,"type:",ze.content_type,"data length:",(($t=ze.data)==null?void 0:$t.length)||0)}),await s($e),E(""),R(""),F(""),k(""),M(""),W([])}catch(Z){Y(Z instanceof Error?Z.message:"Failed to send email")}finally{ee(!1)}},be={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${_.inputBorder}`,borderRadius:"6px",background:_.inputBackground,color:_.text,outline:"none"},Xe={display:"block",fontSize:"12px",fontWeight:500,color:_.textSecondary,marginBottom:"4px",textTransform:"uppercase"},st=(Z,Ie=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:Ie?"not-allowed":"pointer",opacity:Ie?.6:1,background:Z?_.buttonPrimary:_.buttonSecondary,color:Z?"#ffffff":_.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:_.background},children:[q&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:q}),h.jsxs("div",{children:[h.jsx("label",{style:Xe,children:"To"}),h.jsx("input",{type:"email",value:b,onChange:Z=>E(Z.target.value),placeholder:"recipient@example.com",disabled:d||$,style:be})]}),!z&&h.jsx("button",{type:"button",onClick:()=>ie(!0),disabled:d||$,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:_.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),z&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:Xe,children:"CC"}),h.jsx("input",{type:"email",value:N,onChange:Z=>R(Z.target.value),placeholder:"cc@example.com",disabled:d||$,style:be})]}),h.jsxs("div",{children:[h.jsx("label",{style:Xe,children:"BCC"}),h.jsx("input",{type:"email",value:T,onChange:Z=>F(Z.target.value),placeholder:"bcc@example.com",disabled:d||$,style:be})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:Xe,children:"Subject"}),h.jsx("input",{type:"text",value:L,onChange:Z=>k(Z.target.value),placeholder:"Email subject",disabled:d||$,style:be})]}),h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Hc,{value:B,onChange:X,placeholder:p,replyTo:n,theme:_,disabled:d||$,minHeight:m,externalUpdate:ce?l:void 0,insertText:a,insertTextTrigger:u,onAiRestructure:y,onAiProofread:C,onAiRewrite:S,renderAboveToolbar:D})})}),h.jsxs("div",{children:[h.jsx("label",{style:{...Xe,marginBottom:"8px"},children:"Attachments"}),h.jsx("input",{ref:oe,type:"file",multiple:!0,onChange:Ne,style:{display:"none"}}),h.jsxs("div",{onClick:()=>{var Z;return(Z=oe.current)==null?void 0:Z.click()},onDragOver:xe,onDragLeave:ye,onDrop:ue,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${G?_.primary:_.border}`,borderRadius:"8px",background:G?`${_.primary}10`:"transparent",color:G?_.primary:_.textSecondary,cursor:d||$?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:I.length>0?"12px":0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:G?"file_download":"attach_file"}),h.jsx("span",{style:{fontSize:"14px"},children:G?"Drop files here":"Drop files or click to add"})]}),I.length>0&&h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:I.map((Z,Ie)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:_.attachmentBackground,borderRadius:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_.textSecondary},children:ae(Z)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:_.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Z.name}),h.jsx("div",{style:{fontSize:"12px",color:_.textSecondary},children:te(Z.size)})]}),h.jsx("button",{type:"button",onClick:()=>ke(Ie),disabled:d||$,style:{background:"none",border:"none",padding:"4px",cursor:"pointer",color:_.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${Z.name}-${Ie}`))})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!w&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||$,style:st(!1,d||$),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:ge,disabled:d||$||!b.trim()||!L.trim(),style:st(!0,d||$||!b.trim()||!L.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:$?"spin 1s linear infinite":"none"},children:$?"sync":"send"}),$?"Sending...":x]})]}),h.jsx("style",{children:`
179
179
  @keyframes spin {
180
180
  from { transform: rotate(0deg); }
181
181
  to { transform: rotate(360deg); }
182
182
  }
183
- `})]})}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Dg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...kg,...d},[g,m]=_.useState(!1),[x,v]=_.useState(""),b=_.useRef(null),C=_.useRef(null);_.useEffect(()=>{function T(M){b.current&&!b.current.contains(M.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var M;return((M=T.label)==null?void 0:M.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var M;return((M=T.label)==null?void 0:M.toLowerCase())===x.toLowerCase()}),w=e.map(T=>r.find(M=>M.id===T)).filter(Boolean),y=_.useCallback(T=>{var M;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(M=C.current)==null||M.focus())},[e,t,c]),k=_.useCallback(T=>{t(e.filter(M=>M!==T))},[e,t]),N=_.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&y(T.id),v("")},[D,x,i,y]),F=_.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?N():S.length>0&&y(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?k(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[D,S,x,e,N,y,k]);return h.jsxs("div",{ref:b,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[w.map(T=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||p.chipBackground,color:T.color?"#fff":p.chipText},children:[T.label,!u&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),k(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),h.jsx("input",{ref:C,type:"text",value:x,onChange:T=>{v(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:F,placeholder:w.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!D?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(T=>h.jsxs("div",{onClick:()=>y(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:M=>{M.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:M=>{M.currentTarget.style.background=""},children:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),l(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:M=>{M.currentTarget.style.opacity="1",M.currentTarget.style.color="#ef4444"},onMouseLeave:M=>{M.currentTarget.style.opacity="0.5",M.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:N,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Ag={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Tg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Ag,...u},[d,f]=_.useState(""),[p,g]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),v=_.useMemo(()=>e&&r.find(y=>y.id===e)||null,[e,r]),b=_.useMemo(()=>{if(!d.trim())return r;const y=d.toLowerCase();return r.filter(k=>{var N,F;return((N=k.label)==null?void 0:N.toLowerCase().includes(y))||((F=k.notes)==null?void 0:F.toLowerCase().includes(y))})},[r,d]);_.useEffect(()=>{const y=k=>{m.current&&!m.current.contains(k.target)&&g(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const C=y=>{s&&s(y),g(!1),f("")},S=()=>{o&&o(),g(!1)},D=()=>{g(!0)},w=y=>{f(y.target.value),p||g(!0)};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:v&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]}),i&&h.jsx("button",{onClick:y=>{y.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:w,onFocus:D,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:y=>{y.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:y=>{y.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:b.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):b.map((y,k)=>h.jsxs("div",{onClick:()=>C(y),style:{padding:"10px 14px",cursor:"pointer",borderBottom:k<b.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:N=>{N.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:y.color||c.text,marginBottom:y.notes?"2px":0},children:y.label}),y.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y.notes})]},y.id))})]})}function Ng({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=_.useState(null),[x,v]=_.useState(null),[b,C]=_.useState(null),S=_.useRef(null),D=e.reduce((M,L)=>{let E=r.filter(B=>n(B)===L.id);return s&&(E=E.sort((B,R)=>s(B)-s(R))),M[L.id]=E,M},{}),w=_.useCallback((M,L)=>{const E=t(L),B=n(L);m(E),S.current=B,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",E),requestAnimationFrame(()=>{const R=M.target;R.style.opacity="0.5"})},[t,n]),y=_.useCallback(M=>{const L=M.target;L.style.opacity="1",m(null),v(null),C(null),S.current=null},[]),k=_.useCallback((M,L,E)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",v(L),C(E)},[]),N=_.useCallback(M=>{const L=M.relatedTarget;L!=null&&L.closest("[data-kanban-column]")||(v(null),C(null))},[]),F=_.useCallback((M,L,E)=>{if(M.preventDefault(),!g)return;const B=S.current;B===L?l==null||l(g,L,E):B&&o(g,B,L,E),m(null),v(null),C(null),S.current=null},[g,o,l]),T=(M,L)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[M.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:M.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:M.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:L})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(M=>{const L=D[M.id]||[],E=x===M.id;return h.jsxs("div",{"data-kanban-column":M.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:B=>{B.preventDefault(),g&&!E&&v(M.id)},onDragLeave:N,onDrop:B=>F(B,M.id,b??L.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,L.length):T(M,L.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${E?"bg-blue-50":""}`,children:[L.map((B,R)=>{const O=t(B),H=g===O,U=E&&b===R&&!H;return h.jsxs("div",{children:[U&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:Z=>w(Z,B),onDragEnd:y,onDragOver:Z=>k(Z,M.id,R),onClick:()=>a==null?void 0:a(B),className:`cursor-grab active:cursor-grabbing transition-all ${H?"opacity-50 scale-95":""} ${p}`,children:i(B,H)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:B=>{B.preventDefault(),k(B,M.id,L.length)},children:E&&b===L.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),L.length===0&&E&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(M)})]},M.id)})})}const Bg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Fg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Rg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Mg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function jg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Bg,...g},{allDayItems:x,timedItems:v}=_.useMemo(()=>{const y=[],k=[];for(const N of r)l(N)?y.push(N):k.push(N);return{allDayItems:y,timedItems:k}},[r,l]),b=_.useMemo(()=>{const y=[];for(let k=t;k<=n;k++)y.push(k);return y},[t,n]),C=(n-t+1)*s,S=_.useCallback(y=>{const k=i(y);if(!k)return null;const N=Fg(k);if(!N)return null;const{hours:F,minutes:T}=N,M=Math.max(t,Math.min(n,F)),L=F<t?0:T,E=(M-t)*s+L/60*s,B=o(y),R=Math.max(20,B/60*s);return{top:E,height:R}},[i,o,t,n,s]),D=_.useMemo(()=>{if(!f||!Mg(e))return null;const y=new Date,k=y.getHours(),N=y.getMinutes();return k<t||k>n?null:(k-t)*s+N/60*s},[e,f,t,n,s]),w=_.useCallback(y=>{if(!d)return;const k=y.currentTarget.getBoundingClientRect(),F=(y.clientY-k.top)/s*60,T=Math.floor(F/60)+t,M=Math.round(F%60/15)*15,L=Math.min(n,Math.max(t,T)),E=M>=60?0:M,B=`${L.toString().padStart(2,"0")}:${E.toString().padStart(2,"0")}`;d(B)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(y=>h.jsx("div",{onClick:()=>c==null?void 0:c(y),style:{cursor:c?"pointer":"default"},children:u(y)},a(y)))})]}),h.jsxs("div",{style:{position:"relative",height:C},children:[b.map((y,k)=>h.jsxs("div",{style:{position:"absolute",top:k*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Rg(y)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),k<b.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},y)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:w}),D!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:D,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),v.map(y=>{const k=S(y);return k?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:k.top,height:k.height,zIndex:10,cursor:c?"pointer":"default"},onClick:N=>{N.stopPropagation(),c==null||c(y)},children:u(y)},a(y)):null})]})]})}function Hc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=_.useState("idle"),[c,d]=_.useState(0),[f,p]=_.useState(0),[g,m]=_.useState(!1),[x,v]=_.useState(0),[b,C]=_.useState(null),[S,D]=_.useState(!1),[w,y]=_.useState(null),[k,N]=_.useState(!0),[F,T]=_.useState([]),[M,L]=_.useState({completed:0,total:0}),E=_.useRef(!1),B=_.useRef(!0);_.useEffect(()=>{B.current=k},[k]);const R=_.useRef(null),O=_.useRef(null),H=_.useRef(null),U=_.useRef(null),Z=_.useRef(null),q=_.useRef([]),K=_.useRef(null),$=_.useRef(null),re=_.useRef(null),ae=_.useRef(null),le=_.useRef(!1),ce=_.useRef([]),ve=_.useRef(null),pe=_.useRef(null),Fe=_.useRef([]),et=_.useRef([]),ct=_.useRef("insert"),kt=_.useRef(!1),tt=_.useRef(0),xt=_.useRef(0),dt=_.useRef(0),It=Y=>{const j=Math.floor(Y/60),ne=Math.floor(Y%60);return`${j.toString().padStart(2,"0")}:${ne.toString().padStart(2,"0")}`},ue=async Y=>{const j=await Y.arrayBuffer(),ne=new AudioContext,ie=await ne.decodeAudioData(j);return await ne.close(),ie},_e=Y=>{const j=Y.numberOfChannels,ne=Y.sampleRate,ie=1,W=16,ge=W/8,de=j*ge,fe=ne*de,Se=Y.length*de,Be=new ArrayBuffer(44+Se),he=new DataView(Be),me=(Le,De)=>{for(let rt=0;rt<De.length;rt++)he.setUint8(Le+rt,De.charCodeAt(rt))};me(0,"RIFF"),he.setUint32(4,36+Se,!0),me(8,"WAVE"),me(12,"fmt "),he.setUint32(16,16,!0),he.setUint16(20,ie,!0),he.setUint16(22,j,!0),he.setUint32(24,ne,!0),he.setUint32(28,fe,!0),he.setUint16(32,de,!0),he.setUint16(34,W,!0),me(36,"data"),he.setUint32(40,Se,!0);const We=[];for(let Le=0;Le<j;Le++)We.push(Y.getChannelData(Le));let Ge=44;for(let Le=0;Le<Y.length;Le++)for(let De=0;De<j;De++){const rt=Math.max(-1,Math.min(1,We[De][Le])),nt=rt<0?rt*32768:rt*32767;he.setInt16(Ge,nt,!0),Ge+=2}return new Blob([Be],{type:"audio/wav"})},Te=async(Y,j,ne,ie)=>{const W=new AudioContext,ge=Y.sampleRate,de=Math.max(Y.numberOfChannels,j.numberOfChannels),fe=Math.min(ne,Y.length),Se=Math.max(0,Y.length-ne),Be=ie==="insert"?fe+j.length+Se:fe+j.length,he=W.createBuffer(de,Be,ge);for(let me=0;me<de;me++){const We=he.getChannelData(me),Ge=me<Y.numberOfChannels?Y.getChannelData(me):Y.getChannelData(0);for(let De=0;De<fe;De++)We[De]=Ge[De];const Le=me<j.numberOfChannels?j.getChannelData(me):j.getChannelData(0);for(let De=0;De<j.length;De++)We[fe+De]=Le[De];if(ie==="insert")for(let De=0;De<Se;De++)We[fe+j.length+De]=Ge[ne+De]}return await W.close(),he},it=_.useCallback(()=>{const Y=R.current;if(!Y)return;const j=Y.getContext("2d");if(!j)return;const ne=Y.getBoundingClientRect(),ie=ne.width,W=ne.height,ge=ce.current,de=f||c||1,fe=a==="recording"?c:x;j.fillStyle="#2d3b35",j.fillRect(0,0,ie,W);const Se=8,Be="rgba(0, 0, 0, 0.4)",he=j.createLinearGradient(0,0,0,Se);he.addColorStop(0,Be),he.addColorStop(1,"transparent"),j.fillStyle=he,j.fillRect(0,0,ie,Se);const me=j.createLinearGradient(0,W-Se,0,W);me.addColorStop(0,"transparent"),me.addColorStop(1,Be),j.fillStyle=me,j.fillRect(0,W-Se,ie,Se);const We=j.createLinearGradient(0,0,Se,0);We.addColorStop(0,Be),We.addColorStop(1,"transparent"),j.fillStyle=We,j.fillRect(0,0,Se,W);const Ge=j.createLinearGradient(ie-Se,0,ie,0);Ge.addColorStop(0,"transparent"),Ge.addColorStop(1,Be),j.fillStyle=Ge,j.fillRect(ie-Se,0,Se,W),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,W/2),j.lineTo(ie,W/2),j.stroke();const Le=ie/2;if(ge.length>0)if(a==="recording")for(let nt=0;nt<ge.length;nt++){const wt=ge.length-1-nt,Zt=Le-wt*4;if(Zt<-3||Zt>ie)continue;const At=ge[nt]*(W/2-12),A=W/2-At;j.fillStyle="#10b981",j.fillRect(Zt,A,3,At*2)}else{const nt=de>0?fe/de*ge.length:0;for(let wt=0;wt<ge.length;wt++){const Zt=nt-wt,At=Le-Zt*4;if(At<-3||At>ie)continue;const A=ge[wt]*(W/2-12),I=W/2-A;j.fillStyle=wt<=nt?"#10b981":"#4b5563",j.fillRect(At,I,3,A*2)}}j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(Le,0),j.lineTo(Le,W),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText(It(fe),Le,W-6),a==="recording"&&(j.fillStyle="#ef4444",j.beginPath(),j.arc(20,20,8,0,Math.PI*2),j.fill(),j.fillStyle="#fff",j.font="10px sans-serif",j.textAlign="left",j.fillText("REC",34,24)),j.textAlign="left"},[a,x,c,f]),Je=()=>{const Y=Z.current;if(!Y||!le.current)return;const j=Y.frequencyBinCount,ne=new Uint8Array(j);Y.getByteTimeDomainData(ne);let ie=0;for(let de=0;de<j;de++){const fe=(ne[de]-128)/128;ie+=fe*fe}const W=Math.sqrt(ie/j),ge=Math.min(1,W*3);ce.current.push(ge),it(),le.current&&($.current=requestAnimationFrame(Je))},X=async()=>{try{C(null),D(!1),ve.current===null&&(ce.current=[]);const Y=await navigator.mediaDevices.getUserMedia({audio:!0});H.current=Y;const j=new AudioContext;U.current=j;const ne=j.createAnalyser();ne.fftSize=2048,Z.current=ne,j.createMediaStreamSource(Y).connect(ne);const W=new MediaRecorder(Y);O.current=W,q.current=[],W.ondataavailable=ge=>{ge.data.size>0&&q.current.push(ge.data)},W.onstop=async()=>{try{if(le.current=!1,q.current.length===0){C("No audio was recorded. Please try again."),u("idle"),Y.getTracks().forEach(he=>he.stop());return}const ge=new Blob(q.current,{type:"audio/webm"});let de,fe;if(ve.current!==null&&pe.current)try{const he=await ue(ge),me=pe.current.sampleRate,We=Math.floor(ve.current*me),Ge=await Te(pe.current,he,We,ct.current);de=_e(Ge),fe=Ge.length/Ge.sampleRate,ct.current==="insert"&&(ce.current=[...ce.current,...et.current]),ve.current=null,pe.current=null,Fe.current=[],et.current=[]}catch{de=ge,fe=tt.current>0?tt.current:1}else de=ge,fe=tt.current>0?tt.current:1;if(ae.current=de,Y.getTracks().forEach(he=>he.stop()),B.current&&t){T(he=>[...he,de]),L(he=>({...he,total:he.total+1})),ae.current=null,ce.current=[],v(0),p(0),d(0),u("idle");return}const Se=URL.createObjectURL(de),Be=new Audio(Se);Be.ontimeupdate=()=>{v(Be.currentTime)},Be.onended=()=>{m(!1)},re.current=Be,p(fe),v(fe),u("editing")}catch{C("Failed to process recording"),u("idle")}},W.start(100),le.current=!0,u("recording"),d(0),tt.current=0,K.current=setInterval(()=>{tt.current+=1,d(tt.current),tt.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),le.current=!1,y(null),K.current&&(clearInterval(K.current),K.current=null),$.current&&(cancelAnimationFrame($.current),$.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},Ne=()=>{le.current=!1,D(!1),y(null),$.current&&(cancelAnimationFrame($.current),$.current=null),K.current&&(clearInterval(K.current),K.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},Me=Y=>{const j=R.current;if(!j)return;const ne=f||c;if(ne<=0)return;const ie=ce.current;if(ie.length===0)return;const W=j.getBoundingClientRect(),ge=Y-xt.current,de=4,fe=W.width/j.width,Se=ie.length/ne*de,Be=-ge/(Se*fe),he=dt.current+Be,me=Math.max(0,Math.min(he,ne));re.current&&(re.current.currentTime=me),v(me)},Re=()=>{re.current&&(re.current.currentTime=0),v(0)},zt=()=>{const Y=f||c;re.current&&(re.current.currentTime=Y),v(Y)},$t=()=>{const Y=re.current;Y&&(g?(Y.pause(),v(Y.currentTime),m(!1)):(Y.currentTime=x,Y.play().catch(()=>{}),m(!0)))},Jt=async Y=>{if(!ae.current){X();return}try{re.current&&(re.current.pause(),m(!1)),ct.current=Y,pe.current=await ue(ae.current);const j=f||c;ve.current=x;const ne=j>0?x/j:0,ie=Math.floor(ne*ce.current.length);Fe.current=ce.current.slice(0,ie),et.current=ce.current.slice(ie),ce.current=[...Fe.current],X()}catch{C("Failed to prepare recording. Please try again.")}},ee=()=>{re.current&&(re.current.pause(),re.current=null),ae.current=null,pe.current=null,ve.current=null,Fe.current=[],m(!1),v(0),p(0),d(0),X()},se=()=>{ae.current?r(ae.current,f||c):alert("No audio recorded yet!")};_.useEffect(()=>{a==="recording"&&R.current&&Z.current&&le.current&&($.current=requestAnimationFrame(Je))},[a]),_.useEffect(()=>{const Y=R.current;if(!Y)return;const j=()=>{const ne=window.devicePixelRatio||1,ie=Y.getBoundingClientRect();Y.width=ie.width*ne,Y.height=ie.height*ne;const W=Y.getContext("2d");W&&W.scale(ne,ne)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),_.useEffect(()=>{if(a==="idle"){const Y=R.current;if(!Y)return;const j=Y.getContext("2d");if(!j)return;const ne=Y.getBoundingClientRect(),ie=ne.width,W=ne.height;j.fillStyle="#2d3b35",j.fillRect(0,0,ie,W);const ge=8,de="rgba(0, 0, 0, 0.4)",fe=j.createLinearGradient(0,0,0,ge);fe.addColorStop(0,de),fe.addColorStop(1,"transparent"),j.fillStyle=fe,j.fillRect(0,0,ie,ge);const Se=j.createLinearGradient(0,W-ge,0,W);Se.addColorStop(0,"transparent"),Se.addColorStop(1,de),j.fillStyle=Se,j.fillRect(0,W-ge,ie,ge);const Be=j.createLinearGradient(0,0,ge,0);Be.addColorStop(0,de),Be.addColorStop(1,"transparent"),j.fillStyle=Be,j.fillRect(0,0,ge,W);const he=j.createLinearGradient(ie-ge,0,ie,0);he.addColorStop(0,"transparent"),he.addColorStop(1,de),j.fillStyle=he,j.fillRect(ie-ge,0,ge,W),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,W/2),j.lineTo(ie,W/2),j.stroke();const me=ie/2;j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(me,0),j.lineTo(me,W),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText("00:00",me,W-6)}},[a]);const je=_.useCallback(Y=>{T(j=>[...j,Y]),L(j=>({...j,total:j.total+1}))},[]);if(_.useEffect(()=>{(async()=>{if(E.current||F.length===0||!t)return;E.current=!0;const j=F[0];try{const ne=await t(j);ne&&n&&n(ne)}catch(ne){console.error("Transcription failed:",ne)}finally{T(ne=>ne.slice(1)),L(ne=>({...ne,completed:ne.completed+1})),E.current=!1}})()},[F,t,n]),_.useEffect(()=>()=>{le.current=!1,K.current&&clearInterval(K.current),$.current&&cancelAnimationFrame($.current),H.current&&H.current.getTracks().forEach(Y=>Y.stop()),U.current&&U.current.state!=="closed"&&U.current.close()},[]),_.useEffect(()=>{if(a==="editing"&&g){let Y;const j=()=>{const ne=re.current;if(ne&&g){const ie=R.current;if(ie){const W=ie.getContext("2d");if(W){const ge=ie.getBoundingClientRect(),de=ge.width,fe=ge.height,Se=ce.current,Be=f||c||1,he=ne.currentTime;W.fillStyle="#2d3b35",W.fillRect(0,0,de,fe);const me=8,We="rgba(0, 0, 0, 0.4)",Ge=W.createLinearGradient(0,0,0,me);Ge.addColorStop(0,We),Ge.addColorStop(1,"transparent"),W.fillStyle=Ge,W.fillRect(0,0,de,me);const Le=W.createLinearGradient(0,fe-me,0,fe);Le.addColorStop(0,"transparent"),Le.addColorStop(1,We),W.fillStyle=Le,W.fillRect(0,fe-me,de,me);const De=W.createLinearGradient(0,0,me,0);De.addColorStop(0,We),De.addColorStop(1,"transparent"),W.fillStyle=De,W.fillRect(0,0,me,fe);const rt=W.createLinearGradient(de-me,0,de,0);rt.addColorStop(0,"transparent"),rt.addColorStop(1,We),W.fillStyle=rt,W.fillRect(de-me,0,me,fe),W.strokeStyle="#5a6b62",W.lineWidth=1,W.beginPath(),W.moveTo(0,fe/2),W.lineTo(de,fe/2),W.stroke();const nt=de/2,wt=3,Zt=4,At=Be>0?he/Be*Se.length:0;for(let Q=0;Q<Se.length;Q++){const oe=At-Q,we=nt-oe*Zt;if(we<-wt||we>de)continue;const ke=Se[Q]*(fe/2-12),xe=fe/2-ke;W.fillStyle=Q<=At?"#10b981":"#4b5563",W.fillRect(we,xe,wt,ke*2)}W.strokeStyle="#ef4444",W.lineWidth=1,W.beginPath(),W.moveTo(nt,0),W.lineTo(nt,fe),W.stroke(),W.fillStyle="#fff",W.font="bold 18px monospace",W.textAlign="center";const A=Math.floor(he/60),I=Math.floor(he%60);W.fillText(`${A.toString().padStart(2,"0")}:${I.toString().padStart(2,"0")}`,nt,fe-6),W.textAlign="left"}}Y=requestAnimationFrame(j)}};return Y=requestAnimationFrame(j),()=>cancelAnimationFrame(Y)}},[a,g,f,c]),_.useEffect(()=>{a==="editing"&&!g&&it()},[a,x,g,it]),b)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:b}),h.jsx("button",{onClick:()=>{C(null),X()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const $e={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},qe={...$e,opacity:.3,cursor:"not-allowed"},Dt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Dt,children:[h.jsx("canvas",{ref:R,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Y=>{if(a==="editing"){kt.current=!0,xt.current=Y.clientX,dt.current=x;const j=ie=>{kt.current&&Me(ie.clientX)},ne=()=>{kt.current=!1,window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",ne)};window.addEventListener("mousemove",j),window.addEventListener("mouseup",ne)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:Re,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?qe:$e,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const Y=O.current;Y&&(Y.state==="recording"?(Y.pause(),D(!0)):Y.state==="paused"&&(Y.resume(),D(!1)))}else $t()},disabled:a==="idle",style:a==="idle"?qe:$e,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:zt,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?qe:$e,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),h.jsx("button",{onClick:()=>{w==="insert"?Ne():a==="idle"?(y("insert"),X()):a==="editing"&&(y("insert"),Jt("insert"))},disabled:a==="recording"&&w!=="insert"||g,style:a==="recording"&&w!=="insert"||g?qe:$e,title:w==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{B.current||(w==="mic"?Ne():a==="idle"?(y("mic"),X()):a==="editing"&&(y("mic"),Jt("replace")))},onMouseDown:()=>{B.current&&a==="idle"&&!g&&(y("mic"),X())},onMouseUp:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},onMouseLeave:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},onTouchStart:()=>{B.current&&a==="idle"&&!g&&(y("mic"),X())},onTouchEnd:()=>{B.current&&a==="recording"&&w==="mic"&&Ne()},disabled:a==="recording"&&w!=="mic"||g,style:a==="recording"&&w!=="mic"||g?qe:$e,title:k?"Hold to record (walkie-talkie)":w==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{w==="startover"?Ne():a==="editing"&&(y("startover"),ee())},disabled:a==="idle"||a==="recording"&&w!=="startover"||g,style:a==="idle"||a==="recording"&&w!=="startover"||g?qe:$e,title:w==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:w==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[M.total>0&&M.completed<M.total&&h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),M.completed,"/",M.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>N(!k),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:k?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:k?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:k?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&ae.current&&je(ae.current)},disabled:a!=="editing",style:a!=="editing"?qe:$e,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:se,disabled:a!=="editing",style:a!=="editing"?qe:$e,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),M.total>0&&M.completed<M.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${M.completed/M.total*100}%`,transition:"width 0.3s ease"}})})]})}function Lg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=_.useState(!1),[c,d]=_.useState(null),[f,p]=_.useState(!1),g=_.useRef(null),m=b=>{t(e?`${e}
183
+ `})]})}const Dg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Ag({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Dg,...d},[g,m]=v.useState(!1),[x,w]=v.useState(""),y=v.useRef(null),C=v.useRef(null);v.useEffect(()=>{function T(F){y.current&&!y.current.contains(F.target)&&(m(!1),w(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var F;return((F=T.label)==null?void 0:F.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var F;return((F=T.label)==null?void 0:F.toLowerCase())===x.toLowerCase()}),_=e.map(T=>r.find(F=>F.id===T)).filter(Boolean),b=v.useCallback(T=>{var F;c>0&&e.length>=c||(t([...e,T]),w(""),c===1?m(!1):(F=C.current)==null||F.focus())},[e,t,c]),E=v.useCallback(T=>{t(e.filter(F=>F!==T))},[e,t]),N=v.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&b(T.id),w("")},[D,x,i,b]),R=v.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?N():S.length>0&&b(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?E(e[e.length-1]):T.key==="Escape"&&(m(!1),w(""))},[D,S,x,e,N,b,E]);return h.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[_.map(T=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||p.chipBackground,color:T.color?"#fff":p.chipText},children:[T.label,!u&&h.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),E(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),h.jsx("input",{ref:C,type:"text",value:x,onChange:T=>{w(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:R,placeholder:_.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!D?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(T=>h.jsxs("div",{onClick:()=>b(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:F=>{F.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:F=>{F.currentTarget.style.background=""},children:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:F=>{F.stopPropagation(),l(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:F=>{F.currentTarget.style.opacity="1",F.currentTarget.style.color="#ef4444"},onMouseLeave:F=>{F.currentTarget.style.opacity="0.5",F.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:N,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Tg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Ng({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Tg,...u},[d,f]=v.useState(""),[p,g]=v.useState(!1),m=v.useRef(null),x=v.useRef(null),w=v.useMemo(()=>e&&r.find(b=>b.id===e)||null,[e,r]),y=v.useMemo(()=>{if(!d.trim())return r;const b=d.toLowerCase();return r.filter(E=>{var N,R;return((N=E.label)==null?void 0:N.toLowerCase().includes(b))||((R=E.notes)==null?void 0:R.toLowerCase().includes(b))})},[r,d]);v.useEffect(()=>{const b=E=>{m.current&&!m.current.contains(E.target)&&g(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]);const C=b=>{s&&s(b),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},_=b=>{f(b.target.value),p||g(!0)};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:w&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.label}),w.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:w.notes})]}),i&&h.jsx("button",{onClick:b=>{b.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:_,onFocus:D,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:b=>{b.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:b=>{b.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:y.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):y.map((b,E)=>h.jsxs("div",{onClick:()=>C(b),style:{padding:"10px 14px",cursor:"pointer",borderBottom:E<y.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:N=>{N.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:b.color||c.text,marginBottom:b.notes?"2px":0},children:b.label}),b.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.notes})]},b.id))})]})}function Bg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=v.useState(null),[x,w]=v.useState(null),[y,C]=v.useState(null),S=v.useRef(null),D=e.reduce((F,L)=>{let k=r.filter(B=>n(B)===L.id);return s&&(k=k.sort((B,M)=>s(B)-s(M))),F[L.id]=k,F},{}),_=v.useCallback((F,L)=>{const k=t(L),B=n(L);m(k),S.current=B,F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("text/plain",k),requestAnimationFrame(()=>{const M=F.target;M.style.opacity="0.5"})},[t,n]),b=v.useCallback(F=>{const L=F.target;L.style.opacity="1",m(null),w(null),C(null),S.current=null},[]),E=v.useCallback((F,L,k)=>{F.preventDefault(),F.dataTransfer.dropEffect="move",w(L),C(k)},[]),N=v.useCallback(F=>{const L=F.relatedTarget;L!=null&&L.closest("[data-kanban-column]")||(w(null),C(null))},[]),R=v.useCallback((F,L,k)=>{if(F.preventDefault(),!g)return;const B=S.current;B===L?l==null||l(g,L,k):B&&o(g,B,L,k),m(null),w(null),C(null),S.current=null},[g,o,l]),T=(F,L)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[F.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:F.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:F.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:L})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(F=>{const L=D[F.id]||[],k=x===F.id;return h.jsxs("div",{"data-kanban-column":F.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:B=>{B.preventDefault(),g&&!k&&w(F.id)},onDragLeave:N,onDrop:B=>R(B,F.id,y??L.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(F,L.length):T(F,L.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${k?"bg-blue-50":""}`,children:[L.map((B,M)=>{const I=t(B),W=g===I,$=k&&y===M&&!W;return h.jsxs("div",{children:[$&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:ee=>_(ee,B),onDragEnd:b,onDragOver:ee=>E(ee,F.id,M),onClick:()=>a==null?void 0:a(B),className:`cursor-grab active:cursor-grabbing transition-all ${W?"opacity-50 scale-95":""} ${p}`,children:i(B,W)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:B=>{B.preventDefault(),E(B,F.id,L.length)},children:k&&y===L.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),L.length===0&&k&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(F)})]},F.id)})})}const Rg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Mg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Fg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function jg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Lg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Rg,...g},{allDayItems:x,timedItems:w}=v.useMemo(()=>{const b=[],E=[];for(const N of r)l(N)?b.push(N):E.push(N);return{allDayItems:b,timedItems:E}},[r,l]),y=v.useMemo(()=>{const b=[];for(let E=t;E<=n;E++)b.push(E);return b},[t,n]),C=(n-t+1)*s,S=v.useCallback(b=>{const E=i(b);if(!E)return null;const N=Mg(E);if(!N)return null;const{hours:R,minutes:T}=N,F=Math.max(t,Math.min(n,R)),L=R<t?0:T,k=(F-t)*s+L/60*s,B=o(b),M=Math.max(20,B/60*s);return{top:k,height:M}},[i,o,t,n,s]),D=v.useMemo(()=>{if(!f||!jg(e))return null;const b=new Date,E=b.getHours(),N=b.getMinutes();return E<t||E>n?null:(E-t)*s+N/60*s},[e,f,t,n,s]),_=v.useCallback(b=>{if(!d)return;const E=b.currentTarget.getBoundingClientRect(),R=(b.clientY-E.top)/s*60,T=Math.floor(R/60)+t,F=Math.round(R%60/15)*15,L=Math.min(n,Math.max(t,T)),k=F>=60?0:F,B=`${L.toString().padStart(2,"0")}:${k.toString().padStart(2,"0")}`;d(B)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(b=>h.jsx("div",{onClick:()=>c==null?void 0:c(b),style:{cursor:c?"pointer":"default"},children:u(b)},a(b)))})]}),h.jsxs("div",{style:{position:"relative",height:C},children:[y.map((b,E)=>h.jsxs("div",{style:{position:"absolute",top:E*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Fg(b)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),E<y.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},b)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:_}),D!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:D,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),w.map(b=>{const E=S(b);return E?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:E.top,height:E.height,zIndex:10,cursor:c?"pointer":"default"},onClick:N=>{N.stopPropagation(),c==null||c(b)},children:u(b)},a(b)):null})]})]})}function Gc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=v.useState("idle"),[c,d]=v.useState(0),[f,p]=v.useState(0),[g,m]=v.useState(!1),[x,w]=v.useState(0),[y,C]=v.useState(null),[S,D]=v.useState(!1),[_,b]=v.useState(null),[E,N]=v.useState(!0),[R,T]=v.useState([]),[F,L]=v.useState({completed:0,total:0}),k=v.useRef(!1),B=v.useRef(!0);v.useEffect(()=>{B.current=E},[E]);const M=v.useRef(null),I=v.useRef(null),W=v.useRef(null),$=v.useRef(null),ee=v.useRef(null),q=v.useRef([]),Y=v.useRef(null),z=v.useRef(null),ie=v.useRef(null),ce=v.useRef(null),de=v.useRef(!1),me=v.useRef([]),X=v.useRef(null),oe=v.useRef(null),G=v.useRef([]),Ee=v.useRef([]),Ne=v.useRef("insert"),xe=v.useRef(!1),ye=v.useRef(0),ue=v.useRef(0),ae=v.useRef(0),ke=Q=>{const j=Math.floor(Q/60),le=Math.floor(Q%60);return`${j.toString().padStart(2,"0")}:${le.toString().padStart(2,"0")}`},te=async Q=>{const j=await Q.arrayBuffer(),le=new AudioContext,he=await le.decodeAudioData(j);return await le.close(),he},ge=Q=>{const j=Q.numberOfChannels,le=Q.sampleRate,he=1,V=16,Ce=V/8,ve=j*Ce,_e=le*ve,Me=Q.length*ve,Oe=new ArrayBuffer(44+Me),we=new DataView(Oe),Se=(Ue,Le)=>{for(let lt=0;lt<Le.length;lt++)we.setUint8(Ue+lt,Le.charCodeAt(lt))};Se(0,"RIFF"),we.setUint32(4,36+Me,!0),Se(8,"WAVE"),Se(12,"fmt "),we.setUint32(16,16,!0),we.setUint16(20,he,!0),we.setUint16(22,j,!0),we.setUint32(24,le,!0),we.setUint32(28,_e,!0),we.setUint16(32,ve,!0),we.setUint16(34,V,!0),Se(36,"data"),we.setUint32(40,Me,!0);const Je=[];for(let Ue=0;Ue<j;Ue++)Je.push(Q.getChannelData(Ue));let tt=44;for(let Ue=0;Ue<Q.length;Ue++)for(let Le=0;Le<j;Le++){const lt=Math.max(-1,Math.min(1,Je[Le][Ue])),ut=lt<0?lt*32768:lt*32767;we.setInt16(tt,ut,!0),tt+=2}return new Blob([Oe],{type:"audio/wav"})},be=async(Q,j,le,he)=>{const V=new AudioContext,Ce=Q.sampleRate,ve=Math.max(Q.numberOfChannels,j.numberOfChannels),_e=Math.min(le,Q.length),Me=Math.max(0,Q.length-le),Oe=he==="insert"?_e+j.length+Me:_e+j.length,we=V.createBuffer(ve,Oe,Ce);for(let Se=0;Se<ve;Se++){const Je=we.getChannelData(Se),tt=Se<Q.numberOfChannels?Q.getChannelData(Se):Q.getChannelData(0);for(let Le=0;Le<_e;Le++)Je[Le]=tt[Le];const Ue=Se<j.numberOfChannels?j.getChannelData(Se):j.getChannelData(0);for(let Le=0;Le<j.length;Le++)Je[_e+Le]=Ue[Le];if(he==="insert")for(let Le=0;Le<Me;Le++)Je[_e+j.length+Le]=tt[le+Le]}return await V.close(),we},Xe=v.useCallback(()=>{const Q=M.current;if(!Q)return;const j=Q.getContext("2d");if(!j)return;const le=Q.getBoundingClientRect(),he=le.width,V=le.height,Ce=me.current,ve=f||c||1,_e=a==="recording"?c:x;j.fillStyle="#2d3b35",j.fillRect(0,0,he,V);const Me=8,Oe="rgba(0, 0, 0, 0.4)",we=j.createLinearGradient(0,0,0,Me);we.addColorStop(0,Oe),we.addColorStop(1,"transparent"),j.fillStyle=we,j.fillRect(0,0,he,Me);const Se=j.createLinearGradient(0,V-Me,0,V);Se.addColorStop(0,"transparent"),Se.addColorStop(1,Oe),j.fillStyle=Se,j.fillRect(0,V-Me,he,Me);const Je=j.createLinearGradient(0,0,Me,0);Je.addColorStop(0,Oe),Je.addColorStop(1,"transparent"),j.fillStyle=Je,j.fillRect(0,0,Me,V);const tt=j.createLinearGradient(he-Me,0,he,0);tt.addColorStop(0,"transparent"),tt.addColorStop(1,Oe),j.fillStyle=tt,j.fillRect(he-Me,0,Me,V),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,V/2),j.lineTo(he,V/2),j.stroke();const Ue=he/2;if(Ce.length>0)if(a==="recording")for(let ut=0;ut<Ce.length;ut++){const St=Ce.length-1-ut,Zt=Ue-St*4;if(Zt<-3||Zt>he)continue;const Tt=Ce[ut]*(V/2-12),A=V/2-Tt;j.fillStyle="#10b981",j.fillRect(Zt,A,3,Tt*2)}else{const ut=ve>0?_e/ve*Ce.length:0;for(let St=0;St<Ce.length;St++){const Zt=ut-St,Tt=Ue-Zt*4;if(Tt<-3||Tt>he)continue;const A=Ce[St]*(V/2-12),O=V/2-A;j.fillStyle=St<=ut?"#10b981":"#4b5563",j.fillRect(Tt,O,3,A*2)}}j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(Ue,0),j.lineTo(Ue,V),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText(ke(_e),Ue,V-6),a==="recording"&&(j.fillStyle="#ef4444",j.beginPath(),j.arc(20,20,8,0,Math.PI*2),j.fill(),j.fillStyle="#fff",j.font="10px sans-serif",j.textAlign="left",j.fillText("REC",34,24)),j.textAlign="left"},[a,x,c,f]),st=()=>{const Q=ee.current;if(!Q||!de.current)return;const j=Q.frequencyBinCount,le=new Uint8Array(j);Q.getByteTimeDomainData(le);let he=0;for(let ve=0;ve<j;ve++){const _e=(le[ve]-128)/128;he+=_e*_e}const V=Math.sqrt(he/j),Ce=Math.min(1,V*3);me.current.push(Ce),Xe(),de.current&&(z.current=requestAnimationFrame(st))},Z=async()=>{try{C(null),D(!1),X.current===null&&(me.current=[]);const Q=await navigator.mediaDevices.getUserMedia({audio:!0});W.current=Q;const j=new AudioContext;$.current=j;const le=j.createAnalyser();le.fftSize=2048,ee.current=le,j.createMediaStreamSource(Q).connect(le);const V=new MediaRecorder(Q);I.current=V,q.current=[],V.ondataavailable=Ce=>{Ce.data.size>0&&q.current.push(Ce.data)},V.onstop=async()=>{try{if(de.current=!1,q.current.length===0){C("No audio was recorded. Please try again."),u("idle"),Q.getTracks().forEach(we=>we.stop());return}const Ce=new Blob(q.current,{type:"audio/webm"});let ve,_e;if(X.current!==null&&oe.current)try{const we=await te(Ce),Se=oe.current.sampleRate,Je=Math.floor(X.current*Se),tt=await be(oe.current,we,Je,Ne.current);ve=ge(tt),_e=tt.length/tt.sampleRate,Ne.current==="insert"&&(me.current=[...me.current,...Ee.current]),X.current=null,oe.current=null,G.current=[],Ee.current=[]}catch{ve=Ce,_e=ye.current>0?ye.current:1}else ve=Ce,_e=ye.current>0?ye.current:1;if(ce.current=ve,Q.getTracks().forEach(we=>we.stop()),B.current&&t){T(we=>[...we,ve]),L(we=>({...we,total:we.total+1})),ce.current=null,me.current=[],w(0),p(0),d(0),u("idle");return}const Me=URL.createObjectURL(ve),Oe=new Audio(Me);Oe.ontimeupdate=()=>{w(Oe.currentTime)},Oe.onended=()=>{m(!1)},ie.current=Oe,p(_e),w(_e),u("editing")}catch{C("Failed to process recording"),u("idle")}},V.start(100),de.current=!0,u("recording"),d(0),ye.current=0,Y.current=setInterval(()=>{ye.current+=1,d(ye.current),ye.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),de.current=!1,b(null),Y.current&&(clearInterval(Y.current),Y.current=null),z.current&&(cancelAnimationFrame(z.current),z.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},Ie=()=>{de.current=!1,D(!1),b(null),z.current&&(cancelAnimationFrame(z.current),z.current=null),Y.current&&(clearInterval(Y.current),Y.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},$e=Q=>{const j=M.current;if(!j)return;const le=f||c;if(le<=0)return;const he=me.current;if(he.length===0)return;const V=j.getBoundingClientRect(),Ce=Q-ue.current,ve=4,_e=V.width/j.width,Me=he.length/le*ve,Oe=-Ce/(Me*_e),we=ae.current+Oe,Se=Math.max(0,Math.min(we,le));ie.current&&(ie.current.currentTime=Se),w(Se)},ze=()=>{ie.current&&(ie.current.currentTime=0),w(0)},zt=()=>{const Q=f||c;ie.current&&(ie.current.currentTime=Q),w(Q)},$t=()=>{const Q=ie.current;Q&&(g?(Q.pause(),w(Q.currentTime),m(!1)):(Q.currentTime=x,Q.play().catch(()=>{}),m(!0)))},Jt=async Q=>{if(!ce.current){Z();return}try{ie.current&&(ie.current.pause(),m(!1)),Ne.current=Q,oe.current=await te(ce.current);const j=f||c;X.current=x;const le=j>0?x/j:0,he=Math.floor(le*me.current.length);G.current=me.current.slice(0,he),Ee.current=me.current.slice(he),me.current=[...G.current],Z()}catch{C("Failed to prepare recording. Please try again.")}},ne=()=>{ie.current&&(ie.current.pause(),ie.current=null),ce.current=null,oe.current=null,X.current=null,G.current=[],m(!1),w(0),p(0),d(0),Z()},fe=()=>{ce.current?r(ce.current,f||c):alert("No audio recorded yet!")};v.useEffect(()=>{a==="recording"&&M.current&&ee.current&&de.current&&(z.current=requestAnimationFrame(st))},[a]),v.useEffect(()=>{const Q=M.current;if(!Q)return;const j=()=>{const le=window.devicePixelRatio||1,he=Q.getBoundingClientRect();Q.width=he.width*le,Q.height=he.height*le;const V=Q.getContext("2d");V&&V.scale(le,le)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),v.useEffect(()=>{if(a==="idle"){const Q=M.current;if(!Q)return;const j=Q.getContext("2d");if(!j)return;const le=Q.getBoundingClientRect(),he=le.width,V=le.height;j.fillStyle="#2d3b35",j.fillRect(0,0,he,V);const Ce=8,ve="rgba(0, 0, 0, 0.4)",_e=j.createLinearGradient(0,0,0,Ce);_e.addColorStop(0,ve),_e.addColorStop(1,"transparent"),j.fillStyle=_e,j.fillRect(0,0,he,Ce);const Me=j.createLinearGradient(0,V-Ce,0,V);Me.addColorStop(0,"transparent"),Me.addColorStop(1,ve),j.fillStyle=Me,j.fillRect(0,V-Ce,he,Ce);const Oe=j.createLinearGradient(0,0,Ce,0);Oe.addColorStop(0,ve),Oe.addColorStop(1,"transparent"),j.fillStyle=Oe,j.fillRect(0,0,Ce,V);const we=j.createLinearGradient(he-Ce,0,he,0);we.addColorStop(0,"transparent"),we.addColorStop(1,ve),j.fillStyle=we,j.fillRect(he-Ce,0,Ce,V),j.strokeStyle="#5a6b62",j.lineWidth=1,j.beginPath(),j.moveTo(0,V/2),j.lineTo(he,V/2),j.stroke();const Se=he/2;j.strokeStyle="#ef4444",j.lineWidth=1,j.beginPath(),j.moveTo(Se,0),j.lineTo(Se,V),j.stroke(),j.fillStyle="#fff",j.font="bold 18px monospace",j.textAlign="center",j.fillText("00:00",Se,V-6)}},[a]);const qe=v.useCallback(Q=>{T(j=>[...j,Q]),L(j=>({...j,total:j.total+1}))},[]);if(v.useEffect(()=>{(async()=>{if(k.current||R.length===0||!t)return;k.current=!0;const j=R[0];try{const le=await t(j);le&&n&&n(le)}catch(le){console.error("Transcription failed:",le)}finally{T(le=>le.slice(1)),L(le=>({...le,completed:le.completed+1})),k.current=!1}})()},[R,t,n]),v.useEffect(()=>()=>{de.current=!1,Y.current&&clearInterval(Y.current),z.current&&cancelAnimationFrame(z.current),W.current&&W.current.getTracks().forEach(Q=>Q.stop()),$.current&&$.current.state!=="closed"&&$.current.close()},[]),v.useEffect(()=>{if(a==="editing"&&g){let Q;const j=()=>{const le=ie.current;if(le&&g){const he=M.current;if(he){const V=he.getContext("2d");if(V){const Ce=he.getBoundingClientRect(),ve=Ce.width,_e=Ce.height,Me=me.current,Oe=f||c||1,we=le.currentTime;V.fillStyle="#2d3b35",V.fillRect(0,0,ve,_e);const Se=8,Je="rgba(0, 0, 0, 0.4)",tt=V.createLinearGradient(0,0,0,Se);tt.addColorStop(0,Je),tt.addColorStop(1,"transparent"),V.fillStyle=tt,V.fillRect(0,0,ve,Se);const Ue=V.createLinearGradient(0,_e-Se,0,_e);Ue.addColorStop(0,"transparent"),Ue.addColorStop(1,Je),V.fillStyle=Ue,V.fillRect(0,_e-Se,ve,Se);const Le=V.createLinearGradient(0,0,Se,0);Le.addColorStop(0,Je),Le.addColorStop(1,"transparent"),V.fillStyle=Le,V.fillRect(0,0,Se,_e);const lt=V.createLinearGradient(ve-Se,0,ve,0);lt.addColorStop(0,"transparent"),lt.addColorStop(1,Je),V.fillStyle=lt,V.fillRect(ve-Se,0,Se,_e),V.strokeStyle="#5a6b62",V.lineWidth=1,V.beginPath(),V.moveTo(0,_e/2),V.lineTo(ve,_e/2),V.stroke();const ut=ve/2,St=3,Zt=4,Tt=Oe>0?we/Oe*Me.length:0;for(let J=0;J<Me.length;J++){const pe=Tt-J,Be=ut-pe*Zt;if(Be<-St||Be>ve)continue;const je=Me[J]*(_e/2-12),Ae=_e/2-je;V.fillStyle=J<=Tt?"#10b981":"#4b5563",V.fillRect(Be,Ae,St,je*2)}V.strokeStyle="#ef4444",V.lineWidth=1,V.beginPath(),V.moveTo(ut,0),V.lineTo(ut,_e),V.stroke(),V.fillStyle="#fff",V.font="bold 18px monospace",V.textAlign="center";const A=Math.floor(we/60),O=Math.floor(we%60);V.fillText(`${A.toString().padStart(2,"0")}:${O.toString().padStart(2,"0")}`,ut,_e-6),V.textAlign="left"}}Q=requestAnimationFrame(j)}};return Q=requestAnimationFrame(j),()=>cancelAnimationFrame(Q)}},[a,g,f,c]),v.useEffect(()=>{a==="editing"&&!g&&Xe()},[a,x,g,Xe]),y)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:y}),h.jsx("button",{onClick:()=>{C(null),Z()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ke={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Ye={...Ke,opacity:.3,cursor:"not-allowed"},At=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:At,children:[h.jsx("canvas",{ref:M,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Q=>{if(a==="editing"){xe.current=!0,ue.current=Q.clientX,ae.current=x;const j=he=>{xe.current&&$e(he.clientX)},le=()=>{xe.current=!1,window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",le)};window.addEventListener("mousemove",j),window.addEventListener("mouseup",le)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ze,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ye:Ke,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const Q=I.current;Q&&(Q.state==="recording"?(Q.pause(),D(!0)):Q.state==="paused"&&(Q.resume(),D(!1)))}else $t()},disabled:a==="idle",style:a==="idle"?Ye:Ke,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:zt,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ye:Ke,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),h.jsx("button",{onClick:()=>{_==="insert"?Ie():a==="idle"?(b("insert"),Z()):a==="editing"&&(b("insert"),Jt("insert"))},disabled:a==="recording"&&_!=="insert"||g,style:a==="recording"&&_!=="insert"||g?Ye:Ke,title:_==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{B.current||(_==="mic"?Ie():a==="idle"?(b("mic"),Z()):a==="editing"&&(b("mic"),Jt("replace")))},onMouseDown:()=>{B.current&&a==="idle"&&!g&&(b("mic"),Z())},onMouseUp:()=>{B.current&&a==="recording"&&_==="mic"&&Ie()},onMouseLeave:()=>{B.current&&a==="recording"&&_==="mic"&&Ie()},onTouchStart:()=>{B.current&&a==="idle"&&!g&&(b("mic"),Z())},onTouchEnd:()=>{B.current&&a==="recording"&&_==="mic"&&Ie()},disabled:a==="recording"&&_!=="mic"||g,style:a==="recording"&&_!=="mic"||g?Ye:Ke,title:E?"Hold to record (walkie-talkie)":_==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{_==="startover"?Ie():a==="editing"&&(b("startover"),ne())},disabled:a==="idle"||a==="recording"&&_!=="startover"||g,style:a==="idle"||a==="recording"&&_!=="startover"||g?Ye:Ke,title:_==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:_==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[F.total>0&&F.completed<F.total&&h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),F.completed,"/",F.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>N(!E),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:E?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:E?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:E?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&ce.current&&qe(ce.current)},disabled:a!=="editing",style:a!=="editing"?Ye:Ke,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:fe,disabled:a!=="editing",style:a!=="editing"?Ye:Ke,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),F.total>0&&F.completed<F.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${F.completed/F.total*100}%`,transition:"width 0.3s ease"}})})]})}function Pg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=v.useState(!1),[c,d]=v.useState(null),[f,p]=v.useState(!1),g=v.useRef(null),m=y=>{t(e?`${e}
184
184
 
185
- ${b}`:b)},x=async b=>{if(!(!e.trim()||a||!s)){u(!0),d(b),p(!1);try{const C=await s(b,e);t(C)}catch(C){console.error(`${b} failed:`,C)}finally{u(!1),d(null)}}},v=()=>{setTimeout(()=>{var b;(b=g.current)!=null&&b.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Hc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),s&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!e.trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:v,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:b=>t(b.target.value),onKeyDown:b=>b.stopPropagation(),placeholder:i,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}var Pg={value:()=>{}};function ua(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Og(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=ua.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Og(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Ig(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=Ol(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Ol(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Ig(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Ol(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Pg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Il={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vi(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Il.hasOwnProperty(e)?{space:Il[e],local:r}:r}function zg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function $g(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Gc(r){var e=vi(r);return(e.local?$g:zg)(e)}function qg(){}function ca(r){return r==null?qg:function(){return this.querySelector(r)}}function Ug(r){typeof r!="function"&&(r=ca(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=new Array(o),a,u,c=0;c<o;++c)(a=i[c])&&(u=r.call(a,a.__data__,c,i))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new vt(n,this._parents)}function Wg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Vg(){return[]}function Kc(r){return r==null?Vg:function(){return this.querySelectorAll(r)}}function Hg(r){return function(){return Wg(r.apply(this,arguments))}}function Gg(r){typeof r=="function"?r=Hg(r):r=Kc(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new vt(n,s)}function Yc(r){return function(){return this.matches(r)}}function Qc(r){return function(e){return e.matches(r)}}var Kg=Array.prototype.find;function Yg(r){return function(){return Kg.call(this.children,r)}}function Qg(){return this.firstElementChild}function Xg(r){return this.select(r==null?Qg:Yg(typeof r=="function"?r:Qc(r)))}var Jg=Array.prototype.filter;function Zg(){return Array.from(this.children)}function e0(r){return function(){return Jg.call(this.children,r)}}function t0(r){return this.selectAll(r==null?Zg:e0(typeof r=="function"?r:Qc(r)))}function r0(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new vt(n,this._parents)}function Xc(r){return new Array(r.length)}function n0(){return new vt(this._enter||this._groups.map(Xc),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function s0(r){return function(){return r}}function i0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function o0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function a0(r){return r.__data__}function l0(r,e){if(!arguments.length)return Array.from(this,a0);var t=e?o0:i0,n=this._parents,s=this._groups;typeof r!="function"&&(r=s0(r));for(var i=s.length,o=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=u0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),v=a[u]=new Array(f);t(c,d,m,x,v,p,e);for(var b=0,C=0,S,D;b<g;++b)if(S=m[b]){for(b>=C&&(C=b+1);!(D=x[C])&&++C<g;);S._next=D||null}}return o=new vt(o,n),o._enter=l,o._exit=a,o}function u0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function c0(){return new vt(this._exit||this._groups.map(Xc),this._parents)}function d0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function f0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),l=new Array(s),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new vt(l,this._parents)}function h0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function p0(r){r||(r=g0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],l=o.length,a=s[i]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new vt(s,this._parents).order()}function g0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function m0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function y0(){return Array.from(this)}function x0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function b0(){let r=0;for(const e of this)++r;return r}function _0(){return!this.node()}function v0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,l;i<o;++i)(l=s[i])&&r.call(l,l.__data__,i,s);return this}function w0(r){return function(){this.removeAttribute(r)}}function C0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function S0(r,e){return function(){this.setAttribute(r,e)}}function E0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function k0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function D0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function A0(r,e){var t=vi(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?C0:w0:typeof e=="function"?t.local?D0:k0:t.local?E0:S0)(t,e))}function Jc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function T0(r){return function(){this.style.removeProperty(r)}}function N0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function B0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?T0:typeof e=="function"?B0:N0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Jc(r).getComputedStyle(r,null).getPropertyValue(e)}function R0(r){return function(){delete this[r]}}function M0(r,e){return function(){this[r]=e}}function j0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function L0(r,e){return arguments.length>1?this.each((e==null?R0:typeof e=="function"?j0:M0)(r,e)):this.node()[r]}function Zc(r){return r.trim().split(/^|\s+/)}function da(r){return r.classList||new ed(r)}function ed(r){this._node=r,this._names=Zc(r.getAttribute("class")||"")}ed.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function td(r,e){for(var t=da(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function rd(r,e){for(var t=da(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function P0(r){return function(){td(this,r)}}function O0(r){return function(){rd(this,r)}}function I0(r,e){return function(){(e.apply(this,arguments)?td:rd)(this,r)}}function z0(r,e){var t=Zc(r+"");if(arguments.length<2){for(var n=da(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?I0:e?P0:O0)(t,e))}function $0(){this.textContent=""}function q0(r){return function(){this.textContent=r}}function U0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function W0(r){return arguments.length?this.each(r==null?$0:(typeof r=="function"?U0:q0)(r)):this.node().textContent}function V0(){this.innerHTML=""}function H0(r){return function(){this.innerHTML=r}}function G0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function K0(r){return arguments.length?this.each(r==null?V0:(typeof r=="function"?G0:H0)(r)):this.node().innerHTML}function Y0(){this.nextSibling&&this.parentNode.appendChild(this)}function Q0(){return this.each(Y0)}function X0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function J0(){return this.each(X0)}function Z0(r){var e=typeof r=="function"?r:Gc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function em(){return null}function tm(r,e){var t=typeof r=="function"?r:Gc(r),n=e==null?em:typeof e=="function"?e:ca(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function rm(){var r=this.parentNode;r&&r.removeChild(this)}function nm(){return this.each(rm)}function sm(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function im(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function om(r){return this.select(r?im:sm)}function am(r){return arguments.length?this.property("__data__",r):this.node().__data__}function lm(r){return function(e){r.call(this,e,this.__data__)}}function um(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function cm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function dm(r,e,t){return function(){var n=this.__on,s,i=lm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function fm(r,e,t){var n=um(r+""),s,i=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(s=0,c=l[a];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?dm:cm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function nd(r,e,t){var n=Jc(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function hm(r,e){return function(){return nd(this,r,e)}}function pm(r,e){return function(){return nd(this,r,e.apply(this,arguments))}}function gm(r,e){return this.each((typeof e=="function"?pm:hm)(r,e))}function*mm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var sd=[null];function vt(r,e){this._groups=r,this._parents=e}function is(){return new vt([[document.documentElement]],sd)}function ym(){return this}vt.prototype=is.prototype={constructor:vt,select:Ug,selectAll:Gg,selectChild:Xg,selectChildren:t0,filter:r0,data:l0,enter:n0,exit:c0,join:d0,merge:f0,selection:ym,order:h0,sort:p0,call:m0,nodes:y0,node:x0,size:b0,empty:_0,each:v0,attr:A0,style:F0,property:L0,classed:z0,text:W0,html:K0,raise:Q0,lower:J0,append:Z0,insert:tm,remove:nm,clone:om,datum:am,on:fm,dispatch:gm,[Symbol.iterator]:mm};function Ft(r){return typeof r=="string"?new vt([[document.querySelector(r)]],[document.documentElement]):new vt([[r]],sd)}function xm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=xm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function vo(r){r.preventDefault(),r.stopImmediatePropagation()}function bm(r){var e=r.document.documentElement,t=Ft(r).on("dragstart.drag",vo,_o);"onselectstart"in e?t.on("selectstart.drag",vo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function _m(r,e){var t=r.document.documentElement,n=Ft(r).on("dragstart.drag",null);e&&(n.on("click.drag",vo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function fa(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function id(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function os(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vm=/^#([0-9a-f]{3,8})$/,wm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),Cm=new RegExp(`^rgb\\(${Ht},${Ht},${Ht}\\)$`),Sm=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Em=new RegExp(`^rgba\\(${Ht},${Ht},${Ht},${qn}\\)$`),km=new RegExp(`^hsl\\(${qn},${Ht},${Ht}\\)$`),Dm=new RegExp(`^hsla\\(${qn},${Ht},${Ht},${qn}\\)$`),zl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};fa(os,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:$l,formatHex:$l,formatHex8:Am,formatHsl:Tm,formatRgb:ql,toString:ql});function $l(){return this.rgb().formatHex()}function Am(){return this.rgb().formatHex8()}function Tm(){return od(this).formatHsl()}function ql(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=vm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ul(e):t===3?new gt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=wm.exec(r))?new gt(e[1],e[2],e[3],1):(e=Cm.exec(r))?new gt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Sm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Em.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=km.exec(r))?Hl(e[1],e[2]/100,e[3]/100,1):(e=Dm.exec(r))?Hl(e[1],e[2]/100,e[3]/100,e[4]):zl.hasOwnProperty(r)?Ul(zl[r]):r==="transparent"?new gt(NaN,NaN,NaN,0):null}function Ul(r){return new gt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new gt(r,e,t,n)}function Nm(r){return r instanceof os||(r=Un(r)),r?(r=r.rgb(),new gt(r.r,r.g,r.b,r.opacity)):new gt}function wo(r,e,t,n){return arguments.length===1?Nm(r):new gt(r,e,t,n??1)}function gt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}fa(gt,wo,id(os,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new gt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new gt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new gt(Tr(this.r),Tr(this.g),Tr(this.b),Js(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wl,formatHex:Wl,formatHex8:Bm,formatRgb:Vl,toString:Vl}));function Wl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Bm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Hl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Rt(r,e,t,n)}function od(r){if(r instanceof Rt)return new Rt(r.h,r.s,r.l,r.opacity);if(r instanceof os||(r=Un(r)),!r)return new Rt;if(r instanceof Rt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,l=i-s,a=(i+s)/2;return l?(e===i?o=(t-n)/l+(t<n)*6:t===i?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?i+s:2-i-s,o*=60):l=a>0&&a<1?0:o,new Rt(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?od(r):new Rt(r,e,t,n??1)}function Rt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}fa(Rt,Fm,id(os,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Rt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Rt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new gt(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Rt(Gl(this.h),ys(this.s),ys(this.l),Js(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Gl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Gl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ad=r=>()=>r;function Rm(r,e){return function(t){return r+t*e}}function Mm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function jm(r){return(r=+r)==1?ld:function(e,t){return t-e?Mm(e,t,r):ad(isNaN(e)?t:e)}}function ld(r,e){var t=e-r;return t?Rm(r,t):ad(isNaN(r)?e:r)}const Kl=function r(e){var t=jm(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ld(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Lm(r){return function(){return r}}function Pm(r){return function(e){return r(e)+""}}function Om(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Pm(a[0].x):Lm(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Yl=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ud(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Yl,skewX:Math.atan(a)*Yl,scaleX:o,scaleY:l}}var xs;function Im(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:ud(e.a,e.b,e.c,e.d,e.e,e.f)}function zm(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,ud(r.a,r.b,r.c,r.d,r.e,r.f))}function cd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var $m=cd(Im,"px, ","px)","deg)"),qm=cd(zm,", ",")",")"),Um=1e-12;function Ql(r){return((r=Math.exp(r))+1/r)/2}function Wm(r){return((r=Math.exp(r))-1/r)/2}function Vm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Hm=function r(e,t,n){function s(i,o){var l=i[0],a=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,v;if(m<Um)v=Math.log(f/u)/e,x=function(y){return[l+y*p,a+y*g,u*Math.exp(e*y*v)]};else{var b=Math.sqrt(m),C=(f*f-u*u+n*m)/(2*u*t*b),S=(f*f-u*u-n*m)/(2*f*t*b),D=Math.log(Math.sqrt(C*C+1)-C),w=Math.log(Math.sqrt(S*S+1)-S);v=(w-D)/e,x=function(y){var k=y*v,N=Ql(D),F=u/(t*b)*(N*Vm(e*k+D)-Wm(D));return[l+F*p,a+F*g,u*N/Ql(e*k+D)]}}return x.duration=v*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,dd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,fd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function ha(){return Lr||(fd(Gm),Lr=Wn.now()+wi)}function Gm(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=hd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?ha():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function hd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Km(){ha(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{Km()}finally{nn=0,Qm(),Lr=0}}function Ym(){var r=Wn.now(),e=r-ei;e>dd&&(wi-=e,ei=r)}function Qm(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(Ym,dd)),nn=1,fd(Xl))}}function Jl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var Xm=ua("start","end","cancel","interrupt"),Jm=[],pd=0,Zl=1,ko=2,Ss=3,eu=4,Do=5,Es=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;Zm(r,t,{name:e,index:n,group:s,on:Xm,tween:Jm,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pd})}function pa(r,e){var t=Ot(r,e);if(t.state>pd)throw new Error("too late; already scheduled");return t}function Xt(r,e){var t=Ot(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function Ot(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function Zm(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=hd(i,0,t.time);function i(u){t.state=Zl,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==Zl)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Jl(o);p.state===eu?(p.state=Es,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=Es,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Jl(function(){t.state===Ss&&(t.state=eu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=ko,t.on.call("start",r,r.__data__,t.index,t.group),t.state===ko){for(t.state=Ss,s=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Do,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=Es,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function ks(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>ko&&n.state<Do,n.state=Es,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function e2(r){return this.each(function(){ks(this,r)})}function t2(r,e){var t,n;return function(){var s=Xt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function r2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Xt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var l={name:e,value:t},a=0,u=s.length;a<u;++a)if(s[a].name===e){s[a]=l;break}a===u&&s.push(l)}i.tween=s}}function n2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=Ot(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?t2:r2)(t,r,e))}function ga(r,e,t){var n=r._id;return r.each(function(){var s=Xt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Ot(s,n).value[e]}}function gd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Kl:(t=Un(e))?(e=t,Kl):Om)(r,e)}function s2(r){return function(){this.removeAttribute(r)}}function i2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function o2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function a2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function l2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function u2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function c2(r,e){var t=vi(r),n=t==="transform"?qm:gd;return this.attrTween(r,typeof e=="function"?(t.local?u2:l2)(t,n,ga(this,"attr."+r,e)):e==null?(t.local?i2:s2)(t):(t.local?a2:o2)(t,n,e))}function d2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function f2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function h2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&f2(r,i)),t}return s._value=e,s}function p2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&d2(r,i)),t}return s._value=e,s}function g2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=vi(r);return this.tween(t,(n.local?h2:p2)(n,e))}function m2(r,e){return function(){pa(this,r).delay=+e.apply(this,arguments)}}function y2(r,e){return e=+e,function(){pa(this,r).delay=e}}function x2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?m2:y2)(e,r)):Ot(this.node(),e).delay}function b2(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function _2(r,e){return e=+e,function(){Xt(this,r).duration=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?b2:_2)(e,r)):Ot(this.node(),e).duration}function w2(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function C2(r){var e=this._id;return arguments.length?this.each(w2(e,r)):Ot(this.node(),e).ease}function S2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function E2(r){if(typeof r!="function")throw new Error;return this.each(S2(this._id,r))}function k2(r){typeof r!="function"&&(r=Yc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function D2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),l=0;l<i;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function A2(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function T2(r,e,t){var n,s,i=A2(e)?pa:Xt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function N2(r,e){var t=this._id;return arguments.length<2?Ot(this.node(),t).on.on(r):this.each(T2(t,r,e))}function B2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",B2(this._id))}function R2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ca(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,Ot(c,t)));return new ir(i,this._parents,e,t)}function M2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Kc(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=Ot(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var j2=is.prototype.constructor;function L2(){return new j2(this._groups,this._parents)}function P2(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function md(r){return function(){this.style.removeProperty(r)}}function O2(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function I2(r,e,t){var n,s,i;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l))}}function z2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Xt(this,r),u=a.on,c=a.value[i]==null?l||(l=md(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function $2(r,e,t){var n=(r+="")=="transform"?$m:gd;return e==null?this.styleTween(r,P2(r,n)).on("end.style."+r,md(r)):typeof e=="function"?this.styleTween(r,I2(r,n,ga(this,"style."+r,e))).each(z2(this._id,r)):this.styleTween(r,O2(r,n,e),t).on("end.style."+r,null)}function q2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function U2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&q2(r,o,t)),n}return i._value=e,i}function W2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,U2(r,e,t??""))}function V2(r){return function(){this.textContent=r}}function H2(r){return function(){var e=r(this);this.textContent=e??""}}function G2(r){return this.tween("text",typeof r=="function"?H2(ga(this,"text",r)):V2(r==null?"":r+""))}function K2(r){return function(e){this.textContent=r.call(this,e)}}function Y2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&K2(s)),e}return n._value=r,n}function Q2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,Y2(r))}function X2(){for(var r=this._name,e=this._id,t=yd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=Ot(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function J2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var l={value:o},a={value:function(){--s===0&&i()}};t.each(function(){var u=Xt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),s===0&&i()})}var Z2=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function yd(){return++Z2}var tr=is.prototype;ir.prototype={constructor:ir,select:R2,selectAll:M2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:k2,merge:D2,selection:L2,transition:X2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:N2,attr:c2,attrTween:g2,style:$2,styleTween:W2,text:G2,textTween:Q2,remove:F2,tween:n2,delay:x2,duration:v2,ease:C2,easeVarying:E2,end:J2,[Symbol.iterator]:tr[Symbol.iterator]};function ey(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ty={time:null,delay:0,duration:250,ease:ey};function ry(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function ny(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=yd(),(t=ty).time=ha(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||ry(a,e));return new ir(n,this._parents,r,e)}is.prototype.interrupt=e2;is.prototype.transition=ny;const bs=r=>()=>r;function sy(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function iy(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function oy(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function tu(){return this.__zoom||ri}function ay(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function ly(){return navigator.maxTouchPoints||"ontouchstart"in this}function uy(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function cy(){var r=iy,e=oy,t=uy,n=ay,s=ly,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Hm,u=ua("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(E){E.property("__zoom",tu).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(E,B,R,O){var H=E.selection?E.selection():E;H.property("__zoom",tu),E!==H?D(E,B,R,O):H.interrupt().each(function(){w(this,arguments).event(O).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},v.scaleBy=function(E,B,R,O){v.scaleTo(E,function(){var H=this.__zoom.k,U=typeof B=="function"?B.apply(this,arguments):B;return H*U},R,O)},v.scaleTo=function(E,B,R,O){v.transform(E,function(){var H=e.apply(this,arguments),U=this.__zoom,Z=R==null?S(H):typeof R=="function"?R.apply(this,arguments):R,q=U.invert(Z),K=typeof B=="function"?B.apply(this,arguments):B;return t(C(b(U,K),Z,q),H,o)},R,O)},v.translateBy=function(E,B,R,O){v.transform(E,function(){return t(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof R=="function"?R.apply(this,arguments):R),e.apply(this,arguments),o)},null,O)},v.translateTo=function(E,B,R,O,H){v.transform(E,function(){var U=e.apply(this,arguments),Z=this.__zoom,q=O==null?S(U):typeof O=="function"?O.apply(this,arguments):O;return t(ri.translate(q[0],q[1]).scale(Z.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof R=="function"?-R.apply(this,arguments):-R),U,o)},O,H)};function b(E,B){return B=Math.max(i[0],Math.min(i[1],B)),B===E.k?E:new nr(B,E.x,E.y)}function C(E,B,R){var O=B[0]-R[0]*E.k,H=B[1]-R[1]*E.k;return O===E.x&&H===E.y?E:new nr(E.k,O,H)}function S(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function D(E,B,R,O){E.on("start.zoom",function(){w(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(O).end()}).tween("zoom",function(){var H=this,U=arguments,Z=w(H,U).event(O),q=e.apply(H,U),K=R==null?S(q):typeof R=="function"?R.apply(H,U):R,$=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),re=H.__zoom,ae=typeof B=="function"?B.apply(H,U):B,le=a(re.invert(K).concat($/re.k),ae.invert(K).concat($/ae.k));return function(ce){if(ce===1)ce=ae;else{var ve=le(ce),pe=$/ve[2];ce=new nr(pe,K[0]-ve[0]*pe,K[1]-ve[1]*pe)}Z.zoom(null,ce)}})}function w(E,B,R){return!R&&E.__zooming||new y(E,B)}function y(E,B){this.that=E,this.args=B,this.active=0,this.sourceEvent=null,this.extent=e.apply(E,B),this.taps=0}y.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,B){return this.mouse&&E!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&E!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(E){var B=Ft(this.that).datum();u.call(E,this.that,new sy(E,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),B)}};function k(E,...B){if(!r.apply(this,arguments))return;var R=w(this,B).event(E),O=this.__zoom,H=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,n.apply(this,arguments)))),U=wr(E);if(R.wheel)(R.mouse[0][0]!==U[0]||R.mouse[0][1]!==U[1])&&(R.mouse[1]=O.invert(R.mouse[0]=U)),clearTimeout(R.wheel);else{if(O.k===H)return;R.mouse=[U,O.invert(U)],ks(this),R.start()}xn(E),R.wheel=setTimeout(Z,g),R.zoom("mouse",t(C(b(O,H),R.mouse[0],R.mouse[1]),R.extent,o));function Z(){R.wheel=null,R.end()}}function N(E,...B){if(f||!r.apply(this,arguments))return;var R=E.currentTarget,O=w(this,B,!0).event(E),H=Ft(E.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",$,!0),U=wr(E,R),Z=E.clientX,q=E.clientY;bm(E.view),Wi(E),O.mouse=[U,this.__zoom.invert(U)],ks(this),O.start();function K(re){if(xn(re),!O.moved){var ae=re.clientX-Z,le=re.clientY-q;O.moved=ae*ae+le*le>m}O.event(re).zoom("mouse",t(C(O.that.__zoom,O.mouse[0]=wr(re,R),O.mouse[1]),O.extent,o))}function $(re){H.on("mousemove.zoom mouseup.zoom",null),_m(re.view,O.moved),xn(re),O.event(re).end()}}function F(E,...B){if(r.apply(this,arguments)){var R=this.__zoom,O=wr(E.changedTouches?E.changedTouches[0]:E,this),H=R.invert(O),U=R.k*(E.shiftKey?.5:2),Z=t(C(b(R,U),O,H),e.apply(this,B),o);xn(E),l>0?Ft(this).transition().duration(l).call(D,Z,O,E):Ft(this).call(v.transform,Z,O,E)}}function T(E,...B){if(r.apply(this,arguments)){var R=E.touches,O=R.length,H=w(this,B,E.changedTouches.length===O).event(E),U,Z,q,K;for(Wi(E),Z=0;Z<O;++Z)q=R[Z],K=wr(q,this),K=[K,this.__zoom.invert(K),q.identifier],H.touch0?!H.touch1&&H.touch0[2]!==K[2]&&(H.touch1=K,H.taps=0):(H.touch0=K,U=!0,H.taps=1+!!c);c&&(c=clearTimeout(c)),U&&(H.taps<2&&(d=K[0],c=setTimeout(function(){c=null},p)),ks(this),H.start())}}function M(E,...B){if(this.__zooming){var R=w(this,B).event(E),O=E.changedTouches,H=O.length,U,Z,q,K;for(xn(E),U=0;U<H;++U)Z=O[U],q=wr(Z,this),R.touch0&&R.touch0[2]===Z.identifier?R.touch0[0]=q:R.touch1&&R.touch1[2]===Z.identifier&&(R.touch1[0]=q);if(Z=R.that.__zoom,R.touch1){var $=R.touch0[0],re=R.touch0[1],ae=R.touch1[0],le=R.touch1[1],ce=(ce=ae[0]-$[0])*ce+(ce=ae[1]-$[1])*ce,ve=(ve=le[0]-re[0])*ve+(ve=le[1]-re[1])*ve;Z=b(Z,Math.sqrt(ce/ve)),q=[($[0]+ae[0])/2,($[1]+ae[1])/2],K=[(re[0]+le[0])/2,(re[1]+le[1])/2]}else if(R.touch0)q=R.touch0[0],K=R.touch0[1];else return;R.zoom("touch",t(C(Z,q,K),R.extent,o))}}function L(E,...B){if(this.__zooming){var R=w(this,B).event(E),O=E.changedTouches,H=O.length,U,Z;for(Wi(E),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),U=0;U<H;++U)Z=O[U],R.touch0&&R.touch0[2]===Z.identifier?delete R.touch0:R.touch1&&R.touch1[2]===Z.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(Z=wr(Z,this),Math.hypot(d[0]-Z[0],d[1]-Z[1])<x)){var q=Ft(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return v.wheelDelta=function(E){return arguments.length?(n=typeof E=="function"?E:bs(+E),v):n},v.filter=function(E){return arguments.length?(r=typeof E=="function"?E:bs(!!E),v):r},v.touchable=function(E){return arguments.length?(s=typeof E=="function"?E:bs(!!E),v):s},v.extent=function(E){return arguments.length?(e=typeof E=="function"?E:bs([[+E[0][0],+E[0][1]],[+E[1][0],+E[1][1]]]),v):e},v.scaleExtent=function(E){return arguments.length?(i[0]=+E[0],i[1]=+E[1],v):[i[0],i[1]]},v.translateExtent=function(E){return arguments.length?(o[0][0]=+E[0][0],o[1][0]=+E[1][0],o[0][1]=+E[0][1],o[1][1]=+E[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(E){return arguments.length?(t=E,v):t},v.duration=function(E){return arguments.length?(l=+E,v):l},v.interpolate=function(E){return arguments.length?(a=E,v):a},v.on=function(){var E=u.on.apply(u,arguments);return E===u?v:E},v.clickDistance=function(E){return arguments.length?(m=(E=+E)*E,v):Math.sqrt(m)},v.tapDistance=function(E){return arguments.length?(x=+E,v):x},v}function xd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=_.useRef(null),a=_.useRef(),[u,c]=_.useState(n||{x:0,y:0,k:1});_.useEffect(()=>{if(!l.current)return;const x=cy().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const C={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(C),o==null||o(C)});a.current=x;const v=Ft(l.current);return v.call(x),v.on("dblclick.zoom",null),n&&v.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{v.on(".zoom",null)}},[e,t,s,i]),_.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const v={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(v),o==null||o(v)})},[o]);const d=_.useCallback((x,v,b,C=!0)=>{if(!l.current||!a.current)return;const S=Ft(l.current),D=ri.translate(x,v).scale(b);S.call(a.current.transform,D)},[]),f=_.useCallback(()=>{!l.current||!a.current||Ft(l.current).call(a.current.scaleBy,1.3)},[]),p=_.useCallback(()=>{!l.current||!a.current||Ft(l.current).call(a.current.scaleBy,.7)},[]),g=_.useCallback(()=>{d(0,0,1,!0)},[d]),m=_.useCallback((x,v=50)=>{if(!l.current||!a.current||x.length===0)return;const C=l.current.getBoundingClientRect();let S=1/0,D=1/0,w=-1/0,y=-1/0;for(const O of x){const H=O.width||200,U=O.height||100;S=Math.min(S,O.x),D=Math.min(D,O.y),w=Math.max(w,O.x+H),y=Math.max(y,O.y+U)}const k=w-S,N=y-D,F=(C.width-v*2)/k,T=(C.height-v*2)/N,M=Math.min(F,T,t),L=(S+w)/2,E=(D+y)/2,B=C.width/2-L*M,R=C.height/2-E*M;d(B,R,M,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function bd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=_.useState(null),[a,u]=_.useState(!1),[c,d]=_.useState({x:0,y:0}),f=_.useRef(null),p=_.useRef({x:0,y:0}),g=_.useRef(e);_.useEffect(()=>{g.current=e},[e]);const m=_.useCallback((C,S)=>{const D=g.current;return{x:(C-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=_.useCallback((C,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,w=parseFloat(D.dataset.x||"0"),y=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:w,nodeY:y},p.current={x:w,y},l(C),u(!0),d({x:0,y:0}),t==null||t(C)},[i,m,t]),v=_.useCallback(C=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,w=C.clientX-D.x,y=C.clientY-D.y,k=w/S.k,N=y/S.k,F=D.nodeX+k,T=D.nodeY+N;p.current={x:F,y:T},d({x:k,y:N}),n==null||n(o,F,T,k,N)},[a,o,n]),b=_.useCallback(()=>{if(!a||!o)return;const C=p.current;s==null||s(o,C.x,C.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return _.useEffect(()=>{if(!a)return;const C=D=>{v(D)},S=()=>{b()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",S)}},[a,v,b]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:v,endDrag:b}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,onSelectionChange:s}=r,[i,o]=_.useState(new Set),[l,a]=_.useState(null),[u,c]=_.useState(!1),d=_.useRef(null),f=_.useRef(e),p=_.useRef(t);_.useEffect(()=>{f.current=e},[e]),_.useEffect(()=>{p.current=t},[t]);const g=_.useCallback((w,y)=>{const k=f.current;return{x:(w-k.x)/k.k,y:(y-k.y)/k.k}},[]),m=_.useCallback((w,y)=>{const k=p.current.get(w);if(!k)return!1;const N=k.width||200,F=k.height||100;return k.x<y.x+y.width&&k.x+N>y.x&&k.y<y.y+y.height&&k.y+F>y.y},[]),x=_.useCallback(w=>{if(n||w.target.closest("[data-qmap-node]"))return;w.preventDefault();const k=g(w.clientX,w.clientY);d.current=k,a({x:k.x,y:k.y,width:0,height:0}),c(!0),w.shiftKey||o(new Set)},[n,g]),v=_.useCallback(w=>{if(!u||!d.current)return;const y=d.current,k=g(w.clientX,w.clientY),N={x:Math.min(y.x,k.x),y:Math.min(y.y,k.y),width:Math.abs(k.x-y.x),height:Math.abs(k.y-y.y)};a(N);const F=new Set;for(const[T]of p.current)m(T,N)&&F.add(T);o(F)},[u,g,m]),b=_.useCallback(()=>{u&&(s==null||s(Array.from(i)),c(!1),a(null),d.current=null)},[u,i,s]);_.useEffect(()=>{if(!u)return;const w=k=>{v(k)},y=()=>{b()};return window.addEventListener("mousemove",w),window.addEventListener("mouseup",y),()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",y)}},[u,v,b]);const C=_.useCallback((w,y=!1)=>{o(k=>{const N=new Set(y?k:[]);return k.has(w)&&y?N.delete(w):N.add(w),s==null||s(Array.from(N)),N})},[s]),S=_.useCallback(()=>{const w=new Set(p.current.keys());o(w),s==null||s(Array.from(w))},[s]),D=_.useCallback(()=>{o(new Set),s==null||s([])},[s]);return{selectedIds:i,setSelectedIds:o,selectionBox:l,isSelecting:u,startSelection:x,updateSelection:v,endSelection:b,toggleSelect:C,selectAll:S,clearSelection:D}}const vd=_.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=_.useCallback(b=>{i&&b.button===0&&o(e,b)},[e,i,o]),f=_.useCallback(b=>{s||l==null||l(b)},[s,l]),p=_.useCallback(b=>{b.stopPropagation(),a==null||a(b)},[a]),g=_.useCallback(b=>{b.preventDefault(),b.stopPropagation(),u==null||u(b)},[u]),m=t.width||200,x=t.height||100,v=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:v!==0?`rotate(${v}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",outline:n?"2px solid #3b82f6":void 0,outlineOffset:"2px",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function wd(r,e,t="bezier"){const n=Vn(r),s=Vn(e),i=Ao(r,s),o=Ao(e,n);switch(t){case"straight":return`M ${i.x} ${i.y} L ${o.x} ${o.y}`;case"orthogonal":return fy(i,o);case"bezier":default:return dy(i,o)}}function dy(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+i*Math.sign(t),a=r.y,u=e.x-i*Math.sign(t),c=e.y):(l=r.x,a=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function fy(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function Vn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function Ao(r,e){const t=r.width||200,n=r.height||100,s=Vn(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const l=t/2,a=n/2,u=Math.abs(o/(i||.001)),c=a/l;let d,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function hy(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return Vn(r)}}function py(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function gy(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function my(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,l=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+l)}return{x:e,y:t,width:n-e,height:s-t}}function yy(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function xy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Cd=_.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=_.useState(!1),c=_.useMemo(()=>wd(t,n,s),[t,n,s]),d=_.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=_.useCallback(()=>{u(!0)},[]),p=_.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(by,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function by({pathD:r,label:e,color:t}){const n=_.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Sd=_.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=_.useMemo(()=>e.filter(u=>t.has(u.source)&&t.has(u.target)),[e,t]),a=_.useMemo(()=>{if(t.size===0)return"0 0 1000 1000";let u=1/0,c=1/0,d=-1/0,f=-1/0;for(const p of t.values()){const g=p.width||200,m=p.height||100;u=Math.min(u,p.x-100),c=Math.min(c,p.y-100),d=Math.max(d,p.x+g+100),f=Math.max(f,p.y+m+100)}return u-=1e3,c-=1e3,d+=1e3,f+=1e3,`${u} ${c} ${d-u} ${f-c}`},[t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:a,preserveAspectRatio:"none",children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(u=>{const c=t.get(u.source),d=t.get(u.target);return h.jsx(Cd,{edge:u,sourcePosition:c,targetPosition:d,style:u.style||n,color:u.color||s,width:u.width||i,onClick:o},u.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Ed=_.memo(function({box:e,transform:t}){const n=_.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),_y=200,vy=100,wy="bezier",Cy="#94a3b8",Sy=2,Ey=.1,ky=4;function Dy({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=_y,defaultNodeHeight:i=vy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,onSelectionChange:c,onEdgeClick:d,onViewChange:f,onTransformChange:p,minZoom:g=Ey,maxZoom:m=ky,initialTransform:x,defaultEdgeStyle:v=wy,defaultEdgeColor:b=Cy,defaultEdgeWidth:C=Sy,draggable:S=!0,selectable:D=!0,zoomable:w=!0,pannable:y=!0,className:k="",style:N,background:F="#f8fafc",showGrid:T=!1,gridSize:M=20}){const L=r.data||{positions:{}},E=L.positions||{},B=_.useMemo(()=>{const ue=new Map;for(const _e of e){const Te=E[_e._id]||{x:0,y:0};ue.set(_e._id,{x:Te.x,y:Te.y,width:Te.width||s,height:Te.height||i,rotation:Te.rotation||0})}return ue},[e,E,s,i]),{transform:R,containerRef:O,zoomIn:H,zoomOut:U,resetZoom:Z,fitToContent:q}=xd({minZoom:g,maxZoom:m,initialTransform:x||L.transform,zoomable:w,pannable:y,onTransformChange:ue=>{p==null||p(ue);const _e={...L,transform:ue};f==null||f(_e)}}),[K,$]=_.useState(new Map),{draggedNodeId:re,startDrag:ae}=bd({transform:R,disabled:!S,onDragStart:ue=>{const _e=B.get(ue);_e&&$(new Map([[ue,{x:_e.x,y:_e.y}]]))},onDragMove:(ue,_e,Te)=>{$(new Map([[ue,{x:_e,y:Te}]]))},onDragEnd:(ue,_e,Te)=>{$(new Map),o==null||o(ue,_e,Te)}}),{selectedIds:le,selectionBox:ce,isSelecting:ve,startSelection:pe,toggleSelect:Fe,clearSelection:et}=_d({transform:R,nodePositions:B,disabled:!D,onSelectionChange:c}),ct=_.useCallback(ue=>{const _e=B.get(ue)||{x:0,y:0,width:s,height:i},Te=K.get(ue);return Te?{..._e,x:Te.x,y:Te.y}:_e},[B,K,s,i]),kt=_.useMemo(()=>{const ue=new Map;for(const _e of B.keys())ue.set(_e,ct(_e));return ue},[B,ct]),tt=_.useCallback((ue,_e)=>{Fe(ue._id,_e.shiftKey),l==null||l(ue,_e)},[Fe,l]),xt=_.useCallback(ue=>{ue.target.closest("[data-qmap-node]")||et()},[et]),dt=_.useCallback(ue=>{ue.button===0&&(ue.target.closest("[data-qmap-node]")||pe(ue))},[pe]),It=T?`
185
+ ${y}`:y)},x=async y=>{if(!(!e.trim()||a||!s)){u(!0),d(y),p(!1);try{const C=await s(y,e);t(C)}catch(C){console.error(`${y} failed:`,C)}finally{u(!1),d(null)}}},w=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Gc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),s&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!e.trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:w,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:i,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const qi={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Ig({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=v.useRef(null),a=v.useRef(null),u=v.useRef(null),[c,d]=v.useState(!0),[f,p]=v.useState(null),[g,m]=v.useState(n),[x,w]=v.useState(0),[y,C]=v.useState({x:0,y:0,width:100,height:100}),[S,D]=v.useState(!1),[_,b]=v.useState(null),[E,N]=v.useState({x:0,y:0}),[R,T]=v.useState({x:0,y:0,width:100,height:100}),F=o==="dark";v.useEffect(()=>{const X=new Image;X.crossOrigin="anonymous",X.onload=()=>{u.current=X,d(!1),L(X.width,X.height)},X.onerror=()=>{p("Failed to load image"),d(!1)},X.src=r},[r]);const L=v.useCallback((X,oe)=>{const G=qi[g];if(G===null){C({x:0,y:0,width:100,height:100});return}const Ee=X/oe;let Ne,xe;Ee>G?(xe=100,Ne=G/Ee*100):(Ne=100,xe=Ee/G*100);const ye=(100-Ne)/2,ue=(100-xe)/2;C({x:ye,y:ue,width:Ne,height:xe})},[g]);v.useEffect(()=>{u.current&&L(u.current.width,u.current.height)},[g,L]),v.useEffect(()=>{const X=a.current,oe=u.current;if(!X||!oe||c)return;const G=X.getContext("2d");if(!G)return;const Ee=l.current;if(!Ee)return;const Ne=Ee.clientWidth,xe=Ee.clientHeight-120,ye=oe.width/oe.height;let ue,ae;Ne/xe>ye?(ae=xe,ue=ae*ye):(ue=Ne,ae=ue/ye),X.width=ue,X.height=ae,G.clearRect(0,0,ue,ae),G.save(),G.translate(ue/2,ae/2),G.rotate(x*Math.PI/180),x===90||x===270?G.drawImage(oe,-ae/2,-ue/2,ae,ue):G.drawImage(oe,-ue/2,-ae/2,ue,ae),G.restore(),G.fillStyle="rgba(0, 0, 0, 0.6)";const ke=y.x/100*ue,te=y.y/100*ae,ge=y.width/100*ue,be=y.height/100*ae;G.fillRect(0,0,ue,te),G.fillRect(0,te+be,ue,ae-te-be),G.fillRect(0,te,ke,be),G.fillRect(ke+ge,te,ue-ke-ge,be),G.strokeStyle="#fff",G.lineWidth=2,G.strokeRect(ke,te,ge,be),G.strokeStyle="rgba(255, 255, 255, 0.3)",G.lineWidth=1,G.beginPath(),G.moveTo(ke+ge/3,te),G.lineTo(ke+ge/3,te+be),G.moveTo(ke+ge*2/3,te),G.lineTo(ke+ge*2/3,te+be),G.moveTo(ke,te+be/3),G.lineTo(ke+ge,te+be/3),G.moveTo(ke,te+be*2/3),G.lineTo(ke+ge,te+be*2/3),G.stroke();const Xe=12;G.fillStyle="#fff",[{x:ke,y:te},{x:ke+ge,y:te},{x:ke,y:te+be},{x:ke+ge,y:te+be}].forEach(Z=>{G.fillRect(Z.x-Xe/2,Z.y-Xe/2,Xe,Xe)})},[y,x,c]);const k=X=>{const oe=a.current;if(!oe)return;const G=oe.getBoundingClientRect(),Ee=(X.clientX-G.left)/G.width*100,Ne=(X.clientY-G.top)/G.height*100,xe=3,ye=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const ue of ye)if(Math.abs(Ee-ue.x)<xe&&Math.abs(Ne-ue.y)<xe){b(ue.name),N({x:Ee,y:Ne}),T({...y});return}Ee>=y.x&&Ee<=y.x+y.width&&Ne>=y.y&&Ne<=y.y+y.height&&(D(!0),N({x:Ee,y:Ne}),T({...y}))},B=X=>{const oe=a.current;if(!oe)return;const G=oe.getBoundingClientRect(),Ee=(X.clientX-G.left)/G.width*100,Ne=(X.clientY-G.top)/G.height*100;if(S){const xe=Ee-E.x,ye=Ne-E.y;let ue=R.x+xe,ae=R.y+ye;ue=Math.max(0,Math.min(ue,100-y.width)),ae=Math.max(0,Math.min(ae,100-y.height)),C(ke=>({...ke,x:ue,y:ae}))}else if(_){const xe=Ee-E.x,ye=Ne-E.y,ue=qi[g];let ae={...R};if(_==="se")ae.width=Math.max(10,R.width+xe),ae.height=ue?ae.width/ue:Math.max(10,R.height+ye);else if(_==="sw"){const ke=-xe;ae.width=Math.max(10,R.width+ke),ae.x=R.x-ke,ae.height=ue?ae.width/ue:Math.max(10,R.height+ye)}else if(_==="ne"){ae.width=Math.max(10,R.width+xe);const ke=ue?ae.width/ue-R.height:-ye;ae.height=Math.max(10,R.height+ke),ae.y=R.y-(ue?ke:-ye)}else if(_==="nw"){const ke=-xe;ae.width=Math.max(10,R.width+ke),ae.x=R.x-ke;const te=ue?ae.width/ue-R.height:-ye;ae.height=Math.max(10,R.height+te),ae.y=R.y-(ue?te:-ye)}ae.x=Math.max(0,ae.x),ae.y=Math.max(0,ae.y),ae.width=Math.min(ae.width,100-ae.x),ae.height=Math.min(ae.height,100-ae.y),C(ae)}},M=()=>{D(!1),b(null)},I=X=>{w(oe=>X==="right"?(oe+90)%360:(oe-90+360)%360)},W=()=>{const X=u.current;if(!X)return;const oe=document.createElement("canvas"),G=oe.getContext("2d");if(!G)return;const Ee=y.x/100*X.width,Ne=y.y/100*X.height,xe=y.width/100*X.width,ye=y.height/100*X.height;oe.width=xe,oe.height=ye,G.save(),x===0?G.drawImage(X,Ee,Ne,xe,ye,0,0,xe,ye):(G.translate(xe/2,ye/2),G.rotate(x*Math.PI/180),x===90||x===270?(oe.width=ye,oe.height=xe,G.translate(-ye/2,-xe/2),G.drawImage(X,Ee,Ne,xe,ye,0,0,xe,ye)):(G.translate(-xe/2,-ye/2),G.drawImage(X,Ee,Ne,xe,ye,0,0,xe,ye))),G.restore(),oe.toBlob(ue=>{ue&&e(ue)},s,i)},$={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:F?"#1a1a1a":"#f5f5f5",borderRadius:"12px",overflow:"hidden"},ee={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0},q={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${F?"#333":"#ddd"}`,background:F?"#242424":"#fff"},Y={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},z={padding:"8px 16px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},ie={...z,background:"#E67E22",color:"#fff"},ce={...z,background:F?"#333":"#e5e5e5",color:F?"#fff":"#333"},de={padding:"8px",borderRadius:"8px",border:"none",background:F?"#333":"#e5e5e5",color:F?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},me=X=>({padding:"6px 12px",borderRadius:"6px",border:"none",background:X?"#E67E22":F?"#333":"#e5e5e5",color:X?"#fff":F?"#aaa":"#666",cursor:"pointer",fontSize:"12px",fontWeight:500});return c?h.jsx("div",{style:{...$,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:F?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...$,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...ce,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:$,children:[h.jsx("div",{style:ee,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:k,onMouseMove:B,onMouseUp:M,onMouseLeave:M})}),h.jsxs("div",{style:q,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:Object.keys(qi).map(X=>h.jsx("button",{onClick:()=>m(X),style:me(g===X),children:X==="free"?"Free":X},X))}),h.jsxs("div",{style:Y,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>I("left"),style:de,title:"Rotate left",children:h.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>I("right"),style:de,title:"Rotate right",children:h.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:ce,children:"Cancel"}),h.jsx("button",{onClick:W,style:ie,children:"Save"})]})]})]})]})}var Og={value:()=>{}};function ca(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function zg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=ca.prototype={constructor:Cs,on:function(r,e){var t=this._,n=zg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=$g(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=Ol(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Ol(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function $g(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Ol(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Og,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var vo="http://www.w3.org/1999/xhtml";const zl={svg:"http://www.w3.org/2000/svg",xhtml:vo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),zl.hasOwnProperty(e)?{space:zl[e],local:r}:r}function qg(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===vo&&e.documentElement.namespaceURI===vo?e.createElement(r):e.createElementNS(t,r)}}function Ug(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Kc(r){var e=_i(r);return(e.local?Ug:qg)(e)}function Wg(){}function da(r){return r==null?Wg:function(){return this.querySelector(r)}}function Vg(r){typeof r!="function"&&(r=da(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=new Array(o),a,u,c=0;c<o;++c)(a=i[c])&&(u=r.call(a,a.__data__,c,i))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Ct(n,this._parents)}function Hg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Gg(){return[]}function Yc(r){return r==null?Gg:function(){return this.querySelectorAll(r)}}function Kg(r){return function(){return Hg(r.apply(this,arguments))}}function Yg(r){typeof r=="function"?r=Kg(r):r=Yc(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new Ct(n,s)}function Qc(r){return function(){return this.matches(r)}}function Xc(r){return function(e){return e.matches(r)}}var Qg=Array.prototype.find;function Xg(r){return function(){return Qg.call(this.children,r)}}function Jg(){return this.firstElementChild}function Zg(r){return this.select(r==null?Jg:Xg(typeof r=="function"?r:Xc(r)))}var e0=Array.prototype.filter;function t0(){return Array.from(this.children)}function r0(r){return function(){return e0.call(this.children,r)}}function n0(r){return this.selectAll(r==null?t0:r0(typeof r=="function"?r:Xc(r)))}function s0(r){typeof r!="function"&&(r=Qc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new Ct(n,this._parents)}function Jc(r){return new Array(r.length)}function i0(){return new Ct(this._enter||this._groups.map(Jc),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function o0(r){return function(){return r}}function a0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function l0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(f[l])===a&&(s[l]=a)}function u0(r){return r.__data__}function c0(r,e){if(!arguments.length)return Array.from(this,u0);var t=e?l0:a0,n=this._parents,s=this._groups;typeof r!="function"&&(r=o0(r));for(var i=s.length,o=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=d0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),w=a[u]=new Array(f);t(c,d,m,x,w,p,e);for(var y=0,C=0,S,D;y<g;++y)if(S=m[y]){for(y>=C&&(C=y+1);!(D=x[C])&&++C<g;);S._next=D||null}}return o=new Ct(o,n),o._enter=l,o._exit=a,o}function d0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function f0(){return new Ct(this._exit||this._groups.map(Jc),this._parents)}function h0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function p0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),l=new Array(s),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new Ct(l,this._parents)}function g0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function m0(r){r||(r=y0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],l=o.length,a=s[i]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Ct(s,this._parents).order()}function y0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function x0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function b0(){return Array.from(this)}function v0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function _0(){let r=0;for(const e of this)++r;return r}function w0(){return!this.node()}function C0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,l;i<o;++i)(l=s[i])&&r.call(l,l.__data__,i,s);return this}function S0(r){return function(){this.removeAttribute(r)}}function k0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function E0(r,e){return function(){this.setAttribute(r,e)}}function D0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function A0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function N0(r,e){var t=_i(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?k0:S0:typeof e=="function"?t.local?T0:A0:t.local?D0:E0)(t,e))}function Zc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function B0(r){return function(){this.style.removeProperty(r)}}function R0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function M0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function F0(r,e,t){return arguments.length>1?this.each((e==null?B0:typeof e=="function"?M0:R0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Zc(r).getComputedStyle(r,null).getPropertyValue(e)}function j0(r){return function(){delete this[r]}}function L0(r,e){return function(){this[r]=e}}function P0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function I0(r,e){return arguments.length>1?this.each((e==null?j0:typeof e=="function"?P0:L0)(r,e)):this.node()[r]}function ed(r){return r.trim().split(/^|\s+/)}function fa(r){return r.classList||new td(r)}function td(r){this._node=r,this._names=ed(r.getAttribute("class")||"")}td.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function rd(r,e){for(var t=fa(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function nd(r,e){for(var t=fa(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function O0(r){return function(){rd(this,r)}}function z0(r){return function(){nd(this,r)}}function $0(r,e){return function(){(e.apply(this,arguments)?rd:nd)(this,r)}}function q0(r,e){var t=ed(r+"");if(arguments.length<2){for(var n=fa(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?$0:e?O0:z0)(t,e))}function U0(){this.textContent=""}function W0(r){return function(){this.textContent=r}}function V0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function H0(r){return arguments.length?this.each(r==null?U0:(typeof r=="function"?V0:W0)(r)):this.node().textContent}function G0(){this.innerHTML=""}function K0(r){return function(){this.innerHTML=r}}function Y0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function Q0(r){return arguments.length?this.each(r==null?G0:(typeof r=="function"?Y0:K0)(r)):this.node().innerHTML}function X0(){this.nextSibling&&this.parentNode.appendChild(this)}function J0(){return this.each(X0)}function Z0(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function em(){return this.each(Z0)}function tm(r){var e=typeof r=="function"?r:Kc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function rm(){return null}function nm(r,e){var t=typeof r=="function"?r:Kc(r),n=e==null?rm:typeof e=="function"?e:da(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function sm(){var r=this.parentNode;r&&r.removeChild(this)}function im(){return this.each(sm)}function om(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function am(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(r){return this.select(r?am:om)}function um(r){return arguments.length?this.property("__data__",r):this.node().__data__}function cm(r){return function(e){r.call(this,e,this.__data__)}}function dm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function fm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function hm(r,e,t){return function(){var n=this.__on,s,i=cm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function pm(r,e,t){var n=dm(r+""),s,i=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(s=0,c=l[a];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?hm:fm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function sd(r,e,t){var n=Zc(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function gm(r,e){return function(){return sd(this,r,e)}}function mm(r,e){return function(){return sd(this,r,e.apply(this,arguments))}}function ym(r,e){return this.each((typeof e=="function"?mm:gm)(r,e))}function*xm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var id=[null];function Ct(r,e){this._groups=r,this._parents=e}function is(){return new Ct([[document.documentElement]],id)}function bm(){return this}Ct.prototype=is.prototype={constructor:Ct,select:Vg,selectAll:Yg,selectChild:Zg,selectChildren:n0,filter:s0,data:c0,enter:i0,exit:f0,join:h0,merge:p0,selection:bm,order:g0,sort:m0,call:x0,nodes:b0,node:v0,size:_0,empty:w0,each:C0,attr:N0,style:F0,property:I0,classed:q0,text:H0,html:Q0,raise:J0,lower:em,append:tm,insert:nm,remove:im,clone:lm,datum:um,on:pm,dispatch:ym,[Symbol.iterator]:xm};function Mt(r){return typeof r=="string"?new Ct([[document.querySelector(r)]],[document.documentElement]):new Ct([[r]],id)}function vm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=vm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const _o={capture:!0,passive:!1};function wo(r){r.preventDefault(),r.stopImmediatePropagation()}function _m(r){var e=r.document.documentElement,t=Mt(r).on("dragstart.drag",wo,_o);"onselectstart"in e?t.on("selectstart.drag",wo,_o):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function wm(r,e){var t=r.document.documentElement,n=Mt(r).on("dragstart.drag",null);e&&(n.on("click.drag",wo,_o),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function ha(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function od(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function os(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ht="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Cm=/^#([0-9a-f]{3,8})$/,Sm=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),km=new RegExp(`^rgb\\(${Ht},${Ht},${Ht}\\)$`),Em=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Dm=new RegExp(`^rgba\\(${Ht},${Ht},${Ht},${qn}\\)$`),Am=new RegExp(`^hsl\\(${qn},${Ht},${Ht}\\)$`),Tm=new RegExp(`^hsla\\(${qn},${Ht},${Ht},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ha(os,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:Nm,formatHsl:Bm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function Nm(){return this.rgb().formatHex8()}function Bm(){return ad(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Cm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new xt(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Sm.exec(r))?new xt(e[1],e[2],e[3],1):(e=km.exec(r))?new xt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Em.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Dm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Am.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Tm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new xt(NaN,NaN,NaN,0):null}function Wl(r){return new xt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new xt(r,e,t,n)}function Rm(r){return r instanceof os||(r=Un(r)),r?(r=r.rgb(),new xt(r.r,r.g,r.b,r.opacity)):new xt}function Co(r,e,t,n){return arguments.length===1?Rm(r):new xt(r,e,t,n??1)}function xt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}ha(xt,Co,od(os,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new xt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new xt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new xt(Tr(this.r),Tr(this.g),Tr(this.b),Js(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Vl,formatHex:Vl,formatHex8:Mm,formatRgb:Hl,toString:Hl}));function Vl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Mm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Ft(r,e,t,n)}function ad(r){if(r instanceof Ft)return new Ft(r.h,r.s,r.l,r.opacity);if(r instanceof os||(r=Un(r)),!r)return new Ft;if(r instanceof Ft)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,l=i-s,a=(i+s)/2;return l?(e===i?o=(t-n)/l+(t<n)*6:t===i?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?i+s:2-i-s,o*=60):l=a>0&&a<1?0:o,new Ft(o,l,a,r.opacity)}function Fm(r,e,t,n){return arguments.length===1?ad(r):new Ft(r,e,t,n??1)}function Ft(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}ha(Ft,Fm,od(os,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Ft(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Ft(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new xt(Ui(r>=240?r-240:r+120,s,n),Ui(r,s,n),Ui(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Ft(Kl(this.h),ys(this.s),ys(this.l),Js(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function Ui(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const ld=r=>()=>r;function jm(r,e){return function(t){return r+t*e}}function Lm(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Pm(r){return(r=+r)==1?ud:function(e,t){return t-e?Lm(e,t,r):ld(isNaN(e)?t:e)}}function ud(r,e){var t=e-r;return t?jm(r,t):ld(isNaN(r)?e:r)}const Yl=function r(e){var t=Pm(e);function n(s,i){var o=t((s=Co(s)).r,(i=Co(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=ud(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wi=new RegExp(So.source,"g");function Im(r){return function(){return r}}function Om(r){return function(e){return r(e)+""}}function zm(r,e){var t=So.lastIndex=Wi.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=So.exec(r))&&(s=Wi.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Wi.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Om(a[0].x):Im(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Ql=180/Math.PI,ko={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cd(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var xs;function $m(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?ko:cd(e.a,e.b,e.c,e.d,e.e,e.f)}function qm(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?ko:(r=r.matrix,cd(r.a,r.b,r.c,r.d,r.e,r.f))}function dd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Um=dd($m,"px, ","px)","deg)"),Wm=dd(qm,", ",")",")"),Vm=1e-12;function Xl(r){return((r=Math.exp(r))+1/r)/2}function Hm(r){return((r=Math.exp(r))-1/r)/2}function Gm(r){return((r=Math.exp(2*r))-1)/(r+1)}const Km=function r(e,t,n){function s(i,o){var l=i[0],a=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,w;if(m<Vm)w=Math.log(f/u)/e,x=function(b){return[l+b*p,a+b*g,u*Math.exp(e*b*w)]};else{var y=Math.sqrt(m),C=(f*f-u*u+n*m)/(2*u*t*y),S=(f*f-u*u-n*m)/(2*f*t*y),D=Math.log(Math.sqrt(C*C+1)-C),_=Math.log(Math.sqrt(S*S+1)-S);w=(_-D)/e,x=function(b){var E=b*w,N=Xl(D),R=u/(t*y)*(N*Gm(e*E+D)-Hm(D));return[l+R*p,a+R*g,u*N/Xl(e*E+D)]}}return x.duration=w*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,fd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,hd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function pa(){return Lr||(hd(Ym),Lr=Wn.now()+wi)}function Ym(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=pd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?pa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,Eo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Eo())}};function pd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Qm(){pa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Jl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{Qm()}finally{nn=0,Jm(),Lr=0}}function Xm(){var r=Wn.now(),e=r-ei;e>fd&&(wi-=e,ei=r)}function Jm(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,Eo(n)}function Eo(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Jl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(Xm,fd)),nn=1,hd(Jl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var Zm=ca("start","end","cancel","interrupt"),e2=[],gd=0,eu=1,Do=2,Ss=3,tu=4,Ao=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;t2(r,t,{name:e,index:n,group:s,on:Zm,tween:e2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:gd})}function ga(r,e){var t=Ot(r,e);if(t.state>gd)throw new Error("too late; already scheduled");return t}function Xt(r,e){var t=Ot(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function Ot(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function t2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=pd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Do,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Do){for(t.state=Ss,s=new Array(f=t.tween.length),c=0,d=-1;c<f;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Ao,1),d=-1,f=s.length;++d<f;)s[d].call(r,c);t.state===Ao&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Do&&n.state<Ao,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function r2(r){return this.each(function(){Es(this,r)})}function n2(r,e){var t,n;return function(){var s=Xt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function s2(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Xt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var l={name:e,value:t},a=0,u=s.length;a<u;++a)if(s[a].name===e){s[a]=l;break}a===u&&s.push(l)}i.tween=s}}function i2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=Ot(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?n2:s2)(t,r,e))}function ma(r,e,t){var n=r._id;return r.each(function(){var s=Xt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Ot(s,n).value[e]}}function md(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):zm)(r,e)}function o2(r){return function(){this.removeAttribute(r)}}function a2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function l2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function u2(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function c2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function d2(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function f2(r,e){var t=_i(r),n=t==="transform"?Wm:md;return this.attrTween(r,typeof e=="function"?(t.local?d2:c2)(t,n,ma(this,"attr."+r,e)):e==null?(t.local?a2:o2)(t):(t.local?u2:l2)(t,n,e))}function h2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function p2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function g2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&p2(r,i)),t}return s._value=e,s}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&h2(r,i)),t}return s._value=e,s}function y2(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=_i(r);return this.tween(t,(n.local?g2:m2)(n,e))}function x2(r,e){return function(){ga(this,r).delay=+e.apply(this,arguments)}}function b2(r,e){return e=+e,function(){ga(this,r).delay=e}}function v2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?x2:b2)(e,r)):Ot(this.node(),e).delay}function _2(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function w2(r,e){return e=+e,function(){Xt(this,r).duration=e}}function C2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?_2:w2)(e,r)):Ot(this.node(),e).duration}function S2(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function k2(r){var e=this._id;return arguments.length?this.each(S2(e,r)):Ot(this.node(),e).ease}function E2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function D2(r){if(typeof r!="function")throw new Error;return this.each(E2(this._id,r))}function A2(r){typeof r!="function"&&(r=Qc(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function T2(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),l=0;l<i;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function N2(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function B2(r,e,t){var n,s,i=N2(e)?ga:Xt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function R2(r,e){var t=this._id;return arguments.length<2?Ot(this.node(),t).on.on(r):this.each(B2(t,r,e))}function M2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function F2(){return this.on("end.remove",M2(this._id))}function j2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=da(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,Ot(c,t)));return new ir(i,this._parents,e,t)}function L2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Yc(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var f=r.call(c,c.__data__,d,a),p,g=Ot(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var P2=is.prototype.constructor;function I2(){return new P2(this._groups,this._parents)}function O2(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function yd(r){return function(){this.style.removeProperty(r)}}function z2(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function $2(r,e,t){var n,s,i;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l))}}function q2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Xt(this,r),u=a.on,c=a.value[i]==null?l||(l=yd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function U2(r,e,t){var n=(r+="")=="transform"?Um:md;return e==null?this.styleTween(r,O2(r,n)).on("end.style."+r,yd(r)):typeof e=="function"?this.styleTween(r,$2(r,n,ma(this,"style."+r,e))).each(q2(this._id,r)):this.styleTween(r,z2(r,n,e),t).on("end.style."+r,null)}function W2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function V2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&W2(r,o,t)),n}return i._value=e,i}function H2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,V2(r,e,t??""))}function G2(r){return function(){this.textContent=r}}function K2(r){return function(){var e=r(this);this.textContent=e??""}}function Y2(r){return this.tween("text",typeof r=="function"?K2(ma(this,"text",r)):G2(r==null?"":r+""))}function Q2(r){return function(e){this.textContent=r.call(this,e)}}function X2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&Q2(s)),e}return n._value=r,n}function J2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,X2(r))}function Z2(){for(var r=this._name,e=this._id,t=xd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=Ot(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function ey(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var l={value:o},a={value:function(){--s===0&&i()}};t.each(function(){var u=Xt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),s===0&&i()})}var ty=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function xd(){return++ty}var tr=is.prototype;ir.prototype={constructor:ir,select:j2,selectAll:L2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:A2,merge:T2,selection:I2,transition:Z2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:R2,attr:f2,attrTween:y2,style:U2,styleTween:H2,text:Y2,textTween:J2,remove:F2,tween:i2,delay:v2,duration:C2,ease:k2,easeVarying:D2,end:ey,[Symbol.iterator]:tr[Symbol.iterator]};function ry(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var ny={time:null,delay:0,duration:250,ease:ry};function sy(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function iy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=xd(),(t=ny).time=pa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||sy(a,e));return new ir(n,this._parents,r,e)}is.prototype.interrupt=r2;is.prototype.transition=iy;const bs=r=>()=>r;function oy(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Vi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function ay(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function ly(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function uy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function cy(){return navigator.maxTouchPoints||"ontouchstart"in this}function dy(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function fy(){var r=ay,e=ly,t=dy,n=uy,s=cy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Km,u=ca("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function w(k){k.property("__zoom",ru).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",R).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(k,B,M,I){var W=k.selection?k.selection():k;W.property("__zoom",ru),k!==W?D(k,B,M,I):W.interrupt().each(function(){_(this,arguments).event(I).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},w.scaleBy=function(k,B,M,I){w.scaleTo(k,function(){var W=this.__zoom.k,$=typeof B=="function"?B.apply(this,arguments):B;return W*$},M,I)},w.scaleTo=function(k,B,M,I){w.transform(k,function(){var W=e.apply(this,arguments),$=this.__zoom,ee=M==null?S(W):typeof M=="function"?M.apply(this,arguments):M,q=$.invert(ee),Y=typeof B=="function"?B.apply(this,arguments):B;return t(C(y($,Y),ee,q),W,o)},M,I)},w.translateBy=function(k,B,M,I){w.transform(k,function(){return t(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof M=="function"?M.apply(this,arguments):M),e.apply(this,arguments),o)},null,I)},w.translateTo=function(k,B,M,I,W){w.transform(k,function(){var $=e.apply(this,arguments),ee=this.__zoom,q=I==null?S($):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(q[0],q[1]).scale(ee.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof M=="function"?-M.apply(this,arguments):-M),$,o)},I,W)};function y(k,B){return B=Math.max(i[0],Math.min(i[1],B)),B===k.k?k:new nr(B,k.x,k.y)}function C(k,B,M){var I=B[0]-M[0]*k.k,W=B[1]-M[1]*k.k;return I===k.x&&W===k.y?k:new nr(k.k,I,W)}function S(k){return[(+k[0][0]+ +k[1][0])/2,(+k[0][1]+ +k[1][1])/2]}function D(k,B,M,I){k.on("start.zoom",function(){_(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(I).end()}).tween("zoom",function(){var W=this,$=arguments,ee=_(W,$).event(I),q=e.apply(W,$),Y=M==null?S(q):typeof M=="function"?M.apply(W,$):M,z=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),ie=W.__zoom,ce=typeof B=="function"?B.apply(W,$):B,de=a(ie.invert(Y).concat(z/ie.k),ce.invert(Y).concat(z/ce.k));return function(me){if(me===1)me=ce;else{var X=de(me),oe=z/X[2];me=new nr(oe,Y[0]-X[0]*oe,Y[1]-X[1]*oe)}ee.zoom(null,me)}})}function _(k,B,M){return!M&&k.__zooming||new b(k,B)}function b(k,B){this.that=k,this.args=B,this.active=0,this.sourceEvent=null,this.extent=e.apply(k,B),this.taps=0}b.prototype={event:function(k){return k&&(this.sourceEvent=k),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(k,B){return this.mouse&&k!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&k!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&k!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(k){var B=Mt(this.that).datum();u.call(k,this.that,new oy(k,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:u}),B)}};function E(k,...B){if(!r.apply(this,arguments))return;var M=_(this,B).event(k),I=this.__zoom,W=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),$=wr(k);if(M.wheel)(M.mouse[0][0]!==$[0]||M.mouse[0][1]!==$[1])&&(M.mouse[1]=I.invert(M.mouse[0]=$)),clearTimeout(M.wheel);else{if(I.k===W)return;M.mouse=[$,I.invert($)],Es(this),M.start()}xn(k),M.wheel=setTimeout(ee,g),M.zoom("mouse",t(C(y(I,W),M.mouse[0],M.mouse[1]),M.extent,o));function ee(){M.wheel=null,M.end()}}function N(k,...B){if(f||!r.apply(this,arguments))return;var M=k.currentTarget,I=_(this,B,!0).event(k),W=Mt(k.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",z,!0),$=wr(k,M),ee=k.clientX,q=k.clientY;_m(k.view),Vi(k),I.mouse=[$,this.__zoom.invert($)],Es(this),I.start();function Y(ie){if(xn(ie),!I.moved){var ce=ie.clientX-ee,de=ie.clientY-q;I.moved=ce*ce+de*de>m}I.event(ie).zoom("mouse",t(C(I.that.__zoom,I.mouse[0]=wr(ie,M),I.mouse[1]),I.extent,o))}function z(ie){W.on("mousemove.zoom mouseup.zoom",null),wm(ie.view,I.moved),xn(ie),I.event(ie).end()}}function R(k,...B){if(r.apply(this,arguments)){var M=this.__zoom,I=wr(k.changedTouches?k.changedTouches[0]:k,this),W=M.invert(I),$=M.k*(k.shiftKey?.5:2),ee=t(C(y(M,$),I,W),e.apply(this,B),o);xn(k),l>0?Mt(this).transition().duration(l).call(D,ee,I,k):Mt(this).call(w.transform,ee,I,k)}}function T(k,...B){if(r.apply(this,arguments)){var M=k.touches,I=M.length,W=_(this,B,k.changedTouches.length===I).event(k),$,ee,q,Y;for(Vi(k),ee=0;ee<I;++ee)q=M[ee],Y=wr(q,this),Y=[Y,this.__zoom.invert(Y),q.identifier],W.touch0?!W.touch1&&W.touch0[2]!==Y[2]&&(W.touch1=Y,W.taps=0):(W.touch0=Y,$=!0,W.taps=1+!!c);c&&(c=clearTimeout(c)),$&&(W.taps<2&&(d=Y[0],c=setTimeout(function(){c=null},p)),Es(this),W.start())}}function F(k,...B){if(this.__zooming){var M=_(this,B).event(k),I=k.changedTouches,W=I.length,$,ee,q,Y;for(xn(k),$=0;$<W;++$)ee=I[$],q=wr(ee,this),M.touch0&&M.touch0[2]===ee.identifier?M.touch0[0]=q:M.touch1&&M.touch1[2]===ee.identifier&&(M.touch1[0]=q);if(ee=M.that.__zoom,M.touch1){var z=M.touch0[0],ie=M.touch0[1],ce=M.touch1[0],de=M.touch1[1],me=(me=ce[0]-z[0])*me+(me=ce[1]-z[1])*me,X=(X=de[0]-ie[0])*X+(X=de[1]-ie[1])*X;ee=y(ee,Math.sqrt(me/X)),q=[(z[0]+ce[0])/2,(z[1]+ce[1])/2],Y=[(ie[0]+de[0])/2,(ie[1]+de[1])/2]}else if(M.touch0)q=M.touch0[0],Y=M.touch0[1];else return;M.zoom("touch",t(C(ee,q,Y),M.extent,o))}}function L(k,...B){if(this.__zooming){var M=_(this,B).event(k),I=k.changedTouches,W=I.length,$,ee;for(Vi(k),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),$=0;$<W;++$)ee=I[$],M.touch0&&M.touch0[2]===ee.identifier?delete M.touch0:M.touch1&&M.touch1[2]===ee.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(ee=wr(ee,this),Math.hypot(d[0]-ee[0],d[1]-ee[1])<x)){var q=Mt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return w.wheelDelta=function(k){return arguments.length?(n=typeof k=="function"?k:bs(+k),w):n},w.filter=function(k){return arguments.length?(r=typeof k=="function"?k:bs(!!k),w):r},w.touchable=function(k){return arguments.length?(s=typeof k=="function"?k:bs(!!k),w):s},w.extent=function(k){return arguments.length?(e=typeof k=="function"?k:bs([[+k[0][0],+k[0][1]],[+k[1][0],+k[1][1]]]),w):e},w.scaleExtent=function(k){return arguments.length?(i[0]=+k[0],i[1]=+k[1],w):[i[0],i[1]]},w.translateExtent=function(k){return arguments.length?(o[0][0]=+k[0][0],o[1][0]=+k[1][0],o[0][1]=+k[0][1],o[1][1]=+k[1][1],w):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},w.constrain=function(k){return arguments.length?(t=k,w):t},w.duration=function(k){return arguments.length?(l=+k,w):l},w.interpolate=function(k){return arguments.length?(a=k,w):a},w.on=function(){var k=u.on.apply(u,arguments);return k===u?w:k},w.clickDistance=function(k){return arguments.length?(m=(k=+k)*k,w):Math.sqrt(m)},w.tapDistance=function(k){return arguments.length?(x=+k,w):x},w}function bd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=v.useRef(null),a=v.useRef(),[u,c]=v.useState(n||{x:0,y:0,k:1});v.useEffect(()=>{if(!l.current)return;const x=fy().scaleExtent([e,t]).filter(y=>!s&&y.type==="wheel"||!i&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?s:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",y=>{const C={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(C),o==null||o(C)});a.current=x;const w=Mt(l.current);return w.call(x),w.on("dblclick.zoom",null),n&&w.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{w.on(".zoom",null)}},[e,t,s,i]),v.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const w={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(w),o==null||o(w)})},[o]);const d=v.useCallback((x,w,y,C=!0)=>{if(!l.current||!a.current)return;const S=Mt(l.current),D=ri.translate(x,w).scale(y);S.call(a.current.transform,D)},[]),f=v.useCallback(()=>{!l.current||!a.current||Mt(l.current).call(a.current.scaleBy,1.3)},[]),p=v.useCallback(()=>{!l.current||!a.current||Mt(l.current).call(a.current.scaleBy,.7)},[]),g=v.useCallback(()=>{d(0,0,1,!0)},[d]),m=v.useCallback((x,w=50)=>{if(!l.current||!a.current||x.length===0)return;const C=l.current.getBoundingClientRect();let S=1/0,D=1/0,_=-1/0,b=-1/0;for(const I of x){const W=I.width||200,$=I.height||100;S=Math.min(S,I.x),D=Math.min(D,I.y),_=Math.max(_,I.x+W),b=Math.max(b,I.y+$)}const E=_-S,N=b-D,R=(C.width-w*2)/E,T=(C.height-w*2)/N,F=Math.min(R,T,t),L=(S+_)/2,k=(D+b)/2,B=C.width/2-L*F,M=C.height/2-k*F;d(B,M,F,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function vd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=v.useState(null),[a,u]=v.useState(!1),[c,d]=v.useState({x:0,y:0}),f=v.useRef(null),p=v.useRef({x:0,y:0}),g=v.useRef(e);v.useEffect(()=>{g.current=e},[e]);const m=v.useCallback((C,S)=>{const D=g.current;return{x:(C-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=v.useCallback((C,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,_=parseFloat(D.dataset.x||"0"),b=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:_,nodeY:b},p.current={x:_,y:b},l(C),u(!0),d({x:0,y:0}),t==null||t(C)},[i,m,t]),w=v.useCallback(C=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,_=C.clientX-D.x,b=C.clientY-D.y,E=_/S.k,N=b/S.k,R=D.nodeX+E,T=D.nodeY+N;p.current={x:R,y:T},d({x:E,y:N}),n==null||n(o,R,T,E,N)},[a,o,n]),y=v.useCallback(()=>{if(!a||!o)return;const C=p.current;s==null||s(o,C.x,C.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return v.useEffect(()=>{if(!a)return;const C=D=>{w(D)},S=()=>{y()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",S)}},[a,w,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:w,endDrag:y}}function _d(r){const{transform:e,nodePositions:t,disabled:n=!1,onSelectionChange:s}=r,[i,o]=v.useState(new Set),[l,a]=v.useState(null),[u,c]=v.useState(!1),d=v.useRef(null),f=v.useRef(e),p=v.useRef(t);v.useEffect(()=>{f.current=e},[e]),v.useEffect(()=>{p.current=t},[t]);const g=v.useCallback((_,b)=>{const E=f.current;return{x:(_-E.x)/E.k,y:(b-E.y)/E.k}},[]),m=v.useCallback((_,b)=>{const E=p.current.get(_);if(!E)return!1;const N=E.width||200,R=E.height||100;return E.x<b.x+b.width&&E.x+N>b.x&&E.y<b.y+b.height&&E.y+R>b.y},[]),x=v.useCallback(_=>{if(n||_.target.closest("[data-qmap-node]"))return;_.preventDefault();const E=g(_.clientX,_.clientY);d.current=E,a({x:E.x,y:E.y,width:0,height:0}),c(!0),_.shiftKey||o(new Set)},[n,g]),w=v.useCallback(_=>{if(!u||!d.current)return;const b=d.current,E=g(_.clientX,_.clientY),N={x:Math.min(b.x,E.x),y:Math.min(b.y,E.y),width:Math.abs(E.x-b.x),height:Math.abs(E.y-b.y)};a(N);const R=new Set;for(const[T]of p.current)m(T,N)&&R.add(T);o(R)},[u,g,m]),y=v.useCallback(()=>{u&&(s==null||s(Array.from(i)),c(!1),a(null),d.current=null)},[u,i,s]);v.useEffect(()=>{if(!u)return;const _=E=>{w(E)},b=()=>{y()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",b)}},[u,w,y]);const C=v.useCallback((_,b=!1)=>{o(E=>{const N=new Set(b?E:[]);return E.has(_)&&b?N.delete(_):N.add(_),s==null||s(Array.from(N)),N})},[s]),S=v.useCallback(()=>{const _=new Set(p.current.keys());o(_),s==null||s(Array.from(_))},[s]),D=v.useCallback(()=>{o(new Set),s==null||s([])},[s]);return{selectedIds:i,setSelectedIds:o,selectionBox:l,isSelecting:u,startSelection:x,updateSelection:w,endSelection:y,toggleSelect:C,selectAll:S,clearSelection:D}}const wd=v.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=v.useCallback(y=>{i&&y.button===0&&o(e,y)},[e,i,o]),f=v.useCallback(y=>{s||l==null||l(y)},[s,l]),p=v.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=v.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,w=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:w!==0?`rotate(${w}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",outline:n?"2px solid #3b82f6":void 0,outlineOffset:"2px",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Cd(r,e,t="bezier"){const n=Vn(r),s=Vn(e),i=To(r,s),o=To(e,n);switch(t){case"straight":return`M ${i.x} ${i.y} L ${o.x} ${o.y}`;case"orthogonal":return py(i,o);case"bezier":default:return hy(i,o)}}function hy(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+i*Math.sign(t),a=r.y,u=e.x-i*Math.sign(t),c=e.y):(l=r.x,a=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function py(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function Vn(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function To(r,e){const t=r.width||200,n=r.height||100,s=Vn(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const l=t/2,a=n/2,u=Math.abs(o/(i||.001)),c=a/l;let d,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function gy(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return Vn(r)}}function my(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function yy(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function xy(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,l=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+l)}return{x:e,y:t,width:n-e,height:s-t}}function by(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function vy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Sd=v.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=v.useState(!1),c=v.useMemo(()=>Cd(t,n,s),[t,n,s]),d=v.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=v.useCallback(()=>{u(!0)},[]),p=v.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(_y,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function _y({pathD:r,label:e,color:t}){const n=v.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const kd=v.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=v.useMemo(()=>e.filter(u=>t.has(u.source)&&t.has(u.target)),[e,t]),a=v.useMemo(()=>{if(t.size===0)return"0 0 1000 1000";let u=1/0,c=1/0,d=-1/0,f=-1/0;for(const p of t.values()){const g=p.width||200,m=p.height||100;u=Math.min(u,p.x-100),c=Math.min(c,p.y-100),d=Math.max(d,p.x+g+100),f=Math.max(f,p.y+m+100)}return u-=1e3,c-=1e3,d+=1e3,f+=1e3,`${u} ${c} ${d-u} ${f-c}`},[t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},viewBox:a,preserveAspectRatio:"none",children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(u=>{const c=t.get(u.source),d=t.get(u.target);return h.jsx(Sd,{edge:u,sourcePosition:c,targetPosition:d,style:u.style||n,color:u.color||s,width:u.width||i,onClick:o},u.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Ed=v.memo(function({box:e,transform:t}){const n=v.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return h.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),wy=200,Cy=100,Sy="bezier",ky="#94a3b8",Ey=2,Dy=.1,Ay=4;function Ty({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=wy,defaultNodeHeight:i=Cy,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,onSelectionChange:c,onEdgeClick:d,onViewChange:f,onTransformChange:p,minZoom:g=Dy,maxZoom:m=Ay,initialTransform:x,defaultEdgeStyle:w=Sy,defaultEdgeColor:y=ky,defaultEdgeWidth:C=Ey,draggable:S=!0,selectable:D=!0,zoomable:_=!0,pannable:b=!0,className:E="",style:N,background:R="#f8fafc",showGrid:T=!1,gridSize:F=20}){const L=r.data||{positions:{}},k=L.positions||{},B=v.useMemo(()=>{const te=new Map;for(const ge of e){const be=k[ge._id]||{x:0,y:0};te.set(ge._id,{x:be.x,y:be.y,width:be.width||s,height:be.height||i,rotation:be.rotation||0})}return te},[e,k,s,i]),{transform:M,containerRef:I,zoomIn:W,zoomOut:$,resetZoom:ee,fitToContent:q}=bd({minZoom:g,maxZoom:m,initialTransform:x||L.transform,zoomable:_,pannable:b,onTransformChange:te=>{p==null||p(te);const ge={...L,transform:te};f==null||f(ge)}}),[Y,z]=v.useState(new Map),{draggedNodeId:ie,startDrag:ce}=vd({transform:M,disabled:!S,onDragStart:te=>{const ge=B.get(te);ge&&z(new Map([[te,{x:ge.x,y:ge.y}]]))},onDragMove:(te,ge,be)=>{z(new Map([[te,{x:ge,y:be}]]))},onDragEnd:(te,ge,be)=>{z(new Map),o==null||o(te,ge,be)}}),{selectedIds:de,selectionBox:me,isSelecting:X,startSelection:oe,toggleSelect:G,clearSelection:Ee}=_d({transform:M,nodePositions:B,disabled:!D,onSelectionChange:c}),Ne=v.useCallback(te=>{const ge=B.get(te)||{x:0,y:0,width:s,height:i},be=Y.get(te);return be?{...ge,x:be.x,y:be.y}:ge},[B,Y,s,i]),xe=v.useMemo(()=>{const te=new Map;for(const ge of B.keys())te.set(ge,Ne(ge));return te},[B,Ne]),ye=v.useCallback((te,ge)=>{G(te._id,ge.shiftKey),l==null||l(te,ge)},[G,l]),ue=v.useCallback(te=>{te.target.closest("[data-qmap-node]")||Ee()},[Ee]),ae=v.useCallback(te=>{te.button===0&&(te.target.closest("[data-qmap-node]")||oe(te))},[oe]),ke=T?`
186
186
  linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
187
187
  linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px)
188
- `:void 0;return h.jsxs("div",{ref:O,className:`qmap-container ${k}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:F,backgroundImage:It,backgroundSize:T?`${M}px ${M}px`:void 0,cursor:ve?"crosshair":y?"grab":"default",...N},onMouseDown:dt,onClick:xt,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${R.x}px, ${R.y}px) scale(${R.k})`,willChange:"transform"},children:[h.jsx(Sd,{edges:t,nodePositions:kt,defaultStyle:v,defaultColor:b,defaultWidth:C,onEdgeClick:d}),e.map(ue=>{const _e=ct(ue._id),Te=le.has(ue._id),it=re===ue._id;return h.jsx(vd,{nodeId:ue._id,position:_e,isSelected:Te,isDragging:it,draggable:S,onDragStart:ae,onClick:Je=>tt(ue,Je),onDoubleClick:Je=>a==null?void 0:a(ue,Je),onContextMenu:Je=>u==null?void 0:u(ue,Je),children:n(ue,Te,_e)},ue._id)})]}),ce&&h.jsx(Ed,{box:ce,transform:R}),h.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[h.jsx("button",{onClick:H,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),h.jsx("button",{onClick:U,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),h.jsx("button",{onClick:Z,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),h.jsx("button",{onClick:()=>q(Array.from(B.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=la;exports.$isQRCodeNode=yg;exports.AnimatedCardFlip=yf;exports.ApiClient=iu;exports.AudioEditor=Hc;exports.AuthFlow=cu;exports.AuthFlowModal=df;exports.AuthManager=ht;exports.AuthProvider=rf;exports.AuthService=To;exports.Card=pf;exports.ComboBox=Dg;exports.ComboStack=Tg;exports.DataOperations=_s;exports.Detail=gf;exports.ForgotPasswordForm=lu;exports.GraphClient=Bd;exports.KanbanBoard=Ng;exports.LoginForm=Bo;exports.LoginModal=of;exports.Mail=bf;exports.MailClient=su;exports.MailComposer=Eg;exports.MailEditor=Vc;exports.QMap=Dy;exports.QMapEdgeComponent=Cd;exports.QMapEdgeLayer=Sd;exports.QMapNode=vd;exports.QMapSelectionBox=Ed;exports.QRCodeNode=un;exports.RegisterForm=au;exports.ResetPasswordForm=uu;exports.SelectableList=_f;exports.Stack=hf;exports.Timeline=jg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Lg;exports.calculateBoundingBox=my;exports.calculateEdgePath=wd;exports.distance=yy;exports.distanceSquared=xy;exports.getApiClient=No;exports.getAuthService=Jd;exports.getConnectionPoint=Ao;exports.getNodeCenter=Vn;exports.getNodeSidePoint=hy;exports.initializeApiClient=Zd;exports.initializeAuthService=Xd;exports.pointInRect=py;exports.rectsIntersect=gy;exports.useAuth=nf;exports.useMutation=ff;exports.useNodeDrag=bd;exports.useQuery=du;exports.useSelection=_d;exports.useZoomPan=xd;
188
+ `:void 0;return h.jsxs("div",{ref:I,className:`qmap-container ${E}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:R,backgroundImage:ke,backgroundSize:T?`${F}px ${F}px`:void 0,cursor:X?"crosshair":b?"grab":"default",...N},onMouseDown:ae,onClick:ue,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${M.x}px, ${M.y}px) scale(${M.k})`,willChange:"transform"},children:[h.jsx(kd,{edges:t,nodePositions:xe,defaultStyle:w,defaultColor:y,defaultWidth:C,onEdgeClick:d}),e.map(te=>{const ge=Ne(te._id),be=de.has(te._id),Xe=ie===te._id;return h.jsx(wd,{nodeId:te._id,position:ge,isSelected:be,isDragging:Xe,draggable:S,onDragStart:ce,onClick:st=>ye(te,st),onDoubleClick:st=>a==null?void 0:a(te,st),onContextMenu:st=>u==null?void 0:u(te,st),children:n(te,be,ge)},te._id)})]}),me&&h.jsx(Ed,{box:me,transform:M}),h.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[h.jsx("button",{onClick:W,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),h.jsx("button",{onClick:$,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),h.jsx("button",{onClick:ee,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),h.jsx("button",{onClick:()=>q(Array.from(B.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=ua;exports.$isQRCodeNode=xg;exports.AnimatedCardFlip=xf;exports.ApiClient=ou;exports.AudioEditor=Gc;exports.AuthFlow=du;exports.AuthFlowModal=ff;exports.AuthManager=mt;exports.AuthProvider=nf;exports.AuthService=No;exports.Card=gf;exports.ComboBox=Ag;exports.ComboStack=Ng;exports.DataOperations=vs;exports.Detail=mf;exports.ForgotPasswordForm=uu;exports.GraphClient=Rd;exports.ImageEditor=Ig;exports.KanbanBoard=Bg;exports.LoginForm=Ro;exports.LoginModal=af;exports.Mail=vf;exports.MailClient=iu;exports.MailComposer=Eg;exports.MailEditor=Hc;exports.QMap=Ty;exports.QMapEdgeComponent=Sd;exports.QMapEdgeLayer=kd;exports.QMapNode=wd;exports.QMapSelectionBox=Ed;exports.QRCodeNode=un;exports.RegisterForm=lu;exports.ResetPasswordForm=cu;exports.SelectableList=_f;exports.Stack=pf;exports.Timeline=Lg;exports.VerifyCodeForm=Ki;exports.VoiceTextEditor=Pg;exports.calculateBoundingBox=xy;exports.calculateEdgePath=Cd;exports.distance=by;exports.distanceSquared=vy;exports.getApiClient=Bo;exports.getAuthService=Zd;exports.getConnectionPoint=To;exports.getNodeCenter=Vn;exports.getNodeSidePoint=gy;exports.initializeApiClient=ef;exports.initializeAuthService=Jd;exports.pointInRect=my;exports.rectsIntersect=yy;exports.useAuth=sf;exports.useMutation=hf;exports.useNodeDrag=vd;exports.useQuery=fu;exports.useSelection=_d;exports.useZoomPan=bd;