@qwanyx/stack 0.2.102 → 0.2.103
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/client/MailClient.d.ts +68 -7
- package/dist/components/Mail.d.ts +4 -4
- package/dist/components/MailComposer.d.ts +11 -1
- package/dist/components/QMap/QMap.d.ts +1 -1
- package/dist/components/QMap/types.d.ts +2 -0
- package/dist/index.cjs.js +44 -44
- package/dist/index.esm.js +4342 -4109
- package/dist/types/index.d.ts +14 -3
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Rd=Object.defineProperty;var Fd=(r,e,t)=>e in r?Rd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var
|
|
1
|
+
"use strict";var Rd=Object.defineProperty;var Fd=(r,e,t)=>e in r?Rd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _t=(r,e,t)=>Fd(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),ma=require("react-dom");function Ld(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=Ld(y);class Pd{constructor(e){_t(this,"config");_t(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_auth_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 updateEdge(e,t,n,s){return await this.callGraph("update_edge",{source_id:e,target_id:t,edge_type:n,data:s})}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 Xr=new TextEncoder,ya="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn=new Uint8Array(256);for(var os=0;os<ya.length;os++)bn[ya.charCodeAt(os)]=os;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 xa(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function Id(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=Xr.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=Hi(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Xr.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)=>Id(s,i,o));if(e&&t.indexOf("�")>=0)e=!1;else return t}}function zd(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=Xr.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 Od(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]=zd(t.values.sort((s,i)=>s.nr-i.nr).map(s=>s.value).join(""),t.charset)})}class $d{constructor(){this.chunks=[]}update(e){this.chunks.push(e),this.chunks.push(`
|
|
2
2
|
`)}finalize(){return ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class qd{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 ba=/^=[a-f0-9]{2}$/i,Ud=/(?==[a-f0-9]{2})/i,Wd=/=\r?\n/g,Hd=/=[a-fA-F0-9]?$/;class Vd{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(Wd,"");let t=e.split(Ud),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(Hd);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 va{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 qd:/quoted-printable/i.test(e)?this.contentDecoder=new Vd({decoder:kn(this.contentType.parsed.params.charset)}):this.contentDecoder=new $d}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,
|
|
3
|
+
`;if(t=this.remainder+t,t.length<this.maxChunkSize){this.remainder=t;return}this.remainder="";let n=t.match(Hd);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 va{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 qd:/quoted-printable/i.test(e)?this.contentDecoder=new Vd({decoder:kn(this.contentType.parsed.params.charset)}):this.contentDecoder=new $d}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()),Od(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
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
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:Xr.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 _a={"Æ":"Æ","Æ":"Æ","&":"&","&":"&","Á":"Á","Á":"Á","Ă":"Ă","Â":"Â","Â":"Â","А":"А","𝔄":"𝔄","À":"À","À":"À","Α":"Α","Ā":"Ā","⩓":"⩓","Ą":"Ą","𝔸":"𝔸","⁡":"","Å":"Å","Å":"Å","𝒜":"𝒜","≔":"≔","Ã":"Ã","Ã":"Ã","Ä":"Ä","Ä":"Ä","∖":"∖","⫧":"⫧","⌆":"⌆","Б":"Б","∵":"∵","ℬ":"ℬ","Β":"Β","𝔅":"𝔅","𝔹":"𝔹","˘":"˘","ℬ":"ℬ","≎":"≎","Ч":"Ч","©":"©","©":"©","Ć":"Ć","⋒":"⋒","ⅅ":"ⅅ","ℭ":"ℭ","Č":"Č","Ç":"Ç","Ç":"Ç","Ĉ":"Ĉ","∰":"∰","Ċ":"Ċ","¸":"¸","·":"·","ℭ":"ℭ","Χ":"Χ","⊙":"⊙","⊖":"⊖","⊕":"⊕","⊗":"⊗","∲":"∲","”":"”","’":"’","∷":"∷","⩴":"⩴","≡":"≡","∯":"∯","∮":"∮","ℂ":"ℂ","∐":"∐","∳":"∳","⨯":"⨯","𝒞":"𝒞","⋓":"⋓","≍":"≍","ⅅ":"ⅅ","⤑":"⤑","Ђ":"Ђ","Ѕ":"Ѕ","Џ":"Џ","‡":"‡","↡":"↡","⫤":"⫤","Ď":"Ď","Д":"Д","∇":"∇","Δ":"Δ","𝔇":"𝔇","´":"´","˙":"˙","˝":"˝","`":"`","˜":"˜","⋄":"⋄","ⅆ":"ⅆ","𝔻":"𝔻","¨":"¨","⃜":"⃜","≐":"≐","∯":"∯","¨":"¨","⇓":"⇓","⇐":"⇐","⇔":"⇔","⫤":"⫤","⟸":"⟸","⟺":"⟺","⟹":"⟹","⇒":"⇒","⊨":"⊨","⇑":"⇑","⇕":"⇕","∥":"∥","↓":"↓","⤓":"⤓","⇵":"⇵","̑":"̑","⥐":"⥐","⥞":"⥞","↽":"↽","⥖":"⥖","⥟":"⥟","⇁":"⇁","⥗":"⥗","⊤":"⊤","↧":"↧","⇓":"⇓","𝒟":"𝒟","Đ":"Đ","Ŋ":"Ŋ","Ð":"Ð","Ð":"Ð","É":"É","É":"É","Ě":"Ě","Ê":"Ê","Ê":"Ê","Э":"Э","Ė":"Ė","𝔈":"𝔈","È":"È","È":"È","∈":"∈","Ē":"Ē","◻":"◻","▫":"▫","Ę":"Ę","𝔼":"𝔼","Ε":"Ε","⩵":"⩵","≂":"≂","⇌":"⇌","ℰ":"ℰ","⩳":"⩳","Η":"Η","Ë":"Ë","Ë":"Ë","∃":"∃","ⅇ":"ⅇ","Ф":"Ф","𝔉":"𝔉","◼":"◼","▪":"▪","𝔽":"𝔽","∀":"∀","ℱ":"ℱ","ℱ":"ℱ","Ѓ":"Ѓ",">":">",">":">","Γ":"Γ","Ϝ":"Ϝ","Ğ":"Ğ","Ģ":"Ģ","Ĝ":"Ĝ","Г":"Г","Ġ":"Ġ","𝔊":"𝔊","⋙":"⋙","𝔾":"𝔾","≥":"≥","⋛":"⋛","≧":"≧","⪢":"⪢","≷":"≷","⩾":"⩾","≳":"≳","𝒢":"𝒢","≫":"≫","Ъ":"Ъ","ˇ":"ˇ","^":"^","Ĥ":"Ĥ","ℌ":"ℌ","ℋ":"ℋ","ℍ":"ℍ","─":"─","ℋ":"ℋ","Ħ":"Ħ","≎":"≎","≏":"≏","Е":"Е","IJ":"IJ","Ё":"Ё","Í":"Í","Í":"Í","Î":"Î","Î":"Î","И":"И","İ":"İ","ℑ":"ℑ","Ì":"Ì","Ì":"Ì","ℑ":"ℑ","Ī":"Ī","ⅈ":"ⅈ","⇒":"⇒","∬":"∬","∫":"∫","⋂":"⋂","⁣":"","⁢":"","Į":"Į","𝕀":"𝕀","Ι":"Ι","ℐ":"ℐ","Ĩ":"Ĩ","І":"І","Ï":"Ï","Ï":"Ï","Ĵ":"Ĵ","Й":"Й","𝔍":"𝔍","𝕁":"𝕁","𝒥":"𝒥","Ј":"Ј","Є":"Є","Х":"Х","Ќ":"Ќ","Κ":"Κ","Ķ":"Ķ","К":"К","𝔎":"𝔎","𝕂":"𝕂","𝒦":"𝒦","Љ":"Љ","<":"<","<":"<","Ĺ":"Ĺ","Λ":"Λ","⟪":"⟪","ℒ":"ℒ","↞":"↞","Ľ":"Ľ","Ļ":"Ļ","Л":"Л","⟨":"⟨","←":"←","⇤":"⇤","⇆":"⇆","⌈":"⌈","⟦":"⟦","⥡":"⥡","⇃":"⇃","⥙":"⥙","⌊":"⌊","↔":"↔","⥎":"⥎","⊣":"⊣","↤":"↤","⥚":"⥚","⊲":"⊲","⧏":"⧏","⊴":"⊴","⥑":"⥑","⥠":"⥠","↿":"↿","⥘":"⥘","↼":"↼","⥒":"⥒","⇐":"⇐","⇔":"⇔","⋚":"⋚","≦":"≦","≶":"≶","⪡":"⪡","⩽":"⩽","≲":"≲","𝔏":"𝔏","⋘":"⋘","⇚":"⇚","Ŀ":"Ŀ","⟵":"⟵","⟷":"⟷","⟶":"⟶","⟸":"⟸","⟺":"⟺","⟹":"⟹","𝕃":"𝕃","↙":"↙","↘":"↘","ℒ":"ℒ","↰":"↰","Ł":"Ł","≪":"≪","⤅":"⤅","М":"М"," ":" ","ℳ":"ℳ","𝔐":"𝔐","∓":"∓","𝕄":"𝕄","ℳ":"ℳ","Μ":"Μ","Њ":"Њ","Ń":"Ń","Ň":"Ň","Ņ":"Ņ","Н":"Н","​":"","​":"","​":"","​":"","≫":"≫","≪":"≪","
":`
|
|
6
6
|
`,"𝔑":"𝔑","⁠":""," ":" ","ℕ":"ℕ","⫬":"⫬","≢":"≢","≭":"≭","∦":"∦","∉":"∉","≠":"≠","≂̸":"≂̸","∄":"∄","≯":"≯","≱":"≱","≧̸":"≧̸","≫̸":"≫̸","≹":"≹","⩾̸":"⩾̸","≵":"≵","≎̸":"≎̸","≏̸":"≏̸","⋪":"⋪","⧏̸":"⧏̸","⋬":"⋬","≮":"≮","≰":"≰","≸":"≸","≪̸":"≪̸","⩽̸":"⩽̸","≴":"≴","⪢̸":"⪢̸","⪡̸":"⪡̸","⊀":"⊀","⪯̸":"⪯̸","⋠":"⋠","∌":"∌","⋫":"⋫","⧐̸":"⧐̸","⋭":"⋭","⊏̸":"⊏̸","⋢":"⋢","⊐̸":"⊐̸","⋣":"⋣","⊂⃒":"⊂⃒","⊈":"⊈","⊁":"⊁","⪰̸":"⪰̸","⋡":"⋡","≿̸":"≿̸","⊃⃒":"⊃⃒","⊉":"⊉","≁":"≁","≄":"≄","≇":"≇","≉":"≉","∤":"∤","𝒩":"𝒩","Ñ":"Ñ","Ñ":"Ñ","Ν":"Ν","Œ":"Œ","Ó":"Ó","Ó":"Ó","Ô":"Ô","Ô":"Ô","О":"О","Ő":"Ő","𝔒":"𝔒","Ò":"Ò","Ò":"Ò","Ō":"Ō","Ω":"Ω","Ο":"Ο","𝕆":"𝕆","“":"“","‘":"‘","⩔":"⩔","𝒪":"𝒪","Ø":"Ø","Ø":"Ø","Õ":"Õ","Õ":"Õ","⨷":"⨷","Ö":"Ö","Ö":"Ö","‾":"‾","⏞":"⏞","⎴":"⎴","⏜":"⏜","∂":"∂","П":"П","𝔓":"𝔓","Φ":"Φ","Π":"Π","±":"±","ℌ":"ℌ","ℙ":"ℙ","⪻":"⪻","≺":"≺","⪯":"⪯","≼":"≼","≾":"≾","″":"″","∏":"∏","∷":"∷","∝":"∝","𝒫":"𝒫","Ψ":"Ψ",""":'"',""":'"',"𝔔":"𝔔","ℚ":"ℚ","𝒬":"𝒬","⤐":"⤐","®":"®","®":"®","Ŕ":"Ŕ","⟫":"⟫","↠":"↠","⤖":"⤖","Ř":"Ř","Ŗ":"Ŗ","Р":"Р","ℜ":"ℜ","∋":"∋","⇋":"⇋","⥯":"⥯","ℜ":"ℜ","Ρ":"Ρ","⟩":"⟩","→":"→","⇥":"⇥","⇄":"⇄","⌉":"⌉","⟧":"⟧","⥝":"⥝","⇂":"⇂","⥕":"⥕","⌋":"⌋","⊢":"⊢","↦":"↦","⥛":"⥛","⊳":"⊳","⧐":"⧐","⊵":"⊵","⥏":"⥏","⥜":"⥜","↾":"↾","⥔":"⥔","⇀":"⇀","⥓":"⥓","⇒":"⇒","ℝ":"ℝ","⥰":"⥰","⇛":"⇛","ℛ":"ℛ","↱":"↱","⧴":"⧴","Щ":"Щ","Ш":"Ш","Ь":"Ь","Ś":"Ś","⪼":"⪼","Š":"Š","Ş":"Ş","Ŝ":"Ŝ","С":"С","𝔖":"𝔖","↓":"↓","←":"←","→":"→","↑":"↑","Σ":"Σ","∘":"∘","𝕊":"𝕊","√":"√","□":"□","⊓":"⊓","⊏":"⊏","⊑":"⊑","⊐":"⊐","⊒":"⊒","⊔":"⊔","𝒮":"𝒮","⋆":"⋆","⋐":"⋐","⋐":"⋐","⊆":"⊆","≻":"≻","⪰":"⪰","≽":"≽","≿":"≿","∋":"∋","∑":"∑","⋑":"⋑","⊃":"⊃","⊇":"⊇","⋑":"⋑","Þ":"Þ","Þ":"Þ","™":"™","Ћ":"Ћ","Ц":"Ц","	":" ","Τ":"Τ","Ť":"Ť","Ţ":"Ţ","Т":"Т","𝔗":"𝔗","∴":"∴","Θ":"Θ","  ":" "," ":" ","∼":"∼","≃":"≃","≅":"≅","≈":"≈","𝕋":"𝕋","⃛":"⃛","𝒯":"𝒯","Ŧ":"Ŧ","Ú":"Ú","Ú":"Ú","↟":"↟","⥉":"⥉","Ў":"Ў","Ŭ":"Ŭ","Û":"Û","Û":"Û","У":"У","Ű":"Ű","𝔘":"𝔘","Ù":"Ù","Ù":"Ù","Ū":"Ū","_":"_","⏟":"⏟","⎵":"⎵","⏝":"⏝","⋃":"⋃","⊎":"⊎","Ų":"Ų","𝕌":"𝕌","↑":"↑","⤒":"⤒","⇅":"⇅","↕":"↕","⥮":"⥮","⊥":"⊥","↥":"↥","⇑":"⇑","⇕":"⇕","↖":"↖","↗":"↗","ϒ":"ϒ","Υ":"Υ","Ů":"Ů","𝒰":"𝒰","Ũ":"Ũ","Ü":"Ü","Ü":"Ü","⊫":"⊫","⫫":"⫫","В":"В","⊩":"⊩","⫦":"⫦","⋁":"⋁","‖":"‖","‖":"‖","∣":"∣","|":"|","❘":"❘","≀":"≀"," ":" ","𝔙":"𝔙","𝕍":"𝕍","𝒱":"𝒱","⊪":"⊪","Ŵ":"Ŵ","⋀":"⋀","𝔚":"𝔚","𝕎":"𝕎","𝒲":"𝒲","𝔛":"𝔛","Ξ":"Ξ","𝕏":"𝕏","𝒳":"𝒳","Я":"Я","Ї":"Ї","Ю":"Ю","Ý":"Ý","Ý":"Ý","Ŷ":"Ŷ","Ы":"Ы","𝔜":"𝔜","𝕐":"𝕐","𝒴":"𝒴","Ÿ":"Ÿ","Ж":"Ж","Ź":"Ź","Ž":"Ž","З":"З","Ż":"Ż","​":"","Ζ":"Ζ","ℨ":"ℨ","ℤ":"ℤ","𝒵":"𝒵","á":"á","á":"á","ă":"ă","∾":"∾","∾̳":"∾̳","∿":"∿","â":"â","â":"â","´":"´","´":"´","а":"а","æ":"æ","æ":"æ","⁡":"","𝔞":"𝔞","à":"à","à":"à","ℵ":"ℵ","ℵ":"ℵ","α":"α","ā":"ā","⨿":"⨿","&":"&","&":"&","∧":"∧","⩕":"⩕","⩜":"⩜","⩘":"⩘","⩚":"⩚","∠":"∠","⦤":"⦤","∠":"∠","∡":"∡","⦨":"⦨","⦩":"⦩","⦪":"⦪","⦫":"⦫","⦬":"⦬","⦭":"⦭","⦮":"⦮","⦯":"⦯","∟":"∟","⊾":"⊾","⦝":"⦝","∢":"∢","Å":"Å","⍼":"⍼","ą":"ą","𝕒":"𝕒","≈":"≈","⩰":"⩰","⩯":"⩯","≊":"≊","≋":"≋","'":"'","≈":"≈","≊":"≊","å":"å","å":"å","𝒶":"𝒶","*":"*","≈":"≈","≍":"≍","ã":"ã","ã":"ã","ä":"ä","ä":"ä","∳":"∳","⨑":"⨑","⫭":"⫭","≌":"≌","϶":"϶","‵":"‵","∽":"∽","⋍":"⋍","⊽":"⊽","⌅":"⌅","⌅":"⌅","⎵":"⎵","⎶":"⎶","≌":"≌","б":"б","„":"„","∵":"∵","∵":"∵","⦰":"⦰","϶":"϶","ℬ":"ℬ","β":"β","ℶ":"ℶ","≬":"≬","𝔟":"𝔟","⋂":"⋂","◯":"◯","⋃":"⋃","⨀":"⨀","⨁":"⨁","⨂":"⨂","⨆":"⨆","★":"★","▽":"▽","△":"△","⨄":"⨄","⋁":"⋁","⋀":"⋀","⤍":"⤍","⧫":"⧫","▪":"▪","▴":"▴","▾":"▾","◂":"◂","▸":"▸","␣":"␣","▒":"▒","░":"░","▓":"▓","█":"█","=⃥":"=⃥","≡⃥":"≡⃥","⌐":"⌐","𝕓":"𝕓","⊥":"⊥","⊥":"⊥","⋈":"⋈","╗":"╗","╔":"╔","╖":"╖","╓":"╓","═":"═","╦":"╦","╩":"╩","╤":"╤","╧":"╧","╝":"╝","╚":"╚","╜":"╜","╙":"╙","║":"║","╬":"╬","╣":"╣","╠":"╠","╫":"╫","╢":"╢","╟":"╟","⧉":"⧉","╕":"╕","╒":"╒","┐":"┐","┌":"┌","─":"─","╥":"╥","╨":"╨","┬":"┬","┴":"┴","⊟":"⊟","⊞":"⊞","⊠":"⊠","╛":"╛","╘":"╘","┘":"┘","└":"└","│":"│","╪":"╪","╡":"╡","╞":"╞","┼":"┼","┤":"┤","├":"├","‵":"‵","˘":"˘","¦":"¦","¦":"¦","𝒷":"𝒷","⁏":"⁏","∽":"∽","⋍":"⋍","\":"\\","⧅":"⧅","⟈":"⟈","•":"•","•":"•","≎":"≎","⪮":"⪮","≏":"≏","≏":"≏","ć":"ć","∩":"∩","⩄":"⩄","⩉":"⩉","⩋":"⩋","⩇":"⩇","⩀":"⩀","∩︀":"∩︀","⁁":"⁁","ˇ":"ˇ","⩍":"⩍","č":"č","ç":"ç","ç":"ç","ĉ":"ĉ","⩌":"⩌","⩐":"⩐","ċ":"ċ","¸":"¸","¸":"¸","⦲":"⦲","¢":"¢","¢":"¢","·":"·","𝔠":"𝔠","ч":"ч","✓":"✓","✓":"✓","χ":"χ","○":"○","⧃":"⧃","ˆ":"ˆ","≗":"≗","↺":"↺","↻":"↻","®":"®","Ⓢ":"Ⓢ","⊛":"⊛","⊚":"⊚","⊝":"⊝","≗":"≗","⨐":"⨐","⫯":"⫯","⧂":"⧂","♣":"♣","♣":"♣",":":":","≔":"≔","≔":"≔",",":",","@":"@","∁":"∁","∘":"∘","∁":"∁","ℂ":"ℂ","≅":"≅","⩭":"⩭","∮":"∮","𝕔":"𝕔","∐":"∐","©":"©","©":"©","℗":"℗","↵":"↵","✗":"✗","𝒸":"𝒸","⫏":"⫏","⫑":"⫑","⫐":"⫐","⫒":"⫒","⋯":"⋯","⤸":"⤸","⤵":"⤵","⋞":"⋞","⋟":"⋟","↶":"↶","⤽":"⤽","∪":"∪","⩈":"⩈","⩆":"⩆","⩊":"⩊","⊍":"⊍","⩅":"⩅","∪︀":"∪︀","↷":"↷","⤼":"⤼","⋞":"⋞","⋟":"⋟","⋎":"⋎","⋏":"⋏","¤":"¤","¤":"¤","↶":"↶","↷":"↷","⋎":"⋎","⋏":"⋏","∲":"∲","∱":"∱","⌭":"⌭","⇓":"⇓","⥥":"⥥","†":"†","ℸ":"ℸ","↓":"↓","‐":"‐","⊣":"⊣","⤏":"⤏","˝":"˝","ď":"ď","д":"д","ⅆ":"ⅆ","‡":"‡","⇊":"⇊","⩷":"⩷","°":"°","°":"°","δ":"δ","⦱":"⦱","⥿":"⥿","𝔡":"𝔡","⇃":"⇃","⇂":"⇂","⋄":"⋄","⋄":"⋄","♦":"♦","♦":"♦","¨":"¨","ϝ":"ϝ","⋲":"⋲","÷":"÷","÷":"÷","÷":"÷","⋇":"⋇","⋇":"⋇","ђ":"ђ","⌞":"⌞","⌍":"⌍","$":"$","𝕕":"𝕕","˙":"˙","≐":"≐","≑":"≑","∸":"∸","∔":"∔","⊡":"⊡","⌆":"⌆","↓":"↓","⇊":"⇊","⇃":"⇃","⇂":"⇂","⤐":"⤐","⌟":"⌟","⌌":"⌌","𝒹":"𝒹","ѕ":"ѕ","⧶":"⧶","đ":"đ","⋱":"⋱","▿":"▿","▾":"▾","⇵":"⇵","⥯":"⥯","⦦":"⦦","џ":"џ","⟿":"⟿","⩷":"⩷","≑":"≑","é":"é","é":"é","⩮":"⩮","ě":"ě","≖":"≖","ê":"ê","ê":"ê","≕":"≕","э":"э","ė":"ė","ⅇ":"ⅇ","≒":"≒","𝔢":"𝔢","⪚":"⪚","è":"è","è":"è","⪖":"⪖","⪘":"⪘","⪙":"⪙","⏧":"⏧","ℓ":"ℓ","⪕":"⪕","⪗":"⪗","ē":"ē","∅":"∅","∅":"∅","∅":"∅"," ":" "," ":" "," ":" ","ŋ":"ŋ"," ":" ","ę":"ę","𝕖":"𝕖","⋕":"⋕","⧣":"⧣","⩱":"⩱","ε":"ε","ε":"ε","ϵ":"ϵ","≖":"≖","≕":"≕","≂":"≂","⪖":"⪖","⪕":"⪕","=":"=","≟":"≟","≡":"≡","⩸":"⩸","⧥":"⧥","≓":"≓","⥱":"⥱","ℯ":"ℯ","≐":"≐","≂":"≂","η":"η","ð":"ð","ð":"ð","ë":"ë","ë":"ë","€":"€","!":"!","∃":"∃","ℰ":"ℰ","ⅇ":"ⅇ","≒":"≒","ф":"ф","♀":"♀","ffi":"ffi","ff":"ff","ffl":"ffl","𝔣":"𝔣","fi":"fi","fj":"fj","♭":"♭","fl":"fl","▱":"▱","ƒ":"ƒ","𝕗":"𝕗","∀":"∀","⋔":"⋔","⫙":"⫙","⨍":"⨍","½":"½","½":"½","⅓":"⅓","¼":"¼","¼":"¼","⅕":"⅕","⅙":"⅙","⅛":"⅛","⅔":"⅔","⅖":"⅖","¾":"¾","¾":"¾","⅗":"⅗","⅜":"⅜","⅘":"⅘","⅚":"⅚","⅝":"⅝","⅞":"⅞","⁄":"⁄","⌢":"⌢","𝒻":"𝒻","≧":"≧","⪌":"⪌","ǵ":"ǵ","γ":"γ","ϝ":"ϝ","⪆":"⪆","ğ":"ğ","ĝ":"ĝ","г":"г","ġ":"ġ","≥":"≥","⋛":"⋛","≥":"≥","≧":"≧","⩾":"⩾","⩾":"⩾","⪩":"⪩","⪀":"⪀","⪂":"⪂","⪄":"⪄","⋛︀":"⋛︀","⪔":"⪔","𝔤":"𝔤","≫":"≫","⋙":"⋙","ℷ":"ℷ","ѓ":"ѓ","≷":"≷","⪒":"⪒","⪥":"⪥","⪤":"⪤","≩":"≩","⪊":"⪊","⪊":"⪊","⪈":"⪈","⪈":"⪈","≩":"≩","⋧":"⋧","𝕘":"𝕘","`":"`","ℊ":"ℊ","≳":"≳","⪎":"⪎","⪐":"⪐",">":">",">":">","⪧":"⪧","⩺":"⩺","⋗":"⋗","⦕":"⦕","⩼":"⩼","⪆":"⪆","⥸":"⥸","⋗":"⋗","⋛":"⋛","⪌":"⪌","≷":"≷","≳":"≳","≩︀":"≩︀","≩︀":"≩︀","⇔":"⇔"," ":" ","½":"½","ℋ":"ℋ","ъ":"ъ","↔":"↔","⥈":"⥈","↭":"↭","ℏ":"ℏ","ĥ":"ĥ","♥":"♥","♥":"♥","…":"…","⊹":"⊹","𝔥":"𝔥","⤥":"⤥","⤦":"⤦","⇿":"⇿","∻":"∻","↩":"↩","↪":"↪","𝕙":"𝕙","―":"―","𝒽":"𝒽","ℏ":"ℏ","ħ":"ħ","⁃":"⁃","‐":"‐","í":"í","í":"í","⁣":"","î":"î","î":"î","и":"и","е":"е","¡":"¡","¡":"¡","⇔":"⇔","𝔦":"𝔦","ì":"ì","ì":"ì","ⅈ":"ⅈ","⨌":"⨌","∭":"∭","⧜":"⧜","℩":"℩","ij":"ij","ī":"ī","ℑ":"ℑ","ℐ":"ℐ","ℑ":"ℑ","ı":"ı","⊷":"⊷","Ƶ":"Ƶ","∈":"∈","℅":"℅","∞":"∞","⧝":"⧝","ı":"ı","∫":"∫","⊺":"⊺","ℤ":"ℤ","⊺":"⊺","⨗":"⨗","⨼":"⨼","ё":"ё","į":"į","𝕚":"𝕚","ι":"ι","⨼":"⨼","¿":"¿","¿":"¿","𝒾":"𝒾","∈":"∈","⋹":"⋹","⋵":"⋵","⋴":"⋴","⋳":"⋳","∈":"∈","⁢":"","ĩ":"ĩ","і":"і","ï":"ï","ï":"ï","ĵ":"ĵ","й":"й","𝔧":"𝔧","ȷ":"ȷ","𝕛":"𝕛","𝒿":"𝒿","ј":"ј","є":"є","κ":"κ","ϰ":"ϰ","ķ":"ķ","к":"к","𝔨":"𝔨","ĸ":"ĸ","х":"х","ќ":"ќ","𝕜":"𝕜","𝓀":"𝓀","⇚":"⇚","⇐":"⇐","⤛":"⤛","⤎":"⤎","≦":"≦","⪋":"⪋","⥢":"⥢","ĺ":"ĺ","⦴":"⦴","ℒ":"ℒ","λ":"λ","⟨":"⟨","⦑":"⦑","⟨":"⟨","⪅":"⪅","«":"«","«":"«","←":"←","⇤":"⇤","⤟":"⤟","⤝":"⤝","↩":"↩","↫":"↫","⤹":"⤹","⥳":"⥳","↢":"↢","⪫":"⪫","⤙":"⤙","⪭":"⪭","⪭︀":"⪭︀","⤌":"⤌","❲":"❲","{":"{","[":"[","⦋":"⦋","⦏":"⦏","⦍":"⦍","ľ":"ľ","ļ":"ļ","⌈":"⌈","{":"{","л":"л","⤶":"⤶","“":"“","„":"„","⥧":"⥧","⥋":"⥋","↲":"↲","≤":"≤","←":"←","↢":"↢","↽":"↽","↼":"↼","⇇":"⇇","↔":"↔","⇆":"⇆","⇋":"⇋","↭":"↭","⋋":"⋋","⋚":"⋚","≤":"≤","≦":"≦","⩽":"⩽","⩽":"⩽","⪨":"⪨","⩿":"⩿","⪁":"⪁","⪃":"⪃","⋚︀":"⋚︀","⪓":"⪓","⪅":"⪅","⋖":"⋖","⋚":"⋚","⪋":"⪋","≶":"≶","≲":"≲","⥼":"⥼","⌊":"⌊","𝔩":"𝔩","≶":"≶","⪑":"⪑","↽":"↽","↼":"↼","⥪":"⥪","▄":"▄","љ":"љ","≪":"≪","⇇":"⇇","⌞":"⌞","⥫":"⥫","◺":"◺","ŀ":"ŀ","⎰":"⎰","⎰":"⎰","≨":"≨","⪉":"⪉","⪉":"⪉","⪇":"⪇","⪇":"⪇","≨":"≨","⋦":"⋦","⟬":"⟬","⇽":"⇽","⟦":"⟦","⟵":"⟵","⟷":"⟷","⟼":"⟼","⟶":"⟶","↫":"↫","↬":"↬","⦅":"⦅","𝕝":"𝕝","⨭":"⨭","⨴":"⨴","∗":"∗","_":"_","◊":"◊","◊":"◊","⧫":"⧫","(":"(","⦓":"⦓","⇆":"⇆","⌟":"⌟","⇋":"⇋","⥭":"⥭","‎":"","⊿":"⊿","‹":"‹","𝓁":"𝓁","↰":"↰","≲":"≲","⪍":"⪍","⪏":"⪏","[":"[","‘":"‘","‚":"‚","ł":"ł","<":"<","<":"<","⪦":"⪦","⩹":"⩹","⋖":"⋖","⋋":"⋋","⋉":"⋉","⥶":"⥶","⩻":"⩻","⦖":"⦖","◃":"◃","⊴":"⊴","◂":"◂","⥊":"⥊","⥦":"⥦","≨︀":"≨︀","≨︀":"≨︀","∺":"∺","¯":"¯","¯":"¯","♂":"♂","✠":"✠","✠":"✠","↦":"↦","↦":"↦","↧":"↧","↤":"↤","↥":"↥","▮":"▮","⨩":"⨩","м":"м","—":"—","∡":"∡","𝔪":"𝔪","℧":"℧","µ":"µ","µ":"µ","∣":"∣","*":"*","⫰":"⫰","·":"·","·":"·","−":"−","⊟":"⊟","∸":"∸","⨪":"⨪","⫛":"⫛","…":"…","∓":"∓","⊧":"⊧","𝕞":"𝕞","∓":"∓","𝓂":"𝓂","∾":"∾","μ":"μ","⊸":"⊸","⊸":"⊸","⋙̸":"⋙̸","≫⃒":"≫⃒","≫̸":"≫̸","⇍":"⇍","⇎":"⇎","⋘̸":"⋘̸","≪⃒":"≪⃒","≪̸":"≪̸","⇏":"⇏","⊯":"⊯","⊮":"⊮","∇":"∇","ń":"ń","∠⃒":"∠⃒","≉":"≉","⩰̸":"⩰̸","≋̸":"≋̸","ʼn":"ʼn","≉":"≉","♮":"♮","♮":"♮","ℕ":"ℕ"," ":" "," ":" ","≎̸":"≎̸","≏̸":"≏̸","⩃":"⩃","ň":"ň","ņ":"ņ","≇":"≇","⩭̸":"⩭̸","⩂":"⩂","н":"н","–":"–","≠":"≠","⇗":"⇗","⤤":"⤤","↗":"↗","↗":"↗","≐̸":"≐̸","≢":"≢","⤨":"⤨","≂̸":"≂̸","∄":"∄","∄":"∄","𝔫":"𝔫","≧̸":"≧̸","≱":"≱","≱":"≱","≧̸":"≧̸","⩾̸":"⩾̸","⩾̸":"⩾̸","≵":"≵","≯":"≯","≯":"≯","⇎":"⇎","↮":"↮","⫲":"⫲","∋":"∋","⋼":"⋼","⋺":"⋺","∋":"∋","њ":"њ","⇍":"⇍","≦̸":"≦̸","↚":"↚","‥":"‥","≰":"≰","↚":"↚","↮":"↮","≰":"≰","≦̸":"≦̸","⩽̸":"⩽̸","⩽̸":"⩽̸","≮":"≮","≴":"≴","≮":"≮","⋪":"⋪","⋬":"⋬","∤":"∤","𝕟":"𝕟","¬":"¬","¬":"¬","∉":"∉","⋹̸":"⋹̸","⋵̸":"⋵̸","∉":"∉","⋷":"⋷","⋶":"⋶","∌":"∌","∌":"∌","⋾":"⋾","⋽":"⋽","∦":"∦","∦":"∦","⫽⃥":"⫽⃥","∂̸":"∂̸","⨔":"⨔","⊀":"⊀","⋠":"⋠","⪯̸":"⪯̸","⊀":"⊀","⪯̸":"⪯̸","⇏":"⇏","↛":"↛","⤳̸":"⤳̸","↝̸":"↝̸","↛":"↛","⋫":"⋫","⋭":"⋭","⊁":"⊁","⋡":"⋡","⪰̸":"⪰̸","𝓃":"𝓃","∤":"∤","∦":"∦","≁":"≁","≄":"≄","≄":"≄","∤":"∤","∦":"∦","⋢":"⋢","⋣":"⋣","⊄":"⊄","⫅̸":"⫅̸","⊈":"⊈","⊂⃒":"⊂⃒","⊈":"⊈","⫅̸":"⫅̸","⊁":"⊁","⪰̸":"⪰̸","⊅":"⊅","⫆̸":"⫆̸","⊉":"⊉","⊃⃒":"⊃⃒","⊉":"⊉","⫆̸":"⫆̸","≹":"≹","ñ":"ñ","ñ":"ñ","≸":"≸","⋪":"⋪","⋬":"⋬","⋫":"⋫","⋭":"⋭","ν":"ν","#":"#","№":"№"," ":" ","⊭":"⊭","⤄":"⤄","≍⃒":"≍⃒","⊬":"⊬","≥⃒":"≥⃒",">⃒":">⃒","⧞":"⧞","⤂":"⤂","≤⃒":"≤⃒","<⃒":"<⃒","⊴⃒":"⊴⃒","⤃":"⤃","⊵⃒":"⊵⃒","∼⃒":"∼⃒","⇖":"⇖","⤣":"⤣","↖":"↖","↖":"↖","⤧":"⤧","Ⓢ":"Ⓢ","ó":"ó","ó":"ó","⊛":"⊛","⊚":"⊚","ô":"ô","ô":"ô","о":"о","⊝":"⊝","ő":"ő","⨸":"⨸","⊙":"⊙","⦼":"⦼","œ":"œ","⦿":"⦿","𝔬":"𝔬","˛":"˛","ò":"ò","ò":"ò","⧁":"⧁","⦵":"⦵","Ω":"Ω","∮":"∮","↺":"↺","⦾":"⦾","⦻":"⦻","‾":"‾","⧀":"⧀","ō":"ō","ω":"ω","ο":"ο","⦶":"⦶","⊖":"⊖","𝕠":"𝕠","⦷":"⦷","⦹":"⦹","⊕":"⊕","∨":"∨","↻":"↻","⩝":"⩝","ℴ":"ℴ","ℴ":"ℴ","ª":"ª","ª":"ª","º":"º","º":"º","⊶":"⊶","⩖":"⩖","⩗":"⩗","⩛":"⩛","ℴ":"ℴ","ø":"ø","ø":"ø","⊘":"⊘","õ":"õ","õ":"õ","⊗":"⊗","⨶":"⨶","ö":"ö","ö":"ö","⌽":"⌽","∥":"∥","¶":"¶","¶":"¶","∥":"∥","⫳":"⫳","⫽":"⫽","∂":"∂","п":"п","%":"%",".":".","‰":"‰","⊥":"⊥","‱":"‱","𝔭":"𝔭","φ":"φ","ϕ":"ϕ","ℳ":"ℳ","☎":"☎","π":"π","⋔":"⋔","ϖ":"ϖ","ℏ":"ℏ","ℎ":"ℎ","ℏ":"ℏ","+":"+","⨣":"⨣","⊞":"⊞","⨢":"⨢","∔":"∔","⨥":"⨥","⩲":"⩲","±":"±","±":"±","⨦":"⨦","⨧":"⨧","±":"±","⨕":"⨕","𝕡":"𝕡","£":"£","£":"£","≺":"≺","⪳":"⪳","⪷":"⪷","≼":"≼","⪯":"⪯","≺":"≺","⪷":"⪷","≼":"≼","⪯":"⪯","⪹":"⪹","⪵":"⪵","⋨":"⋨","≾":"≾","′":"′","ℙ":"ℙ","⪵":"⪵","⪹":"⪹","⋨":"⋨","∏":"∏","⌮":"⌮","⌒":"⌒","⌓":"⌓","∝":"∝","∝":"∝","≾":"≾","⊰":"⊰","𝓅":"𝓅","ψ":"ψ"," ":" ","𝔮":"𝔮","⨌":"⨌","𝕢":"𝕢","⁗":"⁗","𝓆":"𝓆","ℍ":"ℍ","⨖":"⨖","?":"?","≟":"≟",""":'"',""":'"',"⇛":"⇛","⇒":"⇒","⤜":"⤜","⤏":"⤏","⥤":"⥤","∽̱":"∽̱","ŕ":"ŕ","√":"√","⦳":"⦳","⟩":"⟩","⦒":"⦒","⦥":"⦥","⟩":"⟩","»":"»","»":"»","→":"→","⥵":"⥵","⇥":"⇥","⤠":"⤠","⤳":"⤳","⤞":"⤞","↪":"↪","↬":"↬","⥅":"⥅","⥴":"⥴","↣":"↣","↝":"↝","⤚":"⤚","∶":"∶","ℚ":"ℚ","⤍":"⤍","❳":"❳","}":"}","]":"]","⦌":"⦌","⦎":"⦎","⦐":"⦐","ř":"ř","ŗ":"ŗ","⌉":"⌉","}":"}","р":"р","⤷":"⤷","⥩":"⥩","”":"”","”":"”","↳":"↳","ℜ":"ℜ","ℛ":"ℛ","ℜ":"ℜ","ℝ":"ℝ","▭":"▭","®":"®","®":"®","⥽":"⥽","⌋":"⌋","𝔯":"𝔯","⇁":"⇁","⇀":"⇀","⥬":"⥬","ρ":"ρ","ϱ":"ϱ","→":"→","↣":"↣","⇁":"⇁","⇀":"⇀","⇄":"⇄","⇌":"⇌","⇉":"⇉","↝":"↝","⋌":"⋌","˚":"˚","≓":"≓","⇄":"⇄","⇌":"⇌","‏":"","⎱":"⎱","⎱":"⎱","⫮":"⫮","⟭":"⟭","⇾":"⇾","⟧":"⟧","⦆":"⦆","𝕣":"𝕣","⨮":"⨮","⨵":"⨵",")":")","⦔":"⦔","⨒":"⨒","⇉":"⇉","›":"›","𝓇":"𝓇","↱":"↱","]":"]","’":"’","’":"’","⋌":"⋌","⋊":"⋊","▹":"▹","⊵":"⊵","▸":"▸","⧎":"⧎","⥨":"⥨","℞":"℞","ś":"ś","‚":"‚","≻":"≻","⪴":"⪴","⪸":"⪸","š":"š","≽":"≽","⪰":"⪰","ş":"ş","ŝ":"ŝ","⪶":"⪶","⪺":"⪺","⋩":"⋩","⨓":"⨓","≿":"≿","с":"с","⋅":"⋅","⊡":"⊡","⩦":"⩦","⇘":"⇘","⤥":"⤥","↘":"↘","↘":"↘","§":"§","§":"§",";":";","⤩":"⤩","∖":"∖","∖":"∖","✶":"✶","𝔰":"𝔰","⌢":"⌢","♯":"♯","щ":"щ","ш":"ш","∣":"∣","∥":"∥","­":"","­":"","σ":"σ","ς":"ς","ς":"ς","∼":"∼","⩪":"⩪","≃":"≃","≃":"≃","⪞":"⪞","⪠":"⪠","⪝":"⪝","⪟":"⪟","≆":"≆","⨤":"⨤","⥲":"⥲","←":"←","∖":"∖","⨳":"⨳","⧤":"⧤","∣":"∣","⌣":"⌣","⪪":"⪪","⪬":"⪬","⪬︀":"⪬︀","ь":"ь","/":"/","⧄":"⧄","⌿":"⌿","𝕤":"𝕤","♠":"♠","♠":"♠","∥":"∥","⊓":"⊓","⊓︀":"⊓︀","⊔":"⊔","⊔︀":"⊔︀","⊏":"⊏","⊑":"⊑","⊏":"⊏","⊑":"⊑","⊐":"⊐","⊒":"⊒","⊐":"⊐","⊒":"⊒","□":"□","□":"□","▪":"▪","▪":"▪","→":"→","𝓈":"𝓈","∖":"∖","⌣":"⌣","⋆":"⋆","☆":"☆","★":"★","ϵ":"ϵ","ϕ":"ϕ","¯":"¯","⊂":"⊂","⫅":"⫅","⪽":"⪽","⊆":"⊆","⫃":"⫃","⫁":"⫁","⫋":"⫋","⊊":"⊊","⪿":"⪿","⥹":"⥹","⊂":"⊂","⊆":"⊆","⫅":"⫅","⊊":"⊊","⫋":"⫋","⫇":"⫇","⫕":"⫕","⫓":"⫓","≻":"≻","⪸":"⪸","≽":"≽","⪰":"⪰","⪺":"⪺","⪶":"⪶","⋩":"⋩","≿":"≿","∑":"∑","♪":"♪","¹":"¹","¹":"¹","²":"²","²":"²","³":"³","³":"³","⊃":"⊃","⫆":"⫆","⪾":"⪾","⫘":"⫘","⊇":"⊇","⫄":"⫄","⟉":"⟉","⫗":"⫗","⥻":"⥻","⫂":"⫂","⫌":"⫌","⊋":"⊋","⫀":"⫀","⊃":"⊃","⊇":"⊇","⫆":"⫆","⊋":"⊋","⫌":"⫌","⫈":"⫈","⫔":"⫔","⫖":"⫖","⇙":"⇙","⤦":"⤦","↙":"↙","↙":"↙","⤪":"⤪","ß":"ß","ß":"ß","⌖":"⌖","τ":"τ","⎴":"⎴","ť":"ť","ţ":"ţ","т":"т","⃛":"⃛","⌕":"⌕","𝔱":"𝔱","∴":"∴","∴":"∴","θ":"θ","ϑ":"ϑ","ϑ":"ϑ","≈":"≈","∼":"∼"," ":" ","≈":"≈","∼":"∼","þ":"þ","þ":"þ","˜":"˜","×":"×","×":"×","⊠":"⊠","⨱":"⨱","⨰":"⨰","∭":"∭","⤨":"⤨","⊤":"⊤","⌶":"⌶","⫱":"⫱","𝕥":"𝕥","⫚":"⫚","⤩":"⤩","‴":"‴","™":"™","▵":"▵","▿":"▿","◃":"◃","⊴":"⊴","≜":"≜","▹":"▹","⊵":"⊵","◬":"◬","≜":"≜","⨺":"⨺","⨹":"⨹","⧍":"⧍","⨻":"⨻","⏢":"⏢","𝓉":"𝓉","ц":"ц","ћ":"ћ","ŧ":"ŧ","≬":"≬","↞":"↞","↠":"↠","⇑":"⇑","⥣":"⥣","ú":"ú","ú":"ú","↑":"↑","ў":"ў","ŭ":"ŭ","û":"û","û":"û","у":"у","⇅":"⇅","ű":"ű","⥮":"⥮","⥾":"⥾","𝔲":"𝔲","ù":"ù","ù":"ù","↿":"↿","↾":"↾","▀":"▀","⌜":"⌜","⌜":"⌜","⌏":"⌏","◸":"◸","ū":"ū","¨":"¨","¨":"¨","ų":"ų","𝕦":"𝕦","↑":"↑","↕":"↕","↿":"↿","↾":"↾","⊎":"⊎","υ":"υ","ϒ":"ϒ","υ":"υ","⇈":"⇈","⌝":"⌝","⌝":"⌝","⌎":"⌎","ů":"ů","◹":"◹","𝓊":"𝓊","⋰":"⋰","ũ":"ũ","▵":"▵","▴":"▴","⇈":"⇈","ü":"ü","ü":"ü","⦧":"⦧","⇕":"⇕","⫨":"⫨","⫩":"⫩","⊨":"⊨","⦜":"⦜","ϵ":"ϵ","ϰ":"ϰ","∅":"∅","ϕ":"ϕ","ϖ":"ϖ","∝":"∝","↕":"↕","ϱ":"ϱ","ς":"ς","⊊︀":"⊊︀","⫋︀":"⫋︀","⊋︀":"⊋︀","⫌︀":"⫌︀","ϑ":"ϑ","⊲":"⊲","⊳":"⊳","в":"в","⊢":"⊢","∨":"∨","⊻":"⊻","≚":"≚","⋮":"⋮","|":"|","|":"|","𝔳":"𝔳","⊲":"⊲","⊂⃒":"⊂⃒","⊃⃒":"⊃⃒","𝕧":"𝕧","∝":"∝","⊳":"⊳","𝓋":"𝓋","⫋︀":"⫋︀","⊊︀":"⊊︀","⫌︀":"⫌︀","⊋︀":"⊋︀","⦚":"⦚","ŵ":"ŵ","⩟":"⩟","∧":"∧","≙":"≙","℘":"℘","𝔴":"𝔴","𝕨":"𝕨","℘":"℘","≀":"≀","≀":"≀","𝓌":"𝓌","⋂":"⋂","◯":"◯","⋃":"⋃","▽":"▽","𝔵":"𝔵","⟺":"⟺","⟷":"⟷","ξ":"ξ","⟸":"⟸","⟵":"⟵","⟼":"⟼","⋻":"⋻","⨀":"⨀","𝕩":"𝕩","⨁":"⨁","⨂":"⨂","⟹":"⟹","⟶":"⟶","𝓍":"𝓍","⨆":"⨆","⨄":"⨄","△":"△","⋁":"⋁","⋀":"⋀","ý":"ý","ý":"ý","я":"я","ŷ":"ŷ","ы":"ы","¥":"¥","¥":"¥","𝔶":"𝔶","ї":"ї","𝕪":"𝕪","𝓎":"𝓎","ю":"ю","ÿ":"ÿ","ÿ":"ÿ","ź":"ź","ž":"ž","з":"з","ż":"ż","ℨ":"ℨ","ζ":"ζ","𝔷":"𝔷","ж":"ж","⇝":"⇝","𝕫":"𝕫","𝓏":"𝓏","‍":"","‌":""};function Gd(r){return r.replace(/&(#\d+|#x[a-f0-9]+|[a-z]+\d*);?/gi,(e,t)=>{if(typeof _a[e]=="string")return _a[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 Kd(r){return"<div>"+kr(r).replace(/\n/g,"<br />")+"</div>"}function Yd(r){return r=r.replace(/\r?\n/g,"").replace(/<\!\-\-.*?\-\->/gi," ").replace(/<br\b[^>]*>/gi,`
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
|
|
14
14
|
`).replace(/^\n+/,`
|
|
15
15
|
`).replace(/\n+$/,`
|
|
16
|
-
`),r=Gd(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 Qd(r,e,t){r=(r||"").toString(),e=e||76;let n=0,s=r.length,i="",o,
|
|
17
|
-
`)}return i}function wa(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},
|
|
16
|
+
`),r=Gd(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 Qd(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: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 Qd(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
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">${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 Jd(r,e){let t=!1,n="text",s,i=[],o={address:[],comment:[],group:[],text:[],textWasQuoted:[]},a,
|
|
23
|
+
<div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function Jd(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 Xd{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 Zd=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>Zd)return[];let s=new Xd(r).tokenize(),i=[],o=[],
|
|
25
|
+
`&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const Zd=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>Zd)return[];let s=new Xd(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=Jd(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 ef(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 tf=256,rf=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||tf,maxHeadersSize:this.options.maxHeadersSize||rf},this.root=this.currentNode=new va({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 va({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=Xr.encode(d);break}default:c.content=o.content}this.attachments.push(c)}for(let u of o.childNodes)await i(u,a
|
|
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:a,value:l}=await s.read();if(a)break;n.push(l),t+=l.length}const i=new Uint8Array(t);let o=0;for(let a of n)i.set(a,o),o+=a.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=Xr.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 a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);l&&l.length&&(t[o]=l[0])}}for(const o of["delivered-to","return-path"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);if(l&&l.length&&l[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const a=this.root.headers.filter(u=>u.key===o);let l=[];if(a.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>l=l.concat(u||[])),l&&l.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l}}for(const o of["subject","message-id","in-reply-to","references"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[l]=En(a.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 a of t.attachments||[])a!=null&&a.content&&(a.content=ef(a.content),a.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let a of t.attachments||[])a!=null&&a.content&&(a.content=o.decode(a.content),a.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class iu{constructor(e){vt(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 a=await i.text();throw new Error(`API error (${i.status}): ${a}`)}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}"`)],l=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(l>0)return{success:!0,moved:l}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(a=>`UID STORE ${a} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(a=>a.ok&&a.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 l=[...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(l.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 ${l.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=l.map(p=>{var _,S,D,k,w;const g=d.get(p);if(!g)return null;const m=((_=g.flags)==null?void 0:_.some(E=>E.includes("Seen")))||!1,x=((D=(S=g.envelope)==null?void 0:S.from)==null?void 0:D.email)||"Unknown",v=((k=g.envelope)==null?void 0:k.subject)||"(No subject)",b=((w=g.envelope)==null?void 0:w.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,_;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],a=o.body||o.raw;if(!a)return console.error("No raw email content in response"),null;const u=await new Ds().parse(a);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),k=`data:${S.mimeType};base64,${D}`,w=S.contentId.replace(/^<|>$/g,"");c.set(w,k),c.set(`<${w}>`,k)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(S,D)=>{const k=c.get(D)||c.get(`<${D}>`);return k?`src="${k}"`: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)||((_=u.from)==null?void 0:_.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(a=>a.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(a){return console.error("[MailClient] findEmailInAllMail failed:",a),{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 a={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&&(a.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(a.attachments=t.attachments);const l=await this.callEmail("send",a);return{success:(l==null?void 0:l.sent)??!1,message_id:l==null?void 0:l.message_id,error:l==null?void 0:l.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}}const ou=[{id:"marin",name:"Marin",description:"⭐ Féminin, naturel et fluide"},{id:"cedar",name:"Cedar",description:"⭐ Masculin, expressif et vivant"},{id:"coral",name:"Coral",description:"Féminin, chaleureux et doux"},{id:"alloy",name:"Alloy",description:"Neutre, polyvalent"},{id:"ash",name:"Ash",description:"Masculin, calme et posé"},{id:"ballad",name:"Ballad",description:"Neutre, expressif et narratif"},{id:"echo",name:"Echo",description:"Masculin, profond et résonant"},{id:"fable",name:"Fable",description:"Masculin, accent britannique"},{id:"onyx",name:"Onyx",description:"Masculin, grave et autoritaire"},{id:"nova",name:"Nova",description:"Féminin, dynamique et énergique"},{id:"sage",name:"Sage",description:"Neutre, calme et apaisant"},{id:"shimmer",name:"Shimmer",description:"Féminin, léger et aérien"},{id:"verse",name:"Verse",description:"Neutre, poétique et mélodieux"}];class nf{constructor(e){vt(this,"config");vt(this,"promptCache",{});if(!e.system_id)throw new Error("LLMClient: system_id is REQUIRED");this.config=e}async callLLM(e,t={}){const n={coprocessor:"llm",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(`LLM 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("LLM API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async complete(e,t){var i;const n={model:(t==null?void 0:t.model)??"mlm",prompt:e,max_completion_tokens:(t==null?void 0:t.maxTokens)??2e3};t!=null&&t.systemPrompt&&(n.system=t.systemPrompt),(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature);const s=await this.callLLM("complete",n);return((i=s.result)==null?void 0:i.text)||s.result||""}async chat(e,t){const n={model:(t==null?void 0:t.model)??"mlm",messages:e};(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature),(t==null?void 0:t.maxTokens)!==void 0&&(n.max_completion_tokens=t.maxTokens);const i=(await this.callLLM("chat",n)).result;return typeof i=="string"?i:typeof(i==null?void 0:i.response)=="string"?i.response:typeof(i==null?void 0:i.text)=="string"?i.text:typeof(i==null?void 0:i.content)=="string"?i.content:typeof(i==null?void 0:i.message)=="string"?i.message:(console.warn("LLMClient.chat: unexpected result format",JSON.stringify(i,null,2)),"")}async chatJson(e,t,n){const s=[{role:"system",content:e},{role:"user",content:t}];let o=await this.chat(s,n);return typeof o=="string"&&(o=o.trim(),o.startsWith("```json")?o=o.slice(7):o.startsWith("```")&&(o=o.slice(3)),o.endsWith("```")&&(o=o.slice(0,-3)),o=o.trim()),JSON.parse(o)}async analyzeDocuments(e,t,n){var o;const s={prompt:e,files:t,model:(n==null?void 0:n.model)??"xlm"};return(n==null?void 0:n.temperature)!==void 0&&(s.temperature=n.temperature),(n==null?void 0:n.maxTokens)!==void 0&&(s.max_tokens=n.maxTokens),((o=(await this.callLLM("analyze",s)).result)==null?void 0:o.text)||""}async tts(e,t){var i;const n={model:"gpt-4o-mini-tts",voice:(t==null?void 0:t.voice)??"coral",input:e,response_format:"mp3"},s=await this.callLLM("tts",n);return((i=s.result)==null?void 0:i.audio)||s.result||""}async transcribe(e,t){var i;const n={audio_data:e};return t!=null&&t.filename&&(n.filename=t.filename),t!=null&&t.language&&(n.language=t.language),((i=(await this.callLLM("transcribe",n)).result)==null?void 0:i.text)||""}async getPrompt(e){var s;if(this.promptCache[e])return this.promptCache[e];const n=((s=(await this.callLLM("get_prompt",{name:e})).result)==null?void 0:s.content)||"";return this.promptCache[e]=n,n}clearPromptCache(){this.promptCache={}}buildPrompt(e,t){let n=e;for(const[s,i]of Object.entries(t))n=n.replace(new RegExp(`\\{\\{${s}\\}\\}`,"g"),i);return n}}const Ai="qwanyx_auth_token",Ti="qwanyx_refresh_token",Ni="qwanyx_auth_user";class Ke{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 Ao{constructor(e){vt(this,"config");this.config=e}async register(e,t,n){var s,i;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:"register",params:{email:e,password:t,...n,system_id:this.config.systemId}})})).json();return a.success&&((s=a.result)!=null&&s.success)?{success:!0,userId:a.result.user_id,email:a.result.email,requiresVerification:a.result.requiresVerification}:{success:!1,error:((i=a.result)==null?void 0:i.message)||a.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 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:"verify_email",params:{email:e,code:t}})})).json();if(l.success&&((n=l.result)!=null&&n.token)){const{token:u,user:c}=l.result;return Ke.setToken(u),Ke.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=l.result)==null?void 0:o.error)||l.error||"Verification failed"}}catch(a){return{success:!1,error:a instanceof Error?a.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,a;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 Ke.setToken(c),Ke.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((a=u.result)==null?void 0:a.message)||u.error||"Password reset failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async login(e,t,n){var s,i,o,a,l,u;try{const d=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,system_id:this.config.systemId,...n}})})).json();if((s=d.result)!=null&&s.requiresVerification||d.requiresVerification)return{success:!1,error:((i=d.result)==null?void 0:i.error)||d.error||"Please verify your email first",requiresVerification:!0};if(d.success&&((o=d.result)!=null&&o.token)){const{token:f,user:p}=d.result;return Ke.setToken(f),Ke.setUser(p),(l=(a=this.config).onLogin)==null||l.call(a,p),{success:!0,user:p,token:f}}else return{success:!1,error:((u=d.result)==null?void 0:u.error)||d.error||"Login failed"}}catch(c){return{success:!1,error:c instanceof Error?c.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;Ke.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",...Ke.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 Ke.getUser()}isAuthenticated(){return Ke.isAuthenticated()}async listAllUsers(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_users",params:{...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async listSystemUsers(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_system_users",params:{system_id:this.config.systemId,...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async addUserToSystem(e,t="member"){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async updateMembershipRole(e,t){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listUserSystems(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_systems",params:{user_id:e}})})).json();return n.success&&n.result?{success:!0,systems:n.result.systems||[]}:{success:!1,error:n.error||"Failed to list user systems"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async updateUser(e,t){try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"update_user",params:{user_id:e,updates:t}})})).json();if(s.success&&s.result){const i=Ke.getUser();if(i&&(i._id===e||i.id===e)){const o={...i,...t};Ke.setUser(o)}return{success:!0}}return{success:!1,error:s.error||"Update failed"}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async removeUserFromSystem(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ke.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"remove_system_from_user",params:{user_id:e,system_id:this.config.systemId}})})).json();return{success:n.success||!1,error:n.error}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}}let As=null;function sf(r){return As=new Ao(r),As}function of(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class au{constructor(e){vt(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,a=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,l={...this.config.headers,...Ke.getAuthHeader(),...s},u={method:n,headers:l};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),f=await fetch(a,{...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 af(r){return Ts=new au(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={exports:{}},cn={};/**
|
|
27
|
+
`);c.content=Xr.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(Kd(u.value));break;case"plain":e[l].push(Yd(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=Xr.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=ef(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){_t(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 w,S,D,E,v;const g=d.get(p);if(!g)return null;const m=((w=g.flags)==null?void 0:w.some(k=>k.includes("Seen")))||!1,x=((D=(S=g.envelope)==null?void 0:S.from)==null?void 0:D.email)||"Unknown",_=((E=g.envelope)==null?void 0:E.subject)||"(No subject)",b=((v=g.envelope)==null?void 0:v.date)||"";return{uid:p,from:x,subject:_,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:typeof n=="number"?n:void 0,attachment_id:typeof n=="string"?n:void 0,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,_,b,w;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),E=`data:${S.mimeType};base64,${D}`,v=S.contentId.replace(/^<|>$/g,"");c.set(v,E),c.set(`<${v}>`,E)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(S,D)=>{const E=c.get(D)||c.get(`<${D}>`);return E?`src="${E}"`:S}));const f=((_=o.flags)==null?void 0:_.some(S=>S.toLowerCase().includes("seen")))||!1,p=((b=u.from)==null?void 0:b.address)||((w=u.from)==null?void 0:w.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)}}}async getGmailAuthUrl(e,t){return this.callMail("gmail_get_auth_url",{account_id:e||"gmail",redirect_uri:t||"https://api.qwanyx.com/oauth/gmail/callback"})}async isGmailConnected(e){var t;try{const s=(t=(await this.getSettings()).accounts)==null?void 0:t.find(i=>i.id===e);return(s==null?void 0:s.auth_type)==="gmail_api"&&!!(s!=null&&s.gmail_tokens)}catch{return!1}}async disconnectGmail(e){try{return await this.callMail("gmail_disconnect",{account_id:e}),{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async gmailSearchMessage(e,t,n){try{const s=await this.callMail("gmail_search_message",{account_id:e,subject:t,from:n});return(s==null?void 0:s.found)===!1?null:s}catch(s){return console.error("[MailClient] gmailSearchMessage failed:",s),null}}async connectGmail(e){return new Promise(async t=>{try{const{auth_url:n}=await this.getGmailAuthUrl(e),s=600,i=700,o=window.screenX+(window.outerWidth-s)/2,l=window.screenY+(window.outerHeight-i)/2,a=window.open(n,"gmail_oauth",`width=${s},height=${i},left=${o},top=${l},scrollbars=yes`);if(!a){t({success:!1,error:"Popup blocked. Please allow popups for this site."});return}const u=d=>{var f,p;((f=d.data)==null?void 0:f.type)==="gmail_oauth_success"?(window.removeEventListener("message",u),t({success:!0,email:d.data.email})):((p=d.data)==null?void 0:p.type)==="gmail_oauth_error"&&(window.removeEventListener("message",u),t({success:!1,error:d.data.description||d.data.error}))};window.addEventListener("message",u);const c=setInterval(()=>{a.closed&&(clearInterval(c),window.removeEventListener("message",u),setTimeout(()=>{},500))},500)}catch(n){t({success:!1,error:n instanceof Error?n.message:String(n)})}})}}const ou=[{id:"marin",name:"Marin",description:"⭐ Féminin, naturel et fluide"},{id:"cedar",name:"Cedar",description:"⭐ Masculin, expressif et vivant"},{id:"coral",name:"Coral",description:"Féminin, chaleureux et doux"},{id:"alloy",name:"Alloy",description:"Neutre, polyvalent"},{id:"ash",name:"Ash",description:"Masculin, calme et posé"},{id:"ballad",name:"Ballad",description:"Neutre, expressif et narratif"},{id:"echo",name:"Echo",description:"Masculin, profond et résonant"},{id:"fable",name:"Fable",description:"Masculin, accent britannique"},{id:"onyx",name:"Onyx",description:"Masculin, grave et autoritaire"},{id:"nova",name:"Nova",description:"Féminin, dynamique et énergique"},{id:"sage",name:"Sage",description:"Neutre, calme et apaisant"},{id:"shimmer",name:"Shimmer",description:"Féminin, léger et aérien"},{id:"verse",name:"Verse",description:"Neutre, poétique et mélodieux"}];class nf{constructor(e){_t(this,"config");_t(this,"promptCache",{});if(!e.system_id)throw new Error("LLMClient: system_id is REQUIRED");this.config=e}async callLLM(e,t={}){const n={coprocessor:"llm",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(`LLM 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("LLM API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async complete(e,t){var i;const n={model:(t==null?void 0:t.model)??"mlm",prompt:e,max_completion_tokens:(t==null?void 0:t.maxTokens)??2e3};t!=null&&t.systemPrompt&&(n.system=t.systemPrompt),(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature);const s=await this.callLLM("complete",n);return((i=s.result)==null?void 0:i.text)||s.result||""}async chat(e,t){const n={model:(t==null?void 0:t.model)??"mlm",messages:e};(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature),(t==null?void 0:t.maxTokens)!==void 0&&(n.max_completion_tokens=t.maxTokens);const i=(await this.callLLM("chat",n)).result;return typeof i=="string"?i:typeof(i==null?void 0:i.response)=="string"?i.response:typeof(i==null?void 0:i.text)=="string"?i.text:typeof(i==null?void 0:i.content)=="string"?i.content:typeof(i==null?void 0:i.message)=="string"?i.message:(console.warn("LLMClient.chat: unexpected result format",JSON.stringify(i,null,2)),"")}async chatJson(e,t,n){const s=[{role:"system",content:e},{role:"user",content:t}];let o=await this.chat(s,n);return typeof o=="string"&&(o=o.trim(),o.startsWith("```json")?o=o.slice(7):o.startsWith("```")&&(o=o.slice(3)),o.endsWith("```")&&(o=o.slice(0,-3)),o=o.trim()),JSON.parse(o)}async analyzeDocuments(e,t,n){var o;const s={prompt:e,files:t,model:(n==null?void 0:n.model)??"xlm"};return(n==null?void 0:n.temperature)!==void 0&&(s.temperature=n.temperature),(n==null?void 0:n.maxTokens)!==void 0&&(s.max_tokens=n.maxTokens),((o=(await this.callLLM("analyze",s)).result)==null?void 0:o.text)||""}async tts(e,t){var i;const n={model:"gpt-4o-mini-tts",voice:(t==null?void 0:t.voice)??"coral",input:e,response_format:"mp3"},s=await this.callLLM("tts",n);return((i=s.result)==null?void 0:i.audio)||s.result||""}async transcribe(e,t){var i;const n={audio_data:e};return t!=null&&t.filename&&(n.filename=t.filename),t!=null&&t.language&&(n.language=t.language),((i=(await this.callLLM("transcribe",n)).result)==null?void 0:i.text)||""}async getPrompt(e){var s;if(this.promptCache[e])return this.promptCache[e];const n=((s=(await this.callLLM("get_prompt",{name:e})).result)==null?void 0:s.content)||"";return this.promptCache[e]=n,n}clearPromptCache(){this.promptCache={}}buildPrompt(e,t){let n=e;for(const[s,i]of Object.entries(t))n=n.replace(new RegExp(`\\{\\{${s}\\}\\}`,"g"),i);return n}}const Ai="qwanyx_auth_token",Ti="qwanyx_refresh_token",Ni="qwanyx_auth_user";class Qe{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 Ao{constructor(e){_t(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,system_id:this.config.systemId}})})).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 Qe.setToken(u),Qe.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 Qe.setToken(c),Qe.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,n){var s,i,o,l,a,u;try{const d=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,system_id:this.config.systemId,...n}})})).json();if((s=d.result)!=null&&s.requiresVerification||d.requiresVerification)return{success:!1,error:((i=d.result)==null?void 0:i.error)||d.error||"Please verify your email first",requiresVerification:!0};if(d.success&&((o=d.result)!=null&&o.token)){const{token:f,user:p}=d.result;return Qe.setToken(f),Qe.setUser(p),(a=(l=this.config).onLogin)==null||a.call(l,p),{success:!0,user:p,token:f}}else return{success:!1,error:((u=d.result)==null?void 0:u.error)||d.error||"Login failed"}}catch(c){return{success:!1,error:c instanceof Error?c.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;Qe.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",...Qe.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 Qe.getUser()}isAuthenticated(){return Qe.isAuthenticated()}async listAllUsers(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_users",params:{...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async listSystemUsers(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_system_users",params:{system_id:this.config.systemId,...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async addUserToSystem(e,t="member"){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async updateMembershipRole(e,t){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listUserSystems(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_systems",params:{user_id:e}})})).json();return n.success&&n.result?{success:!0,systems:n.result.systems||[]}:{success:!1,error:n.error||"Failed to list user systems"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async updateUser(e,t){try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"update_user",params:{user_id:e,updates:t}})})).json();if(s.success&&s.result){const i=Qe.getUser();if(i&&(i._id===e||i.id===e)){const o={...i,...t};Qe.setUser(o)}return{success:!0}}return{success:!1,error:s.error||"Update failed"}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async removeUserFromSystem(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Qe.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"remove_system_from_user",params:{user_id:e,system_id:this.config.systemId}})})).json();return{success:n.success||!1,error:n.error}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}}let As=null;function sf(r){return As=new Ao(r),As}function of(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class au{constructor(e){_t(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,...Qe.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 af(r){return Ts=new au(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={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 lf(){if(Sa)return cn;Sa=1;var r=y,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(a,
|
|
36
|
+
*/var Sa;function lf(){if(Sa)return cn;Sa=1;var r=y,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 ka;function uf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,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"),
|
|
45
|
-
`+ge+A}}var xe=!1,
|
|
46
|
-
`),
|
|
47
|
-
`),tt=je.length-1,nt=
|
|
48
|
-
`+je[tt].replace(" at new "," at ");return A.displayName&&
|
|
44
|
+
*/var ka;function uf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,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 $=g&&A[g]||A[m];return typeof $=="function"?$:null}var _=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var $=arguments.length,ne=new Array($>1?$-1:0),me=1;me<$;me++)ne[me-1]=arguments[me];w("error",A,ne)}}function w(A,$,ne){{var me=_.ReactDebugCurrentFrame,Re=me.getStackAddendum();Re!==""&&($+="%s",ne=ne.concat([Re]));var Oe=ne.map(function(Be){return String(Be)});Oe.unshift("Warning: "+$),Function.prototype.apply.call(console[A],console,Oe)}}var S=!1,D=!1,E=!1,v=!1,k=!1,M;M=Symbol.for("react.module.reference");function N(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||k||A===s||A===u||A===c||v||A===p||S||D||E||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===l||A.$$typeof===a||A.$$typeof===M||A.getModuleId!==void 0))}function T(A,$,ne){var me=A.displayName;if(me)return me;var Re=$.displayName||$.name||"";return Re!==""?ne+"("+Re+")":ne}function B(A){return A.displayName||"Context"}function R(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 $=A;return B($)+".Consumer";case o:var ne=A;return B(ne._context)+".Provider";case a:return T(A,A.render,"ForwardRef");case d:var me=A.displayName||null;return me!==null?me:R(A.type)||"Memo";case f:{var Re=A,Oe=Re._payload,Be=Re._init;try{return R(Be(Oe))}catch{return null}}}return null}var C=Object.assign,j=0,F,I,q,ee,O,W,Z;function H(){}H.__reactDisabledLog=!0;function ie(){{if(j===0){F=console.log,I=console.info,q=console.warn,ee=console.error,O=console.group,W=console.groupCollapsed,Z=console.groupEnd;var A={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}j++}}function fe(){{if(j--,j===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},A,{value:F}),info:C({},A,{value:I}),warn:C({},A,{value:q}),error:C({},A,{value:ee}),group:C({},A,{value:O}),groupCollapsed:C({},A,{value:W}),groupEnd:C({},A,{value:Z})})}j<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=_.ReactCurrentDispatcher,ge;function ye(A,$,ne){{if(ge===void 0)try{throw Error()}catch(Re){var me=Re.stack.trim().match(/\n( *(at )?)/);ge=me&&me[1]||""}return`
|
|
45
|
+
`+ge+A}}var xe=!1,Q;{var Se=typeof WeakMap=="function"?WeakMap:Map;Q=new Se}function se(A,$){if(!A||xe)return"";{var ne=Q.get(A);if(ne!==void 0)return ne}var me;xe=!0;var Re=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Oe;Oe=ae.current,ae.current=null,ie();try{if($){var Be=function(){throw Error()};if(Object.defineProperty(Be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Be,[])}catch(vt){me=vt}Reflect.construct(A,[],Be)}else{try{Be.call()}catch(vt){me=vt}A.call(Be.prototype)}}else{try{throw Error()}catch(vt){me=vt}A()}}catch(vt){if(vt&&me&&typeof vt.stack=="string"){for(var je=vt.stack.split(`
|
|
46
|
+
`),pt=me.stack.split(`
|
|
47
|
+
`),tt=je.length-1,nt=pt.length-1;tt>=1&&nt>=0&&je[tt]!==pt[nt];)nt--;for(;tt>=1&&nt>=0;tt--,nt--)if(je[tt]!==pt[nt]){if(tt!==1||nt!==1)do if(tt--,nt--,nt<0||je[tt]!==pt[nt]){var Nt=`
|
|
48
|
+
`+je[tt].replace(" at new "," at ");return A.displayName&&Nt.includes("<anonymous>")&&(Nt=Nt.replace("<anonymous>",A.displayName)),typeof A=="function"&&Q.set(A,Nt),Nt}while(tt>=1&&nt>=0);break}}}finally{xe=!1,ae.current=Oe,fe(),Error.prepareStackTrace=Re}var Or=A?A.displayName||A.name:"",vr=Or?ye(Or):"";return typeof A=="function"&&Q.set(A,vr),vr}function Ne(A,$,ne){return se(A,!1)}function be(A){var $=A.prototype;return!!($&&$.isReactComponent)}function ve(A,$,ne){if(A==null)return"";if(typeof A=="function")return se(A,be(A));if(typeof A=="string")return ye(A);switch(A){case u:return ye("Suspense");case c:return ye("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case a:return Ne(A.render);case d:return ve(A.type,$,ne);case f:{var me=A,Re=me._payload,Oe=me._init;try{return ve(Oe(Re),$,ne)}catch{}}}return""}var Le=Object.prototype.hasOwnProperty,Me={},$e=_.ReactDebugCurrentFrame;function G(A){if(A){var $=A._owner,ne=ve(A.type,A._source,$?$.type:null);$e.setExtraStackFrame(ne)}else $e.setExtraStackFrame(null)}function z(A,$,ne,me,Re){{var Oe=Function.call.bind(Le);for(var Be in A)if(Oe(A,Be)){var je=void 0;try{if(typeof A[Be]!="function"){var pt=Error((me||"React class")+": "+ne+" type `"+Be+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Be]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw pt.name="Invariant Violation",pt}je=A[Be]($,Be,me,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(tt){je=tt}je&&!(je instanceof Error)&&(G(Re),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).",me||"React class",ne,Be,typeof je),G(null)),je instanceof Error&&!(je.message in Me)&&(Me[je.message]=!0,G(Re),b("Failed %s type: %s",ne,je.message),G(null))}}}var Pe=Array.isArray;function He(A){return Pe(A)}function K(A){{var $=typeof Symbol=="function"&&Symbol.toStringTag,ne=$&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ne}}function re(A){try{return de(A),!1}catch{return!0}}function de(A){return""+A}function _e(A){if(re(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",K(A)),de(A)}var we=_.ReactCurrentOwner,xt={key:!0,ref:!0,__self:!0,__source:!0},bt,le;function he(A){if(Le.call(A,"ref")){var $=Object.getOwnPropertyDescriptor(A,"ref").get;if($&&$.isReactWarning)return!1}return A.ref!==void 0}function We(A){if(Le.call(A,"key")){var $=Object.getOwnPropertyDescriptor(A,"key").get;if($&&$.isReactWarning)return!1}return A.key!==void 0}function Ke(A,$){typeof A.ref=="string"&&we.current}function V(A,$){{var ne=function(){bt||(bt=!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)",$))};ne.isReactWarning=!0,Object.defineProperty(A,"key",{get:ne,configurable:!0})}}function Ve(A,$){{var ne=function(){le||(le=!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)",$))};ne.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ne,configurable:!0})}}var U=function(A,$,ne,me,Re,Oe,Be){var je={$$typeof:e,type:A,key:$,ref:ne,props:Be,_owner:Oe};return je._store={},Object.defineProperty(je._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(je,"_self",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.defineProperty(je,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Re}),Object.freeze&&(Object.freeze(je.props),Object.freeze(je)),je};function L(A,$,ne,me,Re){{var Oe,Be={},je=null,pt=null;ne!==void 0&&(_e(ne),je=""+ne),We($)&&(_e($.key),je=""+$.key),he($)&&(pt=$.ref,Ke($,Re));for(Oe in $)Le.call($,Oe)&&!xt.hasOwnProperty(Oe)&&(Be[Oe]=$[Oe]);if(A&&A.defaultProps){var tt=A.defaultProps;for(Oe in tt)Be[Oe]===void 0&&(Be[Oe]=tt[Oe])}if(je||pt){var nt=typeof A=="function"?A.displayName||A.name||"Unknown":A;je&&V(Be,nt),pt&&Ve(Be,nt)}return U(A,je,pt,Re,me,we.current,Be)}}var ce=_.ReactCurrentOwner,pe=_.ReactDebugCurrentFrame;function J(A){if(A){var $=A._owner,ne=ve(A.type,A._source,$?$.type:null);pe.setExtraStackFrame(ne)}else pe.setExtraStackFrame(null)}var Ce;Ce=!1;function ke(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function Ee(){{if(ce.current){var A=R(ce.current.type);if(A)return`
|
|
49
49
|
|
|
50
|
-
Check the render method of \``+A+"`."}return""}}function
|
|
50
|
+
Check the render method of \``+A+"`."}return""}}function Ie(A){return""}var Ge={};function De(A){{var $=Ee();if(!$){var ne=typeof A=="string"?A:A.displayName||A.name;ne&&($=`
|
|
51
51
|
|
|
52
|
-
Check the top-level render call using <`+
|
|
52
|
+
Check the top-level render call using <`+ne+">.")}return $}}function Ae(A,$){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ne=De($);if(Ge[ne])return;Ge[ne]=!0;var me="";A&&A._owner&&A._owner!==ce.current&&(me=" It was passed a child from "+R(A._owner.type)+"."),J(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.',ne,me),J(null)}}function rt(A,$){{if(typeof A!="object")return;if(He(A))for(var ne=0;ne<A.length;ne++){var me=A[ne];ke(me)&&Ae(me,$)}else if(ke(A))A._store&&(A._store.validated=!0);else if(A){var Re=x(A);if(typeof Re=="function"&&Re!==A.entries)for(var Oe=Re.call(A),Be;!(Be=Oe.next()).done;)ke(Be.value)&&Ae(Be.value,$)}}}function it(A){{var $=A.type;if($==null||typeof $=="string")return;var ne;if(typeof $=="function")ne=$.propTypes;else if(typeof $=="object"&&($.$$typeof===a||$.$$typeof===d))ne=$.propTypes;else return;if(ne){var me=R($);z(ne,A.props,"prop",me,A)}else if($.PropTypes!==void 0&&!Ce){Ce=!0;var Re=R($);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Re||"Unknown")}typeof $.getDefaultProps=="function"&&!$.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ye(A){{for(var $=Object.keys(A.props),ne=0;ne<$.length;ne++){var me=$[ne];if(me!=="children"&&me!=="key"){J(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",me),J(null);break}}A.ref!==null&&(J(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}var qe={};function dt(A,$,ne,me,Re,Oe){{var Be=N(A);if(!Be){var je="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(je+=" 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 pt=Ie();pt?je+=pt:je+=Ee();var tt;A===null?tt="null":He(A)?tt="array":A!==void 0&&A.$$typeof===e?(tt="<"+(R(A.type)||"Unknown")+" />",je=" Did you accidentally export a JSX literal instead of a component?"):tt=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",tt,je)}var nt=L(A,$,ne,Re,Oe);if(nt==null)return nt;if(Be){var Nt=$.children;if(Nt!==void 0)if(me)if(He(Nt)){for(var Or=0;Or<Nt.length;Or++)rt(Nt[Or],A);Object.freeze&&Object.freeze(Nt)}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 rt(Nt,A)}if(Le.call($,"key")){var vr=R(A),vt=Object.keys($).filter(function(Md){return Md!=="key"}),Si=vt.length>0?"{key: someKey, "+vt.join(": ..., ")+": ...}":"{key: someKey}";if(!qe[vr+Si]){var jd=vt.length>0?"{"+vt.join(": ..., ")+": ...}":"{}";b(`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,vr,jd,vr),
|
|
57
|
+
<%s key={someKey} {...props} />`,Si,vr,jd,vr),qe[vr+Si]=!0}}return A===n?Ye(nt):it(nt),nt}}function ft(A,$,ne){return dt(A,$,ne,!0)}function Tt(A,$,ne){return dt(A,$,ne,!1)}var Zt=Tt,jt=ft;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=jt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=lf():Vi.exports=uf();var h=Vi.exports;const lu=y.createContext(void 0);function cf({apiUrl:r,systemId:e,children:t}){const[n,s]=y.useState(null),[i,o]=y.useState(null),[l,a]=y.useState(!1),[u,c]=y.useState(!0),[d]=y.useState(()=>new Ao({apiUrl:r,systemId:e})),f=y.useCallback(async D=>{const E=await d.isAdmin(D);a(E)},[d]),p=y.useCallback(()=>{const D=Qe.getToken(),E=Qe.getUser();D&&E?(o(D),s(E),f(E._id).finally(()=>c(!1))):c(!1)},[f]);y.useEffect(()=>{p()},[p]);const g=y.useCallback(async(D,E)=>{const v=await d.login(D,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await f(v.user._id)),v},[d,f]),m=y.useCallback(async(D,E,v)=>d.register(D,E,v),[d]),x=y.useCallback(async(D,E)=>{const v=await d.verifyEmail(D,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await f(v.user._id)),v},[d,f]),_=y.useCallback(async D=>d.requestPasswordReset(D),[d]),b=y.useCallback(async(D,E,v)=>{const k=await d.setPasswordWithCode(D,E,v);return k.success&&k.user&&k.token&&(o(k.token),s(k.user),await f(k.user._id)),k},[d,f]),w=y.useCallback(async D=>d.resendVerificationCode(D),[d]),S=y.useCallback(()=>{d.logout(),s(null),o(null),a(!1)},[d]);return h.jsx(lu.Provider,{value:{user:n,token:i,isAdmin:l,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:_,setPasswordWithCode:b,resendVerificationCode:w,logout:S,refreshUser:p},children:t})}function df(){const r=y.useContext(lu);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const ff={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function No({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]=y.useState(""),[p,g]=y.useState(""),[m,x]=y.useState(""),[_,b]=y.useState(!1),w={...ff,...a};async function S(N){N.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:w.backgroundColor,borderRadius:w.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...c&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},E={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${w.borderColor}`,borderRadius:w.borderRadius,backgroundColor:w.inputBackground,color:w.textColor,fontSize:"1rem",outline:"none"},v={display:"block",fontSize:"0.875rem",fontWeight:500,color:w.textMutedColor,marginBottom:"0.25rem"},k={width:"100%",padding:"0.75rem",backgroundColor:_?w.textMutedColor:w.primaryColor,color:"#ffffff",border:"none",borderRadius:w.borderRadius,fontSize:"1rem",fontWeight:500,cursor:_?"not-allowed":"pointer",transition:"background-color 0.2s"},M={padding:"0.75rem",backgroundColor:w.errorBackgroundColor,border:`1px solid ${w.errorColor}20`,borderRadius:w.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:w.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:S,children:[m&&h.jsx("div",{style:M,children:h.jsx("p",{style:{fontSize:"0.875rem",color:w.errorColor,margin:0},children:m})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:v,children:o}),h.jsx("input",{type:"email",value:d,onChange:N=>f(N.target.value),required:!0,style:E,onFocus:N=>{N.target.style.borderColor=w.primaryColor,N.target.style.boxShadow=`0 0 0 2px ${w.primaryColor}20`},onBlur:N=>{N.target.style.borderColor=w.borderColor,N.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:v,children:l}),h.jsx("input",{type:"password",value:p,onChange:N=>g(N.target.value),required:!0,style:E,onFocus:N=>{N.target.style.borderColor=w.primaryColor,N.target.style.boxShadow=`0 0 0 2px ${w.primaryColor}20`},onBlur:N=>{N.target.style.borderColor=w.borderColor,N.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:_,style:k,onMouseEnter:N=>{_||(N.target.style.backgroundColor=w.primaryHoverColor)},onMouseLeave:N=>{_||(N.target.style.backgroundColor=w.primaryColor)},children:_?i:s})]})]})}function hf({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(No,{...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 pf={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({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:a="Email",passwordLabel:l="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]=y.useState(""),[_,S]=y.useState(""),[D,k]=y.useState(""),[w,E]=y.useState(""),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(!1),j={...pf,...g};async function F(H){if(H.preventDefault(),B(""),_!==D){B("Les mots de passe ne correspondent pas");return}if(_.length<8){B("Le mot de passe doit contenir au moins 8 caractères");return}C(!0);const ue=await r(v,_,p?{firstName:w,lastName:M}:void 0);ue.success?e==null||e(v):B(ue.error||"Erreur lors de l'inscription"),C(!1)}const I={backgroundColor:j.backgroundColor,borderRadius:j.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 ${j.borderColor}`,borderRadius:j.borderRadius,backgroundColor:j.inputBackground,color:j.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},q={display:"block",fontSize:"0.875rem",fontWeight:500,color:j.textMutedColor,marginBottom:"0.25rem"},ne={width:"100%",padding:"0.75rem",backgroundColor:R?j.textMutedColor:j.primaryColor,color:"#ffffff",border:"none",borderRadius:j.borderRadius,fontSize:"1rem",fontWeight:500,cursor:R?"not-allowed":"pointer",transition:"background-color 0.2s"},U={padding:"0.75rem",backgroundColor:j.errorBackgroundColor,border:`1px solid ${j.errorColor}20`,borderRadius:j.borderRadius,marginBottom:"1rem"},Q={color:j.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:j.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:F,children:[T&&h.jsx("div",{style:U,children:h.jsx("p",{style:{fontSize:"0.875rem",color:j.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:q,children:c}),h.jsx("input",{type:"text",value:w,onChange:H=>E(H.target.value),style:W})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:q,children:d}),h.jsx("input",{type:"text",value:M,onChange:H=>N(H.target.value),style:W})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:q,children:a}),h.jsx("input",{type:"email",value:v,onChange:H=>b(H.target.value),required:!0,style:W})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:q,children:l}),h.jsx("input",{type:"password",value:_,onChange:H=>S(H.target.value),required:!0,minLength:8,style:W})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:q,children:u}),h.jsx("input",{type:"password",value:D,onChange:H=>k(H.target.value),required:!0,style:W})]}),h.jsx("button",{type:"submit",disabled:R,style:ne,onMouseEnter:H=>{R||(H.target.style.backgroundColor=j.primaryHoverColor)},onMouseLeave:H=>{R||(H.target.style.backgroundColor=j.primaryColor)},children:R?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:Q,onClick:t,children:f})})]})]})}const gf={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:a="Vérifier",loadingText:l="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]=y.useState(Array(f).fill("")),[b,_]=y.useState(""),[S,D]=y.useState(!1),[k,w]=y.useState(!1),[E,M]=y.useState(!1),N=y.useRef([]),T={...gf,...p};y.useEffect(()=>{var U;(U=N.current[0])==null||U.focus()},[]);const B=(U,Q)=>{var ue;const H=Q.replace(/\D/g,"").slice(-1),ie=[...x];if(ie[U]=H,v(ie),_(""),H&&U<f-1&&((ue=N.current[U+1])==null||ue.focus()),H&&U===f-1){const he=ie.join("");he.length===f&&j(he)}},R=(U,Q)=>{var H;Q.key==="Backspace"&&!x[U]&&U>0&&((H=N.current[U-1])==null||H.focus())},C=U=>{var ue;U.preventDefault();const Q=U.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),H=[...x];Q.split("").forEach((he,ge)=>{ge<f&&(H[ge]=he)}),v(H);const ie=Math.min(Q.length,f)-1;ie>=0&&((ue=N.current[ie])==null||ue.focus()),Q.length===f&&j(Q)};async function j(U){var ie;const Q=U||x.join("");if(Q.length!==f){_("Veuillez entrer le code complet");return}D(!0),_("");const H=await e(r,Q);H.success?t==null||t():(_(H.error||"Code invalide"),v(Array(f).fill("")),(ie=N.current[0])==null||ie.focus()),D(!1)}async function F(){if(!n)return;w(!0),M(!1),_("");const U=await n(r);U.success?(M(!0),setTimeout(()=>M(!1),3e3)):_(U.error||"Erreur lors de l'envoi"),w(!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"},q={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"},ne={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}`}),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})}),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((U,Q)=>h.jsx("input",{ref:H=>{N.current[Q]=H},type:"text",inputMode:"numeric",maxLength:1,value:U,onChange:H=>B(Q,H.target.value),onKeyDown:H=>R(Q,H),onPaste:C,disabled:S,style:{...W,borderColor:U?T.primaryColor:T.borderColor},onFocus:H=>{H.target.style.borderColor=T.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${T.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=U?T.primaryColor:T.borderColor,H.target.style.boxShadow="none"}},Q))}),h.jsx("button",{type:"button",onClick:()=>j(),disabled:S||x.join("").length!==f,style:{...q,opacity:x.join("").length!==f?.5:1},children:S?l:a}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:F,disabled:k,style:{...ne,opacity:k?.5:1},children:k?c:u})}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:ne,children:d})})]})}const mf={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 cu({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:a="Email",backText:l="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[f,p]=y.useState(""),[g,m]=y.useState(""),[x,v]=y.useState(!1),b={...mf,...u};async function _(M){M.preventDefault(),v(!0),m("");const N=await r(f);N.success?e==null||e(f):m(N.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"},k={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},w={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"},E={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:_,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:k,children:a}),h.jsx("input",{type:"email",value:f,onChange:M=>p(M.target.value),required:!0,style:D})]}),h.jsx("button",{type:"submit",disabled:x,style:w,onMouseEnter:M=>{x||(M.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:M=>{x||(M.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:E,children:l})})]})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:a="Réinitialiser",loadingText:l="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]=y.useState(""),[v,b]=y.useState(""),[_,S]=y.useState(""),[D,k]=y.useState(!1),w={...yf,...f};async function E(C){if(C.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}k(!0);const j=await t(r,e,m);j.success?n==null||n():S(j.error||"Erreur lors de la réinitialisation"),k(!1)}const M={backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},N={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${w.borderColor}`,borderRadius:w.borderRadius,backgroundColor:w.inputBackground,color:w.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},T={display:"block",fontSize:"0.875rem",fontWeight:500,color:w.textMutedColor,marginBottom:"0.25rem"},B={width:"100%",padding:"0.75rem",backgroundColor:D?w.textMutedColor:w.primaryColor,color:"#ffffff",border:"none",borderRadius:w.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},R={color:w.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:M,className:p,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:w.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&h.jsx("p",{style:{fontSize:"0.875rem",color:w.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),h.jsxs("form",{onSubmit:E,children:[_&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:w.errorBackgroundColor,border:`1px solid ${w.errorColor}20`,borderRadius:w.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:w.errorColor,margin:0},children:_})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:T,children:u}),h.jsx("input",{type:"password",value:m,onChange:C=>x(C.target.value),required:!0,minLength:8,style:N})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:v,onChange:C=>b(C.target.value),required:!0,style:N})]}),h.jsx("button",{type:"submit",disabled:D,style:B,onMouseEnter:C=>{D||(C.target.style.backgroundColor=w.primaryHoverColor)},onMouseLeave:C=>{D||(C.target.style.backgroundColor=w.primaryColor)},children:D?l:a}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:R,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:a="login",logo:l,theme:u,showNameFields:c=!1,className:d="",isModal:f=!1,labels:p={}}){const[g,m]=y.useState(a),[x,v]=y.useState(""),[b,_]=y.useState("");async function S(N,T){const B=await r(N,T);return B.requiresVerification?(v(N),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):B}async function D(N,T,B){const R=await e(N,T,B);return R.success&&R.requiresVerification&&(v(N),m("verify-email")),R}async function k(N){const T=await n(N);return T.success&&(v(N),m("verify-reset-code")),T}async function w(N,T){return _(T),m("reset-password"),{success:!0}}const E=()=>{switch(g){case"login":return h.jsx(No,{onLogin:S,onSuccess:o,logo:l,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(uu,{onRegister:D,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:l,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(cu,{onRequestReset:k,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:f});case"verify-reset-code":return h.jsx(Gi,{email:x,onVerify:w,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:f});case"reset-password":return h.jsx(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},M=()=>{const N={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:N,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:N,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[E(),M()]})}function xf({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(fu,{...n,isModal:!0})]}),h.jsx("style",{children:`
|
|
68
|
+
`})]})}const pf={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({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[_,b]=y.useState(""),[w,S]=y.useState(""),[D,E]=y.useState(""),[v,k]=y.useState(""),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(!1),j={...pf,...g};async function F(H){if(H.preventDefault(),B(""),w!==D){B("Les mots de passe ne correspondent pas");return}if(w.length<8){B("Le mot de passe doit contenir au moins 8 caractères");return}C(!0);const fe=await r(_,w,p?{firstName:v,lastName:M}:void 0);fe.success?e==null||e(_):B(fe.error||"Erreur lors de l'inscription"),C(!1)}const I={backgroundColor:j.backgroundColor,borderRadius:j.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${j.borderColor}`,borderRadius:j.borderRadius,backgroundColor:j.inputBackground,color:j.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},ee={display:"block",fontSize:"0.875rem",fontWeight:500,color:j.textMutedColor,marginBottom:"0.25rem"},O={width:"100%",padding:"0.75rem",backgroundColor:R?j.textMutedColor:j.primaryColor,color:"#ffffff",border:"none",borderRadius:j.borderRadius,fontSize:"1rem",fontWeight:500,cursor:R?"not-allowed":"pointer",transition:"background-color 0.2s"},W={padding:"0.75rem",backgroundColor:j.errorBackgroundColor,border:`1px solid ${j.errorColor}20`,borderRadius:j.borderRadius,marginBottom:"1rem"},Z={color:j.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:j.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:F,children:[T&&h.jsx("div",{style:W,children:h.jsx("p",{style:{fontSize:"0.875rem",color:j.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:ee,children:c}),h.jsx("input",{type:"text",value:v,onChange:H=>k(H.target.value),style:q})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:ee,children:d}),h.jsx("input",{type:"text",value:M,onChange:H=>N(H.target.value),style:q})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:ee,children:l}),h.jsx("input",{type:"email",value:_,onChange:H=>b(H.target.value),required:!0,style:q})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:ee,children:a}),h.jsx("input",{type:"password",value:w,onChange:H=>S(H.target.value),required:!0,minLength:8,style:q})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:ee,children:u}),h.jsx("input",{type:"password",value:D,onChange:H=>E(H.target.value),required:!0,style:q})]}),h.jsx("button",{type:"submit",disabled:R,style:O,onMouseEnter:H=>{R||(H.target.style.backgroundColor=j.primaryHoverColor)},onMouseLeave:H=>{R||(H.target.style.backgroundColor=j.primaryColor)},children:R?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:Z,onClick:t,children:f})})]})]})}const gf={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,_]=y.useState(Array(f).fill("")),[b,w]=y.useState(""),[S,D]=y.useState(!1),[E,v]=y.useState(!1),[k,M]=y.useState(!1),N=y.useRef([]),T={...gf,...p};y.useEffect(()=>{var W;(W=N.current[0])==null||W.focus()},[]);const B=(W,Z)=>{var fe;const H=Z.replace(/\D/g,"").slice(-1),ie=[...x];if(ie[W]=H,_(ie),w(""),H&&W<f-1&&((fe=N.current[W+1])==null||fe.focus()),H&&W===f-1){const ae=ie.join("");ae.length===f&&j(ae)}},R=(W,Z)=>{var H;Z.key==="Backspace"&&!x[W]&&W>0&&((H=N.current[W-1])==null||H.focus())},C=W=>{var fe;W.preventDefault();const Z=W.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),H=[...x];Z.split("").forEach((ae,ge)=>{ge<f&&(H[ge]=ae)}),_(H);const ie=Math.min(Z.length,f)-1;ie>=0&&((fe=N.current[ie])==null||fe.focus()),Z.length===f&&j(Z)};async function j(W){var ie;const Z=W||x.join("");if(Z.length!==f){w("Veuillez entrer le code complet");return}D(!0),w("");const H=await e(r,Z);H.success?t==null||t():(w(H.error||"Code invalide"),_(Array(f).fill("")),(ie=N.current[0])==null||ie.focus()),D(!1)}async function F(){if(!n)return;v(!0),M(!1),w("");const W=await n(r);W.success?(M(!0),setTimeout(()=>M(!1),3e3)):w(W.error||"Erreur lors de l'envoi"),v(!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)"}},q={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"},ee={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"},O={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}`}),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((W,Z)=>h.jsx("input",{ref:H=>{N.current[Z]=H},type:"text",inputMode:"numeric",maxLength:1,value:W,onChange:H=>B(Z,H.target.value),onKeyDown:H=>R(Z,H),onPaste:C,disabled:S,style:{...q,borderColor:W?T.primaryColor:T.borderColor},onFocus:H=>{H.target.style.borderColor=T.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${T.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=W?T.primaryColor:T.borderColor,H.target.style.boxShadow="none"}},Z))}),h.jsx("button",{type:"button",onClick:()=>j(),disabled:S||x.join("").length!==f,style:{...ee,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:F,disabled:E,style:{...O,opacity:E?.5:1},children:E?c:u})}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:O,children:d})})]})}const mf={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 cu({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]=y.useState(""),[g,m]=y.useState(""),[x,_]=y.useState(!1),b={...mf,...u};async function w(M){M.preventDefault(),_(!0),m("");const N=await r(f);N.success?e==null||e(f):m(N.error||"Erreur lors de l'envoi"),_(!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"},E={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},v={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:w,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:E,children:l}),h.jsx("input",{type:"email",value:f,onChange:M=>p(M.target.value),required:!0,style:D})]}),h.jsx("button",{type:"submit",disabled:x,style:v,onMouseEnter:M=>{x||(M.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:M=>{x||(M.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 yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({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]=y.useState(""),[_,b]=y.useState(""),[w,S]=y.useState(""),[D,E]=y.useState(!1),v={...yf,...f};async function k(C){if(C.preventDefault(),S(""),m!==_){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}E(!0);const j=await t(r,e,m);j.success?n==null||n():S(j.error||"Erreur lors de la réinitialisation"),E(!1)}const M={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},N={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},T={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},B={width:"100%",padding:"0.75rem",backgroundColor:D?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},R={color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:M,className:p,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&h.jsx("p",{style:{fontSize:"0.875rem",color:v.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),h.jsxs("form",{onSubmit:k,children:[w&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:w})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:T,children:u}),h.jsx("input",{type:"password",value:m,onChange:C=>x(C.target.value),required:!0,minLength:8,style:N})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:_,onChange:C=>b(C.target.value),required:!0,style:N})]}),h.jsx("button",{type:"submit",disabled:D,style:B,onMouseEnter:C=>{D||(C.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:C=>{D||(C.target.style.backgroundColor=v.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:R,children:d})})]})]})}function fu({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]=y.useState(l),[x,_]=y.useState(""),[b,w]=y.useState("");async function S(N,T){const B=await r(N,T);return B.requiresVerification?(_(N),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):B}async function D(N,T,B){const R=await e(N,T,B);return R.success&&(R.requiresVerification?(_(N),m("verify-email")):o==null||o()),R}async function E(N){const T=await n(N);return T.success&&(_(N),m("verify-reset-code")),T}async function v(N,T){return w(T),m("reset-password"),{success:!0}}const k=()=>{switch(g){case"login":return h.jsx(No,{onLogin:S,onSuccess:o,logo:a,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(uu,{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(cu,{onRequestReset:E,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:f});case"verify-reset-code":return h.jsx(Gi,{email:x,onVerify:v,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:f});case"reset-password":return h.jsx(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},M=()=>{const N={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:N,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:N,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[k(),M()]})}function xf({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(fu,{...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 hu(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[a
|
|
79
|
+
`})]}):null}function hu(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[l,a]=y.useState(null),[u,c]=y.useState(n),[d,f]=y.useState(null),p=y.useCallback(async()=>{if(n){c(!0),f(null);try{const m=await To().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 y.useEffect(()=>{s&&p()},[p,s]),{data:l,loading:u,error:d,refetch:p}}function bf(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=y.useState(null),[l,a]=y.useState(!1),[u,c]=y.useState(null),d=y.useCallback(async p=>{a(!0),c(null);try{const g=To();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=y.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 vf({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:_,refetch:b}=hu(r,e),[w,S]=y.useState(""),[D,E]=y.useState({}),[v,k]=y.useState(1),M=y.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let C=m;return l&&w&&a.length>0&&(C=vs.search(C,w,a)),Object.keys(D).length>0&&(C=vs.filterByFields(C,D)),vs.paginate(C,v,d)},[m,w,D,v,d,l,a]);y.useEffect(()=>{k(1)},[w,D]);const N=()=>{S(""),E({}),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"},R=i||(C=>h.jsxs("div",{style:{padding:"16px",cursor:f?"pointer":"default"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:T.text},children:C.title||C.name||C.label||"Untitled"}),C.description&&h.jsx("div",{style:{fontSize:"13px",color:T.textSecondary,marginTop:"4px"},children:C.description})]}));return x&&!m?h.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:T.textSecondary},children:"Loading..."}):_?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:_.message}),h.jsx("button",{onClick:N,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:N,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:w,onChange:C=>S(C.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:M.data.length===0?h.jsx("div",{style:{padding:"48px",textAlign:"center",color:T.textSecondary},children:s}):M.data.map((C,j)=>h.jsx("div",{onClick:()=>f==null?void 0:f(C),style:{background:T.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${T.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:F=>{f&&(F.currentTarget.style.background=T.border)},onMouseLeave:F=>{F.currentTarget.style.background=T.cardBackground},children:R(C,j)},o(C,j)))}),M.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 ",v," of ",M.totalPages]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>k(C=>Math.max(1,C-1)),disabled:v===1,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:v===1?"not-allowed":"pointer",opacity:v===1?.5:1},children:"Previous"}),h.jsx("button",{onClick:()=>k(C=>Math.min(M.totalPages,C+1)),disabled:v===M.totalPages,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:v===M.totalPages?"not-allowed":"pointer",opacity:v===M.totalPages?.5:1},children:"Next"})]})]})]})}function _f({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:[l&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:l,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})]}),a&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:a})]}),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 wf({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((a,l)=>{const u=a.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:a.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},l)})}),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 Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Cf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Sf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var N,T;const[a]=y.useState(()=>{if(r.length===0)return[[],[]];const B=Cf(r),R=Math.ceil(B.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:B.slice(0,R).map(C=>C.title),right:B.slice(R).map(C=>C.title)}),[B.slice(0,R),B.slice(R)]}),[l,u]=y.useState(()=>{const B=Ea[s];if(typeof window>"u")return B.base;const R=window.innerWidth;return"lg"in B&&R>=1024?B.lg:R>=768?B.md:R>=640?B.sm:B.base});y.useEffect(()=>{const B=()=>{const R=Ea[s],C=window.innerWidth;"lg"in R&&C>=1024?u(R.lg):C>=768?u(R.md):C>=640?u(R.sm):u(R.base)};return window.addEventListener("resize",B),B(),()=>window.removeEventListener("resize",B)},[s]);const[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(!1),[b,_]=y.useState(!1),[S,D]=y.useState(!1);y.useEffect(()=>{if(a[0].length<=1)return;const B=setInterval(()=>{m(R=>!R),setTimeout(()=>{d(R=>(R+1)%a[0].length),_(R=>!R)},250)},e+Math.random()*(t-e));return()=>clearInterval(B)},[a,e,t]),y.useEffect(()=>{if(a[1].length<=1)return;let B=null;const R=setTimeout(()=>{B=setInterval(()=>{v(C=>!C),setTimeout(()=>{p(C=>(C+1)%a[1].length),D(C=>!C)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(R),B&&clearInterval(B)}},[a,e,t]);const k=(N=a[0])==null?void 0:N[c],w=(T=a[1])==null?void 0:T[f];if(r.length===0||!k)return h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No images available"})});const E=i==="2:3"?l*1.5:l,M=(B,R,C)=>h.jsx("div",{className:"relative",style:{width:l,height:E,perspective:"1000px"},onClick:()=>n==null?void 0:n(B),children:h.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${R?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:h.jsxs("div",{className:"w-full h-full",style:{transform:C?"scaleX(-1)":"none"},children:[h.jsx("img",{src:B.data.image,alt:B.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:B.title})})]})})});return h.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[M(k,g,b),w&&M(w,x,S)]})}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,(a,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const kf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Ef({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:a=!0,searchQuery:l,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:b,renderActions:_,renderEmpty:S,renderLoading:D,theme:k={}}){const w={...kf,...k},[E,M]=y.useState([]),[N,T]=y.useState(!1),[B,R]=y.useState(null),[C,j]=y.useState(new Set),[F,I]=y.useState(null),[W,q]=y.useState(null),[ne,U]=y.useState(null),[Q,H]=y.useState(!1),[ie,ue]=y.useState(""),he=l!==void 0?l:ie,ge=le=>{u?u(le):ue(le)},we=y.useMemo(()=>{if(!he.trim())return E;const le=he.toLowerCase();return E.filter(pe=>$r(pe.from).toLowerCase().includes(le)||$r(pe.subject).toLowerCase().includes(le))},[E,he]),xe=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),Z=y.useCallback(async()=>{if(xe){T(!0),R(null);try{const le=await xe.listEmails(t,n,s);le!=null&&le.messages&&(M(le.messages),x==null||x(le.messages))}catch(le){const pe=le instanceof Error?le:new Error("Failed to fetch emails");R(pe.message),m==null||m(pe)}T(!1)}},[xe,t,n,s,m,x]);y.useEffect(()=>{M([]),j(new Set),q(null),R(null),l===void 0&&ue(""),d&&Z()},[s,d]);const be=y.useCallback(async le=>{if(xe){q(le),U(null),H(!0);try{const pe=await xe.getEmailParsed(t,le.uid,s||"INBOX");pe!=null&&pe.body&&U(pe.body)}catch(pe){console.error("Failed to fetch email body:",pe)}H(!1)}},[xe,t,s]),te=y.useCallback(le=>{f==null||f(le),o&&be(le)},[f,o,be]),Ae=y.useCallback((le,pe,Ve)=>{if(!i){f==null||f(le),o&&be(le);return}const Ze=le.uid;if(Ve.shiftKey&&F!==null){const et=Math.min(F,pe),Bt=Math.max(F,pe),J=E.slice(et,Bt+1).map(fe=>fe.uid),L=new Set(J);j(L),p==null||p(Array.from(L))}else if(Ve.ctrlKey||Ve.metaKey)j(et=>{const Bt=new Set(et);return Bt.has(Ze)?Bt.delete(Ze):Bt.add(Ze),p==null||p(Array.from(Bt)),Bt}),I(pe);else{const et=new Set([Ze]);j(et),I(pe),p==null||p(Array.from(et))}},[i,F,E,C,f,p,o]),_e=y.useCallback(async()=>{if(!xe||C.size===0)return;const le=s||"INBOX";try{const pe=await xe.trashEmails(t,Array.from(C),le);if(console.log("Trash result:",pe),pe.success&&pe.moved>0){M(Ze=>Ze.filter(et=>!C.has(et.uid)));const Ve=Array.from(C);j(new Set),g==null||g(Ve)}else R("Failed to move emails to trash")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Trash failed");console.error("Trash error:",Ve),R(Ve.message),m==null||m(Ve)}},[xe,t,C,s,g,m]),ve=y.useCallback(async()=>{if(!xe||C.size===0)return;const le=s||"INBOX";try{const pe=await xe.archiveEmails(t,Array.from(C),le);if(console.log("Archive result:",pe),pe.success&&pe.archived>0){M(Ze=>Ze.filter(et=>!C.has(et.uid)));const Ve=Array.from(C);j(new Set),g==null||g(Ve)}else R("Failed to archive emails")}catch(pe){const Ve=pe instanceof Error?pe:new Error("Archive failed");console.error("Archive error:",Ve),R(Ve.message),m==null||m(Ve)}},[xe,t,C,s,g,m]),Re=y.useCallback(()=>{if(C.size===E.length)j(new Set),p==null||p([]);else{const le=new Set(E.map(pe=>pe.uid));j(le),p==null||p(Array.from(le))}},[E,C.size,p]),Le=y.useCallback(()=>{j(new Set),p==null||p([])},[p]),qe={delete:_e,archive:ve,refresh:Z,selectAll:Re,clearSelection:Le},V=le=>{if(!le)return"";const pe=new Date(le),Ve=new Date;return pe.toDateString()===Ve.toDateString()?pe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString([],{month:"short",day:"numeric"})},O=(le,pe)=>h.jsx("div",{style:{padding:"12px 16px",background:pe?w.selectedBackground:le.seen?w.cardBackground:w.unreadBackground,borderBottom:`1px solid ${w.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:le.seen?400:600,color:w.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(le.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:le.seen?400:500,color:le.seen?w.textSecondary:w.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(le.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary,flexShrink:0},children:V(le.date)})]})}),Ue=le=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:w.text},children:$r(le.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:w.textSecondary,marginBottom:"16px"},children:["From: ",$r(le.from)," • ",new Date(le.date).toLocaleString()]}),Q?h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"Loading..."}):ne?h.jsx("div",{style:{fontSize:"14px",color:w.text},dangerouslySetInnerHTML:{__html:ne}}):h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"No content available"})]}),se=(le,pe)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:w.cardBackground,borderBottom:`1px solid ${w.border}`},children:[h.jsx("button",{onClick:pe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:w.text},children:le.length===E.length?"Deselect All":"Select All"}),le.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:w.textSecondary},children:[le.length," selected"]}),h.jsx("button",{onClick:pe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:pe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:pe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),re=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:c}),oe=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:"Loading..."}),z=v||O,de=b||Ue,Ce=_||se,We=S||re,dt=D||oe;return N&&E.length===0?h.jsx("div",{style:{background:w.background,width:"100%",height:"100%"},children:dt()}):h.jsxs("div",{style:{display:"flex",background:w.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 ${w.border}`:"none",overflow:"hidden"},children:[i&&Ce(Array.from(C),qe),a&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${w.border}`,background:w.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:w.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:he,onChange:le=>ge(le.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:w.text}}),he&&h.jsx("button",{onClick:()=>ge(""),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:w.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),B&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:w.danger,fontSize:"14px",borderBottom:`1px solid ${w.border}`},children:B}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:we.length===0?We():we.map((le,pe)=>h.jsx("div",{onClick:Ve=>Ae(le,pe,Ve),onDoubleClick:()=>te(le),children:z(le,C.has(le.uid))},le.uid))})]}),o&&W&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:de(W)})]})}function Df({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:a=!0,className:l=""}){const[u,c]=y.useState(new Set),[d,f]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(D=>{const k=new Set(D);return k.has(S)?k.delete(S):k.add(S),t==null||t(Array.from(k)),k})},[t]),x=y.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=y.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=y.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]),_=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.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 ${l}`,children:o}):h.jsxs("div",{className:`space-y-2 ${l}`,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:[a&&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),k=(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 ${k?"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,k)})]},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 k;const D=((k=S.disabled)==null?void 0:k.call(S,p))??!1;return h.jsxs("button",{onClick:()=>_(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 Af(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tf=Af(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 pu=y.createContext(null);function Nf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=y.useContext(pu);return r==null&&Tf(8),r}function Hn(r){return{}}const Bo={},Bf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},It={},jo={},Mo={},jf={},mu={},Mf={},yu={},Rf={},xu={},bu={},Ns={},Ff={},vu={},_u={},wu={},Lf={},Pf={},If={},Da={},Cu={},Of={},Su={},ku={},zf={},ii={},Ro={},Yi={},$f={},qf={},as={},ls={},Uf={},Wf={},Hf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vf=$t&&"documentMode"in document?document.documentMode:null,Mt=$t&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=$t&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!$t||!("InputEvent"in window)||Vf)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Gf=$t&&/Android/.test(navigator.userAgent),Eu=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Kf=$t&&Gf&&Eu,Fo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Yf=0,Qf=1,Jf=2,js=4,Ms=8,Lo=128,Xf=112|(3|js|Ms)|Lo,Po=1,Io=2,Oo=3,zo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"",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 wf({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 Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Cf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function Sf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var N,T;const[l]=y.useState(()=>{if(r.length===0)return[[],[]];const B=Cf(r),R=Math.ceil(B.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:B.slice(0,R).map(C=>C.title),right:B.slice(R).map(C=>C.title)}),[B.slice(0,R),B.slice(R)]}),[a,u]=y.useState(()=>{const B=Ea[s];if(typeof window>"u")return B.base;const R=window.innerWidth;return"lg"in B&&R>=1024?B.lg:R>=768?B.md:R>=640?B.sm:B.base});y.useEffect(()=>{const B=()=>{const R=Ea[s],C=window.innerWidth;"lg"in R&&C>=1024?u(R.lg):C>=768?u(R.md):C>=640?u(R.sm):u(R.base)};return window.addEventListener("resize",B),B(),()=>window.removeEventListener("resize",B)},[s]);const[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(!1),[b,w]=y.useState(!1),[S,D]=y.useState(!1);y.useEffect(()=>{if(l[0].length<=1)return;const B=setInterval(()=>{m(R=>!R),setTimeout(()=>{d(R=>(R+1)%l[0].length),w(R=>!R)},250)},e+Math.random()*(t-e));return()=>clearInterval(B)},[l,e,t]),y.useEffect(()=>{if(l[1].length<=1)return;let B=null;const R=setTimeout(()=>{B=setInterval(()=>{_(C=>!C),setTimeout(()=>{p(C=>(C+1)%l[1].length),D(C=>!C)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(R),B&&clearInterval(B)}},[l,e,t]);const E=(N=l[0])==null?void 0:N[c],v=(T=l[1])==null?void 0:T[f];if(r.length===0||!E)return h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No images available"})});const k=i==="2:3"?a*1.5:a,M=(B,R,C)=>h.jsx("div",{className:"relative",style:{width:a,height:k,perspective:"1000px"},onClick:()=>n==null?void 0:n(B),children:h.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${R?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:h.jsxs("div",{className:"w-full h-full",style:{transform:C?"scaleX(-1)":"none"},children:[h.jsx("img",{src:B.data.image,alt:B.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:B.title})})]})})});return h.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[M(E,g,b),v&&M(v,x,S)]})}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 kf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Ef({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:_,renderDetail:b,renderActions:w,renderEmpty:S,renderLoading:D,theme:E={}}){const v={...kf,...E},[k,M]=y.useState([]),[N,T]=y.useState(!1),[B,R]=y.useState(null),[C,j]=y.useState(new Set),[F,I]=y.useState(null),[q,ee]=y.useState(null),[O,W]=y.useState(null),[Z,H]=y.useState(!1),[ie,fe]=y.useState(""),ae=a!==void 0?a:ie,ge=le=>{u?u(le):fe(le)},ye=y.useMemo(()=>{if(!ae.trim())return k;const le=ae.toLowerCase();return k.filter(he=>$r(he.from).toLowerCase().includes(le)||$r(he.subject).toLowerCase().includes(le))},[k,ae]),xe=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),Q=y.useCallback(async()=>{if(xe){T(!0),R(null);try{const le=await xe.listEmails(t,n,s);le!=null&&le.messages&&(M(le.messages),x==null||x(le.messages))}catch(le){const he=le instanceof Error?le:new Error("Failed to fetch emails");R(he.message),m==null||m(he)}T(!1)}},[xe,t,n,s,m,x]);y.useEffect(()=>{M([]),j(new Set),ee(null),R(null),a===void 0&&fe(""),d&&Q()},[s,d]);const Se=y.useCallback(async le=>{if(xe){ee(le),W(null),H(!0);try{const he=await xe.getEmailParsed(t,le.uid,s||"INBOX");he!=null&&he.body&&W(he.body)}catch(he){console.error("Failed to fetch email body:",he)}H(!1)}},[xe,t,s]),se=y.useCallback(le=>{f==null||f(le),o&&Se(le)},[f,o,Se]),Ne=y.useCallback((le,he,We)=>{if(!i){f==null||f(le),o&&Se(le);return}const Ke=le.uid;if(We.shiftKey&&F!==null){const V=Math.min(F,he),Ve=Math.max(F,he),U=k.slice(V,Ve+1).map(ce=>ce.uid),L=new Set(U);j(L),p==null||p(Array.from(L))}else if(We.ctrlKey||We.metaKey)j(V=>{const Ve=new Set(V);return Ve.has(Ke)?Ve.delete(Ke):Ve.add(Ke),p==null||p(Array.from(Ve)),Ve}),I(he);else{const V=new Set([Ke]);j(V),I(he),p==null||p(Array.from(V))}},[i,F,k,C,f,p,o]),be=y.useCallback(async()=>{if(!xe||C.size===0)return;const le=s||"INBOX";try{const he=await xe.trashEmails(t,Array.from(C),le);if(console.log("Trash result:",he),he.success&&he.moved>0){M(Ke=>Ke.filter(V=>!C.has(V.uid)));const We=Array.from(C);j(new Set),g==null||g(We)}else R("Failed to move emails to trash")}catch(he){const We=he instanceof Error?he:new Error("Trash failed");console.error("Trash error:",We),R(We.message),m==null||m(We)}},[xe,t,C,s,g,m]),ve=y.useCallback(async()=>{if(!xe||C.size===0)return;const le=s||"INBOX";try{const he=await xe.archiveEmails(t,Array.from(C),le);if(console.log("Archive result:",he),he.success&&he.archived>0){M(Ke=>Ke.filter(V=>!C.has(V.uid)));const We=Array.from(C);j(new Set),g==null||g(We)}else R("Failed to archive emails")}catch(he){const We=he instanceof Error?he:new Error("Archive failed");console.error("Archive error:",We),R(We.message),m==null||m(We)}},[xe,t,C,s,g,m]),Le=y.useCallback(()=>{if(C.size===k.length)j(new Set),p==null||p([]);else{const le=new Set(k.map(he=>he.uid));j(le),p==null||p(Array.from(le))}},[k,C.size,p]),Me=y.useCallback(()=>{j(new Set),p==null||p([])},[p]),$e={delete:be,archive:ve,refresh:Q,selectAll:Le,clearSelection:Me},G=le=>{if(!le)return"";const he=new Date(le),We=new Date;return he.toDateString()===We.toDateString()?he.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):he.toLocaleDateString([],{month:"short",day:"numeric"})},z=(le,he)=>h.jsx("div",{style:{padding:"12px 16px",background:he?v.selectedBackground:le.seen?v.cardBackground:v.unreadBackground,borderBottom:`1px solid ${v.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:le.seen?400:600,color:v.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(le.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:le.seen?400:500,color:le.seen?v.textSecondary:v.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(le.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:v.textSecondary,flexShrink:0},children:G(le.date)})]})}),Pe=le=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:v.text},children:$r(le.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:v.textSecondary,marginBottom:"16px"},children:["From: ",$r(le.from)," • ",new Date(le.date).toLocaleString()]}),Z?h.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"Loading..."}):O?h.jsx("div",{style:{fontSize:"14px",color:v.text},dangerouslySetInnerHTML:{__html:O}}):h.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"No content available"})]}),He=(le,he)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:v.cardBackground,borderBottom:`1px solid ${v.border}`},children:[h.jsx("button",{onClick:he.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:v.text},children:le.length===k.length?"Deselect All":"Select All"}),le.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:v.textSecondary},children:[le.length," selected"]}),h.jsx("button",{onClick:he.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:he.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:he.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),K=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:c}),re=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:"Loading..."}),de=_||z,_e=b||Pe,we=w||He,xt=S||K,bt=D||re;return N&&k.length===0?h.jsx("div",{style:{background:v.background,width:"100%",height:"100%"},children:bt()}):h.jsxs("div",{style:{display:"flex",background:v.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&q?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&q?`1px solid ${v.border}`:"none",overflow:"hidden"},children:[i&&we(Array.from(C),$e),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${v.border}`,background:v.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:v.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:ae,onChange:le=>ge(le.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:v.text}}),ae&&h.jsx("button",{onClick:()=>ge(""),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:v.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),B&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:v.danger,fontSize:"14px",borderBottom:`1px solid ${v.border}`},children:B}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ye.length===0?xt():ye.map((le,he)=>h.jsx("div",{onClick:We=>Ne(le,he,We),onDoubleClick:()=>se(le),children:de(le,C.has(le.uid))},le.uid))})]}),o&&q&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:_e(q)})]})}function Df({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=y.useState(new Set),[d,f]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(D=>{const E=new Set(D);return E.has(S)?E.delete(S):E.add(S),t==null||t(Array.from(E)),E})},[t]),x=y.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]),_=y.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=y.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]),w=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.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:_,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),E=(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 ${E?"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,E)})]},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 E;const D=((E=S.disabled)==null?void 0:E.call(S,p))??!1;return h.jsxs("button",{onClick:()=>w(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 Af(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Tf=Af(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 pu=y.createContext(null);function Nf(r,e){return{getTheme:function(){return e??null}}}function Ot(){const r=y.useContext(pu);return r==null&&Tf(8),r}function Hn(r){return{}}const Bo={},Bf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},It={},jo={},Mo={},jf={},mu={},Mf={},yu={},Rf={},xu={},bu={},Ns={},Ff={},vu={},_u={},wu={},Lf={},Pf={},If={},Da={},Cu={},zf={},Su={},ku={},Of={},ii={},Ro={},Yi={},$f={},qf={},as={},ls={},Uf={},Wf={},Hf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vf=$t&&"documentMode"in document?document.documentMode:null,Mt=$t&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=$t&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!$t||!("InputEvent"in window)||Vf)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Gf=$t&&/Android/.test(navigator.userAgent),Eu=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Kf=$t&&Gf&&Eu,Fo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Yf=0,Qf=1,Jf=2,js=4,Ms=8,Lo=128,Xf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"",sr=`
|
|
84
84
|
|
|
85
|
-
`,Zf=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",eh=new RegExp("^[^"+Tu+"]*["+Au+"]"),th=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},rh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:zo,left:Po,right:Oo,start:$o},nh={[Io]:"center",[qo]:"end",[zo]:"justify",[Po]:"left",[Oo]:"right",[$o]:"start"},sh={normal:0,segmented:2,token:1},ih={[Yf]:"normal",[Jf]:"segmented",[Qf]:"token"};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Y=oh(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 Rs(...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 ah=100;let Qi=!1,Uo=0;function lh(r){Uo=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 uh(r,e,t){const n=Nt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function ch(r,e,t){if(G(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function dh(r,e,t,n){for(let s=r;s&&!Sh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=pt(i,t);if(o)return $e(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>ah;try{kt(r,()=>{const s=ce()||function(f){return f.getEditorState().read(()=>{const p=ce();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),a=r._editorState,l=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=dh(m,r,a,o);if(!x)continue;const[v,b]=x;if(g==="characterData")n&&X(b)&&ch(s,m,b)&&uh(m,b,r);else if(g==="childList"){u=!0;const _=p.addedNodes;for(let k=0;k<_.length;k++){const w=_[k],E=Lu(w),M=w.parentNode;if(M!=null&&w!==l&&E===null&&!Bi(w,M,r)){if(mr){const N=w.innerText||w.nodeValue;N&&(c+=N)}M.removeChild(w)}}const S=p.removedNodes,D=S.length;if(D>0){let k=0;for(let w=0;w<D;w++){const E=S[w];(Bi(E,m,r)||l===E)&&(m.appendChild(E),k++)}D!==k&&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,Kt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",lh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,a=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==a)}function Na(r,e){const t=r.mergeWithSibling(e),n=Xe()._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&&X(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&&X(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(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),X(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 fh=1;const hh=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return $e(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function ph(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(ph(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 X(r)||Ar(r)||$e(r)}function gh(r,e){if(e!=null)return void(r.__key=e);_t(),uc();const t=Xe(),n=ar(),s=""+fh++;n._nodeMap.set(s,r),P(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,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 a=i.getWritable();a.__prev=o.__key,o.__next=a.__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 a=s.getWritable();a.__next=o.__key,o.__prev=a.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=Xe(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(l,u,c){let d=l;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 a=e.__key;s._dirtyType=Du,P(r)?o.set(a,!0):s._dirtyLeaves.add(a)}function ct(r){_t();const e=Xe(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=pt(t);n!==null&&n.getWritable()}if(r!==null){const n=pt(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Xe()._compositionKey}function pt(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,Xe());return t!==void 0?pt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Ye().getTextContent())}function Ye(){return Iu(ar())}function Iu(r){return r._nodeMap.get("root")}function Kt(r){_t();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=Xe(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?pt("root"):null:pt(t)}function Ra(r,e){return e?r.getTextContentSize():0}function Ou(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function zu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Nt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let a=$u(s);const l=en(s);if(a!==null&&X(l)){if(a===ai&&t){const u=t.length;a=t,i=u,o=u}a!==null&&Ko(l,a,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let a=e;(o||s)&&e[e.length-1]===ai&&(a=e.slice(0,-1));const l=i.getTextContent();if(s||a!==l){if(a===""){if(ct(null),oi||Vn||Fo)i.remove();else{const m=Xe();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||G(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=ce();if(!G(g)||t===null||n===null)return void i.setTextContent(a);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=ot(i.getTextContent());i.replace(m),i=m}i.setTextContent(a)}}}function mh(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(X(o)||P(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Mt?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 yh(){const r=Ye();Kt(Mu(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=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,a=e.get(i);a===void 0&&Y(33,i);const l=a.klass;let u=r.get(l);u===void 0&&(u=new Map,r.set(l,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 qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function ae(r,e,t){return fc(r,e,t)}function ci(r){return!yt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&Y(75,e),t}function Yn(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&&Y(78),e}function xh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return yt(r)||P(r)&&r.isShadowRoot()}function Jt(r){const e=Xe(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&Y(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),a=o.constructor;return i!==null?o instanceof i||Y(201,i.name,i.getType(),a.name,a.getType(),r.constructor.name,t):o instanceof r.constructor&&a!==r.constructor||Y(202,a.name,a.getType(),r.constructor.name,t),o.__key===r.__key&&Y(203,r.constructor.name,t,a.name,a.getType()),o}return r}function ji(r,e){!yt(r.getParent())||P(e)||$e(e)||Y(99)}function Mi(r){return($e(r)||P(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function bh(r,e,t){let n=r._blockCursorElement;if(G(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let a=!1,l=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(a=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(a=!0,l=r.getElementByKey(u.__key))}}if(a){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=Rs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(l===null?u.appendChild(n):u.insertBefore(n,l))}}n!==null&&Qo(n,r,e)}function Nt(r){return $t?(r||window).getSelection():null}function vh(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($e(r)&&!r.isInline())return!0;if(!P(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||X(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 _h(){return Xe()}const $a=new WeakMap,wh=new Map;function Ch(r){if(!r._readOnly&&r.isEmpty())return wh;r._readOnly||Y(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 Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function Sh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const a=o.__key;o.__parent===e&&(P(o)&&Uu(o,a,t,n,s,i),t.has(a)||i.delete(a),s.push(a)),o=o.getNextSibling()}}let yr,xt,In,fi,Xi,Zi,jr,Ot,eo,On,at="",mt="",Ut=null,Rt="",rr="",Wu=!1,zn=!1,_s=null;function zs(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(Ot.has(r)||xt._keyToDOMMap.delete(r),P(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(On,In,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 _r(r,e){r.setProperty("text-align",e)}const kh="40px";function Hu(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")||kh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===Oo?_r(t,"right"):e===zo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=Ot.get(r);t===void 0&&Y(60);const n=t.createDOM(yr,xt);if(function(s,i,o){const a=o._keyToDOMMap;(function(l,u,c){l[`__lexicalKey_${u._key}`]=c})(i,o,s),a.set(s,i)}(r,n,xt),X(t)?n.setAttribute("data-lexical-text","true"):$e(t)&&n.setAttribute("data-lexical-decorator","true"),P(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const a=i-1;(function(l,u,c,d){const f=mt;mt="",ro(l,c,0,u,c.getDOMSlot(d)),Ku(c,d),mt=f})(qs(t,Ot),a,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(at+=sr,rr+=sr)}else{const s=t.getTextContent();if($e(t)){const i=t.decorate(xt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else X(t)&&(t.isDirectionless()||(mt+=s));at+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(On,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=at;at="";let o=t;for(;o<=n;++o){$s(r[o],s);const a=Ot.get(r[o]);a!==null&&X(a)&&(Ut===null&&(Ut=a.getFormat()),Rt===""&&(Rt=a.getStyle()))}ci(e)&&(at+=sr),s.element.__lexicalTextContent=at,at=i+at}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":$e(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,Ot);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==mt||n!==_s){const i=mt==="",o=i?_s:(s=mt,eh.test(s)?"rtl":th.test(s)?"ltr":null);if(o!==n){const a=e.classList,l=yr.theme;let u=n!==null?l[n]:void 0,c=o!==null?l[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=l[n]=d}a.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=l[o]=d}c!==void 0&&a.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=mt,e.__lexicalDir=o}var s}function Eh(r,e,t){const n=mt;var s;mt="",Ut=null,Rt="",function(i,o,a){const l=at,u=i.__size,c=o.__size;at="";const d=a.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)_n(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=Ot.get(p);X(g)&&(Ut===null&&(Ut=g.getFormat()),Rt===""&&(Rt=g.getStyle()))}else{const f=qs(i,jr),p=qs(o,Ot);if(f.length!==u&&Y(227),p.length!==c&&Y(228),u===0)c!==0&&ro(p,o,0,c-1,a);else if(c===0){if(u!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;to(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,b,_){const S=v-1,D=b-1;let k,w,E=_.getFirstChild(),M=0,N=0;for(;M<=S&&N<=D;){const R=m[M],C=x[N];if(R===C)E=Ri(_n(C,_.element)),M++,N++;else{k===void 0&&(k=new Set(m)),w===void 0&&(w=new Set(x));const F=w.has(R),I=k.has(C);if(F)if(I){const W=Is(xt,C);W===E?E=Ri(_n(C,_.element)):(_.withBefore(E).insertChild(W),_n(C,_.element)),M++,N++}else $s(C,_.withBefore(E)),N++;else E=Ri(no(R)),zs(R,_.element),M++}const j=Ot.get(C);j!==null&&X(j)&&(Ut===null&&(Ut=j.getFormat()),Rt===""&&(Rt=j.getStyle()))}const T=M>S,B=N>D;if(T&&!B){const R=x[D+1],C=R===void 0?null:xt.getElementByKey(R);ro(x,g,N,D,_.withBefore(C))}else B&&!T&&to(m,M,S,_.element)})(o,f,p,u,c,a)}ci(o)&&(at+=sr),d.__lexicalTextContent=at,at=l+at}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!zn&&(s.setTextFormat(Ut),s.setTextStyle(Rt)),function(i){tn(i)&&Rt!==""&&Rt!==i.__textStyle&&!zn&&i.setTextStyle(Rt)}(e),mt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&Y(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=Ot.get(r);t!==void 0&&n!==void 0||Y(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(xt,r);if(t===n&&!s){if(P(t)){const o=i.__lexicalTextContent;o!==void 0&&(at+=o,rr+=o);const a=i.__lexicalDirTextContent;a!==void 0&&(mt+=a)}else{const o=t.getTextContent();X(t)&&!t.isDirectionless()&&(mt+=o),rr+=o,at+=o}return i}if(t!==n&&s&&Yo(On,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&Y(62),e.replaceChild(o,i),zs(r,null),o}if(P(t)&&P(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const a=n.__format;a!==t.__format&&Vu(i,a),s&&(Eh(t,n,i),yt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(at+=sr,rr+=sr)}else{const o=n.getTextContent();if($e(n)){const a=n.decorate(xt,yr);a!==null&&Yu(r,a)}else X(n)&&!n.isDirectionless()&&(mt+=o);at+=o,rr+=o}if(!zn&&yt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=xt._pendingDecorators;const n=xt._decorators;if(t===null){if(n[r]===e)return;t=Pu(xt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===xt._blockCursorElement&&(e=e.nextSibling),e}function Dh(r,e,t,n,s,i){at="",rr="",mt="",Wu=n===Zr,_s=null,xt=t,yr=t._config,In=t._nodes,fi=xt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,Ot=e._nodeMap,zn=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return On=o,_n("root",null),xt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,Ot=void 0,yr=void 0,eo=void 0,On=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&Y(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!ae(e,jf,r)&&t!=null){if(function(a,l,u,c){return La(a)&&!l&&!c&&!u}(t,s,o,i))ae(e,mu,r);else if(function(a,l,u,c,d){return La(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ae(e,Mf,r);else if(function(a,l,u,c){return Fa(a)&&!l&&!c&&!u}(t,s,o,i))ae(e,yu,r);else if(function(a,l,u,c,d){return Fa(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ae(e,Rf,r);else if(function(a,l,u){return function(c){return c==="ArrowUp"}(a)&&!l&&!u}(t,s,i))ae(e,xu,r);else if(function(a,l,u){return function(c){return c==="ArrowDown"}(a)&&!l&&!u}(t,s,i))ae(e,bu,r);else if(function(a,l){return Pa(a)&&l}(t,n))Bn=!0,ae(e,Ns,r);else if(function(a){return a===" "}(t))ae(e,Ff,r);else if(function(a,l){return Mt&&l&&a.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,ae(e,Kr,!0);else if(function(a,l){return Pa(a)&&!l}(t,n))Bn=!1,ae(e,Ns,r);else if(function(a,l,u,c){return Mt?!l&&!u&&(fn(a)||a.toLowerCase()==="h"&&c):!(c||l||u)&&fn(a)}(t,o,i,s))fn(t)?ae(e,vu,r):(r.preventDefault(),ae(e,Er,!0));else if(function(a){return a==="Escape"}(t))ae(e,_u,r);else if(function(a,l,u,c,d){return Mt?!(u||c||d)&&(hn(a)||a.toLowerCase()==="d"&&l):!(l||c||d)&&hn(a)}(t,s,n,o,i))hn(t)?ae(e,wu,r):(r.preventDefault(),ae(e,Er,!1));else if(function(a,l,u){return fn(a)&&(Mt?l:u)}(t,o,s))r.preventDefault(),ae(e,Fn,!0);else if(function(a,l,u){return hn(a)&&(Mt?l:u)}(t,o,s))r.preventDefault(),ae(e,Fn,!1);else if(function(a,l){return Mt&&l&&fn(a)}(t,i))r.preventDefault(),ae(e,Ln,!0);else if(function(a,l){return Mt&&l&&hn(a)}(t,i))r.preventDefault(),ae(e,Ln,!1);else if(function(a,l,u,c){return a.toLowerCase()==="b"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ae(e,It,"bold");else if(function(a,l,u,c){return a.toLowerCase()==="u"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ae(e,It,"underline");else if(function(a,l,u,c){return a.toLowerCase()==="i"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ae(e,It,"italic");else if(function(a,l,u,c){return a==="Tab"&&!l&&!u&&!c}(t,o,s,i))ae(e,Lf,r);else if(function(a,l,u,c){return a.toLowerCase()==="z"&&!l&&vn(u,c)}(t,n,i,s))r.preventDefault(),ae(e,jo,void 0);else if(function(a,l,u,c){return Mt?a.toLowerCase()==="z"&&u&&l:a.toLowerCase()==="y"&&c||a.toLowerCase()==="z"&&c&&l}(t,n,i,s))r.preventDefault(),ae(e,Mo,void 0);else{const a=e._editorState._selection;a===null||G(a)?!mr&&Ia(t,i,s)&&(r.preventDefault(),ae(e,Yi,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),ae(e,ii,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),ae(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),ae(e,Yi,r))}(function(a,l,u,c){return a||l||u||c})(s,n,o,i)&&ae(e,Hf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&kt(e,()=>{$e(en(t))||(ao=!0)})}],["compositionstart",function(r,e){kt(e,()=>{const t=ce();if(G(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ct(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||X(s)&&s.getStyle()!==t.style)&&ae(e,Yr,Zf)}})}],["compositionend",function(r,e){mr?gn=!0:kt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),kt(e,()=>{const t=ce(),n=r.data,s=ec(r);if(n!=null&&G(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Nt(e._window);if(o===null)return;const a=t.isBackward(),l=a?t.anchor.offset:t.focus.offset,u=a?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&X(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,l)+n+i.getTextContent().slice(l+u)===$u(o.anchorNode)||ae(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ct(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);_t(),Bu(Xe())}),Wr=null}],["click",function(r,e){kt(e,()=>{const t=ce(),n=Nt(e._window),s=Zn();if(n){if(G(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!yt(o)&&Ye().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===Gn||o===xr)&&Kt(ea(s,n,e,r))}}}ae(e,gu,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=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&kt(n,()=>{const o=ce();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!G(p))return;Kt(p.clone())}if(G(o)){const p=o.anchor.key===o.focus.key;if(a=t.timeStamp,Qu==="MediaLast"&&a<Nn+so&&n.isComposing()&&p){if(ct(null),Nn=0,setTimeout(()=>{kt(n,()=>{ct(null)})},so),G(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),X(g)||Y(142),o.style=g.getStyle()}}else{ct(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;Kf&&p&&!v&&x||ae(n,Er,!0)}return}}var a;if(!G(o))return;const l=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||yt(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":ae(n,Yr,t);break;case"insertFromComposition":ct(null),ae(n,Yr,t);break;case"insertLineBreak":ct(null),ae(n,Kr,!1);break;case"insertParagraph":ct(null),Bn&&!Vn?(Bn=!1,ae(n,Kr,!1)):ae(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":ae(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||P(p)||P(g)||!p.isToken()||!g.isToken()})(d,f)&&ae(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":ae(n,Ki,t);break;case"deleteContent":ae(n,Er,!1);break;case"deleteWordBackward":ae(n,Fn,!0);break;case"deleteWordForward":ae(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":ae(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":ae(n,Ln,!1);break;case"formatStrikeThrough":ae(n,It,"strikethrough");break;case"formatBold":ae(n,It,"bold");break;case"formatItalic":ae(n,It,"italic");break;case"formatUnderline":ae(n,It,"underline");break;case"historyUndo":ae(n,jo,void 0);break;case"historyRedo":ae(n,Mo,void 0)}else{if(l===`
|
|
86
|
-
`)t.preventDefault(),
|
|
87
|
-
`){const n=
|
|
88
|
-
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&
|
|
89
|
-
`||
|
|
90
|
-
`?s.push(Mr()):
|
|
91
|
-
`),c=!f.isEmpty();else if(c=!1,
|
|
85
|
+
`,Zf=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",eh=new RegExp("^[^"+Tu+"]*["+Au+"]"),th=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},rh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},nh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},sh={normal:0,segmented:2,token:1},ih={[Yf]:"normal",[Jf]:"segmented",[Qf]:"token"};function oh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var X=oh(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 Rs(...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 ah=100;let Qi=!1,Uo=0;function lh(r){Uo=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 uh(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function ch(r,e,t){if(Y(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function dh(r,e,t,n){for(let s=r;s&&!Sh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=ht(i,t);if(o)return Ue(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>ah;try{Et(r,()=>{const s=ue()||function(f){return f.getEditorState().read(()=>{const p=ue();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=dh(m,r,l,o);if(!x)continue;const[_,b]=x;if(g==="characterData")n&&te(b)&&ch(s,m,b)&&uh(m,b,r);else if(g==="childList"){u=!0;const w=p.addedNodes;for(let E=0;E<w.length;E++){const v=w[E],k=Lu(v),M=v.parentNode;if(M!=null&&v!==a&&k===null&&!Bi(v,M,r)){if(mr){const N=v.innerText||v.nodeValue;N&&(c+=N)}M.removeChild(v)}}const S=p.removedNodes,D=S.length;if(D>0){let E=0;for(let v=0;v<D;v++){const k=S[v];(Bi(k,m,r)||a===k)&&(m.appendChild(k),E++)}D!==E&&i.set(_,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 _=g[x],b=_.parentNode;b==null||_.nodeName!=="BR"||Bi(_,m,r)||b.removeChild(_)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",lh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(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=et()._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&&te(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&&te(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(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),te(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 fh=1;const hh=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Ue(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function ph(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(ph(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 te(r)||Ar(r)||Ue(r)}function gh(r,e){if(e!=null)return void(r.__key=e);wt(),uc();const t=et(),n=ar(),s=""+fh++;n._nodeMap.set(s,r),P(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,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){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=et(),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=Du,P(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function ct(r){wt();const e=et(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=ht(t);n!==null&&n.getWritable()}if(r!==null){const n=ht(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:et()._compositionKey}function ht(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,et());return t!==void 0?ht(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Je().getTextContent())}function Je(){return Iu(ar())}function Iu(r){return r._nodeMap.get("root")}function Kt(r){wt();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=et(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?ht("root"):null:ht(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(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 $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=$u(s);const a=en(s);if(l!==null&&te(a)){if(l===ai&&t){const u=t.length;l=t,i=u,o=u}l!==null&&Ko(a,l,i,o,r)}}}function Ko(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(ct(null),oi||Vn||Fo)i.remove();else{const m=et();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||Y(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=ue();if(!Y(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=ot(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function mh(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(te(o)||P(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Mt?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 yh(){const r=Je();Kt(Mu(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=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,l=e.get(i);l===void 0&&X(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 za(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 za(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?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function oe(r,e,t){return fc(r,e,t)}function ci(r){return!mt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&X(75,e),t}function Yn(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&&X(78),e}function xh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return mt(r)||P(r)&&r.isShadowRoot()}function Jt(r){const e=et(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&X(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||X(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||X(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&X(203,r.constructor.name,t,l.name,l.getType()),o}return r}function ji(r,e){!mt(r.getParent())||P(e)||Ue(e)||X(99)}function Mi(r){return(Ue(r)||P(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function bh(r,e,t){let n=r._blockCursorElement;if(Y(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=Rs(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&&Qo(n,r,e)}function Bt(r){return $t?(r||window).getSelection():null}function vh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Oa(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 zs(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(Ue(r)&&!r.isInline())return!0;if(!P(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||te(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 _h(){return et()}const $a=new WeakMap,wh=new Map;function Ch(r){if(!r._readOnly&&r.isEmpty())return wh;r._readOnly||X(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 Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function Sh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(P(o)&&Uu(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,yt,In,fi,Xi,Zi,jr,zt,eo,zn,at="",gt="",Ut=null,Rt="",rr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(zt.has(r)||yt._keyToDOMMap.delete(r),P(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const kh="40px";function Hu(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")||kh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=zt.get(r);t===void 0&&X(60);const n=t.createDOM(yr,yt);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,yt),te(t)?n.setAttribute("data-lexical-text","true"):Ue(t)&&n.setAttribute("data-lexical-decorator","true"),P(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=gt;gt="",ro(a,c,0,u,c.getDOMSlot(d)),Ku(c,d),gt=f})(qs(t,zt),l,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(at+=sr,rr+=sr)}else{const s=t.getTextContent();if(Ue(t)){const i=t.decorate(yt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else te(t)&&(t.isDirectionless()||(gt+=s));at+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=at;at="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=zt.get(r[o]);l!==null&&te(l)&&(Ut===null&&(Ut=l.getFormat()),Rt===""&&(Rt=l.getStyle()))}ci(e)&&(at+=sr),s.element.__lexicalTextContent=at,at=i+at}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Ue(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,zt);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==gt||n!==_s){const i=gt==="",o=i?_s:(s=gt,eh.test(s)?"rtl":th.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=Rs(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=Rs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=gt,e.__lexicalDir=o}var s}function Eh(r,e,t){const n=gt;var s;gt="",Ut=null,Rt="",function(i,o,l){const a=at,u=i.__size,c=o.__size;at="";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=no(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(_){if(typeof _=="object"&&_!=null){const b=`${_.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(b)}throw _}Os(f,null)}const g=zt.get(p);te(g)&&(Ut===null&&(Ut=g.getFormat()),Rt===""&&(Rt=g.getStyle()))}else{const f=qs(i,jr),p=qs(o,zt);if(f.length!==u&&X(227),p.length!==c&&X(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,_,b,w){const S=_-1,D=b-1;let E,v,k=w.getFirstChild(),M=0,N=0;for(;M<=S&&N<=D;){const R=m[M],C=x[N];if(R===C)k=Ri(_n(C,w.element)),M++,N++;else{E===void 0&&(E=new Set(m)),v===void 0&&(v=new Set(x));const F=v.has(R),I=E.has(C);if(F)if(I){const q=Is(yt,C);q===k?k=Ri(_n(C,w.element)):(w.withBefore(k).insertChild(q),_n(C,w.element)),M++,N++}else $s(C,w.withBefore(k)),N++;else k=Ri(no(R)),Os(R,w.element),M++}const j=zt.get(C);j!==null&&te(j)&&(Ut===null&&(Ut=j.getFormat()),Rt===""&&(Rt=j.getStyle()))}const T=M>S,B=N>D;if(T&&!B){const R=x[D+1],C=R===void 0?null:yt.getElementByKey(R);ro(x,g,N,D,w.withBefore(C))}else B&&!T&&to(m,M,S,w.element)})(o,f,p,u,c,l)}ci(o)&&(at+=sr),d.__lexicalTextContent=at,at=a+at}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!On&&(s.setTextFormat(Ut),s.setTextStyle(Rt)),function(i){tn(i)&&Rt!==""&&Rt!==i.__textStyle&&!On&&i.setTextStyle(Rt)}(e),gt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&X(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=zt.get(r);t!==void 0&&n!==void 0||X(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(yt,r);if(t===n&&!s){if(P(t)){const o=i.__lexicalTextContent;o!==void 0&&(at+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(gt+=l)}else{const o=t.getTextContent();te(t)&&!t.isDirectionless()&&(gt+=o),rr+=o,at+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&X(62),e.replaceChild(o,i),Os(r,null),o}if(P(t)&&P(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const l=n.__format;l!==t.__format&&Vu(i,l),s&&(Eh(t,n,i),mt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(at+=sr,rr+=sr)}else{const o=n.getTextContent();if(Ue(n)){const l=n.decorate(yt,yr);l!==null&&Yu(r,l)}else te(n)&&!n.isDirectionless()&&(gt+=o);at+=o,rr+=o}if(!On&&mt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=yt._pendingDecorators;const n=yt._decorators;if(t===null){if(n[r]===e)return;t=Pu(yt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===yt._blockCursorElement&&(e=e.nextSibling),e}function Dh(r,e,t,n,s,i){at="",rr="",gt="",Wu=n===Zr,_s=null,yt=t,yr=t._config,In=t._nodes,fi=yt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,zt=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),yt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,zt=void 0,yr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&X(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!oe(e,jf,r)&&t!=null){if(function(l,a,u,c){return La(l)&&!a&&!c&&!u}(t,s,o,i))oe(e,mu,r);else if(function(l,a,u,c,d){return La(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))oe(e,Mf,r);else if(function(l,a,u,c){return Fa(l)&&!a&&!c&&!u}(t,s,o,i))oe(e,yu,r);else if(function(l,a,u,c,d){return Fa(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))oe(e,Rf,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))oe(e,xu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))oe(e,bu,r);else if(function(l,a){return Pa(l)&&a}(t,n))Bn=!0,oe(e,Ns,r);else if(function(l){return l===" "}(t))oe(e,Ff,r);else if(function(l,a){return Mt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,oe(e,Kr,!0);else if(function(l,a){return Pa(l)&&!a}(t,n))Bn=!1,oe(e,Ns,r);else if(function(l,a,u,c){return Mt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?oe(e,vu,r):(r.preventDefault(),oe(e,Er,!0));else if(function(l){return l==="Escape"}(t))oe(e,_u,r);else if(function(l,a,u,c,d){return Mt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?oe(e,wu,r):(r.preventDefault(),oe(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!0);else if(function(l,a,u){return hn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),oe(e,Fn,!1);else if(function(l,a){return Mt&&a&&fn(l)}(t,i))r.preventDefault(),oe(e,Ln,!0);else if(function(l,a){return Mt&&a&&hn(l)}(t,i))r.preventDefault(),oe(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),oe(e,It,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))oe(e,Lf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),oe(e,jo,void 0);else if(function(l,a,u,c){return Mt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),oe(e,Mo,void 0);else{const l=e._editorState._selection;l===null||Y(l)?!mr&&Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),oe(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),oe(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&oe(e,Hf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Et(e,()=>{Ue(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Et(e,()=>{const t=ue();if(Y(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ct(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||te(s)&&s.getStyle()!==t.style)&&oe(e,Yr,Zf)}})}],["compositionend",function(r,e){mr?gn=!0:Et(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Et(e,()=>{const t=ue(),n=r.data,s=ec(r);if(n!=null&&Y(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(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()&&te(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===$u(o.anchorNode)||oe(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ct(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);wt(),Bu(et())}),Wr=null}],["click",function(r,e){Et(e,()=>{const t=ue(),n=Bt(e._window),s=Zn();if(n){if(Y(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!mt(o)&&Je().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===Gn||o===xr)&&Kt(ea(s,n,e,r))}}}oe(e,gu,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=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&Et(n,()=>{const o=ue();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!Y(p))return;Kt(p.clone())}if(Y(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Qu==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(ct(null),Nn=0,setTimeout(()=>{Et(n,()=>{ct(null)})},so),Y(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),te(g)||X(142),o.style=g.getStyle()}}else{ct(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),_=o.anchor.offset===0&&o.focus.offset===m.length;Kf&&p&&!_&&x||oe(n,Er,!0)}return}}var l;if(!Y(o))return;const a=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||mt(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":oe(n,Yr,t);break;case"insertFromComposition":ct(null),oe(n,Yr,t);break;case"insertLineBreak":ct(null),oe(n,Kr,!1);break;case"insertParagraph":ct(null),Bn&&!Vn?(Bn=!1,oe(n,Kr,!1)):oe(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":oe(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||P(p)||P(g)||!p.isToken()||!g.isToken()})(d,f)&&oe(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":oe(n,Ki,t);break;case"deleteContent":oe(n,Er,!1);break;case"deleteWordBackward":oe(n,Fn,!0);break;case"deleteWordForward":oe(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":oe(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":oe(n,Ln,!1);break;case"formatStrikeThrough":oe(n,It,"strikethrough");break;case"formatBold":oe(n,It,"bold");break;case"formatItalic":oe(n,It,"italic");break;case"formatUnderline":oe(n,It,"underline");break;case"historyUndo":oe(n,jo,void 0);break;case"historyRedo":oe(n,Mo,void 0)}else{if(a===`
|
|
86
|
+
`)t.preventDefault(),oe(n,Kr,!1);else if(a===sr)t.preventDefault(),oe(n,Rn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Zu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),oe(n,Yr,a)):Wr=a;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=et(),u=Bt(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!te(l)||(!s&&(!Bs||Ju<n+50)||l.isDirty()&&p<2||zu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==Fs(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||mh(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;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||Et(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const l=ue();if(Y(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,_=Je(),b=e.isComposing()===!1&&_.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")te(u)||X(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!b){const w=a.getNode();l.style="",w instanceof on&&w.getChildrenSize()===0?(l.format=w.getTextFormat(),l.style=w.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,_=g?d:c,b=g?c:d;let w=Xf,S=!1;for(let D=0;D<p;D++){const E=f[D],v=E.getTextContentSize();if(te(E)&&v!==0&&!(D===0&&E.__key===_&&m===v||D===p-1&&E.__key===b&&x===0)&&(S=!0,w&=E.getFormat(),w===0))break}l.format=S?w:0}}oe(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ct(null),t!==null&&e!=null){if(e===""){const n=ht(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&te(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
|
|
87
|
+
`){const n=ue();if(Y(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void oe(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=Bt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Ru(t.anchorNode);if(n===null)return;ao&&(ao=!1,Et(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==xr||Kt(ea(u,t,n,r))}));const s=Vo(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 Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Ah(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&X(162);const n=t-1;n>=0||X(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const l=Vo(o),a=l[l.length-1]._key;Qr.get(a)===o&&Qr.delete(a)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&X(198);const i=tc(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){wt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=ue();if(!Y(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(Y(i)&&e){const l=i.anchor,a=i.focus;l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(Y(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&mt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){X(64,this.name)}static clone(e){X(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,gh(this,e)}getType(){return this.__type}isInline(){X(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=ht(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||ue();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(te(this))return n;if(Y(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Ue(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:ht(e)}getParentOrThrow(){const e=this.getParent();return e===null&&X(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Yt(t))return P(e)||e===this&&Ue(e)||X(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&X(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:ht(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:ht(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&&X(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=et()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=ht(this.__key);return e===null&&X(113),e}getWritable(){wt();const e=ar(),t=et(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=ue();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){X(70)}updateDOM(e,t,n){X(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){X(72)}static importJSON(e){X(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){wt();let n=ue();n!==null&&(n=n.clone()),ji(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)||X(139),this.getChildren().forEach(m=>{l.append(m)})),Y(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,l),x.key===i&&Qa(x,l)}return hr()===i&&ct(o),l}insertAfter(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=ue();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),Y(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&&Y(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){wt(),ji(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=ue();return t&&Y(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return st()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){wt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(P(n))return n.select();if(!te(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){wt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(P(n))return n.select(0,0);if(!te(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(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&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}return!1}(e)?null:{conversion:Th,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Th(r){return{node:Mr()}}function Mr(){return Jt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(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&js;o!==void 0&&(t&Ms&&t&js?(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 sc(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){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(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 ih[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&&X(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&&X(49)),sc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&nc(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:Mh,priority:0}),b:()=>({conversion:Bh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Nh,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=ot(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)||X(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=cs(t,"b")),this.hasFormat("italic")&&(t=cs(t,"i")),this.hasFormat("strikethrough")&&(t=cs(t,"s")),this.hasFormat("underline")&&(t=cs(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"?rh[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=sh[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){wt();let n=e,s=t;const i=ue(),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(!Y(i))return ac(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||ct(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=ue();if(s&&Y(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){wt();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 _=!1;t.isSegmented()?(p=ot(d),p.__format=g,p.__style=m,p.__detail=x,_=!0):(p=t.getWritable(),p.__text=d);const b=ue(),w=[p];let S=d.length;for(let D=1;D<c;D++){const E=l[D],v=E.length,k=ot(E).getWritable();k.__format=g,k.__style=m,k.__detail=x;const M=k.__key,N=S+v;if(Y(b)){const T=b.anchor,B=b.focus;T.key===s&&T.type==="text"&&T.offset>S&&T.offset<=N&&(T.key=M,T.offset-=S,b.dirty=!0),B.key===s&&B.type==="text"&&B.offset>S&&B.offset<=N&&(B.key=M,B.offset-=S,b.dirty=!0)}i===s&&ct(M),S=N,w.push(k)}if(f!==null){(function(v){const k=v.getPreviousSibling(),M=v.getNextSibling();k!==null&&Ps(k),M!==null&&Ps(M)})(this);const D=f.getWritable(),E=this.getIndexWithinParent();_?(D.splice(E,0,w),this.remove()):D.splice(E,1,w),Y(b)&&Ws(b,f,E,c-1)}return w}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||X(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&ct(n);const l=ue();if(Y(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 Nh(r){return{forChild:Zo(r.style),node:null}}function Bh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function jh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Mh(r){const e=r;r.parentElement===null&&X(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&&!jh(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
|
+
`||l===`\r
|
|
90
|
+
`?s.push(Mr()):l===" "?s.push(Xn()):l!==""&&s.push(ot(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:ot(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===Gn){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 Rh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Rh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function ot(r=""){return Jt(new sn(r))}function te(r){return r instanceof sn}function Zo(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=>(te(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=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){X(126)}setDetail(e){X(127)}setMode(e){X(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Jt(new Jn)}function Fh(r){return r instanceof Jn}class Lh{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=ht(this.key);return e===null&&X(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,es()||(hr()===i&&ct(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Lh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(te(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!P(e)){const i=e.getNextSibling();if(te(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)||te(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(!Wt(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(te(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=ht(s);i!==null&&n.push(i)}return es()||(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 Y(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!!Y(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),es()||(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,te(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!Ue(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=et(),n=t.getEditorState()._selection,s=oc(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(Qt(e.key,e.offset,e.type),Qt(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(Mr()):o===" "?n.push(Xn()):n.push(ot(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,a=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,a=t),o.type==="element"&&function(x,v,b,_){const S=x.getNode(),D=S.getChildAtIndex(x.offset),k=ot(),w=yt(S)?st().append(k):k;k.setFormat(b),k.setStyle(_),D===null?S.append(w):D.insertBefore(w),x.is(v)&&v.set(k.__key,0,"text"),x.set(k.__key,0,"text")}(o,a,s,i);const l=o.offset;let u=a.offset;const c=this.getNodes(),d=c.length;let f=c[0];X(f)||Y(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&a.type==="element"&&(u=p,a.set(o.key,u,"text")),this.isCollapsed()&&l===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(X(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=ot(),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()&&l===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(X(x)&&!Cr(x)||(x=ot(),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()&&l!==p){const x=ot(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(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const _=ot(e);return _.select(),void f.replace(_)}const x=f.getFormat(),v=f.getStyle();if(l!==u||x===s&&v===i){if(Fh(f)){const _=ot(e);return _.setFormat(s),_.setStyle(i),_.select(),void f.replace(_)}}else{if(f.getTextContent()!==""){const _=ot(e);if(_.setFormat(s),_.setStyle(i),_.select(),l===0)f.insertBefore(_,!1);else{const[S]=f.splitText(l);S.insertAfter(_,!1)}return void(_.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const b=u-l;f=f.spliceText(l,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(),_=m;if(!v.is(b)&&b.isInline())do _=b,b=b.getParentOrThrow();while(b.isInline());if(a.type==="text"&&(u!==0||m.getTextContent()==="")||a.type==="element"&&m.getIndexWithinParent()<u)if(X(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const E=ot(m.getTextContent());m.replace(E),m=E}yt(a.getNode())||a.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=b.getChildren(),D=new Set(c),k=v.is(b),w=v.isInline()&&f.getNextSibling()===null?v:f;for(let E=S.length-1;E>=0;E--){const M=S[E];if(M.is(f)||P(M)&&M.isParentOf(f))break;M.isAttached()&&(!D.has(M)||M.is(_)?k||w.insertAfter(M,!1):M.remove())}if(!k){let E=b,M=null;for(;E!==null;){const N=E.getChildren(),T=N.length;(T===0||N[T-1].is(M))&&(x.delete(E.__key),M=E),E=E.getParent()}}if(f.isToken())if(l===p)f.select();else{const E=ot(e);E.select(),f.replace(E)}else f=f.spliceText(l,p-l,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 M=c[E],N=M.__key;x.has(N)||M.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(),a=i.getNode();const l=pn(o,cr),u=pn(a,cr);X(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&X(a)&&a.isToken()&&(i.offset=a.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(a,d)||d.getKey()===o.getKey()||d.getKey()===a.getKey()||d.remove()});const c=(d,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=ot(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===a&&X(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(X(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}X(a)&&(a.spliceText(0,i.offset,""),a=c(a,i.offset)||a),o.isAttached()&&X(o)?o.selectEnd():a.isAttached()&&X(a)&&a.selectStart(),P(l)&&P(u)&&l!==u&&(l.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 ct(null);const n=this.getNodes(),s=[];for(const S of n)X(S)&&s.push(S);const i=S=>{n.forEach(D=>{if(tn(D)){const k=D.getFormatFlags(e,S);D.setTextFormat(k)}})},o=s.length;if(o===0)return this.toggleFormat(e),ct(null),void i(t);const a=this.anchor,l=this.focus,u=this.isBackward(),c=u?l:a,d=u?a:l;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 _=v.getFormatFlags(e,m);b>0&&(b===v.getTextContentSize()||Cr(v)||([v]=v.splitText(b)),v.setFormat(_));for(let S=f+1;S<x;S++){const D=s[S],k=D.getFormatFlags(e,_);D.setFormat(k)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,b,"text"),this.format=m|_}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ce();return G(g)||Y(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)||$e(g))&&!g.isInline())){P(n)||Y(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=st();let x=null;for(let v=0;v<g.length;v++){const b=g[v],_=Ar(b);if(_||$e(b)&&b.isInline()||P(b)&&b.isInline()||X(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),_))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),a=i.getChildren(),l=!P(n)||!n.isEmpty()?this.insertParagraph():null,u=a[a.length-1];let c=a[0];var d;P(d=c)&&cr(d)&&!d.isEmpty()&&P(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(P(n)||Y(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=a[1]),c&&(n===null&&Y(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let b=m;const _=[m];for(;b!==v;)b.getNextSibling()||Y(140),b=b.getNextSibling(),_.push(b);let S=g;for(const D of _)S=S.insertAfter(D)}(n,c));const f=pn(o,cr);l&&P(f)&&(l.canMergeWhenEmpty()||cr(u))&&(f.append(...l.getChildren()),l.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=st();return Ye().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Oi(this),t=pn(this.anchor.getNode(),cr);P(t)||Y(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],a=e[n];const[l,u]=uo(this);if(t===0)return[];if(t===1){if(X(o)&&!this.isCollapsed()){const d=l>u?u:l,f=l>u?l: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(X(o)){const d=c?l:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(X(a)){const d=a.getTextContent().length,f=c?u:l;f===0?e.pop():f!==d&&([a]=a.splitText(f),e[n]=a)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",a=Pn(s,t);if($e(a)&&!a.isIsolated()){if(o&&a.isKeyboardSelectable()){const p=tl();return p.add(a.__key),void Kt(p)}const f=t?a.getPreviousSibling():a.getNextSibling();if(X(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=a.getParentOrThrow();let g,m;return P(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=a.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const l=Xe(),u=Nt(l._window);if(!u)return;const c=l._blockCursorElement,d=l._rootElement;if(d===null||c===null||!P(a)||a.isInline()||a.canBeEmpty()||Qo(c,l,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=yt(p)?p:xh(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 _=m[b];Tn(_,g)?x.push(_):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 _=b.focus,S=b.anchor,D=S.key,k=S.offset,w=S.type;dr(S,_.key,_.offset,_.type),dr(_,D,k,w),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($e(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&P(s)&&s.getChildrenSize()===0){s.remove();const a=tl();a.add(o.__key),Kt(a)}else o.remove(),Xe().dispatchCommand(Bo,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 a=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,a!==null&&a.isSegmented()){const l=i.offset,u=a.getTextContentSize();if(a.is(s)||e&&l!==u||!e&&l!==0)return void Xa(a,e,l)}else if(s!==null&&s.isSegmented()){const l=n.offset,u=s.getTextContentSize();if(s.is(a)||e&&l!==0||!e&&l!==u)return void Xa(s,e,l)}(function(l,u){const c=l.anchor,d=l.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,_=b-1;v!==_&&(Ou(f.getTextContent().slice(v,b))||(u?d.offset=_:c.offset=_))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&yt(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 Wt(r){return r instanceof pi}function Ja(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]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,a=0;for(let u=0;u<i;u++){const c=u===i-1;if(a=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(a=void 0);break}}const l=s.join("").trim();l===""?n.remove():(n.setTextContent(l),n.select(a,a))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const a=r.childNodes,l=a.length,u=n._blockCursorElement;i===l&&(o=!0,i=l-1);let c=a[i],d=!1;if(c===u)c=a[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=Hr(c),X(s))i=Ra(s,o);else{let f=Hr(r);if(f===null)return null;if(P(f)){const p=n.getElementByKey(f.getKey());p===null&&Y(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),P(f)||Y(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 _=x.getParent();return b===null||_===null||!_.canBeEmpty()||_!==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}X(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(P(f)||Y(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&$e(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(P(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return X(s)?Qt(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 a=o.getPreviousSibling();X(a)&&(r.key=a.__key,r.offset=a.getTextContent().length)}}else P(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):X(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 a=o.getNextSibling();X(a)&&(r.key=a.__key,r.offset=0)}}}function ic(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=Xe();if(i.isComposing()&&i._compositionKey!==r.key&&G(t)){const o=t.anchor,a=t.focus;dr(r,o.key,o.offset,o.type),dr(e,a.key,a.offset,a.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,G(i)?i.anchor:null,s);if(o===null)return null;const a=Za(t,n,G(i)?i.focus:null,s);if(a===null)return null;if(o.type==="element"&&a.type==="element"){const l=Hr(r),u=Hr(t);if($e(l)&&$e(u))return null}return ic(o,a,i),[o,a]}function co(r){return P(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),a=new br(Qt(r,e,s),Qt(t,n,i),0,"");return a.dirty=!0,o._selection=a,a}function Ph(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,a=o==="selectionchange",l=!Qi&&(a||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,f;if(G(r)&&!l)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,a&&G(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,G(r)?r.format:0,G(r)?r.style:"")}function ce(){return ar()._selection}function Zn(){return Xe()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),a=i.getNode();if(!e.is(o)&&!e.is(a))return;const l=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(l,c,"element"),i.set(l,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(l,Math.max(0,g+n),"element")}if(e.is(p)){const g=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(l,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 a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(X(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(P(i)){const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(X(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(P(o)){const a=o.getChildrenSize(),l=s>=a,u=l?o.getChildAtIndex(a-1):o.getChildAtIndex(s);if(X(u)){let c=0;l&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,a=null;n!==null?(i=n.__key,X(n)?(o=n.getTextContentSize(),a="text"):P(n)&&(o=n.getChildrenSize(),a="element")):s!==null&&(i=s.__key,X(s)?a="text":P(s)&&(a="element")),i!==null&&a!==null?r.set(i,o,a):(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 Ih(r,e,t,n,s,i,o){const a=n.anchorNode,l=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!G(e))return void(r!==null&&Kn(t,a,l)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),v=Is(t,m),b=f.offset,_=p.offset,S=e.format,D=e.style,k=e.isCollapsed();let w=x,E=v,M=!1;if(f.type==="text"){w=Fs(x);const j=f.getNode();M=j.getFormat()!==S||j.getStyle()!==D}else G(r)&&r.anchor.type==="text"&&(M=!0);var N,T,B,R,C;if(p.type==="text"&&(E=Fs(v)),w!==null&&E!==null&&(k&&(r===null||M||G(r)&&(r.format!==S||r.style!==D))&&(N=S,T=D,B=b,R=g,C=performance.now(),Xu=[N,T,B,R,C]),u!==b||c!==_||a!==w||l!==E||n.type==="Range"&&k||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(w,b,E,_)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const j=e instanceof br&&e.anchor.type==="element"?w.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(j!==null){let F;if(j instanceof Text){const I=document.createRange();I.selectNode(j),F=I.getBoundingClientRect()}else F=j.getBoundingClientRect();(function(I,W,q){const ne=q.ownerDocument,U=ne.defaultView;if(U===null)return;let{top:Q,bottom:H}=W,ie=0,ue=0,he=q;for(;he!==null;){const ge=he===ne.body;if(ge)ie=0,ue=di(I).innerHeight;else{const xe=he.getBoundingClientRect();ie=xe.top,ue=xe.bottom}let we=0;if(Q<ie?we=-(ie-Q):H>ue&&(we=H-ue),we!==0)if(ge)U.scrollBy(0,we);else{const xe=he.scrollTop;he.scrollTop+=we;const Z=he.scrollTop-xe;Q-=Z,H-=Z}if(ge)break;he=Yn(he)}})(t,F,i)}}oo=!0}}function lc(r){let e=ce()||Zn();e===null&&(e=Ye().selectEnd()),e.insertNodes(r)}function Oi(r){let e=r;r.isCollapsed()||e.removeText();const t=ce();G(t)&&(e=t),G(e)||Y(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=st();return Ye().append(s),s.select(),[Ye(),0]}if(X(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(Qt(r.__key,e,"element"),Qt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let lt=null,ut=null,Ct=!1,zi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return Ct||lt!==null&<._readOnly}function _t(){Ct&&Y(13)}function uc(){ws>99&&Y(14)}function ar(){return lt===null&&Y(195,cc()),lt}function Xe(){return ut===null&&Y(196,cc()),ut}function cc(){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 zh(){return ut}function il(r,e,t){const n=e.__type,s=function(a,l){const u=a._nodes.get(l);return u===void 0&&Y(30,l),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 a=0;a<o&&(i[a](e),e.isAttached());a++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(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 $h(r){return ta(r,Xe()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&Y(17,t);const s=n.klass;r.type!==s.getType()&&Y(18,s.name);const i=s.importJSON(r),o=r.children;if(P(i)&&Array.isArray(o))for(let a=0;a<o.length;a++){const l=ta(o[a],e);i.append(l)}return i}function al(r,e,t){const n=lt,s=Ct,i=ut;lt=e,Ct=!0,ut=r;try{return t()}finally{lt=n,Ct=s,ut=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,a=t._selection,l=r._dirtyType!==Nr,u=lt,c=Ct,d=ut,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&l&&p!==null){ut=r,lt=t,Ct=!1,r._updating=!0;try{const k=r._dirtyType,w=r._dirtyElements,E=r._dirtyLeaves;p.disconnect(),g=Dh(i,t,r,k,w,E)}catch(k){if(k instanceof Error&&r._onError(k),zi)throw k;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,sl),r._updating=f,lt=u,Ct=c,ut=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,b=r._updateTags,_=r._deferred;l&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(k,w){const E=k._decorators;let M=k._pendingDecorators||E;const N=w._nodeMap;let T;for(T in M)N.has(T)||(M===E&&(M=Pu(k)),delete M[T])}(r,t);const S=s?null:Nt(r._window);if(r._editable&&S!==null&&(l||a===null||a.dirty)){ut=r,lt=t;try{if(p!==null&&p.disconnect(),l||a===null||a.dirty){const k=r._blockCursorElement;k!==null&&Qo(k,r,n),Ih(o,a,r,S,b,n)}bh(r,n,a),p!==null&&p.observe(n,sl)}finally{ut=d,lt=u}}g!==null&&function(k,w,E,M,N){const T=Array.from(k._listeners.mutation),B=T.length;for(let R=0;R<B;R++){const[C,j]=T[R],F=w.get(j);F!==void 0&&C(F,{dirtyLeaves:M,prevEditorState:N,updateTags:E})}}(r,g,b,m,i),G(a)||a===null||o!==null&&o.is(a)||r.dispatchCommand(Bo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,jn("decorator",r,!0,D)),function(k,w,E){const M=Ma(w),N=Ma(E);M!==N&&jn("textcontent",k,!0,N)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:b}),function(k,w){if(k._deferred=[],w.length!==0){const E=k._updating;k._updating=!0;try{for(let M=0;M<w.length;M++)w[M]()}finally{k._updating=E}}}(r,_),function(k){const w=k._updates;if(w.length!==0){const E=w.shift();if(E){const[M,N]=E;hc(k,M,N)}}}(r)}function jn(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 fc(r,e,t){if(r._updating===!1||ut!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(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 a=o[s];if(a!==void 0){const l=Array.from(a),u=l.length;for(let c=0;c<u;c++)if(l[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 a;if(o!==void 0){if(a=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const l=r._pendingEditorState;l===null&&Y(191),l._flushSync=!0}a&&r._deferred.push(a),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const a=r._editorState;let l=r._pendingEditorState,u=!1;(l===null||l._readOnly)&&(l=r._pendingEditorState=pc(l||a),u=!0),l._flushSync=o;const c=lt,d=Ct,f=ut,p=r._updating;lt=l,Ct=!1,r._updating=!0,ut=r;try{u&&(r._headless?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=function(v){const b=v.getEditorState()._selection,_=Nt(v._window);return G(b)||b==null?ea(b,_,v,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(v,b){const _=b.getEditorState()._selection,S=v._selection;if(G(S)){const D=S.anchor,k=S.focus;let w;if(D.type==="text"&&(w=D.getNode(),w.selectionTransform(_,S)),k.type==="text"){const E=k.getNode();w!==E&&E.selectionTransform(_,S)}}}(l,r),r._dirtyType!==Nr&&(i?function(v,b){const _=b._dirtyLeaves,S=v._nodeMap;for(const D of _){const k=S.get(D);X(k)&&k.isAttached()&&k.isSimpleText()&&!k.isUnmergeable()&&Ba(k)}}(l,r):function(v,b){const _=b._dirtyLeaves,S=b._dirtyElements,D=v._nodeMap,k=hr(),w=new Map;let E=_,M=E.size,N=S,T=N.size;for(;M>0||T>0;){if(M>0){b._dirtyLeaves=new Set;for(const B of E){const R=D.get(B);X(R)&&R.isAttached()&&R.isSimpleText()&&!R.isUnmergeable()&&Ba(R),R!==void 0&&ol(R,k)&&il(b,R,w),_.add(B)}if(E=b._dirtyLeaves,M=E.size,M>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const B of N){const R=B[0],C=B[1];if(R!=="root"&&!C)continue;const j=D.get(R);j!==void 0&&ol(j,k)&&il(b,j,w),S.set(R,C)}E=b._dirtyLeaves,M=E.size,N=b._dirtyElements,T=N.size,ws++}b._dirtyLeaves=_,b._dirtyElements=S}(l,r),ll(r),function(v,b,_,S){const D=v._nodeMap,k=b._nodeMap,w=[];for(const[E]of S){const M=k.get(E);M!==void 0&&(M.isAttached()||(P(M)&&Uu(M,E,D,k,w,S),D.has(E)||S.delete(E),w.push(E)))}for(const E of w)k.delete(E);for(const E of _){const M=k.get(E);M===void 0||M.isAttached()||(D.has(E)||_.delete(E),k.delete(E))}}(a,l,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(l._flushSync=!0);const x=l._selection;if(G(x)){const v=l._nodeMap,b=x.anchor.key,_=x.focus.key;v.get(b)!==void 0&&v.get(_)!==void 0||Y(19)}else Wt(x)&&x._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=a,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{lt=c,Ct=d,ut=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}(l,r)?l._flushSync?(l._flushSync=!1,pr(r)):u&&hh(()=>{pr(r)}):(l._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function kt(r,e,t){r._updating?r._updates.push([e,t]):hc(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&&Y(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&Y(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&Y(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"&&(Vn||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 l=this.getFirstChildOffset();return[e,Math.min(l+e.getChildrenSize(),Math.max(l,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<o.length;l++){const u=i[l],c=o[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}}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&&Y(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 nh[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=Xe()._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(X(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:pt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&Y(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:pt(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&Y(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){_t();const n=ce();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const l=this.getFirstChild();if(X(l)||P(l))return l.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const l=this.getLastChild();if(X(l)||P(l))return l.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const a=this.__key;return G(n)?(n.anchor.set(a,s,"element"),n.focus.set(a,i,"element"),n.dirty=!0,n):ac(a,s,a,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||Y(226,String(e),String(t),String(i));const a=o.__key,l=[],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&&Y(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===a&&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===a&&Y(76),x.__parent=a,l.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=ce();if(G(g)){const m=new Set(u),x=new Set(l),{anchor:v,focus:b}=g;cl(v,m,x)&&Hs(v,v.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),f!==0||this.canBeEmpty()||Yt(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 ra extends hi{constructor(e){super(e)}decorate(e,t){Y(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function $e(r){return r instanceof ra}class ts extends lr{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){Y(51)}getTextContent(){const e=this.__cachedText;return!es()&&Xe()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){Y(52)}replace(e){Y(53)}insertBefore(e){Y(54)}insertAfter(e){Y(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];P(n)||$e(n)||Y(56)}return super.append(...e)}static importJSON(e){const t=Ye();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 yt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&Y(130,t.name),P(r)){const n=e.children;Array.isArray(n)||Y(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(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:gc(Ye())}))}}class sa 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:qh,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=st();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=st();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||X(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 qh(r){const e=st();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function st(){return Jt(new on)}function tn(r){return r instanceof on}const Ie=0,Vr=1,Uh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),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 Wh(r){const e=r||{},t=zh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),a=e.namespace||(s!==null?s._config.namespace:zu()),l=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...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 k=x;x=k.replace,v=k.with,b=k.withKlass||null}const _=x.getType(),S=x.transform(),D=new Set;S!==null&&D.add(S),p.set(_,{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:a,theme:n},c||console.error,function(m,x){const v=new Map,b=new Set,_=S=>{Object.keys(S).forEach(D=>{let k=v.get(D);k===void 0&&(k=[],v.set(D,k)),k.push(S[D])})};return m.forEach(S=>{const D=S.klass.importDOM;if(D==null||b.has(D))return;b.add(D);const k=D.call(S.klass);k!==null&&_(k)}),x&&_(x),v}(p,d?d.import:void 0),f);return l!==void 0&&(g._pendingEditorState=l,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,a){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=zu(),this._onError=i,this._htmlConversions=o,this._editable=a,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&&Y(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&&Y(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(a=>a.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&&Y(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Ch(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 l=this.registerNodeTransformToKlass(i,t);s.push(l)}var o,a;return o=this,a=e.getType(),kt(o,()=>{const l=ar();if(l.isEmpty())return;if(a==="root")return void Ye().markDirty();const u=l._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(l=>l.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return ae(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,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Ah(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(a){const l=a.ownerDocument;return l&&l.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,ju(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(a,l){const u=a.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),a.__lexicalEditor=l;const d=tc(a);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(l.isEditable()||p==="click")&&g(x,l))}:x=>{if(Va(x))return;Ha(x);const v=l.isEditable();switch(p){case"cut":return v&&ae(l,Ro,x);case"copy":return ae(l,ii,x);case"paste":return v&&ae(l,si,x);case"dragstart":return v&&ae(l,Su,x);case"dragover":return v&&ae(l,ku,x);case"dragend":return v&&ae(l,zf,x);case"focus":return v&&ae(l,Uf,x);case"blur":return v&&ae(l,Wf,x);case"drop":return v&&ae(l,Cu,x)}};a.addEventListener(p,m),d.push(()=>{a.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&Y(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(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=na(),a=lt,l=Ct,u=ut,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,lt=o,Ct=!1,ut=s;try{const g=s._nodes;ta(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,lt=a,Ct=l,ut=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){kt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),kt(this,()=>{const s=ce(),i=Ye();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=Nt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Hh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Vh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:a,html:l}=r,u=Nf(null,n),c=Wh({editable:r.editable,html:l,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=Ye();if(p.isEmpty()){const g=st();p.append(g);const m=yc?document.activeElement:null;(ce()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,ds);break}case"object":d.setEditorState(f,ds);break;case"function":d.update(()=>{Ye().isEmpty()&&f(d)},ds)}}}(c,a),[c,u]},[]);return Hh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(pu.Provider,{value:t,children:e})}const Gh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Kh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Yh(){return function(r){const[e]=zt(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Gh(()=>{const{initialValueFn:o,subscribe:a}=t,l=o();return i.current!==l&&(i.current=l,s(l)),a(u=>{i.current=u,s(u)})},[t,r]),n}(Kh)}function Qh(){return Ye().getTextContent()}function Jh(r,e=!0){if(r)return!1;let t=Qh();return e&&(t=t.trim()),t===""}function Xh(r){if(!Jh(r,!1))return!1;const e=Ye().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if($e(s))return!1;if(P(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let a=0;a<o;a++){const l=i[n];if(!X(l))return!1}}}return!0}function xc(r){return()=>Xh(r)}function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Zh(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 ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tp=ep(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 rp=new Map;function np(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 bc(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(),a=s.getNode(),l=e.is(o),u=e.is(a);if(l||u){const[c,d]=uo(r),f=o.is(a),p=e.is(i?a:o),g=e.is(i?o:a);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 sp(r){const e=r.getStyle(),t=np(e);rp.set(e,t)}function ip(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),a=Ye(),l=a.getFirstChild();return void(l?l.replace(o,!0):a.append(o))}const s=r.getNodes(),i=n!==null&&function(o,a){let l=o;for(;l!==null&&l.getParent()!==null&&!a(l);)l=l.getParentOrThrow();return a(l)?l:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const a=s[o];if(!hl(a))continue;P(a)||tp(178);const l=e();l.setFormat(a.getFormatType()),l.setIndent(a.getIndent()),a.replace(l,!0)}}function dl(r,e){const t=Pn(r.focus,e);return $e(t)&&!t.isIsolated()||P(t)&&!t.isInline()&&!t.canBeEmpty()}function op(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ap(r){const e=r.anchor.getNode();return(yt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=ap(r);op(r,e,t?!n:n,"character")}function hl(r){if($e(r)||!P(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||X(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up=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.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||cp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...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 rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function dp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function fp(r){const e=yi(r,t=>P(t)&&!t.isInline());return P(e)||up(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ye()&&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 hp(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 a=o.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[u,c,d,f,p,g]=l;r.update(()=>{const m=ce();if(G(m)){const x=m.anchor;let v=x.getNode(),b=0,_=0;if(X(v)&&u>=0&&c>=0&&(b=u,_=u+c,m.setTextNodeRange(v,b,v,_)),b===_&&d===""||(m.insertRawText(d),v=x.getNode()),X(v)){b=f,_=f+p;const S=v.getTextContentSize();b=b>S?S:b,_=_>S?S:_,m.setTextNodeRange(v,b,v,_)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(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(!Ec.has(o.nodeName)){const a=Dc(o,r,s,!1);a!==null&&(n=n.concat(a))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const a=o.getChildren();for(const l of a)o.insertBefore(l);o.remove()}}(s),n}function Sc(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=Ye().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(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=X(p)&&n!==null?bc(n,p):p,o=p}const a=P(o)?o.getChildren():[],l=r._nodes.get(o.getType());let u;u=l&&l.exportDOM!==void 0?l.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<a.length;p++){const g=a[p],m=kc(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 Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let a=null;const l=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let b=null;if(v!==void 0)for(const _ of v){const S=_(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=l?l(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(a=Array.isArray(g)?g[g.length-1]:g,a!==null){for(const[,m]of s)if(a=m(a,i),!a)break;a&&o.push(...Array.isArray(g)?g:[a])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let f=[];const p=(a==null||!Yt(a))&&(a!=null&&co(a)||n);for(let g=0;g<d.length;g++)f.push(...Dc(d[g],e,t,p,new Map(s),a));return c!=null&&(f=c(f)),Os(r)&&(f=pp(r,f,p?()=>{const g=new sa;return t.push(g),g}:st)),a==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(a)&&a.append(...f),o}function pp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const a=e[o];if(co(a))n&&!a.getFormat()&&a.setFormat(n),s.push(a);else if(i.push(a),o===e.length-1||o<e.length-1&&co(e[o+1])){const l=t();l.setFormat(n),l.append(...i),s.push(l),i=[]}}return s}function gp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=gp(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 mp(r,e=ce()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function yp(r,e=ce()){return e==null&&Vs(166),G(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(xp(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,bp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:l=>l}).createHTML(a):a}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(G(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let a=0;a<o.length;a++){const l=ce();if(G(l)){const u=o[a];u===`
|
|
93
|
+
`?n.push(Mr()):o===" "?n.push(Xn()):n.push(ot(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,_,b,w){const S=x.getNode(),D=S.getChildAtIndex(x.offset),E=ot(),v=mt(S)?st().append(E):E;E.setFormat(b),E.setStyle(w),D===null?S.append(v):D.insertBefore(v),x.is(_)&&_.set(E.__key,0,"text"),x.set(E.__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];te(f)||X(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(te(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=ot(),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(te(x)&&!Cr(x)||(x=ot(),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=ot(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(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const w=ot(e);return w.select(),void f.replace(w)}const x=f.getFormat(),_=f.getStyle();if(a!==u||x===s&&_===i){if(Fh(f)){const w=ot(e);return w.setFormat(s),w.setStyle(i),w.select(),void f.replace(w)}}else{if(f.getTextContent()!==""){const w=ot(e);if(w.setFormat(s),w.setStyle(i),w.select(),a===0)f.insertBefore(w,!1);else{const[S]=f.splitText(a);S.insertAfter(w,!1)}return void(w.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=_))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),_=P(f)?f:f.getParentOrThrow();let b=P(m)?m:m.getParentOrThrow(),w=m;if(!_.is(b)&&b.isInline())do w=b,b=b.getParentOrThrow();while(b.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(te(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const k=ot(m.getTextContent());m.replace(k),m=k}mt(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),E=_.is(b),v=_.isInline()&&f.getNextSibling()===null?_:f;for(let k=S.length-1;k>=0;k--){const M=S[k];if(M.is(f)||P(M)&&M.isParentOf(f))break;M.isAttached()&&(!D.has(M)||M.is(w)?E||v.insertAfter(M,!1):M.remove())}if(!E){let k=b,M=null;for(;k!==null;){const N=k.getChildren(),T=N.length;(T===0||N[T-1].is(M))&&(x.delete(k.__key),M=k),k=k.getParent()}}if(f.isToken())if(a===p)f.select();else{const k=ot(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 M=c[k],N=M.__key;x.has(N)||M.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);te(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&te(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=ot(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&te(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(te(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}te(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&te(o)?o.selectEnd():l.isAttached()&&te(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 ct(null);const n=this.getNodes(),s=[];for(const S of n)te(S)&&s.push(S);const i=S=>{n.forEach(D=>{if(tn(D)){const E=D.getFormatFlags(e,S);D.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ct(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 _=s[x];const b=d.type==="text"?d.offset:_.getTextContentSize();if(p.is(_)){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 w=_.getFormatFlags(e,m);b>0&&(b===_.getTextContentSize()||Cr(_)||([_]=_.splitText(b)),_.setFormat(w));for(let S=f+1;S<x;S++){const D=s[S],E=D.getFormatFlags(e,w);D.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(_.__key,b,"text"),this.format=m|w}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ue();return Y(g)||X(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=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(P(g)||Ue(g))&&!g.isInline())){P(n)||X(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=st();let x=null;for(let _=0;_<g.length;_++){const b=g[_],w=Ar(b);if(w||Ue(b)&&b.isInline()||P(b)&&b.isInline()||te(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),w))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)||X(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&X(212,t.constructor.name,t.getType()),function(g,m,x){const _=m.getParentOrThrow().getLastChild();let b=m;const w=[m];for(;b!==_;)b.getNextSibling()||X(140),b=b.getNextSibling(),w.push(b);let S=g;for(const D of w)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=st();return Je().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),cr);P(t)||X(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]=uo(this);if(t===0)return[];if(t===1){if(te(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(te(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(te(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(Ue(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=tl();return p.add(l.__key),void Kt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(te(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=et(),u=Bt(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!P(l)||l.isInline()||l.canBeEmpty()||Qo(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=mt(p)?p:xh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let _=!1;for(let b=0;b<m.length;b++){const w=m[b];Tn(w,g)?x.push(w):_=!0}if(_&&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 w=b.focus,S=b.anchor,D=S.key,E=S.offset,v=S.type;dr(S,w.key,w.offset,w.type),dr(w,D,E,v),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(Ue(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&P(s)&&s.getChildrenSize()===0){s.remove();const l=tl();l.add(o.__key),Kt(l)}else o.remove(),et().dispatchCommand(Bo,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,_=x?g:m,b=x?m:g,w=b-1;_!==w&&(zu(f.getTextContent().slice(_,b))||(u?d.offset=w:c.offset=w))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&mt(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 Wt(r){return r instanceof pi}function Ja(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]:[Ja(t),Ja(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 Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){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=Hr(c),te(s))i=Ra(s,o);else{let f=Hr(r);if(f===null)return null;if(P(f)){const p=n.getElementByKey(f.getKey());p===null&&X(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),P(f)||X(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(P(m)&&function(x,_,b){const w=x.getParent();return b===null||w===null||!w.canBeEmpty()||w!==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}te(m)?(s=m,f=null,i=Ra(m,o)):m!==f&&o&&!d&&(P(f)||X(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&Ue(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(P(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return te(s)?Qt(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();te(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"):te(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();te(l)&&(r.key=l.__key,r.offset=0)}}}function ic(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=et();if(i.isComposing()&&i._compositionKey!==r.key&&Y(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 oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,Y(i)?i.anchor:null,s);if(o===null)return null;const l=Za(t,n,Y(i)?i.focus:null,s);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=Hr(r),u=Hr(t);if(Ue(a)&&Ue(u))return null}return ic(o,l,i),[o,l]}function co(r){return P(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),l=new br(Qt(r,e,s),Qt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Ph(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(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(Y(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&Y(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,Y(r)?r.format:0,Y(r)?r.style:"")}function ue(){return ar()._selection}function Zn(){return et()._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(te(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(te(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(te(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,l=null;n!==null?(i=n.__key,te(n)?(o=n.getTextContentSize(),l="text"):P(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,te(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 Ih(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&&Wo(d))return;if(!Y(e))return void(r!==null&&Kn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),_=Is(t,m),b=f.offset,w=p.offset,S=e.format,D=e.style,E=e.isCollapsed();let v=x,k=_,M=!1;if(f.type==="text"){v=Fs(x);const j=f.getNode();M=j.getFormat()!==S||j.getStyle()!==D}else Y(r)&&r.anchor.type==="text"&&(M=!0);var N,T,B,R,C;if(p.type==="text"&&(k=Fs(_)),v!==null&&k!==null&&(E&&(r===null||M||Y(r)&&(r.format!==S||r.style!==D))&&(N=S,T=D,B=b,R=g,C=performance.now(),Xu=[N,T,B,R,C]),u!==b||c!==w||l!==v||a!==k||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(v,b,k,w)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const j=e instanceof br&&e.anchor.type==="element"?v.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(j!==null){let F;if(j instanceof Text){const I=document.createRange();I.selectNode(j),F=I.getBoundingClientRect()}else F=j.getBoundingClientRect();(function(I,q,ee){const O=ee.ownerDocument,W=O.defaultView;if(W===null)return;let{top:Z,bottom:H}=q,ie=0,fe=0,ae=ee;for(;ae!==null;){const ge=ae===O.body;if(ge)ie=0,fe=di(I).innerHeight;else{const xe=ae.getBoundingClientRect();ie=xe.top,fe=xe.bottom}let ye=0;if(Z<ie?ye=-(ie-Z):H>fe&&(ye=H-fe),ye!==0)if(ge)W.scrollBy(0,ye);else{const xe=ae.scrollTop;ae.scrollTop+=ye;const Q=ae.scrollTop-xe;Z-=Q,H-=Q}if(ge)break;ae=Yn(ae)}})(t,F,i)}}oo=!0}}function lc(r){let e=ue()||Zn();e===null&&(e=Je().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=ue();Y(t)&&(e=t),Y(e)||X(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=zh(s,i);return i}function zh(r,e){const t=r.getParent();if(!t){const s=st();return Je().append(s),s.select(),[Je(),0]}if(te(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(Qt(r.__key,e,"element"),Qt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let lt=null,ut=null,St=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return St||lt!==null&<._readOnly}function wt(){St&&X(13)}function uc(){ws>99&&X(14)}function ar(){return lt===null&&X(195,cc()),lt}function et(){return ut===null&&X(196,cc()),ut}function cc(){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 Oh(){return ut}function il(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&X(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 dc(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 $h(r){return ta(r,et()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&X(17,t);const s=n.klass;r.type!==s.getType()&&X(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=ta(o[l],e);i.append(a)}return i}function al(r,e,t){const n=lt,s=St,i=ut;lt=e,St=!0,ut=r;try{return t()}finally{lt=n,St=s,ut=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=lt,c=St,d=ut,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){ut=r,lt=t,St=!1,r._updating=!0;try{const E=r._dirtyType,v=r._dirtyElements,k=r._dirtyLeaves;p.disconnect(),g=Dh(i,t,r,E,v,k)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,pr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=f,lt=u,St=c,ut=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,_=r._normalizedNodes,b=r._updateTags,w=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(E,v){const k=E._decorators;let M=E._pendingDecorators||k;const N=v._nodeMap;let T;for(T in M)N.has(T)||(M===k&&(M=Pu(E)),delete M[T])}(r,t);const S=s?null:Bt(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){ut=r,lt=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),Ih(o,l,r,S,b,n)}bh(r,n,l),p!==null&&p.observe(n,sl)}finally{ut=d,lt=u}}g!==null&&function(E,v,k,M,N){const T=Array.from(E._listeners.mutation),B=T.length;for(let R=0;R<B;R++){const[C,j]=T[R],F=v.get(j);F!==void 0&&C(F,{dirtyLeaves:M,prevEditorState:N,updateTags:k})}}(r,g,b,m,i),Y(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Bo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,jn("decorator",r,!0,D)),function(E,v,k){const M=Ma(v),N=Ma(k);M!==N&&jn("textcontent",E,!0,N)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:_,prevEditorState:e||i,tags:b}),function(E,v){if(E._deferred=[],v.length!==0){const k=E._updating;E._updating=!0;try{for(let M=0;M<v.length;M++)v[M]()}finally{E._updating=k}}}(r,w),function(E){const v=E._updates;if(v.length!==0){const k=v.shift();if(k){const[M,N]=k;hc(E,M,N)}}}(r)}function jn(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 fc(r,e,t){if(r._updating===!1||ut!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(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&&X(191),a._flushSync=!0}l&&r._deferred.push(l),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(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=pc(a||l),u=!0),a._flushSync=o;const c=lt,d=St,f=ut,p=r._updating;lt=a,St=!1,r._updating=!0,ut=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(_){const b=_.getEditorState()._selection,w=Bt(_._window);return Y(b)||b==null?ea(b,w,_,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(_,b){const w=b.getEditorState()._selection,S=_._selection;if(Y(S)){const D=S.anchor,E=S.focus;let v;if(D.type==="text"&&(v=D.getNode(),v.selectionTransform(w,S)),E.type==="text"){const k=E.getNode();v!==k&&k.selectionTransform(w,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(_,b){const w=b._dirtyLeaves,S=_._nodeMap;for(const D of w){const E=S.get(D);te(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(a,r):function(_,b){const w=b._dirtyLeaves,S=b._dirtyElements,D=_._nodeMap,E=hr(),v=new Map;let k=w,M=k.size,N=S,T=N.size;for(;M>0||T>0;){if(M>0){b._dirtyLeaves=new Set;for(const B of k){const R=D.get(B);te(R)&&R.isAttached()&&R.isSimpleText()&&!R.isUnmergeable()&&Ba(R),R!==void 0&&ol(R,E)&&il(b,R,v),w.add(B)}if(k=b._dirtyLeaves,M=k.size,M>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const B of N){const R=B[0],C=B[1];if(R!=="root"&&!C)continue;const j=D.get(R);j!==void 0&&ol(j,E)&&il(b,j,v),S.set(R,C)}k=b._dirtyLeaves,M=k.size,N=b._dirtyElements,T=N.size,ws++}b._dirtyLeaves=w,b._dirtyElements=S}(a,r),ll(r),function(_,b,w,S){const D=_._nodeMap,E=b._nodeMap,v=[];for(const[k]of S){const M=E.get(k);M!==void 0&&(M.isAttached()||(P(M)&&Uu(M,k,D,E,v,S),D.has(k)||S.delete(k),v.push(k)))}for(const k of v)E.delete(k);for(const k of w){const M=E.get(k);M===void 0||M.isAttached()||(D.has(k)||w.delete(k),E.delete(k))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(Y(x)){const _=a._nodeMap,b=x.anchor.key,w=x.focus.key;_.get(b)!==void 0&&_.get(w)!==void 0||X(19)}else Wt(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{lt=c,St=d,ut=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const _=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(_))return!0}else if(_!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&hh(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Et(r,e,t){r._updating?r._updates.push([e,t]):hc(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&&X(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&X(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&X(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"&&(Vn||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&&X(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 nh[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=et()._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(te(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:ht(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&X(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ht(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&X(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){wt();const n=ue();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(te(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(te(a)||P(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return Y(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ac(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||X(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&&X(100);const x=g.getNextSibling(),_=g.__key;Dr(g.getWritable()),u.push(_),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 _=m.__key;if(p===null)o.__first=_,x.__prev=null;else{const b=p.getWritable();b.__next=_,x.__prev=b.__key}m.__key===l&&X(76),x.__parent=l,a.push(_),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=ue();if(Y(g)){const m=new Set(u),x=new Set(a),{anchor:_,focus:b}=g;cl(_,m,x)&&Hs(_,_.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),f!==0||this.canBeEmpty()||Yt(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 ra extends hi{constructor(e){super(e)}decorate(e,t){X(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ue(r){return r instanceof ra}class ts extends lr{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){X(51)}getTextContent(){const e=this.__cachedText;return!es()&&et()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){X(52)}replace(e){X(53)}insertBefore(e){X(54)}insertAfter(e){X(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];P(n)||Ue(n)||X(56)}return super.append(...e)}static importJSON(e){const t=Je();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 mt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&X(130,t.name),P(r)){const n=e.children;Array.isArray(n)||X(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(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:gc(Je())}))}}class sa 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:qh,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=st();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=st();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||te(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 qh(r){const e=st();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function st(){return Jt(new on)}function tn(r){return r instanceof on}const ze=0,Vr=1,Uh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),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 Wh(r){const e=r||{},t=Oh(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),l=e.namespace||(s!==null?s._config.namespace:Ou()),a=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...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],_=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,_=E.with,b=E.withKlass||null}const w=x.getType(),S=x.transform(),D=new Set;S!==null&&D.add(S),p.set(w,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:_,replaceWithKlass:b,transforms:D})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const _=new Map,b=new Set,w=S=>{Object.keys(S).forEach(D=>{let E=_.get(D);E===void 0&&(E=[],_.set(D,E)),E.push(S[D])})};return m.forEach(S=>{const D=S.klass.importDOM;if(D==null||b.has(D))return;b.add(D);const E=D.call(S.klass);E!==null&&w(E)}),x&&w(x),_}(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&&X(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&&X(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&&X(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Ch(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(),Et(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void Je().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 oe(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,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Ah(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,ju(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",rc),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=tc(l);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Va(x))return;Ha(x);const _=a.isEditable();switch(p){case"cut":return _&&oe(a,Ro,x);case"copy":return oe(a,ii,x);case"paste":return _&&oe(a,si,x);case"dragstart":return _&&oe(a,Su,x);case"dragover":return _&&oe(a,ku,x);case"dragend":return _&&oe(a,Of,x);case"focus":return _&&oe(a,Uf,x);case"blur":return _&&oe(a,Wf,x);case"drop":return _&&oe(a,Cu,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;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&X(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(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=na(),l=lt,a=St,u=ut,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,lt=o,St=!1,ut=s;try{const g=s._nodes;ta(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,lt=l,St=a,ut=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){Et(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Et(this,()=>{const s=ue(),i=Je();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=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Hh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Vh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=Nf(null,n),c=Wh({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=Je();if(p.isEmpty()){const g=st();p.append(g);const m=yc?document.activeElement:null;(ue()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,ds);break}case"object":d.setEditorState(f,ds);break;case"function":d.update(()=>{Je().isEmpty()&&f(d)},ds)}}}(c,l),[c,u]},[]);return Hh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(pu.Provider,{value:t,children:e})}const Gh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Kh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Yh(){return function(r){const[e]=Ot(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Gh(()=>{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}(Kh)}function Qh(){return Je().getTextContent()}function Jh(r,e=!0){if(r)return!1;let t=Qh();return e&&(t=t.trim()),t===""}function Xh(r){if(!Jh(r,!1))return!1;const e=Je().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Ue(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(!te(a))return!1}}}return!0}function xc(r){return()=>Xh(r)}function Zh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Zh(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 ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var tp=ep(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 rp=new Map;function np(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 bc(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 sp(r){const e=r.getStyle(),t=np(e);rp.set(e,t)}function ip(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=Je(),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)||tp(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 Ue(t)&&!t.isIsolated()||P(t)&&!t.isInline()&&!t.canBeEmpty()}function op(r,e,t,n){r.modify(e?"extend":"move",t,n)}function ap(r){const e=r.anchor.getNode();return(mt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=ap(r);op(r,e,t?!n:n,"character")}function hl(r){if(Ue(r)||!P(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||te(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function lp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var up=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.`)});const vc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,cp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||cp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...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 rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function dp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function fp(r){const e=yi(r,t=>P(t)&&!t.isInline());return P(e)||up(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Je()&&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 hp(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=ue();if(Y(m)){const x=m.anchor;let _=x.getNode(),b=0,w=0;if(te(_)&&u>=0&&c>=0&&(b=u,w=u+c,m.setTextNodeRange(_,b,_,w)),b===w&&d===""||(m.insertRawText(d),_=x.getNode()),te(_)){b=f,w=f+p;const S=_.getTextContentSize();b=b>S?S:b,w=w>S?S:w,m.setTextNodeRange(_,b,_,w)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(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(!Ec.has(o.nodeName)){const l=Dc(o,r,s,!1);l!==null&&(n=n.concat(l))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&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 Sc(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=Je().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(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=te(p)&&n!==null?bc(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=kc(r,g,f,n);!s&&P(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Oa(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,_=m._htmlConversions.get(x.toLowerCase());let b=null;if(_!==void 0)for(const w of _){const S=w(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||!Yt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)f.push(...Dc(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),zs(r)&&(f=pp(r,f,p?()=>{const g=new sa;return t.push(g),g}:st)),l==null?f.length>0?o=o.concat(f):zs(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 pp(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 gp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=gp(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 mp(r,e=ue()){return e==null&&Vs(166),Y(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function yp(r,e=ue()){return e==null&&Vs(166),Y(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(xp(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,bp(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,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(Y(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=ue();if(Y(a)){const u=o[l];u===`
|
|
94
94
|
`||u===`\r
|
|
95
|
-
`?l.insertParagraph():u===" "?l.insertNodes([Xn()]):l.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(Bf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(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=X(u)&&e!==null?bc(e,u):u,o=u}const a=P(o)?o.getChildren():[],l=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),P(u)){const f=c.children;Array.isArray(f)||Vs(59,d.name)}return c}(o);if(X(o)){const u=o.__text;u.length>0?l.text=u:s=!1}for(let u=0;u<a.length;u++){const c=a[u],d=Ac(r,e,c,l.children);!s&&P(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(l);else if(Array.isArray(l.children))for(let u=0;u<l.children.length;u++){const c=l.children[u];n.push(c)}return s}function xp(r,e){const t=[],n=Ye().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function bp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=$h(n);X(s)&&sp(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((l,u)=>{r.update(()=>{l(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Nt(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 a=new Range;return a.setStart(o,0),a.setEnd(o,1),i.removeAllRanges(),i.addRange(a),new Promise((l,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),l(yl(r,d,t))),!0),Uh);qr=window.setTimeout(()=>{c(),qr=null,l(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Nt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const a=ce();if(a===null)return!1;t=_p(a)}e.preventDefault();const n=e.clipboardData;return n!==null&&(wp(n,t),!0)}const vp=[["text/html",mp],["application/x-lexical-editor",yp]];function _p(r=ce()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=_h();for(const[n,s]of vp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function wp(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,Cp=an&&"documentMode"in document?document.documentMode:null,Sp=!(!an||!("InputEvent"in window)||Cp)&&"getTargetRanges"in new window.InputEvent("input"),kp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ep=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Dp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ep,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 rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Ap,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=ia();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=st(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=st();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Jt(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];rs(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?st():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const a=st();a.select(),this.replace(a,!0)}return i}collapseAtStart(){const e=this.isEmpty()?st():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&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Ap(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Jt(new bi(r))}function fs(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=ce();if(!G(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 a=yi(i,u=>P(u)&&!u.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!t.has(l)&&(t.add(l),r(a))}return t.size>0}function hs(r){const e=en(r);return $e(e)}function Tp(r){return Pr(r.registerCommand(gu,e=>{const t=ce();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ce();return!!G(t)&&(t.deleteCharacter(e),!0)},Ie),r.registerCommand(Fn,e=>{const t=ce();return!!G(t)&&(t.deleteWord(e),!0)},Ie),r.registerCommand(Ln,e=>{const t=ce();return!!G(t)&&(t.deleteLine(e),!0)},Ie),r.registerCommand(Yr,e=>{const t=ce();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(G(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Ie),r.registerCommand(Ki,()=>{const e=ce();return!!G(e)&&(e.removeText(),!0)},Ie),r.registerCommand(It,e=>{const t=ce();return!!G(t)&&(t.formatText(e),!0)},Ie),r.registerCommand(Of,e=>{const t=ce();if(!G(t)&&!Wt(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},Ie),r.registerCommand(Kr,e=>{const t=ce();return!!G(t)&&(t.insertLineBreak(e),!0)},Ie),r.registerCommand(Rn,()=>{const e=ce();return!!G(e)&&(e.insertParagraph(),!0)},Ie),r.registerCommand(Pf,()=>(lc([Xn()]),!0),Ie),r.registerCommand(If,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),Ie),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Ie),r.registerCommand(xu,e=>{const t=ce();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(G(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Ie),r.registerCommand(bu,e=>{const t=ce();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(G(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Ye().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&$e(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Ie),r.registerCommand(yu,e=>{const t=ce();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!G(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},Ie),r.registerCommand(mu,e=>{const t=ce();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!G(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},Ie),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ce();if(!G(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!yt(s)&&fp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},Ie),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ce();return!!G(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},Ie),r.registerCommand(Ns,e=>{const t=ce();if(!G(t))return!1;if(e!==null){if((bl||kp||Dp)&&Sp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},Ie),r.registerCommand(_u,()=>{const e=ce();return!!G(e)&&(r.blur(),!0)},Ie),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,a=en(o);if(a!==null){const l=Ph();if(X(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const c=a.getParentOrThrow().getKey(),d=a.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const u=Mu(l);Kt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ce();return!!G(n)},Ie),r.registerCommand(Su,e=>{const[t]=fs(e),n=ce();return!(t&&!G(n))},Ie),r.registerCommand(ku,e=>{const[t]=fs(e),n=ce();if(t&&!G(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);$e(i)&&e.preventDefault()}return!0},Ie),r.registerCommand(Yi,()=>(yh(),!0),Ie),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),Ie),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ce();G(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),Ie),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ce()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ce(),a=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;a!=null&&o!==null&&pl(a,o,i)},{tag:"paste"})}(e,r),!0)},Ie))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Np({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[a,l]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{l(u)})}),[i]),y.useEffect(()=>{l(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(a);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(y.Suspense,{fallback:null,children:a[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,a,i])}(n,t);return function(i){fo(()=>Pr(Tp(i),hp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Bp,{content:e}),s]})}function Bp({content:r}){const[e]=zt(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function a(){const l=Cl(s);o(l)}return a(),Pr(s.registerUpdateListener(()=>{a()}),s.registerEditableListener(()=>{a()}))},[s]),i}(e),n=Yh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function jp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:b,tabIndex:_,"data-testid":S,...D},k){const[w,E]=y.useState(r.isEditable()),M=y.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),N=y.useMemo(()=>function(...T){return B=>{T.forEach(R=>{typeof R=="function"?R(B):R!=null&&(R.current=B)})}}(k,M),[M,k]);return Tc(()=>(E(r.isEditable()),r.registerEditableListener(T=>{E(T)})),[r]),h.jsx("div",{"aria-activedescendant":w?e:void 0,"aria-autocomplete":w?t:"none","aria-controls":w?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":w&&x==="combobox"?!!o:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":u,"aria-multiline":c,"aria-owns":w?d:void 0,"aria-readonly":!w||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:w,"data-testid":S,id:m,ref:N,role:w?x:void 0,spellCheck:v,style:b,tabIndex:_,...D})}const Mp=y.forwardRef(jp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Rp=y.forwardRef(Fp);function Fp(r,e){const{placeholder:t,...n}=r,[s]=zt();return h.jsxs(h.Fragment,{children:[h.jsx(Mp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Lp,{editor:s,content:t})]})}function Lp({content:r,editor:e}){const t=function(o){const[a,l]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);l(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a}(e),[n,s]=y.useState(e.isEditable());if(y.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 ps=0,ho=1,po=2,Ft=0,Pp=1,kl=2,Ip=3,Op=4;function zp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ft;const i=e._selection,o=r._selection;if(s)return Pp;if(!(G(i)&&G(o)&&o.isCollapsed()&&i.isCollapsed()))return Ft;const a=function(v,b,_){const S=v._nodeMap,D=[];for(const k of b){const w=S.get(k);w!==void 0&&D.push(w)}for(const[k,w]of _){if(!w)continue;const E=S.get(k);E===void 0||yt(E)||D.push(E)}return D}(e,t,n);if(a.length===0)return Ft;if(a.length>1){const v=e._nodeMap,b=v.get(i.anchor.key),_=v.get(o.anchor.key);return b&&_&&!r._nodeMap.has(b.__key)&&X(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Ft}const l=a[0],u=r._nodeMap.get(l.__key);if(!X(u)||!X(l)||u.__mode!==l.__mode)return Ft;const c=u.__text,d=l.__text;if(c===d)return Ft;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Ft;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Ip:x===-1&&m===g?Op:Ft}function $p(r,e){let t=Date.now(),n=Ft;return(s,i,o,a,l,u)=>{const c=Date.now();if(u.has("historic"))return n=Ft,t=c,po;const d=zp(s,i,a,l,r.isComposing()),f=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return a.size>0||l.size>0?g===!1&&d!==Ft&&d===n&&c<t+e&&p||a.size===1&&function(x,v,b){const _=v._nodeMap.get(x),S=b._nodeMap.get(x),D=v._selection,k=b._selection;return!(G(D)&&G(k)&&D.anchor.type==="element"&&D.focus.type==="element"&&k.anchor.type==="text"&&k.focus.type==="text"||!X(_)||!X(S)||_.__parent!==S.__parent)&&JSON.stringify(v.read(()=>_.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(a)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function qp(r,e,t){const n=$p(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(l.length!==0){const u=o.current,c=l.pop();u!==null&&(a.push(u),i.dispatchCommand(as,!0)),l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ie),r.registerCommand(Mo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(a.length!==0){const u=o.current;u!==null&&(l.push(u),i.dispatchCommand(ls,!0));const c=a.pop();a.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Ie),r.registerCommand($f,()=>(El(e),!1),Ie),r.registerCommand(qf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),Ie),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:a,dirtyElements:l,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,a,l,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Up(){return{current:null,redoStack:[],undoStack:[]}}function Wp({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Up(),[s]);y.useEffect(()=>qp(n,o,i),[i,n,o])}(t,e,r),null}const Hp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Vp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return Hp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:a,tags:l})=>{e&&i.size===0&&o.size===0||r&&l.has("history-merge")||a.isEmpty()||t(s,n,l)})},[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 Dl={error:null},Gp=function(r){var e,t;function n(){for(var i,o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(i=r.call.apply(r,[this].concat(a))||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,go(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 a,l;(a=(l=this.props).onError)==null||a.call(l,i,o)},s.componentDidUpdate=function(i,o){var a,l,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])}))&&((a=(l=this.props).onResetKeysChange)==null||a.call(l,i.resetKeys,f),this.reset())},s.render=function(){var i=this.state.error,o=this.props,a=o.fallbackRender,l=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof a=="function")return a(c);if(l)return ki.createElement(l,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Kp({children:r,onError:e}){return h.jsx(Gp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Yp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Yp(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 Qp(r){let e=1,t=r.getParent();for(;t!=null;){if(Je(t)){const n=t.getParent();if(Fe(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Fe(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Fe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(Je);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Fe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Vt(r){return Je(r)&&Fe(r.getFirstChild())}function Al(r){return Et().append(r)}function Bc(r,e){return Je(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ce();if(t!==null){const n=t.getNodes();if(G(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,a=o.getNode(),l=a.getParent();if(Bc(a,n)){const u=St(e);if(Yt(l)){a.replace(u);const c=Et();P(a)&&(c.setFormat(a.getFormatType()),c.setIndent(a.getIndent())),u.append(c)}else if(Je(a)){const c=a.getParentOrThrow();Rr(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()||Je(o)||s.has(o.getKey())){if(Fu(o)){let a=o.getParent();for(;a!=null;){const l=a.getKey();if(Fe(a)){if(!s.has(l)){const u=St(e);Rr(u,a.getChildren()),a.replace(u),s.add(l)}break}{const u=a.getParent();if(Yt(u)&&!s.has(l)){s.add(l),Nl(a,e);break}a=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Fe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Et();let i;if(Rr(s,r.getChildren()),Fe(t)&&e===t.getListType())t.append(s),Fe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Fe(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=St(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Jp(r){r.update(()=>{const e=ce();if(G(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const a=dp(o,Ir);a!=null&&t.add(mo(a))}}for(const i of t){let o=i;const a=Nc(i);for(const l of a){const u=st();Rr(u,l.getChildren()),o.insertAfter(u),o=u,l.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),l.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),l.remove()}i.remove()}}})}function Xp(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(Fe(i)){i.append(r);const o=n.getFirstChild();Fe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Fe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Fe(i)&&i.append(r)}else if(Fe(t)){const i=Et(),o=St(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Zp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Fe(t?t.getParent():void 0)&&Je(t)&&Fe(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=Et(),a=St(i);o.append(a),r.getPreviousSiblings().forEach(c=>a.append(c));const l=Et(),u=St(i);l.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(l),t.replace(r)}}}function eg(){const r=ce();if(!G(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Je(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Fe(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=st(),t.insertAfter(i);else{if(!Je(s))return!1;i=Et(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const a=St(n.getListType());if(tn(i))i.insertAfter(a);else{const l=Et();l.append(a),i.insertAfter(l)}o.forEach(l=>{l.remove(),a.append(l)})}return function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const u=l.getParent();if(u==null||!Je(l)&&!Fe(l))break;l=u}l.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 Fe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Fe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(Je(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Fe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tg,priority:0})}}static importJSON(e){const t=Et();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(Je(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Fe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=St(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)||Ht(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(Fe(n)||Ht(39),Je(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=St(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)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Et(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=st();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Je(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,a=e.focus,l=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(l,o.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(l,a.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 Fe(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(;Je(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ht(117),(e=Math.floor(e))>=0||Ht(199);let t=this.getIndent();for(;t!==e;)t<e?(Xp(this),t++):(Zp(this),t--);return this}canInsertAfter(e){return Je(e)}canReplaceWith(e){return Je(e)}canMergeWith(e){return tn(e)||Je(e)}extractWithChild(e,t){if(!G(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 St("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let a;if(i&&i.nested&&(a=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const l=t.getParent(),u=Fe(l)&&l.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(a!==void 0){const l=Gs(a);t.getChildren().some(u=>Fe(u))?n.push(...l):s.push(...l)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Fe(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 tg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return rg(t)}const e=r.getAttribute("aria-checked");return{node:Et(e==="true"||e!=="false"&&void 0)}}function rg(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Et(r.hasAttribute("checked"))}}function Et(r){return Jt(new Ir(void 0,r))}function Je(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[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=>{Fe(e)||Ht(163),function(t){const n=t.getNextSibling();Fe(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())Je(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Fe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=St(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(Je(n))super.append(n);else{const s=Et();if(Fe(n))s.append(n);else if(P(n))if(n.isInline())s.append(n);else{const i=ot(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Je(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],a=Qp(t)-1,l=a%o.length,u=o[l],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!==l&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);a>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function ng(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Je(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Fe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=St("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)?St("check"):St("bullet")),{after:ng,node:t}}const Fl={ol:"number",ul:"bullet"};function St(r,e=1){return Jt(new ln(r,e))}function Fe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),sg=Hn();function ig(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(sg,()=>(Jp(r),!0),Vr),r.registerCommand(Rn,()=>!!eg(),Vr))}function og(){const[r]=zt();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>ig(e),[e])}(r),null}const ag=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),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,a=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")),a!==e.__title&&(a?t.title=a:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:lg,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(!ag.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(!G(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 lg(r){let e=null;if(vh(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 Jt(new Or(r,e))}function mn(r){return r instanceof Or}class ns 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 ns(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 Jt(new ns(r,e))}function ug(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ce();if(!G(i))return;const o=i.extract();if(r===null)o.forEach(a=>{const l=yi(a,u=>!ug(u)&&mn(u));if(l){const u=l.getChildren();for(let c=0;c<u.length;c++)l.insertBefore(u[c]);l.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 a=null,l=null;o.forEach(u=>{const c=u.getParent();if(c!==l&&c!==null&&(!P(u)||u.isInline())){if(mn(c))return l=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&l.setRel(s),void(n!==void 0&&l.setTitle(n));if(c.is(a)||(a=c,l=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(l):c.insertAfter(l):u.insertBefore(l)),mn(u)){if(u.is(l))return;if(l!==null){const d=u.getChildren();for(let f=0;f<d.length;f++)l.append(d[f])}u.remove()}else l!==null&&l.append(u)}})}}function cg({validateUrl:r,attributes:e}){const[t]=zt();return y.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:a}=n;return $i(s,{...e,rel:o,target:i,title:a}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ce();if(!G(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(a=>P(a))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function dg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function fg({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 ra{constructor(t,n,s,i,o){super(o);vt(this,"__src");vt(this,"__altText");vt(this,"__width");vt(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 Rc({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:dg,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(fg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var hg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?hg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(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))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(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&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
|
|
95
|
+
`?a.insertParagraph():u===" "?a.insertNodes([Xn()]):a.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(Bf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(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=te(u)&&e!==null?bc(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()&&Vs(58,d.name),P(u)){const f=c.children;Array.isArray(f)||Vs(59,d.name)}return c}(o);if(te(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=Ac(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 xp(r,e){const t=[],n=Je().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function bp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=$h(n);te(s)&&sp(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=Bt(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),Uh);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=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const l=ue();if(l===null)return!1;t=_p(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(wp(n,t),!0)}const vp=[["text/html",mp],["application/x-lexical-editor",yp]];function _p(r=ue()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=_h();for(const[n,s]of vp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function wp(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,Cp=an&&"documentMode"in document?document.documentMode:null,Sp=!(!an||!("InputEvent"in window)||Cp)&&"getTargetRanges"in new window.InputEvent("input"),kp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ep=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Dp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Ep,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 rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Ap,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=ia();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=st(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=st();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Jt(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];rs(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?st():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=st();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?st():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&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Ap(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Jt(new bi(r))}function fs(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=ue();if(!Y(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 hs(r){const e=en(r);return Ue(e)}function Tp(r){return Pr(r.registerCommand(gu,e=>{const t=ue();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ue();return!!Y(t)&&(t.deleteCharacter(e),!0)},ze),r.registerCommand(Fn,e=>{const t=ue();return!!Y(t)&&(t.deleteWord(e),!0)},ze),r.registerCommand(Ln,e=>{const t=ue();return!!Y(t)&&(t.deleteLine(e),!0)},ze),r.registerCommand(Yr,e=>{const t=ue();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(Y(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},ze),r.registerCommand(Ki,()=>{const e=ue();return!!Y(e)&&(e.removeText(),!0)},ze),r.registerCommand(It,e=>{const t=ue();return!!Y(t)&&(t.formatText(e),!0)},ze),r.registerCommand(zf,e=>{const t=ue();if(!Y(t)&&!Wt(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},ze),r.registerCommand(Kr,e=>{const t=ue();return!!Y(t)&&(t.insertLineBreak(e),!0)},ze),r.registerCommand(Rn,()=>{const e=ue();return!!Y(e)&&(e.insertParagraph(),!0)},ze),r.registerCommand(Pf,()=>(lc([Xn()]),!0),ze),r.registerCommand(If,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),ze),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),ze),r.registerCommand(xu,e=>{const t=ue();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(Y(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Ue(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},ze),r.registerCommand(bu,e=>{const t=ue();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(Y(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Je().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Ue(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},ze),r.registerCommand(yu,e=>{const t=ue();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!Y(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},ze),r.registerCommand(mu,e=>{const t=ue();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!Y(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},ze),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ue();if(!Y(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!mt(s)&&fp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},ze),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ue();return!!Y(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},ze),r.registerCommand(Ns,e=>{const t=ue();if(!Y(t))return!1;if(e!==null){if((bl||kp||Dp)&&Sp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},ze),r.registerCommand(_u,()=>{const e=ue();return!!Y(e)&&(r.blur(),!0)},ze),r.registerCommand(Cu,e=>{const[,t]=fs(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=Ph();if(te(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=Mu(a);Kt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ue();return!!Y(n)},ze),r.registerCommand(Su,e=>{const[t]=fs(e),n=ue();return!(t&&!Y(n))},ze),r.registerCommand(ku,e=>{const[t]=fs(e),n=ue();if(t&&!Y(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Ue(i)&&e.preventDefault()}return!0},ze),r.registerCommand(Yi,()=>(yh(),!0),ze),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),ze),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ue();Y(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),ze),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ue()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ue(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&pl(l,o,i)},{tag:"paste"})}(e,r),!0)},ze))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Np({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=Ot(),s=function(i,o){const[l,a]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),y.useEffect(()=>{a(i.getDecorators())},[i]),y.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(y.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(Tp(i),hp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Bp,{content:e}),s]})}function Bp({content:r}){const[e]=Ot(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function l(){const a=Cl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Yh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function jp({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:_=!0,style:b,tabIndex:w,"data-testid":S,...D},E){const[v,k]=y.useState(r.isEditable()),M=y.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),N=y.useMemo(()=>function(...T){return B=>{T.forEach(R=>{typeof R=="function"?R(B):R!=null&&(R.current=B)})}}(E,M),[M,E]);return Tc(()=>(k(r.isEditable()),r.registerEditableListener(T=>{k(T)})),[r]),h.jsx("div",{"aria-activedescendant":v?e:void 0,"aria-autocomplete":v?t:"none","aria-controls":v?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":v&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":v?d:void 0,"aria-readonly":!v||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:v,"data-testid":S,id:m,ref:N,role:v?x:void 0,spellCheck:_,style:b,tabIndex:w,...D})}const Mp=y.forwardRef(jp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Rp=y.forwardRef(Fp);function Fp(r,e){const{placeholder:t,...n}=r,[s]=Ot();return h.jsxs(h.Fragment,{children:[h.jsx(Mp,{editor:s,...n,ref:e}),t!=null&&h.jsx(Lp,{editor:s,content:t})]})}function Lp({content:r,editor:e}){const t=function(o){const[l,a]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=y.useState(e.isEditable());if(y.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 ps=0,ho=1,po=2,Ft=0,Pp=1,kl=2,Ip=3,zp=4;function Op(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ft;const i=e._selection,o=r._selection;if(s)return Pp;if(!(Y(i)&&Y(o)&&o.isCollapsed()&&i.isCollapsed()))return Ft;const l=function(_,b,w){const S=_._nodeMap,D=[];for(const E of b){const v=S.get(E);v!==void 0&&D.push(v)}for(const[E,v]of w){if(!v)continue;const k=S.get(E);k===void 0||mt(k)||D.push(k)}return D}(e,t,n);if(l.length===0)return Ft;if(l.length>1){const _=e._nodeMap,b=_.get(i.anchor.key),w=_.get(o.anchor.key);return b&&w&&!r._nodeMap.has(b.__key)&&te(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Ft}const a=l[0],u=r._nodeMap.get(a.__key);if(!te(u)||!te(a)||u.__mode!==a.__mode)return Ft;const c=u.__text,d=a.__text;if(c===d)return Ft;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return Ft;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?Ip:x===-1&&m===g?zp:Ft}function $p(r,e){let t=Date.now(),n=Ft;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=Ft,t=c,po;const d=Op(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 ps;if(s===null)return ho;const m=i._selection;return l.size>0||a.size>0?g===!1&&d!==Ft&&d===n&&c<t+e&&p||l.size===1&&function(x,_,b){const w=_._nodeMap.get(x),S=b._nodeMap.get(x),D=_._selection,E=b._selection;return!(Y(D)&&Y(E)&&D.anchor.type==="element"&&D.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!te(w)||!te(S)||w.__parent!==S.__parent)&&JSON.stringify(_.read(()=>w.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function qp(r,e,t){const n=$p(r,t);return Pr(r.registerCommand(jo,()=>(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(as,!0)),a.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),ze),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(ls,!0));const c=l.pop();l.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),ze),r.registerCommand($f,()=>(El(e),!1),ze),r.registerCommand(qf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),ze),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(as,!1)),c!==null&&(f.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Up(){return{current:null,redoStack:[],undoStack:[]}}function Wp({delay:r,externalHistoryState:e}){const[t]=Ot();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Up(),[s]);y.useEffect(()=>qp(n,o,i),[i,n,o])}(t,e,r),null}const Hp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Vp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=Ot();return Hp(()=>{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 Dl={error:null},Gp=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,go(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 Kp({children:r,onError:e}){return h.jsx(Gp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Yp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Yp(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 Qp(r){let e=1,t=r.getParent();for(;t!=null;){if(Ze(t)){const n=t.getParent();if(Fe(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Fe(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Fe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(Ze);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Fe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Vt(r){return Ze(r)&&Fe(r.getFirstChild())}function Al(r){return Dt().append(r)}function Bc(r,e){return Ze(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ue();if(t!==null){const n=t.getNodes();if(Y(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Bc(l,n)){const u=kt(e);if(Yt(a)){l.replace(u);const c=Dt();P(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Ze(l)){const c=l.getParentOrThrow();Rr(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()||Ze(o)||s.has(o.getKey())){if(Fu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Fe(l)){if(!s.has(a)){const u=kt(e);Rr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Yt(u)&&!s.has(a)){s.add(a),Nl(l,e);break}l=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(Fe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Dt();let i;if(Rr(s,r.getChildren()),Fe(t)&&e===t.getListType())t.append(s),Fe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(Fe(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=kt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Jp(r){r.update(()=>{const e=ue();if(Y(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const l=dp(o,Ir);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Nc(i);for(const a of l){const u=st();Rr(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 Xp(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(Fe(i)){i.append(r);const o=n.getFirstChild();Fe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Fe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Fe(i)&&i.append(r)}else if(Fe(t)){const i=Dt(),o=kt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Zp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Fe(t?t.getParent():void 0)&&Ze(t)&&Fe(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=Dt(),l=kt(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=Dt(),u=kt(i);a.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function eg(){const r=ue();if(!Y(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Ze(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Fe(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=st(),t.insertAfter(i);else{if(!Ze(s))return!1;i=Dt(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=kt(n.getListType());if(tn(i))i.insertAfter(l);else{const a=Dt();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||!Ze(a)&&!Fe(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 Fe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Fe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(Ze(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Fe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:tg,priority:0})}}static importJSON(e){const t=Dt();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(Ze(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Fe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=kt(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)||Ht(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(Fe(n)||Ht(39),Ze(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=kt(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)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Dt(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=st();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Ze(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 Fe(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(;Ze(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ht(117),(e=Math.floor(e))>=0||Ht(199);let t=this.getIndent();for(;t!==e;)t<e?(Xp(this),t++):(Zp(this),t--);return this}canInsertAfter(e){return Ze(e)}canReplaceWith(e){return Ze(e)}canMergeWith(e){return tn(e)||Ze(e)}extractWithChild(e,t){if(!Y(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 kt("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=Fe(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=>Fe(u))?n.push(...a):s.push(...a)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){Fe(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 tg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return rg(t)}const e=r.getAttribute("aria-checked");return{node:Dt(e==="true"||e!=="false"&&void 0)}}function rg(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Dt(r.hasAttribute("checked"))}}function Dt(r){return Jt(new Ir(void 0,r))}function Ze(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[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=>{Fe(e)||Ht(163),function(t){const n=t.getNextSibling();Fe(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())Ze(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Fe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=kt(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(Ze(n))super.append(n);else{const s=Dt();if(Fe(n))s.append(n);else if(P(n))if(n.isInline())s.append(n);else{const i=ot(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Ze(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Qp(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&&wc(r,...s),n.length>0&&rs(r,...n)}function ng(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Ze(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Fe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=kt("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)?kt("check"):kt("bullet")),{after:ng,node:t}}const Fl={ol:"number",ul:"bullet"};function kt(r,e=1){return Jt(new ln(r,e))}function Fe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),sg=Hn();function ig(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(sg,()=>(Jp(r),!0),Vr),r.registerCommand(Rn,()=>!!eg(),Vr))}function og(){const[r]=Ot();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>ig(e),[e])}(r),null}const ag=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends lr{static getType(){return"link"}static clone(e){return new zr(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),rs(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:lg,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(!ag.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(!Y(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 lg(r){let e=null;if(vh(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 Jt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{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 ns(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 Jt(new ns(r,e))}function ug(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ue();if(!Y(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!ug(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 cg({validateUrl:r,attributes:e}){const[t]=Ot();return y.useEffect(()=>{if(!t.hasNodes([zr]))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}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ue();if(!Y(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)},Vr):()=>{})},[t,r,e]),null}function dg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function fg({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 ra{constructor(t,n,s,i,o){super(o);_t(this,"__src");_t(this,"__altText");_t(this,"__width");_t(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 Rc({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:dg,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(fg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var hg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?hg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(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))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(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&&Lc.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 Fr;(r=>{const e=class Ne{constructor(l,u,c,d){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<Ne.MIN_VERSION||l>Ne.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=l*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(l,u){const c=r.QrSegment.makeSegments(l);return Ne.encodeSegments(c,u)}static encodeBinary(l,u){const c=r.QrSegment.makeBytes(l);return Ne.encodeSegments([c],u)}static encodeSegments(l,u,c=1,d=40,f=-1,p=!0){if(!(Ne.MIN_VERSION<=c&&c<=d&&d<=Ne.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const _=Ne.getNumDataCodewords(g,u)*8,S=o.getTotalBits(l,g);if(S<=_){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const _ of[Ne.Ecc.MEDIUM,Ne.Ecc.QUARTILE,Ne.Ecc.HIGH])p&&m<=Ne.getNumDataCodewords(g,_)*8&&(u=_);let x=[];for(const _ of l){t(_.mode.modeBits,4,x),t(_.numChars,_.mode.numCharCountBits(g),x);for(const S of _.getData())x.push(S)}s(x.length==m);const v=Ne.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 _=236;x.length<v;_^=253)t(_,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((_,S)=>b[S>>>3]|=_<<7-(S&7)),new Ne(g,u,b,f)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}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 l=this.getAlignmentPatternPositions(),u=l.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(l[c],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;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 l=this.version;for(let c=0;c<12;c++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;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(l,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=l+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,f!=2&&f!=4)}}drawAlignmentPattern(l,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(l,u,c){this.modules[u][l]=c,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,c=this.errorCorrectionLevel;if(l.length!=Ne.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Ne.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=Ne.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Ne.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const v=Ne.reedSolomonComputeDivisor(f);for(let _=0,S=0;_<d;_++){let D=l.slice(S,S+m-f+(_<g?0:1));S+=D.length;const k=Ne.reedSolomonComputeRemainder(D,v);_<g&&D.push(0),x.push(D.concat(k))}let b=[];for(let _=0;_<x[0].length;_++)x.forEach((S,D)=>{(_!=m-f||D>=g)&&b.push(S[_])});return s(b.length==p),b}drawCodewords(l){if(l.length!=Math.floor(Ne.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<l.length*8&&(this.modules[m][p]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>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(l){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 l=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?l+=Ne.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ne.PENALTY_N3),p=this.modules[f][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ne.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?l+=Ne.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ne.PENALTY_N3),p=this.modules[x][f],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ne.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]&&(l+=Ne.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),l+=d*Ne.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let c=[6];for(let d=this.size-7;c.length<l;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(l){if(l<Ne.MIN_VERSION||l>Ne.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const c=Math.floor(l/7)+2;u-=(25*c-10)*c-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(Ne.getNumRawDataModules(l)/8)-Ne.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*Ne.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<l-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<l;d++){for(let f=0;f<u.length;f++)u[f]=Ne.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=Ne.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(l,u){let c=u.map(d=>0);for(const d of l){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Ne.reedSolomonMultiply(p,f))}return c}static reedSolomonMultiply(l,u){if(l>>>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)*l;return s(c>>>8==0),c}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const c=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(c&&l[0]>=u*4&&l[6]>=u?1:0)+(c&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,c){return l&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};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(a,l,u){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let c=l-1;c>=0;c--)u.push(a>>>c&1)}function n(a,l){return(a>>>l&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}const i=class Qe{constructor(l,u,c){if(this.mode=l,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(l){let u=[];for(const c of l)t(c,8,u);return new Qe(Qe.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!Qe.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<l.length;){const d=Math.min(l.length-c,3);t(parseInt(l.substring(c,c+d),10),d*3+1,u),c+=d}return new Qe(Qe.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!Qe.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=l.length;c+=2){let d=Qe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c))*45;d+=Qe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c+1)),t(d,11,u)}return c<l.length&&t(Qe.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c)),6,u),new Qe(Qe.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:Qe.isNumeric(l)?[Qe.makeNumeric(l)]:Qe.isAlphanumeric(l)?[Qe.makeAlphanumeric(l)]:[Qe.makeBytes(Qe.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)t(l,8,u);else if(l<16384)t(2,2,u),t(l,14,u);else if(l<1e6)t(6,3,u),t(l,21,u);else throw new RangeError("ECI assignment value out of range");return new Qe(Qe.Mode.ECI,0,u)}static isNumeric(l){return Qe.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return Qe.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let c=0;for(const d of l){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+d.bitData.length}return c}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let c=0;c<l.length;c++)l.charAt(c)!="%"?u.push(l.charCodeAt(c)):(u.push(parseInt(l.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})(Fr||(Fr={}));(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={}))})(Fr||(Fr={}));(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={}))})(Fr||(Fr={}));var Gr=Fr;/**
|
|
99
|
+
*/var Fr;(r=>{const e=class Te{constructor(a,u,c,d){if(this.version=a,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],a<Te.MIN_VERSION||a>Te.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 Te.encodeSegments(c,u)}static encodeBinary(a,u){const c=r.QrSegment.makeBytes(a);return Te.encodeSegments([c],u)}static encodeSegments(a,u,c=1,d=40,f=-1,p=!0){if(!(Te.MIN_VERSION<=c&&c<=d&&d<=Te.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const w=Te.getNumDataCodewords(g,u)*8,S=o.getTotalBits(a,g);if(S<=w){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const w of[Te.Ecc.MEDIUM,Te.Ecc.QUARTILE,Te.Ecc.HIGH])p&&m<=Te.getNumDataCodewords(g,w)*8&&(u=w);let x=[];for(const w of a){t(w.mode.modeBits,4,x),t(w.numChars,w.mode.numCharCountBits(g),x);for(const S of w.getData())x.push(S)}s(x.length==m);const _=Te.getNumDataCodewords(g,u)*8;s(x.length<=_),t(0,Math.min(4,_-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let w=236;x.length<_;w^=253)t(w,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((w,S)=>b[S>>>3]|=w<<7-(S&7)),new Te(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!=Te.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Te.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=Te.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Te.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const _=Te.reedSolomonComputeDivisor(f);for(let w=0,S=0;w<d;w++){let D=a.slice(S,S+m-f+(w<g?0:1));S+=D.length;const E=Te.reedSolomonComputeRemainder(D,_);w<g&&D.push(0),x.push(D.concat(E))}let b=[];for(let w=0;w<x[0].length;w++)x.forEach((S,D)=>{(w!=m-f||D>=g)&&b.push(S[w])});return s(b.length==p),b}drawCodewords(a){if(a.length!=Math.floor(Te.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+=Te.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Te.PENALTY_N3),p=this.modules[f][x],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Te.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+=Te.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Te.PENALTY_N3),p=this.modules[x][f],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Te.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+=Te.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*Te.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<Te.MIN_VERSION||a>Te.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(Te.getNumRawDataModules(a)/8)-Te.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a]*Te.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]=Te.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=Te.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]^=Te.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 Xe{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 Xe(Xe.Mode.BYTE,a.length,u)}static makeNumeric(a){if(!Xe.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 Xe(Xe.Mode.NUMERIC,a.length,u)}static makeAlphanumeric(a){if(!Xe.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=Xe.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c))*45;d+=Xe.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c+1)),t(d,11,u)}return c<a.length&&t(Xe.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c)),6,u),new Xe(Xe.Mode.ALPHANUMERIC,a.length,u)}static makeSegments(a){return a==""?[]:Xe.isNumeric(a)?[Xe.makeNumeric(a)]:Xe.isAlphanumeric(a)?[Xe.makeAlphanumeric(a)]:[Xe.makeBytes(Xe.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 Xe(Xe.Mode.ECI,0,u)}static isNumeric(a){return Xe.NUMERIC_REGEX.test(a)}static isAlphanumeric(a){return Xe.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})(Fr||(Fr={}));(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={}))})(Fr||(Fr={}));(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={}))})(Fr||(Fr={}));var Gr=Fr;/**
|
|
100
100
|
* @license qrcode.react
|
|
101
101
|
* Copyright (c) Paul O'Shannessy
|
|
102
102
|
* SPDX-License-Identifier: ISC
|
|
103
|
-
*/var pg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",
|
|
103
|
+
*/var pg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",zc="#FFFFFF",Oc="#000000",$c=!1,qc=1,gg=4,mg=0,yg=.1;function Uc(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 Wc(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 xg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*yg),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),_=Math.ceil(a+c-m);f={x:g,y:m,w:x,h:_}}const p=n.crossOrigin;return{x:u,y:c,h:a,w:l,excavation:f,opacity:d,crossOrigin:p}}function bg(r,e){return e!=null?Math.max(Math.floor(e),0):r?gg:mg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:l}){let a=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,pg[e],t,void 0,void 0,l)},[r,e,t,l]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=y.useMemo(()=>{let p=a.getModules();const g=bg(n,s),m=p.length+g*2,x=xg(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 vg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),_g=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:l=zc,fgColor:a=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,marginSize:f,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,_=xo(m,["style"]),b=p==null?void 0:p.src,w=y.useRef(null),S=y.useRef(null),D=y.useCallback(C=>{w.current=C,typeof t=="function"?t(C):t&&(t.current=C)},[t]),[E,v]=y.useState(!1),{margin:k,cells:M,numCells:N,calculatedImageSettings:T}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});y.useEffect(()=>{if(w.current!=null){const C=w.current,j=C.getContext("2d");if(!j)return;let F=M;const I=S.current,q=T!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;q&&T.excavation!=null&&(F=Wc(M,T.excavation));const ee=window.devicePixelRatio||1;C.height=C.width=i*ee;const O=i/N*ee;j.scale(O,O),j.fillStyle=l,j.fillRect(0,0,N,N),j.fillStyle=a,vg?j.fill(new Path2D(Uc(F,k))):M.forEach(function(W,Z){W.forEach(function(H,ie){H&&j.fillRect(ie+k,Z+k,1,1)})}),T&&(j.globalAlpha=T.opacity),q&&j.drawImage(I,T.x+k,T.y+k,T.w,T.h)}}),y.useEffect(()=>{v(!1)},[b]);const B=yo({height:i,width:i},x);let R=null;return b!=null&&(R=y.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{v(!0)},ref:S,crossOrigin:T==null?void 0:T.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",yo({style:B,height:i,width:i,ref:D,role:"img"},_)),R)});_g.displayName="QRCodeCanvas";var Vc=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:l=zc,fgColor:a=Oc,includeMargin:u=$c,minVersion:c=qc,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:_,numCells:b,calculatedImageSettings:w}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=_,D=null;g!=null&&w!=null&&(w.excavation!=null&&(S=Wc(_,w.excavation)),D=y.createElement("image",{href:g.src,height:w.h,width:w.w,x:w.x+x,y:w.y+x,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const E=Uc(S,x);return y.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!f&&y.createElement("title",null,f),y.createElement("path",{fill:l,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:a,d:E,shapeRendering:"crispEdges"}),D)});Vc.displayName="QRCodeSVG";function wg(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:aa({data:e,size:t})}}return null}function Cg({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 ra{constructor(t,n=150,s){super(s);_t(this,"__data");_t(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 aa({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:wg,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(Cg,{data:this.__data,size:this.__size})}getData(){return this.__data}getSize(){return this.__size}}function aa(r){return new un(r.data,r.size)}function Sg(r){return r instanceof un}const kg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},Eg={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 Dg({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:l,hasContent:a}){const[u]=Ot(),[c,d]=y.useState(!1),f=y.useRef(null),p=t||n||s,g=y.useCallback(()=>{u.dispatchCommand(It,"bold")},[u]),m=y.useCallback(()=>{u.dispatchCommand(It,"italic")},[u]),x=y.useCallback(()=>{u.dispatchCommand(It,"underline")},[u]),_=y.useCallback(()=>{u.dispatchCommand(jc,void 0)},[u]),b=y.useCallback(()=>{u.dispatchCommand(Mc,void 0)},[u]),w=y.useCallback(()=>{u.update(()=>{const v=ue();Y(v)&&ip(v,()=>ia())})},[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
|
-
`,
|
|
108
|
-
`).map(
|
|
107
|
+
`,E=()=>{setTimeout(()=>{var v;(v=f.current)!=null&&v.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:_,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:w,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:E,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:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.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:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.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:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.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 Ag({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=Ot(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Je();i.clear();const o=st();i.append(o),o.select();const a=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,a).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Tg({text:r,trigger:e}){const[t]=Ot(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=ue();if(Y(i))i.insertText(s);else{const o=Je(),l=o.getLastChild();if(l){l.selectEnd();const a=ue();Y(a)&&a.insertText(s)}else{const a=st(),u=ot(s);a.append(u),o.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Ng({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 Gc({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 _={...kg,...s},[b,w]=y.useState(!1),S=y.useRef(void 0),[D,E]=y.useState(r),[v,k]=y.useState(!1),[M,N]=y.useState(null),T=g??v,B=m??M;y.useEffect(()=>{a!==void 0&&a!==S.current&&(S.current=a,w(!0))},[a]);const R=y.useCallback(()=>{w(!1)},[]),C=W=>W.replace(/<[^>]*>/g,"").trim(),j=W=>W.split(`
|
|
108
|
+
`).map(Z=>`<p>${Z||"<br>"}</p>`).join(""),F=async W=>{const Z=C(D);if(!Z)return;const H=W==="restructure"?d:W==="proofread"?f:p;if(H){k(!0),N(W);try{const ie=await H(Z),fe=j(ie);E(fe),e==null||e(fe),S.current=Date.now(),w(!0)}catch(ie){console.error(`AI ${W} failed:`,ie)}finally{k(!1),N(null)}}},I=C(D).length>0,q={namespace:"MailEditor",theme:Eg,onError:W=>{console.error("Lexical error:",W)},nodes:[ln,Ir,zr,ns,bi,xi,vi,un],editable:!i},ee=y.useCallback((W,Z)=>{W.read(()=>{const H=Sc(Z,null);E(H),e==null||e(H)})},[e]),O=`
|
|
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: ${
|
|
130
|
+
color: ${_.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 ${
|
|
137
|
-
background: ${
|
|
138
|
-
color: ${
|
|
136
|
+
border-left: 3px solid ${_.quoteBorder};
|
|
137
|
+
background: ${_.quoteBackground};
|
|
138
|
+
color: ${_.textSecondary};
|
|
139
139
|
}
|
|
140
140
|
.mail-editor-h1 {
|
|
141
141
|
font-size: 24px;
|
|
@@ -154,11 +154,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
154
154
|
}
|
|
155
155
|
.mail-editor-content {
|
|
156
156
|
outline: none;
|
|
157
|
-
min-height: ${
|
|
157
|
+
min-height: ${l};
|
|
158
158
|
padding: 16px;
|
|
159
159
|
font-size: 14px;
|
|
160
160
|
line-height: 1.6;
|
|
161
|
-
color: ${
|
|
161
|
+
color: ${_.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: ${
|
|
170
|
+
color: ${_.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:a},children:[h.jsx("style",{children:ne}),x,h.jsxs(Vh,{initialConfig:W,children:[h.jsx(Dg,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:B,onAiAction:F,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Np,{contentEditable:h.jsx(Rp,{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:Kp})}),h.jsx(og,{}),h.jsx(cg,{}),h.jsx(Wp,{}),h.jsx(Vp,{onChange:q}),h.jsx(Ag,{html:b?D:r,isExternalUpdate:b,onImportComplete:R}),h.jsx(Tg,{text:u,trigger:c})]}),n&&h.jsx(Ng,{replyTo:n,theme:v})]})}const Bg={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 jg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:a,insertText:l,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:_,onAiRewrite:S,renderAboveToolbar:D}){const k={...Bg,...c},[w,E]=y.useState(r),[M,N]=y.useState(""),[T,B]=y.useState(""),[R,C]=y.useState(e),[j,F]=y.useState(t),[I,W]=y.useState([]),[q,ne]=y.useState(!1),[U,Q]=y.useState(""),[H,ie]=y.useState(f),[ue,he]=y.useState("message"),[ge,we]=y.useState(!1),xe=y.useRef(void 0);y.useEffect(()=>{a!==void 0&&a!==xe.current&&(xe.current=a,F(t),we(!0))},[a,t]);const Z=z=>{F(z),we(!1),o==null||o(z)},be=y.useRef(null),[te,Ae]=y.useState(!1),_e=z=>{const de=z.target.files;if(de){const Ce=Array.from(de);console.log("[MailComposer] Files selected:",Ce.map(We=>({name:We.name,size:We.size,type:We.type}))),W(We=>[...We,...Ce])}be.current&&(be.current.value="")},ve=z=>{z.preventDefault(),z.stopPropagation(),Ae(!0)},Re=z=>{z.preventDefault(),z.stopPropagation(),Ae(!1)},Le=z=>{if(z.preventDefault(),z.stopPropagation(),Ae(!1),z.dataTransfer.files&&z.dataTransfer.files.length>0){const de=Array.from(z.dataTransfer.files);console.log("[MailComposer] Files dropped:",de.map(Ce=>({name:Ce.name,size:Ce.size,type:Ce.type}))),W(Ce=>[...Ce,...de])}else console.log("[MailComposer] Drop event but no files:",z.dataTransfer.types)},qe=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",V=z=>{W(de=>de.filter((Ce,We)=>We!==z))},O=z=>z<1024?`${z} B`:z<1024*1024?`${(z/1024).toFixed(1)} KB`:`${(z/(1024*1024)).toFixed(1)} MB`,Ue=async()=>{if(!w.trim()){Q("Recipient email is required");return}if(!R.trim()){Q("Subject is required");return}ne(!0),Q("");try{const z=await Promise.all(I.map(async We=>{const dt=await We.arrayBuffer(),le=btoa(new Uint8Array(dt).reduce((pe,Ve)=>pe+String.fromCharCode(Ve),""));return{filename:We.name,content_type:We.type||"application/octet-stream",data:le,size:We.size}})),de=j.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),Ce={to:w.trim(),cc:M.trim()||void 0,bcc:T.trim()||void 0,subject:R.trim(),html:de,attachments:z,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",Ce.to,"subject:",Ce.subject,"attachmentsCount:",Ce.attachments.length),Ce.attachments.length>0&&Ce.attachments.forEach((We,dt)=>{var le;console.log(`[MailComposer] Attachment ${dt+1}:`,We.filename,"size:",We.size,"type:",We.content_type,"data length:",((le=We.data)==null?void 0:le.length)||0)}),await s(Ce),E(""),N(""),B(""),C(""),F(""),W([])}catch(z){Q(z instanceof Error?z.message:"Failed to send email")}finally{ne(!1)}},se={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none"},re={display:"block",fontSize:"12px",fontWeight:500,color:k.textSecondary,marginBottom:"4px",textTransform:"uppercase"},oe=(z,de=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:de?"not-allowed":"pointer",opacity:de?.6:1,background:z?k.buttonPrimary:k.buttonSecondary,color:z?"#ffffff":k.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:k.background},children:[U&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:U}),h.jsxs("div",{children:[h.jsx("label",{style:re,children:"To"}),h.jsx("input",{type:"email",value:w,onChange:z=>E(z.target.value),placeholder:"recipient@example.com",disabled:d||q,style:se})]}),!H&&h.jsx("button",{type:"button",onClick:()=>ie(!0),disabled:d||q,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:k.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),H&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:re,children:"CC"}),h.jsx("input",{type:"email",value:M,onChange:z=>N(z.target.value),placeholder:"cc@example.com",disabled:d||q,style:se})]}),h.jsxs("div",{children:[h.jsx("label",{style:re,children:"BCC"}),h.jsx("input",{type:"email",value:T,onChange:z=>B(z.target.value),placeholder:"bcc@example.com",disabled:d||q,style:se})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:re,children:"Subject"}),h.jsx("input",{type:"text",value:R,onChange:z=>C(z.target.value),placeholder:"Email subject",disabled:d||q,style:se})]}),h.jsx("input",{ref:be,type:"file",multiple:!0,onChange:_e,style:{display:"none"}}),h.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${k.border}`,marginBottom:"0"},children:[h.jsx("button",{type:"button",onClick:()=>he("message"),disabled:d||q,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ue==="message"?`2px solid ${k.primary}`:"2px solid transparent",color:ue==="message"?k.primary:k.textSecondary,fontWeight:ue==="message"?600:400,cursor:d||q?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),h.jsxs("button",{type:"button",onClick:()=>he("attachments"),disabled:d||q,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ue==="attachments"?`2px solid ${k.primary}`:"2px solid transparent",color:ue==="attachments"?k.primary:k.textSecondary,fontWeight:ue==="attachments"?600:400,cursor:d||q?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",I.length>0&&h.jsx("span",{style:{background:k.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:I.length})]}),ue==="message"&&h.jsx("button",{type:"button",onClick:()=>{var z;return(z=be.current)==null?void 0:z.click()},disabled:d||q,title:"Add attachment",style:{marginLeft:"auto",padding:"6px 10px",border:"none",background:"none",color:k.textSecondary,cursor:d||q?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"4px",fontSize:"13px",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})})]}),ue==="message"&&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(Gc,{value:j,onChange:Z,placeholder:p,replyTo:n,theme:k,disabled:d||q,minHeight:m,externalUpdate:ge?a:void 0,insertText:l,insertTextTrigger:u,onAiRestructure:b,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:D})})}),ue==="attachments"&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[h.jsxs("div",{onClick:()=>{var z;return(z=be.current)==null?void 0:z.click()},onDragOver:ve,onDragLeave:Re,onDrop:Le,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${te?k.primary:k.border}`,borderRadius:"8px",background:te?`${k.primary}10`:"transparent",color:te?k.primary:k.textSecondary,cursor:d||q?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:te?"file_download":"cloud_upload"}),h.jsx("span",{style:{fontSize:"14px"},children:te?"Drop files here":"Drop files or click to add"})]}),h.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:I.length>0?h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:I.map((z,de)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${k.border}`,gap:"12px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:k.textSecondary},children:qe(z)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:k.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),h.jsx("div",{style:{fontSize:"12px",color:k.textSecondary},children:O(z.size)})]}),h.jsx("button",{type:"button",onClick:()=>V(de),disabled:d||q,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:d||q?"not-allowed":"pointer",color:k.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${z.name}-${de}`))}):h.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:k.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!v&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||q,style:oe(!1,d||q),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:Ue,disabled:d||q||!w.trim()||!R.trim(),style:oe(!0,d||q||!w.trim()||!R.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:q?"spin 1s linear infinite":"none"},children:q?"sync":"send"}),q?"Sending...":x]})]}),h.jsx("style",{children:`
|
|
178
|
+
`;return h.jsxs("div",{className:o,style:{border:`1px solid ${_.border}`,borderRadius:"8px",background:_.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:O}),x,h.jsxs(Vh,{initialConfig:q,children:[h.jsx(Dg,{theme:_,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:B,onAiAction:F,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Np,{contentEditable:h.jsx(Rp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:_.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Kp})}),h.jsx(og,{}),h.jsx(cg,{}),h.jsx(Wp,{}),h.jsx(Vp,{onChange:ee}),h.jsx(Ag,{html:b?D:r,isExternalUpdate:b,onImportComplete:R}),h.jsx(Tg,{text:u,trigger:c})]}),n&&h.jsx(Ng,{replyTo:n,theme:_})]})}const Bg={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 jg({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="",hideToField:m=!1,minHeight:x="200px",hideCancelButton:_=!1,onAiRestructure:b,onAiProofread:w,onAiRewrite:S,onAiGenerate:D,renderAboveToolbar:E}){const v={...Bg,...c},[k,M]=y.useState(r),[N,T]=y.useState(""),[B,R]=y.useState(""),[C,j]=y.useState(e),[F,I]=y.useState(t),[q,ee]=y.useState([]),[O,W]=y.useState(!1),[Z,H]=y.useState(""),[ie,fe]=y.useState(f),[ae,ge]=y.useState("message"),[ye,xe]=y.useState(""),[Q,Se]=y.useState(!1),[se,Ne]=y.useState(!0),[be,ve]=y.useState(!0);y.useEffect(()=>{M(r)},[r]);const[Le,Me]=y.useState(!1),$e=y.useRef(void 0);y.useEffect(()=>{l!==void 0&&l!==$e.current&&($e.current=l,I(t),Me(!0))},[l,t]);const G=V=>{I(V),Me(!1),o==null||o(V)},z=y.useRef(null),[Pe,He]=y.useState(!1),K=V=>{const Ve=V.target.files;if(Ve){const U=Array.from(Ve);console.log("[MailComposer] Files selected:",U.map(L=>({name:L.name,size:L.size,type:L.type}))),ee(L=>[...L,...U])}z.current&&(z.current.value="")},re=V=>{V.preventDefault(),V.stopPropagation(),He(!0)},de=V=>{V.preventDefault(),V.stopPropagation(),He(!1)},_e=V=>{if(V.preventDefault(),V.stopPropagation(),He(!1),V.dataTransfer.files&&V.dataTransfer.files.length>0){const Ve=Array.from(V.dataTransfer.files);console.log("[MailComposer] Files dropped:",Ve.map(U=>({name:U.name,size:U.size,type:U.type}))),ee(U=>[...U,...Ve])}else console.log("[MailComposer] Drop event but no files:",V.dataTransfer.types)},we=V=>V.type.startsWith("image/")?"image":V.type==="application/pdf"?"picture_as_pdf":V.type.includes("spreadsheet")||V.type.includes("excel")?"table_chart":V.type.includes("document")||V.type.includes("word")?"description":"attach_file",xt=V=>{ee(Ve=>Ve.filter((U,L)=>L!==V))},bt=V=>V<1024?`${V} B`:V<1024*1024?`${(V/1024).toFixed(1)} KB`:`${(V/(1024*1024)).toFixed(1)} MB`,le=async()=>{if(!k.trim()){H("Recipient email is required");return}if(!C.trim()){H("Subject is required");return}W(!0),H("");try{const V=await Promise.all(q.map(async L=>{const ce=await L.arrayBuffer(),pe=btoa(new Uint8Array(ce).reduce((J,Ce)=>J+String.fromCharCode(Ce),""));return{filename:L.name,content_type:L.type||"application/octet-stream",data:pe,size:L.size}})),Ve=F.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),U={to:k.trim(),cc:N.trim()||void 0,bcc:B.trim()||void 0,subject:C.trim(),html:Ve,attachments:V,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",U.to,"subject:",U.subject,"attachmentsCount:",U.attachments.length),U.attachments.length>0&&U.attachments.forEach((L,ce)=>{var pe;console.log(`[MailComposer] Attachment ${ce+1}:`,L.filename,"size:",L.size,"type:",L.content_type,"data length:",((pe=L.data)==null?void 0:pe.length)||0)}),await s(U),M(""),T(""),R(""),j(""),I(""),ee([])}catch(V){H(V instanceof Error?V.message:"Failed to send email")}finally{W(!1)}},he={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${v.inputBorder}`,borderRadius:"6px",background:v.inputBackground,color:v.text,outline:"none"},We={display:"block",fontSize:"12px",fontWeight:500,color:v.textSecondary,marginBottom:"4px",textTransform:"uppercase"},Ke=(V,Ve=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:Ve?"not-allowed":"pointer",opacity:Ve?.6:1,background:V?v.buttonPrimary:v.buttonSecondary,color:V?"#ffffff":v.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:v.background},children:[Z&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:Z}),!m&&h.jsxs("div",{children:[h.jsx("label",{style:We,children:"To"}),h.jsx("input",{type:"email",value:k,onChange:V=>M(V.target.value),placeholder:"recipient@example.com",disabled:d||O,style:he})]}),!ie&&h.jsx("button",{type:"button",onClick:()=>fe(!0),disabled:d||O,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:v.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),ie&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:We,children:"CC"}),h.jsx("input",{type:"email",value:N,onChange:V=>T(V.target.value),placeholder:"cc@example.com",disabled:d||O,style:he})]}),h.jsxs("div",{children:[h.jsx("label",{style:We,children:"BCC"}),h.jsx("input",{type:"email",value:B,onChange:V=>R(V.target.value),placeholder:"bcc@example.com",disabled:d||O,style:he})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:We,children:"Subject"}),h.jsx("input",{type:"text",value:C,onChange:V=>j(V.target.value),placeholder:"Email subject",disabled:d||O,style:he})]}),h.jsx("input",{ref:z,type:"file",multiple:!0,onChange:K,style:{display:"none"}}),h.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${v.border}`,marginBottom:"0"},children:[h.jsx("button",{type:"button",onClick:()=>ge("message"),disabled:d||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ae==="message"?`2px solid ${v.primary}`:"2px solid transparent",color:ae==="message"?v.primary:v.textSecondary,fontWeight:ae==="message"?600:400,cursor:d||O?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),h.jsxs("button",{type:"button",onClick:()=>ge("attachments"),disabled:d||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ae==="attachments"?`2px solid ${v.primary}`:"2px solid transparent",color:ae==="attachments"?v.primary:v.textSecondary,fontWeight:ae==="attachments"?600:400,cursor:d||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",q.length>0&&h.jsx("span",{style:{background:v.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:q.length})]}),D&&h.jsx("button",{type:"button",onClick:()=>ge("prompt"),disabled:d||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:ae==="prompt"?`2px solid ${v.primary}`:"2px solid transparent",color:ae==="prompt"?v.primary:v.textSecondary,fontWeight:ae==="prompt"?600:400,cursor:d||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),ae==="message"&&h.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{type:"button",onClick:()=>{var V;return(V=z.current)==null?void 0:V.click()},disabled:d||O,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:v.textSecondary,cursor:d||O?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),h.jsx("button",{type:"button",onClick:le,disabled:d||O||!k.trim()||!C.trim()||!F.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:d||O||!k.trim()||!C.trim()||!F.replace(/<[^>]*>/g,"").trim()?v.textSecondary:v.primary,cursor:d||O||!k.trim()||!C.trim()||!F.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:d||O||!k.trim()||!C.trim()||!F.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:O?"spin 1s linear infinite":"none"},children:O?"sync":"send"})})]})]}),ae==="message"&&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(Gc,{value:F,onChange:G,placeholder:p,replyTo:n,theme:v,disabled:d||O,minHeight:x,externalUpdate:Le?l:void 0,insertText:a,insertTextTrigger:u,onAiRestructure:b,onAiProofread:w,onAiRewrite:S,renderAboveToolbar:E})})}),ae==="attachments"&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[h.jsxs("div",{onClick:()=>{var V;return(V=z.current)==null?void 0:V.click()},onDragOver:re,onDragLeave:de,onDrop:_e,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${Pe?v.primary:v.border}`,borderRadius:"8px",background:Pe?`${v.primary}10`:"transparent",color:Pe?v.primary:v.textSecondary,cursor:d||O?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:Pe?"file_download":"cloud_upload"}),h.jsx("span",{style:{fontSize:"14px"},children:Pe?"Drop files here":"Drop files or click to add"})]}),h.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:q.length>0?h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:q.map((V,Ve)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${v.border}`,gap:"12px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:v.textSecondary},children:we(V)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:v.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:V.name}),h.jsx("div",{style:{fontSize:"12px",color:v.textSecondary},children:bt(V.size)})]}),h.jsx("button",{type:"button",onClick:()=>xt(Ve),disabled:d||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:d||O?"not-allowed":"pointer",color:v.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${V.name}-${Ve}`))}):h.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:v.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),ae==="prompt"&&D&&h.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[h.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:v.text},children:[h.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[h.jsx("input",{type:"checkbox",checked:se,onChange:V=>Ne(V.target.checked),disabled:d||O||Q,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),h.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[h.jsx("input",{type:"checkbox",checked:be,onChange:V=>ve(V.target.checked),disabled:d||O||Q,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),h.jsx("textarea",{value:ye,onChange:V=>xe(V.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:d||O||Q,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${v.inputBorder}`,borderRadius:"6px",background:v.inputBackground,color:v.text,outline:"none",resize:"none",minHeight:"150px"}}),h.jsxs("button",{type:"button",onClick:async()=>{if(!(!ye.trim()||!D)){Se(!0);try{const V=await D(ye,{to:k,subject:C},{useNotes:se,addSignature:be});I(V),ge("message"),xe("")}catch(V){console.error("AI generation failed:",V)}finally{Se(!1)}}},disabled:d||O||Q||!ye.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:d||O||Q||!ye.trim()?"not-allowed":"pointer",opacity:d||O||Q||!ye.trim()?.6:1,background:v.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:Q?"spin 1s linear infinite":"none"},children:Q?"sync":"auto_awesome"}),Q?"Génération...":"Générer"]})]}),!_&&i&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx("button",{type:"button",onClick:i,disabled:d||O,style:Ke(!1,d||O),children:"Cancel"})}),h.jsx("style",{children:`
|
|
179
179
|
@keyframes spin {
|
|
180
180
|
from { transform: rotate(0deg); }
|
|
181
181
|
to { transform: rotate(360deg); }
|
|
182
182
|
}
|
|
183
|
-
`})]})}const Mg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Rg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:a,label:l,disabled:u=!1,max:c=0,theme:d={},className:f=""}){const p={...Mg,...d},[g,m]=y.useState(!1),[x,v]=y.useState(""),b=y.useRef(null),_=y.useRef(null);y.useEffect(()=>{function T(B){b.current&&!b.current.contains(B.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase())===x.toLowerCase()}),k=e.map(T=>r.find(B=>B.id===T)).filter(Boolean),w=y.useCallback(T=>{var B;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(B=_.current)==null||B.focus())},[e,t,c]),E=y.useCallback(T=>{t(e.filter(B=>B!==T))},[e,t]),M=y.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&w(T.id),v("")},[D,x,i,w]),N=y.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?M():S.length>0&&w(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?E(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[D,S,x,e,M,w,E]);return h.jsxs("div",{ref:b,className:f,style:{position:"relative"},children:[l&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:l}),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:[k.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:B=>{B.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:_,type:"text",value:x,onChange:T=>{v(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:N,placeholder:k.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:()=>w(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:B=>{B.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:[T.label,o&&a&&h.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),a(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:B=>{B.currentTarget.style.opacity="1",B.currentTarget.style.color="#ef4444"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.5",B.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:M,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 Fg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Lg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:a=300,className:l="",theme:u={}}){const c={...Fg,...u},[d,f]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),v=y.useMemo(()=>e&&r.find(E=>E.id===e)||null,[e,r]),b=y.useMemo(()=>{if(!d.trim())return r;const E=d.toLowerCase();return r.filter(M=>{var N,T;return((N=M.label)==null?void 0:N.toLowerCase().includes(E))||((T=M.notes)==null?void 0:T.toLowerCase().includes(E))})},[r,d]);y.useEffect(()=>{const E=M=>{m.current&&!m.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const _=E=>{s&&s(E),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},k=E=>{f(E.target.value),p||g(!0)},w=E=>{E.key==="Enter"?(E.preventDefault(),b.length>0&&s?(s(b[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):E.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${l}`,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:E=>{E.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:k,onFocus:D,onKeyDown:w,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:E=>{E.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:E=>{E.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 a=="number"?`${a}px`:a,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((E,M)=>h.jsxs("div",{onClick:()=>_(E),style:{padding:"10px 14px",cursor:"pointer",borderBottom:M<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:E.color||c.text,marginBottom:E.notes?"2px":0},children:E.label}),E.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.notes})]},E.id))})]})}function Pg({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:a,onItemClick:l,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:f="",itemClassName:p=""}){const[g,m]=y.useState(null),[x,v]=y.useState(null),[b,_]=y.useState(null),S=y.useRef(null),D=e.reduce((B,R)=>{let C=r.filter(j=>n(j)===R.id);return s&&(C=C.sort((j,F)=>s(j)-s(F))),B[R.id]=C,B},{}),k=y.useCallback((B,R)=>{const C=t(R),j=n(R);m(C),S.current=j,B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const F=B.target;F.style.opacity="0.5"})},[t,n]),w=y.useCallback(B=>{const R=B.target;R.style.opacity="1",m(null),v(null),_(null),S.current=null},[]),E=y.useCallback((B,R,C)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",v(R),_(C)},[]),M=y.useCallback(B=>{const R=B.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(v(null),_(null))},[]),N=y.useCallback((B,R,C)=>{if(B.preventDefault(),!g)return;const j=S.current;j===R?a==null||a(g,R,C):j&&o(g,j,R,C),m(null),v(null),_(null),S.current=null},[g,o,a]),T=(B,R)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[B.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:B.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:B.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(B=>{const R=D[B.id]||[],C=x===B.id;return h.jsxs("div",{"data-kanban-column":B.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:j=>{j.preventDefault(),g&&!C&&v(B.id)},onDragLeave:M,onDrop:j=>N(j,B.id,b??R.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(B,R.length):T(B,R.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${C?"bg-blue-50":""}`,children:[R.map((j,F)=>{const I=t(j),W=g===I,q=C&&b===F&&!W;return h.jsxs("div",{children:[q&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:ne=>k(ne,j),onDragEnd:w,onDragOver:ne=>E(ne,B.id,F),onClick:()=>l==null?void 0:l(j),className:`cursor-grab active:cursor-grabbing transition-all ${W?"opacity-50 scale-95":""} ${p}`,children:i(j,W)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:j=>{j.preventDefault(),E(j,B.id,R.length)},children:C&&b===R.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.length===0&&C&&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(B)})]},B.id)})})}function Kc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function Ig(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function zg(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const $g={"1:1":1,"2:3":1.5,"16:9":.5625};function Yc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Kc(r),o=$g[e],a=e==="2:3"?160:e==="16:9"?280:180,l=e==="2:3"||e==="16:9"?a*o:a;return h.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:a,height:l,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?h.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:h.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Qc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[a,l]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(l(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const f=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:h.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[h.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),h.jsxs("div",{style:{position:"relative"},children:[a&&h.jsx("button",{onClick:()=>f("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&h.jsx("button",{onClick:()=>f("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),h.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>h.jsx(Yc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Jc({node:r,onClose:e}){const t=Kc(r),n=Ig(r),s=Og(r),i=zg(r);return y.useEffect(()=>{const o=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),h.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:h.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),h.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[h.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?h.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),h.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:h.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),h.jsxs("div",{style:{padding:"0 32px 32px"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&h.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&h.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&h.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&h.jsxs("div",{style:{marginTop:24},children:[h.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,a])=>h.jsxs("div",{children:[h.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),h.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(a)})]},o))})]})]})]})]})})}function qg({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),a=u=>{n?n(u):i(u)},l=()=>{i(null)};return h.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>h.jsx(Qc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:a},u.id)),o.every(u=>u.nodes.length===0)&&h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[h.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),h.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&h.jsx(Jc,{node:s,onClose:l})]})}const Ug={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Wg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Hg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Vg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Gg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:a,getItemId:l,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:f=!0,className:p="",theme:g={}}){const m={...Ug,...g},{allDayItems:x,timedItems:v}=y.useMemo(()=>{const w=[],E=[];for(const M of r)a(M)?w.push(M):E.push(M);return{allDayItems:w,timedItems:E}},[r,a]),b=y.useMemo(()=>{const w=[];for(let E=t;E<=n;E++)w.push(E);return w},[t,n]),_=(n-t+1)*s,S=y.useCallback(w=>{const E=i(w);if(!E)return null;const M=Wg(E);if(!M)return null;const{hours:N,minutes:T}=M,B=Math.max(t,Math.min(n,N)),R=N<t?0:T,C=(B-t)*s+R/60*s,j=o(w),F=Math.max(20,j/60*s);return{top:C,height:F}},[i,o,t,n,s]),D=y.useMemo(()=>{if(!f||!Vg(e))return null;const w=new Date,E=w.getHours(),M=w.getMinutes();return E<t||E>n?null:(E-t)*s+M/60*s},[e,f,t,n,s]),k=y.useCallback(w=>{if(!d)return;const E=w.currentTarget.getBoundingClientRect(),N=(w.clientY-E.top)/s*60,T=Math.floor(N/60)+t,B=Math.round(N%60/15)*15,R=Math.min(n,Math.max(t,T)),C=B>=60?0:B,j=`${R.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(j)},[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(w=>h.jsx("div",{onClick:()=>c==null?void 0:c(w),style:{cursor:c?"pointer":"default"},children:u(w)},l(w)))})]}),h.jsxs("div",{style:{position:"relative",height:_},children:[b.map((w,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:Hg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),E<b.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},w)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:k}),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(w=>{const E=S(w);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:M=>{M.stopPropagation(),c==null||c(w)},children:u(w)},l(w)):null})]})]})}function Xc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const a=s==="widget",[l,u]=y.useState("idle"),[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,v]=y.useState(0),[b,_]=y.useState(null),[S,D]=y.useState(!1),[k,w]=y.useState(null),[E,M]=y.useState(!0),[N,T]=y.useState([]),[B,R]=y.useState({completed:0,total:0}),C=y.useRef(!1),j=y.useRef(!0);y.useEffect(()=>{j.current=E},[E]);const F=y.useRef(null),I=y.useRef(null),W=y.useRef(null),q=y.useRef(null),ne=y.useRef(null),U=y.useRef([]),Q=y.useRef(null),H=y.useRef(null),ie=y.useRef(null),ue=y.useRef(null),he=y.useRef(!1),ge=y.useRef([]),we=y.useRef(null),xe=y.useRef(null),Z=y.useRef([]),be=y.useRef([]),te=y.useRef("insert"),Ae=y.useRef(!1),_e=y.useRef(0),ve=y.useRef(0),Re=y.useRef(0),Le=J=>{const L=Math.floor(J/60),fe=Math.floor(J%60);return`${L.toString().padStart(2,"0")}:${fe.toString().padStart(2,"0")}`},qe=async J=>{const L=await J.arrayBuffer(),fe=new AudioContext,me=await fe.decodeAudioData(L);return await fe.close(),me},V=J=>{const L=J.numberOfChannels,fe=J.sampleRate,me=1,K=16,De=K/8,Se=L*De,ke=fe*Se,Pe=J.length*Se,He=new ArrayBuffer(44+Pe),Ee=new DataView(He),Te=(Ge,ze)=>{for(let ft=0;ft<ze.length;ft++)Ee.setUint8(Ge+ft,ze.charCodeAt(ft))};Te(0,"RIFF"),Ee.setUint32(4,36+Pe,!0),Te(8,"WAVE"),Te(12,"fmt "),Ee.setUint32(16,16,!0),Ee.setUint16(20,me,!0),Ee.setUint16(22,L,!0),Ee.setUint32(24,fe,!0),Ee.setUint32(28,ke,!0),Ee.setUint16(32,Se,!0),Ee.setUint16(34,K,!0),Te(36,"data"),Ee.setUint32(40,Pe,!0);const rt=[];for(let Ge=0;Ge<L;Ge++)rt.push(J.getChannelData(Ge));let it=44;for(let Ge=0;Ge<J.length;Ge++)for(let ze=0;ze<L;ze++){const ft=Math.max(-1,Math.min(1,rt[ze][Ge])),ht=ft<0?ft*32768:ft*32767;Ee.setInt16(it,ht,!0),it+=2}return new Blob([He],{type:"audio/wav"})},O=async(J,L,fe,me)=>{const K=new AudioContext,De=J.sampleRate,Se=Math.max(J.numberOfChannels,L.numberOfChannels),ke=Math.min(fe,J.length),Pe=Math.max(0,J.length-fe),He=me==="insert"?ke+L.length+Pe:ke+L.length,Ee=K.createBuffer(Se,He,De);for(let Te=0;Te<Se;Te++){const rt=Ee.getChannelData(Te),it=Te<J.numberOfChannels?J.getChannelData(Te):J.getChannelData(0);for(let ze=0;ze<ke;ze++)rt[ze]=it[ze];const Ge=Te<L.numberOfChannels?L.getChannelData(Te):L.getChannelData(0);for(let ze=0;ze<L.length;ze++)rt[ke+ze]=Ge[ze];if(me==="insert")for(let ze=0;ze<Pe;ze++)rt[ke+L.length+ze]=it[fe+ze]}return await K.close(),Ee},Ue=y.useCallback(()=>{const J=F.current;if(!J)return;const L=J.getContext("2d");if(!L)return;const fe=J.getBoundingClientRect(),me=fe.width,K=fe.height,De=ge.current,Se=f||c||1,ke=l==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,me,K);const Pe=8,He="rgba(0, 0, 0, 0.4)",Ee=L.createLinearGradient(0,0,0,Pe);Ee.addColorStop(0,He),Ee.addColorStop(1,"transparent"),L.fillStyle=Ee,L.fillRect(0,0,me,Pe);const Te=L.createLinearGradient(0,K-Pe,0,K);Te.addColorStop(0,"transparent"),Te.addColorStop(1,He),L.fillStyle=Te,L.fillRect(0,K-Pe,me,Pe);const rt=L.createLinearGradient(0,0,Pe,0);rt.addColorStop(0,He),rt.addColorStop(1,"transparent"),L.fillStyle=rt,L.fillRect(0,0,Pe,K);const it=L.createLinearGradient(me-Pe,0,me,0);it.addColorStop(0,"transparent"),it.addColorStop(1,He),L.fillStyle=it,L.fillRect(me-Pe,0,Pe,K),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,K/2),L.lineTo(me,K/2),L.stroke();const Ge=me/2;if(De.length>0)if(l==="recording")for(let ht=0;ht<De.length;ht++){const At=De.length-1-ht,Zt=Ge-At*4;if(Zt<-3||Zt>me)continue;const jt=De[ht]*(K/2-12),A=K/2-jt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,jt*2)}else{const ht=Se>0?ke/Se*De.length:0;for(let At=0;At<De.length;At++){const Zt=ht-At,jt=Ge-Zt*4;if(jt<-3||jt>me)continue;const A=De[At]*(K/2-12),$=K/2-A;L.fillStyle=At<=ht?"#10b981":"#4b5563",L.fillRect(jt,$,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ge,0),L.lineTo(Ge,K),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Le(ke),Ge,K-6),l==="recording"&&(L.fillStyle="#ef4444",L.beginPath(),L.arc(20,20,8,0,Math.PI*2),L.fill(),L.fillStyle="#fff",L.font="10px sans-serif",L.textAlign="left",L.fillText("REC",34,24)),L.textAlign="left"},[l,x,c,f]),se=()=>{const J=ne.current;if(!J||!he.current)return;const L=J.frequencyBinCount,fe=new Uint8Array(L);J.getByteTimeDomainData(fe);let me=0;for(let Se=0;Se<L;Se++){const ke=(fe[Se]-128)/128;me+=ke*ke}const K=Math.sqrt(me/L),De=Math.min(1,K*3);ge.current.push(De),Ue(),he.current&&(H.current=requestAnimationFrame(se))},re=async()=>{try{_(null),D(!1),we.current===null&&(ge.current=[]);const J=await navigator.mediaDevices.getUserMedia({audio:!0});W.current=J;const L=new AudioContext;q.current=L;const fe=L.createAnalyser();fe.fftSize=2048,ne.current=fe,L.createMediaStreamSource(J).connect(fe);const K=new MediaRecorder(J);I.current=K,U.current=[],K.ondataavailable=De=>{De.data.size>0&&U.current.push(De.data)},K.onstop=async()=>{try{if(he.current=!1,U.current.length===0){_("No audio was recorded. Please try again."),u("idle"),J.getTracks().forEach(Ee=>Ee.stop());return}const De=new Blob(U.current,{type:"audio/webm"});let Se,ke;if(we.current!==null&&xe.current)try{const Ee=await qe(De),Te=xe.current.sampleRate,rt=Math.floor(we.current*Te),it=await O(xe.current,Ee,rt,te.current);Se=V(it),ke=it.length/it.sampleRate,te.current==="insert"&&(ge.current=[...ge.current,...be.current]),we.current=null,xe.current=null,Z.current=[],be.current=[]}catch{Se=De,ke=_e.current>0?_e.current:1}else Se=De,ke=_e.current>0?_e.current:1;if(ue.current=Se,J.getTracks().forEach(Ee=>Ee.stop()),j.current&&t){T(Ee=>[...Ee,Se]),R(Ee=>({...Ee,total:Ee.total+1})),ue.current=null,ge.current=[],v(0),p(0),d(0),u("idle");return}const Pe=URL.createObjectURL(Se),He=new Audio(Pe);He.ontimeupdate=()=>{v(He.currentTime)},He.onended=()=>{m(!1)},ie.current=He,p(ke),v(ke),u("editing")}catch{_("Failed to process recording"),u("idle")}},K.start(100),he.current=!0,u("recording"),d(0),_e.current=0,Q.current=setInterval(()=>{_e.current+=1,d(_e.current),_e.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),he.current=!1,w(null),Q.current&&(clearInterval(Q.current),Q.current=null),H.current&&(cancelAnimationFrame(H.current),H.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{_("Could not access microphone. Please allow microphone access.")}},oe=()=>{he.current=!1,D(!1),w(null),H.current&&(cancelAnimationFrame(H.current),H.current=null),Q.current&&(clearInterval(Q.current),Q.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},z=J=>{const L=F.current;if(!L)return;const fe=f||c;if(fe<=0)return;const me=ge.current;if(me.length===0)return;const K=L.getBoundingClientRect(),De=J-ve.current,Se=4,ke=K.width/L.width,Pe=me.length/fe*Se,He=-De/(Pe*ke),Ee=Re.current+He,Te=Math.max(0,Math.min(Ee,fe));ie.current&&(ie.current.currentTime=Te),v(Te)},de=()=>{ie.current&&(ie.current.currentTime=0),v(0)},Ce=()=>{const J=f||c;ie.current&&(ie.current.currentTime=J),v(J)},We=()=>{const J=ie.current;J&&(g?(J.pause(),v(J.currentTime),m(!1)):(J.currentTime=x,J.play().catch(()=>{}),m(!0)))},dt=async J=>{if(!ue.current){re();return}try{ie.current&&(ie.current.pause(),m(!1)),te.current=J,xe.current=await qe(ue.current);const L=f||c;we.current=x;const fe=L>0?x/L:0,me=Math.floor(fe*ge.current.length);Z.current=ge.current.slice(0,me),be.current=ge.current.slice(me),ge.current=[...Z.current],re()}catch{_("Failed to prepare recording. Please try again.")}},le=()=>{ie.current&&(ie.current.pause(),ie.current=null),ue.current=null,xe.current=null,we.current=null,Z.current=[],m(!1),v(0),p(0),d(0),re()},pe=()=>{ue.current?r(ue.current,f||c):alert("No audio recorded yet!")};y.useEffect(()=>{l==="recording"&&F.current&&ne.current&&he.current&&(H.current=requestAnimationFrame(se))},[l]),y.useEffect(()=>{const J=F.current;if(!J)return;const L=()=>{const fe=window.devicePixelRatio||1,me=J.getBoundingClientRect();J.width=me.width*fe,J.height=me.height*fe;const K=J.getContext("2d");K&&K.scale(fe,fe)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),y.useEffect(()=>{if(l==="idle"){const J=F.current;if(!J)return;const L=J.getContext("2d");if(!L)return;const fe=J.getBoundingClientRect(),me=fe.width,K=fe.height;L.fillStyle="#2d3b35",L.fillRect(0,0,me,K);const De=8,Se="rgba(0, 0, 0, 0.4)",ke=L.createLinearGradient(0,0,0,De);ke.addColorStop(0,Se),ke.addColorStop(1,"transparent"),L.fillStyle=ke,L.fillRect(0,0,me,De);const Pe=L.createLinearGradient(0,K-De,0,K);Pe.addColorStop(0,"transparent"),Pe.addColorStop(1,Se),L.fillStyle=Pe,L.fillRect(0,K-De,me,De);const He=L.createLinearGradient(0,0,De,0);He.addColorStop(0,Se),He.addColorStop(1,"transparent"),L.fillStyle=He,L.fillRect(0,0,De,K);const Ee=L.createLinearGradient(me-De,0,me,0);Ee.addColorStop(0,"transparent"),Ee.addColorStop(1,Se),L.fillStyle=Ee,L.fillRect(me-De,0,De,K),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,K/2),L.lineTo(me,K/2),L.stroke();const Te=me/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Te,0),L.lineTo(Te,K),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Te,K-6)}},[l]);const Ve=y.useCallback(J=>{T(L=>[...L,J]),R(L=>({...L,total:L.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(C.current||N.length===0||!t)return;C.current=!0;const L=N[0];try{const fe=await t(L);fe&&n&&n(fe)}catch(fe){console.error("Transcription failed:",fe)}finally{T(fe=>fe.slice(1)),R(fe=>({...fe,completed:fe.completed+1})),C.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{he.current=!1,Q.current&&clearInterval(Q.current),H.current&&cancelAnimationFrame(H.current),W.current&&W.current.getTracks().forEach(J=>J.stop()),q.current&&q.current.state!=="closed"&&q.current.close()},[]),y.useEffect(()=>{if(l==="editing"&&g){let J;const L=()=>{const fe=ie.current;if(fe&&g){const me=F.current;if(me){const K=me.getContext("2d");if(K){const De=me.getBoundingClientRect(),Se=De.width,ke=De.height,Pe=ge.current,He=f||c||1,Ee=fe.currentTime;K.fillStyle="#2d3b35",K.fillRect(0,0,Se,ke);const Te=8,rt="rgba(0, 0, 0, 0.4)",it=K.createLinearGradient(0,0,0,Te);it.addColorStop(0,rt),it.addColorStop(1,"transparent"),K.fillStyle=it,K.fillRect(0,0,Se,Te);const Ge=K.createLinearGradient(0,ke-Te,0,ke);Ge.addColorStop(0,"transparent"),Ge.addColorStop(1,rt),K.fillStyle=Ge,K.fillRect(0,ke-Te,Se,Te);const ze=K.createLinearGradient(0,0,Te,0);ze.addColorStop(0,rt),ze.addColorStop(1,"transparent"),K.fillStyle=ze,K.fillRect(0,0,Te,ke);const ft=K.createLinearGradient(Se-Te,0,Se,0);ft.addColorStop(0,"transparent"),ft.addColorStop(1,rt),K.fillStyle=ft,K.fillRect(Se-Te,0,Te,ke),K.strokeStyle="#5a6b62",K.lineWidth=1,K.beginPath(),K.moveTo(0,ke/2),K.lineTo(Se,ke/2),K.stroke();const ht=Se/2,At=3,Zt=4,jt=He>0?Ee/He*Pe.length:0;for(let ee=0;ee<Pe.length;ee++){const ye=jt-ee,Me=ht-ye*Zt;if(Me<-At||Me>Se)continue;const Oe=Pe[ee]*(ke/2-12),Be=ke/2-Oe;K.fillStyle=ee<=jt?"#10b981":"#4b5563",K.fillRect(Me,Be,At,Oe*2)}K.strokeStyle="#ef4444",K.lineWidth=1,K.beginPath(),K.moveTo(ht,0),K.lineTo(ht,ke),K.stroke(),K.fillStyle="#fff",K.font="bold 18px monospace",K.textAlign="center";const A=Math.floor(Ee/60),$=Math.floor(Ee%60);K.fillText(`${A.toString().padStart(2,"0")}:${$.toString().padStart(2,"0")}`,ht,ke-6),K.textAlign="left"}}J=requestAnimationFrame(L)}};return J=requestAnimationFrame(L),()=>cancelAnimationFrame(J)}},[l,g,f,c]),y.useEffect(()=>{l==="editing"&&!g&&Ue()},[l,x,g,Ue]),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:()=>{_(null),re()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ze={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},et={...Ze,opacity:.3,cursor:"not-allowed"},Bt=a?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Bt,children:[h.jsx("canvas",{ref:F,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:J=>{if(l==="editing"){Ae.current=!0,ve.current=J.clientX,Re.current=x;const L=me=>{Ae.current&&z(me.clientX)},fe=()=>{Ae.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",fe)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",fe)}}}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:a?"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:de,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?et:Ze,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(l==="recording"){const J=I.current;J&&(J.state==="recording"?(J.pause(),D(!0)):J.state==="paused"&&(J.resume(),D(!1)))}else We()},disabled:l==="idle",style:l==="idle"?et:Ze,title:g||l==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||l==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ce,disabled:l==="idle"||l==="recording",style:l==="idle"||l==="recording"?et:Ze,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:()=>{k==="insert"?oe():l==="idle"?(w("insert"),re()):l==="editing"&&(w("insert"),dt("insert"))},disabled:l==="recording"&&k!=="insert"||g,style:l==="recording"&&k!=="insert"||g?et:Ze,title:k==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{j.current||(k==="mic"?oe():l==="idle"?(w("mic"),re()):l==="editing"&&(w("mic"),dt("replace")))},onMouseDown:()=>{j.current&&l==="idle"&&!g&&(w("mic"),re())},onMouseUp:()=>{j.current&&l==="recording"&&k==="mic"&&oe()},onMouseLeave:()=>{j.current&&l==="recording"&&k==="mic"&&oe()},onTouchStart:J=>{J.preventDefault(),j.current&&l==="idle"&&!g&&(w("mic"),re())},onTouchEnd:J=>{J.preventDefault(),j.current&&l==="recording"&&k==="mic"&&oe()},disabled:l==="recording"&&k!=="mic"||g,style:l==="recording"&&k!=="mic"||g?et:Ze,title:E?"Hold to record (walkie-talkie)":k==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{k==="startover"?oe():l==="editing"&&(w("startover"),le())},disabled:l==="idle"||l==="recording"&&k!=="startover"||g,style:l==="idle"||l==="recording"&&k!=="startover"||g?et:Ze,title:k==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[B.total>0&&B.completed<B.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"}),B.completed,"/",B.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>M(!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:()=>{l==="editing"&&ue.current&&Ve(ue.current)},disabled:l!=="editing",style:l!=="editing"?et:Ze,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:pe,disabled:l!=="editing",style:l!=="editing"?et:Ze,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),B.total>0&&B.completed<B.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${B.completed/B.total*100}%`,transition:"width 0.3s ease"}})})]})}function Kg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,placeholder:o="Type or record...",className:a="",rows:l,llmClient:u,graphClient:c,nodeId:d,audioFilename:f,existingAudio:p,existingVoice:g,onAudioGenerated:m,onGenerateTTS:x,audioUrl:v,voice:b="coral",onVoiceChange:_,generateButton:S,generatePrompt:D,generateSourceText:k,generateSourceError:w}){const[E,M]=y.useState(!1),[N,T]=y.useState(null),[B,R]=y.useState(!1),[C,j]=y.useState(""),[F,I]=y.useState(!1),[W,q]=y.useState(!1),[ne,U]=y.useState(null),[Q,H]=y.useState(g||b),[ie,ue]=y.useState(p),[he,ge]=y.useState(Date.now()),we=y.useRef(null),xe=y.useRef(null),Z=!!(u&&c&&d&&f);y.useEffect(()=>{p!==void 0&&ue(p)},[p]),y.useEffect(()=>{g!==void 0&&H(g)},[g]);const be=Z&&ie&&c&&d?`${c.getFileUrl(d,ie)}?v=${he}`:v,te=V=>{t(e?`${e}
|
|
183
|
+
`})]})}const Mg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Rg({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={...Mg,...d},[g,m]=y.useState(!1),[x,_]=y.useState(""),b=y.useRef(null),w=y.useRef(null);y.useEffect(()=>{function T(B){b.current&&!b.current.contains(B.target)&&(m(!1),_(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),D=s&&x.trim()&&!r.some(T=>{var B;return((B=T.label)==null?void 0:B.toLowerCase())===x.toLowerCase()}),E=e.map(T=>r.find(B=>B.id===T)).filter(Boolean),v=y.useCallback(T=>{var B;c>0&&e.length>=c||(t([...e,T]),_(""),c===1?m(!1):(B=w.current)==null||B.focus())},[e,t,c]),k=y.useCallback(T=>{t(e.filter(B=>B!==T))},[e,t]),M=y.useCallback(async()=>{if(!D)return;const T=await(i==null?void 0:i(x.trim()));T&&v(T.id),_("")},[D,x,i,v]),N=y.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),D?M():S.length>0&&v(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?k(e[e.length-1]):T.key==="Escape"&&(m(!1),_(""))},[D,S,x,e,M,v,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:[E.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:B=>{B.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:w,type:"text",value:x,onChange:T=>{_(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:N,placeholder:E.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:()=>v(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:B=>{B.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:B=>{B.currentTarget.style.background=""},children:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),l(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:B=>{B.currentTarget.style.opacity="1",B.currentTarget.style.color="#ef4444"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.5",B.currentTarget.style.color=p.textSecondary||""},children:"×"})]},T.id)),D&&h.jsxs("div",{onClick:M,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 Fg={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Lg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Fg,...u},[d,f]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),_=y.useMemo(()=>e&&r.find(k=>k.id===e)||null,[e,r]),b=y.useMemo(()=>{if(!d.trim())return r;const k=d.toLowerCase();return r.filter(M=>{var N,T;return((N=M.label)==null?void 0:N.toLowerCase().includes(k))||((T=M.notes)==null?void 0:T.toLowerCase().includes(k))})},[r,d]);y.useEffect(()=>{const k=M=>{m.current&&!m.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const w=k=>{s&&s(k),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},E=k=>{f(k.target.value),p||g(!0)},v=k=>{k.key==="Enter"?(k.preventDefault(),b.length>0&&s?(s(b[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):k.key==="Escape"&&(g(!1),f(""))};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:_&&!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:_.label}),_.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.notes})]}),i&&h.jsx("button",{onClick:k=>{k.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:E,onFocus:D,onKeyDown:v,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:k=>{k.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:k=>{k.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((k,M)=>h.jsxs("div",{onClick:()=>w(k),style:{padding:"10px 14px",cursor:"pointer",borderBottom:M<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:k.color||c.text,marginBottom:k.notes?"2px":0},children:k.label}),k.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.notes})]},k.id))})]})}function Pg({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]=y.useState(null),[x,_]=y.useState(null),[b,w]=y.useState(null),S=y.useRef(null),D=e.reduce((B,R)=>{let C=r.filter(j=>n(j)===R.id);return s&&(C=C.sort((j,F)=>s(j)-s(F))),B[R.id]=C,B},{}),E=y.useCallback((B,R)=>{const C=t(R),j=n(R);m(C),S.current=j,B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const F=B.target;F.style.opacity="0.5"})},[t,n]),v=y.useCallback(B=>{const R=B.target;R.style.opacity="1",m(null),_(null),w(null),S.current=null},[]),k=y.useCallback((B,R,C)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",_(R),w(C)},[]),M=y.useCallback(B=>{const R=B.relatedTarget;R!=null&&R.closest("[data-kanban-column]")||(_(null),w(null))},[]),N=y.useCallback((B,R,C)=>{if(B.preventDefault(),!g)return;const j=S.current;j===R?l==null||l(g,R,C):j&&o(g,j,R,C),m(null),_(null),w(null),S.current=null},[g,o,l]),T=(B,R)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[B.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:B.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:B.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:R})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(B=>{const R=D[B.id]||[],C=x===B.id;return h.jsxs("div",{"data-kanban-column":B.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:j=>{j.preventDefault(),g&&!C&&_(B.id)},onDragLeave:M,onDrop:j=>N(j,B.id,b??R.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(B,R.length):T(B,R.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${C?"bg-blue-50":""}`,children:[R.map((j,F)=>{const I=t(j),q=g===I,ee=C&&b===F&&!q;return h.jsxs("div",{children:[ee&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:O=>E(O,j),onDragEnd:v,onDragOver:O=>k(O,B.id,F),onClick:()=>a==null?void 0:a(j),className:`cursor-grab active:cursor-grabbing transition-all ${q?"opacity-50 scale-95":""} ${p}`,children:i(j,q)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:j=>{j.preventDefault(),k(j,B.id,R.length)},children:C&&b===R.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),R.length===0&&C&&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(B)})]},B.id)})})}function Kc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function Ig(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function zg(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function Og(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const $g={"1:1":1,"2:3":1.5,"16:9":.5625};function Yc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Kc(r),o=$g[e],l=e==="2:3"?160:e==="16:9"?280:180,a=e==="2:3"||e==="16:9"?l*o:l;return h.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:l,height:a,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?h.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:h.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Qc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[l,a]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(a(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const f=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:h.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[h.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),h.jsxs("div",{style:{position:"relative"},children:[l&&h.jsx("button",{onClick:()=>f("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&h.jsx("button",{onClick:()=>f("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:h.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),h.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>h.jsx(Yc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Jc({node:r,onClose:e}){const t=Kc(r),n=Ig(r),s=zg(r),i=Og(r);return y.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),h.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:h.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[h.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),h.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[h.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?h.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):h.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),h.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),h.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:h.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),h.jsxs("div",{style:{padding:"0 32px 32px"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&h.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&h.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&h.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&h.jsxs("div",{style:{marginTop:24},children:[h.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),h.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,l])=>h.jsxs("div",{children:[h.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),h.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(l)})]},o))})]})]})]})]})})}function qg({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),l=u=>{n?n(u):i(u)},a=()=>{i(null)};return h.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>h.jsx(Qc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:l},u.id)),o.every(u=>u.nodes.length===0)&&h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[h.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),h.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&h.jsx(Jc,{node:s,onClose:a})]})}const Ug={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Wg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Hg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Vg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Gg({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={...Ug,...g},{allDayItems:x,timedItems:_}=y.useMemo(()=>{const v=[],k=[];for(const M of r)l(M)?v.push(M):k.push(M);return{allDayItems:v,timedItems:k}},[r,l]),b=y.useMemo(()=>{const v=[];for(let k=t;k<=n;k++)v.push(k);return v},[t,n]),w=(n-t+1)*s,S=y.useCallback(v=>{const k=i(v);if(!k)return null;const M=Wg(k);if(!M)return null;const{hours:N,minutes:T}=M,B=Math.max(t,Math.min(n,N)),R=N<t?0:T,C=(B-t)*s+R/60*s,j=o(v),F=Math.max(20,j/60*s);return{top:C,height:F}},[i,o,t,n,s]),D=y.useMemo(()=>{if(!f||!Vg(e))return null;const v=new Date,k=v.getHours(),M=v.getMinutes();return k<t||k>n?null:(k-t)*s+M/60*s},[e,f,t,n,s]),E=y.useCallback(v=>{if(!d)return;const k=v.currentTarget.getBoundingClientRect(),N=(v.clientY-k.top)/s*60,T=Math.floor(N/60)+t,B=Math.round(N%60/15)*15,R=Math.min(n,Math.max(t,T)),C=B>=60?0:B,j=`${R.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(j)},[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(v=>h.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},a(v)))})]}),h.jsxs("div",{style:{position:"relative",height:w},children:[b.map((v,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:Hg(v)}),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}})]},v)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),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}})]}),_.map(v=>{const k=S(v);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:M=>{M.stopPropagation(),c==null||c(v)},children:u(v)},a(v)):null})]})]})}function Xc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=y.useState("idle"),[c,d]=y.useState(0),[f,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(0),[b,w]=y.useState(null),[S,D]=y.useState(!1),[E,v]=y.useState(null),[k,M]=y.useState(!0),[N,T]=y.useState([]),[B,R]=y.useState({completed:0,total:0}),C=y.useRef(!1),j=y.useRef(!0);y.useEffect(()=>{j.current=k},[k]);const F=y.useRef(null),I=y.useRef(null),q=y.useRef(null),ee=y.useRef(null),O=y.useRef(null),W=y.useRef([]),Z=y.useRef(null),H=y.useRef(null),ie=y.useRef(null),fe=y.useRef(null),ae=y.useRef(!1),ge=y.useRef([]),ye=y.useRef(null),xe=y.useRef(null),Q=y.useRef([]),Se=y.useRef([]),se=y.useRef("insert"),Ne=y.useRef(!1),be=y.useRef(0),ve=y.useRef(0),Le=y.useRef(0),Me=U=>{const L=Math.floor(U/60),ce=Math.floor(U%60);return`${L.toString().padStart(2,"0")}:${ce.toString().padStart(2,"0")}`},$e=async U=>{const L=await U.arrayBuffer(),ce=new AudioContext,pe=await ce.decodeAudioData(L);return await ce.close(),pe},G=U=>{const L=U.numberOfChannels,ce=U.sampleRate,pe=1,J=16,Ce=J/8,ke=L*Ce,Ee=ce*ke,Ie=U.length*ke,Ge=new ArrayBuffer(44+Ie),De=new DataView(Ge),Ae=(Ye,qe)=>{for(let dt=0;dt<qe.length;dt++)De.setUint8(Ye+dt,qe.charCodeAt(dt))};Ae(0,"RIFF"),De.setUint32(4,36+Ie,!0),Ae(8,"WAVE"),Ae(12,"fmt "),De.setUint32(16,16,!0),De.setUint16(20,pe,!0),De.setUint16(22,L,!0),De.setUint32(24,ce,!0),De.setUint32(28,Ee,!0),De.setUint16(32,ke,!0),De.setUint16(34,J,!0),Ae(36,"data"),De.setUint32(40,Ie,!0);const rt=[];for(let Ye=0;Ye<L;Ye++)rt.push(U.getChannelData(Ye));let it=44;for(let Ye=0;Ye<U.length;Ye++)for(let qe=0;qe<L;qe++){const dt=Math.max(-1,Math.min(1,rt[qe][Ye])),ft=dt<0?dt*32768:dt*32767;De.setInt16(it,ft,!0),it+=2}return new Blob([Ge],{type:"audio/wav"})},z=async(U,L,ce,pe)=>{const J=new AudioContext,Ce=U.sampleRate,ke=Math.max(U.numberOfChannels,L.numberOfChannels),Ee=Math.min(ce,U.length),Ie=Math.max(0,U.length-ce),Ge=pe==="insert"?Ee+L.length+Ie:Ee+L.length,De=J.createBuffer(ke,Ge,Ce);for(let Ae=0;Ae<ke;Ae++){const rt=De.getChannelData(Ae),it=Ae<U.numberOfChannels?U.getChannelData(Ae):U.getChannelData(0);for(let qe=0;qe<Ee;qe++)rt[qe]=it[qe];const Ye=Ae<L.numberOfChannels?L.getChannelData(Ae):L.getChannelData(0);for(let qe=0;qe<L.length;qe++)rt[Ee+qe]=Ye[qe];if(pe==="insert")for(let qe=0;qe<Ie;qe++)rt[Ee+L.length+qe]=it[ce+qe]}return await J.close(),De},Pe=y.useCallback(()=>{const U=F.current;if(!U)return;const L=U.getContext("2d");if(!L)return;const ce=U.getBoundingClientRect(),pe=ce.width,J=ce.height,Ce=ge.current,ke=f||c||1,Ee=a==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,pe,J);const Ie=8,Ge="rgba(0, 0, 0, 0.4)",De=L.createLinearGradient(0,0,0,Ie);De.addColorStop(0,Ge),De.addColorStop(1,"transparent"),L.fillStyle=De,L.fillRect(0,0,pe,Ie);const Ae=L.createLinearGradient(0,J-Ie,0,J);Ae.addColorStop(0,"transparent"),Ae.addColorStop(1,Ge),L.fillStyle=Ae,L.fillRect(0,J-Ie,pe,Ie);const rt=L.createLinearGradient(0,0,Ie,0);rt.addColorStop(0,Ge),rt.addColorStop(1,"transparent"),L.fillStyle=rt,L.fillRect(0,0,Ie,J);const it=L.createLinearGradient(pe-Ie,0,pe,0);it.addColorStop(0,"transparent"),it.addColorStop(1,Ge),L.fillStyle=it,L.fillRect(pe-Ie,0,Ie,J),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,J/2),L.lineTo(pe,J/2),L.stroke();const Ye=pe/2;if(Ce.length>0)if(a==="recording")for(let ft=0;ft<Ce.length;ft++){const Tt=Ce.length-1-ft,Zt=Ye-Tt*4;if(Zt<-3||Zt>pe)continue;const jt=Ce[ft]*(J/2-12),A=J/2-jt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,jt*2)}else{const ft=ke>0?Ee/ke*Ce.length:0;for(let Tt=0;Tt<Ce.length;Tt++){const Zt=ft-Tt,jt=Ye-Zt*4;if(jt<-3||jt>pe)continue;const A=Ce[Tt]*(J/2-12),$=J/2-A;L.fillStyle=Tt<=ft?"#10b981":"#4b5563",L.fillRect(jt,$,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ye,0),L.lineTo(Ye,J),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Me(Ee),Ye,J-6),a==="recording"&&(L.fillStyle="#ef4444",L.beginPath(),L.arc(20,20,8,0,Math.PI*2),L.fill(),L.fillStyle="#fff",L.font="10px sans-serif",L.textAlign="left",L.fillText("REC",34,24)),L.textAlign="left"},[a,x,c,f]),He=()=>{const U=O.current;if(!U||!ae.current)return;const L=U.frequencyBinCount,ce=new Uint8Array(L);U.getByteTimeDomainData(ce);let pe=0;for(let ke=0;ke<L;ke++){const Ee=(ce[ke]-128)/128;pe+=Ee*Ee}const J=Math.sqrt(pe/L),Ce=Math.min(1,J*3);ge.current.push(Ce),Pe(),ae.current&&(H.current=requestAnimationFrame(He))},K=async()=>{try{w(null),D(!1),ye.current===null&&(ge.current=[]);const U=await navigator.mediaDevices.getUserMedia({audio:!0});q.current=U;const L=new AudioContext;ee.current=L;const ce=L.createAnalyser();ce.fftSize=2048,O.current=ce,L.createMediaStreamSource(U).connect(ce);const J=new MediaRecorder(U);I.current=J,W.current=[],J.ondataavailable=Ce=>{Ce.data.size>0&&W.current.push(Ce.data)},J.onstop=async()=>{try{if(ae.current=!1,W.current.length===0){w("No audio was recorded. Please try again."),u("idle"),U.getTracks().forEach(De=>De.stop());return}const Ce=new Blob(W.current,{type:"audio/webm"});let ke,Ee;if(ye.current!==null&&xe.current)try{const De=await $e(Ce),Ae=xe.current.sampleRate,rt=Math.floor(ye.current*Ae),it=await z(xe.current,De,rt,se.current);ke=G(it),Ee=it.length/it.sampleRate,se.current==="insert"&&(ge.current=[...ge.current,...Se.current]),ye.current=null,xe.current=null,Q.current=[],Se.current=[]}catch{ke=Ce,Ee=be.current>0?be.current:1}else ke=Ce,Ee=be.current>0?be.current:1;if(fe.current=ke,U.getTracks().forEach(De=>De.stop()),j.current&&t){T(De=>[...De,ke]),R(De=>({...De,total:De.total+1})),fe.current=null,ge.current=[],_(0),p(0),d(0),u("idle");return}const Ie=URL.createObjectURL(ke),Ge=new Audio(Ie);Ge.ontimeupdate=()=>{_(Ge.currentTime)},Ge.onended=()=>{m(!1)},ie.current=Ge,p(Ee),_(Ee),u("editing")}catch{w("Failed to process recording"),u("idle")}},J.start(100),ae.current=!0,u("recording"),d(0),be.current=0,Z.current=setInterval(()=>{be.current+=1,d(be.current),be.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),ae.current=!1,v(null),Z.current&&(clearInterval(Z.current),Z.current=null),H.current&&(cancelAnimationFrame(H.current),H.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{w("Could not access microphone. Please allow microphone access.")}},re=()=>{ae.current=!1,D(!1),v(null),H.current&&(cancelAnimationFrame(H.current),H.current=null),Z.current&&(clearInterval(Z.current),Z.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},de=U=>{const L=F.current;if(!L)return;const ce=f||c;if(ce<=0)return;const pe=ge.current;if(pe.length===0)return;const J=L.getBoundingClientRect(),Ce=U-ve.current,ke=4,Ee=J.width/L.width,Ie=pe.length/ce*ke,Ge=-Ce/(Ie*Ee),De=Le.current+Ge,Ae=Math.max(0,Math.min(De,ce));ie.current&&(ie.current.currentTime=Ae),_(Ae)},_e=()=>{ie.current&&(ie.current.currentTime=0),_(0)},we=()=>{const U=f||c;ie.current&&(ie.current.currentTime=U),_(U)},xt=()=>{const U=ie.current;U&&(g?(U.pause(),_(U.currentTime),m(!1)):(U.currentTime=x,U.play().catch(()=>{}),m(!0)))},bt=async U=>{if(!fe.current){K();return}try{ie.current&&(ie.current.pause(),m(!1)),se.current=U,xe.current=await $e(fe.current);const L=f||c;ye.current=x;const ce=L>0?x/L:0,pe=Math.floor(ce*ge.current.length);Q.current=ge.current.slice(0,pe),Se.current=ge.current.slice(pe),ge.current=[...Q.current],K()}catch{w("Failed to prepare recording. Please try again.")}},le=()=>{ie.current&&(ie.current.pause(),ie.current=null),fe.current=null,xe.current=null,ye.current=null,Q.current=[],m(!1),_(0),p(0),d(0),K()},he=()=>{fe.current?r(fe.current,f||c):alert("No audio recorded yet!")};y.useEffect(()=>{a==="recording"&&F.current&&O.current&&ae.current&&(H.current=requestAnimationFrame(He))},[a]),y.useEffect(()=>{const U=F.current;if(!U)return;const L=()=>{const ce=window.devicePixelRatio||1,pe=U.getBoundingClientRect();U.width=pe.width*ce,U.height=pe.height*ce;const J=U.getContext("2d");J&&J.scale(ce,ce)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),y.useEffect(()=>{if(a==="idle"){const U=F.current;if(!U)return;const L=U.getContext("2d");if(!L)return;const ce=U.getBoundingClientRect(),pe=ce.width,J=ce.height;L.fillStyle="#2d3b35",L.fillRect(0,0,pe,J);const Ce=8,ke="rgba(0, 0, 0, 0.4)",Ee=L.createLinearGradient(0,0,0,Ce);Ee.addColorStop(0,ke),Ee.addColorStop(1,"transparent"),L.fillStyle=Ee,L.fillRect(0,0,pe,Ce);const Ie=L.createLinearGradient(0,J-Ce,0,J);Ie.addColorStop(0,"transparent"),Ie.addColorStop(1,ke),L.fillStyle=Ie,L.fillRect(0,J-Ce,pe,Ce);const Ge=L.createLinearGradient(0,0,Ce,0);Ge.addColorStop(0,ke),Ge.addColorStop(1,"transparent"),L.fillStyle=Ge,L.fillRect(0,0,Ce,J);const De=L.createLinearGradient(pe-Ce,0,pe,0);De.addColorStop(0,"transparent"),De.addColorStop(1,ke),L.fillStyle=De,L.fillRect(pe-Ce,0,Ce,J),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,J/2),L.lineTo(pe,J/2),L.stroke();const Ae=pe/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ae,0),L.lineTo(Ae,J),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Ae,J-6)}},[a]);const We=y.useCallback(U=>{T(L=>[...L,U]),R(L=>({...L,total:L.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(C.current||N.length===0||!t)return;C.current=!0;const L=N[0];try{const ce=await t(L);ce&&n&&n(ce)}catch(ce){console.error("Transcription failed:",ce)}finally{T(ce=>ce.slice(1)),R(ce=>({...ce,completed:ce.completed+1})),C.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{ae.current=!1,Z.current&&clearInterval(Z.current),H.current&&cancelAnimationFrame(H.current),q.current&&q.current.getTracks().forEach(U=>U.stop()),ee.current&&ee.current.state!=="closed"&&ee.current.close()},[]),y.useEffect(()=>{if(a==="editing"&&g){let U;const L=()=>{const ce=ie.current;if(ce&&g){const pe=F.current;if(pe){const J=pe.getContext("2d");if(J){const Ce=pe.getBoundingClientRect(),ke=Ce.width,Ee=Ce.height,Ie=ge.current,Ge=f||c||1,De=ce.currentTime;J.fillStyle="#2d3b35",J.fillRect(0,0,ke,Ee);const Ae=8,rt="rgba(0, 0, 0, 0.4)",it=J.createLinearGradient(0,0,0,Ae);it.addColorStop(0,rt),it.addColorStop(1,"transparent"),J.fillStyle=it,J.fillRect(0,0,ke,Ae);const Ye=J.createLinearGradient(0,Ee-Ae,0,Ee);Ye.addColorStop(0,"transparent"),Ye.addColorStop(1,rt),J.fillStyle=Ye,J.fillRect(0,Ee-Ae,ke,Ae);const qe=J.createLinearGradient(0,0,Ae,0);qe.addColorStop(0,rt),qe.addColorStop(1,"transparent"),J.fillStyle=qe,J.fillRect(0,0,Ae,Ee);const dt=J.createLinearGradient(ke-Ae,0,ke,0);dt.addColorStop(0,"transparent"),dt.addColorStop(1,rt),J.fillStyle=dt,J.fillRect(ke-Ae,0,Ae,Ee),J.strokeStyle="#5a6b62",J.lineWidth=1,J.beginPath(),J.moveTo(0,Ee/2),J.lineTo(ke,Ee/2),J.stroke();const ft=ke/2,Tt=3,Zt=4,jt=Ge>0?De/Ge*Ie.length:0;for(let ne=0;ne<Ie.length;ne++){const me=jt-ne,Re=ft-me*Zt;if(Re<-Tt||Re>ke)continue;const Oe=Ie[ne]*(Ee/2-12),Be=Ee/2-Oe;J.fillStyle=ne<=jt?"#10b981":"#4b5563",J.fillRect(Re,Be,Tt,Oe*2)}J.strokeStyle="#ef4444",J.lineWidth=1,J.beginPath(),J.moveTo(ft,0),J.lineTo(ft,Ee),J.stroke(),J.fillStyle="#fff",J.font="bold 18px monospace",J.textAlign="center";const A=Math.floor(De/60),$=Math.floor(De%60);J.fillText(`${A.toString().padStart(2,"0")}:${$.toString().padStart(2,"0")}`,ft,Ee-6),J.textAlign="left"}}U=requestAnimationFrame(L)}};return U=requestAnimationFrame(L),()=>cancelAnimationFrame(U)}},[a,g,f,c]),y.useEffect(()=>{a==="editing"&&!g&&Pe()},[a,x,g,Pe]),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:()=>{w(null),K()},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"},V={...Ke,opacity:.3,cursor:"not-allowed"},Ve=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Ve,children:[h.jsx("canvas",{ref:F,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:U=>{if(a==="editing"){Ne.current=!0,ve.current=U.clientX,Le.current=x;const L=pe=>{Ne.current&&de(pe.clientX)},ce=()=>{Ne.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",ce)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",ce)}}}),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:_e,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?V: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 U=I.current;U&&(U.state==="recording"?(U.pause(),D(!0)):U.state==="paused"&&(U.resume(),D(!1)))}else xt()},disabled:a==="idle",style:a==="idle"?V: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:we,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?V: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:()=>{E==="insert"?re():a==="idle"?(v("insert"),K()):a==="editing"&&(v("insert"),bt("insert"))},disabled:a==="recording"&&E!=="insert"||g,style:a==="recording"&&E!=="insert"||g?V:Ke,title:E==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{j.current||(E==="mic"?re():a==="idle"?(v("mic"),K()):a==="editing"&&(v("mic"),bt("replace")))},onMouseDown:()=>{j.current&&a==="idle"&&!g&&(v("mic"),K())},onMouseUp:()=>{j.current&&a==="recording"&&E==="mic"&&re()},onMouseLeave:()=>{j.current&&a==="recording"&&E==="mic"&&re()},onTouchStart:U=>{U.preventDefault(),j.current&&a==="idle"&&!g&&(v("mic"),K())},onTouchEnd:U=>{U.preventDefault(),j.current&&a==="recording"&&E==="mic"&&re()},disabled:a==="recording"&&E!=="mic"||g,style:a==="recording"&&E!=="mic"||g?V:Ke,title:k?"Hold to record (walkie-talkie)":E==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{E==="startover"?re():a==="editing"&&(v("startover"),le())},disabled:a==="idle"||a==="recording"&&E!=="startover"||g,style:a==="idle"||a==="recording"&&E!=="startover"||g?V:Ke,title:E==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[B.total>0&&B.completed<B.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"}),B.completed,"/",B.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>M(!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"&&fe.current&&We(fe.current)},disabled:a!=="editing",style:a!=="editing"?V:Ke,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:he,disabled:a!=="editing",style:a!=="editing"?V:Ke,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),B.total>0&&B.completed<B.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${B.completed/B.total*100}%`,transition:"width 0.3s ease"}})})]})}function Kg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,placeholder:o="Type or record...",className:l="",rows:a,llmClient:u,graphClient:c,nodeId:d,audioFilename:f,existingAudio:p,existingVoice:g,onAudioGenerated:m,onGenerateTTS:x,audioUrl:_,voice:b="coral",onVoiceChange:w,generateButton:S,generatePrompt:D,generateSourceText:E,generateSourceError:v}){const[k,M]=y.useState(!1),[N,T]=y.useState(null),[B,R]=y.useState(!1),[C,j]=y.useState(""),[F,I]=y.useState(!1),[q,ee]=y.useState(!1),[O,W]=y.useState(null),[Z,H]=y.useState(g||b),[ie,fe]=y.useState(p),[ae,ge]=y.useState(Date.now()),ye=y.useRef(null),xe=y.useRef(null),Q=!!(u&&c&&d&&f);y.useEffect(()=>{p!==void 0&&fe(p)},[p]),y.useEffect(()=>{g!==void 0&&H(g)},[g]);const Se=Q&&ie&&c&&d?`${c.getFileUrl(d,ie)}?v=${ae}`:_,se=G=>{t(e?`${e}
|
|
184
184
|
|
|
185
|
-
${V}`:V)},Ae=async V=>{if(!(!(typeof e=="string"?e:"").trim()||E||!s)){M(!0),T(V),R(!1);try{const O=await s(V,e);t(O)}catch(O){console.error(`${V} failed:`,O)}finally{M(!1),T(null)}}},_e=()=>{setTimeout(()=>{var V;(V=we.current)!=null&&V.contains(document.activeElement)||R(!1)},150)},ve=async()=>{if(!(!C.trim()||E||!i)){M(!0),T(C);try{const V=await i(C,e);t(V),j("")}catch(V){console.error("AI prompt failed:",V)}finally{M(!1),T(null)}}},Re=async()=>{if(!(typeof e=="string"?e:"").trim()||F)return;if(!(Z||x)){console.warn("TTS: No generation mode available",{integratedTTS:Z,hasCallback:!!x,llmClient:!!u,graphClient:!!c,nodeId:d,audioFilename:f}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}xe.current&&(xe.current.pause(),xe.current.currentTime=0),I(!0);try{if(Z&&u&&c&&d&&f){console.log("TTS: Generating audio...",{voice:Q,textLength:e.length});const O=await u.tts(e,{voice:Q});console.log("TTS: Audio generated, uploading...",{audioLength:O==null?void 0:O.length});const Ue=atob(O),se=new Uint8Array(Ue.length);for(let z=0;z<Ue.length;z++)se[z]=Ue.charCodeAt(z);const re=new Blob([se],{type:"audio/mpeg"}),oe=new File([re],f,{type:"audio/mpeg"});await c.uploadFile(d,f,oe),console.log("TTS: Upload complete",{nodeId:d,audioFilename:f}),ge(Date.now()),ue(f),m==null||m(f,Q)}else x&&(await x(e,Q),ge(Date.now()))}catch(O){console.error("TTS generation failed:",O),alert("Erreur TTS: "+(O instanceof Error?O.message:"Erreur inconnue"))}finally{I(!1)}},Le=async()=>{if(!(!u||!D||W)){if(!(k!=null&&k.trim())){U(w||"Le texte source est requis pour la génération.");return}q(!0),U(null);try{const V=await u.chat([{role:"system",content:D},{role:"user",content:k}]);t(V)}catch(V){U(V instanceof Error?V.message:"Erreur de génération")}finally{q(!1)}}},qe=V=>{H(V),_==null||_(V)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[h.jsx(Xc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:te,hideSaveButton:!0,variant:"div"}),i&&h.jsxs("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200",children:[h.jsx("textarea",{value:C,onChange:V=>j(V.target.value),onKeyDown:V=>{V.stopPropagation(),V.key==="Enter"&&V.ctrlKey&&(V.preventDefault(),ve())},placeholder:"Instructions AI... (Ctrl+Enter pour envoyer)",disabled:E,rows:5,className:"flex-1 pl-0 pr-2 py-2 text-sm border-0 resize-y min-h-[80px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50"}),h.jsx("button",{type:"button",onClick:ve,disabled:E||!C.trim(),className:"self-start p-2 text-neutral-700 hover:text-neutral-900 transition-colors disabled:opacity-30",title:"Envoyer (Ctrl+Enter)",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:E?"hourglass_empty":"smart_toy"})})]}),(r||s||(typeof e=="string"?e:"").trim()||Z||x||S)&&h.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[r&&h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),S&&u&&D&&h.jsxs("button",{type:"button",onClick:Le,disabled:W,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:S.label,children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:W?"hourglass_empty":S.icon||"auto_awesome"}),S.label]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?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"})}),(Z||x)&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("select",{value:Q,onChange:V=>qe(V.target.value),disabled:F,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(V=>h.jsxs("option",{value:V.id,children:[V.name," - ",V.description]},V.id))}),h.jsx("button",{type:"button",onClick:Re,disabled:F||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:F?"Génération en cours...":"Générer audio TTS",children:h.jsx("span",{className:`material-icons ${F?"animate-pulse text-blue-600":be?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:F?"hourglass_empty":"record_voice_over"})}),be&&h.jsxs(h.Fragment,{children:[h.jsx("audio",{ref:xe,src:be,controls:!0,className:"h-6 w-32"},he),h.jsx("button",{type:"button",onClick:()=>{xe.current&&xe.current.pause(),ue(void 0),m==null||m("",Q)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:h.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]}),s&&h.jsxs("div",{className:"relative",ref:we,children:[h.jsx("button",{type:"button",onClick:()=>R(!B),disabled:E||!(typeof e=="string"?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:E?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),N==="restructure"&&"Restructuring...",N==="proofread"&&"Proofreading...",N==="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"})]})}),B&&!E&&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:_e,children:[h.jsxs("button",{type:"button",onClick:()=>Ae("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:()=>Ae("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:()=>Ae("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:V=>t(V.target.value),onKeyDown:V=>V.stopPropagation(),placeholder:o,rows:l,disabled:E||W,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),ne&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),h.jsx("p",{className:"text-sm text-neutral-600",children:ne})]})]}),h.jsx("div",{className:"mt-4 flex justify-end",children:h.jsx("button",{type:"button",onClick:()=>U(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Yg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const a=y.useRef(null),l=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[f,p]=y.useState(null),[g,m]=y.useState(n),[x,v]=y.useState(0),[b,_]=y.useState({x:0,y:0,width:100,height:100}),[S,D]=y.useState(!1),[k,w]=y.useState(null),[E,M]=y.useState({x:0,y:0}),[N,T]=y.useState({x:0,y:0,width:100,height:100}),B=o==="dark",R=y.useCallback(()=>{const Z=u.current;return Z?x===90||x===270?{width:Z.height,height:Z.width}:{width:Z.width,height:Z.height}:{width:100,height:100}},[x]),C=y.useCallback((Z,be)=>{const te=Z/be,Ae=.05;for(const[_e,ve]of Object.entries(gs))if(ve!==null&&Math.abs(te-ve)/ve<Ae)return _e;return"free"},[]);y.useEffect(()=>{const Z=new Image;Z.crossOrigin="anonymous",Z.onload=()=>{u.current=Z;const be=C(Z.width,Z.height);m(be),d(!1)},Z.onerror=()=>{p("Failed to load image"),d(!1)},Z.src=r},[r,C]);const j=y.useCallback(()=>{const{width:Z,height:be}=R(),te=gs[g];if(te===null){_({x:0,y:0,width:100,height:100});return}const Ae=Z/be;let _e,ve;Ae>te?(ve=100,_e=te/Ae*100):(_e=100,ve=Ae/te*100);const Re=(100-_e)/2,Le=(100-ve)/2;_({x:Re,y:Le,width:_e,height:ve})},[g,R]);y.useEffect(()=>{u.current&&j()},[g,x,j]),y.useEffect(()=>{const Z=l.current,be=u.current;if(!Z||!be||c)return;const te=Z.getContext("2d");if(!te)return;const Ae=a.current;if(!Ae)return;const _e=Ae.clientWidth,ve=Ae.clientHeight-140,{width:Re,height:Le}=R(),qe=Re/Le;let V,O;_e/ve>qe?(O=Math.min(ve,Le),V=O*qe):(V=Math.min(_e,Re),O=V/qe),V>_e&&(V=_e,O=V/qe),O>ve&&(O=ve,V=O*qe),Z.width=V,Z.height=O,te.clearRect(0,0,V,O),te.save(),te.translate(V/2,O/2),te.rotate(x*Math.PI/180);let Ue,se;x===90||x===270?(Ue=O,se=V):(Ue=V,se=O),te.drawImage(be,-Ue/2,-se/2,Ue,se),te.restore(),te.fillStyle="rgba(0, 0, 0, 0.6)";const re=b.x/100*V,oe=b.y/100*O,z=b.width/100*V,de=b.height/100*O;te.fillRect(0,0,V,oe),te.fillRect(0,oe+de,V,O-oe-de),te.fillRect(0,oe,re,de),te.fillRect(re+z,oe,V-re-z,de),te.strokeStyle="#fff",te.lineWidth=2,te.strokeRect(re,oe,z,de),te.strokeStyle="rgba(255, 255, 255, 0.3)",te.lineWidth=1,te.beginPath(),te.moveTo(re+z/3,oe),te.lineTo(re+z/3,oe+de),te.moveTo(re+z*2/3,oe),te.lineTo(re+z*2/3,oe+de),te.moveTo(re,oe+de/3),te.lineTo(re+z,oe+de/3),te.moveTo(re,oe+de*2/3),te.lineTo(re+z,oe+de*2/3),te.stroke();const Ce=14;te.fillStyle="#fff",te.strokeStyle="#333",te.lineWidth=1,[{x:re,y:oe},{x:re+z,y:oe},{x:re,y:oe+de},{x:re+z,y:oe+de}].forEach(dt=>{te.fillRect(dt.x-Ce/2,dt.y-Ce/2,Ce,Ce),te.strokeRect(dt.x-Ce/2,dt.y-Ce/2,Ce,Ce)})},[b,x,c,R]);const F=Z=>{const be=l.current;if(!be)return;const te=be.getBoundingClientRect(),Ae=(Z.clientX-te.left)/te.width*100,_e=(Z.clientY-te.top)/te.height*100,ve=4,Re=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Le of Re)if(Math.abs(Ae-Le.x)<ve&&Math.abs(_e-Le.y)<ve){w(Le.name),M({x:Ae,y:_e}),T({...b});return}Ae>=b.x&&Ae<=b.x+b.width&&_e>=b.y&&_e<=b.y+b.height&&(D(!0),M({x:Ae,y:_e}),T({...b}))},I=Z=>{const be=l.current;if(!be)return;const te=be.getBoundingClientRect(),Ae=(Z.clientX-te.left)/te.width*100,_e=(Z.clientY-te.top)/te.height*100;if(S){const ve=Ae-E.x,Re=_e-E.y;let Le=N.x+ve,qe=N.y+Re;Le=Math.max(0,Math.min(Le,100-N.width)),qe=Math.max(0,Math.min(qe,100-N.height)),_({...N,x:Le,y:qe})}else if(k){const ve=gs[g],{width:Re,height:Le}=R(),qe=Re/Le,V=ve?ve/qe:null;let O={...N};const Ue=Ae-E.x,se=_e-E.y;if(k==="se")O.width=Math.max(10,Math.min(100-O.x,N.width+Ue)),V?(O.height=O.width/V,O.y+O.height>100&&(O.height=100-O.y,O.width=O.height*V)):O.height=Math.max(10,Math.min(100-O.y,N.height+se));else if(k==="sw"){const re=-Ue,oe=Math.max(10,N.width+re),z=N.x+N.width-oe;z>=0&&(O.width=oe,O.x=z,V?(O.height=O.width/V,O.y+O.height>100&&(O.height=100-O.y,O.width=O.height*V,O.x=N.x+N.width-O.width)):O.height=Math.max(10,Math.min(100-O.y,N.height+se)))}else if(k==="ne")if(O.width=Math.max(10,Math.min(100-O.x,N.width+Ue)),V){const re=O.width/V,oe=N.y+N.height-re;oe>=0?(O.height=re,O.y=oe):(O.y=0,O.height=N.y+N.height,O.width=O.height*V)}else{const re=-se,oe=Math.max(10,N.height+re),z=N.y+N.height-oe;z>=0&&(O.height=oe,O.y=z)}else if(k==="nw"){const re=-Ue,oe=Math.max(10,N.width+re),z=N.x+N.width-oe;if(z>=0)if(O.width=oe,O.x=z,V){const de=O.width/V,Ce=N.y+N.height-de;Ce>=0?(O.height=de,O.y=Ce):(O.y=0,O.height=N.y+N.height,O.width=O.height*V,O.x=N.x+N.width-O.width)}else{const de=-se,Ce=Math.max(10,N.height+de),We=N.y+N.height-Ce;We>=0&&(O.height=Ce,O.y=We)}}O.x=Math.max(0,O.x),O.y=Math.max(0,O.y),O.width=Math.min(O.width,100-O.x),O.height=Math.min(O.height,100-O.y),_(O)}},W=()=>{D(!1),w(null)},q=Z=>{v(be=>Z==="right"?(be+90)%360:(be-90+360)%360)},ne=()=>{const Z=u.current;if(!Z)return;const{width:be,height:te}=R(),Ae=b.x/100*be,_e=b.y/100*te,ve=b.width/100*be,Re=b.height/100*te,Le=document.createElement("canvas"),qe=Le.getContext("2d");if(!qe)return;Le.width=ve,Le.height=Re;const V=document.createElement("canvas"),O=V.getContext("2d");O&&(V.width=be,V.height=te,O.save(),O.translate(be/2,te/2),O.rotate(x*Math.PI/180),O.drawImage(Z,-Z.width/2,-Z.height/2,Z.width,Z.height),O.restore(),qe.drawImage(V,Ae,_e,ve,Re,0,0,ve,Re),Le.toBlob(Ue=>{Ue&&e(Ue)},s,i))},U={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:B?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Q={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},H={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${B?"#333":"#ddd"}`,background:B?"#242424":"#fff",flexShrink:0},ie={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ue={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},he={...ue,background:"#E67E22",color:"#fff"},ge={...ue,background:B?"#333":"#e5e5e5",color:B?"#fff":"#333"},we={padding:"10px",borderRadius:"8px",border:"none",background:B?"#333":"#e5e5e5",color:B?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=Z=>({padding:"8px 14px",borderRadius:"6px",border:Z?"2px solid #E67E22":"2px solid transparent",background:Z?"#E67E22":B?"#333":"#e5e5e5",color:Z?"#fff":B?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...U,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:B?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...U,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...ge,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:a,style:U,children:[h.jsx("div",{style:Q,children:h.jsx("canvas",{ref:l,style:{cursor:S?"grabbing":k?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:I,onMouseUp:W,onMouseLeave:W})}),h.jsxs("div",{style:H,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(Z=>h.jsx("button",{onClick:()=>m(Z),style:xe(g===Z),children:Z==="free"?"Libre":Z},Z))}),h.jsxs("div",{style:ie,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>q("left"),style:we,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",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:()=>q("right"),style:we,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",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:ge,children:"Annuler"}),h.jsx("button",{onClick:ne,style:he,children:"Enregistrer"})]})]})]})]})}var Qg={value:()=>{}};function la(){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 Jg(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=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Jg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Xg(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 Xg(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]=Qg,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 zl={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 _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 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 e0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Zc(r){var e=_i(r);return(e.local?e0:Zg)(e)}function t0(){}function ua(r){return r==null?t0:function(){return this.querySelector(r)}}function r0(r){typeof r!="function"&&(r=ua(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,a=n[s]=new Array(o),l,u,c=0;c<o;++c)(l=i[c])&&(u=r.call(l,l.__data__,c,i))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Dt(n,this._parents)}function n0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function s0(){return[]}function ed(r){return r==null?s0:function(){return this.querySelectorAll(r)}}function i0(r){return function(){return n0(r.apply(this,arguments))}}function o0(r){typeof r=="function"?r=i0(r):r=ed(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(n.push(r.call(l,l.__data__,u,o)),s.push(l));return new Dt(n,s)}function td(r){return function(){return this.matches(r)}}function rd(r){return function(e){return e.matches(r)}}var a0=Array.prototype.find;function l0(r){return function(){return a0.call(this.children,r)}}function u0(){return this.firstElementChild}function c0(r){return this.select(r==null?u0:l0(typeof r=="function"?r:rd(r)))}var d0=Array.prototype.filter;function f0(){return Array.from(this.children)}function h0(r){return function(){return d0.call(this.children,r)}}function p0(r){return this.selectAll(r==null?f0:h0(typeof r=="function"?r:rd(r)))}function g0(r){typeof r!="function"&&(r=td(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,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new Dt(n,this._parents)}function nd(r){return new Array(r.length)}function m0(){return new Dt(this._enter||this._groups.map(nd),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 y0(r){return function(){return r}}function x0(r,e,t,n,s,i){for(var o=0,a,l=e.length,u=i.length;o<u;++o)(a=e[o])?(a.__data__=i[o],n[o]=a):t[o]=new Qs(r,i[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function b0(r,e,t,n,s,i,o){var a,l,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(a=0;a<c;++a)(l=e[a])&&(f[a]=p=o.call(l,l.__data__,a,e)+"",u.has(p)?s[a]=l:u.set(p,l));for(a=0;a<d;++a)p=o.call(r,i[a],a,i)+"",(l=u.get(p))?(n[a]=l,l.__data__=i[a],u.delete(p)):t[a]=new Qs(r,i[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(f[a])===l&&(s[a]=l)}function v0(r){return r.__data__}function _0(r,e){if(!arguments.length)return Array.from(this,v0);var t=e?b0:x0,n=this._parents,s=this._groups;typeof r!="function"&&(r=y0(r));for(var i=s.length,o=new Array(i),a=new Array(i),l=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],f=d.length,p=w0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=a[u]=new Array(g),x=o[u]=new Array(g),v=l[u]=new Array(f);t(c,d,m,x,v,p,e);for(var b=0,_=0,S,D;b<g;++b)if(S=m[b]){for(b>=_&&(_=b+1);!(D=x[_])&&++_<g;);S._next=D||null}}return o=new Dt(o,n),o._enter=a,o._exit=l,o}function w0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function C0(){return new Dt(this._exit||this._groups.map(nd),this._parents)}function S0(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 k0(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),a=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,f=a[l]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;l<s;++l)a[l]=t[l];return new Dt(a,this._parents)}function E0(){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 D0(r){r||(r=A0);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],a=o.length,l=s[i]=new Array(a),u,c=0;c<a;++c)(u=o[c])&&(l[c]=u);l.sort(e)}return new Dt(s,this._parents).order()}function A0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function T0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function N0(){return Array.from(this)}function B0(){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 j0(){let r=0;for(const e of this)++r;return r}function M0(){return!this.node()}function R0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,a;i<o;++i)(a=s[i])&&r.call(a,a.__data__,i,s);return this}function F0(r){return function(){this.removeAttribute(r)}}function L0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function P0(r,e){return function(){this.setAttribute(r,e)}}function I0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function z0(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 $0(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?L0:F0:typeof e=="function"?t.local?z0:O0:t.local?I0:P0)(t,e))}function sd(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function q0(r){return function(){this.style.removeProperty(r)}}function U0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function W0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function H0(r,e,t){return arguments.length>1?this.each((e==null?q0:typeof e=="function"?W0:U0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||sd(r).getComputedStyle(r,null).getPropertyValue(e)}function V0(r){return function(){delete this[r]}}function G0(r,e){return function(){this[r]=e}}function K0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Y0(r,e){return arguments.length>1?this.each((e==null?V0:typeof e=="function"?K0:G0)(r,e)):this.node()[r]}function id(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new od(r)}function od(r){this._node=r,this._names=id(r.getAttribute("class")||"")}od.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 ad(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function Q0(r){return function(){ad(this,r)}}function J0(r){return function(){ld(this,r)}}function X0(r,e){return function(){(e.apply(this,arguments)?ad:ld)(this,r)}}function Z0(r,e){var t=id(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?X0:e?Q0:J0)(t,e))}function em(){this.textContent=""}function tm(r){return function(){this.textContent=r}}function rm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function nm(r){return arguments.length?this.each(r==null?em:(typeof r=="function"?rm:tm)(r)):this.node().textContent}function sm(){this.innerHTML=""}function im(r){return function(){this.innerHTML=r}}function om(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function am(r){return arguments.length?this.each(r==null?sm:(typeof r=="function"?om:im)(r)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function um(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function dm(){return this.each(cm)}function fm(r){var e=typeof r=="function"?r:Zc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function hm(){return null}function pm(r,e){var t=typeof r=="function"?r:Zc(r),n=e==null?hm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function gm(){var r=this.parentNode;r&&r.removeChild(this)}function mm(){return this.each(gm)}function ym(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function xm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(r){return this.select(r?xm:ym)}function vm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function _m(r){return function(e){r.call(this,e,this.__data__)}}function wm(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 Sm(r,e,t){return function(){var n=this.__on,s,i=_m(e);if(n){for(var o=0,a=n.length;o<a;++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 km(r,e,t){var n=wm(r+""),s,i=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(s=0,c=a[l];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(a=e?Sm:Cm,s=0;s<i;++s)this.each(a(n[s],e,t));return this}function ud(r,e,t){var n=sd(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 Em(r,e){return function(){return ud(this,r,e)}}function Dm(r,e){return function(){return ud(this,r,e.apply(this,arguments))}}function Am(r,e){return this.each((typeof e=="function"?Dm:Em)(r,e))}function*Tm(){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 cd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],cd)}function Nm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:r0,selectAll:o0,selectChild:c0,selectChildren:p0,filter:g0,data:_0,enter:m0,exit:C0,join:S0,merge:k0,selection:Nm,order:E0,sort:D0,call:T0,nodes:N0,node:B0,size:j0,empty:M0,each:R0,attr:$0,style:H0,property:Y0,classed:Z0,text:nm,html:am,raise:um,lower:dm,append:fm,insert:pm,remove:mm,clone:bm,datum:vm,on:km,dispatch:Am,[Symbol.iterator]:Tm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],cd)}function Bm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=Bm(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 vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function jm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Mm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),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 da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function dd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Lm=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Pm=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),Im=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),zm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${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};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:$m,formatHsl:qm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function $m(){return this.rgb().formatHex8()}function qm(){return fd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Rm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new wt(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=Fm.exec(r))?new wt(e[1],e[2],e[3],1):(e=Lm.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Pm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Im.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=zm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Wl(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Um(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function wo(r,e,t,n){return arguments.length===1?Um(r):new wt(r,e,t,n??1)}function wt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(wt,wo,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new wt(Tr(this.r),Tr(this.g),Tr(this.b),Xs(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:Hl,formatHex:Hl,formatHex8:Wm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Wm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(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 Pt(r,e,t,n)}function fd(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)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,a=i-s,l=(i+s)/2;return a?(e===i?o=(t-n)/a+(t<n)*6:t===i?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?i+s:2-i-s,o*=60):a=l>0&&l<1?0:o,new Pt(o,a,l,r.opacity)}function Hm(r,e,t,n){return arguments.length===1?fd(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,Hm,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(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 wt(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 Pt(Kl(this.h),ys(this.s),ys(this.l),Xs(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=Xs(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 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 hd=r=>()=>r;function Vm(r,e){return function(t){return r+t*e}}function Gm(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 Km(r){return(r=+r)==1?pd:function(e,t){return t-e?Gm(e,t,r):hd(isNaN(e)?t:e)}}function pd(r,e){var t=e-r;return t?Vm(r,t):hd(isNaN(r)?e:r)}const Yl=function r(e){var t=Km(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),a=t(s.g,i.g),l=t(s.b,i.b),u=pd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=a(c),s.b=l(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 Ym(r){return function(){return r}}function Qm(r){return function(e){return r(e)+""}}function Jm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,a=[],l=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?Qm(l[0].x):Ym(e):(e=l.length,function(u){for(var c=0,d;c<e;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gd(r,e,t,n,s,i){var o,a,l;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(l=r*t+e*n)&&(t-=r*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),r*n<e*t&&(r=-r,e=-e,l=-l,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(l)*Ql,scaleX:o,scaleY:a}}var xs;function Xm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:gd(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,gd(r.a,r.b,r.c,r.d,r.e,r.f))}function md(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 a(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 l(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),a(u.skewX,c.skewX,d,f),l(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 ey=md(Xm,"px, ","px)","deg)"),ty=md(Zm,", ",")",")"),ry=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function ny(r){return((r=Math.exp(r))-1/r)/2}function sy(r){return((r=Math.exp(2*r))-1)/(r+1)}const iy=function r(e,t,n){function s(i,o){var a=i[0],l=i[1],u=i[2],c=o[0],d=o[1],f=o[2],p=c-a,g=d-l,m=p*p+g*g,x,v;if(m<ry)v=Math.log(f/u)/e,x=function(w){return[a+w*p,l+w*g,u*Math.exp(e*w*v)]};else{var b=Math.sqrt(m),_=(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(_*_+1)-_),k=Math.log(Math.sqrt(S*S+1)-S);v=(k-D)/e,x=function(w){var E=w*v,M=Jl(D),N=u/(t*b)*(M*sy(e*E+D)-ny(D));return[a+N*p,l+N*g,u*M/Jl(e*E+D)]}}return x.duration=v*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,l=a*a;return r(o,a,l)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,yd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,xd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(xd(oy),Lr=Wn.now()+wi)}function oy(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=bd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function bd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ay(){fa(),++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{ay()}finally{nn=0,uy(),Lr=0}}function ly(){var r=Wn.now(),e=r-ei;e>yd&&(wi-=e,ei=r)}function uy(){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,ko(n)}function ko(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(ly,yd)),nn=1,xd(Xl))}}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 cy=la("start","end","cancel","interrupt"),dy=[],vd=0,eu=1,Eo=2,Ss=3,tu=4,Do=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;fy(r,t,{name:e,index:n,group:s,on:cy,tween:dy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vd})}function ha(r,e){var t=qt(r,e);if(t.state>vd)throw new Error("too late; already scheduled");return t}function Xt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function fy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=bd(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 l();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(a,t.delay,t.time),a(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){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 a(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(l),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),l())}function l(){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>Eo&&n.state<Do,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 hy(r){return this.each(function(){Es(this,r)})}function py(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,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function gy(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 a={name:e,value:t},l=0,u=s.length;l<u;++l)if(s[l].name===e){s[l]=a;break}l===u&&s.push(a)}i.tween=s}}function my(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(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?py:gy)(t,r,e))}function pa(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 qt(s,n).value[e]}}function _d(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Jm)(r,e)}function yy(r){return function(){this.removeAttribute(r)}}function xy(r){return function(){this.removeAttributeNS(r.space,r.local)}}function by(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 vy(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 _y(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(r):(o=this.getAttribute(r),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function wy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Cy(r,e){var t=_i(r),n=t==="transform"?ty:_d;return this.attrTween(r,typeof e=="function"?(t.local?wy:_y)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?xy:yy)(t):(t.local?vy:by)(t,n,e))}function Sy(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function ky(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Ey(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Sy(r,i)),t}return s._value=e,s}function Ay(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?Ey:Dy)(n,e))}function Ty(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function Ny(r,e){return e=+e,function(){ha(this,r).delay=e}}function By(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ty:Ny)(e,r)):qt(this.node(),e).delay}function jy(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function My(r,e){return e=+e,function(){Xt(this,r).duration=e}}function Ry(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?jy:My)(e,r)):qt(this.node(),e).duration}function Fy(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function Ly(r){var e=this._id;return arguments.length?this.each(Fy(e,r)):qt(this.node(),e).ease}function Py(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function Iy(r){if(typeof r!="function")throw new Error;return this.each(Py(this._id,r))}function Oy(r){typeof r!="function"&&(r=td(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,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new ir(n,this._parents,this._name,this._id)}function zy(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),a=0;a<i;++a)for(var l=e[a],u=t[a],c=l.length,d=o[a]=new Array(c),f,p=0;p<c;++p)(f=l[p]||u[p])&&(d[p]=f);for(;a<n;++a)o[a]=e[a];return new ir(o,this._parents,this._name,this._id)}function $y(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 qy(r,e,t){var n,s,i=$y(e)?ha:Xt;return function(){var o=i(this,r),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function Uy(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(qy(t,r,e))}function Wy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Hy(){return this.on("end.remove",Wy(this._id))}function Vy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,u=i[o]=new Array(l),c,d,f=0;f<l;++f)(c=a[f])&&(d=r.call(c,c.__data__,f,a))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ed(r));for(var n=this._groups,s=n.length,i=[],o=[],a=0;a<s;++a)for(var l=n[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var f=r.call(c,c.__data__,d,l),p,g=qt(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 Ky=ss.prototype.constructor;function Yy(){return new Ky(this._groups,this._parents)}function Qy(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 wd(r){return function(){this.style.removeProperty(r)}}function Jy(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 Xy(r,e,t){var n,s,i;return function(){var o=rn(this,r),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(r),rn(this,r))),o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a))}}function Zy(r,e){var t,n,s,i="style."+e,o="end."+i,a;return function(){var l=Xt(this,r),u=l.on,c=l.value[i]==null?a||(a=wd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),l.on=n}}function e2(r,e,t){var n=(r+="")=="transform"?ey:_d;return e==null?this.styleTween(r,Qy(r,n)).on("end.style."+r,wd(r)):typeof e=="function"?this.styleTween(r,Xy(r,n,pa(this,"style."+r,e))).each(Zy(this._id,r)):this.styleTween(r,Jy(r,n,e),t).on("end.style."+r,null)}function t2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function r2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&t2(r,o,t)),n}return i._value=e,i}function n2(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,r2(r,e,t??""))}function s2(r){return function(){this.textContent=r}}function i2(r){return function(){var e=r(this);this.textContent=e??""}}function o2(r){return this.tween("text",typeof r=="function"?i2(pa(this,"text",r)):s2(r==null?"":r+""))}function a2(r){return function(e){this.textContent=r.call(this,e)}}function l2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&a2(s)),e}return n._value=r,n}function u2(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,l2(r))}function c2(){for(var r=this._name,e=this._id,t=Cd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var c=qt(l,e);Ci(l,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 d2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var a={value:o},l={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(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),s===0&&i()})}var f2=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Cd(){return++f2}var tr=ss.prototype;ir.prototype={constructor:ir,select:Vy,selectAll:Gy,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:Oy,merge:zy,selection:Yy,transition:c2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:Uy,attr:Cy,attrTween:Ay,style:e2,styleTween:n2,text:o2,textTween:u2,remove:Hy,tween:my,delay:By,duration:Ry,ease:Ly,easeVarying:Iy,end:d2,[Symbol.iterator]:tr[Symbol.iterator]};function h2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var p2={time:null,delay:0,duration:250,ease:h2};function g2(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 m2(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=Cd(),(t=p2).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Ci(l,r,e,u,o,t||g2(l,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=hy;ss.prototype.transition=m2;const bs=r=>()=>r;function y2(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 x2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function b2(){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 v2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function _2(){return navigator.maxTouchPoints||"ontouchstart"in this}function w2(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 C2(){var r=x2,e=b2,t=w2,n=v2,s=_2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=iy,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(C){C.property("__zoom",ru).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",N).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(C,j,F,I){var W=C.selection?C.selection():C;W.property("__zoom",ru),C!==W?D(C,j,F,I):W.interrupt().each(function(){k(this,arguments).event(I).start().zoom(null,typeof j=="function"?j.apply(this,arguments):j).end()})},v.scaleBy=function(C,j,F,I){v.scaleTo(C,function(){var W=this.__zoom.k,q=typeof j=="function"?j.apply(this,arguments):j;return W*q},F,I)},v.scaleTo=function(C,j,F,I){v.transform(C,function(){var W=e.apply(this,arguments),q=this.__zoom,ne=F==null?S(W):typeof F=="function"?F.apply(this,arguments):F,U=q.invert(ne),Q=typeof j=="function"?j.apply(this,arguments):j;return t(_(b(q,Q),ne,U),W,o)},F,I)},v.translateBy=function(C,j,F,I){v.transform(C,function(){return t(this.__zoom.translate(typeof j=="function"?j.apply(this,arguments):j,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,I)},v.translateTo=function(C,j,F,I,W){v.transform(C,function(){var q=e.apply(this,arguments),ne=this.__zoom,U=I==null?S(q):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(U[0],U[1]).scale(ne.k).translate(typeof j=="function"?-j.apply(this,arguments):-j,typeof F=="function"?-F.apply(this,arguments):-F),q,o)},I,W)};function b(C,j){return j=Math.max(i[0],Math.min(i[1],j)),j===C.k?C:new nr(j,C.x,C.y)}function _(C,j,F){var I=j[0]-F[0]*C.k,W=j[1]-F[1]*C.k;return I===C.x&&W===C.y?C:new nr(C.k,I,W)}function S(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function D(C,j,F,I){C.on("start.zoom",function(){k(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(I).end()}).tween("zoom",function(){var W=this,q=arguments,ne=k(W,q).event(I),U=e.apply(W,q),Q=F==null?S(U):typeof F=="function"?F.apply(W,q):F,H=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),ie=W.__zoom,ue=typeof j=="function"?j.apply(W,q):j,he=l(ie.invert(Q).concat(H/ie.k),ue.invert(Q).concat(H/ue.k));return function(ge){if(ge===1)ge=ue;else{var we=he(ge),xe=H/we[2];ge=new nr(xe,Q[0]-we[0]*xe,Q[1]-we[1]*xe)}ne.zoom(null,ge)}})}function k(C,j,F){return!F&&C.__zooming||new w(C,j)}function w(C,j){this.that=C,this.args=j,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,j),this.taps=0}w.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,j){return this.mouse&&C!=="mouse"&&(this.mouse[1]=j.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=j.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=j.invert(this.touch1[0])),this.that.__zoom=j,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var j=Lt(this.that).datum();u.call(C,this.that,new y2(C,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),j)}};function E(C,...j){if(!r.apply(this,arguments))return;var F=k(this,j).event(C),I=this.__zoom,W=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),q=wr(C);if(F.wheel)(F.mouse[0][0]!==q[0]||F.mouse[0][1]!==q[1])&&(F.mouse[1]=I.invert(F.mouse[0]=q)),clearTimeout(F.wheel);else{if(I.k===W)return;F.mouse=[q,I.invert(q)],Es(this),F.start()}xn(C),F.wheel=setTimeout(ne,g),F.zoom("mouse",t(_(b(I,W),F.mouse[0],F.mouse[1]),F.extent,o));function ne(){F.wheel=null,F.end()}}function M(C,...j){if(f||!r.apply(this,arguments))return;var F=C.currentTarget,I=k(this,j,!0).event(C),W=Lt(C.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",H,!0),q=wr(C,F),ne=C.clientX,U=C.clientY;jm(C.view),Wi(C),I.mouse=[q,this.__zoom.invert(q)],Es(this),I.start();function Q(ie){if(xn(ie),!I.moved){var ue=ie.clientX-ne,he=ie.clientY-U;I.moved=ue*ue+he*he>m}I.event(ie).zoom("mouse",t(_(I.that.__zoom,I.mouse[0]=wr(ie,F),I.mouse[1]),I.extent,o))}function H(ie){W.on("mousemove.zoom mouseup.zoom",null),Mm(ie.view,I.moved),xn(ie),I.event(ie).end()}}function N(C,...j){if(r.apply(this,arguments)){var F=this.__zoom,I=wr(C.changedTouches?C.changedTouches[0]:C,this),W=F.invert(I),q=F.k*(C.shiftKey?.5:2),ne=t(_(b(F,q),I,W),e.apply(this,j),o);xn(C),a>0?Lt(this).transition().duration(a).call(D,ne,I,C):Lt(this).call(v.transform,ne,I,C)}}function T(C,...j){if(r.apply(this,arguments)){var F=C.touches,I=F.length,W=k(this,j,C.changedTouches.length===I).event(C),q,ne,U,Q;for(Wi(C),ne=0;ne<I;++ne)U=F[ne],Q=wr(U,this),Q=[Q,this.__zoom.invert(Q),U.identifier],W.touch0?!W.touch1&&W.touch0[2]!==Q[2]&&(W.touch1=Q,W.taps=0):(W.touch0=Q,q=!0,W.taps=1+!!c);c&&(c=clearTimeout(c)),q&&(W.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Es(this),W.start())}}function B(C,...j){if(this.__zooming){var F=k(this,j).event(C),I=C.changedTouches,W=I.length,q,ne,U,Q;for(xn(C),q=0;q<W;++q)ne=I[q],U=wr(ne,this),F.touch0&&F.touch0[2]===ne.identifier?F.touch0[0]=U:F.touch1&&F.touch1[2]===ne.identifier&&(F.touch1[0]=U);if(ne=F.that.__zoom,F.touch1){var H=F.touch0[0],ie=F.touch0[1],ue=F.touch1[0],he=F.touch1[1],ge=(ge=ue[0]-H[0])*ge+(ge=ue[1]-H[1])*ge,we=(we=he[0]-ie[0])*we+(we=he[1]-ie[1])*we;ne=b(ne,Math.sqrt(ge/we)),U=[(H[0]+ue[0])/2,(H[1]+ue[1])/2],Q=[(ie[0]+he[0])/2,(ie[1]+he[1])/2]}else if(F.touch0)U=F.touch0[0],Q=F.touch0[1];else return;F.zoom("touch",t(_(ne,U,Q),F.extent,o))}}function R(C,...j){if(this.__zooming){var F=k(this,j).event(C),I=C.changedTouches,W=I.length,q,ne;for(Wi(C),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),q=0;q<W;++q)ne=I[q],F.touch0&&F.touch0[2]===ne.identifier?delete F.touch0:F.touch1&&F.touch1[2]===ne.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(ne=wr(ne,this),Math.hypot(d[0]-ne[0],d[1]-ne[1])<x)){var U=Lt(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return v.wheelDelta=function(C){return arguments.length?(n=typeof C=="function"?C:bs(+C),v):n},v.filter=function(C){return arguments.length?(r=typeof C=="function"?C:bs(!!C),v):r},v.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:bs(!!C),v):s},v.extent=function(C){return arguments.length?(e=typeof C=="function"?C:bs([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),v):e},v.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],v):[i[0],i[1]]},v.translateExtent=function(C){return arguments.length?(o[0][0]=+C[0][0],o[1][0]=+C[1][0],o[0][1]=+C[0][1],o[1][1]=+C[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(C){return arguments.length?(t=C,v):t},v.duration=function(C){return arguments.length?(a=+C,v):a},v.interpolate=function(C){return arguments.length?(l=C,v):l},v.on=function(){var C=u.on.apply(u,arguments);return C===u?v:C},v.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,v):Math.sqrt(m)},v.tapDistance=function(C){return arguments.length?(x=+C,v):x},v}function Sd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,a=y.useRef(null),l=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!a.current)return;const x=C2().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 _={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(_),o==null||o(_)});l.current=x;const v=Lt(a.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]),y.useEffect(()=>{l.current&&l.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=y.useCallback((x,v,b,_=!0)=>{if(!a.current||!l.current)return;const S=Lt(a.current),D=ri.translate(x,v).scale(b);S.call(l.current.transform,D)},[]),f=y.useCallback(()=>{!a.current||!l.current||Lt(a.current).call(l.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!a.current||!l.current||Lt(a.current).call(l.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,v=50)=>{if(!a.current||!l.current||x.length===0)return;const _=a.current.getBoundingClientRect();let S=1/0,D=1/0,k=-1/0,w=-1/0;for(const I of x){const W=I.width||200,q=I.height||100;S=Math.min(S,I.x),D=Math.min(D,I.y),k=Math.max(k,I.x+W),w=Math.max(w,I.y+q)}const E=k-S,M=w-D,N=(_.width-v*2)/E,T=(_.height-v*2)/M,B=Math.min(N,T,t),R=(S+k)/2,C=(D+w)/2,j=_.width/2-R*B,F=_.height/2-C*B;d(j,F,B,!0)},[t,d]);return{transform:u,containerRef:a,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function kd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,a]=y.useState(null),[l,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),f=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((_,S)=>{const D=g.current;return{x:(_-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=y.useCallback((_,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,k=parseFloat(D.dataset.x||"0"),w=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:k,nodeY:w},p.current={x:k,y:w},a(_),u(!0),d({x:0,y:0}),t==null||t(_)},[i,m,t]),v=y.useCallback(_=>{if(!l||!o||!f.current)return;const S=g.current,D=f.current,k=_.clientX-D.x,w=_.clientY-D.y,E=k/S.k,M=w/S.k,N=D.nodeX+E,T=D.nodeY+M;p.current={x:N,y:T},d({x:E,y:M}),n==null||n(o,N,T,E,M)},[l,o,n]),b=y.useCallback(()=>{if(!l||!o)return;const _=p.current;s==null||s(o,_.x,_.y),a(null),u(!1),d({x:0,y:0}),f.current=null},[l,o,s]);return y.useEffect(()=>{if(!l)return;const _=D=>{v(D)},S=()=>{b()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",S)}},[l,v,b]),{draggedNodeId:o,isDragging:l,dragOffset:c,startDrag:x,updateDrag:v,endDrag:b}}function Ed(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,a]=y.useState(new Set),l=s!==void 0,u=l?new Set(s):o,c=l?N=>{const T=typeof N=="function"?N(u):N;i==null||i(Array.from(T))}:a,[d,f]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),v=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{v.current=t},[t]);const b=y.useCallback((N,T)=>{const B=x.current;return{x:(N-B.x)/B.k,y:(T-B.y)/B.k}},[]),_=y.useCallback((N,T)=>{const B=v.current.get(N);if(!B)return!1;const R=B.width||200,C=B.height||100;return B.x<T.x+T.width&&B.x+R>T.x&&B.y<T.y+T.height&&B.y+C>T.y},[]),S=y.useCallback(N=>{if(n||N.target.closest("[data-qmap-node]"))return;N.preventDefault();const B=b(N.clientX,N.clientY);m.current=B,f({x:B.x,y:B.y,width:0,height:0}),g(!0),N.shiftKey||c(new Set)},[n,b]),D=y.useCallback(N=>{if(!p||!m.current)return;const T=m.current,B=b(N.clientX,N.clientY),R={x:Math.min(T.x,B.x),y:Math.min(T.y,B.y),width:Math.abs(B.x-T.x),height:Math.abs(B.y-T.y)};f(R);const C=new Set;for(const[j]of v.current)_(j,R)&&C.add(j);c(C)},[p,b,_]),k=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const N=B=>{D(B)},T=()=>{k()};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",T)}},[p,D,k]);const w=y.useCallback((N,T=!1)=>{c(B=>{const R=new Set(T?B:[]);return B.has(N)&&T?R.delete(N):R.add(N),i==null||i(Array.from(R)),R})},[i]),E=y.useCallback(()=>{const N=new Set(v.current.keys());c(N),i==null||i(Array.from(N))},[i]),M=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:D,endSelection:k,toggleSelect:w,selectAll:E,clearSelection:M}}const Dd=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:a,onDoubleClick:l,onContextMenu:u,nodeRef:c,children:d}){const f=y.useCallback(v=>{i&&v.button===0&&o(e,v)},[e,i,o]),p=y.useCallback(v=>{s||a==null||a(v)},[s,a]),g=y.useCallback(v=>{v.stopPropagation(),l==null||l(v)},[l]),m=y.useCallback(v=>{v.preventDefault(),v.stopPropagation(),u==null||u(v)},[u]),x=t.rotation||0;return h.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:f,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Ad(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return k2(n,s);case"bezier":default:return S2(n,s)}}function S2(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 a,l,u,c;return o?(a=r.x+i*Math.sign(t),l=r.y,u=e.x-i*Math.sign(t),c=e.y):(a=r.x,l=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${a} ${l}, ${u} ${c}, ${e.x} ${e.y}`}function k2(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 ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function E2(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const a=t/2,l=n/2,u=Math.abs(o/(i||.001)),c=l/a;let d,f;return u<c?(d=s.x+(i>0?a:-a),f=s.y+o*a/Math.abs(i)):(f=s.y+(o>0?l:-l),d=s.x+i*l/Math.abs(o)),{x:d,y:f}}function D2(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 ga(r)}}function A2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function T2(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 N2(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,a=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+a)}return{x:e,y:t,width:n-e,height:s-t}}function B2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Td=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:a}){const[l,u]=y.useState(!1),c=y.useMemo(()=>Ad(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),a==null||a(e,x)},[e,a]),f=y.useCallback(()=>{u(!0)},[]),p=y.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:a?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:l?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&h.jsx(M2,{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 M2({pathD:r,label:e,color:t}){const n=y.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 Nd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const a=y.useMemo(()=>e.filter(l=>t.has(l.source)&&t.has(l.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:a.map(l=>{const u=t.get(l.source),c=t.get(l.target);return h.jsx(Td,{edge:l,sourcePosition:u,targetPosition:c,style:l.style||n,color:l.color||s,width:l.width||i,onClick:o},l.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Bd=y.memo(function({box:e,transform:t}){const n=y.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}})}),R2=200,F2=100,L2="bezier",P2="#94a3b8",I2=2,O2=.1,z2=4;function $2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=R2,defaultNodeHeight:i=F2,onNodeMove:o,onNodeClick:a,onNodeDoubleClick:l,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=O2,maxZoom:x=z2,initialTransform:v,defaultEdgeStyle:b=L2,defaultEdgeColor:_=P2,defaultEdgeWidth:S=I2,draggable:D=!0,selectable:k=!0,zoomable:w=!0,pannable:E=!0,className:M="",style:N,background:T="#f8fafc",showGrid:B=!1,gridSize:R=20}){const C=r.data||{positions:{}},j=C.positions||{},F=y.useMemo(()=>{const se=new Map;for(const re of e){const oe=j[re._id]||{x:0,y:0};se.set(re._id,{x:oe.x,y:oe.y,width:oe.width||s,height:oe.height||i,rotation:oe.rotation||0})}return se},[e,j,s,i]),{transform:I,containerRef:W,zoomIn:q,zoomOut:ne,resetZoom:U,fitToContent:Q}=Sd({minZoom:m,maxZoom:x,initialTransform:v||C.transform,zoomable:w,pannable:E,onTransformChange:se=>{g==null||g(se);const re={...C,transform:se};p==null||p(re)}}),[H,ie]=y.useState(new Map),[ue,he]=y.useState(new Map),ge=y.useRef(new Map);y.useEffect(()=>{const se=new Map;ge.current.forEach((oe,z)=>{if(oe){const de=oe.getBoundingClientRect();se.set(z,{width:de.width,height:de.height})}}),e.some(oe=>{const z=se.get(oe._id),de=ue.get(oe._id);return z?de?z.width!==de.width||z.height!==de.height:!0:!1})&&he(se)},[e,ue]);const{draggedNodeId:we,startDrag:xe}=kd({transform:I,disabled:!D,onDragStart:se=>{const re=F.get(se);re&&ie(new Map([[se,{x:re.x,y:re.y}]]))},onDragMove:(se,re,oe)=>{ie(new Map([[se,{x:re,y:oe}]]))},onDragEnd:(se,re,oe)=>{ie(new Map),o==null||o(se,re,oe)}}),{selectedIds:Z,selectionBox:be,isSelecting:te,startSelection:Ae,toggleSelect:_e,clearSelection:ve}=Ed({transform:I,nodePositions:F,disabled:!k,controlledSelectedIds:c,onSelectionChange:d}),Re=y.useCallback(se=>{const re=F.get(se)||{x:0,y:0,width:s,height:i},oe=H.get(se),z=ue.get(se),de=(z==null?void 0:z.width)||re.width||s,Ce=(z==null?void 0:z.height)||re.height||i;return oe?{...re,x:oe.x,y:oe.y,width:de,height:Ce}:{...re,width:de,height:Ce}},[F,H,ue,s,i]),Le=y.useMemo(()=>{const se=new Map;for(const re of F.keys())se.set(re,Re(re));return se},[F,Re]),qe=y.useCallback((se,re)=>{_e(se._id,re.shiftKey),a==null||a(se,re)},[_e,a]),V=y.useCallback(se=>{se.target.closest("[data-qmap-node]")||ve()},[ve]),O=y.useCallback(se=>{se.button===0&&(se.target.closest("[data-qmap-node]")||Ae(se))},[Ae]),Ue=B?`
|
|
185
|
+
${G}`:G)},Ne=async G=>{if(!(!(typeof e=="string"?e:"").trim()||k||!s)){M(!0),T(G),R(!1);try{const z=await s(G,e);t(z)}catch(z){console.error(`${G} failed:`,z)}finally{M(!1),T(null)}}},be=()=>{setTimeout(()=>{var G;(G=ye.current)!=null&&G.contains(document.activeElement)||R(!1)},150)},ve=async()=>{if(!(!C.trim()||k||!i)){M(!0),T(C);try{const G=await i(C,e);t(G),j("")}catch(G){console.error("AI prompt failed:",G)}finally{M(!1),T(null)}}},Le=async()=>{if(!(typeof e=="string"?e:"").trim()||F)return;if(!(Q||x)){console.warn("TTS: No generation mode available",{integratedTTS:Q,hasCallback:!!x,llmClient:!!u,graphClient:!!c,nodeId:d,audioFilename:f}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}xe.current&&(xe.current.pause(),xe.current.currentTime=0),I(!0);try{if(Q&&u&&c&&d&&f){console.log("TTS: Generating audio...",{voice:Z,textLength:e.length});const z=await u.tts(e,{voice:Z});console.log("TTS: Audio generated, uploading...",{audioLength:z==null?void 0:z.length});const Pe=atob(z),He=new Uint8Array(Pe.length);for(let de=0;de<Pe.length;de++)He[de]=Pe.charCodeAt(de);const K=new Blob([He],{type:"audio/mpeg"}),re=new File([K],f,{type:"audio/mpeg"});await c.uploadFile(d,f,re),console.log("TTS: Upload complete",{nodeId:d,audioFilename:f}),ge(Date.now()),fe(f),m==null||m(f,Z)}else x&&(await x(e,Z),ge(Date.now()))}catch(z){console.error("TTS generation failed:",z),alert("Erreur TTS: "+(z instanceof Error?z.message:"Erreur inconnue"))}finally{I(!1)}},Me=async()=>{if(!(!u||!D||q)){if(!(E!=null&&E.trim())){W(v||"Le texte source est requis pour la génération.");return}ee(!0),W(null);try{const G=await u.chat([{role:"system",content:D},{role:"user",content:E}]);t(G)}catch(G){W(G instanceof Error?G.message:"Erreur de génération")}finally{ee(!1)}}},$e=G=>{H(G),w==null||w(G)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${l}`,children:[h.jsx(Xc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:se,hideSaveButton:!0,variant:"div"}),i&&h.jsxs("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200",children:[h.jsx("textarea",{value:C,onChange:G=>j(G.target.value),onKeyDown:G=>{G.stopPropagation(),G.key==="Enter"&&G.ctrlKey&&(G.preventDefault(),ve())},placeholder:"Instructions AI... (Ctrl+Enter pour envoyer)",disabled:k,rows:5,className:"flex-1 pl-0 pr-2 py-2 text-sm border-0 resize-y min-h-[80px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50"}),h.jsx("button",{type:"button",onClick:ve,disabled:k||!C.trim(),className:"self-start p-2 text-neutral-700 hover:text-neutral-900 transition-colors disabled:opacity-30",title:"Envoyer (Ctrl+Enter)",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:k?"hourglass_empty":"smart_toy"})})]}),(r||s||(typeof e=="string"?e:"").trim()||Q||x||S)&&h.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[r&&h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),S&&u&&D&&h.jsxs("button",{type:"button",onClick:Me,disabled:q,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:S.label,children:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:q?"hourglass_empty":S.icon||"auto_awesome"}),S.label]})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?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"})}),(Q||x)&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("select",{value:Z,onChange:G=>$e(G.target.value),disabled:F,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(G=>h.jsxs("option",{value:G.id,children:[G.name," - ",G.description]},G.id))}),h.jsx("button",{type:"button",onClick:Le,disabled:F||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:F?"Génération en cours...":"Générer audio TTS",children:h.jsx("span",{className:`material-icons ${F?"animate-pulse text-blue-600":Se?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:F?"hourglass_empty":"record_voice_over"})}),Se&&h.jsxs(h.Fragment,{children:[h.jsx("audio",{ref:xe,src:Se,controls:!0,className:"h-6 w-32"},ae),h.jsx("button",{type:"button",onClick:()=>{xe.current&&xe.current.pause(),fe(void 0),m==null||m("",Z)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:h.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]}),s&&h.jsxs("div",{className:"relative",ref:ye,children:[h.jsx("button",{type:"button",onClick:()=>R(!B),disabled:k||!(typeof e=="string"?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:k?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),N==="restructure"&&"Restructuring...",N==="proofread"&&"Proofreading...",N==="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"})]})}),B&&!k&&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:be,children:[h.jsxs("button",{type:"button",onClick:()=>Ne("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:()=>Ne("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:()=>Ne("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:G=>t(G.target.value),onKeyDown:G=>G.stopPropagation(),placeholder:o,rows:a,disabled:k||q,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),O&&h.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),h.jsx("p",{className:"text-sm text-neutral-600",children:O})]})]}),h.jsx("div",{className:"mt-4 flex justify-end",children:h.jsx("button",{type:"button",onClick:()=>W(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Yg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=y.useRef(null),a=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[f,p]=y.useState(null),[g,m]=y.useState(n),[x,_]=y.useState(0),[b,w]=y.useState({x:0,y:0,width:100,height:100}),[S,D]=y.useState(!1),[E,v]=y.useState(null),[k,M]=y.useState({x:0,y:0}),[N,T]=y.useState({x:0,y:0,width:100,height:100}),B=o==="dark",R=y.useCallback(()=>{const Q=u.current;return Q?x===90||x===270?{width:Q.height,height:Q.width}:{width:Q.width,height:Q.height}:{width:100,height:100}},[x]),C=y.useCallback((Q,Se)=>{const se=Q/Se,Ne=.05;for(const[be,ve]of Object.entries(gs))if(ve!==null&&Math.abs(se-ve)/ve<Ne)return be;return"free"},[]);y.useEffect(()=>{const Q=new Image;Q.crossOrigin="anonymous",Q.onload=()=>{u.current=Q;const Se=C(Q.width,Q.height);m(Se),d(!1)},Q.onerror=()=>{p("Failed to load image"),d(!1)},Q.src=r},[r,C]);const j=y.useCallback(()=>{const{width:Q,height:Se}=R(),se=gs[g];if(se===null){w({x:0,y:0,width:100,height:100});return}const Ne=Q/Se;let be,ve;Ne>se?(ve=100,be=se/Ne*100):(be=100,ve=Ne/se*100);const Le=(100-be)/2,Me=(100-ve)/2;w({x:Le,y:Me,width:be,height:ve})},[g,R]);y.useEffect(()=>{u.current&&j()},[g,x,j]),y.useEffect(()=>{const Q=a.current,Se=u.current;if(!Q||!Se||c)return;const se=Q.getContext("2d");if(!se)return;const Ne=l.current;if(!Ne)return;const be=Ne.clientWidth,ve=Ne.clientHeight-140,{width:Le,height:Me}=R(),$e=Le/Me;let G,z;be/ve>$e?(z=Math.min(ve,Me),G=z*$e):(G=Math.min(be,Le),z=G/$e),G>be&&(G=be,z=G/$e),z>ve&&(z=ve,G=z*$e),Q.width=G,Q.height=z,se.clearRect(0,0,G,z),se.save(),se.translate(G/2,z/2),se.rotate(x*Math.PI/180);let Pe,He;x===90||x===270?(Pe=z,He=G):(Pe=G,He=z),se.drawImage(Se,-Pe/2,-He/2,Pe,He),se.restore(),se.fillStyle="rgba(0, 0, 0, 0.6)";const K=b.x/100*G,re=b.y/100*z,de=b.width/100*G,_e=b.height/100*z;se.fillRect(0,0,G,re),se.fillRect(0,re+_e,G,z-re-_e),se.fillRect(0,re,K,_e),se.fillRect(K+de,re,G-K-de,_e),se.strokeStyle="#fff",se.lineWidth=2,se.strokeRect(K,re,de,_e),se.strokeStyle="rgba(255, 255, 255, 0.3)",se.lineWidth=1,se.beginPath(),se.moveTo(K+de/3,re),se.lineTo(K+de/3,re+_e),se.moveTo(K+de*2/3,re),se.lineTo(K+de*2/3,re+_e),se.moveTo(K,re+_e/3),se.lineTo(K+de,re+_e/3),se.moveTo(K,re+_e*2/3),se.lineTo(K+de,re+_e*2/3),se.stroke();const we=14;se.fillStyle="#fff",se.strokeStyle="#333",se.lineWidth=1,[{x:K,y:re},{x:K+de,y:re},{x:K,y:re+_e},{x:K+de,y:re+_e}].forEach(bt=>{se.fillRect(bt.x-we/2,bt.y-we/2,we,we),se.strokeRect(bt.x-we/2,bt.y-we/2,we,we)})},[b,x,c,R]);const F=Q=>{const Se=a.current;if(!Se)return;const se=Se.getBoundingClientRect(),Ne=(Q.clientX-se.left)/se.width*100,be=(Q.clientY-se.top)/se.height*100,ve=4,Le=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Me of Le)if(Math.abs(Ne-Me.x)<ve&&Math.abs(be-Me.y)<ve){v(Me.name),M({x:Ne,y:be}),T({...b});return}Ne>=b.x&&Ne<=b.x+b.width&&be>=b.y&&be<=b.y+b.height&&(D(!0),M({x:Ne,y:be}),T({...b}))},I=Q=>{const Se=a.current;if(!Se)return;const se=Se.getBoundingClientRect(),Ne=(Q.clientX-se.left)/se.width*100,be=(Q.clientY-se.top)/se.height*100;if(S){const ve=Ne-k.x,Le=be-k.y;let Me=N.x+ve,$e=N.y+Le;Me=Math.max(0,Math.min(Me,100-N.width)),$e=Math.max(0,Math.min($e,100-N.height)),w({...N,x:Me,y:$e})}else if(E){const ve=gs[g],{width:Le,height:Me}=R(),$e=Le/Me,G=ve?ve/$e:null;let z={...N};const Pe=Ne-k.x,He=be-k.y;if(E==="se")z.width=Math.max(10,Math.min(100-z.x,N.width+Pe)),G?(z.height=z.width/G,z.y+z.height>100&&(z.height=100-z.y,z.width=z.height*G)):z.height=Math.max(10,Math.min(100-z.y,N.height+He));else if(E==="sw"){const K=-Pe,re=Math.max(10,N.width+K),de=N.x+N.width-re;de>=0&&(z.width=re,z.x=de,G?(z.height=z.width/G,z.y+z.height>100&&(z.height=100-z.y,z.width=z.height*G,z.x=N.x+N.width-z.width)):z.height=Math.max(10,Math.min(100-z.y,N.height+He)))}else if(E==="ne")if(z.width=Math.max(10,Math.min(100-z.x,N.width+Pe)),G){const K=z.width/G,re=N.y+N.height-K;re>=0?(z.height=K,z.y=re):(z.y=0,z.height=N.y+N.height,z.width=z.height*G)}else{const K=-He,re=Math.max(10,N.height+K),de=N.y+N.height-re;de>=0&&(z.height=re,z.y=de)}else if(E==="nw"){const K=-Pe,re=Math.max(10,N.width+K),de=N.x+N.width-re;if(de>=0)if(z.width=re,z.x=de,G){const _e=z.width/G,we=N.y+N.height-_e;we>=0?(z.height=_e,z.y=we):(z.y=0,z.height=N.y+N.height,z.width=z.height*G,z.x=N.x+N.width-z.width)}else{const _e=-He,we=Math.max(10,N.height+_e),xt=N.y+N.height-we;xt>=0&&(z.height=we,z.y=xt)}}z.x=Math.max(0,z.x),z.y=Math.max(0,z.y),z.width=Math.min(z.width,100-z.x),z.height=Math.min(z.height,100-z.y),w(z)}},q=()=>{D(!1),v(null)},ee=Q=>{_(Se=>Q==="right"?(Se+90)%360:(Se-90+360)%360)},O=()=>{const Q=u.current;if(!Q)return;const{width:Se,height:se}=R(),Ne=b.x/100*Se,be=b.y/100*se,ve=b.width/100*Se,Le=b.height/100*se,Me=document.createElement("canvas"),$e=Me.getContext("2d");if(!$e)return;Me.width=ve,Me.height=Le;const G=document.createElement("canvas"),z=G.getContext("2d");z&&(G.width=Se,G.height=se,z.save(),z.translate(Se/2,se/2),z.rotate(x*Math.PI/180),z.drawImage(Q,-Q.width/2,-Q.height/2,Q.width,Q.height),z.restore(),$e.drawImage(G,Ne,be,ve,Le,0,0,ve,Le),Me.toBlob(Pe=>{Pe&&e(Pe)},s,i))},W={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:B?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Z={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},H={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${B?"#333":"#ddd"}`,background:B?"#242424":"#fff",flexShrink:0},ie={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},fe={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},ae={...fe,background:"#E67E22",color:"#fff"},ge={...fe,background:B?"#333":"#e5e5e5",color:B?"#fff":"#333"},ye={padding:"10px",borderRadius:"8px",border:"none",background:B?"#333":"#e5e5e5",color:B?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=Q=>({padding:"8px 14px",borderRadius:"6px",border:Q?"2px solid #E67E22":"2px solid transparent",background:Q?"#E67E22":B?"#333":"#e5e5e5",color:Q?"#fff":B?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:B?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...ge,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:W,children:[h.jsx("div",{style:Z,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:I,onMouseUp:q,onMouseLeave:q})}),h.jsxs("div",{style:H,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(Q=>h.jsx("button",{onClick:()=>m(Q),style:xe(g===Q),children:Q==="free"?"Libre":Q},Q))}),h.jsxs("div",{style:ie,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>ee("left"),style:ye,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",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:()=>ee("right"),style:ye,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",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:ge,children:"Annuler"}),h.jsx("button",{onClick:O,style:ae,children:"Enregistrer"})]})]})]})]})}var Qg={value:()=>{}};function la(){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 Jg(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=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Jg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Xg(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]=zl(t[s],r.name,e);else if(e==null)for(s in t)t[s]=zl(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 Xg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function zl(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Qg,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 Ol={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 _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[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 e0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Zc(r){var e=_i(r);return(e.local?e0:Zg)(e)}function t0(){}function ua(r){return r==null?t0:function(){return this.querySelector(r)}}function r0(r){typeof r!="function"&&(r=ua(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 At(n,this._parents)}function n0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function s0(){return[]}function ed(r){return r==null?s0:function(){return this.querySelectorAll(r)}}function i0(r){return function(){return n0(r.apply(this,arguments))}}function o0(r){typeof r=="function"?r=i0(r):r=ed(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 At(n,s)}function td(r){return function(){return this.matches(r)}}function rd(r){return function(e){return e.matches(r)}}var a0=Array.prototype.find;function l0(r){return function(){return a0.call(this.children,r)}}function u0(){return this.firstElementChild}function c0(r){return this.select(r==null?u0:l0(typeof r=="function"?r:rd(r)))}var d0=Array.prototype.filter;function f0(){return Array.from(this.children)}function h0(r){return function(){return d0.call(this.children,r)}}function p0(r){return this.selectAll(r==null?f0:h0(typeof r=="function"?r:rd(r)))}function g0(r){typeof r!="function"&&(r=td(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 At(n,this._parents)}function nd(r){return new Array(r.length)}function m0(){return new At(this._enter||this._groups.map(nd),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 y0(r){return function(){return r}}function x0(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 b0(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 v0(r){return r.__data__}function _0(r,e){if(!arguments.length)return Array.from(this,v0);var t=e?b0:x0,n=this._parents,s=this._groups;typeof r!="function"&&(r=y0(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=w0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),_=a[u]=new Array(f);t(c,d,m,x,_,p,e);for(var b=0,w=0,S,D;b<g;++b)if(S=m[b]){for(b>=w&&(w=b+1);!(D=x[w])&&++w<g;);S._next=D||null}}return o=new At(o,n),o._enter=l,o._exit=a,o}function w0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function C0(){return new At(this._exit||this._groups.map(nd),this._parents)}function S0(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 k0(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 At(l,this._parents)}function E0(){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 D0(r){r||(r=A0);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 At(s,this._parents).order()}function A0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function T0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function N0(){return Array.from(this)}function B0(){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 j0(){let r=0;for(const e of this)++r;return r}function M0(){return!this.node()}function R0(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 F0(r){return function(){this.removeAttribute(r)}}function L0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function P0(r,e){return function(){this.setAttribute(r,e)}}function I0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function z0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function O0(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 $0(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?L0:F0:typeof e=="function"?t.local?O0:z0:t.local?I0:P0)(t,e))}function sd(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function q0(r){return function(){this.style.removeProperty(r)}}function U0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function W0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function H0(r,e,t){return arguments.length>1?this.each((e==null?q0:typeof e=="function"?W0:U0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||sd(r).getComputedStyle(r,null).getPropertyValue(e)}function V0(r){return function(){delete this[r]}}function G0(r,e){return function(){this[r]=e}}function K0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Y0(r,e){return arguments.length>1?this.each((e==null?V0:typeof e=="function"?K0:G0)(r,e)):this.node()[r]}function id(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new od(r)}function od(r){this._node=r,this._names=id(r.getAttribute("class")||"")}od.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 ad(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function Q0(r){return function(){ad(this,r)}}function J0(r){return function(){ld(this,r)}}function X0(r,e){return function(){(e.apply(this,arguments)?ad:ld)(this,r)}}function Z0(r,e){var t=id(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?X0:e?Q0:J0)(t,e))}function em(){this.textContent=""}function tm(r){return function(){this.textContent=r}}function rm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function nm(r){return arguments.length?this.each(r==null?em:(typeof r=="function"?rm:tm)(r)):this.node().textContent}function sm(){this.innerHTML=""}function im(r){return function(){this.innerHTML=r}}function om(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function am(r){return arguments.length?this.each(r==null?sm:(typeof r=="function"?om:im)(r)):this.node().innerHTML}function lm(){this.nextSibling&&this.parentNode.appendChild(this)}function um(){return this.each(lm)}function cm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function dm(){return this.each(cm)}function fm(r){var e=typeof r=="function"?r:Zc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function hm(){return null}function pm(r,e){var t=typeof r=="function"?r:Zc(r),n=e==null?hm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function gm(){var r=this.parentNode;r&&r.removeChild(this)}function mm(){return this.each(gm)}function ym(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function xm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(r){return this.select(r?xm:ym)}function vm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function _m(r){return function(e){r.call(this,e,this.__data__)}}function wm(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 Sm(r,e,t){return function(){var n=this.__on,s,i=_m(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 km(r,e,t){var n=wm(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?Sm:Cm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function ud(r,e,t){var n=sd(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 Em(r,e){return function(){return ud(this,r,e)}}function Dm(r,e){return function(){return ud(this,r,e.apply(this,arguments))}}function Am(r,e){return this.each((typeof e=="function"?Dm:Em)(r,e))}function*Tm(){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 cd=[null];function At(r,e){this._groups=r,this._parents=e}function ss(){return new At([[document.documentElement]],cd)}function Nm(){return this}At.prototype=ss.prototype={constructor:At,select:r0,selectAll:o0,selectChild:c0,selectChildren:p0,filter:g0,data:_0,enter:m0,exit:C0,join:S0,merge:k0,selection:Nm,order:E0,sort:D0,call:T0,nodes:N0,node:B0,size:j0,empty:M0,each:R0,attr:$0,style:H0,property:Y0,classed:Z0,text:nm,html:am,raise:um,lower:dm,append:fm,insert:pm,remove:mm,clone:bm,datum:vm,on:km,dispatch:Am,[Symbol.iterator]:Tm};function Lt(r){return typeof r=="string"?new At([[document.querySelector(r)]],[document.documentElement]):new At([[r]],cd)}function Bm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=Bm(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 vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function jm(r){var e=r.document.documentElement,t=Lt(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Mm(r,e){var t=r.document.documentElement,n=Lt(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),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 da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function dd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rm=/^#([0-9a-f]{3,8})$/,Fm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Lm=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Pm=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),Im=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),zm=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Om=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${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};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:$m,formatHsl:qm,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function $m(){return this.rgb().formatHex8()}function qm(){return fd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Rm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new Ct(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=Fm.exec(r))?new Ct(e[1],e[2],e[3],1):(e=Lm.exec(r))?new Ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Pm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Im.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=zm.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new Ct(NaN,NaN,NaN,0):null}function Wl(r){return new Ct(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new Ct(r,e,t,n)}function Um(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new Ct(r.r,r.g,r.b,r.opacity)):new Ct}function wo(r,e,t,n){return arguments.length===1?Um(r):new Ct(r,e,t,n??1)}function Ct(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(Ct,wo,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ct(Tr(this.r),Tr(this.g),Tr(this.b),Xs(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:Hl,formatHex:Hl,formatHex8:Wm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Wm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(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 Pt(r,e,t,n)}function fd(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)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 Pt(o,l,a,r.opacity)}function Hm(r,e,t,n){return arguments.length===1?fd(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,Hm,dd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(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 Ct(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 Pt(Kl(this.h),ys(this.s),ys(this.l),Xs(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=Xs(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 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 hd=r=>()=>r;function Vm(r,e){return function(t){return r+t*e}}function Gm(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 Km(r){return(r=+r)==1?pd:function(e,t){return t-e?Gm(e,t,r):hd(isNaN(e)?t:e)}}function pd(r,e){var t=e-r;return t?Vm(r,t):hd(isNaN(r)?e:r)}const Yl=function r(e){var t=Km(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=pd(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 Ym(r){return function(){return r}}function Qm(r){return function(e){return r(e)+""}}function Jm(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]?Qm(a[0].x):Ym(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,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gd(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 Xm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:gd(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,gd(r.a,r.b,r.c,r.d,r.e,r.f))}function md(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 ey=md(Xm,"px, ","px)","deg)"),ty=md(Zm,", ",")",")"),ry=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function ny(r){return((r=Math.exp(r))-1/r)/2}function sy(r){return((r=Math.exp(2*r))-1)/(r+1)}const iy=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,_;if(m<ry)_=Math.log(f/u)/e,x=function(v){return[l+v*p,a+v*g,u*Math.exp(e*v*_)]};else{var b=Math.sqrt(m),w=(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(w*w+1)-w),E=Math.log(Math.sqrt(S*S+1)-S);_=(E-D)/e,x=function(v){var k=v*_,M=Jl(D),N=u/(t*b)*(M*sy(e*k+D)-ny(D));return[l+N*p,a+N*g,u*M/Jl(e*k+D)]}}return x.duration=_*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,yd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,xd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(xd(oy),Lr=Wn.now()+wi)}function oy(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=bd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function bd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ay(){fa(),++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{ay()}finally{nn=0,uy(),Lr=0}}function ly(){var r=Wn.now(),e=r-ei;e>yd&&(wi-=e,ei=r)}function uy(){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,ko(n)}function ko(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(ly,yd)),nn=1,xd(Xl))}}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 cy=la("start","end","cancel","interrupt"),dy=[],vd=0,eu=1,Eo=2,Ss=3,tu=4,Do=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;fy(r,t,{name:e,index:n,group:s,on:cy,tween:dy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vd})}function ha(r,e){var t=qt(r,e);if(t.state>vd)throw new Error("too late; already scheduled");return t}function Xt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function fy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=bd(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=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){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=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>Eo&&n.state<Do,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 hy(r){return this.each(function(){Es(this,r)})}function py(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 gy(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 my(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(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?py:gy)(t,r,e))}function pa(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 qt(s,n).value[e]}}function _d(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Jm)(r,e)}function yy(r){return function(){this.removeAttribute(r)}}function xy(r){return function(){this.removeAttributeNS(r.space,r.local)}}function by(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 vy(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 _y(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 wy(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 Cy(r,e){var t=_i(r),n=t==="transform"?ty:_d;return this.attrTween(r,typeof e=="function"?(t.local?wy:_y)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?xy:yy)(t):(t.local?vy:by)(t,n,e))}function Sy(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function ky(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Ey(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Sy(r,i)),t}return s._value=e,s}function Ay(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?Ey:Dy)(n,e))}function Ty(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function Ny(r,e){return e=+e,function(){ha(this,r).delay=e}}function By(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ty:Ny)(e,r)):qt(this.node(),e).delay}function jy(r,e){return function(){Xt(this,r).duration=+e.apply(this,arguments)}}function My(r,e){return e=+e,function(){Xt(this,r).duration=e}}function Ry(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?jy:My)(e,r)):qt(this.node(),e).duration}function Fy(r,e){if(typeof e!="function")throw new Error;return function(){Xt(this,r).ease=e}}function Ly(r){var e=this._id;return arguments.length?this.each(Fy(e,r)):qt(this.node(),e).ease}function Py(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Xt(this,r).ease=t}}function Iy(r){if(typeof r!="function")throw new Error;return this.each(Py(this._id,r))}function zy(r){typeof r!="function"&&(r=td(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 Oy(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 $y(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 qy(r,e,t){var n,s,i=$y(e)?ha:Xt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function Uy(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(qy(t,r,e))}function Wy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Hy(){return this.on("end.remove",Wy(this._id))}function Vy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(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,qt(c,t)));return new ir(i,this._parents,e,t)}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ed(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=qt(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 Ky=ss.prototype.constructor;function Yy(){return new Ky(this._groups,this._parents)}function Qy(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 wd(r){return function(){this.style.removeProperty(r)}}function Jy(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 Xy(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 Zy(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=wd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function e2(r,e,t){var n=(r+="")=="transform"?ey:_d;return e==null?this.styleTween(r,Qy(r,n)).on("end.style."+r,wd(r)):typeof e=="function"?this.styleTween(r,Xy(r,n,pa(this,"style."+r,e))).each(Zy(this._id,r)):this.styleTween(r,Jy(r,n,e),t).on("end.style."+r,null)}function t2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function r2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&t2(r,o,t)),n}return i._value=e,i}function n2(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,r2(r,e,t??""))}function s2(r){return function(){this.textContent=r}}function i2(r){return function(){var e=r(this);this.textContent=e??""}}function o2(r){return this.tween("text",typeof r=="function"?i2(pa(this,"text",r)):s2(r==null?"":r+""))}function a2(r){return function(e){this.textContent=r.call(this,e)}}function l2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&a2(s)),e}return n._value=r,n}function u2(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,l2(r))}function c2(){for(var r=this._name,e=this._id,t=Cd(),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=qt(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 d2(){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 f2=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Cd(){return++f2}var tr=ss.prototype;ir.prototype={constructor:ir,select:Vy,selectAll:Gy,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:zy,merge:Oy,selection:Yy,transition:c2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:Uy,attr:Cy,attrTween:Ay,style:e2,styleTween:n2,text:o2,textTween:u2,remove:Hy,tween:my,delay:By,duration:Ry,ease:Ly,easeVarying:Iy,end:d2,[Symbol.iterator]:tr[Symbol.iterator]};function h2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var p2={time:null,delay:0,duration:250,ease:h2};function g2(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 m2(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=Cd(),(t=p2).time=fa(),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||g2(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=hy;ss.prototype.transition=m2;const bs=r=>()=>r;function y2(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 x2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function b2(){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 v2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function _2(){return navigator.maxTouchPoints||"ontouchstart"in this}function w2(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 C2(){var r=x2,e=b2,t=w2,n=v2,s=_2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=iy,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function _(C){C.property("__zoom",ru).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",N).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(C,j,F,I){var q=C.selection?C.selection():C;q.property("__zoom",ru),C!==q?D(C,j,F,I):q.interrupt().each(function(){E(this,arguments).event(I).start().zoom(null,typeof j=="function"?j.apply(this,arguments):j).end()})},_.scaleBy=function(C,j,F,I){_.scaleTo(C,function(){var q=this.__zoom.k,ee=typeof j=="function"?j.apply(this,arguments):j;return q*ee},F,I)},_.scaleTo=function(C,j,F,I){_.transform(C,function(){var q=e.apply(this,arguments),ee=this.__zoom,O=F==null?S(q):typeof F=="function"?F.apply(this,arguments):F,W=ee.invert(O),Z=typeof j=="function"?j.apply(this,arguments):j;return t(w(b(ee,Z),O,W),q,o)},F,I)},_.translateBy=function(C,j,F,I){_.transform(C,function(){return t(this.__zoom.translate(typeof j=="function"?j.apply(this,arguments):j,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,I)},_.translateTo=function(C,j,F,I,q){_.transform(C,function(){var ee=e.apply(this,arguments),O=this.__zoom,W=I==null?S(ee):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(W[0],W[1]).scale(O.k).translate(typeof j=="function"?-j.apply(this,arguments):-j,typeof F=="function"?-F.apply(this,arguments):-F),ee,o)},I,q)};function b(C,j){return j=Math.max(i[0],Math.min(i[1],j)),j===C.k?C:new nr(j,C.x,C.y)}function w(C,j,F){var I=j[0]-F[0]*C.k,q=j[1]-F[1]*C.k;return I===C.x&&q===C.y?C:new nr(C.k,I,q)}function S(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function D(C,j,F,I){C.on("start.zoom",function(){E(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(I).end()}).tween("zoom",function(){var q=this,ee=arguments,O=E(q,ee).event(I),W=e.apply(q,ee),Z=F==null?S(W):typeof F=="function"?F.apply(q,ee):F,H=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),ie=q.__zoom,fe=typeof j=="function"?j.apply(q,ee):j,ae=a(ie.invert(Z).concat(H/ie.k),fe.invert(Z).concat(H/fe.k));return function(ge){if(ge===1)ge=fe;else{var ye=ae(ge),xe=H/ye[2];ge=new nr(xe,Z[0]-ye[0]*xe,Z[1]-ye[1]*xe)}O.zoom(null,ge)}})}function E(C,j,F){return!F&&C.__zooming||new v(C,j)}function v(C,j){this.that=C,this.args=j,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,j),this.taps=0}v.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,j){return this.mouse&&C!=="mouse"&&(this.mouse[1]=j.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=j.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=j.invert(this.touch1[0])),this.that.__zoom=j,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var j=Lt(this.that).datum();u.call(C,this.that,new y2(C,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),j)}};function k(C,...j){if(!r.apply(this,arguments))return;var F=E(this,j).event(C),I=this.__zoom,q=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),ee=wr(C);if(F.wheel)(F.mouse[0][0]!==ee[0]||F.mouse[0][1]!==ee[1])&&(F.mouse[1]=I.invert(F.mouse[0]=ee)),clearTimeout(F.wheel);else{if(I.k===q)return;F.mouse=[ee,I.invert(ee)],Es(this),F.start()}xn(C),F.wheel=setTimeout(O,g),F.zoom("mouse",t(w(b(I,q),F.mouse[0],F.mouse[1]),F.extent,o));function O(){F.wheel=null,F.end()}}function M(C,...j){if(f||!r.apply(this,arguments))return;var F=C.currentTarget,I=E(this,j,!0).event(C),q=Lt(C.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",H,!0),ee=wr(C,F),O=C.clientX,W=C.clientY;jm(C.view),Wi(C),I.mouse=[ee,this.__zoom.invert(ee)],Es(this),I.start();function Z(ie){if(xn(ie),!I.moved){var fe=ie.clientX-O,ae=ie.clientY-W;I.moved=fe*fe+ae*ae>m}I.event(ie).zoom("mouse",t(w(I.that.__zoom,I.mouse[0]=wr(ie,F),I.mouse[1]),I.extent,o))}function H(ie){q.on("mousemove.zoom mouseup.zoom",null),Mm(ie.view,I.moved),xn(ie),I.event(ie).end()}}function N(C,...j){if(r.apply(this,arguments)){var F=this.__zoom,I=wr(C.changedTouches?C.changedTouches[0]:C,this),q=F.invert(I),ee=F.k*(C.shiftKey?.5:2),O=t(w(b(F,ee),I,q),e.apply(this,j),o);xn(C),l>0?Lt(this).transition().duration(l).call(D,O,I,C):Lt(this).call(_.transform,O,I,C)}}function T(C,...j){if(r.apply(this,arguments)){var F=C.touches,I=F.length,q=E(this,j,C.changedTouches.length===I).event(C),ee,O,W,Z;for(Wi(C),O=0;O<I;++O)W=F[O],Z=wr(W,this),Z=[Z,this.__zoom.invert(Z),W.identifier],q.touch0?!q.touch1&&q.touch0[2]!==Z[2]&&(q.touch1=Z,q.taps=0):(q.touch0=Z,ee=!0,q.taps=1+!!c);c&&(c=clearTimeout(c)),ee&&(q.taps<2&&(d=Z[0],c=setTimeout(function(){c=null},p)),Es(this),q.start())}}function B(C,...j){if(this.__zooming){var F=E(this,j).event(C),I=C.changedTouches,q=I.length,ee,O,W,Z;for(xn(C),ee=0;ee<q;++ee)O=I[ee],W=wr(O,this),F.touch0&&F.touch0[2]===O.identifier?F.touch0[0]=W:F.touch1&&F.touch1[2]===O.identifier&&(F.touch1[0]=W);if(O=F.that.__zoom,F.touch1){var H=F.touch0[0],ie=F.touch0[1],fe=F.touch1[0],ae=F.touch1[1],ge=(ge=fe[0]-H[0])*ge+(ge=fe[1]-H[1])*ge,ye=(ye=ae[0]-ie[0])*ye+(ye=ae[1]-ie[1])*ye;O=b(O,Math.sqrt(ge/ye)),W=[(H[0]+fe[0])/2,(H[1]+fe[1])/2],Z=[(ie[0]+ae[0])/2,(ie[1]+ae[1])/2]}else if(F.touch0)W=F.touch0[0],Z=F.touch0[1];else return;F.zoom("touch",t(w(O,W,Z),F.extent,o))}}function R(C,...j){if(this.__zooming){var F=E(this,j).event(C),I=C.changedTouches,q=I.length,ee,O;for(Wi(C),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),ee=0;ee<q;++ee)O=I[ee],F.touch0&&F.touch0[2]===O.identifier?delete F.touch0:F.touch1&&F.touch1[2]===O.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(O=wr(O,this),Math.hypot(d[0]-O[0],d[1]-O[1])<x)){var W=Lt(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return _.wheelDelta=function(C){return arguments.length?(n=typeof C=="function"?C:bs(+C),_):n},_.filter=function(C){return arguments.length?(r=typeof C=="function"?C:bs(!!C),_):r},_.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:bs(!!C),_):s},_.extent=function(C){return arguments.length?(e=typeof C=="function"?C:bs([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),_):e},_.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],_):[i[0],i[1]]},_.translateExtent=function(C){return arguments.length?(o[0][0]=+C[0][0],o[1][0]=+C[1][0],o[0][1]=+C[0][1],o[1][1]=+C[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(C){return arguments.length?(t=C,_):t},_.duration=function(C){return arguments.length?(l=+C,_):l},_.interpolate=function(C){return arguments.length?(a=C,_):a},_.on=function(){var C=u.on.apply(u,arguments);return C===u?_:C},_.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,_):Math.sqrt(m)},_.tapDistance=function(C){return arguments.length?(x=+C,_):x},_}function Sd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=y.useRef(null),a=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!l.current)return;const x=C2().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 w={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(w),o==null||o(w)});a.current=x;const _=Lt(l.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),y.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=y.useCallback((x,_,b,w=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),D=ri.translate(x,_).scale(b);S.call(a.current.transform,D)},[]),f=y.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,_=50)=>{if(!l.current||!a.current||x.length===0)return;const w=l.current.getBoundingClientRect();let S=1/0,D=1/0,E=-1/0,v=-1/0;for(const I of x){const q=I.width||200,ee=I.height||100;S=Math.min(S,I.x),D=Math.min(D,I.y),E=Math.max(E,I.x+q),v=Math.max(v,I.y+ee)}const k=E-S,M=v-D,N=(w.width-_*2)/k,T=(w.height-_*2)/M,B=Math.min(N,T,t),R=(S+E)/2,C=(D+v)/2,j=w.width/2-R*B,F=w.height/2-C*B;d(j,F,B,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function kd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=y.useState(null),[a,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),f=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((w,S)=>{const D=g.current;return{x:(w-D.x)/D.k,y:(S-D.y)/D.k}},[]),x=y.useCallback((w,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const D=S.currentTarget,E=parseFloat(D.dataset.x||"0"),v=parseFloat(D.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:E,nodeY:v},p.current={x:E,y:v},l(w),u(!0),d({x:0,y:0}),t==null||t(w)},[i,m,t]),_=y.useCallback(w=>{if(!a||!o||!f.current)return;const S=g.current,D=f.current,E=w.clientX-D.x,v=w.clientY-D.y,k=E/S.k,M=v/S.k,N=D.nodeX+k,T=D.nodeY+M;p.current={x:N,y:T},d({x:k,y:M}),n==null||n(o,N,T,k,M)},[a,o,n]),b=y.useCallback(()=>{if(!a||!o)return;const w=p.current;s==null||s(o,w.x,w.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return y.useEffect(()=>{if(!a)return;const w=D=>{_(D)},S=()=>{b()};return window.addEventListener("mousemove",w),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",S)}},[a,_,b]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:_,endDrag:b}}function Ed(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=y.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?N=>{const T=typeof N=="function"?N(u):N;i==null||i(Array.from(T))}:l,[d,f]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),_=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{_.current=t},[t]);const b=y.useCallback((N,T)=>{const B=x.current;return{x:(N-B.x)/B.k,y:(T-B.y)/B.k}},[]),w=y.useCallback((N,T)=>{const B=_.current.get(N);if(!B)return!1;const R=B.width||200,C=B.height||100;return B.x<T.x+T.width&&B.x+R>T.x&&B.y<T.y+T.height&&B.y+C>T.y},[]),S=y.useCallback(N=>{if(n||N.target.closest("[data-qmap-node]"))return;N.preventDefault();const B=b(N.clientX,N.clientY);m.current=B,f({x:B.x,y:B.y,width:0,height:0}),g(!0),N.shiftKey||c(new Set)},[n,b]),D=y.useCallback(N=>{if(!p||!m.current)return;const T=m.current,B=b(N.clientX,N.clientY),R={x:Math.min(T.x,B.x),y:Math.min(T.y,B.y),width:Math.abs(B.x-T.x),height:Math.abs(B.y-T.y)};f(R);const C=new Set;for(const[j]of _.current)w(j,R)&&C.add(j);c(C)},[p,b,w]),E=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const N=B=>{D(B)},T=()=>{E()};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",T)}},[p,D,E]);const v=y.useCallback((N,T=!1)=>{c(B=>{const R=new Set(T?B:[]);return B.has(N)&&T?R.delete(N):R.add(N),i==null||i(Array.from(R)),R})},[i]),k=y.useCallback(()=>{const N=new Set(_.current.keys());c(N),i==null||i(Array.from(N))},[i]),M=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:D,endSelection:E,toggleSelect:v,selectAll:k,clearSelection:M}}const Dd=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,nodeRef:c,children:d}){const f=y.useCallback(_=>{i&&_.button===0&&o(e,_)},[e,i,o]),p=y.useCallback(_=>{s||l==null||l(_)},[s,l]),g=y.useCallback(_=>{_.stopPropagation(),a==null||a(_)},[a]),m=y.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u==null||u(_)},[u]),x=t.rotation||0;return h.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:f,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Ad(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return k2(n,s);case"bezier":default:return S2(n,s)}}function S2(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 k2(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 ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function E2(r,e){const t=r.width||200,n=r.height||100,s=ga(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 D2(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 ga(r)}}function A2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function T2(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 N2(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 B2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Td=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=y.useState(!1),c=y.useMemo(()=>Ad(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=y.useCallback(()=>{u(!0)},[]),p=y.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(M2,{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 M2({pathD:r,label:e,color:t}){const n=y.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 Nd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=y.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return h.jsx(Td,{edge:a,sourcePosition:u,targetPosition:c,style:a.style||n,color:a.color||s,width:a.width||i,onClick:o},a.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),Bd=y.memo(function({box:e,transform:t}){const n=y.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}})}),R2=200,F2=100,L2="bezier",P2="#94a3b8",I2=2,z2=.1,O2=4;function $2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=R2,defaultNodeHeight:i=F2,onNodeMove:o,onNodeDrag:l,onNodeClick:a,onNodeDoubleClick:u,onNodeContextMenu:c,selectedIds:d,onSelectionChange:f,onEdgeClick:p,onViewChange:g,onTransformChange:m,minZoom:x=z2,maxZoom:_=O2,initialTransform:b,defaultEdgeStyle:w=L2,defaultEdgeColor:S=P2,defaultEdgeWidth:D=I2,draggable:E=!0,selectable:v=!0,zoomable:k=!0,pannable:M=!0,className:N="",style:T,background:B="#f8fafc",showGrid:R=!1,gridSize:C=20}){const j=r.data||{positions:{}},F=j.positions||{},I=y.useMemo(()=>{const K=new Map;for(const re of e){const de=F[re._id]||{x:0,y:0};K.set(re._id,{x:de.x,y:de.y,width:de.width||s,height:de.height||i,rotation:de.rotation||0})}return K},[e,F,s,i]),{transform:q,containerRef:ee,zoomIn:O,zoomOut:W,resetZoom:Z,fitToContent:H}=Sd({minZoom:x,maxZoom:_,initialTransform:b||j.transform,zoomable:k,pannable:M,onTransformChange:K=>{m==null||m(K);const re={...j,transform:K};g==null||g(re)}}),[ie,fe]=y.useState(new Map),[ae,ge]=y.useState(new Map),ye=y.useRef(new Map);y.useEffect(()=>{const K=new Map;ye.current.forEach((de,_e)=>{if(de){const we=de.getBoundingClientRect();K.set(_e,{width:we.width,height:we.height})}}),e.some(de=>{const _e=K.get(de._id),we=ae.get(de._id);return _e?we?_e.width!==we.width||_e.height!==we.height:!0:!1})&&ge(K)},[e,ae]);const{draggedNodeId:xe,startDrag:Q}=kd({transform:q,disabled:!E,onDragStart:K=>{const re=I.get(K);re&&fe(new Map([[K,{x:re.x,y:re.y}]]))},onDragMove:(K,re,de)=>{fe(new Map([[K,{x:re,y:de}]])),l==null||l(K,re,de)},onDragEnd:(K,re,de)=>{fe(new Map),o==null||o(K,re,de)}}),{selectedIds:Se,selectionBox:se,isSelecting:Ne,startSelection:be,toggleSelect:ve,clearSelection:Le}=Ed({transform:q,nodePositions:I,disabled:!v,controlledSelectedIds:d,onSelectionChange:f}),Me=y.useCallback(K=>{const re=I.get(K)||{x:0,y:0,width:s,height:i},de=ie.get(K),_e=ae.get(K),we=(_e==null?void 0:_e.width)||re.width||s,xt=(_e==null?void 0:_e.height)||re.height||i;return de?{...re,x:de.x,y:de.y,width:we,height:xt}:{...re,width:we,height:xt}},[I,ie,ae,s,i]),$e=y.useMemo(()=>{const K=new Map;for(const re of I.keys())K.set(re,Me(re));return K},[I,Me]),G=y.useCallback((K,re)=>{ve(K._id,re.shiftKey),a==null||a(K,re)},[ve,a]),z=y.useCallback(K=>{K.target.closest("[data-qmap-node]")||Le()},[Le]),Pe=y.useCallback(K=>{K.button===0&&(K.target.closest("[data-qmap-node]")||be(K))},[be]),He=R?`
|
|
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:
|
|
188
|
+
`:void 0;return h.jsxs("div",{ref:ee,className:`qmap-container ${N}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:B,backgroundImage:He,backgroundSize:R?`${C}px ${C}px`:void 0,cursor:Ne?"crosshair":M?"grab":"default",...T},onMouseDown:Pe,onClick:z,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${q.x}px, ${q.y}px) scale(${q.k})`,willChange:"transform"},children:[h.jsx(Nd,{edges:t,nodePositions:$e,defaultStyle:w,defaultColor:S,defaultWidth:D,onEdgeClick:p}),e.map(K=>{const re=Me(K._id),de=Se.has(K._id),_e=xe===K._id;return h.jsx(Dd,{nodeId:K._id,position:re,isSelected:de,isDragging:_e,draggable:E,onDragStart:Q,onClick:we=>G(K,we),onDoubleClick:we=>u==null?void 0:u(K,we),onContextMenu:we=>c==null?void 0:c(K,we),nodeRef:we=>{we?ye.current.set(K._id,we):ye.current.delete(K._id)},children:n(K,de,re)},K._id)})]}),se&&h.jsx(Bd,{box:se,transform:q}),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:O,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: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 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:()=>H(Array.from(I.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=aa;exports.$isQRCodeNode=Sg;exports.AnimatedCardFlip=Sf;exports.ApiClient=au;exports.AudioEditor=Xc;exports.AuthFlow=fu;exports.AuthFlowModal=xf;exports.AuthManager=Qe;exports.AuthProvider=cf;exports.AuthService=Ao;exports.Card=_f;exports.ComboBox=Rg;exports.ComboStack=Lg;exports.DataOperations=vs;exports.Detail=wf;exports.ForgotPasswordForm=cu;exports.GraphClient=Pd;exports.ImageEditor=Yg;exports.KanbanBoard=Pg;exports.LLMClient=nf;exports.LoginForm=No;exports.LoginModal=hf;exports.Mail=Ef;exports.MailClient=iu;exports.MailComposer=jg;exports.MailEditor=Gc;exports.NetflixCard=Yc;exports.NetflixDetail=Jc;exports.NetflixLane=Qc;exports.NetflixStack=qg;exports.QMap=$2;exports.QMapEdgeComponent=Td;exports.QMapEdgeLayer=Nd;exports.QMapNode=Dd;exports.QMapSelectionBox=Bd;exports.QRCodeNode=un;exports.RegisterForm=uu;exports.ResetPasswordForm=du;exports.SelectableList=Df;exports.Stack=vf;exports.TTS_VOICES=ou;exports.Timeline=Gg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Kg;exports.calculateBoundingBox=N2;exports.calculateEdgePath=Ad;exports.distance=B2;exports.distanceSquared=j2;exports.getApiClient=To;exports.getAuthService=of;exports.getConnectionPoint=E2;exports.getNodeCenter=ga;exports.getNodeSidePoint=D2;exports.initializeApiClient=af;exports.initializeAuthService=sf;exports.pointInRect=A2;exports.rectsIntersect=T2;exports.useAuth=df;exports.useMutation=bf;exports.useNodeDrag=kd;exports.useQuery=hu;exports.useSelection=Ed;exports.useZoomPan=Sd;
|