erdbpro 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8387,7 +8387,7 @@ ${A}
|
|
|
8387
8387
|
`}),s+=`);
|
|
8388
8388
|
|
|
8389
8389
|
`});const l=new Set;i.forEach(B=>{var y,b;const E=o.get(B.source),p=o.get(B.target);if(E&&p){const v=(y=B.sourceHandle)==null?void 0:y.replace("col-","").replace("-source-l","").replace("-source",""),x=(b=B.targetHandle)==null?void 0:b.replace("col-","").replace("-target-r","").replace("-target",""),S=E.columns.find(N=>N.id===v),L=p.columns.find(N=>N.id===x);if(S&&L){const N=`fk_${E.name}_${S.name}`.toLowerCase(),O=`${E.name}.${S.name}->${p.name}.${L.name}`;l.has(O)||(s+=`ALTER TABLE ${E.name} ADD CONSTRAINT ${N} FOREIGN KEY (${S.name}) REFERENCES ${p.name}(${L.name});
|
|
8390
|
-
`,l.add(O))}}});const d=new Blob([s],{type:"text/plain"}),h=URL.createObjectURL(d),f=document.createElement("a");f.href=h,f.download=`${A.name.toLowerCase().replace(/\s+/g,"_")}_schema.sql`,f.click(),URL.revokeObjectURL(h)}}}function bQ(e,t,A,n){if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return A==="m"?n:A==="a"?n.call(e):n?n.value:t.get(e)}function W0e(e,t,A,n,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,A),A}var UZ,ek,r0e,KGe,Qct;const j5="__TAURI_TO_IPC_KEY__";function T6n(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}let SWt=class{constructor(t){UZ.set(this,void 0),ek.set(this,0),r0e.set(this,[]),KGe.set(this,void 0),W0e(this,UZ,t||(()=>{})),this.id=T6n(A=>{const n=A.index;if("end"in A){n==bQ(this,ek,"f")?this.cleanupCallback():W0e(this,KGe,n);return}const i=A.message;if(n==bQ(this,ek,"f")){for(bQ(this,UZ,"f").call(this,i),W0e(this,ek,bQ(this,ek,"f")+1);bQ(this,ek,"f")in bQ(this,r0e,"f");){const u=bQ(this,r0e,"f")[bQ(this,ek,"f")];bQ(this,UZ,"f").call(this,u),delete bQ(this,r0e,"f")[bQ(this,ek,"f")],W0e(this,ek,bQ(this,ek,"f")+1)}bQ(this,ek,"f")===bQ(this,KGe,"f")&&this.cleanupCallback()}else bQ(this,r0e,"f")[n]=i})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(t){W0e(this,UZ,t)}get onmessage(){return bQ(this,UZ,"f")}[(UZ=new WeakMap,ek=new WeakMap,r0e=new WeakMap,KGe=new WeakMap,j5)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[j5]()}};class ntn{constructor(t,A,n){this.plugin=t,this.event=A,this.channelId=n}async unregister(){return jr(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function BYi(e,t,A){const n=new SWt(A);try{return await jr(`plugin:${e}|register_listener`,{event:t,handler:n}),new ntn(e,t,n.id)}catch{return await jr(`plugin:${e}|registerListener`,{event:t,handler:n}),new ntn(e,t,n.id)}}async function jr(e,t={},A){return window.__TAURI_INTERNALS__.invoke(e,t,A)}class LWt{get rid(){return bQ(this,Qct,"f")}constructor(t){Qct.set(this,void 0),W0e(this,Qct,t)}async close(){return jr("plugin:resources|close",{rid:this.rid})}}Qct=new WeakMap;class H6n extends LWt{constructor(t){super(t.rid),this.available=!0,this.currentVersion=t.currentVersion,this.version=t.version,this.date=t.date,this.body=t.body,this.rawJson=t.rawJson}async download(t,A){OWt(A);const n=new SWt;t&&(n.onmessage=t);const i=await jr("plugin:updater|download",{onEvent:n,rid:this.rid,...A});this.downloadedBytes=new LWt(i)}async install(){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await jr("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(t,A){OWt(A);const n=new SWt;t&&(n.onmessage=t),await jr("plugin:updater|download_and_install",{onEvent:n,rid:this.rid,...A})}async close(){var t;await((t=this.downloadedBytes)==null?void 0:t.close()),await super.close()}}async function Y6n(e){OWt(e);const t=await jr("plugin:updater|check",{...e});return t?new H6n(t):null}function OWt(e){e!=null&&e.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}const rtn=Object.freeze(Object.defineProperty({__proto__:null,Update:H6n,check:Y6n},Symbol.toStringTag,{value:"Module"})),itn="erd-update-dismissed-version",atn="erd-update-notified-version";function EYi(){return!!window.__TAURI__||!!window.__TAURI_INTERNALS__}async function kB(e,t,A){if(EYi())try{await fetch("http://localhost:3099/api/log/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:e,message:t,extra:A,timestamp:new Date().toISOString()})})}catch{}}function IYi(e,t,A){const[n,i]=J.useState(!1),[u,o]=J.useState(null),[s,l]=J.useState(!1),[d,h]=J.useState(!1),[f,B]=J.useState(null),E=J.useRef(e);E.current=e;const p=J.useRef(!1),y=J.useRef(null),b=J.useRef(!1),v=J.useCallback(T=>{localStorage.setItem(itn,T)},[]),x=J.useCallback(T=>typeof window>"u"?!1:localStorage.getItem(itn)===T,[]),S=J.useCallback(async T=>{var P;if(kB("debug","handleDownloadUpdate called",`downloadingRef=${b.current} version=${T.version}`),b.current){kB("debug","BLOCKED: download already in progress");return}b.current=!0,h(!0),kB("info","download STARTED");const U=gA.loading("Downloading update...",{description:"Please wait, downloading the latest version."});kB("info","download_started",T.version);try{let R=0,Y=0;await T.downloadAndInstall(H=>{switch(H.event){case"Started":Y=H.data.contentLength||0,kB("info","download_progress",`0% of ${JGe(Y)}`),gA.loading("Downloading update...",{id:U,description:`0% - ${JGe(Y)}`});break;case"Progress":R+=H.data.chunkLength;const j=Math.round(R/Y*100);gA.loading(`Downloading update... ${j}%`,{id:U,description:`${JGe(R)} / ${JGe(Y)}`});break;case"Finished":kB("info","download_finished","ready to install");break}}),kB("info","downloadAndInstall resolved — install complete"),gA.success("Update installed successfully!",{id:U,description:"The application will now restart to apply the update.",duration:8e3}),setTimeout(async()=>{try{const{relaunch:H}=await Xr(async()=>{const{relaunch:j}=await Promise.resolve().then(()=>hIa);return{relaunch:j}},[]);await H()}catch{window.location.reload()}},1e3),h(!1),b.current=!1}catch(R){const Y=typeof R=="string"?R:(R==null?void 0:R.message)||((P=R==null?void 0:R.toString)==null?void 0:P.call(R))||JSON.stringify(R);kB("error","download_failed",Y),gA.error("Update failed",{id:U,description:Y||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(Y).catch(()=>{})}}),h(!1),b.current=!1}},[]),L=J.useCallback(async(T=!1)=>{var Y,H;if(kB("debug","performCheck called",`isManual=${T} checkingRef=${p.current}`),!(!!window.__TAURI__||!!window.__TAURI_INTERNALS__))return kB("debug","SKIP: not Tauri"),!1;if(p.current)return kB("debug","SKIP: already checking"),!1;p.current=!0,l(!0);let P="";try{const{getVersion:j}=await Xr(async()=>{const{getVersion:K}=await Promise.resolve().then(()=>zFn);return{getVersion:K}},void 0);P=await j()}catch{P="0.0.0"}let R;T&&(R=gA.loading("Checking for updates...",{description:`ERD Builder Pro v${P}`})),kB("info","check_started",`current=${P} manual=${T}`);try{const j=await Y6n();if(j)return i(!0),o(j.version),B(j),R&&gA.dismiss(R),!T&&(y.current===j.version||x(j.version))?(kB("debug","SKIP toast: already shown/dismissed",j.version),l(!1),p.current=!1,!0):(y.current=j.version,kB("info","update_available",`v${j.version}`),T&&localStorage.getItem(atn)===j.version?(kB("debug","SKIP toast: already notified by auto-check",j.version),i(!0),o(j.version),B(j),(Y=E.current)==null||Y.call(E),l(!1),p.current=!1,!0):(kB("debug","SHOWING toast: Update Available",`v${j.version} manual=${T}`),gA.info("Update Available",{description:`New version (v${j.version}) is ready.`,duration:1/0,action:{label:"Update Now",onClick:()=>S(j)},cancel:{label:"Later",onClick:()=>v(j.version)}}),T||localStorage.setItem(atn,j.version),(H=E.current)==null||H.call(E),l(!1),p.current=!1,!0));R&&gA.dismiss(R),T&&gA.success("You're up to date",{description:`ERD Builder Pro v${P} is the latest version.`}),kB("info","no_update",`current=${P}`),i(!1),o(null),B(null)}catch(j){kB("error","check_failed",(j==null?void 0:j.message)||String(j)),R&&gA.dismiss(R),T&&gA.error("Check failed",{description:"Could not check for updates. Check your internet connection."})}return l(!1),p.current=!1,!1},[x,S]),N=J.useCallback(()=>{kB("debug","handleDownload called",`update=${f==null?void 0:f.version} downloadingRef=${b.current}`),f&&S(f)},[f,S]),O=J.useRef(L);O.current=L;const M=J.useCallback(()=>{kB("debug","checkNow (manual trigger)"),O.current(!0)},[]);return J.useEffect(()=>{kB("debug","scheduling auto-check in 5s");const T=setTimeout(()=>{kB("debug","auto-check timer fired"),O.current(!1)},5e3);return()=>clearTimeout(T)},[t]),J.useEffect(()=>{const T=()=>O.current(!0);return window.addEventListener("menu-check-update",T),()=>window.removeEventListener("menu-check-update",T)},[A]),{hasUpdate:n,latestVersion:u,isChecking:s,isDownloading:d,checkNow:M,handleDownload:N}}function JGe(e){if(e===0)return"0 B";const t=1024,A=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,n)*100)/100+" "+A[n]}const P6n="erd-version-check",utn="erd-version-current",pYi=3600*1e3;function _6n(){try{return"3.1.1"}catch{return"0.0.0"}}async function QYi(){try{const A=await fetch("/api/version/current");if(A.ok){const n=await A.json(),i=n==null?void 0:n.current;if(i&&i!=="0.0.0")return localStorage.setItem(utn,i),i}}catch{}const e=localStorage.getItem(utn);return e||_6n()}function otn(){try{const e=localStorage.getItem(P6n);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.fetchedAt>pYi?null:t}catch{return null}}function mYi(e,t){try{localStorage.setItem(P6n,JSON.stringify({latest:e,current:t,fetchedAt:Date.now()}))}catch{}}function wYi(){const[e,t]=J.useState(!1),[A,n]=J.useState(null),[i,u]=J.useState(_6n()),o=J.useRef(!1),s=J.useCallback(async()=>{if(o.current)return;o.current=!0;const l=await QYi();u(l);const d=otn();if(d&&d.current===l){d.latest!==l&&d.latest&&(t(!0),n(d.latest));return}try{const f=await fetch("/api/version/latest");if(!f.ok)return;const B=await f.json(),E=B==null?void 0:B.latest;if(!E)return;mYi(E,l),E!==l&&(t(!0),n(E))}catch{const h=otn();h&&h.latest!==l&&h.latest&&(t(!0),n(h.latest))}},[]);return J.useEffect(()=>{s()},[s]),{isOutdated:e,latestVersion:A,currentVersion:i,checkNow:s}}function yYi(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const A=document.implementation.createHTMLDocument(),n=A.createElement("base"),i=A.createElement("a");return A.head.appendChild(n),A.body.appendChild(i),t&&(n.href=t),i.href=e,i.href}const bYi=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function fT(e){const t=[];for(let A=0,n=e.length;A<n;A++)t.push(e[A]);return t}function dht(e,t){const n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace("px","")):0}function DYi(e){const t=dht(e,"border-left-width"),A=dht(e,"border-right-width");return e.clientWidth+t+A}function vYi(e){const t=dht(e,"border-top-width"),A=dht(e,"border-bottom-width");return e.clientHeight+t+A}function j6n(e,t={}){const A=t.width||DYi(e),n=t.height||vYi(e);return{width:A,height:n}}function kYi(){let e,t;try{t=process}catch{}const A=t&&t.env?t.env.devicePixelRatio:null;return A&&(e=parseInt(A,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const BD=16384;function xYi(e){(e.width>BD||e.height>BD)&&(e.width>BD&&e.height>BD?e.width>e.height?(e.height*=BD/e.width,e.width=BD):(e.width*=BD/e.height,e.height=BD):e.width>BD?(e.height*=BD/e.width,e.width=BD):(e.width*=BD/e.height,e.height=BD))}function hht(e){return new Promise((t,A)=>{const n=new Image;n.decode=()=>t(n),n.onload=()=>t(n),n.onerror=A,n.crossOrigin="anonymous",n.decoding="async",n.src=e})}async function FYi(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function SYi(e,t,A){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),u=document.createElementNS(n,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${A}`),i.setAttribute("viewBox",`0 0 ${t} ${A}`),u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("externalResourcesRequired","true"),i.appendChild(u),u.appendChild(e),FYi(i)}const R5=(e,t)=>{if(e instanceof t)return!0;const A=Object.getPrototypeOf(e);return A===null?!1:A.constructor.name===t.name||R5(A,t)};function LYi(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function OYi(e){return fT(e).map(t=>{const A=e.getPropertyValue(t),n=e.getPropertyPriority(t);return`${t}: ${A}${n?" !important":""};`}).join(" ")}function NYi(e,t,A){const n=`.${e}:${t}`,i=A.cssText?LYi(A):OYi(A);return document.createTextNode(`${n}{${i}}`)}function stn(e,t,A){const n=window.getComputedStyle(e,A),i=n.getPropertyValue("content");if(i===""||i==="none")return;const u=bYi();try{t.className=`${t.className} ${u}`}catch{return}const o=document.createElement("style");o.appendChild(NYi(u,A,n)),t.appendChild(o)}function MYi(e,t){stn(e,t,":before"),stn(e,t,":after")}const ltn="application/font-woff",ctn="image/jpeg",RYi={woff:ltn,woff2:ltn,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:ctn,jpeg:ctn,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function UYi(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function PiA(e){const t=UYi(e).toLowerCase();return RYi[t]||""}function GYi(e){return e.split(/,/)[1]}function NWt(e){return e.search(/^(data:)/)!==-1}function TYi(e,t){return`data:${t};base64,${e}`}async function K6n(e,t,A){const n=await fetch(e,t);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const i=await n.blob();return new Promise((u,o)=>{const s=new FileReader;s.onerror=o,s.onloadend=()=>{try{u(A({res:n,result:s.result}))}catch(l){o(l)}},s.readAsDataURL(i)})}const YTt={};function HYi(e,t,A){let n=e.replace(/\?.*/,"");return A&&(n=e),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),t?`[${t}]${n}`:n}async function _iA(e,t,A){const n=HYi(e,t,A.includeQueryParams);if(YTt[n]!=null)return YTt[n];A.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const u=await K6n(e,A.fetchRequestInit,({res:o,result:s})=>(t||(t=o.headers.get("Content-Type")||""),GYi(s)));i=TYi(u,t)}catch(u){i=A.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;u&&(o=typeof u=="string"?u:u.message),o&&console.warn(o)}return YTt[n]=i,i}async function YYi(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):hht(t)}async function PYi(e,t){if(e.currentSrc){const u=document.createElement("canvas"),o=u.getContext("2d");u.width=e.clientWidth,u.height=e.clientHeight,o==null||o.drawImage(e,0,0,u.width,u.height);const s=u.toDataURL();return hht(s)}const A=e.poster,n=PiA(A),i=await _iA(A,n,t);return hht(i)}async function _Yi(e){var t;try{if(!((t=e==null?void 0:e.contentDocument)===null||t===void 0)&&t.body)return await xEt(e.contentDocument.body,{},!0)}catch{}return e.cloneNode(!1)}async function jYi(e,t){return R5(e,HTMLCanvasElement)?YYi(e):R5(e,HTMLVideoElement)?PYi(e,t):R5(e,HTMLIFrameElement)?_Yi(e):e.cloneNode(!1)}const KYi=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT";async function JYi(e,t,A){var n,i;let u=[];return KYi(e)&&e.assignedNodes?u=fT(e.assignedNodes()):R5(e,HTMLIFrameElement)&&(!((n=e.contentDocument)===null||n===void 0)&&n.body)?u=fT(e.contentDocument.body.childNodes):u=fT(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),u.length===0||R5(e,HTMLVideoElement)||await u.reduce((o,s)=>o.then(()=>xEt(s,A)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function $Yi(e,t){const A=t.style;if(!A)return;const n=window.getComputedStyle(e);n.cssText?(A.cssText=n.cssText,A.transformOrigin=n.transformOrigin):fT(n).forEach(i=>{let u=n.getPropertyValue(i);i==="font-size"&&u.endsWith("px")&&(u=`${Math.floor(parseFloat(u.substring(0,u.length-2)))-.1}px`),R5(e,HTMLIFrameElement)&&i==="display"&&u==="inline"&&(u="block"),i==="d"&&t.getAttribute("d")&&(u=`path(${t.getAttribute("d")})`),A.setProperty(i,u,n.getPropertyPriority(i))})}function zYi(e,t){R5(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),R5(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function qYi(e,t){if(R5(e,HTMLSelectElement)){const n=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));n&&n.setAttribute("selected","")}}function WYi(e,t){return R5(t,Element)&&($Yi(e,t),MYi(e,t),zYi(e,t),qYi(e,t)),t}async function ZYi(e,t){const A=e.querySelectorAll?e.querySelectorAll("use"):[];if(A.length===0)return e;const n={};for(let u=0;u<A.length;u++){const s=A[u].getAttribute("xlink:href");if(s){const l=e.querySelector(s),d=document.querySelector(s);!l&&d&&!n[s]&&(n[s]=await xEt(d,t,!0))}}const i=Object.values(n);if(i.length){const u="http://www.w3.org/1999/xhtml",o=document.createElementNS(u,"svg");o.setAttribute("xmlns",u),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const s=document.createElementNS(u,"defs");o.appendChild(s);for(let l=0;l<i.length;l++)s.appendChild(i[l]);e.appendChild(o)}return e}async function xEt(e,t,A){return!A&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(n=>jYi(n,t)).then(n=>JYi(e,n,t)).then(n=>WYi(e,n)).then(n=>ZYi(n,t))}const J6n=/url\((['"]?)([^'"]+?)\1\)/g,VYi=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,XYi=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ePi(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function tPi(e){const t=[];return e.replace(J6n,(A,n,i)=>(t.push(i),A)),t.filter(A=>!NWt(A))}async function APi(e,t,A,n,i){try{const u=A?yYi(t,A):t,o=PiA(t);let s;return i||(s=await _iA(u,o,n)),e.replace(ePi(t),`$1${s}$3`)}catch{}return e}function nPi(e,{preferredFontFormat:t}){return t?e.replace(XYi,A=>{for(;;){const[n,,i]=VYi.exec(A)||[];if(!i)return"";if(i===t)return`src: ${n};`}}):e}function $6n(e){return e.search(J6n)!==-1}async function z6n(e,t,A){if(!$6n(e))return e;const n=nPi(e,A);return tPi(n).reduce((u,o)=>u.then(s=>APi(s,o,t,A)),Promise.resolve(n))}async function $Ge(e,t,A){var n;const i=(n=t.style)===null||n===void 0?void 0:n.getPropertyValue(e);if(i){const u=await z6n(i,null,A);return t.style.setProperty(e,u,t.style.getPropertyPriority(e)),!0}return!1}async function rPi(e,t){await $Ge("background",e,t)||await $Ge("background-image",e,t),await $Ge("mask",e,t)||await $Ge("mask-image",e,t)}async function iPi(e,t){const A=R5(e,HTMLImageElement);if(!(A&&!NWt(e.src))&&!(R5(e,SVGImageElement)&&!NWt(e.href.baseVal)))return;const n=A?e.src:e.href.baseVal,i=await _iA(n,PiA(n),t);await new Promise((u,o)=>{e.onload=u,e.onerror=o;const s=e;s.decode&&(s.decode=u),s.loading==="lazy"&&(s.loading="eager"),A?(e.srcset="",e.src=i):e.href.baseVal=i})}async function aPi(e,t){const n=fT(e.childNodes).map(i=>q6n(i,t));await Promise.all(n).then(()=>e)}async function q6n(e,t){R5(e,Element)&&(await rPi(e,t),await iPi(e,t),await aPi(e,t))}function uPi(e,t){const{style:A}=e;t.backgroundColor&&(A.backgroundColor=t.backgroundColor),t.width&&(A.width=`${t.width}px`),t.height&&(A.height=`${t.height}px`);const n=t.style;return n!=null&&Object.keys(n).forEach(i=>{A[i]=n[i]}),e}const gtn={};async function dtn(e){let t=gtn[e];if(t!=null)return t;const n=await(await fetch(e)).text();return t={url:e,cssText:n},gtn[e]=t,t}async function htn(e,t){let A=e.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,u=(A.match(/url\([^)]+\)/g)||[]).map(async o=>{let s=o.replace(n,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),K6n(s,t.fetchRequestInit,({result:l})=>(A=A.replace(o,`url(${l})`),[o,l]))});return Promise.all(u).then(()=>A)}function Ctn(e){if(e==null)return[];const t=[],A=/(\/\*[\s\S]*?\*\/)/gi;let n=e.replace(A,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(n);if(l===null)break;t.push(l[0])}n=n.replace(i,"");const u=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(o,"gi");for(;;){let l=u.exec(n);if(l===null){if(l=s.exec(n),l===null)break;u.lastIndex=s.lastIndex}else s.lastIndex=u.lastIndex;t.push(l[0])}return t}async function oPi(e,t){const A=[],n=[];return e.forEach(i=>{if("cssRules"in i)try{fT(i.cssRules||[]).forEach((u,o)=>{if(u.type===CSSRule.IMPORT_RULE){let s=o+1;const l=u.href,d=dtn(l).then(h=>htn(h,t)).then(h=>Ctn(h).forEach(f=>{try{i.insertRule(f,f.startsWith("@import")?s+=1:i.cssRules.length)}catch(B){console.error("Error inserting rule from remote css",{rule:f,error:B})}})).catch(h=>{console.error("Error loading remote css",h.toString())});n.push(d)}})}catch(u){const o=e.find(s=>s.href==null)||document.styleSheets[0];i.href!=null&&n.push(dtn(i.href).then(s=>htn(s,t)).then(s=>Ctn(s).forEach(l=>{o.insertRule(l,i.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",u)}}),Promise.all(n).then(()=>(e.forEach(i=>{if("cssRules"in i)try{fT(i.cssRules||[]).forEach(u=>{A.push(u)})}catch(u){console.error(`Error while reading CSS rules from ${i.href}`,u)}}),A))}function sPi(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>$6n(t.style.getPropertyValue("src")))}async function lPi(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const A=fT(e.ownerDocument.styleSheets),n=await oPi(A,t);return sPi(n)}async function cPi(e,t){const A=await lPi(e,t);return(await Promise.all(A.map(i=>{const u=i.parentStyleSheet?i.parentStyleSheet.href:null;return z6n(i.cssText,u,t)}))).join(`
|
|
8390
|
+
`,l.add(O))}}});const d=new Blob([s],{type:"text/plain"}),h=URL.createObjectURL(d),f=document.createElement("a");f.href=h,f.download=`${A.name.toLowerCase().replace(/\s+/g,"_")}_schema.sql`,f.click(),URL.revokeObjectURL(h)}}}function bQ(e,t,A,n){if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return A==="m"?n:A==="a"?n.call(e):n?n.value:t.get(e)}function W0e(e,t,A,n,i){if(typeof t=="function"?e!==t||!0:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t.set(e,A),A}var UZ,ek,r0e,KGe,Qct;const j5="__TAURI_TO_IPC_KEY__";function T6n(e,t=!1){return window.__TAURI_INTERNALS__.transformCallback(e,t)}let SWt=class{constructor(t){UZ.set(this,void 0),ek.set(this,0),r0e.set(this,[]),KGe.set(this,void 0),W0e(this,UZ,t||(()=>{})),this.id=T6n(A=>{const n=A.index;if("end"in A){n==bQ(this,ek,"f")?this.cleanupCallback():W0e(this,KGe,n);return}const i=A.message;if(n==bQ(this,ek,"f")){for(bQ(this,UZ,"f").call(this,i),W0e(this,ek,bQ(this,ek,"f")+1);bQ(this,ek,"f")in bQ(this,r0e,"f");){const u=bQ(this,r0e,"f")[bQ(this,ek,"f")];bQ(this,UZ,"f").call(this,u),delete bQ(this,r0e,"f")[bQ(this,ek,"f")],W0e(this,ek,bQ(this,ek,"f")+1)}bQ(this,ek,"f")===bQ(this,KGe,"f")&&this.cleanupCallback()}else bQ(this,r0e,"f")[n]=i})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(t){W0e(this,UZ,t)}get onmessage(){return bQ(this,UZ,"f")}[(UZ=new WeakMap,ek=new WeakMap,r0e=new WeakMap,KGe=new WeakMap,j5)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[j5]()}};class ntn{constructor(t,A,n){this.plugin=t,this.event=A,this.channelId=n}async unregister(){return jr(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function BYi(e,t,A){const n=new SWt(A);try{return await jr(`plugin:${e}|register_listener`,{event:t,handler:n}),new ntn(e,t,n.id)}catch{return await jr(`plugin:${e}|registerListener`,{event:t,handler:n}),new ntn(e,t,n.id)}}async function jr(e,t={},A){return window.__TAURI_INTERNALS__.invoke(e,t,A)}class LWt{get rid(){return bQ(this,Qct,"f")}constructor(t){Qct.set(this,void 0),W0e(this,Qct,t)}async close(){return jr("plugin:resources|close",{rid:this.rid})}}Qct=new WeakMap;class H6n extends LWt{constructor(t){super(t.rid),this.available=!0,this.currentVersion=t.currentVersion,this.version=t.version,this.date=t.date,this.body=t.body,this.rawJson=t.rawJson}async download(t,A){OWt(A);const n=new SWt;t&&(n.onmessage=t);const i=await jr("plugin:updater|download",{onEvent:n,rid:this.rid,...A});this.downloadedBytes=new LWt(i)}async install(){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await jr("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(t,A){OWt(A);const n=new SWt;t&&(n.onmessage=t),await jr("plugin:updater|download_and_install",{onEvent:n,rid:this.rid,...A})}async close(){var t;await((t=this.downloadedBytes)==null?void 0:t.close()),await super.close()}}async function Y6n(e){OWt(e);const t=await jr("plugin:updater|check",{...e});return t?new H6n(t):null}function OWt(e){e!=null&&e.headers&&(e.headers=Array.from(new Headers(e.headers).entries()))}const rtn=Object.freeze(Object.defineProperty({__proto__:null,Update:H6n,check:Y6n},Symbol.toStringTag,{value:"Module"})),itn="erd-update-dismissed-version",atn="erd-update-notified-version";function EYi(){return!!window.__TAURI__||!!window.__TAURI_INTERNALS__}async function kB(e,t,A){if(EYi())try{await fetch("http://localhost:3099/api/log/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:e,message:t,extra:A,timestamp:new Date().toISOString()})})}catch{}}function IYi(e,t,A){const[n,i]=J.useState(!1),[u,o]=J.useState(null),[s,l]=J.useState(!1),[d,h]=J.useState(!1),[f,B]=J.useState(null),E=J.useRef(e);E.current=e;const p=J.useRef(!1),y=J.useRef(null),b=J.useRef(!1),v=J.useCallback(T=>{localStorage.setItem(itn,T)},[]),x=J.useCallback(T=>typeof window>"u"?!1:localStorage.getItem(itn)===T,[]),S=J.useCallback(async T=>{var P;if(kB("debug","handleDownloadUpdate called",`downloadingRef=${b.current} version=${T.version}`),b.current){kB("debug","BLOCKED: download already in progress");return}b.current=!0,h(!0),kB("info","download STARTED");const U=gA.loading("Downloading update...",{description:"Please wait, downloading the latest version."});kB("info","download_started",T.version);try{let R=0,Y=0;await T.downloadAndInstall(H=>{switch(H.event){case"Started":Y=H.data.contentLength||0,kB("info","download_progress",`0% of ${JGe(Y)}`),gA.loading("Downloading update...",{id:U,description:`0% - ${JGe(Y)}`});break;case"Progress":R+=H.data.chunkLength;const j=Math.round(R/Y*100);gA.loading(`Downloading update... ${j}%`,{id:U,description:`${JGe(R)} / ${JGe(Y)}`});break;case"Finished":kB("info","download_finished","ready to install");break}}),kB("info","downloadAndInstall resolved — install complete"),gA.success("Update installed successfully!",{id:U,description:"The application will now restart to apply the update.",duration:8e3}),setTimeout(async()=>{try{const{relaunch:H}=await Xr(async()=>{const{relaunch:j}=await Promise.resolve().then(()=>hIa);return{relaunch:j}},[]);await H()}catch{window.location.reload()}},1e3),h(!1),b.current=!1}catch(R){const Y=typeof R=="string"?R:(R==null?void 0:R.message)||((P=R==null?void 0:R.toString)==null?void 0:P.call(R))||JSON.stringify(R);kB("error","download_failed",Y),gA.error("Update failed",{id:U,description:Y||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(Y).catch(()=>{})}}),h(!1),b.current=!1}},[]),L=J.useCallback(async(T=!1)=>{var Y,H;if(kB("debug","performCheck called",`isManual=${T} checkingRef=${p.current}`),!(!!window.__TAURI__||!!window.__TAURI_INTERNALS__))return kB("debug","SKIP: not Tauri"),!1;if(p.current)return kB("debug","SKIP: already checking"),!1;p.current=!0,l(!0);let P="";try{const{getVersion:j}=await Xr(async()=>{const{getVersion:K}=await Promise.resolve().then(()=>zFn);return{getVersion:K}},void 0);P=await j()}catch{P="0.0.0"}let R;T&&(R=gA.loading("Checking for updates...",{description:`ERD Builder Pro v${P}`})),kB("info","check_started",`current=${P} manual=${T}`);try{const j=await Y6n();if(j)return i(!0),o(j.version),B(j),R&&gA.dismiss(R),!T&&(y.current===j.version||x(j.version))?(kB("debug","SKIP toast: already shown/dismissed",j.version),l(!1),p.current=!1,!0):(y.current=j.version,kB("info","update_available",`v${j.version}`),T&&localStorage.getItem(atn)===j.version?(kB("debug","SKIP toast: already notified by auto-check",j.version),i(!0),o(j.version),B(j),(Y=E.current)==null||Y.call(E),l(!1),p.current=!1,!0):(kB("debug","SHOWING toast: Update Available",`v${j.version} manual=${T}`),gA.info("Update Available",{description:`New version (v${j.version}) is ready.`,duration:1/0,action:{label:"Update Now",onClick:()=>S(j)},cancel:{label:"Later",onClick:()=>v(j.version)}}),T||localStorage.setItem(atn,j.version),(H=E.current)==null||H.call(E),l(!1),p.current=!1,!0));R&&gA.dismiss(R),T&&gA.success("You're up to date",{description:`ERD Builder Pro v${P} is the latest version.`}),kB("info","no_update",`current=${P}`),i(!1),o(null),B(null)}catch(j){kB("error","check_failed",(j==null?void 0:j.message)||String(j)),R&&gA.dismiss(R),T&&gA.error("Check failed",{description:"Could not check for updates. Check your internet connection."})}return l(!1),p.current=!1,!1},[x,S]),N=J.useCallback(()=>{kB("debug","handleDownload called",`update=${f==null?void 0:f.version} downloadingRef=${b.current}`),f&&S(f)},[f,S]),O=J.useRef(L);O.current=L;const M=J.useCallback(()=>{kB("debug","checkNow (manual trigger)"),O.current(!0)},[]);return J.useEffect(()=>{kB("debug","scheduling auto-check in 5s");const T=setTimeout(()=>{kB("debug","auto-check timer fired"),O.current(!1)},5e3);return()=>clearTimeout(T)},[t]),J.useEffect(()=>{const T=()=>O.current(!0);return window.addEventListener("menu-check-update",T),()=>window.removeEventListener("menu-check-update",T)},[A]),{hasUpdate:n,latestVersion:u,isChecking:s,isDownloading:d,checkNow:M,handleDownload:N}}function JGe(e){if(e===0)return"0 B";const t=1024,A=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,n)*100)/100+" "+A[n]}const P6n="erd-version-check",utn="erd-version-current",pYi=3600*1e3;function _6n(){try{return"3.1.2"}catch{return"0.0.0"}}async function QYi(){try{const A=await fetch("/api/version/current");if(A.ok){const n=await A.json(),i=n==null?void 0:n.current;if(i&&i!=="0.0.0")return localStorage.setItem(utn,i),i}}catch{}const e=localStorage.getItem(utn);return e||_6n()}function otn(){try{const e=localStorage.getItem(P6n);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.fetchedAt>pYi?null:t}catch{return null}}function mYi(e,t){try{localStorage.setItem(P6n,JSON.stringify({latest:e,current:t,fetchedAt:Date.now()}))}catch{}}function wYi(){const[e,t]=J.useState(!1),[A,n]=J.useState(null),[i,u]=J.useState(_6n()),o=J.useRef(!1),s=J.useCallback(async()=>{if(o.current)return;o.current=!0;const l=await QYi();u(l);const d=otn();if(d&&d.current===l){d.latest!==l&&d.latest&&(t(!0),n(d.latest));return}try{const f=await fetch("/api/version/latest");if(!f.ok)return;const B=await f.json(),E=B==null?void 0:B.latest;if(!E)return;mYi(E,l),E!==l&&(t(!0),n(E))}catch{const h=otn();h&&h.latest!==l&&h.latest&&(t(!0),n(h.latest))}},[]);return J.useEffect(()=>{s()},[s]),{isOutdated:e,latestVersion:A,currentVersion:i,checkNow:s}}function yYi(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const A=document.implementation.createHTMLDocument(),n=A.createElement("base"),i=A.createElement("a");return A.head.appendChild(n),A.body.appendChild(i),t&&(n.href=t),i.href=e,i.href}const bYi=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function fT(e){const t=[];for(let A=0,n=e.length;A<n;A++)t.push(e[A]);return t}function dht(e,t){const n=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return n?parseFloat(n.replace("px","")):0}function DYi(e){const t=dht(e,"border-left-width"),A=dht(e,"border-right-width");return e.clientWidth+t+A}function vYi(e){const t=dht(e,"border-top-width"),A=dht(e,"border-bottom-width");return e.clientHeight+t+A}function j6n(e,t={}){const A=t.width||DYi(e),n=t.height||vYi(e);return{width:A,height:n}}function kYi(){let e,t;try{t=process}catch{}const A=t&&t.env?t.env.devicePixelRatio:null;return A&&(e=parseInt(A,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const BD=16384;function xYi(e){(e.width>BD||e.height>BD)&&(e.width>BD&&e.height>BD?e.width>e.height?(e.height*=BD/e.width,e.width=BD):(e.width*=BD/e.height,e.height=BD):e.width>BD?(e.height*=BD/e.width,e.width=BD):(e.width*=BD/e.height,e.height=BD))}function hht(e){return new Promise((t,A)=>{const n=new Image;n.decode=()=>t(n),n.onload=()=>t(n),n.onerror=A,n.crossOrigin="anonymous",n.decoding="async",n.src=e})}async function FYi(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function SYi(e,t,A){const n="http://www.w3.org/2000/svg",i=document.createElementNS(n,"svg"),u=document.createElementNS(n,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${A}`),i.setAttribute("viewBox",`0 0 ${t} ${A}`),u.setAttribute("width","100%"),u.setAttribute("height","100%"),u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("externalResourcesRequired","true"),i.appendChild(u),u.appendChild(e),FYi(i)}const R5=(e,t)=>{if(e instanceof t)return!0;const A=Object.getPrototypeOf(e);return A===null?!1:A.constructor.name===t.name||R5(A,t)};function LYi(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function OYi(e){return fT(e).map(t=>{const A=e.getPropertyValue(t),n=e.getPropertyPriority(t);return`${t}: ${A}${n?" !important":""};`}).join(" ")}function NYi(e,t,A){const n=`.${e}:${t}`,i=A.cssText?LYi(A):OYi(A);return document.createTextNode(`${n}{${i}}`)}function stn(e,t,A){const n=window.getComputedStyle(e,A),i=n.getPropertyValue("content");if(i===""||i==="none")return;const u=bYi();try{t.className=`${t.className} ${u}`}catch{return}const o=document.createElement("style");o.appendChild(NYi(u,A,n)),t.appendChild(o)}function MYi(e,t){stn(e,t,":before"),stn(e,t,":after")}const ltn="application/font-woff",ctn="image/jpeg",RYi={woff:ltn,woff2:ltn,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:ctn,jpeg:ctn,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function UYi(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function PiA(e){const t=UYi(e).toLowerCase();return RYi[t]||""}function GYi(e){return e.split(/,/)[1]}function NWt(e){return e.search(/^(data:)/)!==-1}function TYi(e,t){return`data:${t};base64,${e}`}async function K6n(e,t,A){const n=await fetch(e,t);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const i=await n.blob();return new Promise((u,o)=>{const s=new FileReader;s.onerror=o,s.onloadend=()=>{try{u(A({res:n,result:s.result}))}catch(l){o(l)}},s.readAsDataURL(i)})}const YTt={};function HYi(e,t,A){let n=e.replace(/\?.*/,"");return A&&(n=e),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),t?`[${t}]${n}`:n}async function _iA(e,t,A){const n=HYi(e,t,A.includeQueryParams);if(YTt[n]!=null)return YTt[n];A.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const u=await K6n(e,A.fetchRequestInit,({res:o,result:s})=>(t||(t=o.headers.get("Content-Type")||""),GYi(s)));i=TYi(u,t)}catch(u){i=A.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;u&&(o=typeof u=="string"?u:u.message),o&&console.warn(o)}return YTt[n]=i,i}async function YYi(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):hht(t)}async function PYi(e,t){if(e.currentSrc){const u=document.createElement("canvas"),o=u.getContext("2d");u.width=e.clientWidth,u.height=e.clientHeight,o==null||o.drawImage(e,0,0,u.width,u.height);const s=u.toDataURL();return hht(s)}const A=e.poster,n=PiA(A),i=await _iA(A,n,t);return hht(i)}async function _Yi(e){var t;try{if(!((t=e==null?void 0:e.contentDocument)===null||t===void 0)&&t.body)return await xEt(e.contentDocument.body,{},!0)}catch{}return e.cloneNode(!1)}async function jYi(e,t){return R5(e,HTMLCanvasElement)?YYi(e):R5(e,HTMLVideoElement)?PYi(e,t):R5(e,HTMLIFrameElement)?_Yi(e):e.cloneNode(!1)}const KYi=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT";async function JYi(e,t,A){var n,i;let u=[];return KYi(e)&&e.assignedNodes?u=fT(e.assignedNodes()):R5(e,HTMLIFrameElement)&&(!((n=e.contentDocument)===null||n===void 0)&&n.body)?u=fT(e.contentDocument.body.childNodes):u=fT(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),u.length===0||R5(e,HTMLVideoElement)||await u.reduce((o,s)=>o.then(()=>xEt(s,A)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function $Yi(e,t){const A=t.style;if(!A)return;const n=window.getComputedStyle(e);n.cssText?(A.cssText=n.cssText,A.transformOrigin=n.transformOrigin):fT(n).forEach(i=>{let u=n.getPropertyValue(i);i==="font-size"&&u.endsWith("px")&&(u=`${Math.floor(parseFloat(u.substring(0,u.length-2)))-.1}px`),R5(e,HTMLIFrameElement)&&i==="display"&&u==="inline"&&(u="block"),i==="d"&&t.getAttribute("d")&&(u=`path(${t.getAttribute("d")})`),A.setProperty(i,u,n.getPropertyPriority(i))})}function zYi(e,t){R5(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),R5(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function qYi(e,t){if(R5(e,HTMLSelectElement)){const n=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));n&&n.setAttribute("selected","")}}function WYi(e,t){return R5(t,Element)&&($Yi(e,t),MYi(e,t),zYi(e,t),qYi(e,t)),t}async function ZYi(e,t){const A=e.querySelectorAll?e.querySelectorAll("use"):[];if(A.length===0)return e;const n={};for(let u=0;u<A.length;u++){const s=A[u].getAttribute("xlink:href");if(s){const l=e.querySelector(s),d=document.querySelector(s);!l&&d&&!n[s]&&(n[s]=await xEt(d,t,!0))}}const i=Object.values(n);if(i.length){const u="http://www.w3.org/1999/xhtml",o=document.createElementNS(u,"svg");o.setAttribute("xmlns",u),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const s=document.createElementNS(u,"defs");o.appendChild(s);for(let l=0;l<i.length;l++)s.appendChild(i[l]);e.appendChild(o)}return e}async function xEt(e,t,A){return!A&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(n=>jYi(n,t)).then(n=>JYi(e,n,t)).then(n=>WYi(e,n)).then(n=>ZYi(n,t))}const J6n=/url\((['"]?)([^'"]+?)\1\)/g,VYi=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,XYi=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ePi(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function tPi(e){const t=[];return e.replace(J6n,(A,n,i)=>(t.push(i),A)),t.filter(A=>!NWt(A))}async function APi(e,t,A,n,i){try{const u=A?yYi(t,A):t,o=PiA(t);let s;return i||(s=await _iA(u,o,n)),e.replace(ePi(t),`$1${s}$3`)}catch{}return e}function nPi(e,{preferredFontFormat:t}){return t?e.replace(XYi,A=>{for(;;){const[n,,i]=VYi.exec(A)||[];if(!i)return"";if(i===t)return`src: ${n};`}}):e}function $6n(e){return e.search(J6n)!==-1}async function z6n(e,t,A){if(!$6n(e))return e;const n=nPi(e,A);return tPi(n).reduce((u,o)=>u.then(s=>APi(s,o,t,A)),Promise.resolve(n))}async function $Ge(e,t,A){var n;const i=(n=t.style)===null||n===void 0?void 0:n.getPropertyValue(e);if(i){const u=await z6n(i,null,A);return t.style.setProperty(e,u,t.style.getPropertyPriority(e)),!0}return!1}async function rPi(e,t){await $Ge("background",e,t)||await $Ge("background-image",e,t),await $Ge("mask",e,t)||await $Ge("mask-image",e,t)}async function iPi(e,t){const A=R5(e,HTMLImageElement);if(!(A&&!NWt(e.src))&&!(R5(e,SVGImageElement)&&!NWt(e.href.baseVal)))return;const n=A?e.src:e.href.baseVal,i=await _iA(n,PiA(n),t);await new Promise((u,o)=>{e.onload=u,e.onerror=o;const s=e;s.decode&&(s.decode=u),s.loading==="lazy"&&(s.loading="eager"),A?(e.srcset="",e.src=i):e.href.baseVal=i})}async function aPi(e,t){const n=fT(e.childNodes).map(i=>q6n(i,t));await Promise.all(n).then(()=>e)}async function q6n(e,t){R5(e,Element)&&(await rPi(e,t),await iPi(e,t),await aPi(e,t))}function uPi(e,t){const{style:A}=e;t.backgroundColor&&(A.backgroundColor=t.backgroundColor),t.width&&(A.width=`${t.width}px`),t.height&&(A.height=`${t.height}px`);const n=t.style;return n!=null&&Object.keys(n).forEach(i=>{A[i]=n[i]}),e}const gtn={};async function dtn(e){let t=gtn[e];if(t!=null)return t;const n=await(await fetch(e)).text();return t={url:e,cssText:n},gtn[e]=t,t}async function htn(e,t){let A=e.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,u=(A.match(/url\([^)]+\)/g)||[]).map(async o=>{let s=o.replace(n,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),K6n(s,t.fetchRequestInit,({result:l})=>(A=A.replace(o,`url(${l})`),[o,l]))});return Promise.all(u).then(()=>A)}function Ctn(e){if(e==null)return[];const t=[],A=/(\/\*[\s\S]*?\*\/)/gi;let n=e.replace(A,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(n);if(l===null)break;t.push(l[0])}n=n.replace(i,"");const u=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(o,"gi");for(;;){let l=u.exec(n);if(l===null){if(l=s.exec(n),l===null)break;u.lastIndex=s.lastIndex}else s.lastIndex=u.lastIndex;t.push(l[0])}return t}async function oPi(e,t){const A=[],n=[];return e.forEach(i=>{if("cssRules"in i)try{fT(i.cssRules||[]).forEach((u,o)=>{if(u.type===CSSRule.IMPORT_RULE){let s=o+1;const l=u.href,d=dtn(l).then(h=>htn(h,t)).then(h=>Ctn(h).forEach(f=>{try{i.insertRule(f,f.startsWith("@import")?s+=1:i.cssRules.length)}catch(B){console.error("Error inserting rule from remote css",{rule:f,error:B})}})).catch(h=>{console.error("Error loading remote css",h.toString())});n.push(d)}})}catch(u){const o=e.find(s=>s.href==null)||document.styleSheets[0];i.href!=null&&n.push(dtn(i.href).then(s=>htn(s,t)).then(s=>Ctn(s).forEach(l=>{o.insertRule(l,i.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",u)}}),Promise.all(n).then(()=>(e.forEach(i=>{if("cssRules"in i)try{fT(i.cssRules||[]).forEach(u=>{A.push(u)})}catch(u){console.error(`Error while reading CSS rules from ${i.href}`,u)}}),A))}function sPi(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>$6n(t.style.getPropertyValue("src")))}async function lPi(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const A=fT(e.ownerDocument.styleSheets),n=await oPi(A,t);return sPi(n)}async function cPi(e,t){const A=await lPi(e,t);return(await Promise.all(A.map(i=>{const u=i.parentStyleSheet?i.parentStyleSheet.href:null;return z6n(i.cssText,u,t)}))).join(`
|
|
8391
8391
|
`)}async function gPi(e,t){const A=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await cPi(e,t);if(A){const n=document.createElement("style"),i=document.createTextNode(A);n.appendChild(i),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n)}}async function W6n(e,t={}){const{width:A,height:n}=j6n(e,t),i=await xEt(e,t,!0);return await gPi(i,t),await q6n(i,t),uPi(i,t),await SYi(i,A,n)}async function dPi(e,t={}){const{width:A,height:n}=j6n(e,t),i=await W6n(e,t),u=await hht(i),o=document.createElement("canvas"),s=o.getContext("2d"),l=t.pixelRatio||kYi(),d=t.canvasWidth||A,h=t.canvasHeight||n;return o.width=d*l,o.height=h*l,t.skipAutoScale||xYi(o),o.style.width=`${d}`,o.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,o.width,o.height)),s.drawImage(u,0,0,o.width,o.height),o}async function hPi(e,t={}){return(await dPi(e,t)).toDataURL()}function Bg(e){"@babel/helpers - typeof";return Bg=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bg(e)}var KF=Uint8Array,HD=Uint16Array,jiA=Int32Array,KiA=new KF([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),JiA=new KF([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ftn=new KF([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Z6n=function(e,t){for(var A=new HD(31),n=0;n<31;++n)A[n]=t+=1<<e[n-1];for(var i=new jiA(A[30]),n=1;n<30;++n)for(var u=A[n];u<A[n+1];++u)i[u]=u-A[n]<<5|n;return{b:A,r:i}},V6n=Z6n(KiA,2),CPi=V6n.b,MWt=V6n.r;CPi[28]=258,MWt[258]=28;var fPi=Z6n(JiA,0),Btn=fPi.r,RWt=new HD(32768);for(var YC=0;YC<32768;++YC){var Y_=(YC&43690)>>1|(YC&21845)<<1;Y_=(Y_&52428)>>2|(Y_&13107)<<2,Y_=(Y_&61680)>>4|(Y_&3855)<<4,RWt[YC]=((Y_&65280)>>8|(Y_&255)<<8)>>1}var Lwe=(function(e,t,A){for(var n=e.length,i=0,u=new HD(t);i<n;++i)e[i]&&++u[e[i]-1];var o=new HD(t);for(i=1;i<t;++i)o[i]=o[i-1]+u[i-1]<<1;var s;if(A){s=new HD(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var d=i<<4|e[i],h=t-e[i],f=o[e[i]-1]++<<h,B=f|(1<<h)-1;f<=B;++f)s[RWt[f]>>l]=d}else for(s=new HD(n),i=0;i<n;++i)e[i]&&(s[i]=RWt[o[e[i]-1]++]>>15-e[i]);return s}),Ene=new KF(288);for(var YC=0;YC<144;++YC)Ene[YC]=8;for(var YC=144;YC<256;++YC)Ene[YC]=9;for(var YC=256;YC<280;++YC)Ene[YC]=7;for(var YC=280;YC<288;++YC)Ene[YC]=8;var Cht=new KF(32);for(var YC=0;YC<32;++YC)Cht[YC]=5;var BPi=Lwe(Ene,9,0),EPi=Lwe(Cht,5,0),X6n=function(e){return(e+7)/8|0},IPi=function(e,t,A){return(A==null||A>e.length)&&(A=e.length),new KF(e.subarray(t,A))},VU=function(e,t,A){A<<=t&7;var n=t/8|0;e[n]|=A,e[n+1]|=A>>8},lQe=function(e,t,A){A<<=t&7;var n=t/8|0;e[n]|=A,e[n+1]|=A>>8,e[n+2]|=A>>16},PTt=function(e,t){for(var A=[],n=0;n<e.length;++n)e[n]&&A.push({s:n,f:e[n]});var i=A.length,u=A.slice();if(!i)return{t:tDn,l:0};if(i==1){var o=new KF(A[0].s+1);return o[A[0].s]=1,{t:o,l:1}}A.sort(function(N,O){return N.f-O.f}),A.push({s:-1,f:25001});var s=A[0],l=A[1],d=0,h=1,f=2;for(A[0]={s:-1,f:s.f+l.f,l:s,r:l};h!=i-1;)s=A[A[d].f<A[f].f?d++:f++],l=A[d!=h&&A[d].f<A[f].f?d++:f++],A[h++]={s:-1,f:s.f+l.f,l:s,r:l};for(var B=u[0].s,n=1;n<i;++n)u[n].s>B&&(B=u[n].s);var E=new HD(B+1),p=UWt(A[h-1],E,0);if(p>t){var n=0,y=0,b=p-t,v=1<<b;for(u.sort(function(O,M){return E[M.s]-E[O.s]||O.f-M.f});n<i;++n){var x=u[n].s;if(E[x]>t)y+=v-(1<<p-E[x]),E[x]=t;else break}for(y>>=b;y>0;){var S=u[n].s;E[S]<t?y-=1<<t-E[S]++-1:++n}for(;n>=0&&y;--n){var L=u[n].s;E[L]==t&&(--E[L],++y)}p=t}return{t:new KF(E),l:p}},UWt=function(e,t,A){return e.s==-1?Math.max(UWt(e.l,t,A+1),UWt(e.r,t,A+1)):t[e.s]=A},Etn=function(e){for(var t=e.length;t&&!e[--t];);for(var A=new HD(++t),n=0,i=e[0],u=1,o=function(l){A[n++]=l},s=1;s<=t;++s)if(e[s]==i&&s!=t)++u;else{if(!i&&u>2){for(;u>138;u-=138)o(32754);u>2&&(o(u>10?u-11<<5|28690:u-3<<5|12305),u=0)}else if(u>3){for(o(i),--u;u>6;u-=6)o(8304);u>2&&(o(u-3<<5|8208),u=0)}for(;u--;)o(i);u=1,i=e[s]}return{c:A.subarray(0,n),n:t}},cQe=function(e,t){for(var A=0,n=0;n<t.length;++n)A+=e[n]*t[n];return A},eDn=function(e,t,A){var n=A.length,i=X6n(t+2);e[i]=n&255,e[i+1]=n>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var u=0;u<n;++u)e[i+u+4]=A[u];return(i+4+n)*8},Itn=function(e,t,A,n,i,u,o,s,l,d,h){VU(t,h++,A),++i[256];for(var f=PTt(i,15),B=f.t,E=f.l,p=PTt(u,15),y=p.t,b=p.l,v=Etn(B),x=v.c,S=v.n,L=Etn(y),N=L.c,O=L.n,M=new HD(19),T=0;T<x.length;++T)++M[x[T]&31];for(var T=0;T<N.length;++T)++M[N[T]&31];for(var U=PTt(M,7),P=U.t,R=U.l,Y=19;Y>4&&!P[ftn[Y-1]];--Y);var H=d+5<<3,j=cQe(i,Ene)+cQe(u,Cht)+o,K=cQe(i,B)+cQe(u,y)+o+14+3*Y+cQe(M,P)+2*M[16]+3*M[17]+7*M[18];if(l>=0&&H<=j&&H<=K)return eDn(t,h,e.subarray(l,l+d));var W,q,ee,V;if(VU(t,h,1+(K<j)),h+=2,K<j){W=Lwe(B,E,0),q=B,ee=Lwe(y,b,0),V=y;var Z=Lwe(P,R,0);VU(t,h,S-257),VU(t,h+5,O-1),VU(t,h+10,Y-4),h+=14;for(var T=0;T<Y;++T)VU(t,h+3*T,P[ftn[T]]);h+=3*Y;for(var re=[x,N],ae=0;ae<2;++ae)for(var ne=re[ae],T=0;T<ne.length;++T){var ge=ne[T]&31;VU(t,h,Z[ge]),h+=P[ge],ge>15&&(VU(t,h,ne[T]>>5&127),h+=ne[T]>>12)}}else W=BPi,q=Ene,ee=EPi,V=Cht;for(var T=0;T<s;++T){var le=n[T];if(le>255){var ge=le>>18&31;lQe(t,h,W[ge+257]),h+=q[ge+257],ge>7&&(VU(t,h,le>>23&31),h+=KiA[ge]);var Ce=le&31;lQe(t,h,ee[Ce]),h+=V[Ce],Ce>3&&(lQe(t,h,le>>5&8191),h+=JiA[Ce])}else lQe(t,h,W[le]),h+=q[le]}return lQe(t,h,W[256]),h+q[256]},pPi=new jiA([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),tDn=new KF(0),QPi=function(e,t,A,n,i,u){var o=u.z||e.length,s=new KF(n+o+5*(1+Math.ceil(o/7e3))+i),l=s.subarray(n,s.length-i),d=u.l,h=(u.r||0)&7;if(t){h&&(l[0]=u.r>>3);for(var f=pPi[t-1],B=f>>13,E=f&8191,p=(1<<A)-1,y=u.p||new HD(32768),b=u.h||new HD(p+1),v=Math.ceil(A/3),x=2*v,S=function(Be){return(e[Be]^e[Be+1]<<v^e[Be+2]<<x)&p},L=new jiA(25e3),N=new HD(288),O=new HD(32),M=0,T=0,U=u.i||0,P=0,R=u.w||0,Y=0;U+2<o;++U){var H=S(U),j=U&32767,K=b[H];if(y[j]=K,b[H]=j,R<=U){var W=o-U;if((M>7e3||P>24576)&&(W>423||!d)){h=Itn(e,l,0,L,N,O,T,P,Y,U-Y,h),P=M=T=0,Y=U;for(var q=0;q<286;++q)N[q]=0;for(var q=0;q<30;++q)O[q]=0}var ee=2,V=0,Z=E,re=j-K&32767;if(W>2&&H==S(U-re))for(var ae=Math.min(B,W)-1,ne=Math.min(32767,U),ge=Math.min(258,W);re<=ne&&--Z&&j!=K;){if(e[U+ee]==e[U+ee-re]){for(var le=0;le<ge&&e[U+le]==e[U+le-re];++le);if(le>ee){if(ee=le,V=re,le>ae)break;for(var Ce=Math.min(re,le-2),fe=0,q=0;q<Ce;++q){var we=U-re+q&32767,me=y[we],De=we-me&32767;De>fe&&(fe=De,K=we)}}}j=K,K=y[j],re+=j-K&32767}if(V){L[P++]=268435456|MWt[ee]<<18|Btn[V];var be=MWt[ee]&31,Le=Btn[V]&31;T+=KiA[be]+JiA[Le],++N[257+be],++O[Le],R=U+ee,++M}else L[P++]=e[U],++N[e[U]]}}for(U=Math.max(U,R);U<o;++U)L[P++]=e[U],++N[e[U]];h=Itn(e,l,d,L,N,O,T,P,Y,U-Y,h),d||(u.r=h&7|l[h/8|0]<<3,h-=7,u.h=b,u.p=y,u.i=U,u.w=R)}else{for(var U=u.w||0;U<o+d;U+=65535){var Se=U+65535;Se>=o&&(l[h/8|0]=d,Se=o),h=eDn(l,h+1,e.subarray(U,Se))}u.i=o}return IPi(s,0,n+X6n(h)+i)},ADn=function(){var e=1,t=0;return{p:function(A){for(var n=e,i=t,u=A.length|0,o=0;o!=u;){for(var s=Math.min(o+2655,u);o<s;++o)i+=n+=A[o];n=(n&65535)+15*(n>>16),i=(i&65535)+15*(i>>16)}e=n,t=i},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},mPi=function(e,t,A,n,i){if(!i&&(i={l:1},t.dictionary)){var u=t.dictionary.subarray(-32768),o=new KF(u.length+e.length);o.set(u),o.set(e,u.length),e=o,i.w=u.length}return QPi(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,A,n,i)},nDn=function(e,t,A){for(;A;++t)e[t]=A,A>>>=8},wPi=function(e,t){var A=t.level,n=A==0?0:A<6?1:A==9?3:2;if(e[0]=120,e[1]=n<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var i=ADn();i.p(t.dictionary),nDn(e,2,i.d())}};function GWt(e,t){t||(t={});var A=ADn();A.p(e);var n=mPi(e,t,t.dictionary?6:2,4);return wPi(n,t),nDn(n,n.length-4,A.d()),n}var yPi=typeof TextDecoder<"u"&&new TextDecoder,bPi=0;try{yPi.decode(tDn,{stream:!0}),bPi=1}catch{}function DPi(e){if(Array.isArray(e))return e}function vPi(e,t){var A=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(A!=null){var n,i,u,o,s=[],l=!0,d=!1;try{if(u=(A=A.call(e)).next,t!==0)for(;!(l=(n=u.call(A)).done)&&(s.push(n.value),s.length!==t);l=!0);}catch(h){d=!0,i=h}finally{try{if(!l&&A.return!=null&&(o=A.return(),Object(o)!==o))return}finally{if(d)throw i}}return s}}function ptn(e,t){(t==null||t>e.length)&&(t=e.length);for(var A=0,n=Array(t);A<t;A++)n[A]=e[A];return n}function kPi(e,t){if(e){if(typeof e=="string")return ptn(e,t);var A={}.toString.call(e).slice(8,-1);return A==="Object"&&e.constructor&&(A=e.constructor.name),A==="Map"||A==="Set"?Array.from(e):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?ptn(e,t):void 0}}function xPi(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8392
8392
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Qtn(e,t){return DPi(e)||vPi(e,t)||kPi(e,t)||xPi()}function mtn(e,t="utf8"){return new TextDecoder(t).decode(e)}const FPi=new TextEncoder;function SPi(e){return FPi.encode(e)}const LPi=1024*8,OPi=(()=>{const e=new Uint8Array(4),t=new Uint32Array(e.buffer);return!((t[0]=1)&e[0])})(),_Tt={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class $iA{constructor(t=LPi,A={}){ra(this,"buffer");ra(this,"byteLength");ra(this,"byteOffset");ra(this,"length");ra(this,"offset");ra(this,"lastWrittenByte");ra(this,"littleEndian");ra(this,"_data");ra(this,"_mark");ra(this,"_marks");let n=!1;typeof t=="number"?t=new ArrayBuffer(t):(n=!0,this.lastWrittenByte=t.byteLength);const i=A.offset?A.offset>>>0:0,u=t.byteLength-i;let o=i;(ArrayBuffer.isView(t)||t instanceof $iA)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+i),t=t.buffer),n?this.lastWrittenByte=u:this.lastWrittenByte=0,this.buffer=t,this.length=u,this.byteLength=u,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,u),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}back(t=1){return this.offset-=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){const n=(this.offset+t)*2,i=new Uint8Array(n);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=n,this.byteLength=n,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){return this.readArray(t,"uint8")}readArray(t,A){const n=_Tt[A].BYTES_PER_ELEMENT*t,i=this.byteOffset+this.offset,u=this.buffer.slice(i,i+n);if(this.littleEndian===OPi&&A!=="uint8"&&A!=="int8"){const s=new Uint8Array(this.buffer.slice(i,i+n));s.reverse();const l=new _Tt[A](s.buffer);return this.offset+=n,l.reverse(),l}const o=new _Tt[A](u);return this.offset+=n,o}readInt16(){const t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){const t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){const t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){const t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){const t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){const t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readBigInt64(){const t=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,t}readBigUint64(){const t=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let A="";for(let n=0;n<t;n++)A+=this.readChar();return A}readUtf8(t=1){return mtn(this.readBytes(t))}decodeText(t=1,A="utf8"){return mtn(this.readBytes(t),A)}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let A=0;A<t.length;A++)this._data.setUint8(this.offset++,t[A]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(t){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(t){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let A=0;A<t.length;A++)this.writeUint8(t.charCodeAt(A));return this}writeUtf8(t){return this.writeBytes(SPi(t))}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}getWrittenByteLength(){return this.lastWrittenByte-this.byteOffset}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ghe(e){let t=e.length;for(;--t>=0;)e[t]=0}const NPi=3,MPi=258,rDn=29,RPi=256,UPi=RPi+1+rDn,iDn=30,GPi=512,TPi=new Array((UPi+2)*2);ghe(TPi);const HPi=new Array(iDn*2);ghe(HPi);const YPi=new Array(GPi);ghe(YPi);const PPi=new Array(MPi-NPi+1);ghe(PPi);const _Pi=new Array(rDn);ghe(_Pi);const jPi=new Array(iDn);ghe(jPi);const KPi=(e,t,A,n)=>{let i=e&65535|0,u=e>>>16&65535|0,o=0;for(;A!==0;){o=A>2e3?2e3:A,A-=o;do i=i+t[n++]|0,u=u+i|0;while(--o);i%=65521,u%=65521}return i|u<<16|0};var TWt=KPi;const JPi=()=>{let e,t=[];for(var A=0;A<256;A++){e=A;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;t[A]=e}return t},$Pi=new Uint32Array(JPi()),zPi=(e,t,A,n)=>{const i=$Pi,u=n+A;e^=-1;for(let o=n;o<u;o++)e=e>>>8^i[(e^t[o])&255];return e^-1};var IO=zPi,HWt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},aDn={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const qPi=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var WPi=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const A=t.shift();if(A){if(typeof A!="object")throw new TypeError(A+"must be non-object");for(const n in A)qPi(A,n)&&(e[n]=A[n])}}return e},ZPi=e=>{let t=0;for(let n=0,i=e.length;n<i;n++)t+=e[n].length;const A=new Uint8Array(t);for(let n=0,i=0,u=e.length;n<u;n++){let o=e[n];A.set(o,i),i+=o.length}return A},uDn={assign:WPi,flattenChunks:ZPi};let oDn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{oDn=!1}const Ebe=new Uint8Array(256);for(let e=0;e<256;e++)Ebe[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ebe[254]=Ebe[254]=1;var VPi=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,A,n,i,u,o=e.length,s=0;for(i=0;i<o;i++)A=e.charCodeAt(i),(A&64512)===55296&&i+1<o&&(n=e.charCodeAt(i+1),(n&64512)===56320&&(A=65536+(A-55296<<10)+(n-56320),i++)),s+=A<128?1:A<2048?2:A<65536?3:4;for(t=new Uint8Array(s),u=0,i=0;u<s;i++)A=e.charCodeAt(i),(A&64512)===55296&&i+1<o&&(n=e.charCodeAt(i+1),(n&64512)===56320&&(A=65536+(A-55296<<10)+(n-56320),i++)),A<128?t[u++]=A:A<2048?(t[u++]=192|A>>>6,t[u++]=128|A&63):A<65536?(t[u++]=224|A>>>12,t[u++]=128|A>>>6&63,t[u++]=128|A&63):(t[u++]=240|A>>>18,t[u++]=128|A>>>12&63,t[u++]=128|A>>>6&63,t[u++]=128|A&63);return t};const XPi=(e,t)=>{if(t<65534&&e.subarray&&oDn)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let A="";for(let n=0;n<t;n++)A+=String.fromCharCode(e[n]);return A};var e_i=(e,t)=>{const A=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let n,i;const u=new Array(A*2);for(i=0,n=0;n<A;){let o=e[n++];if(o<128){u[i++]=o;continue}let s=Ebe[o];if(s>4){u[i++]=65533,n+=s-1;continue}for(o&=s===2?31:s===3?15:7;s>1&&n<A;)o=o<<6|e[n++]&63,s--;if(s>1){u[i++]=65533;continue}o<65536?u[i++]=o:(o-=65536,u[i++]=55296|o>>10&1023,u[i++]=56320|o&1023)}return XPi(u,i)},t_i=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let A=t-1;for(;A>=0&&(e[A]&192)===128;)A--;return A<0||A===0?t:A+Ebe[e[A]]>t?A:t},YWt={string2buf:VPi,buf2string:e_i,utf8border:t_i};function A_i(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var n_i=A_i;const zGe=16209,r_i=16191;var i_i=function(t,A){let n,i,u,o,s,l,d,h,f,B,E,p,y,b,v,x,S,L,N,O,M,T,U,P;const R=t.state;n=t.next_in,U=t.input,i=n+(t.avail_in-5),u=t.next_out,P=t.output,o=u-(A-t.avail_out),s=u+(t.avail_out-257),l=R.dmax,d=R.wsize,h=R.whave,f=R.wnext,B=R.window,E=R.hold,p=R.bits,y=R.lencode,b=R.distcode,v=(1<<R.lenbits)-1,x=(1<<R.distbits)-1;e:do{p<15&&(E+=U[n++]<<p,p+=8,E+=U[n++]<<p,p+=8),S=y[E&v];t:for(;;){if(L=S>>>24,E>>>=L,p-=L,L=S>>>16&255,L===0)P[u++]=S&65535;else if(L&16){N=S&65535,L&=15,L&&(p<L&&(E+=U[n++]<<p,p+=8),N+=E&(1<<L)-1,E>>>=L,p-=L),p<15&&(E+=U[n++]<<p,p+=8,E+=U[n++]<<p,p+=8),S=b[E&x];A:for(;;){if(L=S>>>24,E>>>=L,p-=L,L=S>>>16&255,L&16){if(O=S&65535,L&=15,p<L&&(E+=U[n++]<<p,p+=8,p<L&&(E+=U[n++]<<p,p+=8)),O+=E&(1<<L)-1,O>l){t.msg="invalid distance too far back",R.mode=zGe;break e}if(E>>>=L,p-=L,L=u-o,O>L){if(L=O-L,L>h&&R.sane){t.msg="invalid distance too far back",R.mode=zGe;break e}if(M=0,T=B,f===0){if(M+=d-L,L<N){N-=L;do P[u++]=B[M++];while(--L);M=u-O,T=P}}else if(f<L){if(M+=d+f-L,L-=f,L<N){N-=L;do P[u++]=B[M++];while(--L);if(M=0,f<N){L=f,N-=L;do P[u++]=B[M++];while(--L);M=u-O,T=P}}}else if(M+=f-L,L<N){N-=L;do P[u++]=B[M++];while(--L);M=u-O,T=P}for(;N>2;)P[u++]=T[M++],P[u++]=T[M++],P[u++]=T[M++],N-=3;N&&(P[u++]=T[M++],N>1&&(P[u++]=T[M++]))}else{M=u-O;do P[u++]=P[M++],P[u++]=P[M++],P[u++]=P[M++],N-=3;while(N>2);N&&(P[u++]=P[M++],N>1&&(P[u++]=P[M++]))}}else if((L&64)===0){S=b[(S&65535)+(E&(1<<L)-1)];continue A}else{t.msg="invalid distance code",R.mode=zGe;break e}break}}else if((L&64)===0){S=y[(S&65535)+(E&(1<<L)-1)];continue t}else if(L&32){R.mode=r_i;break e}else{t.msg="invalid literal/length code",R.mode=zGe;break e}break}}while(n<i&&u<s);N=p>>3,n-=N,p-=N<<3,E&=(1<<p)-1,t.next_in=n,t.next_out=u,t.avail_in=n<i?5+(i-n):5-(n-i),t.avail_out=u<s?257+(s-u):257-(u-s),R.hold=E,R.bits=p};const i0e=15,wtn=852,ytn=592,btn=0,jTt=1,Dtn=2,a_i=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),u_i=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),o_i=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),s_i=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),l_i=(e,t,A,n,i,u,o,s)=>{const l=s.bits;let d=0,h=0,f=0,B=0,E=0,p=0,y=0,b=0,v=0,x=0,S,L,N,O,M,T=null,U;const P=new Uint16Array(i0e+1),R=new Uint16Array(i0e+1);let Y=null,H,j,K;for(d=0;d<=i0e;d++)P[d]=0;for(h=0;h<n;h++)P[t[A+h]]++;for(E=l,B=i0e;B>=1&&P[B]===0;B--);if(E>B&&(E=B),B===0)return i[u++]=1<<24|64<<16|0,i[u++]=1<<24|64<<16|0,s.bits=1,0;for(f=1;f<B&&P[f]===0;f++);for(E<f&&(E=f),b=1,d=1;d<=i0e;d++)if(b<<=1,b-=P[d],b<0)return-1;if(b>0&&(e===btn||B!==1))return-1;for(R[1]=0,d=1;d<i0e;d++)R[d+1]=R[d]+P[d];for(h=0;h<n;h++)t[A+h]!==0&&(o[R[t[A+h]]++]=h);if(e===btn?(T=Y=o,U=20):e===jTt?(T=a_i,Y=u_i,U=257):(T=o_i,Y=s_i,U=0),x=0,h=0,d=f,M=u,p=E,y=0,N=-1,v=1<<E,O=v-1,e===jTt&&v>wtn||e===Dtn&&v>ytn)return 1;for(;;){H=d-y,o[h]+1<U?(j=0,K=o[h]):o[h]>=U?(j=Y[o[h]-U],K=T[o[h]-U]):(j=96,K=0),S=1<<d-y,L=1<<p,f=L;do L-=S,i[M+(x>>y)+L]=H<<24|j<<16|K|0;while(L!==0);for(S=1<<d-1;x&S;)S>>=1;if(S!==0?(x&=S-1,x+=S):x=0,h++,--P[d]===0){if(d===B)break;d=t[A+o[h]]}if(d>E&&(x&O)!==N){for(y===0&&(y=E),M+=f,p=d-y,b=1<<p;p+y<B&&(b-=P[p+y],!(b<=0));)p++,b<<=1;if(v+=1<<p,e===jTt&&v>wtn||e===Dtn&&v>ytn)return 1;N=x&O,i[N]=E<<24|p<<16|M-u|0}}return x!==0&&(i[M+x]=d-y<<24|64<<16|0),s.bits=E,0};var Owe=l_i;const c_i=0,sDn=1,lDn=2,{Z_FINISH:vtn,Z_BLOCK:g_i,Z_TREES:qGe,Z_OK:Ine,Z_STREAM_END:d_i,Z_NEED_DICT:h_i,Z_STREAM_ERROR:lx,Z_DATA_ERROR:cDn,Z_MEM_ERROR:gDn,Z_BUF_ERROR:C_i,Z_DEFLATED:ktn}=aDn,FEt=16180,xtn=16181,Ftn=16182,Stn=16183,Ltn=16184,Otn=16185,Ntn=16186,Mtn=16187,Rtn=16188,Utn=16189,fht=16190,XU=16191,KTt=16192,Gtn=16193,JTt=16194,Ttn=16195,Htn=16196,Ytn=16197,Ptn=16198,WGe=16199,ZGe=16200,_tn=16201,jtn=16202,Ktn=16203,Jtn=16204,$tn=16205,$Tt=16206,ztn=16207,qtn=16208,m1=16209,dDn=16210,hDn=16211,f_i=852,B_i=592,E_i=15,I_i=E_i,Wtn=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function p_i(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const pre=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<FEt||t.mode>hDn?1:0},CDn=e=>{if(pre(e))return lx;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=FEt,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(f_i),t.distcode=t.distdyn=new Int32Array(B_i),t.sane=1,t.back=-1,Ine},fDn=e=>{if(pre(e))return lx;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,CDn(e)},BDn=(e,t)=>{let A;if(pre(e))return lx;const n=e.state;return t<0?(A=0,t=-t):(A=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?lx:(n.window!==null&&n.wbits!==t&&(n.window=null),n.wrap=A,n.wbits=t,fDn(e))},EDn=(e,t)=>{if(!e)return lx;const A=new p_i;e.state=A,A.strm=e,A.window=null,A.mode=FEt;const n=BDn(e,t);return n!==Ine&&(e.state=null),n},Q_i=e=>EDn(e,I_i);let Ztn=!0,zTt,qTt;const m_i=e=>{if(Ztn){zTt=new Int32Array(512),qTt=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Owe(sDn,e.lens,0,288,zTt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Owe(lDn,e.lens,0,32,qTt,0,e.work,{bits:5}),Ztn=!1}e.lencode=zTt,e.lenbits=9,e.distcode=qTt,e.distbits=5},IDn=(e,t,A,n)=>{let i;const u=e.state;return u.window===null&&(u.wsize=1<<u.wbits,u.wnext=0,u.whave=0,u.window=new Uint8Array(u.wsize)),n>=u.wsize?(u.window.set(t.subarray(A-u.wsize,A),0),u.wnext=0,u.whave=u.wsize):(i=u.wsize-u.wnext,i>n&&(i=n),u.window.set(t.subarray(A-n,A-n+i),u.wnext),n-=i,n?(u.window.set(t.subarray(A-n,A),0),u.wnext=n,u.whave=u.wsize):(u.wnext+=i,u.wnext===u.wsize&&(u.wnext=0),u.whave<u.wsize&&(u.whave+=i))),0},w_i=(e,t)=>{let A,n,i,u,o,s,l,d,h,f,B,E,p,y,b=0,v,x,S,L,N,O,M,T;const U=new Uint8Array(4);let P,R;const Y=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(pre(e)||!e.output||!e.input&&e.avail_in!==0)return lx;A=e.state,A.mode===XU&&(A.mode=KTt),o=e.next_out,i=e.output,l=e.avail_out,u=e.next_in,n=e.input,s=e.avail_in,d=A.hold,h=A.bits,f=s,B=l,T=Ine;e:for(;;)switch(A.mode){case FEt:if(A.wrap===0){A.mode=KTt;break}for(;h<16;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(A.wrap&2&&d===35615){A.wbits===0&&(A.wbits=15),A.check=0,U[0]=d&255,U[1]=d>>>8&255,A.check=IO(A.check,U,2,0),d=0,h=0,A.mode=xtn;break}if(A.head&&(A.head.done=!1),!(A.wrap&1)||(((d&255)<<8)+(d>>8))%31){e.msg="incorrect header check",A.mode=m1;break}if((d&15)!==ktn){e.msg="unknown compression method",A.mode=m1;break}if(d>>>=4,h-=4,M=(d&15)+8,A.wbits===0&&(A.wbits=M),M>15||M>A.wbits){e.msg="invalid window size",A.mode=m1;break}A.dmax=1<<A.wbits,A.flags=0,e.adler=A.check=1,A.mode=d&512?Utn:XU,d=0,h=0;break;case xtn:for(;h<16;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(A.flags=d,(A.flags&255)!==ktn){e.msg="unknown compression method",A.mode=m1;break}if(A.flags&57344){e.msg="unknown header flags set",A.mode=m1;break}A.head&&(A.head.text=d>>8&1),A.flags&512&&A.wrap&4&&(U[0]=d&255,U[1]=d>>>8&255,A.check=IO(A.check,U,2,0)),d=0,h=0,A.mode=Ftn;case Ftn:for(;h<32;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}A.head&&(A.head.time=d),A.flags&512&&A.wrap&4&&(U[0]=d&255,U[1]=d>>>8&255,U[2]=d>>>16&255,U[3]=d>>>24&255,A.check=IO(A.check,U,4,0)),d=0,h=0,A.mode=Stn;case Stn:for(;h<16;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}A.head&&(A.head.xflags=d&255,A.head.os=d>>8),A.flags&512&&A.wrap&4&&(U[0]=d&255,U[1]=d>>>8&255,A.check=IO(A.check,U,2,0)),d=0,h=0,A.mode=Ltn;case Ltn:if(A.flags&1024){for(;h<16;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}A.length=d,A.head&&(A.head.extra_len=d),A.flags&512&&A.wrap&4&&(U[0]=d&255,U[1]=d>>>8&255,A.check=IO(A.check,U,2,0)),d=0,h=0}else A.head&&(A.head.extra=null);A.mode=Otn;case Otn:if(A.flags&1024&&(E=A.length,E>s&&(E=s),E&&(A.head&&(M=A.head.extra_len-A.length,A.head.extra||(A.head.extra=new Uint8Array(A.head.extra_len)),A.head.extra.set(n.subarray(u,u+E),M)),A.flags&512&&A.wrap&4&&(A.check=IO(A.check,n,E,u)),s-=E,u+=E,A.length-=E),A.length))break e;A.length=0,A.mode=Ntn;case Ntn:if(A.flags&2048){if(s===0)break e;E=0;do M=n[u+E++],A.head&&M&&A.length<65536&&(A.head.name+=String.fromCharCode(M));while(M&&E<s);if(A.flags&512&&A.wrap&4&&(A.check=IO(A.check,n,E,u)),s-=E,u+=E,M)break e}else A.head&&(A.head.name=null);A.length=0,A.mode=Mtn;case Mtn:if(A.flags&4096){if(s===0)break e;E=0;do M=n[u+E++],A.head&&M&&A.length<65536&&(A.head.comment+=String.fromCharCode(M));while(M&&E<s);if(A.flags&512&&A.wrap&4&&(A.check=IO(A.check,n,E,u)),s-=E,u+=E,M)break e}else A.head&&(A.head.comment=null);A.mode=Rtn;case Rtn:if(A.flags&512){for(;h<16;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(A.wrap&4&&d!==(A.check&65535)){e.msg="header crc mismatch",A.mode=m1;break}d=0,h=0}A.head&&(A.head.hcrc=A.flags>>9&1,A.head.done=!0),e.adler=A.check=0,A.mode=XU;break;case Utn:for(;h<32;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}e.adler=A.check=Wtn(d),d=0,h=0,A.mode=fht;case fht:if(A.havedict===0)return e.next_out=o,e.avail_out=l,e.next_in=u,e.avail_in=s,A.hold=d,A.bits=h,h_i;e.adler=A.check=1,A.mode=XU;case XU:if(t===g_i||t===qGe)break e;case KTt:if(A.last){d>>>=h&7,h-=h&7,A.mode=$Tt;break}for(;h<3;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}switch(A.last=d&1,d>>>=1,h-=1,d&3){case 0:A.mode=Gtn;break;case 1:if(m_i(A),A.mode=WGe,t===qGe){d>>>=2,h-=2;break e}break;case 2:A.mode=Htn;break;case 3:e.msg="invalid block type",A.mode=m1}d>>>=2,h-=2;break;case Gtn:for(d>>>=h&7,h-=h&7;h<32;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if((d&65535)!==(d>>>16^65535)){e.msg="invalid stored block lengths",A.mode=m1;break}if(A.length=d&65535,d=0,h=0,A.mode=JTt,t===qGe)break e;case JTt:A.mode=Ttn;case Ttn:if(E=A.length,E){if(E>s&&(E=s),E>l&&(E=l),E===0)break e;i.set(n.subarray(u,u+E),o),s-=E,u+=E,l-=E,o+=E,A.length-=E;break}A.mode=XU;break;case Htn:for(;h<14;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(A.nlen=(d&31)+257,d>>>=5,h-=5,A.ndist=(d&31)+1,d>>>=5,h-=5,A.ncode=(d&15)+4,d>>>=4,h-=4,A.nlen>286||A.ndist>30){e.msg="too many length or distance symbols",A.mode=m1;break}A.have=0,A.mode=Ytn;case Ytn:for(;A.have<A.ncode;){for(;h<3;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}A.lens[Y[A.have++]]=d&7,d>>>=3,h-=3}for(;A.have<19;)A.lens[Y[A.have++]]=0;if(A.lencode=A.lendyn,A.lenbits=7,P={bits:A.lenbits},T=Owe(c_i,A.lens,0,19,A.lencode,0,A.work,P),A.lenbits=P.bits,T){e.msg="invalid code lengths set",A.mode=m1;break}A.have=0,A.mode=Ptn;case Ptn:for(;A.have<A.nlen+A.ndist;){for(;b=A.lencode[d&(1<<A.lenbits)-1],v=b>>>24,x=b>>>16&255,S=b&65535,!(v<=h);){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(S<16)d>>>=v,h-=v,A.lens[A.have++]=S;else{if(S===16){for(R=v+2;h<R;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(d>>>=v,h-=v,A.have===0){e.msg="invalid bit length repeat",A.mode=m1;break}M=A.lens[A.have-1],E=3+(d&3),d>>>=2,h-=2}else if(S===17){for(R=v+3;h<R;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}d>>>=v,h-=v,M=0,E=3+(d&7),d>>>=3,h-=3}else{for(R=v+7;h<R;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}d>>>=v,h-=v,M=0,E=11+(d&127),d>>>=7,h-=7}if(A.have+E>A.nlen+A.ndist){e.msg="invalid bit length repeat",A.mode=m1;break}for(;E--;)A.lens[A.have++]=M}}if(A.mode===m1)break;if(A.lens[256]===0){e.msg="invalid code -- missing end-of-block",A.mode=m1;break}if(A.lenbits=9,P={bits:A.lenbits},T=Owe(sDn,A.lens,0,A.nlen,A.lencode,0,A.work,P),A.lenbits=P.bits,T){e.msg="invalid literal/lengths set",A.mode=m1;break}if(A.distbits=6,A.distcode=A.distdyn,P={bits:A.distbits},T=Owe(lDn,A.lens,A.nlen,A.ndist,A.distcode,0,A.work,P),A.distbits=P.bits,T){e.msg="invalid distances set",A.mode=m1;break}if(A.mode=WGe,t===qGe)break e;case WGe:A.mode=ZGe;case ZGe:if(s>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=u,e.avail_in=s,A.hold=d,A.bits=h,i_i(e,B),o=e.next_out,i=e.output,l=e.avail_out,u=e.next_in,n=e.input,s=e.avail_in,d=A.hold,h=A.bits,A.mode===XU&&(A.back=-1);break}for(A.back=0;b=A.lencode[d&(1<<A.lenbits)-1],v=b>>>24,x=b>>>16&255,S=b&65535,!(v<=h);){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(x&&(x&240)===0){for(L=v,N=x,O=S;b=A.lencode[O+((d&(1<<L+N)-1)>>L)],v=b>>>24,x=b>>>16&255,S=b&65535,!(L+v<=h);){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}d>>>=L,h-=L,A.back+=L}if(d>>>=v,h-=v,A.back+=v,A.length=S,x===0){A.mode=$tn;break}if(x&32){A.back=-1,A.mode=XU;break}if(x&64){e.msg="invalid literal/length code",A.mode=m1;break}A.extra=x&15,A.mode=_tn;case _tn:if(A.extra){for(R=A.extra;h<R;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}A.length+=d&(1<<A.extra)-1,d>>>=A.extra,h-=A.extra,A.back+=A.extra}A.was=A.length,A.mode=jtn;case jtn:for(;b=A.distcode[d&(1<<A.distbits)-1],v=b>>>24,x=b>>>16&255,S=b&65535,!(v<=h);){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if((x&240)===0){for(L=v,N=x,O=S;b=A.distcode[O+((d&(1<<L+N)-1)>>L)],v=b>>>24,x=b>>>16&255,S=b&65535,!(L+v<=h);){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}d>>>=L,h-=L,A.back+=L}if(d>>>=v,h-=v,A.back+=v,x&64){e.msg="invalid distance code",A.mode=m1;break}A.offset=S,A.extra=x&15,A.mode=Ktn;case Ktn:if(A.extra){for(R=A.extra;h<R;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}A.offset+=d&(1<<A.extra)-1,d>>>=A.extra,h-=A.extra,A.back+=A.extra}if(A.offset>A.dmax){e.msg="invalid distance too far back",A.mode=m1;break}A.mode=Jtn;case Jtn:if(l===0)break e;if(E=B-l,A.offset>E){if(E=A.offset-E,E>A.whave&&A.sane){e.msg="invalid distance too far back",A.mode=m1;break}E>A.wnext?(E-=A.wnext,p=A.wsize-E):p=A.wnext-E,E>A.length&&(E=A.length),y=A.window}else y=i,p=o-A.offset,E=A.length;E>l&&(E=l),l-=E,A.length-=E;do i[o++]=y[p++];while(--E);A.length===0&&(A.mode=ZGe);break;case $tn:if(l===0)break e;i[o++]=A.length,l--,A.mode=ZGe;break;case $Tt:if(A.wrap){for(;h<32;){if(s===0)break e;s--,d|=n[u++]<<h,h+=8}if(B-=l,e.total_out+=B,A.total+=B,A.wrap&4&&B&&(e.adler=A.check=A.flags?IO(A.check,i,B,o-B):TWt(A.check,i,B,o-B)),B=l,A.wrap&4&&(A.flags?d:Wtn(d))!==A.check){e.msg="incorrect data check",A.mode=m1;break}d=0,h=0}A.mode=ztn;case ztn:if(A.wrap&&A.flags){for(;h<32;){if(s===0)break e;s--,d+=n[u++]<<h,h+=8}if(A.wrap&4&&d!==(A.total&4294967295)){e.msg="incorrect length check",A.mode=m1;break}d=0,h=0}A.mode=qtn;case qtn:T=d_i;break e;case m1:T=cDn;break e;case dDn:return gDn;case hDn:default:return lx}return e.next_out=o,e.avail_out=l,e.next_in=u,e.avail_in=s,A.hold=d,A.bits=h,(A.wsize||B!==e.avail_out&&A.mode<m1&&(A.mode<$Tt||t!==vtn))&&IDn(e,e.output,e.next_out,B-e.avail_out),f-=e.avail_in,B-=e.avail_out,e.total_in+=f,e.total_out+=B,A.total+=B,A.wrap&4&&B&&(e.adler=A.check=A.flags?IO(A.check,i,B,e.next_out-B):TWt(A.check,i,B,e.next_out-B)),e.data_type=A.bits+(A.last?64:0)+(A.mode===XU?128:0)+(A.mode===WGe||A.mode===JTt?256:0),(f===0&&B===0||t===vtn)&&T===Ine&&(T=C_i),T},y_i=e=>{if(pre(e))return lx;let t=e.state;return t.window&&(t.window=null),e.state=null,Ine},b_i=(e,t)=>{if(pre(e))return lx;const A=e.state;return(A.wrap&2)===0?lx:(A.head=t,t.done=!1,Ine)},D_i=(e,t)=>{const A=t.length;let n,i,u;return pre(e)||(n=e.state,n.wrap!==0&&n.mode!==fht)?lx:n.mode===fht&&(i=1,i=TWt(i,t,A,0),i!==n.check)?cDn:(u=IDn(e,t,A,A),u?(n.mode=dDn,gDn):(n.havedict=1,Ine))};var v_i=fDn,k_i=BDn,x_i=CDn,F_i=Q_i,S_i=EDn,L_i=w_i,O_i=y_i,N_i=b_i,M_i=D_i,R_i="pako inflate (from Nodeca project)",xG={inflateReset:v_i,inflateReset2:k_i,inflateResetKeep:x_i,inflateInit:F_i,inflateInit2:S_i,inflate:L_i,inflateEnd:O_i,inflateGetHeader:N_i,inflateSetDictionary:M_i,inflateInfo:R_i};function U_i(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var G_i=U_i;const pDn=Object.prototype.toString,{Z_NO_FLUSH:T_i,Z_FINISH:H_i,Z_OK:Ibe,Z_STREAM_END:WTt,Z_NEED_DICT:ZTt,Z_STREAM_ERROR:Y_i,Z_DATA_ERROR:Vtn,Z_MEM_ERROR:P_i}=aDn;function sDe(e){this.options=uDn.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new n_i,this.strm.avail_out=0;let A=xG.inflateInit2(this.strm,t.windowBits);if(A!==Ibe)throw new Error(HWt[A]);if(this.header=new G_i,xG.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=YWt.string2buf(t.dictionary):pDn.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(A=xG.inflateSetDictionary(this.strm,t.dictionary),A!==Ibe)))throw new Error(HWt[A])}sDe.prototype.push=function(e,t){const A=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let u,o,s;if(this.ended)return!1;for(t===~~t?o=t:o=t===!0?H_i:T_i,pDn.call(e)==="[object ArrayBuffer]"?A.input=new Uint8Array(e):A.input=e,A.next_in=0,A.avail_in=A.input.length;;){for(A.avail_out===0&&(A.output=new Uint8Array(n),A.next_out=0,A.avail_out=n),u=xG.inflate(A,o),u===ZTt&&i&&(u=xG.inflateSetDictionary(A,i),u===Ibe?u=xG.inflate(A,o):u===Vtn&&(u=ZTt));A.avail_in>0&&u===WTt&&A.state.wrap>0&&e[A.next_in]!==0;)xG.inflateReset(A),u=xG.inflate(A,o);switch(u){case Y_i:case Vtn:case ZTt:case P_i:return this.onEnd(u),this.ended=!0,!1}if(s=A.avail_out,A.next_out&&(A.avail_out===0||u===WTt))if(this.options.to==="string"){let l=YWt.utf8border(A.output,A.next_out),d=A.next_out-l,h=YWt.buf2string(A.output,l);A.next_out=d,A.avail_out=n-d,d&&A.output.set(A.output.subarray(l,l+d),0),this.onData(h)}else this.onData(A.output.length===A.next_out?A.output:A.output.subarray(0,A.next_out));if(!(u===Ibe&&s===0)){if(u===WTt)return u=xG.inflateEnd(this.strm),this.onEnd(u),this.ended=!0,!0;if(A.avail_in===0)break}}return!0};sDe.prototype.onData=function(e){this.chunks.push(e)};sDe.prototype.onEnd=function(e){e===Ibe&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=uDn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function __i(e,t){const A=new sDe(t);if(A.push(e),A.err)throw A.msg||HWt[A.err];return A.result}var j_i=sDe,K_i=__i,J_i={Inflate:j_i,inflate:K_i};const{Inflate:$_i,inflate:z_i}=J_i;var Xtn=$_i,q_i=z_i;const QDn=[];for(let e=0;e<256;e++){let t=e;for(let A=0;A<8;A++)t&1?t=3988292384^t>>>1:t=t>>>1;QDn[e]=t}const eAn=4294967295;function W_i(e,t,A){let n=e;for(let i=0;i<A;i++)n=QDn[(n^t[i])&255]^n>>>8;return n}function Z_i(e,t){return(W_i(eAn,e,t)^eAn)>>>0}function tAn(e,t,A){const n=e.readUint32(),i=Z_i(new Uint8Array(e.buffer,e.byteOffset+e.offset-t-4,t),t);if(i!==n)throw new Error(`CRC mismatch for chunk ${A}. Expected ${n}, found ${i}`)}function mDn(e,t,A){for(let n=0;n<A;n++)t[n]=e[n]}function wDn(e,t,A,n){let i=0;for(;i<n;i++)t[i]=e[i];for(;i<A;i++)t[i]=e[i]+t[i-n]&255}function yDn(e,t,A,n){let i=0;if(A.length===0)for(;i<n;i++)t[i]=e[i];else for(;i<n;i++)t[i]=e[i]+A[i]&255}function bDn(e,t,A,n,i){let u=0;if(A.length===0){for(;u<i;u++)t[u]=e[u];for(;u<n;u++)t[u]=e[u]+(t[u-i]>>1)&255}else{for(;u<i;u++)t[u]=e[u]+(A[u]>>1)&255;for(;u<n;u++)t[u]=e[u]+(t[u-i]+A[u]>>1)&255}}function DDn(e,t,A,n,i){let u=0;if(A.length===0){for(;u<i;u++)t[u]=e[u];for(;u<n;u++)t[u]=e[u]+t[u-i]&255}else{for(;u<i;u++)t[u]=e[u]+A[u]&255;for(;u<n;u++)t[u]=e[u]+V_i(t[u-i],A[u],A[u-i])&255}}function V_i(e,t,A){const n=e+t-A,i=Math.abs(n-e),u=Math.abs(n-t),o=Math.abs(n-A);return i<=u&&i<=o?e:u<=o?t:A}function X_i(e,t,A,n,i,u){switch(e){case 0:mDn(t,A,i);break;case 1:wDn(t,A,i,u);break;case 2:yDn(t,A,n,i);break;case 3:bDn(t,A,n,i,u);break;case 4:DDn(t,A,n,i,u);break;default:throw new Error(`Unsupported filter: ${e}`)}}const eji=new Uint16Array([255]),tji=new Uint8Array(eji.buffer),Aji=tji[0]===255;function nji(e){const{data:t,width:A,height:n,channels:i,depth:u}=e,o=[{x:0,y:0,xStep:8,yStep:8},{x:4,y:0,xStep:8,yStep:8},{x:0,y:4,xStep:4,yStep:8},{x:2,y:0,xStep:4,yStep:4},{x:0,y:2,xStep:2,yStep:4},{x:1,y:0,xStep:2,yStep:2},{x:0,y:1,xStep:1,yStep:2}],s=Math.ceil(u/8)*i,l=new Uint8Array(n*A*s);let d=0;for(let h=0;h<7;h++){const f=o[h],B=Math.ceil((A-f.x)/f.xStep),E=Math.ceil((n-f.y)/f.yStep);if(B<=0||E<=0)continue;const p=B*s,y=new Uint8Array(p);for(let b=0;b<E;b++){const v=t[d++],x=t.subarray(d,d+p);d+=p;const S=new Uint8Array(p);X_i(v,x,S,y,p,s),y.set(S);for(let L=0;L<B;L++){const N=f.x+L*f.xStep,O=f.y+b*f.yStep;if(!(N>=A||O>=n))for(let M=0;M<s;M++)l[(O*A+N)*s+M]=S[L*s+M]}}}if(u===16){const h=new Uint16Array(l.buffer);if(Aji)for(let f=0;f<h.length;f++)h[f]=rji(h[f]);return h}else return l}function rji(e){return(e&255)<<8|e>>8&255}const iji=new Uint16Array([255]),aji=new Uint8Array(iji.buffer),uji=aji[0]===255,oji=new Uint8Array(0);function AAn(e){const{data:t,width:A,height:n,channels:i,depth:u}=e,o=Math.ceil(u/8)*i,s=Math.ceil(u/8*i*A),l=new Uint8Array(n*s);let d=oji,h=0,f,B;for(let E=0;E<n;E++){switch(f=t.subarray(h+1,h+1+s),B=l.subarray(E*s,(E+1)*s),t[h]){case 0:mDn(f,B,s);break;case 1:wDn(f,B,s,o);break;case 2:yDn(f,B,d,s);break;case 3:bDn(f,B,d,s,o);break;case 4:DDn(f,B,d,s,o);break;default:throw new Error(`Unsupported filter: ${t[h]}`)}d=B,h+=s+1}if(u===16){const E=new Uint16Array(l.buffer);if(uji)for(let p=0;p<E.length;p++)E[p]=sji(E[p]);return E}else return l}function sji(e){return(e&255)<<8|e>>8&255}const mct=Uint8Array.of(137,80,78,71,13,10,26,10);function nAn(e){if(!lji(e.readBytes(mct.length)))throw new Error("wrong PNG signature")}function lji(e){if(e.length<mct.length)return!1;for(let t=0;t<mct.length;t++)if(e[t]!==mct[t])return!1;return!0}const cji="tEXt",gji=0,vDn=new TextDecoder("latin1");function dji(e){if(Cji(e),e.length===0||e.length>79)throw new Error("keyword length must be between 1 and 79")}const hji=/^[\u0000-\u00FF]*$/;function Cji(e){if(!hji.test(e))throw new Error("invalid latin1 text")}function fji(e,t,A){const n=kDn(t);e[n]=Bji(t,A-n.length-1)}function kDn(e){for(e.mark();e.readByte()!==gji;);const t=e.offset;e.reset();const A=vDn.decode(e.readBytes(t-e.offset-1));return e.skip(1),dji(A),A}function Bji(e,t){return vDn.decode(e.readBytes(t))}const ED={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},VTt={UNKNOWN:-1,DEFLATE:0},rAn={UNKNOWN:-1,ADAPTIVE:0},XTt={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},VGe={NONE:0,BACKGROUND:1,PREVIOUS:2},eHt={SOURCE:0,OVER:1};class Eji extends $iA{constructor(A,n={}){super(A);ra(this,"_checkCrc");ra(this,"_inflator");ra(this,"_png");ra(this,"_apng");ra(this,"_end");ra(this,"_hasPalette");ra(this,"_palette");ra(this,"_hasTransparency");ra(this,"_transparency");ra(this,"_compressionMethod");ra(this,"_filterMethod");ra(this,"_interlaceMethod");ra(this,"_colorType");ra(this,"_isAnimated");ra(this,"_numberOfFrames");ra(this,"_numberOfPlays");ra(this,"_frames");ra(this,"_writingDataChunks");const{checkCrc:i=!1}=n;this._checkCrc=i,this._inflator=new Xtn,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=VTt.UNKNOWN,this._filterMethod=rAn.UNKNOWN,this._interlaceMethod=XTt.UNKNOWN,this._colorType=ED.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(nAn(this);!this._end;){const A=this.readUint32(),n=this.readChars(4);this.decodeChunk(A,n)}return this.decodeImage(),this._png}decodeApng(){for(nAn(this);!this._end;){const A=this.readUint32(),n=this.readChars(4);this.decodeApngChunk(A,n)}return this.decodeApngImage(),this._apng}decodeChunk(A,n){const i=this.offset;switch(n){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(A);break;case"IDAT":this.decodeIDAT(A);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(A);break;case"iCCP":this.decodeiCCP(A);break;case cji:fji(this._png.text,this,A);break;case"pHYs":this.decodepHYs();break;default:this.skip(A);break}if(this.offset-i!==A)throw new Error(`Length mismatch while decoding chunk ${n}`);this._checkCrc?tAn(this,A+4,n):this.skip(4)}decodeApngChunk(A,n){const i=this.offset;switch(n!=="fdAT"&&n!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),n){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(A);break;default:this.decodeChunk(A,n),this.offset=i+A;break}if(this.offset-i!==A)throw new Error(`Length mismatch while decoding chunk ${n}`);this._checkCrc?tAn(this,A+4,n):this.skip(4)}decodeIHDR(){const A=this._png;A.width=this.readUint32(),A.height=this.readUint32(),A.depth=Iji(this.readUint8());const n=this.readUint8();this._colorType=n;let i;switch(n){case ED.GREYSCALE:i=1;break;case ED.TRUECOLOUR:i=3;break;case ED.INDEXED_COLOUR:i=1;break;case ED.GREYSCALE_ALPHA:i=2;break;case ED.TRUECOLOUR_ALPHA:i=4;break;case ED.UNKNOWN:default:throw new Error(`Unknown color type: ${n}`)}if(this._png.channels=i,this._compressionMethod=this.readUint8(),this._compressionMethod!==VTt.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const A={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(A)}decodePLTE(A){if(A%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${A}`);const n=A/3;this._hasPalette=!0;const i=[];this._palette=i;for(let u=0;u<n;u++)i.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(A){this._writingDataChunks=!0;const n=A,i=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,i,n)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(A)}decodeFDAT(A){this._writingDataChunks=!0;let n=A,i=this.offset+this.byteOffset;if(i+=4,n-=4,this._inflator.push(new Uint8Array(this.buffer,i,n)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(A)}decodetRNS(A){switch(this._colorType){case ED.GREYSCALE:case ED.TRUECOLOUR:{if(A%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${A}`);if(A/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${A/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(A/2);for(let n=0;n<A/2;n++)this._transparency[n]=this.readUint16();break}case ED.INDEXED_COLOUR:{if(A>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${A} vs ${this._palette.length})`);let n=0;for(;n<A;n++){const i=this.readByte();this._palette[n].push(i)}for(;n<this._palette.length;n++)this._palette[n].push(255);break}case ED.UNKNOWN:case ED.GREYSCALE_ALPHA:case ED.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(A){const n=kDn(this),i=this.readUint8();if(i!==VTt.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${i}`);const u=this.readBytes(A-n.length-2);this._png.iccEmbeddedProfile={name:n,profile:q_i(u)}}decodepHYs(){const A=this.readUint32(),n=this.readUint32(),i=this.readByte();this._png.resolution={x:A,y:n,unit:i}}decodeApngImage(){this._apng.width=this._png.width,this._apng.height=this._png.height,this._apng.channels=this._png.channels,this._apng.depth=this._png.depth,this._apng.numberOfFrames=this._numberOfFrames,this._apng.numberOfPlays=this._numberOfPlays,this._apng.text=this._png.text,this._apng.resolution=this._png.resolution;for(let A=0;A<this._numberOfFrames;A++){const n={sequenceNumber:this._frames[A].sequenceNumber,delayNumber:this._frames[A].delayNumber,delayDenominator:this._frames[A].delayDenominator,data:this._apng.depth===8?new Uint8Array(this._apng.width*this._apng.height*this._apng.channels):new Uint16Array(this._apng.width*this._apng.height*this._apng.channels)},i=this._frames.at(A);if(i){if(i.data=AAn({data:i.data,width:i.width,height:i.height,channels:this._apng.channels,depth:this._apng.depth}),this._hasPalette&&(this._apng.palette=this._palette),this._hasTransparency&&(this._apng.transparency=this._transparency),A===0||i.xOffset===0&&i.yOffset===0&&i.width===this._png.width&&i.height===this._png.height)n.data=i.data;else{const u=this._apng.frames.at(A-1);this.disposeFrame(i,u,n),this.addFrameDataToCanvas(n,i)}this._apng.frames.push(n)}}return this._apng}disposeFrame(A,n,i){switch(A.disposeOp){case VGe.NONE:break;case VGe.BACKGROUND:for(let u=0;u<this._png.height;u++)for(let o=0;o<this._png.width;o++){const s=(u*A.width+o)*this._png.channels;for(let l=0;l<this._png.channels;l++)i.data[s+l]=0}break;case VGe.PREVIOUS:i.data.set(n.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(A,n){const i=1<<this._png.depth,u=(o,s)=>{const l=((o+n.yOffset)*this._png.width+n.xOffset+s)*this._png.channels,d=(o*n.width+s)*this._png.channels;return{index:l,frameIndex:d}};switch(n.blendOp){case eHt.SOURCE:for(let o=0;o<n.height;o++)for(let s=0;s<n.width;s++){const{index:l,frameIndex:d}=u(o,s);for(let h=0;h<this._png.channels;h++)A.data[l+h]=n.data[d+h]}break;case eHt.OVER:for(let o=0;o<n.height;o++)for(let s=0;s<n.width;s++){const{index:l,frameIndex:d}=u(o,s);for(let h=0;h<this._png.channels;h++){const f=n.data[d+this._png.channels-1]/i,B=h%(this._png.channels-1)===0?1:n.data[d+h],E=Math.floor(f*B+(1-f)*A.data[l+h]);A.data[l+h]+=E}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){var n;if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const A=this._isAnimated?((n=this._frames)==null?void 0:n.at(0)).data:this._inflator.result;if(this._filterMethod!==rAn.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===XTt.NO_INTERLACE)this._png.data=AAn({data:A,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===XTt.ADAM7)this._png.data=nji({data:A,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else throw new Error(`Interlace method ${this._interlaceMethod} not supported`);this._hasPalette&&(this._png.palette=this._palette),this._hasTransparency&&(this._png.transparency=this._transparency)}pushDataToFrame(){const A=this._inflator.result,n=this._frames.at(-1);n?n.data=A:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:VGe.NONE,blendOp:eHt.SOURCE,data:A}),this._inflator=new Xtn,this._writingDataChunks=!1}}function Iji(e){if(e!==1&&e!==2&&e!==4&&e!==8&&e!==16)throw new Error(`invalid bit depth: ${e}`);return e}var iAn;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.METRE=1]="METRE"})(iAn||(iAn={}));function pji(e,t){return new Eji(e,t).decode()}var Os=(function(){return typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:this})();function tHt(){Os.console&&typeof Os.console.log=="function"&&Os.console.log.apply(Os.console,arguments)}var kh={log:tHt,warn:function(e){Os.console&&(typeof Os.console.warn=="function"?Os.console.warn.apply(Os.console,arguments):tHt.call(null,arguments))},error:function(e){Os.console&&(typeof Os.console.error=="function"?Os.console.error.apply(Os.console,arguments):tHt(e))}};function AHt(e,t,A){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){bte(n.response,t,A)},n.onerror=function(){kh.error("could not download file")},n.send()}function aAn(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function XGe(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var bte=Os.saveAs||((typeof window>"u"?"undefined":Bg(window))!=="object"||window!==Os?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(e,t,A){var n=Os.URL||Os.webkitURL,i=document.createElement("a");t=t||e.name||"download",i.download=t,i.rel="noopener",typeof e=="string"?(i.href=e,i.origin!==location.origin?aAn(i.href)?AHt(e,t,A):XGe(i,i.target="_blank"):XGe(i)):(i.href=n.createObjectURL(e),setTimeout(function(){n.revokeObjectURL(i.href)},4e4),setTimeout(function(){XGe(i)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,A){if(t=t||e.name||"download",typeof e=="string")if(aAn(e))AHt(e,t,A);else{var n=document.createElement("a");n.href=e,n.target="_blank",setTimeout(function(){XGe(n)})}else navigator.msSaveOrOpenBlob((function(i,u){return u===void 0?u={autoBom:!1}:Bg(u)!=="object"&&(kh.warn("Deprecated: Expected third argument to be a object"),u={autoBom:!u}),u.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(i.type)?new Blob(["\uFEFF",i],{type:i.type}):i})(e,A),t)}:function(e,t,A,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),typeof e=="string")return AHt(e,t,A);var i=e.type==="application/octet-stream",u=/constructor/i.test(Os.HTMLElement)||Os.safari,o=/CriOS\/[\d]+/.test(navigator.userAgent);if((o||i&&u)&&(typeof FileReader>"u"?"undefined":Bg(FileReader))==="object"){var s=new FileReader;s.onloadend=function(){var h=s.result;h=o?h:h.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=h:location=h,n=null},s.readAsDataURL(e)}else{var l=Os.URL||Os.webkitURL,d=l.createObjectURL(e);n?n.location=d:location.href=d,n=null,setTimeout(function(){l.revokeObjectURL(d)},4e4)}});/**
|
|
8393
8393
|
* A class to parse color values
|
|
@@ -8612,7 +8612,7 @@ end`};t.events.push(["putFont",function(u){(function(o){var s=o.font,l=o.out,d=o
|
|
|
8612
8612
|
`))}function l(E,p,y,b){const v=y.enter("tableCell"),x=y.enter("phrasing"),S=y.containerPhrasing(E,{...b,before:u,after:u});return x(),v(),S}function d(E,p){return dXi(E,{align:p,alignDelimiters:n,padding:A,stringLength:i})}function h(E,p,y){const b=E.children;let v=-1;const x=[],S=p.enter("table");for(;++v<b.length;)x[v]=f(b[v],p,y);return S(),x}function f(E,p,y){const b=E.children;let v=-1;const x=[],S=p.enter("tableRow");for(;++v<b.length;)x[v]=l(b[v],E,p,y);return S(),x}function B(E,p,y){let b=fvn.inlineCode(E,p,y);return y.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function iea(){return{exit:{taskListCheckValueChecked:Nnn,taskListCheckValueUnchecked:Nnn,paragraph:uea}}}function aea(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:oea}}}function Nnn(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function uea(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const A=this.stack[this.stack.length-1];A.type;const n=A.children[0];if(n&&n.type==="text"){const i=t.children;let u=-1,o;for(;++u<i.length;){const s=i[u];if(s.type==="paragraph"){o=s;break}}o===A&&(n.value=n.value.slice(1),n.value.length===0?A.children.shift():A.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,A.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function oea(e,t,A,n){const i=e.children[0],u=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",s=A.createTracker(n);u&&s.move(o);let l=fvn.listItem(e,t,A,{...n,...s.current()});return u&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),l;function d(h){return h+o}}function sea(){return[RVi(),nXi(),uXi(),VXi(),iea()]}function lea(e){return{extensions:[UVi(),rXi(e),oXi(),rea(e),aea()]}}function cea(e,t,A,n){const i=e.length;let u=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,A=A>0?A:0,n.length<1e4)o=Array.from(n),o.unshift(t,A),e.splice(...o);else for(A&&e.splice(t,A);u<n.length;)o=n.slice(u,u+1e4),o.unshift(t,0),e.splice(...o),u+=1e4,t+=1e4}const Mnn={}.hasOwnProperty;function gea(e){const t={};let A=-1;for(;++A<e.length;)dea(t,e[A]);return t}function dea(e,t){let A;for(A in t){const i=(Mnn.call(e,A)?e[A]:void 0)||(e[A]={}),u=t[A];let o;if(u)for(o in u){Mnn.call(i,o)||(i[o]=[]);const s=u[o];hea(i[o],Array.isArray(s)?s:s?[s]:[])}}}function hea(e,t){let A=-1;const n=[];for(;++A<t.length;)(t[A].add==="after"?e:n).push(t[A]);cea(e,0,0,n)}const bbe=UEt(/[A-Za-z]/),paA=UEt(/[\dA-Za-z]/);function Cea(e){return e!==null&&(e<32||e===127)}function Gge(e){return e!==null&&(e<0||e===32)}const Bvn=UEt(new RegExp("\\p{P}|\\p{S}","u")),Dbe=UEt(/\s/);function UEt(e){return t;function t(A){return A!==null&&A>-1&&e.test(String.fromCharCode(A))}}const fea={tokenize:mea,partial:!0},Evn={tokenize:wea,partial:!0},Ivn={tokenize:yea,partial:!0},pvn={tokenize:bea,partial:!0},Bea={tokenize:Dea,partial:!0},Qvn={name:"wwwAutolink",tokenize:pea,previous:wvn},mvn={name:"protocolAutolink",tokenize:Qea,previous:yvn},lH={name:"emailAutolink",tokenize:Iea,previous:bvn},BM={};function Eea(){return{text:BM}}let GZ=48;for(;GZ<123;)BM[GZ]=lH,GZ++,GZ===58?GZ=65:GZ===91&&(GZ=97);BM[43]=lH;BM[45]=lH;BM[46]=lH;BM[95]=lH;BM[72]=[lH,mvn];BM[104]=[lH,mvn];BM[87]=[lH,Qvn];BM[119]=[lH,Qvn];function Iea(e,t,A){const n=this;let i,u;return o;function o(f){return!iZt(f)||!bvn.call(n,n.previous)||QaA(n.events)?A(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(f))}function s(f){return iZt(f)?(e.consume(f),s):f===64?(e.consume(f),l):A(f)}function l(f){return f===46?e.check(Bea,h,d)(f):f===45||f===95||paA(f)?(u=!0,e.consume(f),l):h(f)}function d(f){return e.consume(f),i=!0,l}function h(f){return u&&i&&bbe(n.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):A(f)}}function pea(e,t,A){const n=this;return i;function i(o){return o!==87&&o!==119||!wvn.call(n,n.previous)||QaA(n.events)?A(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(fea,e.attempt(Evn,e.attempt(Ivn,u),A),A)(o))}function u(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function Qea(e,t,A){const n=this;let i="",u=!1;return o;function o(f){return(f===72||f===104)&&yvn.call(n,n.previous)&&!QaA(n.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),s):A(f)}function s(f){if(bbe(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),s;if(f===58){const B=i.toLowerCase();if(B==="http"||B==="https")return e.consume(f),l}return A(f)}function l(f){return f===47?(e.consume(f),u?d:(u=!0,l)):A(f)}function d(f){return f===null||Cea(f)||Gge(f)||Dbe(f)||Bvn(f)?A(f):e.attempt(Evn,e.attempt(Ivn,h),A)(f)}function h(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function mea(e,t,A){let n=0;return i;function i(o){return(o===87||o===119)&&n<3?(n++,e.consume(o),i):o===46&&n===3?(e.consume(o),u):A(o)}function u(o){return o===null?A(o):t(o)}}function wea(e,t,A){let n,i,u;return o;function o(d){return d===46||d===95?e.check(pvn,l,s)(d):d===null||Gge(d)||Dbe(d)||d!==45&&Bvn(d)?l(d):(u=!0,e.consume(d),o)}function s(d){return d===95?n=!0:(i=n,n=void 0),e.consume(d),o}function l(d){return i||n||!u?A(d):t(d)}}function yea(e,t){let A=0,n=0;return i;function i(o){return o===40?(A++,e.consume(o),i):o===41&&n<A?u(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(pvn,t,u)(o):o===null||Gge(o)||Dbe(o)?t(o):(e.consume(o),i)}function u(o){return o===41&&n++,e.consume(o),i}}function bea(e,t,A){return n;function n(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),n):s===38?(e.consume(s),u):s===93?(e.consume(s),i):s===60||s===null||Gge(s)||Dbe(s)?t(s):A(s)}function i(s){return s===null||s===40||s===91||Gge(s)||Dbe(s)?t(s):n(s)}function u(s){return bbe(s)?o(s):A(s)}function o(s){return s===59?(e.consume(s),n):bbe(s)?(e.consume(s),o):A(s)}}function Dea(e,t,A){return n;function n(u){return e.consume(u),i}function i(u){return paA(u)?A(u):t(u)}}function wvn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Gge(e)}function yvn(e){return!bbe(e)}function bvn(e){return!(e===47||iZt(e))}function iZt(e){return e===43||e===45||e===46||e===95||paA(e)}function QaA(e){let t=e.length,A=!1;for(;t--;){const n=e[t][1];if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){A=!0;break}if(n._gfmAutolinkLiteralWalkedInto){A=!1;break}}return e.length>0&&!A&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),A}function vea(e){return e!==null&&e<-2}function yht(e){return e!==null&&(e<0||e===32)}function aZt(e){return e===-2||e===-1||e===32}function maA(e,t,A,n){const i=n?n-1:Number.POSITIVE_INFINITY;let u=0;return o;function o(l){return aZt(l)?(e.enter(A),s(l)):t(l)}function s(l){return aZt(l)&&u++<i?(e.consume(l),s):(e.exit(A),t(l))}}const kea={partial:!0,tokenize:xea};function xea(e,t,A){return n;function n(u){return aZt(u)?maA(e,i,"linePrefix")(u):i(u)}function i(u){return u===null||vea(u)?t(u):A(u)}}function waA(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Fea={tokenize:Gea,partial:!0};function Sea(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Mea,continuation:{tokenize:Rea},exit:Uea}},text:{91:{name:"gfmFootnoteCall",tokenize:Nea},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Lea,resolveTo:Oea}}}}function Lea(e,t,A){const n=this;let i=n.events.length;const u=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let o;for(;i--;){const l=n.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return s;function s(l){if(!o||!o._balanced)return A(l);const d=waA(n.sliceSerialize({start:o.end,end:n.now()}));return d.codePointAt(0)!==94||!u.includes(d.slice(1))?A(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Oea(e,t){let A=e.length;for(;A--;)if(e[A][1].type==="labelImage"&&e[A][0]==="enter"){e[A][1];break}e[A+1][1].type="data",e[A+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},e[A+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[A+3][1].end),end:Object.assign({},e[A+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},s=[e[A+1],e[A+2],["enter",n,t],e[A+3],e[A+4],["enter",i,t],["exit",i,t],["enter",u,t],["enter",o,t],["exit",o,t],["exit",u,t],e[e.length-2],e[e.length-1],["exit",n,t]];return e.splice(A,e.length-A+1,...s),e}function Nea(e,t,A){const n=this,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let u=0,o;return s;function s(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?A(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(f){if(u>999||f===93&&!o||f===null||f===91||yht(f))return A(f);if(f===93){e.exit("chunkString");const B=e.exit("gfmFootnoteCallString");return i.includes(waA(n.sliceSerialize(B)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):A(f)}return yht(f)||(o=!0),u++,e.consume(f),f===92?h:d}function h(f){return f===91||f===92||f===93?(e.consume(f),u++,d):d(f)}}function Mea(e,t,A){const n=this,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let u,o=0,s;return l;function l(p){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(p){return p===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):A(p)}function h(p){if(o>999||p===93&&!s||p===null||p===91||yht(p))return A(p);if(p===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return u=waA(n.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(p),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),B}return yht(p)||(s=!0),o++,e.consume(p),p===92?f:h}function f(p){return p===91||p===92||p===93?(e.consume(p),o++,h):h(p)}function B(p){return p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),i.includes(u)||i.push(u),maA(e,E,"gfmFootnoteDefinitionWhitespace")):A(p)}function E(p){return t(p)}}function Rea(e,t,A){return e.check(kea,t,e.attempt(Fea,t,A))}function Uea(e){e.exit("gfmFootnoteDefinition")}function Gea(e,t,A){const n=this;return maA(e,i,"gfmFootnoteDefinitionIndent",5);function i(u){const o=n.events[n.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(u):A(u)}}function kHt(e,t,A,n){const i=e.length;let u=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,A=A>0?A:0,n.length<1e4)o=Array.from(n),o.unshift(t,A),e.splice(...o);else for(A&&e.splice(t,A);u<n.length;)o=n.slice(u,u+1e4),o.unshift(t,0),e.splice(...o),u+=1e4,t+=1e4}function Tea(e){return e!==null&&(e<0||e===32)}const Hea=Dvn(new RegExp("\\p{P}|\\p{S}","u")),Yea=Dvn(/\s/);function Dvn(e){return t;function t(A){return A!==null&&A>-1&&e.test(String.fromCharCode(A))}}function Rnn(e){if(e===null||Tea(e)||Yea(e))return 1;if(Hea(e))return 2}function Pea(e,t,A){const n=[];let i=-1;for(;++i<e.length;){const u=e[i].resolveAll;u&&!n.includes(u)&&(t=u(t,A),n.push(u))}return t}function _ea(e){let A=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:u,resolveAll:i};return A==null&&(A=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function i(o,s){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let d=l;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[l][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[l][1].start)},B=[["enter",h,s],["enter",o[d][1],s],["exit",o[d][1],s],["enter",f,s]],E=s.parser.constructs.insideSpan.null;E&&kHt(B,B.length,0,Pea(E,o.slice(d+1,l),s)),kHt(B,B.length,0,[["exit",f,s],["enter",o[l][1],s],["exit",o[l][1],s],["exit",h,s]]),kHt(o,d-1,l-d+3,B),l=d+B.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function u(o,s,l){const d=this.previous,h=this.events;let f=0;return B;function B(p){return d===126&&h[h.length-1][1].type!=="characterEscape"?l(p):(o.enter("strikethroughSequenceTemporary"),E(p))}function E(p){const y=Rnn(d);if(p===126)return f>1?l(p):(o.consume(p),f++,E);if(f<2&&!A)return l(p);const b=o.exit("strikethroughSequenceTemporary"),v=Rnn(p);return b._open=!v||v===2&&!!y,b._close=!y||y===2&&!!v,s(p)}}}function cTe(e){return e!==null&&e<-2}function Unn(e){return e!==null&&(e<0||e===32)}function Yte(e){return e===-2||e===-1||e===32}function EQe(e,t,A,n){const i=n?n-1:Number.POSITIVE_INFINITY;let u=0;return o;function o(l){return Yte(l)?(e.enter(A),s(l)):t(l)}function s(l){return Yte(l)&&u++<i?(e.consume(l),s):(e.exit(A),t(l))}}class jea{constructor(){this.map=[]}add(t,A,n){Kea(this,t,A,n)}consume(t){if(this.map.sort(function(u,o){return u[0]-o[0]}),this.map.length===0)return;let A=this.map.length;const n=[];for(;A>0;)A-=1,n.push(t.slice(this.map[A][0]+this.map[A][1]),this.map[A][2]),t.length=this.map[A][0];n.push(t.slice()),t.length=0;let i=n.pop();for(;i;){for(const u of i)t.push(u);i=n.pop()}this.map.length=0}}function Kea(e,t,A,n){let i=0;if(!(A===0&&n.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=A,e.map[i][2].push(...n);return}i+=1}e.map.push([t,A,n])}}function Jea(e,t){let A=!1;const n=[];for(;t<e.length;){const i=e[t];if(A){if(i[0]==="enter")i[1].type==="tableContent"&&n.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const u=n.length-1;n[u]=n[u]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(A=!0);t+=1}return n}function $ea(){return{flow:{null:{name:"table",tokenize:zea,resolveAll:qea}}}}function zea(e,t,A){const n=this;let i=0,u=0,o;return s;function s(P){let R=n.events.length-1;for(;R>-1;){const j=n.events[R][1].type;if(j==="lineEnding"||j==="linePrefix")R--;else break}const Y=R>-1?n.events[R][1].type:null,H=Y==="tableHead"||Y==="tableRow"?O:l;return H===O&&n.parser.lazy[n.now().line]?A(P):H(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),d(P)}function d(P){return P===124||(o=!0,u+=1),h(P)}function h(P){return P===null?A(P):cTe(P)?u>1?(u=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),E):A(P):Yte(P)?EQe(e,h,"whitespace")(P):(u+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,h):(e.enter("data"),f(P)))}function f(P){return P===null||P===124||Unn(P)?(e.exit("data"),h(P)):(e.consume(P),P===92?B:f)}function B(P){return P===92||P===124?(e.consume(P),f):f(P)}function E(P){return n.interrupt=!1,n.parser.lazy[n.now().line]?A(P):(e.enter("tableDelimiterRow"),o=!1,Yte(P)?EQe(e,p,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):p(P))}function p(P){return P===45||P===58?b(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),y):N(P)}function y(P){return Yte(P)?EQe(e,b,"whitespace")(P):b(P)}function b(P){return P===58?(u+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),v):P===45?(u+=1,v(P)):P===null||cTe(P)?L(P):N(P)}function v(P){return P===45?(e.enter("tableDelimiterFiller"),x(P)):N(P)}function x(P){return P===45?(e.consume(P),x):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),S):(e.exit("tableDelimiterFiller"),S(P))}function S(P){return Yte(P)?EQe(e,L,"whitespace")(P):L(P)}function L(P){return P===124?p(P):P===null||cTe(P)?!o||i!==u?N(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):N(P)}function N(P){return A(P)}function O(P){return e.enter("tableRow"),M(P)}function M(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),M):P===null||cTe(P)?(e.exit("tableRow"),t(P)):Yte(P)?EQe(e,M,"whitespace")(P):(e.enter("data"),T(P))}function T(P){return P===null||P===124||Unn(P)?(e.exit("data"),M(P)):(e.consume(P),P===92?U:T)}function U(P){return P===92||P===124?(e.consume(P),T):T(P)}}function qea(e,t){let A=-1,n=!0,i=0,u=[0,0,0,0],o=[0,0,0,0],s=!1,l=0,d,h,f;const B=new jea;for(;++A<e.length;){const E=e[A],p=E[1];E[0]==="enter"?p.type==="tableHead"?(s=!1,l!==0&&(Gnn(B,t,l,d,h),h=void 0,l=0),d={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},B.add(A,0,[["enter",d,t]])):p.type==="tableRow"||p.type==="tableDelimiterRow"?(n=!0,f=void 0,u=[0,0,0,0],o=[0,A+1,0,0],s&&(s=!1,h={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},B.add(A,0,[["enter",h,t]])),i=p.type==="tableDelimiterRow"?2:h?3:1):i&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")?(n=!1,o[2]===0&&(u[1]!==0&&(o[0]=o[1],f=gTe(B,t,u,i,void 0,f),u=[0,0,0,0]),o[2]=A)):p.type==="tableCellDivider"&&(n?n=!1:(u[1]!==0&&(o[0]=o[1],f=gTe(B,t,u,i,void 0,f)),u=o,o=[u[1],A,0,0])):p.type==="tableHead"?(s=!0,l=A):p.type==="tableRow"||p.type==="tableDelimiterRow"?(l=A,u[1]!==0?(o[0]=o[1],f=gTe(B,t,u,i,A,f)):o[1]!==0&&(f=gTe(B,t,o,i,A,f)),i=0):i&&(p.type==="data"||p.type==="tableDelimiterMarker"||p.type==="tableDelimiterFiller")&&(o[3]=A)}for(l!==0&&Gnn(B,t,l,d,h),B.consume(t.events),A=-1;++A<t.events.length;){const E=t.events[A];E[0]==="enter"&&E[1].type==="table"&&(E[1]._align=Jea(t.events,A))}return e}function gTe(e,t,A,n,i,u){const o=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",s="tableContent";A[0]!==0&&(u.end=Object.assign({},tle(t.events,A[0])),e.add(A[0],0,[["exit",u,t]]));const l=tle(t.events,A[1]);if(u={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(A[1],0,[["enter",u,t]]),A[2]!==0){const d=tle(t.events,A[2]),h=tle(t.events,A[3]),f={type:s,start:Object.assign({},d),end:Object.assign({},h)};if(e.add(A[2],0,[["enter",f,t]]),n!==2){const B=t.events[A[2]],E=t.events[A[3]];if(B[1].end=Object.assign({},E[1].end),B[1].type="chunkText",B[1].contentType="text",A[3]>A[2]+1){const p=A[2]+1,y=A[3]-A[2]-1;e.add(p,y,[])}}e.add(A[3]+1,0,[["exit",f,t]])}return i!==void 0&&(u.end=Object.assign({},tle(t.events,i)),e.add(i,0,[["exit",u,t]]),u=void 0),u}function Gnn(e,t,A,n,i){const u=[],o=tle(t.events,A);i&&(i.end=Object.assign({},o),u.push(["exit",i,t])),n.end=Object.assign({},o),u.push(["exit",n,t]),e.add(A+1,0,u)}function tle(e,t){const A=e[t],n=A[0]==="enter"?"start":"end";return A[1][n]}function Wea(e){return e!==null&&e<-2}function Zea(e){return e!==null&&(e<0||e===32)}function uZt(e){return e===-2||e===-1||e===32}function Vea(e,t,A,n){const i=Number.POSITIVE_INFINITY;let u=0;return o;function o(l){return uZt(l)?(e.enter(A),s(l)):t(l)}function s(l){return uZt(l)&&u++<i?(e.consume(l),s):(e.exit(A),t(l))}}const Xea={name:"tasklistCheck",tokenize:tta};function eta(){return{text:{91:Xea}}}function tta(e,t,A){const n=this;return i;function i(l){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?A(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),u)}function u(l){return Zea(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):A(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):A(l)}function s(l){return Wea(l)?t(l):uZt(l)?e.check({tokenize:Ata},t,A)(l):A(l)}}function Ata(e,t,A){return Vea(e,n,"whitespace");function n(i){return i===null?A(i):t(i)}}function nta(e){return gea([Eea(),Sea(),_ea(e),$ea(),eta()])}const rta={};function vvn(e){const t=this,A=e||rta,n=t.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),u=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),o=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(nta(A)),u.push(sea()),o.push(lea(A))}const Tnn="hadziqmtqn/erd-builder-pro",ita=5;function ata(e){if(!e)return 1;const t=e.match(/page=(\d+)>;\s*rel="last"/);return t?parseInt(t[1],10):1}function uta(){const[e,t]=J.useState([]),[A,n]=J.useState(!0),[i,u]=J.useState(!1),[o,s]=J.useState(null),[l,d]=J.useState(null),[h,f]=J.useState(1),[B,E]=J.useState(1),p=J.useRef(null),y=async x=>{x===1?n(!0):u(!0);try{const S=await fetch(`https://api.github.com/repos/${Tnn}/releases?per_page=${ita}&page=${x}`);if(!S.ok)throw new Error("Failed to fetch releases");const L=await S.json();t(L),E(ata(S.headers.get("Link")))}catch(S){s(S instanceof Error?S.message:"Unknown error")}finally{n(!1),u(!1)}};J.useEffect(()=>{y(1)},[]),J.useEffect(()=>{var x;y(h),(x=p.current)==null||x.scrollTo({top:0,behavior:"smooth"})},[h]);const v=h===1?e.findIndex(x=>!x.prerelease):-1;return A&&e.length===0?m.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center space-y-4",children:[m.jsx(js,{className:"w-8 h-8 text-primary animate-spin"}),m.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Fetching latest updates..."})]}):o?m.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center space-y-4 p-8 text-center",children:[m.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:m.jsx(ND,{className:"w-6 h-6 text-destructive"})}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("h3",{className:"font-bold text-lg",children:"Gagal memuat Changelog"}),m.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:o})]}),m.jsx(VA,{onClick:()=>window.location.reload(),variant:"outline",children:"Coba Lagi"})]}):m.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden bg-background",children:[m.jsxs("div",{className:"flex items-center justify-between p-6 border-b bg-muted/20",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsxs("h2",{className:"text-2xl font-bold tracking-tight flex items-center gap-2",children:[m.jsx(FAe,{className:"w-6 h-6 text-primary"}),"What's New"]}),m.jsx("p",{className:"text-sm text-muted-foreground",children:"Lacak pembaruan dan perubahan terbaru pada ERD Builder Pro."})]}),m.jsxs(VA,{variant:"outline",size:"sm",render:m.jsx("a",{href:`https://github.com/${Tnn}/releases`,target:"_blank",rel:"noreferrer"}),children:[m.jsx(IK,{className:"w-4 h-4 mr-2"}),"GitHub Releases"]})]}),m.jsx("div",{ref:p,className:"flex-1 overflow-y-auto px-6 py-8",children:m.jsxs("div",{className:"max-w-3xl mx-auto relative pl-8 space-y-12",children:[m.jsx("div",{className:"absolute left-[15px] top-2 bottom-0 w-px bg-border"}),m.jsx(ubn,{mode:"popLayout",children:e.map((x,S)=>m.jsxs(Xk.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:S*.1},className:"relative",children:[m.jsx("div",{className:Xn("absolute -left-[32px] top-1.5 size-8 rounded-full border-4 border-background flex items-center justify-center transition-colors",S===v&&v!==-1?"bg-primary shadow-[0_0_15px_rgba(var(--primary),0.5)]":x.prerelease?"bg-amber-500/20 border-amber-500/30":"bg-muted"),children:S===v&&v!==-1?m.jsx(ry,{className:"w-4 h-4 text-primary-foreground"}):x.prerelease?m.jsx(GAe,{className:"w-3 h-3 text-amber-400"}):m.jsx(GAe,{className:"w-3 h-3 text-muted-foreground"})}),m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs(Lf,{variant:x.prerelease?"secondary":"default",className:"font-mono text-xs px-2 pointer-events-none",children:["v",x.tag_name.replace("v","")]}),x.prerelease&&m.jsx(Lf,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-amber-500/10 text-amber-400 border-amber-500/30",children:"Pre-release"}),m.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[m.jsx(xAe,{className:"w-3 h-3"}),Nk(new Date(x.published_at),"MMMM d, yyyy")]}),S===v&&v!==-1&&m.jsx(Lf,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-primary/5 text-primary border-primary/20",children:"Latest"})]}),m.jsx(Vk,{className:Xn("group transition-all duration-300 hover:border-primary/50 cursor-pointer overflow-hidden backdrop-blur-sm",S===v&&v!==-1?"bg-primary/5 border-primary/20 shadow-lg shadow-primary/5":x.prerelease?"bg-card/30 border-amber-500/10":"bg-card/50"),onClick:()=>d(x),children:m.jsxs(ihe,{className:"p-4 flex flex-row items-center justify-between space-y-0",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx(ahe,{className:"text-base font-bold group-hover:text-primary transition-colors",children:x.name||`Release ${x.tag_name}`}),m.jsx(cEt,{className:"line-clamp-2 text-sm leading-relaxed",children:x.body.split(`
|
|
8613
8613
|
`)[0].replace(/#+\s*/,"")||"Lihat detail pembaruan..."})]}),m.jsx(Yf,{className:"w-5 h-5 text-muted-foreground group-hover:text-primary group-hover:translate-x-1 transition-all"})]})})]})]},x.id))}),i&&m.jsx("div",{className:"flex justify-center pt-4",children:m.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[m.jsx(js,{className:"w-3.5 h-3.5 animate-spin"}),"Loading page..."]})}),B>1&&!i&&m.jsxs("div",{className:"flex items-center justify-center gap-1 pt-8 pb-4",children:[m.jsx(VA,{variant:"ghost",size:"sm",disabled:h===1,onClick:()=>f(1),className:"size-9 p-0",children:m.jsx(P3e,{className:"w-4 h-4"})}),m.jsx(VA,{variant:"ghost",size:"sm",disabled:h===1,onClick:()=>f(x=>x-1),className:"size-9 p-0",children:m.jsx(B3,{className:"w-4 h-4"})}),m.jsx("div",{className:"flex items-center gap-1 px-2",children:(()=>{const x=[];for(let L=1;L<=B;L++)L===1||L===B||L>=h-1&&L<=h+1?x.push(L):x[x.length-1]!=="ellipsis"&&x.push("ellipsis");return x.map((L,N)=>L==="ellipsis"?m.jsx("span",{className:"px-1 text-xs text-muted-foreground",children:"..."},`e-${N}`):m.jsx(VA,{variant:L===h?"default":"ghost",size:"sm",onClick:()=>f(L),className:"min-w-9 h-9 p-0 text-xs font-mono",children:L},L))})()}),m.jsx(VA,{variant:"ghost",size:"sm",disabled:h===B,onClick:()=>f(x=>x+1),className:"size-9 p-0",children:m.jsx(Yf,{className:"w-4 h-4"})}),m.jsx(VA,{variant:"ghost",size:"sm",disabled:h===B,onClick:()=>f(B),className:"size-9 p-0",children:m.jsx(_3e,{className:"w-4 h-4"})})]}),B>1&&!i&&m.jsxs("p",{className:"text-center text-[11px] text-muted-foreground/60 pb-2",children:["Page ",h," of ",B]})]})}),m.jsx(Hg,{open:!!l,onOpenChange:x=>!x&&d(null),children:m.jsx(mg,{className:"sm:max-w-2xl",children:l&&m.jsxs(m.Fragment,{children:[m.jsxs(ah,{children:[m.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[m.jsxs(Lf,{className:"font-mono text-xs",children:["v",l.tag_name.replace("v","")]}),l.prerelease?m.jsx(Lf,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-amber-500/10 text-amber-400 border-amber-500/30",children:"Pre-release"}):m.jsx(Lf,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-emerald-500/10 text-emerald-400 border-emerald-500/30",children:"Stable"}),m.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[m.jsx(xAe,{className:"w-3 h-3"}),Nk(new Date(l.published_at),"MMMM d, yyyy")]})]}),m.jsx(Yg,{className:"text-2xl",children:l.name||`Release ${l.tag_name}`})]}),m.jsx(G1,{className:"bg-muted/50",children:m.jsx("div",{className:"prose prose-invert prose-sm max-w-none prose-pre:bg-black/50 prose-pre:border prose-pre:border-border",children:m.jsx(W9n,{remarkPlugins:[vvn],children:l.body})})}),m.jsx(ep,{children:m.jsxs(VA,{variant:"secondary",size:"sm",render:m.jsx("a",{href:l.html_url,target:"_blank",rel:"noreferrer"}),children:[m.jsx(IK,{className:"w-4 h-4 mr-2"}),"View on GitHub"]})})]})})})]})}function ota(e){const t=e==null?void 0:e.data;if(!t)return{projects:0,notes:0,diagrams:0,entities:0,columns:0,relationships:0,flowcharts:0,drawings:0,ai_chat_sessions:0,ai_chat_messages:0,skipped_existing:0};let A=0,n=0,i=0;for(const o of t.diagrams||[]){A+=(o.entities||[]).length;for(const s of o.entities||[])n+=(s.columns||[]).length;i+=(o.relationships||[]).length}let u=0;for(const o of t.ai_chat_sessions||[])u+=(o.messages||[]).length;return{projects:(t.projects||[]).length,notes:(t.notes||[]).length,diagrams:(t.diagrams||[]).length,entities:A,columns:n,relationships:i,flowcharts:(t.flowcharts||[]).length,drawings:(t.drawings||[]).length,ai_chat_sessions:(t.ai_chat_sessions||[]).length,ai_chat_messages:u,skipped_existing:0}}function sta(e){const t=e==null?void 0:e.data;if(!t)return 1;let A=0;A+=(t.projects||[]).length,A+=(t.notes||[]).length;for(const n of t.diagrams||[]){A+=1;const i=n.entities||[];A+=i.length;for(const u of i)A+=(u.columns||[]).length;A+=(n.relationships||[]).length}A+=(t.flowcharts||[]).length,A+=(t.drawings||[]).length;for(const n of t.ai_chat_sessions||[])A+=1,A+=(n.messages||[]).length;return Math.max(A,1)}function lta(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Hnn(){return sessionStorage.getItem("auth_mode")==="guest"?"guest":typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__)?"desktop":"web"}function cta(){const e=J.useRef(null),t=J.useRef(null),A=J.useRef(null),n=J.useRef(null),i=J.useRef(null),[u,o]=J.useState("idle"),[s,l]=J.useState(null),[d,h]=J.useState(null),[f,B]=J.useState(null),[E,p]=J.useState(null),[y,b]=J.useState(""),[v,x]=J.useState({current:0,total:1,phase:""}),S=Hnn();J.useEffect(()=>(u==="done"&&(t.current=setTimeout(()=>{window.location.reload()},2500)),()=>{t.current&&(clearTimeout(t.current),t.current=null)}),[u]);const L=J.useCallback(async K=>{var ee,V;const W=(ee=K.target.files)==null?void 0:ee[0];if(!W)return;const q=(V=W.name.split(".").pop())==null?void 0:V.toLowerCase();if(q==="db"||q==="sqlite"||q==="sqlite3"){if(Hnn()!=="desktop"){gA.error("Database file restore is only available in the Desktop app."),e.current&&(e.current.value="");return}l("db"),B({fileName:W.name,fileSize:lta(W.size)}),h(null),b(""),o("preview"),i.current=W,e.current&&(e.current.value="");return}if(q==="json"){let Z;try{Z=JSON.parse(await W.text())}catch{gA.error("Invalid JSON file. Please select a valid export file."),e.current&&(e.current.value="");return}if(!Z.data||typeof Z.data!="object"){gA.error('Invalid export format. Missing "data" field.'),e.current&&(e.current.value="");return}const re=ota(Z);if(Object.values(re).reduce((ne,ge)=>ne+(ge||0),0)<=1){gA.info("The export file contains no data to import."),e.current&&(e.current.value="");return}n.current=Z,l("json"),h(re),B(null),b(""),o("preview"),e.current&&(e.current.value="");return}gA.error(`Unsupported file type ".${q}". Please select a .json, .db, or .sqlite file.`),e.current&&(e.current.value="")},[]),N=J.useCallback(async()=>{var ee;const K=n.current;if(!K)return;const W=sta(K);o("importing"),b(""),x({current:0,total:W,phase:"Preparing import…"});const q=S==="guest"?"/api/guest/import":"/api/desktop/import";try{const V=new AbortController;A.current=V;const Z=await vr(q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K),signal:V.signal});if(!Z.ok){let ge=`Server returned ${Z.status}`;try{ge=(await Z.json()).error||ge}catch{}throw new Error(ge)}const re=(ee=Z.body)==null?void 0:ee.getReader();if(!re)throw new Error("Browser does not support streaming responses.");const ae=new TextDecoder;let ne="";for(;;){const{done:ge,value:le}=await re.read();if(ge)break;ne+=ae.decode(le,{stream:!0});const Ce=ne.split(`
|
|
8614
8614
|
`);ne=Ce.pop()||"";for(const fe of Ce)if(fe.trim())try{const we=JSON.parse(fe);if(we.type==="progress")x({current:Number(we.current)||0,total:Number(we.total)||W,phase:String(we.phase||"")});else if(we.type==="complete"){p(we.summary),o("done"),gA.success(we.message||"Import completed successfully!"),A.current=null;return}else if(we.type==="error")throw new Error(we.error||"Import failed on server.")}catch(we){if(we instanceof SyntaxError)continue;throw we}}throw new Error("Stream ended unexpectedly. Import may be incomplete.")}catch(V){if(V.name==="AbortError")return;o("error"),b(V.message||"Import failed"),gA.error("Import failed: "+(V.message||"Unknown error"))}A.current=null},[S]),O=J.useCallback(async()=>{var W;const K=i.current;if(K){o("importing"),b(""),x({current:0,total:5,phase:"Uploading database file…"});try{const q=new AbortController;A.current=q;const ee=new FormData;ee.append("database",K);const V=await vr("/api/desktop/restore/database",{method:"POST",body:ee,signal:q.signal});if(!V.ok){let ne=`Server returned ${V.status}`;try{ne=(await V.json()).error||ne}catch{}throw new Error(ne)}const Z=(W=V.body)==null?void 0:W.getReader();if(!Z)throw new Error("Browser does not support streaming responses.");const re=new TextDecoder;let ae="";for(;;){const{done:ne,value:ge}=await Z.read();if(ne)break;ae+=re.decode(ge,{stream:!0});const le=ae.split(`
|
|
8615
|
-
`);ae=le.pop()||"";for(const Ce of le)if(Ce.trim())try{const fe=JSON.parse(Ce);if(fe.type==="progress")x({current:Number(fe.current)||0,total:Number(fe.total)||5,phase:String(fe.phase||"")});else if(fe.type==="complete"){o("done"),gA.success(fe.message||"Database restored successfully!"),A.current=null;return}else if(fe.type==="error")throw new Error(fe.error||"Restore failed on server.")}catch(fe){if(fe instanceof SyntaxError)continue;throw fe}}throw new Error("Stream ended unexpectedly. Restore may be incomplete.")}catch(q){if(q.name==="AbortError")return;o("error"),b(q.message||"Restore failed"),gA.error("Restore failed: "+(q.message||"Unknown error"))}A.current=null}},[]),M=J.useCallback(()=>{t.current&&(clearTimeout(t.current),t.current=null),n.current=null,i.current=null,o("idle"),l(null),p(null),h(null),B(null),b(""),x({current:0,total:1,phase:""})},[]),T=J.useCallback(()=>{n.current=null,i.current=null,h(null),B(null),o("idle"),l(null)},[]),U=J.useCallback(()=>{t.current&&(clearTimeout(t.current),t.current=null),window.location.reload()},[]),P=J.useCallback(()=>{A.current&&(A.current.abort(),A.current=null),n.current=null,i.current=null,o("idle"),l(null),x({current:0,total:1,phase:""})},[]),R=J.useCallback(()=>{s==="db"?O():N()},[s,O,N]),Y=Math.min(Math.round(v.current/v.total*100),100),{accept:H,acceptLabel:j}=S==="desktop"?{accept:".json,.db,.sqlite,.sqlite3",acceptLabel:".json (data) or .db / .sqlite (database restore)"}:{accept:".json",acceptLabel:".json format from Guest Mode export"};if(u==="done")return m.jsxs("div",{className:"space-y-6",children:[m.jsxs("div",{className:"flex items-center gap-3 p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl",children:[m.jsx(bG,{className:"size-6 text-emerald-500 shrink-0"}),m.jsxs("div",{children:[m.jsx("h4",{className:"font-semibold text-sm",children:s==="db"?"Database Restored":"Import Completed"}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s==="db"?"The database file has been restored. The app will reload to apply the changes.":"Data has been added to your workspace."})]})]}),E&&m.jsx(Ynn,{summary:E}),m.jsxs("div",{className:"flex gap-3",children:[m.jsxs(VA,{variant:"default",size:"sm",onClick:U,children:[m.jsx(v4,{className:"size-3.5 mr-1.5"}),"Reload App Now"]}),m.jsx(VA,{variant:"outline",size:"sm",onClick:M,children:"Import Another File"})]}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"App will reload automatically in a few seconds…"})]});if(u==="preview"){if(s==="db"&&f)return m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[m.jsx(q3e,{className:"size-5 text-blue-500 shrink-0"}),m.jsxs("div",{children:[m.jsx("h4",{className:"font-semibold text-sm",children:"Restore Database File"}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["This will ",m.jsx("strong",{className:"text-amber-500",children:"replace"})," your current local database with the selected file. A safety backup will be created automatically before the restore."]}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Use this if you reinstalled the app and want to restore from a previous",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px] mx-0.5",children:".db"})," file that you saved manually."]})]})]}),m.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-4 space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:"File"}),m.jsx("span",{className:"font-medium",children:f.fileName})]}),m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:"Size"}),m.jsx("span",{className:"font-medium",children:f.fileSize})]})]}),m.jsxs("div",{className:"flex gap-3 pt-2",children:[m.jsxs(VA,{variant:"default",size:"sm",onClick:R,children:[m.jsx(lT,{className:"size-3.5 mr-1.5"}),"Restore Database"]}),m.jsxs(VA,{variant:"outline",size:"sm",onClick:T,children:[m.jsx(Zk,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]});if(s==="json"&&d){const K=Object.values(d).reduce((W,q)=>W+(q||0),0);return m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[m.jsx(hce,{className:"size-5 text-blue-500 shrink-0"}),m.jsxs("div",{children:[m.jsx("h4",{className:"font-semibold text-sm",children:"Import Preview"}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[K," items found in the export file. Click ",m.jsx("strong",{children:"Submit"})," to import the data."]})]})]}),m.jsx(Ynn,{summary:d}),m.jsxs("div",{className:"flex gap-3 pt-2",children:[m.jsxs(VA,{variant:"default",size:"sm",onClick:R,children:[m.jsx(lT,{className:"size-3.5 mr-1.5"}),"Submit"]}),m.jsxs(VA,{variant:"outline",size:"sm",onClick:T,children:[m.jsx(Zk,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]})}}return u==="error"?m.jsx("div",{className:"space-y-5",children:m.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:[m.jsx(ND,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),m.jsxs("div",{className:"text-xs text-red-600",children:[m.jsx("p",{className:"font-medium",children:s==="db"?"Database restore failed":"Import failed"}),m.jsx("p",{className:"mt-0.5",children:y}),m.jsx(VA,{variant:"ghost",size:"sm",className:"mt-2 h-auto py-1 text-xs",onClick:M,children:"Try again"})]})]})}):m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[m.jsx(Ok,{className:"size-5 text-blue-500 shrink-0 mt-0.5"}),m.jsxs("div",{className:"text-sm space-y-1",children:[m.jsx("p",{className:"font-medium",children:"Import Data"}),m.jsxs("p",{className:"text-xs text-muted-foreground",children:["Upload a ",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," file exported from Guest Mode. All data will be ",m.jsx("strong",{children:"added"})," to your workspace — existing items with the same ID will be skipped. New projects will be created for any project‑scoped items."]}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"Supports: Notes, ERD Diagrams (entities, columns, relationships), Flowcharts, Drawings, AI Chat sessions & messages, and Projects."}),S==="desktop"&&m.jsxs("p",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-border/40",children:[m.jsx("strong",{className:"text-amber-500",children:"Desktop only:"})," You can also restore a",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px] mx-0.5",children:".db"})," database file — useful after reinstalling the app to recover data from a manually saved copy. A safety backup is created automatically."]})]})]}),m.jsxs("div",{onClick:()=>{var K;u!=="importing"&&((K=e.current)==null||K.click())},onKeyDown:K=>{var W;(K.key==="Enter"||K.key===" ")&&u!=="importing"&&((W=e.current)==null||W.click())},role:"button",tabIndex:0,className:"border-2 border-dashed border-border/50 hover:border-primary/40 rounded-xl p-8 text-center cursor-pointer transition-colors",children:[m.jsx("input",{ref:e,type:"file",accept:H,className:"hidden",onChange:L}),u==="importing"?m.jsxs("div",{className:"w-full max-w-sm mx-auto space-y-4",children:[m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground truncate mr-2",children:v.phase||"Importing…"}),m.jsxs("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:[Y,"%"]})]}),m.jsx("div",{className:"w-full h-2 bg-muted/50 rounded-full overflow-hidden",children:m.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300 ease-out",style:{width:`${Y}%`}})}),m.jsxs("p",{className:"text-[11px] text-muted-foreground tabular-nums",children:[v.current.toLocaleString()," / ",v.total.toLocaleString()," items"]})]}),m.jsx(VA,{variant:"ghost",size:"sm",onClick:K=>{K.stopPropagation(),P()},className:"text-xs",children:"Cancel"})]}):m.jsxs("div",{className:"flex flex-col items-center gap-3",children:[m.jsx("div",{className:"p-3 bg-muted/30 rounded-full",children:m.jsx(LN,{className:"size-6 text-muted-foreground"})}),m.jsxs("div",{children:[m.jsx("p",{className:"text-sm font-medium",children:"Click to select a file"}),m.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:j})]})]})]})]})}function Ynn({summary:e}){return m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[m.jsx(tG,{label:"Projects",value:e.projects}),m.jsx(tG,{label:"Notes",value:e.notes}),m.jsx(tG,{label:"ERD Diagrams",value:e.diagrams}),m.jsx(tG,{label:"Tables (Entities)",value:e.entities}),m.jsx(tG,{label:"Columns",value:e.columns}),m.jsx(tG,{label:"Relationships",value:e.relationships}),m.jsx(tG,{label:"Flowcharts",value:e.flowcharts}),m.jsx(tG,{label:"Drawings",value:e.drawings}),m.jsx(tG,{label:"AI Sessions",value:e.ai_chat_sessions})]}),e.ai_chat_messages>0&&m.jsxs("p",{className:"text-[11px] text-muted-foreground px-0.5",children:["Includes ",e.ai_chat_messages.toLocaleString()," AI chat messages."]}),e.skipped_existing>0&&m.jsxs("p",{className:"text-[11px] text-amber-500 px-0.5",children:[e.skipped_existing.toLocaleString()," item(s) already existed and were skipped."]})]})}function tG({label:e,value:t}){return m.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-3 text-center",children:[m.jsx("p",{className:"text-lg font-bold",children:t.toLocaleString()}),m.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:e})]})}function gta(){if(!(typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli")))return m.jsx("div",{className:"p-4 md:p-8",children:m.jsx(Vk,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:m.jsxs(dT,{className:"py-12 text-center",children:[m.jsx(Ok,{className:"w-8 h-8 mx-auto text-muted-foreground/40"}),m.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Storage configuration is only available in the desktop app or CLI mode."})]})})});const[t,A]=J.useState({type:"r2",accountId:"",endpoint:"",region:"auto",accessKeyId:"",secretAccessKey:"",bucketName:"",publicUrl:""}),[n,i]=J.useState(null),[u,o]=J.useState("none"),[s,l]=J.useState(!0),[d,h]=J.useState(!1),[f,B]=J.useState(!1),[E,p]=J.useState({type:"",message:""}),[y,b]=J.useState(!1),[v,x]=J.useState(!1),S=J.useCallback(async()=>{l(!0);try{const T=await vr("/api/storage/config",{credentials:"include"});if(T.ok){const U=await T.json();o(U.source),U.config&&(i(U.config),A({type:U.config.type||"r2",accountId:U.config.accountId||"",endpoint:U.config.endpoint||"",region:U.config.region||"auto",accessKeyId:U.config.accessKeyId||"",secretAccessKey:U.config.secretAccessKey||"",bucketName:U.config.bucketName||"",publicUrl:U.config.publicUrl||""}))}}catch(T){console.error("Failed to load storage config:",T)}finally{l(!1)}},[]);J.useEffect(()=>{S()},[S]);const L=async()=>{h(!0),p({type:"",message:""});try{const T=await vr("/api/storage/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"});if(T.ok)p({type:"success",message:"Storage configuration saved successfully."}),i({...t}),await S();else{const U=await T.json();p({type:"error",message:U.error||"Failed to save configuration"})}}catch(T){p({type:"error",message:T.message||"Network error"})}finally{h(!1)}},N=async()=>{B(!0),p({type:"",message:""});try{const T=await vr("/api/storage/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"});if(T.ok)p({type:"success",message:"Successfully connected to storage."});else{const U=await T.json();p({type:"error",message:U.error||"Connection failed"})}}catch(T){p({type:"error",message:T.message||"Network error"})}finally{B(!1)}},O=(T,U)=>{A(P=>({...P,[T]:U})),p({type:"",message:""})};if(s)return m.jsx("div",{className:"p-4 md:p-8",children:m.jsx(Vk,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:m.jsxs(dT,{className:"py-12 text-center",children:[m.jsx(v4,{className:"w-6 h-6 animate-spin mx-auto text-muted-foreground"}),m.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Loading storage configuration..."})]})})});const M=u==="env";return m.jsx("div",{className:"p-6 space-y-6",children:m.jsxs(Vk,{className:"border border-border/50 bg-background/50 backdrop-blur-sm shadow-lg",children:[m.jsxs(ihe,{className:"border-b border-border/30 pb-6",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(BK,{className:"w-6 h-6 text-blue-500"}),m.jsx(ahe,{className:"text-xl md:text-2xl font-bold",children:"Storage Configuration"})]}),m.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Configure Cloudflare R2 or S3-compatible storage for image uploads in Notes and Drawings."})]}),m.jsxs(dT,{className:"space-y-6 p-4 md:p-6",children:[M&&m.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[m.jsx(bF,{className:"w-4 h-4 text-blue-500 shrink-0"}),m.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:"Pre-filled from environment variables. Save to override with custom settings."})]}),E.type&&m.jsxs("div",{className:`flex items-center gap-3 p-4 rounded-lg border ${E.type==="success"?"bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400":"bg-red-500/10 border-red-500/20 text-red-600 dark:text-red-400"}`,children:[E.type==="success"?m.jsx(Bk,{className:"w-5 h-5 shrink-0"}):m.jsx(nN,{className:"w-5 h-5 shrink-0"}),m.jsx("p",{className:"text-sm",children:E.message})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(Ok,{className:"size-3"}),"Storage Provider"]}),m.jsxs(KB,{value:t.type,onValueChange:(T,U)=>T&&O("type",T),children:[m.jsx(_f,{className:"h-9 text-sm",children:m.jsx(JB,{children:t.type==="r2"?m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(BK,{className:"w-4 h-4"}),"Cloudflare R2"]}):m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(Ok,{className:"w-4 h-4"}),"S3-Compatible"]})})}),m.jsxs($B,{children:[m.jsx(e0,{value:"r2",children:m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(BK,{className:"w-4 h-4"}),"Cloudflare R2"]})}),m.jsx(e0,{value:"s3-compatible",children:m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(Ok,{className:"w-4 h-4"}),"S3-Compatible"]})})]})]})]}),t.type==="r2"&&m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(zk,{className:"size-3"}),"Account ID"]}),m.jsx(Wo,{placeholder:"Your Cloudflare R2 Account ID",value:t.accountId||"",onChange:T=>O("accountId",T.target.value),className:"h-9 text-sm font-mono"}),m.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:"Found in your Cloudflare dashboard under R2 → Account ID."})]}),t.type==="s3-compatible"&&m.jsxs(m.Fragment,{children:[m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(zk,{className:"size-3"}),"Endpoint URL"]}),m.jsx(Wo,{placeholder:"https://s3.us-east-1.amazonaws.com",value:t.endpoint||"",onChange:T=>O("endpoint",T.target.value),className:"h-9 text-sm font-mono"})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(zk,{className:"size-3"}),"Region"]}),m.jsx(Wo,{placeholder:"us-east-1",value:t.region||"",onChange:T=>O("region",T.target.value),className:"h-9 text-sm font-mono"})]})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(Ice,{className:"size-3"}),"Access Key ID"]}),m.jsxs("div",{className:"relative",children:[m.jsx(Wo,{type:v?"text":"password",placeholder:"Your access key ID",value:t.accessKeyId,onChange:T=>O("accessKeyId",T.target.value),className:"h-9 text-sm font-mono pr-10"}),m.jsx("button",{type:"button",onClick:()=>x(!v),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:v?m.jsx(FN,{className:"w-4 h-4"}):m.jsx(cT,{className:"w-4 h-4"})})]})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(Ice,{className:"size-3"}),"Secret Access Key"]}),m.jsxs("div",{className:"relative",children:[m.jsx(Wo,{type:y?"text":"password",placeholder:"Your secret access key",value:t.secretAccessKey,onChange:T=>O("secretAccessKey",T.target.value),className:"h-9 text-sm font-mono pr-10"}),m.jsx("button",{type:"button",onClick:()=>b(!y),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:y?m.jsx(FN,{className:"w-4 h-4"}):m.jsx(cT,{className:"w-4 h-4"})})]})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(fce,{className:"size-3"}),"Bucket Name"]}),m.jsx(Wo,{placeholder:"your-bucket-name",value:t.bucketName,onChange:T=>O("bucketName",T.target.value),className:"h-9 text-sm font-mono"})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(mce,{className:"size-3"}),"Public URL (optional)"]}),m.jsx(Wo,{placeholder:"https://cdn.yourdomain.com",value:t.publicUrl||"",onChange:T=>O("publicUrl",T.target.value),className:"h-9 text-sm font-mono"}),m.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:t.type==="s3-compatible"?"Optional. If set, overrides the auto-constructed endpoint URL. Useful for custom CDN/domain. If empty, URL is built from Endpoint + Bucket.":"Optional public URL prefix for direct image access (e.g., custom domain or CDN). If empty, R2 public URL is auto-constructed."})]})]}),m.jsxs(Fge,{className:"bg-muted/5 border-t border-border/30 p-4 md:px-6 md:py-4 flex flex-col sm:flex-row gap-3 sm:justify-end",children:[m.jsx("button",{type:"button",onClick:N,disabled:f||!t.bucketName||!t.accessKeyId||!t.secretAccessKey,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-border text-sm font-medium whitespace-nowrap transition-colors h-10 px-4 bg-background hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none",children:f?m.jsxs(m.Fragment,{children:[m.jsx(v4,{className:"w-4 h-4 shrink-0 animate-spin pointer-events-none"}),m.jsx("span",{className:"pointer-events-none",children:"Testing..."})]}):m.jsxs(m.Fragment,{children:[m.jsx(v4,{className:"w-4 h-4 shrink-0 pointer-events-none"}),m.jsx("span",{className:"pointer-events-none",children:"Test Connection"})]})}),m.jsxs(VA,{onClick:L,className:"gap-2 px-6",disabled:d,children:[d?m.jsx(v4,{className:"w-4 h-4 animate-spin"}):m.jsx(gT,{className:"w-4 h-4"}),d?"Saving...":"Save Configuration"]})]})]})})}function dta(){const{isSettingsOpen:e,setIsSettingsOpen:t,settingsTab:A,setSettingsTab:n}=qB(),i=typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli"),{providers:u,configs:o,isTesting:s,isSaving:l,handleSaveConfig:d,handleTestConnection:h,updateProviderLocal:f,updateConfigLocal:B}=kKi(),{isGuest:E}=yx(),{models:p,newModel:y,editingModelId:b,isSaving:v,setNewModel:x,handleAddModel:S,handleDeleteModel:L,startEditingModel:N,cancelEdit:O}=xKi(),{prompts:M,isSaving:T,handleSavePrompt:U,handleDeletePrompt:P,togglePromptDefault:R}=FKi(),Y=Ot.useMemo(()=>E?[{label:"General",items:[{id:"appearance",label:"Appearance",icon:m.jsx(NAe,{className:"size-4"})}]},{label:"More",items:[{id:"changelog",label:"What's New",icon:m.jsx(FAe,{className:"size-4"})}]}]:[{label:"General",items:[{id:"account",label:"Account",icon:m.jsx(ON,{className:"size-4"})},{id:"appearance",label:"Appearance",icon:m.jsx(NAe,{className:"size-4"})},...i?[{id:"storage",label:"Storage",icon:m.jsx(Ok,{className:"size-4"})}]:[]]},{label:"Feature",items:[{id:"ai-config",label:"AI Configuration",icon:m.jsx(ry,{className:"size-4"})},{id:"ai-models",label:"Model Catalog",icon:m.jsx(Qce,{className:"size-4"})},{id:"ai-rules",label:"AI Rules",icon:m.jsx(swe,{className:"size-4"})},{id:"ai-prompts",label:"System Prompts",icon:m.jsx(Y3e,{className:"size-4"})}]},{label:"More",items:[{id:"import-data",label:"Import Data",icon:m.jsx(LN,{className:"size-4"})},{id:"backups",label:"Database Backup",icon:m.jsx(Z0,{className:"size-4"})},{id:"changelog",label:"What's New",icon:m.jsx(FAe,{className:"size-4"})}]}],[E]),H=Y.flatMap(K=>K.items),j=K=>{var W;return((W=H.find(q=>q.id===K))==null?void 0:W.label)||""};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"overflow-hidden p-0 md:max-h-150 md:max-w-175 lg:max-w-237.5 bg-background border-border/40 shadow-2xl",children:[m.jsx(Yg,{className:"sr-only",children:"Settings"}),m.jsx(ip,{className:"sr-only",children:"Manage your application settings and AI configuration."}),m.jsxs(Z5n,{className:"items-start min-h-0! h-full",children:[m.jsx(V5n,{collapsible:"none",className:"w-55 border-r border-border/40 bg-muted/5 hidden md:flex h-full",children:m.jsxs(e6n,{className:"pt-4 px-2 pb-0",children:[m.jsx("div",{className:"px-4 py-2 mb-2",children:m.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[m.jsx(MAe,{className:"size-4"}),"Settings"]})}),Y.map(K=>m.jsxs(Ict,{className:"py-1",children:[m.jsx(DWt,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-4 mb-0.5",children:K.label}),m.jsx(vWt,{children:m.jsx(oDe,{children:K.items.map(W=>m.jsx(Nge,{children:m.jsxs($K,{isActive:A===W.id,onClick:()=>n(W.id),className:`transition-all duration-200 px-4 py-2 rounded-md ${A===W.id?"bg-sidebar-accent text-sidebar-accent-foreground font-medium":"text-muted-foreground hover:bg-sidebar-accent/50"}`,children:[W.icon,m.jsx("span",{className:"text-xs",children:W.label})]})},W.id))})})]},K.label))]})}),m.jsxs("main",{className:"flex-1 flex flex-col h-150 overflow-hidden",children:[m.jsx("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-6 backdrop-blur-sm",children:m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(A6n,{className:"hidden md:flex",children:m.jsxs(n6n,{children:[m.jsx(j8,{children:m.jsx(_Ti,{href:"#",className:"text-[11px] text-muted-foreground",children:"Settings"})}),m.jsx(kWt,{}),m.jsx(j8,{children:m.jsx(GO,{className:"text-[11px] font-semibold",children:j(A)})})]})}),m.jsx("div",{className:"md:hidden",children:m.jsxs(fy,{children:[m.jsx(y3,{render:m.jsxs(VA,{variant:"ghost",size:"sm",className:"-ml-2 h-8 gap-2 text-xs font-semibold",children:[m.jsx(MAe,{className:"size-3.5"}),j(A),m.jsx(N5,{className:"size-3 opacity-50"})]})}),m.jsx(b3,{align:"start",className:"w-56",children:Y.map(K=>m.jsxs(ble,{children:[m.jsx(MiA,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-2 py-1.5",children:K.label}),K.items.map(W=>m.jsxs(dc,{onClick:()=>n(W.id),className:A===W.id?"bg-accent":"",children:[W.icon,m.jsx("span",{className:"ml-2",children:W.label})]},W.id)),m.jsx(GI,{})]},K.label))})]})})]})}),m.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[A==="ai-config"&&m.jsx(dJi,{providers:u,configs:o,models:p,isSaving:l,isTesting:s,onSave:d,onTest:K=>h(K,Object.values(p).flat()),onUpdateProvider:f,onUpdateConfig:B}),A==="ai-models"&&m.jsx(IJi,{providers:u,models:Object.values(p).flat(),newModel:y,editingModelId:b,isSaving:v,onSetNewModel:x,onAddModel:S,onEditModel:N,onDeleteModel:L,onCancelEdit:O}),A==="ai-prompts"&&m.jsx(DJi,{prompts:M,isSaving:T,onSave:U,onDelete:P,onToggleDefault:R}),A==="ai-rules"&&m.jsx(xJi,{}),A==="backups"&&m.jsx("div",{className:"p-6 space-y-6",children:m.jsx(uzi,{})}),A==="account"&&m.jsx(OJi,{}),A==="changelog"&&m.jsx("div",{className:"p-6 space-y-6",children:m.jsx(uta,{})}),A==="import-data"&&m.jsxs("div",{className:"p-4 md:p-6 overflow-y-auto h-full",children:[m.jsxs("div",{className:"mb-6",children:[m.jsx("h2",{className:"text-lg font-semibold",children:"Import Data"}),m.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Restore data from a JSON backup or replace the local database from a .db file."})]}),m.jsx(cta,{})]}),A==="appearance"&&m.jsx(RJi,{}),A==="storage"&&m.jsx(gta,{})]})]})]})]})})}async function hta(){try{const{getVersion:e}=await Xr(async()=>{const{getVersion:t}=await Promise.resolve().then(()=>zFn);return{getVersion:t}},void 0);return await e()}catch{return"0.0.0"}}function kvn({open:e,onOpenChange:t,hasUpdate:A=!1,latestVersion:n=null,isChecking:i=!1,isDownloading:u=!1,onCheckUpdate:o,onDownload:s}){const l=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),[d,h]=J.useState("..."),[f,B]=J.useState(!1),[E,p]=J.useState(null),[y,b]=J.useState(!1),[v,x]=J.useState(!1),[S,L]=J.useState(null),N=A||f,O=n||E,M=i||y,T=u||v;J.useEffect(()=>{l?hta().then(h):h("3.1.1")},[l]),J.useEffect(()=>{if(!e||!l||A||i||u)return;if(o){o();return}if(s)return;b(!0);let R=!1;return(async()=>{try{const{check:H}=await Xr(async()=>{const{check:K}=await Promise.resolve().then(()=>rtn);return{check:K}},void 0),j=await H();if(R)return;j?(B(!0),p(j.version),L(j)):(B(!1),p(null),L(null))}catch{}finally{R||b(!1)}})(),()=>{R=!0}},[e,l]);const U=J.useCallback(()=>{if(s)s();else if(S){if(v)return;x(!0),S.downloadAndInstall(()=>{}).catch(R=>{const Y=typeof R=="string"?R:R!=null&&R.message?R.message:JSON.stringify(R);gA.error("Update failed",{description:Y||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(Y).catch(()=>{})}})}).finally(()=>x(!1))}},[s,S,v]),P=J.useCallback(()=>{if(T)return;if(o){o();return}b(!0),B(!1),p(null),(async()=>{try{const{check:Y}=await Xr(async()=>{const{check:j}=await Promise.resolve().then(()=>rtn);return{check:j}},void 0),H=await Y();H?(B(!0),p(H.version),L(H)):(B(!1),p(null),L(null))}catch{}finally{b(!1)}})()},[o,T]);return J.useEffect(()=>{e||(B(!1),p(null),b(!1),L(null))},[e]),m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"max-w-sm bg-background border-border/40 shadow-2xl",children:[m.jsx(Yg,{className:"sr-only",children:"About ERD Builder Pro"}),m.jsx(ip,{className:"sr-only",children:"Application information and credits."}),m.jsxs("div",{className:"flex flex-col items-center py-6 gap-4",children:[m.jsx("div",{className:"flex items-center justify-center",children:m.jsx("img",{src:"/favicon.svg",alt:"ERD Builder Pro",className:"size-14"})}),m.jsxs("div",{className:"text-center",children:[m.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"ERD Builder Pro"}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Version ",d]})]}),m.jsx("p",{className:"text-xs text-center text-muted-foreground max-w-60 leading-relaxed",children:"Entity-Relationship Diagram builder, flowcharts, notes, and AI-powered assistance — all in one desktop app."}),l&&m.jsxs("div",{className:"w-full",children:[m.jsx("div",{className:"w-full border-t border-border/40 mb-3"}),M?m.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground py-1",children:[m.jsx(js,{className:"size-3.5 animate-spin"}),"Checking for updates..."]}):N&&O?m.jsxs("div",{className:"flex flex-col items-center gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-500",children:[m.jsx(YQ,{className:"size-3.5"}),m.jsxs("span",{children:["Update ",m.jsxs("strong",{children:["v",O]})," available"]})]}),m.jsxs(VA,{variant:"default",size:"sm",className:"h-8 text-xs gap-1.5",onClick:U,disabled:T,children:[T?m.jsx(js,{className:"size-3.5 animate-spin"}):m.jsx(YQ,{className:"size-3.5"}),T?"Downloading...":"Download Update"]})]}):m.jsxs("div",{className:"flex flex-col items-center gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-500",children:[m.jsx(Bk,{className:"size-3.5"}),m.jsx("span",{children:"You're up to date"})]}),m.jsxs(VA,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:P,children:[m.jsx(v4,{className:"size-3"}),"Check Again"]})]})]}),m.jsx("div",{className:"w-full border-t border-border/40"}),m.jsxs("div",{className:"text-[10px] text-center text-muted-foreground/60 leading-relaxed",children:[m.jsx("p",{children:"Built with React, Tauri, Express & Prisma."}),m.jsxs("p",{className:"mt-0.5",children:["© ",new Date().getFullYear()," Bekenweb."]})]}),m.jsx("div",{className:"flex items-center gap-3",children:m.jsxs(VA,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:()=>{window.open("https://github.com/hadziqmtqn/erd-builder-pro","_blank")},children:[m.jsx(IK,{className:"size-3"}),"GitHub"]})})]})]})})}function Cta(e){const[t,A]=J.useState(!1),[n,i]=J.useState(null),[u,o]=J.useState(!1),[s,l]=J.useState(null),{setViewport:d,fitView:h}=yJ();return{isPublicView:t,setIsPublicView:A,publicData:n,isPublicLoading:u,forbiddenDoc:s,fetchPublicDocument:async(B,E,p,y,b)=>{o(!0),l(null);try{const v=B==="erd"?"files":B==="flowchart"?"flowcharts":B,x={"Content-Type":"application/json"};b&&(x["x-share-token"]=b);const S=await vr(`/api/${v}/public/${E}`,{headers:x,credentials:"include"});if(!S.ok){let O="Document not found or access denied",M="Access Denied";try{O=(await S.json()).error||O,S.status===404?M="Not Found":(S.status===401||S.status===403)&&(M="Access Denied")}catch{}if(S.status===401||S.status===403||S.status===404)return l({title:M,message:O,status:S.status}),!1;throw new Error(O)}const L=S.headers.get("content-type");if(!L||!L.includes("application/json"))throw new Error("Received invalid response from server");const N=await S.json();if(i(N),e(B),B==="erd"){const O=N.entities.map(U=>({id:U.id,type:"entity",position:{x:U.x,y:U.y},data:U})),M=N.relationships.map(U=>{const P=N.entities.find(j=>String(j.id)===String(U.source_entity_id)),R=N.entities.find(j=>String(j.id)===String(U.target_entity_id));let Y=U.source_handle,H=U.target_handle;if(!Y&&P&&R){const j=Number(P.x)||0,K=Number(R.x)||0;Y=j<K?`col-${U.source_column_id}-source`:`col-${U.source_column_id}-source-l`}if(!H&&P&&R){const j=Number(P.x)||0,K=Number(R.x)||0;H=j<K?`col-${U.target_column_id}-target`:`col-${U.target_column_id}-target-r`}return{id:U.id,source:U.source_entity_id,target:U.target_entity_id,sourceHandle:Y||(U.source_column_id?`col-${U.source_column_id}-source`:void 0),targetHandle:H||(U.target_column_id?`col-${U.target_column_id}-target`:void 0),label:U.label,type:"smoothstep",animated:!0}});p(O),y(M);const T=(U=0)=>{N.viewport_x!==void 0&&(N.viewport_x!==0||N.viewport_y!==0)?d({x:N.viewport_x,y:N.viewport_y,zoom:N.viewport_zoom||1},{duration:U}):O.length>0&&h({padding:.2,duration:U})};setTimeout(()=>T(0),50),setTimeout(()=>T(0),300)}else if(B==="flowchart")try{const O=typeof N.data=="string"?JSON.parse(N.data):N.data;p(O.nodes||[]),y(O.edges||[]);const M=(T=0)=>{var U;N.viewport_x!==void 0&&(N.viewport_x!==0||N.viewport_y!==0)?d({x:N.viewport_x,y:N.viewport_y,zoom:N.viewport_zoom||1},{duration:T}):((U=O.nodes)==null?void 0:U.length)>0&&h({padding:.2,duration:T})};setTimeout(()=>M(0),50),setTimeout(()=>M(0),300)}catch(O){console.error("Failed to parse flowchart data:",O)}else p([]),y([]);return!0}catch(v){return gA.error(v.message||"Failed to load shared document"),setTimeout(()=>window.location.href="/",3e3),!1}finally{o(!1)}}}}function fta(e){const{open:t,defaultOpen:A,onOpenChange:n,disabled:i}=e,u=t!==void 0,[o,s]=Bne({controlled:t,default:A,name:"Collapsible",state:"open"}),{mounted:l,setMounted:d,transitionStatus:h}=kJ(o,!0,!0),[f,B]=J.useState(o),[{height:E,width:p},y]=J.useState({height:void 0,width:void 0}),b=R4(),[v,x]=J.useState(),S=v??b,[L,N]=J.useState(!1),[O,M]=J.useState(!1),T=J.useRef(null),U=J.useRef(null),P=J.useRef(null),R=J.useRef(null),Y=VBt(R,!1),H=la(j=>{const K=!o,W=Eo(JN,j.nativeEvent);if(n(K,W),W.isCanceled)return;const q=R.current;U.current==="css-animation"&&q!=null&&q.style.removeProperty("animation-name"),!L&&!O&&(U.current!=null&&U.current!=="css-animation"&&!l&&K&&d(!0),U.current==="css-animation"&&(!f&&K&&B(!0),!l&&K&&d(!0))),s(K),U.current==="none"&&l&&!K&&d(!1)});return Li(()=>{u&&U.current==="none"&&!O&&!o&&d(!1)},[u,O,o,t,d]),J.useMemo(()=>({abortControllerRef:T,animationTypeRef:U,disabled:i,handleTrigger:H,height:E,mounted:l,open:o,panelId:S,panelRef:R,runOnceAnimationsFinish:Y,setDimensions:y,setHiddenUntilFound:N,setKeepMounted:M,setMounted:d,setOpen:s,setPanelIdState:x,setVisible:B,transitionDimensionRef:P,transitionStatus:h,visible:f,width:p}),[T,U,i,H,E,l,o,S,R,Y,y,N,M,d,s,B,P,h,f,p])}const xvn=J.createContext(void 0);function Fvn(){const e=J.useContext(xvn);if(e===void 0)throw new Error(Cc(15));return e}let Uwe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=LT.startingStyle]="startingStyle",e[e.endingStyle=LT.endingStyle]="endingStyle",e})({}),Bta=(function(e){return e.panelOpen="data-panel-open",e})({});const Eta={[Uwe.open]:""},Ita={[Uwe.closed]:""},pta={open(e){return e?{[Bta.panelOpen]:""}:null}},Qta={open(e){return e?Eta:Ita}},Svn={...Qta,...wx},mta=J.forwardRef(function(t,A){const{render:n,className:i,defaultOpen:u=!1,disabled:o=!1,onOpenChange:s,open:l,...d}=t,h=la(s),f=fta({open:l,defaultOpen:u,onOpenChange:h,disabled:o}),B=J.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),E=J.useMemo(()=>({...f,onOpenChange:h,state:B}),[f,h,B]),p=go("div",t,{state:B,ref:A,props:d,stateAttributesMapping:Svn});return m.jsx(xvn.Provider,{value:E,children:p})}),wta={...pta,...wx},yta=J.forwardRef(function(t,A){const{panelId:n,open:i,handleTrigger:u,state:o,disabled:s}=Fvn(),{className:l,disabled:d=s,id:h,render:f,nativeButton:B=!0,...E}=t,{getButtonProps:p,buttonRef:y}=iS({disabled:d,focusableWhenDisabled:!0,native:B}),b=J.useMemo(()=>({"aria-controls":i?n:void 0,"aria-expanded":i,onClick:u}),[n,i,u]);return go("button",t,{state:o,ref:[A,y],props:[b,E,p],stateAttributesMapping:wta})});let bta=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e})({});function Dta(e){const{abortControllerRef:t,animationTypeRef:A,externalRef:n,height:i,hiddenUntilFound:u,keepMounted:o,id:s,mounted:l,onOpenChange:d,open:h,panelRef:f,runOnceAnimationsFinish:B,setDimensions:E,setMounted:p,setOpen:y,setVisible:b,transitionDimensionRef:v,visible:x,width:S}=e,L=J.useRef(!1),N=J.useRef(null),O=J.useRef(h),M=J.useRef(h),T=z6e(),U=J.useMemo(()=>A.current==="css-animation"?!x:!h&&!l,[h,l,x,A]),P=la(Y=>{if(!Y)return;if(A.current==null||v.current==null){const K=getComputedStyle(Y),W=K.animationName!=="none"&&K.animationName!=="",q=K.transitionDuration!=="0s"&&K.transitionDuration!=="";W&&q||(K.animationName==="none"&&K.transitionDuration!=="0s"?A.current="css-transition":K.animationName!=="none"&&K.transitionDuration==="0s"?A.current="css-animation":A.current="none"),Y.getAttribute(bta.orientation)==="horizontal"||K.transitionProperty.indexOf("width")>-1?v.current="width":v.current="height"}if(A.current!=="css-transition")return;(i===void 0||S===void 0)&&(E({height:Y.scrollHeight,width:Y.scrollWidth}),M.current&&Y.style.setProperty("transition-duration","0s"));let H=-1,j=-1;return H=MB.request(()=>{M.current=!1,j=MB.request(()=>{setTimeout(()=>{Y.style.removeProperty("transition-duration")})})}),()=>{MB.cancel(H),MB.cancel(j)}}),R=jF(n,f,P);return Li(()=>{if(A.current!=="css-transition")return;const Y=f.current;if(!Y)return;let H=-1;if(t.current!=null&&(t.current.abort(),t.current=null),h){const j={"justify-content":Y.style.justifyContent,"align-items":Y.style.alignItems,"align-content":Y.style.alignContent,"justify-items":Y.style.justifyItems};Object.keys(j).forEach(K=>{Y.style.setProperty(K,"initial","important")}),!M.current&&!o&&Y.setAttribute(Uwe.startingStyle,""),E({height:Y.scrollHeight,width:Y.scrollWidth}),H=MB.request(()=>{Object.entries(j).forEach(([K,W])=>{W===""?Y.style.removeProperty(K):Y.style.setProperty(K,W)})})}else{if(Y.scrollHeight===0&&Y.scrollWidth===0)return;E({height:Y.scrollHeight,width:Y.scrollWidth});const j=new AbortController;t.current=j;const K=j.signal;let W=null;const q=Uwe.endingStyle;return W=new MutationObserver(ee=>{ee.some(Z=>Z.type==="attributes"&&Z.attributeName===q)&&(W==null||W.disconnect(),W=null,B(()=>{E({height:0,width:0}),Y.style.removeProperty("content-visibility"),p(!1),t.current===j&&(t.current=null)},K))}),W.observe(Y,{attributes:!0,attributeFilter:[q]}),()=>{W==null||W.disconnect(),T.cancel(),t.current===j&&(j.abort(),t.current=null)}}return()=>{MB.cancel(H)}},[t,A,T,u,o,l,h,f,B,E,p]),Li(()=>{if(A.current!=="css-animation")return;const Y=f.current;Y&&(N.current=Y.style.animationName||N.current,Y.style.setProperty("animation-name","none"),E({height:Y.scrollHeight,width:Y.scrollWidth}),!O.current&&!L.current&&Y.style.removeProperty("animation-name"),h?(t.current!=null&&(t.current.abort(),t.current=null),p(!0),b(!0)):(t.current=new AbortController,B(()=>{p(!1),b(!1),t.current=null},t.current.signal)))},[t,A,h,f,B,E,p,b,x]),j6e(()=>{const Y=MB.request(()=>{O.current=!1});return()=>MB.cancel(Y)}),Li(()=>{if(!u)return;const Y=f.current;if(!Y)return;let H=-1,j=-1;return h&&L.current&&(Y.style.transitionDuration="0s",E({height:Y.scrollHeight,width:Y.scrollWidth}),H=MB.request(()=>{L.current=!1,j=MB.request(()=>{setTimeout(()=>{Y.style.removeProperty("transition-duration")})})})),()=>{MB.cancel(H),MB.cancel(j)}},[u,h,f,E]),Li(()=>{const Y=f.current;Y&&u&&U&&(Y.setAttribute("hidden","until-found"),A.current==="css-transition"&&Y.setAttribute(Uwe.startingStyle,""))},[u,U,A,f]),J.useEffect(function(){const H=f.current;if(!H)return;function j(K){L.current=!0,y(!0),d(!0,Eo(KN,K))}return H.addEventListener("beforematch",j),()=>{H.removeEventListener("beforematch",j)}},[d,f,y]),J.useMemo(()=>({props:{hidden:U,id:s,ref:R}}),[U,s,R])}let Pnn=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const vta=J.forwardRef(function(t,A){const{className:n,hiddenUntilFound:i,keepMounted:u,render:o,id:s,...l}=t,{abortControllerRef:d,animationTypeRef:h,height:f,mounted:B,onOpenChange:E,open:p,panelId:y,panelRef:b,runOnceAnimationsFinish:v,setDimensions:x,setHiddenUntilFound:S,setKeepMounted:L,setMounted:N,setPanelIdState:O,setOpen:M,setVisible:T,state:U,transitionDimensionRef:P,visible:R,width:Y,transitionStatus:H}=Fvn(),j=i??!1,K=u??!1;Li(()=>{if(s)return O(s),()=>{O(void 0)}},[s,O]),Li(()=>{S(j)},[S,j]),Li(()=>{L(K)},[L,K]);const{props:W}=Dta({abortControllerRef:d,animationTypeRef:h,externalRef:A,height:f,hiddenUntilFound:j,id:y,keepMounted:K,mounted:B,onOpenChange:E,open:p,panelRef:b,runOnceAnimationsFinish:v,setDimensions:x,setMounted:N,setOpen:M,setVisible:T,transitionDimensionRef:P,visible:R,width:Y});a9({open:p&&H==="idle",ref:b,onComplete(){p&&x({height:void 0,width:void 0})}});const q=J.useMemo(()=>({...U,transitionStatus:H}),[U,H]),ee=go("div",t,{state:q,ref:[A,b],props:[W,{style:{[Pnn.collapsiblePanelHeight]:f===void 0?"auto":`${f}px`,[Pnn.collapsiblePanelWidth]:Y===void 0?"auto":`${Y}px`}},l],stateAttributesMapping:Svn});return K||j||!K&&B?ee:null});function kta({...e}){return m.jsx(mta,{"data-slot":"collapsible",...e})}function xta({...e}){return m.jsx(yta,{"data-slot":"collapsible-trigger",...e})}function Fta({...e}){return m.jsx(vta,{"data-slot":"collapsible-content",...e})}function Sta({items:e}){return m.jsx(oDe,{children:e.map(t=>{var A;return m.jsx(Nge,{children:t.items?m.jsxs(kta,{defaultOpen:t.isActive,className:"group/collapsible",children:[m.jsx(xta,{render:m.jsxs($K,{tooltip:t.title,className:"cursor-pointer",children:[t.icon&&m.jsx(t.icon,{className:t.iconClassName}),m.jsx("span",{children:t.title}),m.jsx(Yf,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),m.jsx(Fta,{children:m.jsx(YTi,{children:(A=t.items)==null?void 0:A.map(n=>m.jsx(PTi,{children:m.jsx(t6n,{render:m.jsx("a",{href:n.url}),className:"cursor-pointer",children:m.jsx("span",{children:n.title})})},n.title))})})]}):m.jsxs($K,{tooltip:t.title,isActive:t.isActive,onClick:t.onClick,className:"cursor-pointer",children:[t.icon&&m.jsx(t.icon,{className:t.iconClassName}),m.jsx("span",{children:t.title})]})},t.title)})})}const Lvn=J.createContext(void 0);function Ovn(){const e=J.useContext(Lvn);if(e===void 0)throw new Error(Cc(13));return e}const yaA={imageLoadingStatus:()=>null},Lta=J.forwardRef(function(t,A){const{className:n,render:i,...u}=t,[o,s]=J.useState("idle"),l={imageLoadingStatus:o},d=J.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),h=go("span",t,{state:l,ref:A,props:u,stateAttributesMapping:yaA});return m.jsx(Lvn.Provider,{value:d,children:h})});function Ota(e,{referrerPolicy:t,crossOrigin:A}){const[n,i]=J.useState("idle");return Li(()=>{if(!e)return i("error"),iy;let u=!0;const o=new window.Image,s=l=>()=>{u&&i(l)};return i("loading"),o.onload=s("loaded"),o.onerror=s("error"),t&&(o.referrerPolicy=t),o.crossOrigin=A??null,o.src=e,()=>{u=!1}},[e,A,t]),n}const Nta={...yaA,...wx},Mta=J.forwardRef(function(t,A){const{className:n,render:i,onLoadingStatusChange:u,referrerPolicy:o,crossOrigin:s,...l}=t,d=Ovn(),h=Ota(t.src,{referrerPolicy:o,crossOrigin:s}),f=h==="loaded",{mounted:B,transitionStatus:E,setMounted:p}=kJ(f),y=J.useRef(null),b=la(S=>{u==null||u(S),d.setImageLoadingStatus(S)});Li(()=>{h!=="idle"&&b(h)},[h,b]);const v={imageLoadingStatus:h,transitionStatus:E};a9({open:f,ref:y,onComplete(){f||p(!1)}});const x=go("img",t,{state:v,ref:[A,y],props:l,stateAttributesMapping:Nta,enabled:B});return B?x:null}),Rta=J.forwardRef(function(t,A){const{className:n,render:i,delay:u,...o}=t,{imageLoadingStatus:s}=Ovn(),[l,d]=J.useState(u===void 0),h=dC();return J.useEffect(()=>(u!==void 0&&h.start(u,()=>d(!0)),h.clear),[h,u]),go("span",t,{state:{imageLoadingStatus:s},ref:A,props:o,stateAttributesMapping:yaA,enabled:s!=="loaded"&&l})}),oZt=J.forwardRef(({className:e,size:t="default",...A},n)=>m.jsx(Lta,{ref:n,"data-slot":"avatar","data-size":t,className:Xn("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",e),...A}));oZt.displayName="Avatar";const sZt=J.forwardRef(({className:e,...t},A)=>m.jsx(Mta,{ref:A,"data-slot":"avatar-image",className:Xn("aspect-square size-full rounded-full object-cover",e),...t}));sZt.displayName="AvatarImage";const lZt=J.forwardRef(({className:e,...t},A)=>m.jsx(Rta,{ref:A,"data-slot":"avatar-fallback",className:Xn("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",e),...t}));lZt.displayName="AvatarFallback";function Uta({open:e,onOpenChange:t}){const[A,n]=J.useState(!1),i=async()=>{n(!0);try{await r9n(),gA.success("Data exported successfully!")}catch(u){gA.error("Export failed: "+(u.message||"Unknown error"))}finally{n(!1)}};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-[420px] bg-background border-border/40 shadow-2xl",children:[m.jsx(Yg,{className:"sr-only",children:"Guest Data Backup"}),m.jsx(ip,{className:"sr-only",children:"Export your Guest Mode data as a JSON file for safe keeping or future import."}),m.jsxs("div",{className:"p-2 space-y-6",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"p-2.5 bg-amber-500/10 rounded-xl",children:m.jsx(ON,{className:"size-5 text-amber-500"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"font-semibold text-base",children:"Guest Mode"}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"You are browsing as a guest"})]})]}),m.jsxs("div",{className:"bg-muted/10 border border-border/40 rounded-xl p-4 space-y-3",children:[m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx(Z0,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),m.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:m.jsxs("p",{children:["Your data (notes, diagrams, flowcharts, drawings, and AI chats) is stored locally in your browser. Export it as a ",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," ","file so you can import it after signing in."]})})]}),m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx(hce,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),m.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:m.jsxs("p",{children:["The export file can be imported into any ERD Builder Pro account via",m.jsx("strong",{children:" Settings → Guest Data Import"}),"."]})})]})]}),m.jsx(VA,{onClick:i,disabled:A,className:"w-full",children:A?m.jsxs(m.Fragment,{children:[m.jsx(js,{className:"size-4 mr-2 animate-spin"}),"Exporting…"]}):m.jsxs(m.Fragment,{children:[m.jsx(YQ,{className:"size-4 mr-2"}),"Export My Data"]})}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute inset-0 flex items-center",children:m.jsx("span",{className:"w-full border-t border-border/30"})}),m.jsx("div",{className:"relative flex justify-center text-xs",children:m.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Need an account?"})})]}),m.jsx("div",{className:"text-center space-y-2",children:m.jsx("p",{className:"text-xs text-muted-foreground",children:"Sign up or log in from the main page to import your backup."})})]})]})})}function Gta({user:e,onLogout:t,onViewChange:A,isOnline:n,onOpenFeedback:i}){var R,Y,H;const{isMobile:u}=LJ(),{isGuest:o,setIsSettingsOpen:s,setSettingsTab:l,hasUpdate:d,latestVersion:h,isCheckingUpdate:f,isDownloadingUpdate:B,isWebOutdated:E,showOutdatedBadge:p,checkForUpdates:y,downloadUpdate:b}=qB(),v=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__);if(!e)return null;const x=e.email||"",S=((R=e.user_metadata)==null?void 0:R.full_name)||((Y=e.user_metadata)==null?void 0:Y.name)||x.split("@")[0]||"User",L=((H=e.user_metadata)==null?void 0:H.avatar_url)||"",N=S.substring(0,2).toUpperCase(),O=j=>{l(j),s(!0)},[M,T]=J.useState(!1),[U,P]=J.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx(oDe,{children:m.jsx(Nge,{children:m.jsxs(fy,{children:[m.jsx(y3,{render:m.jsxs($K,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[m.jsxs("div",{className:"relative",children:[m.jsxs(oZt,{className:"h-8 w-8 rounded-lg",children:[m.jsx(sZt,{src:L,alt:S}),m.jsx(lZt,{className:"rounded-lg",children:N})]}),p&&m.jsx("span",{className:"absolute -top-1 -right-1 flex size-3 rounded-full bg-amber-500 ring-2 ring-sidebar",title:v?`Update available: v${h||"?"}`:E?`New version available: v${h||"?"}. You're on v3.1.1. Pull latest Docker image or update your install.`:""})]}),m.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[m.jsx("span",{className:"truncate font-semibold",children:S}),m.jsx("span",{className:"truncate text-xs",children:x})]}),m.jsx(j3e,{className:"ml-auto size-4"})]})}),m.jsxs(b3,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:u?"bottom":"right",align:"end",sideOffset:4,children:[m.jsx(ble,{children:m.jsx(MiA,{className:"p-0 font-normal",children:m.jsx(ble,{children:m.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[m.jsxs(oZt,{className:"h-8 w-8 rounded-lg",children:[m.jsx(sZt,{src:L,alt:S}),m.jsx(lZt,{className:"rounded-lg",children:N})]}),m.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[m.jsx("span",{className:"truncate font-semibold",children:S}),m.jsx("span",{className:"truncate text-xs",children:x})]})]})})})}),m.jsx(GI,{}),m.jsxs(ble,{children:[m.jsxs(dc,{onClick:()=>O(o?"appearance":"account"),className:"cursor-pointer",disabled:!o&&!n,children:[m.jsx(MAe,{className:"mr-2 size-4"}),"Settings"]}),o&&m.jsxs(dc,{onClick:()=>T(!0),className:"cursor-pointer",children:[m.jsx(YQ,{className:"mr-2 size-4"}),"Backup Data"]}),m.jsx(GI,{}),m.jsxs(dc,{onClick:()=>P(!0),className:"cursor-pointer",children:[d?m.jsx(Ej,{className:"mr-2 size-4 text-emerald-400"}):E?m.jsx(T3e,{className:"mr-2 size-4 text-amber-500"}):m.jsx(bF,{className:"mr-2 size-4"}),"About",p&&m.jsx("span",{className:`ml-auto flex size-2 rounded-full ${d?"bg-emerald-400":"bg-amber-500"}`})]}),m.jsxs(dc,{render:m.jsx("a",{href:"https://github.com/hadziqmtqn/erd-builder-pro",target:"_blank",rel:"noopener noreferrer"}),className:"cursor-pointer",children:[m.jsx(V3e,{className:"mr-2 size-4"}),"Github"]}),m.jsxs(dc,{onClick:i,className:"cursor-pointer",children:[m.jsx(hwe,{className:"mr-2 size-4"}),"Feedback"]})]}),m.jsx(GI,{}),m.jsx(ble,{children:m.jsxs(dc,{onClick:()=>n&&A("trash"),disabled:!n,className:`text-destructive focus:bg-accent focus:text-destructive cursor-pointer ${!n&&"opacity-50 cursor-not-allowed"}`,children:[m.jsx(Qg,{className:"mr-2 size-4"}),"Trash"]})}),m.jsx(GI,{}),!v&&m.jsxs(dc,{onClick:()=>n&&t(),disabled:!n,className:`cursor-pointer ${!n&&"opacity-50 cursor-not-allowed"}`,title:n?"":"Logging out while offline may cause data loss of unsynced changes",children:[m.jsx(cwe,{className:"mr-2 size-4"}),"Log out"]})]})]})})}),m.jsx(Uta,{open:M,onOpenChange:T}),m.jsx(kvn,{open:U,onOpenChange:P,hasUpdate:d,latestVersion:h,isChecking:f,isDownloading:B,onCheckUpdate:y,onDownload:b})]})}function Tta({teams:e}){const{isMobile:t}=LJ(),A=AS(),n=e[0];return m.jsx(oDe,{children:m.jsx(Nge,{children:m.jsxs($K,{size:"lg",onClick:()=>A("/"),className:"hover:bg-accent/50 active:bg-accent/70 transition-colors cursor-pointer",children:[m.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground",children:m.jsx(n.logo,{className:"size-4"})}),m.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[m.jsx("span",{className:"truncate font-semibold",children:n.name}),m.jsx("span",{className:"truncate text-xs",children:n.plan})]})]})})})}const cZt=({isOpen:e,onOpenChange:t,mode:A="move-to-trash",activeDocument:n,view:i,deleteDiagram:u,deleteNote:o,deleteDrawing:s,deleteFlowchart:l,deleteProject:d,fetchTrash:h,itemType:f,onConfirm:B,onAfterDelete:E})=>{const p=async()=>{if(A==="permanent-delete"){B==null||B(),E==null||E();return}if(B){B(),E==null||E();return}const v=i==="erd"||i==="notes"||i==="flowchart"||i==="drawings"?(n==null?void 0:n.uid)??(n==null?void 0:n.id):n==null?void 0:n.id;v&&(i==="erd"?await(u==null?void 0:u(v)):i==="notes"?await(o==null?void 0:o(String(v))):i==="drawings"?await(s==null?void 0:s(v)):i==="flowchart"?await(l==null?void 0:l(v)):i==="project"&&await(d==null?void 0:d(v)),h==null||h(),t(!1),E==null||E())},y=f==="erd"?"diagram":f==="notes"?"note":f==="drawings"?"drawing":f==="project"?"workspace":"item";if(A==="permanent-delete"){const v=f==="project";return m.jsx(DF,{open:e,onOpenChange:t,children:m.jsxs(vF,{size:"sm",className:"max-w-[400px]",children:[m.jsxs(kF,{children:[m.jsx(Rge,{className:"bg-destructive/10",children:m.jsx(p4,{className:"w-5 h-5 text-destructive"})}),m.jsx(SF,{children:"Are you absolutely sure?"})]}),m.jsx(xF,{children:m.jsx(Qne,{children:v?m.jsxs(m.Fragment,{children:["This action cannot be undone. Deleting this workspace will also permanently delete all",m.jsx("strong",{children:" notes, diagrams, drawings, and flowcharts"})," inside it."]}):m.jsxs(m.Fragment,{children:["This action cannot be undone. This will permanently delete the ",m.jsx("strong",{children:y})," from our servers."]})})}),m.jsxs(FF,{children:[m.jsx(ex,{onClick:()=>t(!1),children:"Cancel"}),m.jsx(zN,{onClick:p,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Permanently Delete"})]})]})})}const b=i!=="project";return m.jsx(DF,{open:e,onOpenChange:t,children:m.jsxs(vF,{size:"sm",className:"max-w-[400px]",children:[m.jsxs(kF,{children:[m.jsx(Rge,{className:"bg-destructive/10",children:m.jsx(Qg,{className:"w-5 h-5 text-destructive"})}),m.jsx(SF,{children:b?"Move to Trash?":"Delete Workspace?"})]}),m.jsx(xF,{children:m.jsx(Qne,{children:b?m.jsxs(m.Fragment,{children:["Are you sure you want to move ",m.jsx("strong",{children:(n==null?void 0:n.title)||(n==null?void 0:n.name)||"this item"})," to trash?",m.jsx("br",{}),"You can restore it later from the trash bin."]}):m.jsxs(m.Fragment,{children:["This will move the workspace and all its contents to trash.",m.jsx("br",{}),"You can restore it later from the trash bin."]})})}),m.jsxs(FF,{children:[m.jsx(ex,{onClick:()=>t(!1),children:"Cancel"}),m.jsx(zN,{onClick:p,children:b?"Move to Trash":"Delete"})]})]})})},Hta=J.memo(({projects:e,view:t,onViewChange:A,onNoteSelect:n,onDrawingSelect:i,onProjectCreate:u,onProjectUpdate:o,onProjectDelete:s,onLogout:l,onWorkspaceFilter:d,selectedWorkspaceUid:h,searchQuery:f,onSearchChange:B,isInstallable:E,onInstall:p,isProjectsLoading:y,user:b,isOnline:v,onOpenFeedback:x,...S})=>{const{state:L,setOpen:N}=LJ(),O=L==="collapsed",M=J.useRef(null),[T,U]=J.useState(null),[P,R]=J.useState(""),[Y,H]=J.useState(null),[j,K]=J.useState(!1),[W,q]=J.useState(""),ee=[{title:"Notes",url:"#",icon:ZI,iconClassName:"text-yellow-400",isActive:t==="notes",onClick:()=>A("notes",!0)},{title:"ERD Builder",url:"#",icon:Z0,iconClassName:"text-blue-400",isActive:t==="erd",onClick:()=>A("erd",!0)},{title:"Flowchart",url:"#",icon:qk,iconClassName:"text-green-400",isActive:t==="flowchart",onClick:()=>A("flowchart",!0)},{title:"Drawings",url:"#",icon:Wk,iconClassName:"text-purple-400",isActive:t==="drawings",onClick:()=>A("drawings",!0)}],V=e.filter(re=>!re.is_deleted),Z=(re,ae)=>{const ne=re??(ae!=null?String(ae):null);A(t,!0,ne)};return m.jsxs(m.Fragment,{children:[m.jsxs(V5n,{collapsible:"icon",...S,children:[m.jsxs(UTi,{children:[m.jsx(Tta,{teams:[{name:"ERD Builder Pro",logo:Z0,plan:"Workspace"}]}),m.jsx(Ict,{className:"py-0 group-data-[collapsible=icon]:hidden",children:m.jsxs(vWt,{className:"relative",children:[m.jsx(X5n,{ref:M,placeholder:"search workspace",className:"pl-8",value:f,onChange:re=>B(re.target.value),disabled:!v}),m.jsx(_D,{className:"pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 select-none text-muted-foreground transition-opacity group-disabled:opacity-50"})]})}),m.jsxs(Ict,{className:"group-data-[collapsible=icon]:p-0",children:[m.jsxs(DWt,{className:"flex items-center justify-between",children:["Features",!v&&m.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-destructive/10 text-[10px] font-bold text-destructive uppercase tracking-wider",children:[m.jsx("span",{className:"w-1 h-1 rounded-full bg-destructive animate-pulse"}),"Offline"]})]}),m.jsx(Sta,{items:ee})]})]}),m.jsx(e6n,{children:m.jsxs(Ict,{className:"px-4 group-data-[collapsible=icon]:p-2",children:[m.jsxs(DWt,{className:"flex items-center justify-between",children:[m.jsx("span",{children:"Workspaces"}),m.jsx(u3,{children:m.jsxs(HB,{children:[m.jsx(YB,{className:"hover:bg-muted hover:text-foreground rounded-md p-0.5 cursor-pointer",onClick:()=>{q(""),K(!0)},children:m.jsx(jC,{className:"h-3.5 w-3.5"})}),m.jsx(PB,{side:"right",children:"Create Workspace"})]})})]}),m.jsx(vWt,{children:m.jsxs(oDe,{children:[m.jsx(Nge,{children:m.jsxs($K,{tooltip:"All Workspaces",isActive:h===null||h==="",onClick:()=>Z(null),children:[m.jsx(SN,{className:"h-4 w-4 shrink-0"}),m.jsx("span",{children:"All Workspaces"})]})}),y?m.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground animate-pulse group-data-[collapsible=icon]:hidden",children:"Loading workspaces..."}):V.length===0?m.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground group-data-[collapsible=icon]:hidden",children:"No workspaces yet"}):V.map(re=>m.jsx(Nge,{children:m.jsxs($K,{tooltip:re.name,isActive:h===re.uid||String(h??"")===String(re.id??""),onClick:()=>Z(re.uid,re.id),children:[m.jsx(SN,{className:"h-4 w-4 shrink-0"}),m.jsx("span",{className:"truncate flex-1 text-left",children:re.name}),m.jsx("span",{onClick:ae=>ae.stopPropagation(),children:m.jsxs(fy,{children:[m.jsx(y3,{nativeButton:!1,render:m.jsx("span",{className:"p-1 rounded hover:bg-accent/50 cursor-pointer inline-flex items-center justify-center",children:m.jsx(ny,{className:"h-3.5 w-3.5"})})}),m.jsxs(b3,{align:"end",children:[m.jsxs(dc,{onClick:()=>{R(re.name),U(re)},children:[m.jsx(M5,{className:"h-3.5 w-3.5 mr-2"}),"Edit"]}),m.jsx(GI,{}),m.jsxs(dc,{onClick:()=>H(re),children:[m.jsx(Qg,{className:"h-3.5 w-3.5 mr-2 text-destructive"}),"Delete"]})]})]})})]})},re.uid??re.id))]})})]})}),m.jsxs(GTi,{children:[E&&m.jsx("div",{className:Xn("px-3 mb-2",O&&"px-0 flex justify-center"),children:m.jsx(u3,{children:m.jsxs(HB,{children:[m.jsxs(YB,{className:Xn("inline-flex items-center justify-center rounded-lg border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 cursor-pointer [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","border-primary/20 bg-primary/5 hover:bg-primary/10 text-primary transition-all duration-300",O?"size-9 p-0 justify-center":"w-full justify-start gap-2 h-9 px-2.5"),onClick:p,children:[m.jsx(Xk.div,{animate:{rotate:[0,15,-15,0]},transition:{duration:2,repeat:1/0},children:m.jsx(Z0,{className:"w-4 h-4"})}),!O&&m.jsx("span",{children:"Install App"})]}),O&&m.jsx(PB,{side:"right",children:"Install App"})]})})}),m.jsx("div",{className:Xn("px-3 mb-2",O&&"px-0 flex justify-center"),children:m.jsx(u3,{children:m.jsxs(HB,{children:[m.jsxs(YB,{className:Xn("inline-flex items-center justify-center rounded-lg border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 cursor-pointer [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","border-red-200 dark:border-red-900/40 bg-red-50 dark:bg-red-950/30 hover:bg-red-100 dark:hover:bg-red-950/50 text-red-700 dark:text-red-400 transition-all duration-300",O?"size-9 p-0 justify-center":"w-full justify-start gap-2 h-9 px-2.5"),onClick:()=>window.open("https://trakteer.id/khadziq_muttaqin/tip","_blank","noopener,noreferrer"),children:[m.jsx(iwe,{className:"w-4 h-4"}),!O&&m.jsx("span",{children:"Sponsor"})]}),O&&m.jsx(PB,{side:"right",children:"Sponsor"})]})})}),m.jsx(Gta,{user:b,onLogout:l,onViewChange:A,isOnline:v,onOpenFeedback:x})]}),m.jsx(MTi,{})]}),m.jsx(Hg,{open:T!==null,onOpenChange:re=>{re||U(null)},children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsx(ah,{children:m.jsx(Yg,{children:"Rename Workspace"})}),m.jsx(G1,{children:m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"rename-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),m.jsx(Wo,{id:"rename-project-input",type:"text",className:"h-10",value:P,onChange:re=>R(re.target.value),onKeyDown:re=>{re.key==="Enter"&&P.trim()&&T&&(o(T.id,P.trim()),U(null))},autoFocus:!0})]})}),m.jsxs(ep,{children:[m.jsx(lht,{render:m.jsx(VA,{variant:"outline",className:"h-9"}),children:"Cancel"}),m.jsx(VA,{className:"h-9 px-6",disabled:!P.trim(),onClick:()=>{T&&P.trim()&&(o(T.id,P.trim()),U(null))},children:"Save Changes"})]})]})}),m.jsx(Hg,{open:j,onOpenChange:K,children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsx(ah,{children:m.jsx(Yg,{children:"Create Workspace"})}),m.jsx(G1,{children:m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"create-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),m.jsx(Wo,{id:"create-project-input",type:"text",className:"h-10",value:W,onChange:re=>q(re.target.value),onKeyDown:re=>{re.key==="Enter"&&W.trim()&&(u(W.trim()),K(!1),q(""))},autoFocus:!0})]})}),m.jsxs(ep,{children:[m.jsx(lht,{render:m.jsx(VA,{variant:"outline",className:"h-9"}),children:"Cancel"}),m.jsx(VA,{className:"h-9 px-6",disabled:!W.trim(),onClick:()=>{W.trim()&&(u(W.trim()),K(!1),q(""))},children:"Create"})]})]})}),m.jsx(cZt,{isOpen:Y!==null,onOpenChange:re=>{re||H(null)},mode:"move-to-trash",view:"project",activeDocument:Y?{id:Y.id,name:Y.name}:void 0,deleteProject:s,onAfterDelete:()=>H(null)})]})}),PC=J.forwardRef(({className:e,...t},A)=>m.jsx("label",{ref:A,"data-slot":"label",className:Xn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t}));PC.displayName="Label";function Yta({isOpen:e,onOpenChange:t,documentType:A,documentUid:n,documentId:i,documentTitle:u,isPublicView:o=!1,initialSettings:s,onSettingsSaved:l}){const[d,h]=Ot.useState((s==null?void 0:s.share_token)||""),[f,B]=Ot.useState(!1),[E,p]=Ot.useState((s==null?void 0:s.is_public)||!1),[y,b]=Ot.useState(""),[v,x]=Ot.useState(!1);Ot.useEffect(()=>{if(s!=null&&s.expiry_date){const U=new Date(s.expiry_date),P=new Date,R=U.getTime()-P.getTime(),Y=Math.ceil(R/(1e3*60*60*24));Y>0&&b(Y.toString())}h((s==null?void 0:s.share_token)||""),p((s==null?void 0:s.is_public)||!1)},[s]);const L={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[A]||A,N=`${window.location.origin}/view/${L}/${n}`,O=()=>{navigator.clipboard.writeText(N),B(!0),gA.success("Link copied to clipboard!"),setTimeout(()=>B(!1),2e3)},M=()=>{const U=Math.random().toString(36).substring(2,10).toUpperCase();h(U),gA.info("Secure token generated")},T=async()=>{x(!0);try{const U=A==="erd"?"diagrams":A==="flowchart"?"flowcharts":A;let P=null;if(y&&!isNaN(parseInt(y))){const Y=new Date;Y.setDate(Y.getDate()+parseInt(y)),P=Y.toISOString()}if(!(await vr(`/api/${U}/${i}/share`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_public:E,share_token:d,expiry_date:P})})).ok)throw new Error("Failed to save settings");gA.success("Sharing settings updated!"),l&&l(),t(!1)}catch(U){gA.error(U.message||"Something went wrong")}finally{x(!1)}};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-md",children:[m.jsxs(ah,{children:[m.jsx(Yg,{children:o?"Share Document":`Share "${u}"`}),m.jsx(ip,{children:o?"Share this link with others to view this document.":E?"Anyone with this link can view this document. No account required.":"This document is currently private. Only you can access it."})]}),m.jsxs(G1,{className:"space-y-4",children:[!o&&m.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30 transition-colors hover:bg-muted/50",children:[m.jsxs("div",{className:"space-y-0.5",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[E?m.jsx(zk,{className:"w-4 h-4 text-primary"}):m.jsx(TD,{className:"w-4 h-4 text-muted-foreground"}),m.jsx(PC,{htmlFor:"public-status",className:"text-sm font-bold",children:"Public Access"})]}),m.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Enable sharing via public link"})]}),m.jsx("input",{id:"public-status",type:"checkbox",checked:E,onChange:U=>p(U.target.checked),className:"w-4 h-4 cursor-pointer accent-primary"})]}),m.jsxs("div",{className:`space-y-4 transition-all duration-300 ${E||o?"opacity-100":"opacity-40 pointer-events-none grayscale-[0.5]"}`,children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx(PC,{htmlFor:"share-link",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Public Link"}),m.jsxs("div",{className:"flex items-center space-x-2",children:[m.jsx(Wo,{id:"share-link",readOnly:!0,value:N,className:"flex-1 bg-muted/20 font-mono text-xs"}),m.jsx(VA,{onClick:O,size:"icon",variant:"outline",className:"shrink-0 cursor-pointer hover:bg-primary/10 hover:text-primary transition-colors",disabled:!E&&!o,children:f?m.jsx(Oh,{className:"w-4 h-4 text-green-500"}):m.jsx(E3,{className:"w-4 h-4"})})]})]}),!o&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"space-y-2 pt-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(PC,{htmlFor:"access-token",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Access Token (Optional)"}),m.jsxs(VA,{variant:"link",size:"sm",onClick:M,className:"h-auto p-0 text-[10px] uppercase font-bold tracking-tighter cursor-pointer text-primary hover:no-underline",disabled:!E,children:[m.jsx(v4,{className:"w-3 h-3 mr-1"}),"Generate"]})]}),m.jsx(Wo,{id:"access-token",placeholder:"Enter or generate a token...",value:d,onChange:U=>h(U.target.value),disabled:!E,className:"font-mono text-xs"})]}),m.jsxs("div",{className:"space-y-2 pt-2",children:[m.jsx(PC,{htmlFor:"valid-until",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Duration (Days)"}),m.jsx(Wo,{id:"valid-until",type:"number",placeholder:"Forever",value:y,onChange:U=>b(U.target.value),disabled:!E,className:"text-xs"})]})]})]})]}),m.jsx(ep,{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:o?m.jsx(VA,{type:"button",onClick:()=>t(!1),className:"cursor-pointer w-full sm:w-auto font-bold",children:"Close"}):m.jsxs(m.Fragment,{children:[m.jsx(VA,{variant:"ghost",onClick:()=>t(!1),className:"cursor-pointer order-2 sm:order-1 font-semibold",disabled:v,children:"Cancel"}),m.jsx(VA,{type:"button",onClick:T,className:"cursor-pointer order-1 sm:order-2 font-bold min-w-[120px]",disabled:v,children:v?m.jsxs(m.Fragment,{children:[m.jsx(v4,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})})]})})}const Pta=({onShare:e,onRename:t,onDelete:A,onDuplicate:n,onExportAll:i,onExportSQL:u,onExportPDF:o,onExportImage:s,onExportMarkdown:l,onCopyMarkdown:d,onImportMarkdown:h,isOnline:f,isPublicView:B=!1,isPublic:E=!1,activeFileUid:p,documentType:y,noteContent:b})=>{const v=N=>N.replace(/<[^>]+>/g,"").replace(/&[^;]+;/g," ").trim(),S=(N=>{const O=N?v(N):"";if(!O)return{words:0,sentences:0,paragraphs:0,characters:0};const M=O.split(/\s+/).filter(Boolean).length,T=O.split(/[.!?]+(?:\s|$)/).filter(R=>R.trim().length>0).length,U=N?(N.match(/<p[^>]*>[\s\S]*?<\/p>/g)||[]).length||O.split(/\n\s*\n/).filter(Boolean).length:O.split(/\n\s*\n/).filter(Boolean).length,P=O.replace(/\s/g,"").length;return{words:M,sentences:T,paragraphs:U,characters:P}})(b),L=()=>{if(!p){gA.error("Document link not available");return}const O={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[y]||y,M=`${window.location.origin}/view/${O}/${p}`;navigator.clipboard.writeText(M),gA.success("Public share link copied to clipboard")};return m.jsx("div",{className:"flex items-center gap-1 sm:gap-2",children:m.jsxs(fy,{children:[m.jsx(y3,{render:m.jsx(VA,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:bg-muted/80 hover:text-foreground hover:shadow-sm active:scale-95 transition-all duration-200",children:m.jsx(ny,{className:"h-4 w-4"})})}),m.jsxs(b3,{align:"end",className:"w-56",children:[B?m.jsxs(dc,{onClick:L,className:"gap-2 cursor-pointer",children:[m.jsx(SAe,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Copy Public Link"})]}):m.jsxs(m.Fragment,{children:[m.jsxs(dc,{disabled:!f,onClick:e,className:"gap-2 cursor-pointer",children:[m.jsx(RAe,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Share"})]}),E&&m.jsxs(dc,{disabled:!f,onClick:L,className:"gap-2 cursor-pointer",children:[m.jsx(SAe,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Copy Public Link"})]}),m.jsx(GI,{}),m.jsxs(dc,{disabled:!f,onClick:t,className:"gap-2 cursor-pointer",children:[y==="erd"?m.jsx(xce,{className:"h-4 w-4 text-muted-foreground"}):m.jsx(bj,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:y==="erd"?"Settings":"Edit Document"})]}),m.jsx(GI,{}),m.jsxs(dc,{disabled:!f,onClick:A,className:"gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer",children:[m.jsx(Qg,{className:"h-4 w-4"}),m.jsx("span",{children:"Move to Trash"})]})]}),(y==="notes"||y==="drawings")&&!B&&m.jsxs(m.Fragment,{children:[m.jsx(GI,{}),m.jsxs(dc,{disabled:!f,onClick:n,className:"gap-2 cursor-pointer",children:[m.jsx(E3,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Duplicate"})]})]}),y==="erd"&&!B&&m.jsxs(m.Fragment,{children:[m.jsx(GI,{}),m.jsxs(dc,{onClick:i,className:"gap-2 cursor-pointer",children:[m.jsx(YQ,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Export All"})]})]}),y==="notes"&&!B&&m.jsxs(m.Fragment,{children:[m.jsx(GI,{}),m.jsx(dc,{disabled:!f,onClick:d,className:"gap-2 cursor-pointer flex items-center",children:m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(E3,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Copy Markdown"})]})}),m.jsxs(dc,{disabled:!f,onClick:h,className:"gap-2 cursor-pointer flex items-center",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(LN,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Import"})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),m.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"I"})]})]}),m.jsxs(dc,{disabled:!f,onClick:l,className:"gap-2 cursor-pointer flex items-center",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(YQ,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Export"})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),m.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"E"})]})]}),m.jsx(GI,{}),m.jsxs(IHi,{children:[m.jsxs(pHi,{className:"gap-2 cursor-pointer",children:[m.jsx(Bj,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Text Stats"})]}),m.jsx(QHi,{className:"w-52 p-1",children:m.jsxs("div",{className:"px-3 py-1.5 space-y-1",children:[m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Words"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.words.toLocaleString()})]}),m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Sentences"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.sentences.toLocaleString()})]}),m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Paragraphs"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.paragraphs.toLocaleString()})]}),m.jsx(GI,{className:"my-1.5"}),m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Characters"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.characters.toLocaleString()})]})]})})]})]})]})]})})},Nvn=J.createContext(void 0);function dDe(e){const t=J.useContext(Nvn);if(t===void 0&&!e)throw new Error(Cc(47));return t}function _ta(){return{...AEt(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const jta={...nEt,disabled:Si(e=>e.disabled),instantType:Si(e=>e.instantType),openMethod:Si(e=>e.openMethod),openChangeReason:Si(e=>e.openChangeReason),modal:Si(e=>e.modal),stickIfOpen:Si(e=>e.stickIfOpen),titleElementId:Si(e=>e.titleElementId),descriptionElementId:Si(e=>e.descriptionElementId),openOnHover:Si(e=>e.openOnHover),closeDelay:Si(e=>e.closeDelay),hasViewport:Si(e=>e.hasViewport)};class baA extends Z6e{constructor(A){const n={..._ta(),...A};n.open&&(A==null?void 0:A.mounted)===void 0&&(n.mounted=!0);super(n,{popupRef:J.createRef(),backdropRef:J.createRef(),internalBackdropRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),stickIfOpenTimeout:new ox,triggerElements:new nhe},jta);ra(this,"setOpen",(A,n)=>{var h,f;const i=n.reason===i2,u=n.reason===JN&&n.event.detail===0,o=!A&&(n.reason===$6e||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},(f=(h=this.context).onOpenChange)==null||f.call(h,A,n),n.isCanceled)return;const s={open:A,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger},l=this.state.floatingRootContext.context.events;l==null||l.emit("openchange",s);const d=()=>{var p;const B={open:A,openChangeReason:n.reason},E=((p=n.trigger)==null?void 0:p.id)??null;(E||A)&&(B.activeTriggerId=E,B.activeTriggerElement=n.trigger??null),this.update(B)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($wn,()=>{this.set("stickIfOpen",!1)}),Ul.flushSync(d)):d(),u||o?this.set("instantType",u?"click":"dismiss"):n.reason===$N?this.set("instantType","focus"):this.set("instantType",void 0)});ra(this,"disposeEffect",()=>this.context.stickIfOpenTimeout.disposeEffect())}static useStore(A,n){const i=XI(()=>new baA(n)).current,u=A??i;return j6e(i.disposeEffect),u}}function _nn({props:e}){const{children:t,open:A,defaultOpen:n=!1,onOpenChange:i,onOpenChangeComplete:u,modal:o=!1,handle:s,triggerId:l,defaultTriggerId:d=null}=e,h=baA.useStore(s==null?void 0:s.store,{modal:o,open:n,openProp:A,activeTriggerId:d,triggerIdProp:l});P6e(()=>{A===void 0&&h.state.open===!1&&n===!0&&h.update({open:!0,activeTriggerId:d})}),h.useControlledProp("openProp",A),h.useControlledProp("triggerIdProp",l);const f=h.useState("open"),B=h.useState("positionerElement"),E=h.useState("payload"),p=h.useState("openChangeReason");h.useContextCallback("onOpenChange",i),h.useContextCallback("onOpenChangeComplete",u);const{openMethod:y,triggerProps:b}=wEt(f);eEt(h);const{forceUnmount:v}=tEt(f,h,()=>{h.update({stickIfOpen:!0,openChangeReason:null})});mEt(f&&o===!0&&p!==i2&&y!=="touch",B),J.useEffect(()=>{f||h.context.stickIfOpenTimeout.clear()},[h,f]);const x=J.useCallback(j=>{const K=Eo(j);return K.preventUnmountOnClose=()=>{h.set("preventUnmountingOnClose",!0)},K},[h]),S=J.useCallback(()=>{h.setOpen(!1,x($Bt))},[h,x]);J.useImperativeHandle(e.actionsRef,()=>({unmount:v,close:S}),[v,S]);const L=rEt({popupStore:h,onOpenChange:h.setOpen}),N=W6e(L,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),O=OrA(L),{getReferenceProps:M,getFloatingProps:T,getTriggerProps:U}=oH([N,O]),P=J.useMemo(()=>M(b),[M,b]),R=J.useMemo(()=>U(b),[U,b]),Y=J.useMemo(()=>T(),[T]);h.useSyncedValues({modal:o,openMethod:y,activeTriggerProps:P,inactiveTriggerProps:R,popupProps:Y,floatingRootContext:L,nested:dM()!=null});const H=J.useMemo(()=>({store:h}),[h]);return m.jsx(Nvn.Provider,{value:H,children:typeof t=="function"?t({payload:E}):t})}function Kta(e){return dDe(!0)?m.jsx(_nn,{props:e}):m.jsx(cyn,{children:m.jsx(_nn,{props:e})})}const Jta=300,$ta=J.forwardRef(function(t,A){const{render:n,className:i,disabled:u=!1,nativeButton:o=!0,handle:s,payload:l,openOnHover:d=!1,delay:h=Jta,closeDelay:f=0,id:B,...E}=t,p=dDe(!0),y=(s==null?void 0:s.store)??(p==null?void 0:p.store);if(!y)throw new Error(Cc(74));const b=R4(B),v=y.useState("isTriggerActive",b),x=y.useState("floatingRootContext"),S=y.useState("isOpenedByTrigger",b),L=J.useRef(null),{registerTrigger:N,isMountedByThisTrigger:O}=XBt(b,L,y,{payload:l,disabled:u,openOnHover:d,closeDelay:f}),M=y.useState("openChangeReason"),T=y.useState("stickIfOpen"),U=y.useState("openMethod"),P=iEt(x,{enabled:x!=null&&d&&(U!=="touch"||M!==JN),mouseOnly:!0,move:!1,handleClose:uEt(),restMs:h,delay:{close:f},triggerElementRef:L,isActiveTrigger:v}),R=q6e(x,{enabled:x!=null,stickIfOpen:T}),Y=oH([R]),H=y.useState("triggerProps",O),j={disabled:u,open:S},{getButtonProps:K,buttonRef:W}=iS({disabled:u,native:o}),q=J.useMemo(()=>({open(ae){return ae&&M===JN?Xdt.open(ae):V6e.open(ae)}}),[M]),ee=go("button",t,{state:j,ref:[W,A,N,L],props:[Y.getReferenceProps(),P,H,{[orA]:"",id:b},E,K],stateAttributesMapping:q}),V=J.useRef(null),Z=la(ae=>{Ul.flushSync(()=>{y.setOpen(!1,Eo($N,ae.nativeEvent,ae.currentTarget))});const ne=Kwn(V.current);ne==null||ne.focus()}),re=la(ae=>{var ge;const ne=y.select("positionerElement");if(ne&&kAe(ae,ne))(ge=y.context.beforeContentFocusGuardRef.current)==null||ge.focus();else{Ul.flushSync(()=>{y.setOpen(!1,Eo($N,ae.nativeEvent,ae.currentTarget))});let le=jwn(y.context.triggerFocusTargetRef.current||L.current);for(;le!==null&&ls(ne,le);){const Ce=le;if(le=KBt(le),le===Ce)break}le==null||le.focus()}});return v?m.jsxs(J.Fragment,{children:[m.jsx(jK,{ref:V,onFocus:Z}),m.jsx(J.Fragment,{children:ee},b),m.jsx(jK,{ref:y.context.triggerFocusTargetRef,onFocus:re})]}):m.jsx(J.Fragment,{children:ee},b)}),Mvn=J.createContext(void 0);function zta(){const e=J.useContext(Mvn);if(e===void 0)throw new Error(Cc(45));return e}const qta=J.forwardRef(function(t,A){const{keepMounted:n=!1,...i}=t,{store:u}=dDe();return u.useState("mounted")||n?m.jsx(Mvn.Provider,{value:n,children:m.jsx(zBt,{ref:A,...i})}):null}),Rvn=J.createContext(void 0);function Wta(){const e=J.useContext(Rvn);if(!e)throw new Error(Cc(46));return e}const Zta=J.forwardRef(function(t,A){const{render:n,className:i,anchor:u,positionMethod:o="absolute",side:s="bottom",align:l="center",sideOffset:d=0,alignOffset:h=0,collisionBoundary:f="clipping-ancestors",collisionPadding:B=5,arrowPadding:E=5,sticky:p=!1,disableAnchorTracking:y=!1,collisionAvoidance:b=srA,...v}=t,{store:x}=dDe(),S=zta(),L=drA(),N=x.useState("floatingRootContext"),O=x.useState("mounted"),M=x.useState("open"),T=x.useState("openChangeReason"),U=x.useState("activeTriggerElement"),P=x.useState("modal"),R=x.useState("positionerElement"),Y=x.useState("instantType"),H=x.useState("transitionStatus"),j=x.useState("hasViewport"),K=J.useRef(null),W=VBt(R,!1,!1),q=oEt({anchor:u,floatingRootContext:N,positionMethod:o,mounted:O,side:s,sideOffset:d,align:l,alignOffset:h,arrowPadding:E,collisionBoundary:f,collisionPadding:B,sticky:p,disableAnchorTracking:y,keepMounted:S,nodeId:L,collisionAvoidance:b,adaptiveOrigin:j?MrA:void 0}),ee=J.useMemo(()=>{const ge={};return M||(ge.pointerEvents="none"),{role:"presentation",hidden:!O,style:{...q.positionerStyles,...ge}}},[M,O,q.positionerStyles]),V=J.useMemo(()=>({props:ee,...q}),[ee,q]),Z=N.useState("domReferenceElement");Li(()=>{const ge=Z,le=K.current;if(ge&&(K.current=ge),le&&ge&&ge!==le){x.set("instantType",void 0);const Ce=new AbortController;return W(()=>{x.set("instantType","trigger-change")},Ce.signal),()=>{Ce.abort()}}},[Z,W,x]);const re={open:M,side:V.side,align:V.align,anchorHidden:V.anchorHidden,instant:Y},ae=J.useCallback(ge=>{x.set("positionerElement",ge)},[x]),ne=go("div",t,{state:re,props:[V.props,xJ(H),v],ref:[A,ae],stateAttributesMapping:rS});return m.jsxs(Rvn.Provider,{value:V,children:[O&&P===!0&&T!==i2&&m.jsx(QEt,{ref:x.context.internalBackdropRef,inert:X6e(!M),cutout:U}),m.jsx(lyn,{id:L,children:ne})]})}),Vta=J.createContext(void 0);function Xta(){const[e,t]=J.useState(0),A=la(()=>(t(i=>i+1),()=>{t(i=>Math.max(0,i-1))}));return{context:J.useMemo(()=>({register:A}),[A]),hasClosePart:e>0}}function eAa(e){const{value:t,children:A}=e;return m.jsx(Vta.Provider,{value:t,children:A})}const tAa={...rS,...wx},AAa=J.forwardRef(function(t,A){const{className:n,render:i,initialFocus:u,finalFocus:o,...s}=t,{store:l}=dDe(),d=Wta(),h=OiA()!=null,{context:f,hasClosePart:B}=Xta(),E=l.useState("open"),p=l.useState("openMethod"),y=l.useState("instantType"),b=l.useState("transitionStatus"),v=l.useState("popupProps"),x=l.useState("titleElementId"),S=l.useState("descriptionElementId"),L=l.useState("modal"),N=l.useState("mounted"),O=l.useState("openChangeReason"),M=l.useState("activeTriggerElement"),T=l.useState("floatingRootContext");a9({open:E,ref:l.context.popupRef,onComplete(){var ee,V;E&&((V=(ee=l.context).onOpenChangeComplete)==null||V.call(ee,!0))}});const U=l.useState("disabled"),P=l.useState("openOnHover"),R=l.useState("closeDelay");LrA(T,{enabled:P&&!U,closeDelay:R});function Y(ee){return ee==="touch"?l.context.popupRef.current:!0}const H=u===void 0?Y:u,j={open:E,side:d.side,align:d.align,instant:y,transitionStatus:b},K=L!==!1&&B,W=J.useCallback(ee=>{l.set("popupElement",ee)},[l]),q=go("div",t,{state:j,ref:[A,l.context.popupRef,W],props:[v,{"aria-labelledby":x,"aria-describedby":S,onKeyDown(ee){h&&pEt.has(ee.key)&&ee.stopPropagation()}},xJ(b),s],stateAttributesMapping:tAa});return m.jsx(qBt,{context:T,openInteractionType:p,modal:K,disabled:!N||O===i2,initialFocus:H,returnFocus:o,restoreFocus:"popup",previousFocusableElement:HC(M)?M:void 0,nextFocusableElement:l.context.triggerFocusTargetRef,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:m.jsx(eAa,{value:f,children:q})})});function Uvn({...e}){return m.jsx(Kta,{"data-slot":"popover",...e})}function Gvn({...e}){return m.jsx($ta,{"data-slot":"popover-trigger",...e})}function nAa({...e}){return m.jsx(qta,{"data-slot":"popover-portal",...e})}function Tvn({className:e,align:t="center",side:A="bottom",sideOffset:n=4,...i}){return m.jsx(nAa,{children:m.jsx(Zta,{align:t,side:A,sideOffset:n,children:m.jsx(AAa,{"data-slot":"popover-content",className:Xn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...i})})})}const rAa={note:{icon:ZI,label:"Notes"},diagram:{icon:Z0,label:"ERD"},flowchart:{icon:qk,label:"Flowchart"},drawing:{icon:Wk,label:"Drawing"}};function iAa(){const{notes:e,diagrams:t,flowcharts:A,drawings:n,activeDocument:i,handleNoteSelect:u,handleDiagramSelect:o,handleDrawingSelect:s,handleFlowchartSelect:l}=qB(),d=(i==null?void 0:i.project_id)??null,[h,f]=J.useState(!1),[B,E]=J.useState(""),p=J.useRef(null),[y,b]=J.useState(0),v=J.useMemo(()=>{if(!d)return[];const O=[],M=d,T=(e??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.title||"Untitled",type:"note"}));T.length&&O.push({label:"Notes",items:T});const U=(t??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.name||"Untitled",type:"diagram"}));U.length&&O.push({label:"ERD",items:U});const P=(A??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.title||"Untitled",type:"flowchart"}));P.length&&O.push({label:"Flowcharts",items:P});const R=(n??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.title||"Untitled",type:"drawing"}));return R.length&&O.push({label:"Drawings",items:R}),O},[e,t,A,n,d]),x=J.useMemo(()=>{if(!B.trim())return v;const O=B.toLowerCase();return v.map(M=>({...M,items:M.items.filter(T=>T.name.toLowerCase().includes(O))})).filter(M=>M.items.length>0)},[v,B]),S=J.useMemo(()=>x.flatMap(O=>O.items),[x]);J.useEffect(()=>{b(0)},[B]),J.useEffect(()=>{h&&setTimeout(()=>{var O;return(O=p.current)==null?void 0:O.focus()},50)},[h]),J.useEffect(()=>{const O=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&!M.shiftKey&&(M.preventDefault(),f(T=>!T))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[]);const L=J.useCallback(O=>{switch(f(!1),E(""),O.type){case"note":u(O.uid);break;case"diagram":o(O.id);break;case"flowchart":l(O.uid);break;case"drawing":s(O.uid);break}},[u,o,l,s]);if(!d)return null;const N=O=>{O.key==="ArrowDown"?(O.preventDefault(),b(M=>Math.min(M+1,S.length-1))):O.key==="ArrowUp"?(O.preventDefault(),b(M=>Math.max(M-1,0))):O.key==="Enter"&&S[y]&&(O.preventDefault(),L(S[y]))};return m.jsxs(Uvn,{open:h,onOpenChange:f,children:[m.jsx(Gvn,{render:m.jsxs("button",{className:"hidden md:flex items-center gap-2 h-8 px-3 rounded-lg border border-border/50 bg-muted/30 hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors text-xs min-w-[180px] max-w-[260px]",children:[m.jsx(_D,{className:"w-3.5 h-3.5 shrink-0"}),m.jsx("span",{className:"flex-1 text-left truncate",children:"Quick jump to file..."}),m.jsxs("kbd",{className:"pointer-events-none inline-flex h-4 select-none items-center gap-0.5 rounded border bg-background px-1 font-mono text-[9px] font-medium text-muted-foreground shrink-0",children:[m.jsx("span",{className:"text-[10px]",children:"⌘"}),"K"]})]})}),m.jsxs(Tvn,{align:"center",sideOffset:8,className:"w-[360px] p-0 bg-popover border border-border shadow-xl z-[10000]",children:[m.jsxs("div",{className:"flex items-center gap-2 px-3 border-b border-border",children:[m.jsx(_D,{className:"w-4 h-4 shrink-0 text-muted-foreground"}),m.jsx(Wo,{ref:p,value:B,onChange:O=>E(O.target.value),onKeyDown:N,placeholder:"Search files...",className:"h-10 border-0 bg-transparent px-0 text-sm focus-visible:ring-0 focus-visible:ring-offset-0 placeholder:text-muted-foreground/50"})]}),m.jsx("div",{className:"max-h-[320px] overflow-y-auto py-1",children:x.length===0?m.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No files found"}):x.map(O=>{var U;const M=((U=rAa[O.items[0].type])==null?void 0:U.icon)??ZI,T=O.items[0].type==="diagram"?"text-emerald-400":O.items[0].type==="flowchart"?"text-sky-400":O.items[0].type==="drawing"?"text-purple-400":"text-amber-400";return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:[m.jsx(M,{className:`w-3 h-3 ${T}`}),O.label]}),O.items.map((P,R)=>{const Y=x.slice(0,x.indexOf(O)).reduce((j,K)=>j+K.items.length,0)+R,H=Y===y;return m.jsxs("button",{onClick:()=>L(P),onMouseEnter:()=>b(Y),className:`flex items-center gap-2 w-full px-3 py-2 text-sm text-left transition-colors ${H?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"}`,children:[m.jsx(M,{className:`w-4 h-4 shrink-0 ${T}`}),m.jsx("span",{className:"flex-1 truncate",children:P.name}),m.jsx(lT,{className:`w-3 h-3 shrink-0 transition-opacity ${H?"opacity-60":"opacity-0"}`})]},`${P.type}-${P.uid}`)})]},O.label)})})]})]})}const aAa=Ot.memo(({featureLabel:e,activeProjectName:t,activeFileName:A,view:n,hasActiveItem:i,syncError:u,isSyncing:o,isRefreshing:s,isLocalSaving:l=!1,hasPendingSyncs:d,activeFileUid:h,activeFileId:f,initialShareSettings:B,onSettingsSaved:E,isPublicView:p=!1,isOnline:y,updatedAt:b,onDelete:v,onRename:x,onSave:S,onExportAll:L,onExportSQL:N,onExportPDF:O,onExportImage:M,onExportMarkdown:T,onCopyMarkdown:U,onImportMarkdown:P,onDuplicate:R,isGuest:Y=!1,fileSearchRef:H,fileSearchQuery:j="",onFileSearchChange:K,hideFileSearch:W,breadcrumbLabel:q,noteContent:ee})=>{const V=d2(),[Z,re]=Ot.useState(!1),[ae,ne]=Ot.useState(!1),ge=V.pathname.startsWith("/table/");return Ot.useEffect(()=>{ne(window.navigator.userAgent.toLowerCase().includes("mac"))},[]),m.jsxs("header",{className:"flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-[[data-collapsible=icon]]/sidebar-wrapper:h-12 w-full overflow-hidden border-b bg-background/50 backdrop-blur-sm",children:[m.jsxs("div",{className:"flex items-center gap-2 px-4 min-w-0 flex-none",children:[!p&&m.jsxs(m.Fragment,{children:[m.jsx(NTi,{className:"-ml-1 shrink-0"}),m.jsx(j5n,{orientation:"vertical",className:"h-4 shrink-0 bg-border/50"})]}),m.jsx(A6n,{className:"min-w-0 flex items-center",children:m.jsx(n6n,{className:"flex-nowrap items-center",children:!p&&(()=>{var Ce;const le=V.pathname;if(le==="/")return m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-semibold text-foreground",children:"Dashboard"})});if(le.startsWith("/table/")){const fe={notes:"Notes",erd:"ERD Builder",drawings:"Drawings",flowchart:"Flowcharts"},we=(Ce=le.match(/^\/table\/([^/]+)$/))==null?void 0:Ce[1],me=we?fe[we]||we:"Unknown";return m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-foreground",children:me})})}if(le.startsWith("/notes/")||le.startsWith("/diagrams/")||le.startsWith("/drawings/")||le.startsWith("/flowcharts/")){const fe={notes:{label:"Notes",href:"/table/notes"},diagrams:{label:"ERD Builder",href:"/table/erd"},drawings:{label:"Drawings",href:"/table/drawings"},flowcharts:{label:"Flowcharts",href:"/table/flowchart"}},we=le.split("/")[1],me=fe[we];return m.jsxs(m.Fragment,{children:[me&&m.jsxs(m.Fragment,{children:[m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-muted-foreground",children:me.label})}),t&&m.jsx(kWt,{className:"shrink-0"})]}),t&&m.jsxs(m.Fragment,{children:[m.jsx(j8,{className:"min-w-0 shrink",children:m.jsx(GO,{className:"max-w-[80px] sm:max-w-[150px] md:max-w-[250px] truncate text-muted-foreground",children:t})}),A&&m.jsx(kWt,{className:"shrink-0"})]}),A&&m.jsxs(j8,{className:"min-w-0 shrink flex items-center gap-2",children:[m.jsx(GO,{className:"max-w-[120px] sm:max-w-[200px] md:max-w-[300px] truncate font-semibold text-foreground",children:A}),(B==null?void 0:B.is_public)&&!p&&m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs(Lf,{variant:"outline",className:"h-5 px-1.5 gap-1.5 bg-green-500/5 text-green-500 border-green-500/20 rounded-full hover:bg-green-500/10 cursor-help shadow-sm",children:[m.jsx(zk,{className:"w-2.5 h-2.5"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Public"}),m.jsx("div",{className:"w-1 h-1 rounded-full bg-green-500 animate-pulse ml-0.5"})]})}),m.jsx(PB,{side:"bottom",align:"center",className:"text-[10px] font-medium",children:"This document is shared publicly via a secret link."})]})})]}),!A&&!t&&m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-foreground",children:(me==null?void 0:me.label)||"Document"})})]})}return le.startsWith("/trash")?m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-foreground",children:"Trash"})}):q?m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-semibold text-foreground",children:q})}):m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-muted-foreground",children:e})})})()})})]}),m.jsx("div",{className:"flex-1 flex items-center justify-center px-2",children:!y&&!p?m.jsxs("div",{className:"hidden md:flex items-center gap-2 px-3 py-1 rounded-full bg-destructive/10 border border-destructive/20 text-destructive animate-in fade-in slide-in-from-top-1 duration-500",children:[m.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-destructive animate-pulse"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",children:"Offline Mode: Navigation Disabled"})]}):null}),m.jsxs("div",{className:"px-2 sm:px-4 flex items-center gap-1 sm:gap-4",children:[V.pathname!=="/"&&m.jsx(iAa,{}),!p&&ge&&!W&&m.jsxs("div",{className:"relative flex items-center mr-1 sm:mr-2",children:[m.jsx(_D,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground"}),m.jsx(Wo,{ref:H,type:"text",placeholder:"Search files...",value:j,onChange:le=>K==null?void 0:K(le.target.value),className:"h-8 w-[120px] sm:w-[180px] md:w-[220px] pl-8 pr-8 text-xs"}),m.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none flex items-center gap-0.5 opacity-40",children:m.jsxs("kbd",{className:"pointer-events-none inline-flex h-4 select-none items-center gap-0.5 rounded border bg-muted px-1 font-mono text-[9px] font-medium text-muted-foreground",children:[m.jsx("span",{className:"text-[10px]",children:ae?"⌘":"Ctrl"}),"K"]})})]}),!!V.pathname.match(/^\/(notes|diagrams|drawings|flowcharts)\/[^/]+$/)&&m.jsxs("div",{className:"flex items-center gap-1 sm:gap-4",children:[!p&&m.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 shrink-0",children:[l?m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-amber-500/10 sm:border sm:border-amber-500/20 text-amber-500 sm:shadow-sm transition-all duration-300",children:[m.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Saving..."})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium",children:"Saving changes locally..."})]})}):u?m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-destructive/10 sm:border sm:border-destructive/20 text-destructive cursor-help sm:shadow-sm transition-all duration-300",children:[m.jsx($3e,{className:"w-3.5 h-3.5"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Sync Failed"})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium max-w-[200px] text-center",children:"Changes saved locally, but cloud sync failed. We'll retry automatically."})]})}):o?m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-primary/10 sm:border sm:border-primary/20 text-primary sm:shadow-sm transition-all duration-300",children:[m.jsx(BK,{className:"w-3.5 h-3.5 animate-bounce"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Syncing..."})]}):d?m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs(VA,{variant:"ghost",size:"sm",onClick:S,disabled:!y,className:"h-6 sm:h-7 px-1 sm:px-2 gap-1 sm:gap-2 bg-primary/10 text-primary hover:bg-primary/20 hover:text-primary-foreground border border-primary/20 transition-all duration-300 sm:shadow-sm",children:[m.jsx(gT,{className:"w-3.5 h-3.5 animate-in zoom-in-50"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Save"})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium",children:m.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[m.jsx("span",{children:"Save changes to cloud"}),m.jsxs("span",{className:"opacity-50 text-[9px]",children:[ae?"⌘":"Ctrl"," + S"]})]})})]})}):m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-green-500/5 sm:border sm:border-green-500/10 text-green-500/60 sm:shadow-sm transition-all duration-300",children:[m.jsx(Oh,{className:"w-3.5 h-3.5"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Synced"})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium",children:"All changes are saved and synced"})]})}),s&&m.jsx("div",{className:"flex items-center gap-2 text-primary animate-pulse ml-1 sm:ml-2",children:m.jsx("div",{className:"w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin"})})]}),!p&&b&&m.jsx(u3,{delay:200,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"hidden lg:flex items-center gap-1.5 text-[11px] text-muted-foreground font-medium cursor-help hover:text-foreground transition-colors",children:[m.jsx("span",{className:"opacity-50",children:"Edited"}),m.jsx("span",{children:Nk(new Date(b),"MMM dd")})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] py-1 px-2 font-mono",children:Nk(new Date(b),"eee, dd MMM yyyy HH:mm:ss")})]})}),m.jsx(Pta,{onShare:()=>y&&re(!0),onDelete:v,onRename:x,onDuplicate:R,onExportAll:L,onExportSQL:N,onExportPDF:O,onExportImage:M,onExportMarkdown:T,onCopyMarkdown:U,onImportMarkdown:P,isOnline:y,isPublicView:p,isPublic:B==null?void 0:B.is_public,activeFileUid:h,documentType:n,noteContent:ee}),h&&f&&y&&m.jsx(Yta,{isOpen:Z,onOpenChange:re,documentType:n,documentUid:h,documentId:f,documentTitle:A||"Untitled",isPublicView:p,initialSettings:B,onSettingsSaved:E})]})]})]})});function uAa({open:e,onOpenChange:t}){const[A,n]=Ot.useState(!1),[i,u]=Ot.useState(""),[o,s]=Ot.useState("suggestion"),[l,d]=Ot.useState(""),h=async f=>{if(f.preventDefault(),!!i.trim()){n(!0);try{if((await vr("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,category:o,email:l,url:window.location.href,browser:navigator.userAgent})})).ok)gA.success("Feedback terkirim! Terima kasih masukannya."),t(!1),u("");else throw new Error}catch{gA.error("Gagal mengirim feedback. Coba lagi nanti.")}finally{n(!1)}}};return m.jsx(Hg,{open:e,onOpenChange:f=>{t(f),f||u("")},children:m.jsx(mg,{className:"sm:max-w-[425px] border-border bg-popover/95 backdrop-blur-xl shadow-2xl",children:m.jsxs("form",{onSubmit:h,className:"flex flex-col max-h-[inherit]",children:[m.jsxs(ah,{children:[m.jsx(Yg,{className:"text-xl font-bold",children:"Kirim Masukan"}),m.jsx(ip,{className:"text-sm text-muted-foreground",children:"Bantu kami membuat ERD Builder Pro jadi lebih baik. Saran Anda sangat berharga!"})]}),m.jsxs(G1,{className:"space-y-5",children:[m.jsxs("div",{className:"grid gap-2",children:[m.jsx(PC,{htmlFor:"category",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Tipe Masukan"}),m.jsxs(KB,{value:o,onValueChange:f=>f&&s(f),children:[m.jsx(_f,{id:"category",className:"bg-white/5 border-white/10 focus:ring-primary/50",children:m.jsx(JB,{placeholder:"Pilih tipe",children:o==="suggestion"?"Saran Fitur":o==="bug"?"Lapor Bug":o==="other"?"Kritik / Lainnya":o})}),m.jsxs($B,{className:"bg-popover border-border text-popover-foreground",children:[m.jsx(e0,{value:"suggestion",className:"focus:bg-muted",children:"Saran Fitur"}),m.jsx(e0,{value:"bug",className:"focus:bg-muted text-destructive",children:"Lapor Bug"}),m.jsx(e0,{value:"other",className:"focus:bg-muted",children:"Kritik / Lainnya"})]})]})]}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx(PC,{htmlFor:"content",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Pesan"}),m.jsx("textarea",{id:"content",autoComplete:"off",className:"flex min-h-[140px] w-full rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm ring-offset-background placeholder:text-muted-foreground/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-all resize-none",placeholder:"Tuliskan masukan Anda di sini...",value:i,onChange:f=>u(f.target.value),required:!0})]}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx(PC,{htmlFor:"email",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email (Opsional)"}),m.jsx(Wo,{id:"email",type:"email",autoComplete:"off",placeholder:"email@contoh.com",className:"bg-muted/50 border-border focus:ring-primary/50 h-10 px-4",value:l,onChange:f=>d(f.target.value)})]})]}),m.jsxs(ep,{className:"gap-3",children:[m.jsx(VA,{variant:"ghost",type:"button",onClick:()=>t(!1),className:"hover:bg-muted",children:"Batal"}),m.jsx(VA,{type:"submit",disabled:A,className:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-lg shadow-primary/20",children:A?"Mengirim...":"Kirim Masukan"})]})]})})})}const oAa=({isOpen:e,onOpenChange:t,selectedEntity:A,deleteEntity:n,setSelectedNodeId:i})=>m.jsx(DF,{open:e,onOpenChange:t,children:m.jsxs(vF,{size:"sm",className:"max-w-[400px]",children:[m.jsxs(kF,{children:[m.jsx(Rge,{className:"bg-destructive/10",children:m.jsx(p4,{className:"w-5 h-5 text-destructive"})}),m.jsx(SF,{children:"Delete Table"})]}),m.jsx(xF,{children:m.jsxs(Qne,{children:["Are you sure you want to delete the table ",m.jsx("strong",{children:A==null?void 0:A.name}),"? This action cannot be undone."]})}),m.jsxs(FF,{children:[m.jsx(ex,{onClick:()=>t(!1),children:"Cancel"}),m.jsx(zN,{onClick:()=>{A&&(n(A.id),i(null),t(!1))},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),xHt=e=>e==="erd"?"diagram":e==="notes"?"note":e==="drawings"?"drawing":"flowchart",jnn=({isOpen:e,onOpenChange:t,mode:A="edit",view:n,activeDocument:i,newName:u,setNewName:o,projects:s,selectedProjectId:l,setSelectedProjectId:d,onCreate:h,updateDiagram:f,updateNote:B,updateDrawing:E,updateFlowchart:p,onMoveDiagramToProject:y,onMoveNoteToProject:b,onMoveDrawingToProject:v,onMoveFlowchartToProject:x,onRenameSuccess:S})=>{var O;const L=A==="create";J.useEffect(()=>{if(e&&!L&&i){const M=(i==null?void 0:i.project_id)??(i==null?void 0:i.projectId);d(M!=null?String(M):"none")}},[e]);const N=async()=>{if(!u.trim())return;if(L){h==null||h(u.trim(),l==="none"?null:l),t(!1);return}const M=n==="notes"||n==="flowchart"||n==="drawings"?i==null?void 0:i.uid:i==null?void 0:i.id;if(M&&u.trim()){const T=l==="none"?null:l,U=(i==null?void 0:i.project_id)||(i==null?void 0:i.projectId),P=u.trim()!==((i==null?void 0:i.title)||(i==null?void 0:i.name)),R=String(T)!==String(U);try{P&&(n==="erd"?await(f==null?void 0:f(M,u,{silent:!0})):n==="notes"?await(B==null?void 0:B(String(M),u,{silent:!0})):n==="drawings"?await(E==null?void 0:E(M,u,{silent:!0})):n==="flowchart"&&await(p==null?void 0:p(M,u,{silent:!0}))),R&&(n==="erd"?await(y==null?void 0:y(M,T,{silent:!0})):n==="notes"?await(b==null?void 0:b(M,T,{silent:!0})):n==="drawings"?await(v==null?void 0:v(M,T,{silent:!0})):n==="flowchart"&&await(x==null?void 0:x(M,T,{silent:!0}))),(P||R)&&S&&await S(),gA.success("Document updated successfully"),t(!1)}catch{gA.error("Failed to update document")}}};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsxs(ah,{children:[m.jsx(Yg,{children:L?`Create ${xHt(n)}`:"Edit Document"}),m.jsx(ip,{children:L?`Enter a name and select a workspace for your new ${xHt(n)}.`:`Update the name and project for your ${xHt(n)}.`})]}),m.jsx(G1,{children:m.jsxs("div",{className:"space-y-4",children:[m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"rename-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:L?"Name":"New Name"}),m.jsx(Wo,{id:"rename-input",type:"text",value:u,onChange:M=>o(M.target.value),onKeyDown:M=>{M.key==="Enter"&&u.trim()&&N()},autoFocus:!0})]}),m.jsxs(Ac,{children:[m.jsx(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Project"}),m.jsxs(KB,{value:l,onValueChange:M=>M!==null&&d(M),children:[m.jsx(_f,{className:"h-9",children:m.jsx(JB,{children:l==="none"?"Uncategorized":((O=s.find(M=>M.id.toString()===l))==null?void 0:O.name)||"Select Project"})}),m.jsxs($B,{children:[m.jsx(e0,{value:"none",children:"Uncategorized"}),s.map(M=>m.jsx(e0,{value:M.id.toString(),children:M.name},M.id))]})]})]})]})}),m.jsxs(ep,{children:[m.jsx(lht,{render:m.jsx(VA,{variant:"outline",className:"h-9"}),children:"Cancel"}),m.jsx(VA,{disabled:!u.trim(),onClick:N,className:"h-9 px-6",children:L?"Create":"Save Changes"})]})]})})},sAa=({isOpen:e,onOpenChange:t,view:A,duplicateName:n,setDuplicateName:i,executeDuplicate:u,isRefreshing:o})=>m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsxs(ah,{children:[m.jsx(Yg,{children:"Duplicate Document"}),m.jsxs(ip,{children:["Create a copy of this ",A==="erd"?"diagram":A==="notes"?"note":A==="drawings"?"drawing":"flowchart","."]})]}),m.jsx(G1,{children:m.jsx("div",{className:"space-y-4",children:m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"duplicate-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"New Name"}),m.jsx(Wo,{id:"duplicate-input",type:"text",value:n,onChange:s=>i(s.target.value),onKeyDown:s=>{s.key==="Enter"&&n.trim()&&u()},autoFocus:!0})]})})}),m.jsxs(ep,{className:"gap-2 sm:gap-0",children:[m.jsx(VA,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),m.jsx(VA,{onClick:u,disabled:!n.trim()||o,children:o?m.jsxs(m.Fragment,{children:[m.jsx(js,{className:"mr-2 h-4 w-4 animate-spin"}),"Duplicating..."]}):"Duplicate"})]})]})});function Mk(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var FHt={exports:{}};/*!
|
|
8615
|
+
`);ae=le.pop()||"";for(const Ce of le)if(Ce.trim())try{const fe=JSON.parse(Ce);if(fe.type==="progress")x({current:Number(fe.current)||0,total:Number(fe.total)||5,phase:String(fe.phase||"")});else if(fe.type==="complete"){o("done"),gA.success(fe.message||"Database restored successfully!"),A.current=null;return}else if(fe.type==="error")throw new Error(fe.error||"Restore failed on server.")}catch(fe){if(fe instanceof SyntaxError)continue;throw fe}}throw new Error("Stream ended unexpectedly. Restore may be incomplete.")}catch(q){if(q.name==="AbortError")return;o("error"),b(q.message||"Restore failed"),gA.error("Restore failed: "+(q.message||"Unknown error"))}A.current=null}},[]),M=J.useCallback(()=>{t.current&&(clearTimeout(t.current),t.current=null),n.current=null,i.current=null,o("idle"),l(null),p(null),h(null),B(null),b(""),x({current:0,total:1,phase:""})},[]),T=J.useCallback(()=>{n.current=null,i.current=null,h(null),B(null),o("idle"),l(null)},[]),U=J.useCallback(()=>{t.current&&(clearTimeout(t.current),t.current=null),window.location.reload()},[]),P=J.useCallback(()=>{A.current&&(A.current.abort(),A.current=null),n.current=null,i.current=null,o("idle"),l(null),x({current:0,total:1,phase:""})},[]),R=J.useCallback(()=>{s==="db"?O():N()},[s,O,N]),Y=Math.min(Math.round(v.current/v.total*100),100),{accept:H,acceptLabel:j}=S==="desktop"?{accept:".json,.db,.sqlite,.sqlite3",acceptLabel:".json (data) or .db / .sqlite (database restore)"}:{accept:".json",acceptLabel:".json format from Guest Mode export"};if(u==="done")return m.jsxs("div",{className:"space-y-6",children:[m.jsxs("div",{className:"flex items-center gap-3 p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl",children:[m.jsx(bG,{className:"size-6 text-emerald-500 shrink-0"}),m.jsxs("div",{children:[m.jsx("h4",{className:"font-semibold text-sm",children:s==="db"?"Database Restored":"Import Completed"}),m.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:s==="db"?"The database file has been restored. The app will reload to apply the changes.":"Data has been added to your workspace."})]})]}),E&&m.jsx(Ynn,{summary:E}),m.jsxs("div",{className:"flex gap-3",children:[m.jsxs(VA,{variant:"default",size:"sm",onClick:U,children:[m.jsx(v4,{className:"size-3.5 mr-1.5"}),"Reload App Now"]}),m.jsx(VA,{variant:"outline",size:"sm",onClick:M,children:"Import Another File"})]}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"App will reload automatically in a few seconds…"})]});if(u==="preview"){if(s==="db"&&f)return m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[m.jsx(q3e,{className:"size-5 text-blue-500 shrink-0"}),m.jsxs("div",{children:[m.jsx("h4",{className:"font-semibold text-sm",children:"Restore Database File"}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["This will ",m.jsx("strong",{className:"text-amber-500",children:"replace"})," your current local database with the selected file. A safety backup will be created automatically before the restore."]}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Use this if you reinstalled the app and want to restore from a previous",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px] mx-0.5",children:".db"})," file that you saved manually."]})]})]}),m.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-4 space-y-2",children:[m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:"File"}),m.jsx("span",{className:"font-medium",children:f.fileName})]}),m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:"Size"}),m.jsx("span",{className:"font-medium",children:f.fileSize})]})]}),m.jsxs("div",{className:"flex gap-3 pt-2",children:[m.jsxs(VA,{variant:"default",size:"sm",onClick:R,children:[m.jsx(lT,{className:"size-3.5 mr-1.5"}),"Restore Database"]}),m.jsxs(VA,{variant:"outline",size:"sm",onClick:T,children:[m.jsx(Zk,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]});if(s==="json"&&d){const K=Object.values(d).reduce((W,q)=>W+(q||0),0);return m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[m.jsx(hce,{className:"size-5 text-blue-500 shrink-0"}),m.jsxs("div",{children:[m.jsx("h4",{className:"font-semibold text-sm",children:"Import Preview"}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[K," items found in the export file. Click ",m.jsx("strong",{children:"Submit"})," to import the data."]})]})]}),m.jsx(Ynn,{summary:d}),m.jsxs("div",{className:"flex gap-3 pt-2",children:[m.jsxs(VA,{variant:"default",size:"sm",onClick:R,children:[m.jsx(lT,{className:"size-3.5 mr-1.5"}),"Submit"]}),m.jsxs(VA,{variant:"outline",size:"sm",onClick:T,children:[m.jsx(Zk,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]})}}return u==="error"?m.jsx("div",{className:"space-y-5",children:m.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:[m.jsx(ND,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),m.jsxs("div",{className:"text-xs text-red-600",children:[m.jsx("p",{className:"font-medium",children:s==="db"?"Database restore failed":"Import failed"}),m.jsx("p",{className:"mt-0.5",children:y}),m.jsx(VA,{variant:"ghost",size:"sm",className:"mt-2 h-auto py-1 text-xs",onClick:M,children:"Try again"})]})]})}):m.jsxs("div",{className:"space-y-5",children:[m.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[m.jsx(Ok,{className:"size-5 text-blue-500 shrink-0 mt-0.5"}),m.jsxs("div",{className:"text-sm space-y-1",children:[m.jsx("p",{className:"font-medium",children:"Import Data"}),m.jsxs("p",{className:"text-xs text-muted-foreground",children:["Upload a ",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," file exported from Guest Mode. All data will be ",m.jsx("strong",{children:"added"})," to your workspace — existing items with the same ID will be skipped. New projects will be created for any project‑scoped items."]}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"Supports: Notes, ERD Diagrams (entities, columns, relationships), Flowcharts, Drawings, AI Chat sessions & messages, and Projects."}),S==="desktop"&&m.jsxs("p",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-border/40",children:[m.jsx("strong",{className:"text-amber-500",children:"Desktop only:"})," You can also restore a",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px] mx-0.5",children:".db"})," database file — useful after reinstalling the app to recover data from a manually saved copy. A safety backup is created automatically."]})]})]}),m.jsxs("div",{onClick:()=>{var K;u!=="importing"&&((K=e.current)==null||K.click())},onKeyDown:K=>{var W;(K.key==="Enter"||K.key===" ")&&u!=="importing"&&((W=e.current)==null||W.click())},role:"button",tabIndex:0,className:"border-2 border-dashed border-border/50 hover:border-primary/40 rounded-xl p-8 text-center cursor-pointer transition-colors",children:[m.jsx("input",{ref:e,type:"file",accept:H,className:"hidden",onChange:L}),u==="importing"?m.jsxs("div",{className:"w-full max-w-sm mx-auto space-y-4",children:[m.jsxs("div",{className:"space-y-1.5",children:[m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground truncate mr-2",children:v.phase||"Importing…"}),m.jsxs("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:[Y,"%"]})]}),m.jsx("div",{className:"w-full h-2 bg-muted/50 rounded-full overflow-hidden",children:m.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300 ease-out",style:{width:`${Y}%`}})}),m.jsxs("p",{className:"text-[11px] text-muted-foreground tabular-nums",children:[v.current.toLocaleString()," / ",v.total.toLocaleString()," items"]})]}),m.jsx(VA,{variant:"ghost",size:"sm",onClick:K=>{K.stopPropagation(),P()},className:"text-xs",children:"Cancel"})]}):m.jsxs("div",{className:"flex flex-col items-center gap-3",children:[m.jsx("div",{className:"p-3 bg-muted/30 rounded-full",children:m.jsx(LN,{className:"size-6 text-muted-foreground"})}),m.jsxs("div",{children:[m.jsx("p",{className:"text-sm font-medium",children:"Click to select a file"}),m.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:j})]})]})]})]})}function Ynn({summary:e}){return m.jsxs("div",{className:"space-y-3",children:[m.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[m.jsx(tG,{label:"Projects",value:e.projects}),m.jsx(tG,{label:"Notes",value:e.notes}),m.jsx(tG,{label:"ERD Diagrams",value:e.diagrams}),m.jsx(tG,{label:"Tables (Entities)",value:e.entities}),m.jsx(tG,{label:"Columns",value:e.columns}),m.jsx(tG,{label:"Relationships",value:e.relationships}),m.jsx(tG,{label:"Flowcharts",value:e.flowcharts}),m.jsx(tG,{label:"Drawings",value:e.drawings}),m.jsx(tG,{label:"AI Sessions",value:e.ai_chat_sessions})]}),e.ai_chat_messages>0&&m.jsxs("p",{className:"text-[11px] text-muted-foreground px-0.5",children:["Includes ",e.ai_chat_messages.toLocaleString()," AI chat messages."]}),e.skipped_existing>0&&m.jsxs("p",{className:"text-[11px] text-amber-500 px-0.5",children:[e.skipped_existing.toLocaleString()," item(s) already existed and were skipped."]})]})}function tG({label:e,value:t}){return m.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-3 text-center",children:[m.jsx("p",{className:"text-lg font-bold",children:t.toLocaleString()}),m.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:e})]})}function gta(){if(!(typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli")))return m.jsx("div",{className:"p-4 md:p-8",children:m.jsx(Vk,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:m.jsxs(dT,{className:"py-12 text-center",children:[m.jsx(Ok,{className:"w-8 h-8 mx-auto text-muted-foreground/40"}),m.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Storage configuration is only available in the desktop app or CLI mode."})]})})});const[t,A]=J.useState({type:"r2",accountId:"",endpoint:"",region:"auto",accessKeyId:"",secretAccessKey:"",bucketName:"",publicUrl:""}),[n,i]=J.useState(null),[u,o]=J.useState("none"),[s,l]=J.useState(!0),[d,h]=J.useState(!1),[f,B]=J.useState(!1),[E,p]=J.useState({type:"",message:""}),[y,b]=J.useState(!1),[v,x]=J.useState(!1),S=J.useCallback(async()=>{l(!0);try{const T=await vr("/api/storage/config",{credentials:"include"});if(T.ok){const U=await T.json();o(U.source),U.config&&(i(U.config),A({type:U.config.type||"r2",accountId:U.config.accountId||"",endpoint:U.config.endpoint||"",region:U.config.region||"auto",accessKeyId:U.config.accessKeyId||"",secretAccessKey:U.config.secretAccessKey||"",bucketName:U.config.bucketName||"",publicUrl:U.config.publicUrl||""}))}}catch(T){console.error("Failed to load storage config:",T)}finally{l(!1)}},[]);J.useEffect(()=>{S()},[S]);const L=async()=>{h(!0),p({type:"",message:""});try{const T=await vr("/api/storage/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"});if(T.ok)p({type:"success",message:"Storage configuration saved successfully."}),i({...t}),await S();else{const U=await T.json();p({type:"error",message:U.error||"Failed to save configuration"})}}catch(T){p({type:"error",message:T.message||"Network error"})}finally{h(!1)}},N=async()=>{B(!0),p({type:"",message:""});try{const T=await vr("/api/storage/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),credentials:"include"});if(T.ok)p({type:"success",message:"Successfully connected to storage."});else{const U=await T.json();p({type:"error",message:U.error||"Connection failed"})}}catch(T){p({type:"error",message:T.message||"Network error"})}finally{B(!1)}},O=(T,U)=>{A(P=>({...P,[T]:U})),p({type:"",message:""})};if(s)return m.jsx("div",{className:"p-4 md:p-8",children:m.jsx(Vk,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:m.jsxs(dT,{className:"py-12 text-center",children:[m.jsx(v4,{className:"w-6 h-6 animate-spin mx-auto text-muted-foreground"}),m.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Loading storage configuration..."})]})})});const M=u==="env";return m.jsx("div",{className:"p-6 space-y-6",children:m.jsxs(Vk,{className:"border border-border/50 bg-background/50 backdrop-blur-sm shadow-lg",children:[m.jsxs(ihe,{className:"border-b border-border/30 pb-6",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(BK,{className:"w-6 h-6 text-blue-500"}),m.jsx(ahe,{className:"text-xl md:text-2xl font-bold",children:"Storage Configuration"})]}),m.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Configure Cloudflare R2 or S3-compatible storage for image uploads in Notes and Drawings."})]}),m.jsxs(dT,{className:"space-y-6 p-4 md:p-6",children:[M&&m.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[m.jsx(bF,{className:"w-4 h-4 text-blue-500 shrink-0"}),m.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:"Pre-filled from environment variables. Save to override with custom settings."})]}),E.type&&m.jsxs("div",{className:`flex items-center gap-3 p-4 rounded-lg border ${E.type==="success"?"bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400":"bg-red-500/10 border-red-500/20 text-red-600 dark:text-red-400"}`,children:[E.type==="success"?m.jsx(Bk,{className:"w-5 h-5 shrink-0"}):m.jsx(nN,{className:"w-5 h-5 shrink-0"}),m.jsx("p",{className:"text-sm",children:E.message})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(Ok,{className:"size-3"}),"Storage Provider"]}),m.jsxs(KB,{value:t.type,onValueChange:(T,U)=>T&&O("type",T),children:[m.jsx(_f,{className:"h-9 text-sm",children:m.jsx(JB,{children:t.type==="r2"?m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(BK,{className:"w-4 h-4"}),"Cloudflare R2"]}):m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(Ok,{className:"w-4 h-4"}),"S3-Compatible"]})})}),m.jsxs($B,{children:[m.jsx(e0,{value:"r2",children:m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(BK,{className:"w-4 h-4"}),"Cloudflare R2"]})}),m.jsx(e0,{value:"s3-compatible",children:m.jsxs("span",{className:"flex items-center gap-2",children:[m.jsx(Ok,{className:"w-4 h-4"}),"S3-Compatible"]})})]})]})]}),t.type==="r2"&&m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(zk,{className:"size-3"}),"Account ID"]}),m.jsx(Wo,{placeholder:"Your Cloudflare R2 Account ID",value:t.accountId||"",onChange:T=>O("accountId",T.target.value),className:"h-9 text-sm font-mono"}),m.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:"Found in your Cloudflare dashboard under R2 → Account ID."})]}),t.type==="s3-compatible"&&m.jsxs(m.Fragment,{children:[m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(zk,{className:"size-3"}),"Endpoint URL"]}),m.jsx(Wo,{placeholder:"https://s3.us-east-1.amazonaws.com",value:t.endpoint||"",onChange:T=>O("endpoint",T.target.value),className:"h-9 text-sm font-mono"})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(zk,{className:"size-3"}),"Region"]}),m.jsx(Wo,{placeholder:"us-east-1",value:t.region||"",onChange:T=>O("region",T.target.value),className:"h-9 text-sm font-mono"})]})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(Ice,{className:"size-3"}),"Access Key ID"]}),m.jsxs("div",{className:"relative",children:[m.jsx(Wo,{type:v?"text":"password",placeholder:"Your access key ID",value:t.accessKeyId,onChange:T=>O("accessKeyId",T.target.value),className:"h-9 text-sm font-mono pr-10"}),m.jsx("button",{type:"button",onClick:()=>x(!v),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:v?m.jsx(FN,{className:"w-4 h-4"}):m.jsx(cT,{className:"w-4 h-4"})})]})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(Ice,{className:"size-3"}),"Secret Access Key"]}),m.jsxs("div",{className:"relative",children:[m.jsx(Wo,{type:y?"text":"password",placeholder:"Your secret access key",value:t.secretAccessKey,onChange:T=>O("secretAccessKey",T.target.value),className:"h-9 text-sm font-mono pr-10"}),m.jsx("button",{type:"button",onClick:()=>b(!y),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:y?m.jsx(FN,{className:"w-4 h-4"}):m.jsx(cT,{className:"w-4 h-4"})})]})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(fce,{className:"size-3"}),"Bucket Name"]}),m.jsx(Wo,{placeholder:"your-bucket-name",value:t.bucketName,onChange:T=>O("bucketName",T.target.value),className:"h-9 text-sm font-mono"})]}),m.jsxs(Ac,{children:[m.jsxs(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[m.jsx(mce,{className:"size-3"}),"Public URL (optional)"]}),m.jsx(Wo,{placeholder:"https://cdn.yourdomain.com",value:t.publicUrl||"",onChange:T=>O("publicUrl",T.target.value),className:"h-9 text-sm font-mono"}),m.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:t.type==="s3-compatible"?"Optional. If set, overrides the auto-constructed endpoint URL. Useful for custom CDN/domain. If empty, URL is built from Endpoint + Bucket.":"Optional public URL prefix for direct image access (e.g., custom domain or CDN). If empty, R2 public URL is auto-constructed."})]})]}),m.jsxs(Fge,{className:"bg-muted/5 border-t border-border/30 p-4 md:px-6 md:py-4 flex flex-col sm:flex-row gap-3 sm:justify-end",children:[m.jsx("button",{type:"button",onClick:N,disabled:f||!t.bucketName||!t.accessKeyId||!t.secretAccessKey,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-border text-sm font-medium whitespace-nowrap transition-colors h-10 px-4 bg-background hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50 cursor-pointer select-none",children:f?m.jsxs(m.Fragment,{children:[m.jsx(v4,{className:"w-4 h-4 shrink-0 animate-spin pointer-events-none"}),m.jsx("span",{className:"pointer-events-none",children:"Testing..."})]}):m.jsxs(m.Fragment,{children:[m.jsx(v4,{className:"w-4 h-4 shrink-0 pointer-events-none"}),m.jsx("span",{className:"pointer-events-none",children:"Test Connection"})]})}),m.jsxs(VA,{onClick:L,className:"gap-2 px-6",disabled:d,children:[d?m.jsx(v4,{className:"w-4 h-4 animate-spin"}):m.jsx(gT,{className:"w-4 h-4"}),d?"Saving...":"Save Configuration"]})]})]})})}function dta(){const{isSettingsOpen:e,setIsSettingsOpen:t,settingsTab:A,setSettingsTab:n}=qB(),i=typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli"),{providers:u,configs:o,isTesting:s,isSaving:l,handleSaveConfig:d,handleTestConnection:h,updateProviderLocal:f,updateConfigLocal:B}=kKi(),{isGuest:E}=yx(),{models:p,newModel:y,editingModelId:b,isSaving:v,setNewModel:x,handleAddModel:S,handleDeleteModel:L,startEditingModel:N,cancelEdit:O}=xKi(),{prompts:M,isSaving:T,handleSavePrompt:U,handleDeletePrompt:P,togglePromptDefault:R}=FKi(),Y=Ot.useMemo(()=>E?[{label:"General",items:[{id:"appearance",label:"Appearance",icon:m.jsx(NAe,{className:"size-4"})}]},{label:"More",items:[{id:"changelog",label:"What's New",icon:m.jsx(FAe,{className:"size-4"})}]}]:[{label:"General",items:[{id:"account",label:"Account",icon:m.jsx(ON,{className:"size-4"})},{id:"appearance",label:"Appearance",icon:m.jsx(NAe,{className:"size-4"})},...i?[{id:"storage",label:"Storage",icon:m.jsx(Ok,{className:"size-4"})}]:[]]},{label:"Feature",items:[{id:"ai-config",label:"AI Configuration",icon:m.jsx(ry,{className:"size-4"})},{id:"ai-models",label:"Model Catalog",icon:m.jsx(Qce,{className:"size-4"})},{id:"ai-rules",label:"AI Rules",icon:m.jsx(swe,{className:"size-4"})},{id:"ai-prompts",label:"System Prompts",icon:m.jsx(Y3e,{className:"size-4"})}]},{label:"More",items:[{id:"import-data",label:"Import Data",icon:m.jsx(LN,{className:"size-4"})},{id:"backups",label:"Database Backup",icon:m.jsx(Z0,{className:"size-4"})},{id:"changelog",label:"What's New",icon:m.jsx(FAe,{className:"size-4"})}]}],[E]),H=Y.flatMap(K=>K.items),j=K=>{var W;return((W=H.find(q=>q.id===K))==null?void 0:W.label)||""};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"overflow-hidden p-0 md:max-h-150 md:max-w-175 lg:max-w-237.5 bg-background border-border/40 shadow-2xl",children:[m.jsx(Yg,{className:"sr-only",children:"Settings"}),m.jsx(ip,{className:"sr-only",children:"Manage your application settings and AI configuration."}),m.jsxs(Z5n,{className:"items-start min-h-0! h-full",children:[m.jsx(V5n,{collapsible:"none",className:"w-55 border-r border-border/40 bg-muted/5 hidden md:flex h-full",children:m.jsxs(e6n,{className:"pt-4 px-2 pb-0",children:[m.jsx("div",{className:"px-4 py-2 mb-2",children:m.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[m.jsx(MAe,{className:"size-4"}),"Settings"]})}),Y.map(K=>m.jsxs(Ict,{className:"py-1",children:[m.jsx(DWt,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-4 mb-0.5",children:K.label}),m.jsx(vWt,{children:m.jsx(oDe,{children:K.items.map(W=>m.jsx(Nge,{children:m.jsxs($K,{isActive:A===W.id,onClick:()=>n(W.id),className:`transition-all duration-200 px-4 py-2 rounded-md ${A===W.id?"bg-sidebar-accent text-sidebar-accent-foreground font-medium":"text-muted-foreground hover:bg-sidebar-accent/50"}`,children:[W.icon,m.jsx("span",{className:"text-xs",children:W.label})]})},W.id))})})]},K.label))]})}),m.jsxs("main",{className:"flex-1 flex flex-col h-150 overflow-hidden",children:[m.jsx("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-6 backdrop-blur-sm",children:m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(A6n,{className:"hidden md:flex",children:m.jsxs(n6n,{children:[m.jsx(j8,{children:m.jsx(_Ti,{href:"#",className:"text-[11px] text-muted-foreground",children:"Settings"})}),m.jsx(kWt,{}),m.jsx(j8,{children:m.jsx(GO,{className:"text-[11px] font-semibold",children:j(A)})})]})}),m.jsx("div",{className:"md:hidden",children:m.jsxs(fy,{children:[m.jsx(y3,{render:m.jsxs(VA,{variant:"ghost",size:"sm",className:"-ml-2 h-8 gap-2 text-xs font-semibold",children:[m.jsx(MAe,{className:"size-3.5"}),j(A),m.jsx(N5,{className:"size-3 opacity-50"})]})}),m.jsx(b3,{align:"start",className:"w-56",children:Y.map(K=>m.jsxs(ble,{children:[m.jsx(MiA,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-2 py-1.5",children:K.label}),K.items.map(W=>m.jsxs(dc,{onClick:()=>n(W.id),className:A===W.id?"bg-accent":"",children:[W.icon,m.jsx("span",{className:"ml-2",children:W.label})]},W.id)),m.jsx(GI,{})]},K.label))})]})})]})}),m.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[A==="ai-config"&&m.jsx(dJi,{providers:u,configs:o,models:p,isSaving:l,isTesting:s,onSave:d,onTest:K=>h(K,Object.values(p).flat()),onUpdateProvider:f,onUpdateConfig:B}),A==="ai-models"&&m.jsx(IJi,{providers:u,models:Object.values(p).flat(),newModel:y,editingModelId:b,isSaving:v,onSetNewModel:x,onAddModel:S,onEditModel:N,onDeleteModel:L,onCancelEdit:O}),A==="ai-prompts"&&m.jsx(DJi,{prompts:M,isSaving:T,onSave:U,onDelete:P,onToggleDefault:R}),A==="ai-rules"&&m.jsx(xJi,{}),A==="backups"&&m.jsx("div",{className:"p-6 space-y-6",children:m.jsx(uzi,{})}),A==="account"&&m.jsx(OJi,{}),A==="changelog"&&m.jsx("div",{className:"p-6 space-y-6",children:m.jsx(uta,{})}),A==="import-data"&&m.jsxs("div",{className:"p-4 md:p-6 overflow-y-auto h-full",children:[m.jsxs("div",{className:"mb-6",children:[m.jsx("h2",{className:"text-lg font-semibold",children:"Import Data"}),m.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Restore data from a JSON backup or replace the local database from a .db file."})]}),m.jsx(cta,{})]}),A==="appearance"&&m.jsx(RJi,{}),A==="storage"&&m.jsx(gta,{})]})]})]})]})})}async function hta(){try{const{getVersion:e}=await Xr(async()=>{const{getVersion:t}=await Promise.resolve().then(()=>zFn);return{getVersion:t}},void 0);return await e()}catch{return"0.0.0"}}function kvn({open:e,onOpenChange:t,hasUpdate:A=!1,latestVersion:n=null,isChecking:i=!1,isDownloading:u=!1,onCheckUpdate:o,onDownload:s}){const l=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),[d,h]=J.useState("..."),[f,B]=J.useState(!1),[E,p]=J.useState(null),[y,b]=J.useState(!1),[v,x]=J.useState(!1),[S,L]=J.useState(null),N=A||f,O=n||E,M=i||y,T=u||v;J.useEffect(()=>{l?hta().then(h):h("3.1.2")},[l]),J.useEffect(()=>{if(!e||!l||A||i||u)return;if(o){o();return}if(s)return;b(!0);let R=!1;return(async()=>{try{const{check:H}=await Xr(async()=>{const{check:K}=await Promise.resolve().then(()=>rtn);return{check:K}},void 0),j=await H();if(R)return;j?(B(!0),p(j.version),L(j)):(B(!1),p(null),L(null))}catch{}finally{R||b(!1)}})(),()=>{R=!0}},[e,l]);const U=J.useCallback(()=>{if(s)s();else if(S){if(v)return;x(!0),S.downloadAndInstall(()=>{}).catch(R=>{const Y=typeof R=="string"?R:R!=null&&R.message?R.message:JSON.stringify(R);gA.error("Update failed",{description:Y||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(Y).catch(()=>{})}})}).finally(()=>x(!1))}},[s,S,v]),P=J.useCallback(()=>{if(T)return;if(o){o();return}b(!0),B(!1),p(null),(async()=>{try{const{check:Y}=await Xr(async()=>{const{check:j}=await Promise.resolve().then(()=>rtn);return{check:j}},void 0),H=await Y();H?(B(!0),p(H.version),L(H)):(B(!1),p(null),L(null))}catch{}finally{b(!1)}})()},[o,T]);return J.useEffect(()=>{e||(B(!1),p(null),b(!1),L(null))},[e]),m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"max-w-sm bg-background border-border/40 shadow-2xl",children:[m.jsx(Yg,{className:"sr-only",children:"About ERD Builder Pro"}),m.jsx(ip,{className:"sr-only",children:"Application information and credits."}),m.jsxs("div",{className:"flex flex-col items-center py-6 gap-4",children:[m.jsx("div",{className:"flex items-center justify-center",children:m.jsx("img",{src:"/favicon.svg",alt:"ERD Builder Pro",className:"size-14"})}),m.jsxs("div",{className:"text-center",children:[m.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"ERD Builder Pro"}),m.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Version ",d]})]}),m.jsx("p",{className:"text-xs text-center text-muted-foreground max-w-60 leading-relaxed",children:"Entity-Relationship Diagram builder, flowcharts, notes, and AI-powered assistance — all in one desktop app."}),l&&m.jsxs("div",{className:"w-full",children:[m.jsx("div",{className:"w-full border-t border-border/40 mb-3"}),M?m.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground py-1",children:[m.jsx(js,{className:"size-3.5 animate-spin"}),"Checking for updates..."]}):N&&O?m.jsxs("div",{className:"flex flex-col items-center gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-500",children:[m.jsx(YQ,{className:"size-3.5"}),m.jsxs("span",{children:["Update ",m.jsxs("strong",{children:["v",O]})," available"]})]}),m.jsxs(VA,{variant:"default",size:"sm",className:"h-8 text-xs gap-1.5",onClick:U,disabled:T,children:[T?m.jsx(js,{className:"size-3.5 animate-spin"}):m.jsx(YQ,{className:"size-3.5"}),T?"Downloading...":"Download Update"]})]}):m.jsxs("div",{className:"flex flex-col items-center gap-2",children:[m.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-500",children:[m.jsx(Bk,{className:"size-3.5"}),m.jsx("span",{children:"You're up to date"})]}),m.jsxs(VA,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:P,children:[m.jsx(v4,{className:"size-3"}),"Check Again"]})]})]}),m.jsx("div",{className:"w-full border-t border-border/40"}),m.jsxs("div",{className:"text-[10px] text-center text-muted-foreground/60 leading-relaxed",children:[m.jsx("p",{children:"Built with React, Tauri, Express & Prisma."}),m.jsxs("p",{className:"mt-0.5",children:["© ",new Date().getFullYear()," Bekenweb."]})]}),m.jsx("div",{className:"flex items-center gap-3",children:m.jsxs(VA,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:()=>{window.open("https://github.com/hadziqmtqn/erd-builder-pro","_blank")},children:[m.jsx(IK,{className:"size-3"}),"GitHub"]})})]})]})})}function Cta(e){const[t,A]=J.useState(!1),[n,i]=J.useState(null),[u,o]=J.useState(!1),[s,l]=J.useState(null),{setViewport:d,fitView:h}=yJ();return{isPublicView:t,setIsPublicView:A,publicData:n,isPublicLoading:u,forbiddenDoc:s,fetchPublicDocument:async(B,E,p,y,b)=>{o(!0),l(null);try{const v=B==="erd"?"files":B==="flowchart"?"flowcharts":B,x={"Content-Type":"application/json"};b&&(x["x-share-token"]=b);const S=await vr(`/api/${v}/public/${E}`,{headers:x,credentials:"include"});if(!S.ok){let O="Document not found or access denied",M="Access Denied";try{O=(await S.json()).error||O,S.status===404?M="Not Found":(S.status===401||S.status===403)&&(M="Access Denied")}catch{}if(S.status===401||S.status===403||S.status===404)return l({title:M,message:O,status:S.status}),!1;throw new Error(O)}const L=S.headers.get("content-type");if(!L||!L.includes("application/json"))throw new Error("Received invalid response from server");const N=await S.json();if(i(N),e(B),B==="erd"){const O=N.entities.map(U=>({id:U.id,type:"entity",position:{x:U.x,y:U.y},data:U})),M=N.relationships.map(U=>{const P=N.entities.find(j=>String(j.id)===String(U.source_entity_id)),R=N.entities.find(j=>String(j.id)===String(U.target_entity_id));let Y=U.source_handle,H=U.target_handle;if(!Y&&P&&R){const j=Number(P.x)||0,K=Number(R.x)||0;Y=j<K?`col-${U.source_column_id}-source`:`col-${U.source_column_id}-source-l`}if(!H&&P&&R){const j=Number(P.x)||0,K=Number(R.x)||0;H=j<K?`col-${U.target_column_id}-target`:`col-${U.target_column_id}-target-r`}return{id:U.id,source:U.source_entity_id,target:U.target_entity_id,sourceHandle:Y||(U.source_column_id?`col-${U.source_column_id}-source`:void 0),targetHandle:H||(U.target_column_id?`col-${U.target_column_id}-target`:void 0),label:U.label,type:"smoothstep",animated:!0}});p(O),y(M);const T=(U=0)=>{N.viewport_x!==void 0&&(N.viewport_x!==0||N.viewport_y!==0)?d({x:N.viewport_x,y:N.viewport_y,zoom:N.viewport_zoom||1},{duration:U}):O.length>0&&h({padding:.2,duration:U})};setTimeout(()=>T(0),50),setTimeout(()=>T(0),300)}else if(B==="flowchart")try{const O=typeof N.data=="string"?JSON.parse(N.data):N.data;p(O.nodes||[]),y(O.edges||[]);const M=(T=0)=>{var U;N.viewport_x!==void 0&&(N.viewport_x!==0||N.viewport_y!==0)?d({x:N.viewport_x,y:N.viewport_y,zoom:N.viewport_zoom||1},{duration:T}):((U=O.nodes)==null?void 0:U.length)>0&&h({padding:.2,duration:T})};setTimeout(()=>M(0),50),setTimeout(()=>M(0),300)}catch(O){console.error("Failed to parse flowchart data:",O)}else p([]),y([]);return!0}catch(v){return gA.error(v.message||"Failed to load shared document"),setTimeout(()=>window.location.href="/",3e3),!1}finally{o(!1)}}}}function fta(e){const{open:t,defaultOpen:A,onOpenChange:n,disabled:i}=e,u=t!==void 0,[o,s]=Bne({controlled:t,default:A,name:"Collapsible",state:"open"}),{mounted:l,setMounted:d,transitionStatus:h}=kJ(o,!0,!0),[f,B]=J.useState(o),[{height:E,width:p},y]=J.useState({height:void 0,width:void 0}),b=R4(),[v,x]=J.useState(),S=v??b,[L,N]=J.useState(!1),[O,M]=J.useState(!1),T=J.useRef(null),U=J.useRef(null),P=J.useRef(null),R=J.useRef(null),Y=VBt(R,!1),H=la(j=>{const K=!o,W=Eo(JN,j.nativeEvent);if(n(K,W),W.isCanceled)return;const q=R.current;U.current==="css-animation"&&q!=null&&q.style.removeProperty("animation-name"),!L&&!O&&(U.current!=null&&U.current!=="css-animation"&&!l&&K&&d(!0),U.current==="css-animation"&&(!f&&K&&B(!0),!l&&K&&d(!0))),s(K),U.current==="none"&&l&&!K&&d(!1)});return Li(()=>{u&&U.current==="none"&&!O&&!o&&d(!1)},[u,O,o,t,d]),J.useMemo(()=>({abortControllerRef:T,animationTypeRef:U,disabled:i,handleTrigger:H,height:E,mounted:l,open:o,panelId:S,panelRef:R,runOnceAnimationsFinish:Y,setDimensions:y,setHiddenUntilFound:N,setKeepMounted:M,setMounted:d,setOpen:s,setPanelIdState:x,setVisible:B,transitionDimensionRef:P,transitionStatus:h,visible:f,width:p}),[T,U,i,H,E,l,o,S,R,Y,y,N,M,d,s,B,P,h,f,p])}const xvn=J.createContext(void 0);function Fvn(){const e=J.useContext(xvn);if(e===void 0)throw new Error(Cc(15));return e}let Uwe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=LT.startingStyle]="startingStyle",e[e.endingStyle=LT.endingStyle]="endingStyle",e})({}),Bta=(function(e){return e.panelOpen="data-panel-open",e})({});const Eta={[Uwe.open]:""},Ita={[Uwe.closed]:""},pta={open(e){return e?{[Bta.panelOpen]:""}:null}},Qta={open(e){return e?Eta:Ita}},Svn={...Qta,...wx},mta=J.forwardRef(function(t,A){const{render:n,className:i,defaultOpen:u=!1,disabled:o=!1,onOpenChange:s,open:l,...d}=t,h=la(s),f=fta({open:l,defaultOpen:u,onOpenChange:h,disabled:o}),B=J.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),E=J.useMemo(()=>({...f,onOpenChange:h,state:B}),[f,h,B]),p=go("div",t,{state:B,ref:A,props:d,stateAttributesMapping:Svn});return m.jsx(xvn.Provider,{value:E,children:p})}),wta={...pta,...wx},yta=J.forwardRef(function(t,A){const{panelId:n,open:i,handleTrigger:u,state:o,disabled:s}=Fvn(),{className:l,disabled:d=s,id:h,render:f,nativeButton:B=!0,...E}=t,{getButtonProps:p,buttonRef:y}=iS({disabled:d,focusableWhenDisabled:!0,native:B}),b=J.useMemo(()=>({"aria-controls":i?n:void 0,"aria-expanded":i,onClick:u}),[n,i,u]);return go("button",t,{state:o,ref:[A,y],props:[b,E,p],stateAttributesMapping:wta})});let bta=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e})({});function Dta(e){const{abortControllerRef:t,animationTypeRef:A,externalRef:n,height:i,hiddenUntilFound:u,keepMounted:o,id:s,mounted:l,onOpenChange:d,open:h,panelRef:f,runOnceAnimationsFinish:B,setDimensions:E,setMounted:p,setOpen:y,setVisible:b,transitionDimensionRef:v,visible:x,width:S}=e,L=J.useRef(!1),N=J.useRef(null),O=J.useRef(h),M=J.useRef(h),T=z6e(),U=J.useMemo(()=>A.current==="css-animation"?!x:!h&&!l,[h,l,x,A]),P=la(Y=>{if(!Y)return;if(A.current==null||v.current==null){const K=getComputedStyle(Y),W=K.animationName!=="none"&&K.animationName!=="",q=K.transitionDuration!=="0s"&&K.transitionDuration!=="";W&&q||(K.animationName==="none"&&K.transitionDuration!=="0s"?A.current="css-transition":K.animationName!=="none"&&K.transitionDuration==="0s"?A.current="css-animation":A.current="none"),Y.getAttribute(bta.orientation)==="horizontal"||K.transitionProperty.indexOf("width")>-1?v.current="width":v.current="height"}if(A.current!=="css-transition")return;(i===void 0||S===void 0)&&(E({height:Y.scrollHeight,width:Y.scrollWidth}),M.current&&Y.style.setProperty("transition-duration","0s"));let H=-1,j=-1;return H=MB.request(()=>{M.current=!1,j=MB.request(()=>{setTimeout(()=>{Y.style.removeProperty("transition-duration")})})}),()=>{MB.cancel(H),MB.cancel(j)}}),R=jF(n,f,P);return Li(()=>{if(A.current!=="css-transition")return;const Y=f.current;if(!Y)return;let H=-1;if(t.current!=null&&(t.current.abort(),t.current=null),h){const j={"justify-content":Y.style.justifyContent,"align-items":Y.style.alignItems,"align-content":Y.style.alignContent,"justify-items":Y.style.justifyItems};Object.keys(j).forEach(K=>{Y.style.setProperty(K,"initial","important")}),!M.current&&!o&&Y.setAttribute(Uwe.startingStyle,""),E({height:Y.scrollHeight,width:Y.scrollWidth}),H=MB.request(()=>{Object.entries(j).forEach(([K,W])=>{W===""?Y.style.removeProperty(K):Y.style.setProperty(K,W)})})}else{if(Y.scrollHeight===0&&Y.scrollWidth===0)return;E({height:Y.scrollHeight,width:Y.scrollWidth});const j=new AbortController;t.current=j;const K=j.signal;let W=null;const q=Uwe.endingStyle;return W=new MutationObserver(ee=>{ee.some(Z=>Z.type==="attributes"&&Z.attributeName===q)&&(W==null||W.disconnect(),W=null,B(()=>{E({height:0,width:0}),Y.style.removeProperty("content-visibility"),p(!1),t.current===j&&(t.current=null)},K))}),W.observe(Y,{attributes:!0,attributeFilter:[q]}),()=>{W==null||W.disconnect(),T.cancel(),t.current===j&&(j.abort(),t.current=null)}}return()=>{MB.cancel(H)}},[t,A,T,u,o,l,h,f,B,E,p]),Li(()=>{if(A.current!=="css-animation")return;const Y=f.current;Y&&(N.current=Y.style.animationName||N.current,Y.style.setProperty("animation-name","none"),E({height:Y.scrollHeight,width:Y.scrollWidth}),!O.current&&!L.current&&Y.style.removeProperty("animation-name"),h?(t.current!=null&&(t.current.abort(),t.current=null),p(!0),b(!0)):(t.current=new AbortController,B(()=>{p(!1),b(!1),t.current=null},t.current.signal)))},[t,A,h,f,B,E,p,b,x]),j6e(()=>{const Y=MB.request(()=>{O.current=!1});return()=>MB.cancel(Y)}),Li(()=>{if(!u)return;const Y=f.current;if(!Y)return;let H=-1,j=-1;return h&&L.current&&(Y.style.transitionDuration="0s",E({height:Y.scrollHeight,width:Y.scrollWidth}),H=MB.request(()=>{L.current=!1,j=MB.request(()=>{setTimeout(()=>{Y.style.removeProperty("transition-duration")})})})),()=>{MB.cancel(H),MB.cancel(j)}},[u,h,f,E]),Li(()=>{const Y=f.current;Y&&u&&U&&(Y.setAttribute("hidden","until-found"),A.current==="css-transition"&&Y.setAttribute(Uwe.startingStyle,""))},[u,U,A,f]),J.useEffect(function(){const H=f.current;if(!H)return;function j(K){L.current=!0,y(!0),d(!0,Eo(KN,K))}return H.addEventListener("beforematch",j),()=>{H.removeEventListener("beforematch",j)}},[d,f,y]),J.useMemo(()=>({props:{hidden:U,id:s,ref:R}}),[U,s,R])}let Pnn=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const vta=J.forwardRef(function(t,A){const{className:n,hiddenUntilFound:i,keepMounted:u,render:o,id:s,...l}=t,{abortControllerRef:d,animationTypeRef:h,height:f,mounted:B,onOpenChange:E,open:p,panelId:y,panelRef:b,runOnceAnimationsFinish:v,setDimensions:x,setHiddenUntilFound:S,setKeepMounted:L,setMounted:N,setPanelIdState:O,setOpen:M,setVisible:T,state:U,transitionDimensionRef:P,visible:R,width:Y,transitionStatus:H}=Fvn(),j=i??!1,K=u??!1;Li(()=>{if(s)return O(s),()=>{O(void 0)}},[s,O]),Li(()=>{S(j)},[S,j]),Li(()=>{L(K)},[L,K]);const{props:W}=Dta({abortControllerRef:d,animationTypeRef:h,externalRef:A,height:f,hiddenUntilFound:j,id:y,keepMounted:K,mounted:B,onOpenChange:E,open:p,panelRef:b,runOnceAnimationsFinish:v,setDimensions:x,setMounted:N,setOpen:M,setVisible:T,transitionDimensionRef:P,visible:R,width:Y});a9({open:p&&H==="idle",ref:b,onComplete(){p&&x({height:void 0,width:void 0})}});const q=J.useMemo(()=>({...U,transitionStatus:H}),[U,H]),ee=go("div",t,{state:q,ref:[A,b],props:[W,{style:{[Pnn.collapsiblePanelHeight]:f===void 0?"auto":`${f}px`,[Pnn.collapsiblePanelWidth]:Y===void 0?"auto":`${Y}px`}},l],stateAttributesMapping:Svn});return K||j||!K&&B?ee:null});function kta({...e}){return m.jsx(mta,{"data-slot":"collapsible",...e})}function xta({...e}){return m.jsx(yta,{"data-slot":"collapsible-trigger",...e})}function Fta({...e}){return m.jsx(vta,{"data-slot":"collapsible-content",...e})}function Sta({items:e}){return m.jsx(oDe,{children:e.map(t=>{var A;return m.jsx(Nge,{children:t.items?m.jsxs(kta,{defaultOpen:t.isActive,className:"group/collapsible",children:[m.jsx(xta,{render:m.jsxs($K,{tooltip:t.title,className:"cursor-pointer",children:[t.icon&&m.jsx(t.icon,{className:t.iconClassName}),m.jsx("span",{children:t.title}),m.jsx(Yf,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),m.jsx(Fta,{children:m.jsx(YTi,{children:(A=t.items)==null?void 0:A.map(n=>m.jsx(PTi,{children:m.jsx(t6n,{render:m.jsx("a",{href:n.url}),className:"cursor-pointer",children:m.jsx("span",{children:n.title})})},n.title))})})]}):m.jsxs($K,{tooltip:t.title,isActive:t.isActive,onClick:t.onClick,className:"cursor-pointer",children:[t.icon&&m.jsx(t.icon,{className:t.iconClassName}),m.jsx("span",{children:t.title})]})},t.title)})})}const Lvn=J.createContext(void 0);function Ovn(){const e=J.useContext(Lvn);if(e===void 0)throw new Error(Cc(13));return e}const yaA={imageLoadingStatus:()=>null},Lta=J.forwardRef(function(t,A){const{className:n,render:i,...u}=t,[o,s]=J.useState("idle"),l={imageLoadingStatus:o},d=J.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),h=go("span",t,{state:l,ref:A,props:u,stateAttributesMapping:yaA});return m.jsx(Lvn.Provider,{value:d,children:h})});function Ota(e,{referrerPolicy:t,crossOrigin:A}){const[n,i]=J.useState("idle");return Li(()=>{if(!e)return i("error"),iy;let u=!0;const o=new window.Image,s=l=>()=>{u&&i(l)};return i("loading"),o.onload=s("loaded"),o.onerror=s("error"),t&&(o.referrerPolicy=t),o.crossOrigin=A??null,o.src=e,()=>{u=!1}},[e,A,t]),n}const Nta={...yaA,...wx},Mta=J.forwardRef(function(t,A){const{className:n,render:i,onLoadingStatusChange:u,referrerPolicy:o,crossOrigin:s,...l}=t,d=Ovn(),h=Ota(t.src,{referrerPolicy:o,crossOrigin:s}),f=h==="loaded",{mounted:B,transitionStatus:E,setMounted:p}=kJ(f),y=J.useRef(null),b=la(S=>{u==null||u(S),d.setImageLoadingStatus(S)});Li(()=>{h!=="idle"&&b(h)},[h,b]);const v={imageLoadingStatus:h,transitionStatus:E};a9({open:f,ref:y,onComplete(){f||p(!1)}});const x=go("img",t,{state:v,ref:[A,y],props:l,stateAttributesMapping:Nta,enabled:B});return B?x:null}),Rta=J.forwardRef(function(t,A){const{className:n,render:i,delay:u,...o}=t,{imageLoadingStatus:s}=Ovn(),[l,d]=J.useState(u===void 0),h=dC();return J.useEffect(()=>(u!==void 0&&h.start(u,()=>d(!0)),h.clear),[h,u]),go("span",t,{state:{imageLoadingStatus:s},ref:A,props:o,stateAttributesMapping:yaA,enabled:s!=="loaded"&&l})}),oZt=J.forwardRef(({className:e,size:t="default",...A},n)=>m.jsx(Lta,{ref:n,"data-slot":"avatar","data-size":t,className:Xn("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",e),...A}));oZt.displayName="Avatar";const sZt=J.forwardRef(({className:e,...t},A)=>m.jsx(Mta,{ref:A,"data-slot":"avatar-image",className:Xn("aspect-square size-full rounded-full object-cover",e),...t}));sZt.displayName="AvatarImage";const lZt=J.forwardRef(({className:e,...t},A)=>m.jsx(Rta,{ref:A,"data-slot":"avatar-fallback",className:Xn("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",e),...t}));lZt.displayName="AvatarFallback";function Uta({open:e,onOpenChange:t}){const[A,n]=J.useState(!1),i=async()=>{n(!0);try{await r9n(),gA.success("Data exported successfully!")}catch(u){gA.error("Export failed: "+(u.message||"Unknown error"))}finally{n(!1)}};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-[420px] bg-background border-border/40 shadow-2xl",children:[m.jsx(Yg,{className:"sr-only",children:"Guest Data Backup"}),m.jsx(ip,{className:"sr-only",children:"Export your Guest Mode data as a JSON file for safe keeping or future import."}),m.jsxs("div",{className:"p-2 space-y-6",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"p-2.5 bg-amber-500/10 rounded-xl",children:m.jsx(ON,{className:"size-5 text-amber-500"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"font-semibold text-base",children:"Guest Mode"}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"You are browsing as a guest"})]})]}),m.jsxs("div",{className:"bg-muted/10 border border-border/40 rounded-xl p-4 space-y-3",children:[m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx(Z0,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),m.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:m.jsxs("p",{children:["Your data (notes, diagrams, flowcharts, drawings, and AI chats) is stored locally in your browser. Export it as a ",m.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," ","file so you can import it after signing in."]})})]}),m.jsxs("div",{className:"flex items-start gap-3",children:[m.jsx(hce,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),m.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:m.jsxs("p",{children:["The export file can be imported into any ERD Builder Pro account via",m.jsx("strong",{children:" Settings → Guest Data Import"}),"."]})})]})]}),m.jsx(VA,{onClick:i,disabled:A,className:"w-full",children:A?m.jsxs(m.Fragment,{children:[m.jsx(js,{className:"size-4 mr-2 animate-spin"}),"Exporting…"]}):m.jsxs(m.Fragment,{children:[m.jsx(YQ,{className:"size-4 mr-2"}),"Export My Data"]})}),m.jsxs("div",{className:"relative",children:[m.jsx("div",{className:"absolute inset-0 flex items-center",children:m.jsx("span",{className:"w-full border-t border-border/30"})}),m.jsx("div",{className:"relative flex justify-center text-xs",children:m.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Need an account?"})})]}),m.jsx("div",{className:"text-center space-y-2",children:m.jsx("p",{className:"text-xs text-muted-foreground",children:"Sign up or log in from the main page to import your backup."})})]})]})})}function Gta({user:e,onLogout:t,onViewChange:A,isOnline:n,onOpenFeedback:i}){var R,Y,H;const{isMobile:u}=LJ(),{isGuest:o,setIsSettingsOpen:s,setSettingsTab:l,hasUpdate:d,latestVersion:h,isCheckingUpdate:f,isDownloadingUpdate:B,isWebOutdated:E,showOutdatedBadge:p,checkForUpdates:y,downloadUpdate:b}=qB(),v=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__);if(!e)return null;const x=e.email||"",S=((R=e.user_metadata)==null?void 0:R.full_name)||((Y=e.user_metadata)==null?void 0:Y.name)||x.split("@")[0]||"User",L=((H=e.user_metadata)==null?void 0:H.avatar_url)||"",N=S.substring(0,2).toUpperCase(),O=j=>{l(j),s(!0)},[M,T]=J.useState(!1),[U,P]=J.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx(oDe,{children:m.jsx(Nge,{children:m.jsxs(fy,{children:[m.jsx(y3,{render:m.jsxs($K,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[m.jsxs("div",{className:"relative",children:[m.jsxs(oZt,{className:"h-8 w-8 rounded-lg",children:[m.jsx(sZt,{src:L,alt:S}),m.jsx(lZt,{className:"rounded-lg",children:N})]}),p&&m.jsx("span",{className:"absolute -top-1 -right-1 flex size-3 rounded-full bg-amber-500 ring-2 ring-sidebar",title:v?`Update available: v${h||"?"}`:E?`New version available: v${h||"?"}. You're on v3.1.2. Pull latest Docker image or update your install.`:""})]}),m.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[m.jsx("span",{className:"truncate font-semibold",children:S}),m.jsx("span",{className:"truncate text-xs",children:x})]}),m.jsx(j3e,{className:"ml-auto size-4"})]})}),m.jsxs(b3,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:u?"bottom":"right",align:"end",sideOffset:4,children:[m.jsx(ble,{children:m.jsx(MiA,{className:"p-0 font-normal",children:m.jsx(ble,{children:m.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[m.jsxs(oZt,{className:"h-8 w-8 rounded-lg",children:[m.jsx(sZt,{src:L,alt:S}),m.jsx(lZt,{className:"rounded-lg",children:N})]}),m.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[m.jsx("span",{className:"truncate font-semibold",children:S}),m.jsx("span",{className:"truncate text-xs",children:x})]})]})})})}),m.jsx(GI,{}),m.jsxs(ble,{children:[m.jsxs(dc,{onClick:()=>O(o?"appearance":"account"),className:"cursor-pointer",disabled:!o&&!n,children:[m.jsx(MAe,{className:"mr-2 size-4"}),"Settings"]}),o&&m.jsxs(dc,{onClick:()=>T(!0),className:"cursor-pointer",children:[m.jsx(YQ,{className:"mr-2 size-4"}),"Backup Data"]}),m.jsx(GI,{}),m.jsxs(dc,{onClick:()=>P(!0),className:"cursor-pointer",children:[d?m.jsx(Ej,{className:"mr-2 size-4 text-emerald-400"}):E?m.jsx(T3e,{className:"mr-2 size-4 text-amber-500"}):m.jsx(bF,{className:"mr-2 size-4"}),"About",p&&m.jsx("span",{className:`ml-auto flex size-2 rounded-full ${d?"bg-emerald-400":"bg-amber-500"}`})]}),m.jsxs(dc,{render:m.jsx("a",{href:"https://github.com/hadziqmtqn/erd-builder-pro",target:"_blank",rel:"noopener noreferrer"}),className:"cursor-pointer",children:[m.jsx(V3e,{className:"mr-2 size-4"}),"Github"]}),m.jsxs(dc,{onClick:i,className:"cursor-pointer",children:[m.jsx(hwe,{className:"mr-2 size-4"}),"Feedback"]})]}),m.jsx(GI,{}),m.jsx(ble,{children:m.jsxs(dc,{onClick:()=>n&&A("trash"),disabled:!n,className:`text-destructive focus:bg-accent focus:text-destructive cursor-pointer ${!n&&"opacity-50 cursor-not-allowed"}`,children:[m.jsx(Qg,{className:"mr-2 size-4"}),"Trash"]})}),m.jsx(GI,{}),!v&&m.jsxs(dc,{onClick:()=>n&&t(),disabled:!n,className:`cursor-pointer ${!n&&"opacity-50 cursor-not-allowed"}`,title:n?"":"Logging out while offline may cause data loss of unsynced changes",children:[m.jsx(cwe,{className:"mr-2 size-4"}),"Log out"]})]})]})})}),m.jsx(Uta,{open:M,onOpenChange:T}),m.jsx(kvn,{open:U,onOpenChange:P,hasUpdate:d,latestVersion:h,isChecking:f,isDownloading:B,onCheckUpdate:y,onDownload:b})]})}function Tta({teams:e}){const{isMobile:t}=LJ(),A=AS(),n=e[0];return m.jsx(oDe,{children:m.jsx(Nge,{children:m.jsxs($K,{size:"lg",onClick:()=>A("/"),className:"hover:bg-accent/50 active:bg-accent/70 transition-colors cursor-pointer",children:[m.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground",children:m.jsx(n.logo,{className:"size-4"})}),m.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[m.jsx("span",{className:"truncate font-semibold",children:n.name}),m.jsx("span",{className:"truncate text-xs",children:n.plan})]})]})})})}const cZt=({isOpen:e,onOpenChange:t,mode:A="move-to-trash",activeDocument:n,view:i,deleteDiagram:u,deleteNote:o,deleteDrawing:s,deleteFlowchart:l,deleteProject:d,fetchTrash:h,itemType:f,onConfirm:B,onAfterDelete:E})=>{const p=async()=>{if(A==="permanent-delete"){B==null||B(),E==null||E();return}if(B){B(),E==null||E();return}const v=i==="erd"||i==="notes"||i==="flowchart"||i==="drawings"?(n==null?void 0:n.uid)??(n==null?void 0:n.id):n==null?void 0:n.id;v&&(i==="erd"?await(u==null?void 0:u(v)):i==="notes"?await(o==null?void 0:o(String(v))):i==="drawings"?await(s==null?void 0:s(v)):i==="flowchart"?await(l==null?void 0:l(v)):i==="project"&&await(d==null?void 0:d(v)),h==null||h(),t(!1),E==null||E())},y=f==="erd"?"diagram":f==="notes"?"note":f==="drawings"?"drawing":f==="project"?"workspace":"item";if(A==="permanent-delete"){const v=f==="project";return m.jsx(DF,{open:e,onOpenChange:t,children:m.jsxs(vF,{size:"sm",className:"max-w-[400px]",children:[m.jsxs(kF,{children:[m.jsx(Rge,{className:"bg-destructive/10",children:m.jsx(p4,{className:"w-5 h-5 text-destructive"})}),m.jsx(SF,{children:"Are you absolutely sure?"})]}),m.jsx(xF,{children:m.jsx(Qne,{children:v?m.jsxs(m.Fragment,{children:["This action cannot be undone. Deleting this workspace will also permanently delete all",m.jsx("strong",{children:" notes, diagrams, drawings, and flowcharts"})," inside it."]}):m.jsxs(m.Fragment,{children:["This action cannot be undone. This will permanently delete the ",m.jsx("strong",{children:y})," from our servers."]})})}),m.jsxs(FF,{children:[m.jsx(ex,{onClick:()=>t(!1),children:"Cancel"}),m.jsx(zN,{onClick:p,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Permanently Delete"})]})]})})}const b=i!=="project";return m.jsx(DF,{open:e,onOpenChange:t,children:m.jsxs(vF,{size:"sm",className:"max-w-[400px]",children:[m.jsxs(kF,{children:[m.jsx(Rge,{className:"bg-destructive/10",children:m.jsx(Qg,{className:"w-5 h-5 text-destructive"})}),m.jsx(SF,{children:b?"Move to Trash?":"Delete Workspace?"})]}),m.jsx(xF,{children:m.jsx(Qne,{children:b?m.jsxs(m.Fragment,{children:["Are you sure you want to move ",m.jsx("strong",{children:(n==null?void 0:n.title)||(n==null?void 0:n.name)||"this item"})," to trash?",m.jsx("br",{}),"You can restore it later from the trash bin."]}):m.jsxs(m.Fragment,{children:["This will move the workspace and all its contents to trash.",m.jsx("br",{}),"You can restore it later from the trash bin."]})})}),m.jsxs(FF,{children:[m.jsx(ex,{onClick:()=>t(!1),children:"Cancel"}),m.jsx(zN,{onClick:p,children:b?"Move to Trash":"Delete"})]})]})})},Hta=J.memo(({projects:e,view:t,onViewChange:A,onNoteSelect:n,onDrawingSelect:i,onProjectCreate:u,onProjectUpdate:o,onProjectDelete:s,onLogout:l,onWorkspaceFilter:d,selectedWorkspaceUid:h,searchQuery:f,onSearchChange:B,isInstallable:E,onInstall:p,isProjectsLoading:y,user:b,isOnline:v,onOpenFeedback:x,...S})=>{const{state:L,setOpen:N}=LJ(),O=L==="collapsed",M=J.useRef(null),[T,U]=J.useState(null),[P,R]=J.useState(""),[Y,H]=J.useState(null),[j,K]=J.useState(!1),[W,q]=J.useState(""),ee=[{title:"Notes",url:"#",icon:ZI,iconClassName:"text-yellow-400",isActive:t==="notes",onClick:()=>A("notes",!0)},{title:"ERD Builder",url:"#",icon:Z0,iconClassName:"text-blue-400",isActive:t==="erd",onClick:()=>A("erd",!0)},{title:"Flowchart",url:"#",icon:qk,iconClassName:"text-green-400",isActive:t==="flowchart",onClick:()=>A("flowchart",!0)},{title:"Drawings",url:"#",icon:Wk,iconClassName:"text-purple-400",isActive:t==="drawings",onClick:()=>A("drawings",!0)}],V=e.filter(re=>!re.is_deleted),Z=(re,ae)=>{const ne=re??(ae!=null?String(ae):null);A(t,!0,ne)};return m.jsxs(m.Fragment,{children:[m.jsxs(V5n,{collapsible:"icon",...S,children:[m.jsxs(UTi,{children:[m.jsx(Tta,{teams:[{name:"ERD Builder Pro",logo:Z0,plan:"Workspace"}]}),m.jsx(Ict,{className:"py-0 group-data-[collapsible=icon]:hidden",children:m.jsxs(vWt,{className:"relative",children:[m.jsx(X5n,{ref:M,placeholder:"search workspace",className:"pl-8",value:f,onChange:re=>B(re.target.value),disabled:!v}),m.jsx(_D,{className:"pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 select-none text-muted-foreground transition-opacity group-disabled:opacity-50"})]})}),m.jsxs(Ict,{className:"group-data-[collapsible=icon]:p-0",children:[m.jsxs(DWt,{className:"flex items-center justify-between",children:["Features",!v&&m.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-destructive/10 text-[10px] font-bold text-destructive uppercase tracking-wider",children:[m.jsx("span",{className:"w-1 h-1 rounded-full bg-destructive animate-pulse"}),"Offline"]})]}),m.jsx(Sta,{items:ee})]})]}),m.jsx(e6n,{children:m.jsxs(Ict,{className:"px-4 group-data-[collapsible=icon]:p-2",children:[m.jsxs(DWt,{className:"flex items-center justify-between",children:[m.jsx("span",{children:"Workspaces"}),m.jsx(u3,{children:m.jsxs(HB,{children:[m.jsx(YB,{className:"hover:bg-muted hover:text-foreground rounded-md p-0.5 cursor-pointer",onClick:()=>{q(""),K(!0)},children:m.jsx(jC,{className:"h-3.5 w-3.5"})}),m.jsx(PB,{side:"right",children:"Create Workspace"})]})})]}),m.jsx(vWt,{children:m.jsxs(oDe,{children:[m.jsx(Nge,{children:m.jsxs($K,{tooltip:"All Workspaces",isActive:h===null||h==="",onClick:()=>Z(null),children:[m.jsx(SN,{className:"h-4 w-4 shrink-0"}),m.jsx("span",{children:"All Workspaces"})]})}),y?m.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground animate-pulse group-data-[collapsible=icon]:hidden",children:"Loading workspaces..."}):V.length===0?m.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground group-data-[collapsible=icon]:hidden",children:"No workspaces yet"}):V.map(re=>m.jsx(Nge,{children:m.jsxs($K,{tooltip:re.name,isActive:h===re.uid||String(h??"")===String(re.id??""),onClick:()=>Z(re.uid,re.id),children:[m.jsx(SN,{className:"h-4 w-4 shrink-0"}),m.jsx("span",{className:"truncate flex-1 text-left",children:re.name}),m.jsx("span",{onClick:ae=>ae.stopPropagation(),children:m.jsxs(fy,{children:[m.jsx(y3,{nativeButton:!1,render:m.jsx("span",{className:"p-1 rounded hover:bg-accent/50 cursor-pointer inline-flex items-center justify-center",children:m.jsx(ny,{className:"h-3.5 w-3.5"})})}),m.jsxs(b3,{align:"end",children:[m.jsxs(dc,{onClick:()=>{R(re.name),U(re)},children:[m.jsx(M5,{className:"h-3.5 w-3.5 mr-2"}),"Edit"]}),m.jsx(GI,{}),m.jsxs(dc,{onClick:()=>H(re),children:[m.jsx(Qg,{className:"h-3.5 w-3.5 mr-2 text-destructive"}),"Delete"]})]})]})})]})},re.uid??re.id))]})})]})}),m.jsxs(GTi,{children:[E&&m.jsx("div",{className:Xn("px-3 mb-2",O&&"px-0 flex justify-center"),children:m.jsx(u3,{children:m.jsxs(HB,{children:[m.jsxs(YB,{className:Xn("inline-flex items-center justify-center rounded-lg border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 cursor-pointer [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","border-primary/20 bg-primary/5 hover:bg-primary/10 text-primary transition-all duration-300",O?"size-9 p-0 justify-center":"w-full justify-start gap-2 h-9 px-2.5"),onClick:p,children:[m.jsx(Xk.div,{animate:{rotate:[0,15,-15,0]},transition:{duration:2,repeat:1/0},children:m.jsx(Z0,{className:"w-4 h-4"})}),!O&&m.jsx("span",{children:"Install App"})]}),O&&m.jsx(PB,{side:"right",children:"Install App"})]})})}),m.jsx("div",{className:Xn("px-3 mb-2",O&&"px-0 flex justify-center"),children:m.jsx(u3,{children:m.jsxs(HB,{children:[m.jsxs(YB,{className:Xn("inline-flex items-center justify-center rounded-lg border border-transparent text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 cursor-pointer [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","border-red-200 dark:border-red-900/40 bg-red-50 dark:bg-red-950/30 hover:bg-red-100 dark:hover:bg-red-950/50 text-red-700 dark:text-red-400 transition-all duration-300",O?"size-9 p-0 justify-center":"w-full justify-start gap-2 h-9 px-2.5"),onClick:()=>window.open("https://trakteer.id/khadziq_muttaqin/tip","_blank","noopener,noreferrer"),children:[m.jsx(iwe,{className:"w-4 h-4"}),!O&&m.jsx("span",{children:"Sponsor"})]}),O&&m.jsx(PB,{side:"right",children:"Sponsor"})]})})}),m.jsx(Gta,{user:b,onLogout:l,onViewChange:A,isOnline:v,onOpenFeedback:x})]}),m.jsx(MTi,{})]}),m.jsx(Hg,{open:T!==null,onOpenChange:re=>{re||U(null)},children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsx(ah,{children:m.jsx(Yg,{children:"Rename Workspace"})}),m.jsx(G1,{children:m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"rename-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),m.jsx(Wo,{id:"rename-project-input",type:"text",className:"h-10",value:P,onChange:re=>R(re.target.value),onKeyDown:re=>{re.key==="Enter"&&P.trim()&&T&&(o(T.id,P.trim()),U(null))},autoFocus:!0})]})}),m.jsxs(ep,{children:[m.jsx(lht,{render:m.jsx(VA,{variant:"outline",className:"h-9"}),children:"Cancel"}),m.jsx(VA,{className:"h-9 px-6",disabled:!P.trim(),onClick:()=>{T&&P.trim()&&(o(T.id,P.trim()),U(null))},children:"Save Changes"})]})]})}),m.jsx(Hg,{open:j,onOpenChange:K,children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsx(ah,{children:m.jsx(Yg,{children:"Create Workspace"})}),m.jsx(G1,{children:m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"create-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),m.jsx(Wo,{id:"create-project-input",type:"text",className:"h-10",value:W,onChange:re=>q(re.target.value),onKeyDown:re=>{re.key==="Enter"&&W.trim()&&(u(W.trim()),K(!1),q(""))},autoFocus:!0})]})}),m.jsxs(ep,{children:[m.jsx(lht,{render:m.jsx(VA,{variant:"outline",className:"h-9"}),children:"Cancel"}),m.jsx(VA,{className:"h-9 px-6",disabled:!W.trim(),onClick:()=>{W.trim()&&(u(W.trim()),K(!1),q(""))},children:"Create"})]})]})}),m.jsx(cZt,{isOpen:Y!==null,onOpenChange:re=>{re||H(null)},mode:"move-to-trash",view:"project",activeDocument:Y?{id:Y.id,name:Y.name}:void 0,deleteProject:s,onAfterDelete:()=>H(null)})]})}),PC=J.forwardRef(({className:e,...t},A)=>m.jsx("label",{ref:A,"data-slot":"label",className:Xn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t}));PC.displayName="Label";function Yta({isOpen:e,onOpenChange:t,documentType:A,documentUid:n,documentId:i,documentTitle:u,isPublicView:o=!1,initialSettings:s,onSettingsSaved:l}){const[d,h]=Ot.useState((s==null?void 0:s.share_token)||""),[f,B]=Ot.useState(!1),[E,p]=Ot.useState((s==null?void 0:s.is_public)||!1),[y,b]=Ot.useState(""),[v,x]=Ot.useState(!1);Ot.useEffect(()=>{if(s!=null&&s.expiry_date){const U=new Date(s.expiry_date),P=new Date,R=U.getTime()-P.getTime(),Y=Math.ceil(R/(1e3*60*60*24));Y>0&&b(Y.toString())}h((s==null?void 0:s.share_token)||""),p((s==null?void 0:s.is_public)||!1)},[s]);const L={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[A]||A,N=`${window.location.origin}/view/${L}/${n}`,O=()=>{navigator.clipboard.writeText(N),B(!0),gA.success("Link copied to clipboard!"),setTimeout(()=>B(!1),2e3)},M=()=>{const U=Math.random().toString(36).substring(2,10).toUpperCase();h(U),gA.info("Secure token generated")},T=async()=>{x(!0);try{const U=A==="erd"?"diagrams":A==="flowchart"?"flowcharts":A;let P=null;if(y&&!isNaN(parseInt(y))){const Y=new Date;Y.setDate(Y.getDate()+parseInt(y)),P=Y.toISOString()}if(!(await vr(`/api/${U}/${i}/share`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_public:E,share_token:d,expiry_date:P})})).ok)throw new Error("Failed to save settings");gA.success("Sharing settings updated!"),l&&l(),t(!1)}catch(U){gA.error(U.message||"Something went wrong")}finally{x(!1)}};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-md",children:[m.jsxs(ah,{children:[m.jsx(Yg,{children:o?"Share Document":`Share "${u}"`}),m.jsx(ip,{children:o?"Share this link with others to view this document.":E?"Anyone with this link can view this document. No account required.":"This document is currently private. Only you can access it."})]}),m.jsxs(G1,{className:"space-y-4",children:[!o&&m.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30 transition-colors hover:bg-muted/50",children:[m.jsxs("div",{className:"space-y-0.5",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[E?m.jsx(zk,{className:"w-4 h-4 text-primary"}):m.jsx(TD,{className:"w-4 h-4 text-muted-foreground"}),m.jsx(PC,{htmlFor:"public-status",className:"text-sm font-bold",children:"Public Access"})]}),m.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Enable sharing via public link"})]}),m.jsx("input",{id:"public-status",type:"checkbox",checked:E,onChange:U=>p(U.target.checked),className:"w-4 h-4 cursor-pointer accent-primary"})]}),m.jsxs("div",{className:`space-y-4 transition-all duration-300 ${E||o?"opacity-100":"opacity-40 pointer-events-none grayscale-[0.5]"}`,children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx(PC,{htmlFor:"share-link",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Public Link"}),m.jsxs("div",{className:"flex items-center space-x-2",children:[m.jsx(Wo,{id:"share-link",readOnly:!0,value:N,className:"flex-1 bg-muted/20 font-mono text-xs"}),m.jsx(VA,{onClick:O,size:"icon",variant:"outline",className:"shrink-0 cursor-pointer hover:bg-primary/10 hover:text-primary transition-colors",disabled:!E&&!o,children:f?m.jsx(Oh,{className:"w-4 h-4 text-green-500"}):m.jsx(E3,{className:"w-4 h-4"})})]})]}),!o&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"space-y-2 pt-2",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(PC,{htmlFor:"access-token",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Access Token (Optional)"}),m.jsxs(VA,{variant:"link",size:"sm",onClick:M,className:"h-auto p-0 text-[10px] uppercase font-bold tracking-tighter cursor-pointer text-primary hover:no-underline",disabled:!E,children:[m.jsx(v4,{className:"w-3 h-3 mr-1"}),"Generate"]})]}),m.jsx(Wo,{id:"access-token",placeholder:"Enter or generate a token...",value:d,onChange:U=>h(U.target.value),disabled:!E,className:"font-mono text-xs"})]}),m.jsxs("div",{className:"space-y-2 pt-2",children:[m.jsx(PC,{htmlFor:"valid-until",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Duration (Days)"}),m.jsx(Wo,{id:"valid-until",type:"number",placeholder:"Forever",value:y,onChange:U=>b(U.target.value),disabled:!E,className:"text-xs"})]})]})]})]}),m.jsx(ep,{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:o?m.jsx(VA,{type:"button",onClick:()=>t(!1),className:"cursor-pointer w-full sm:w-auto font-bold",children:"Close"}):m.jsxs(m.Fragment,{children:[m.jsx(VA,{variant:"ghost",onClick:()=>t(!1),className:"cursor-pointer order-2 sm:order-1 font-semibold",disabled:v,children:"Cancel"}),m.jsx(VA,{type:"button",onClick:T,className:"cursor-pointer order-1 sm:order-2 font-bold min-w-[120px]",disabled:v,children:v?m.jsxs(m.Fragment,{children:[m.jsx(v4,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})})]})})}const Pta=({onShare:e,onRename:t,onDelete:A,onDuplicate:n,onExportAll:i,onExportSQL:u,onExportPDF:o,onExportImage:s,onExportMarkdown:l,onCopyMarkdown:d,onImportMarkdown:h,isOnline:f,isPublicView:B=!1,isPublic:E=!1,activeFileUid:p,documentType:y,noteContent:b})=>{const v=N=>N.replace(/<[^>]+>/g,"").replace(/&[^;]+;/g," ").trim(),S=(N=>{const O=N?v(N):"";if(!O)return{words:0,sentences:0,paragraphs:0,characters:0};const M=O.split(/\s+/).filter(Boolean).length,T=O.split(/[.!?]+(?:\s|$)/).filter(R=>R.trim().length>0).length,U=N?(N.match(/<p[^>]*>[\s\S]*?<\/p>/g)||[]).length||O.split(/\n\s*\n/).filter(Boolean).length:O.split(/\n\s*\n/).filter(Boolean).length,P=O.replace(/\s/g,"").length;return{words:M,sentences:T,paragraphs:U,characters:P}})(b),L=()=>{if(!p){gA.error("Document link not available");return}const O={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[y]||y,M=`${window.location.origin}/view/${O}/${p}`;navigator.clipboard.writeText(M),gA.success("Public share link copied to clipboard")};return m.jsx("div",{className:"flex items-center gap-1 sm:gap-2",children:m.jsxs(fy,{children:[m.jsx(y3,{render:m.jsx(VA,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:bg-muted/80 hover:text-foreground hover:shadow-sm active:scale-95 transition-all duration-200",children:m.jsx(ny,{className:"h-4 w-4"})})}),m.jsxs(b3,{align:"end",className:"w-56",children:[B?m.jsxs(dc,{onClick:L,className:"gap-2 cursor-pointer",children:[m.jsx(SAe,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Copy Public Link"})]}):m.jsxs(m.Fragment,{children:[m.jsxs(dc,{disabled:!f,onClick:e,className:"gap-2 cursor-pointer",children:[m.jsx(RAe,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Share"})]}),E&&m.jsxs(dc,{disabled:!f,onClick:L,className:"gap-2 cursor-pointer",children:[m.jsx(SAe,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Copy Public Link"})]}),m.jsx(GI,{}),m.jsxs(dc,{disabled:!f,onClick:t,className:"gap-2 cursor-pointer",children:[y==="erd"?m.jsx(xce,{className:"h-4 w-4 text-muted-foreground"}):m.jsx(bj,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:y==="erd"?"Settings":"Edit Document"})]}),m.jsx(GI,{}),m.jsxs(dc,{disabled:!f,onClick:A,className:"gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer",children:[m.jsx(Qg,{className:"h-4 w-4"}),m.jsx("span",{children:"Move to Trash"})]})]}),(y==="notes"||y==="drawings")&&!B&&m.jsxs(m.Fragment,{children:[m.jsx(GI,{}),m.jsxs(dc,{disabled:!f,onClick:n,className:"gap-2 cursor-pointer",children:[m.jsx(E3,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Duplicate"})]})]}),y==="erd"&&!B&&m.jsxs(m.Fragment,{children:[m.jsx(GI,{}),m.jsxs(dc,{onClick:i,className:"gap-2 cursor-pointer",children:[m.jsx(YQ,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Export All"})]})]}),y==="notes"&&!B&&m.jsxs(m.Fragment,{children:[m.jsx(GI,{}),m.jsx(dc,{disabled:!f,onClick:d,className:"gap-2 cursor-pointer flex items-center",children:m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(E3,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Copy Markdown"})]})}),m.jsxs(dc,{disabled:!f,onClick:h,className:"gap-2 cursor-pointer flex items-center",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(LN,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Import"})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),m.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"I"})]})]}),m.jsxs(dc,{disabled:!f,onClick:l,className:"gap-2 cursor-pointer flex items-center",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(YQ,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Export"})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),m.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),m.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"E"})]})]}),m.jsx(GI,{}),m.jsxs(IHi,{children:[m.jsxs(pHi,{className:"gap-2 cursor-pointer",children:[m.jsx(Bj,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("span",{children:"Text Stats"})]}),m.jsx(QHi,{className:"w-52 p-1",children:m.jsxs("div",{className:"px-3 py-1.5 space-y-1",children:[m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Words"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.words.toLocaleString()})]}),m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Sentences"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.sentences.toLocaleString()})]}),m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Paragraphs"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.paragraphs.toLocaleString()})]}),m.jsx(GI,{className:"my-1.5"}),m.jsxs("div",{className:"flex items-center justify-between text-xs",children:[m.jsx("span",{className:"text-muted-foreground",children:"Characters"}),m.jsx("span",{className:"font-medium tabular-nums",children:S.characters.toLocaleString()})]})]})})]})]})]})]})})},Nvn=J.createContext(void 0);function dDe(e){const t=J.useContext(Nvn);if(t===void 0&&!e)throw new Error(Cc(47));return t}function _ta(){return{...AEt(),disabled:!1,modal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}const jta={...nEt,disabled:Si(e=>e.disabled),instantType:Si(e=>e.instantType),openMethod:Si(e=>e.openMethod),openChangeReason:Si(e=>e.openChangeReason),modal:Si(e=>e.modal),stickIfOpen:Si(e=>e.stickIfOpen),titleElementId:Si(e=>e.titleElementId),descriptionElementId:Si(e=>e.descriptionElementId),openOnHover:Si(e=>e.openOnHover),closeDelay:Si(e=>e.closeDelay),hasViewport:Si(e=>e.hasViewport)};class baA extends Z6e{constructor(A){const n={..._ta(),...A};n.open&&(A==null?void 0:A.mounted)===void 0&&(n.mounted=!0);super(n,{popupRef:J.createRef(),backdropRef:J.createRef(),internalBackdropRef:J.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:J.createRef(),beforeContentFocusGuardRef:J.createRef(),stickIfOpenTimeout:new ox,triggerElements:new nhe},jta);ra(this,"setOpen",(A,n)=>{var h,f;const i=n.reason===i2,u=n.reason===JN&&n.event.detail===0,o=!A&&(n.reason===$6e||n.reason==null);if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},(f=(h=this.context).onOpenChange)==null||f.call(h,A,n),n.isCanceled)return;const s={open:A,nativeEvent:n.event,reason:n.reason,nested:this.state.nested,triggerElement:n.trigger},l=this.state.floatingRootContext.context.events;l==null||l.emit("openchange",s);const d=()=>{var p;const B={open:A,openChangeReason:n.reason},E=((p=n.trigger)==null?void 0:p.id)??null;(E||A)&&(B.activeTriggerId=E,B.activeTriggerElement=n.trigger??null),this.update(B)};i?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start($wn,()=>{this.set("stickIfOpen",!1)}),Ul.flushSync(d)):d(),u||o?this.set("instantType",u?"click":"dismiss"):n.reason===$N?this.set("instantType","focus"):this.set("instantType",void 0)});ra(this,"disposeEffect",()=>this.context.stickIfOpenTimeout.disposeEffect())}static useStore(A,n){const i=XI(()=>new baA(n)).current,u=A??i;return j6e(i.disposeEffect),u}}function _nn({props:e}){const{children:t,open:A,defaultOpen:n=!1,onOpenChange:i,onOpenChangeComplete:u,modal:o=!1,handle:s,triggerId:l,defaultTriggerId:d=null}=e,h=baA.useStore(s==null?void 0:s.store,{modal:o,open:n,openProp:A,activeTriggerId:d,triggerIdProp:l});P6e(()=>{A===void 0&&h.state.open===!1&&n===!0&&h.update({open:!0,activeTriggerId:d})}),h.useControlledProp("openProp",A),h.useControlledProp("triggerIdProp",l);const f=h.useState("open"),B=h.useState("positionerElement"),E=h.useState("payload"),p=h.useState("openChangeReason");h.useContextCallback("onOpenChange",i),h.useContextCallback("onOpenChangeComplete",u);const{openMethod:y,triggerProps:b}=wEt(f);eEt(h);const{forceUnmount:v}=tEt(f,h,()=>{h.update({stickIfOpen:!0,openChangeReason:null})});mEt(f&&o===!0&&p!==i2&&y!=="touch",B),J.useEffect(()=>{f||h.context.stickIfOpenTimeout.clear()},[h,f]);const x=J.useCallback(j=>{const K=Eo(j);return K.preventUnmountOnClose=()=>{h.set("preventUnmountingOnClose",!0)},K},[h]),S=J.useCallback(()=>{h.setOpen(!1,x($Bt))},[h,x]);J.useImperativeHandle(e.actionsRef,()=>({unmount:v,close:S}),[v,S]);const L=rEt({popupStore:h,onOpenChange:h.setOpen}),N=W6e(L,{outsidePressEvent:{mouse:o==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),O=OrA(L),{getReferenceProps:M,getFloatingProps:T,getTriggerProps:U}=oH([N,O]),P=J.useMemo(()=>M(b),[M,b]),R=J.useMemo(()=>U(b),[U,b]),Y=J.useMemo(()=>T(),[T]);h.useSyncedValues({modal:o,openMethod:y,activeTriggerProps:P,inactiveTriggerProps:R,popupProps:Y,floatingRootContext:L,nested:dM()!=null});const H=J.useMemo(()=>({store:h}),[h]);return m.jsx(Nvn.Provider,{value:H,children:typeof t=="function"?t({payload:E}):t})}function Kta(e){return dDe(!0)?m.jsx(_nn,{props:e}):m.jsx(cyn,{children:m.jsx(_nn,{props:e})})}const Jta=300,$ta=J.forwardRef(function(t,A){const{render:n,className:i,disabled:u=!1,nativeButton:o=!0,handle:s,payload:l,openOnHover:d=!1,delay:h=Jta,closeDelay:f=0,id:B,...E}=t,p=dDe(!0),y=(s==null?void 0:s.store)??(p==null?void 0:p.store);if(!y)throw new Error(Cc(74));const b=R4(B),v=y.useState("isTriggerActive",b),x=y.useState("floatingRootContext"),S=y.useState("isOpenedByTrigger",b),L=J.useRef(null),{registerTrigger:N,isMountedByThisTrigger:O}=XBt(b,L,y,{payload:l,disabled:u,openOnHover:d,closeDelay:f}),M=y.useState("openChangeReason"),T=y.useState("stickIfOpen"),U=y.useState("openMethod"),P=iEt(x,{enabled:x!=null&&d&&(U!=="touch"||M!==JN),mouseOnly:!0,move:!1,handleClose:uEt(),restMs:h,delay:{close:f},triggerElementRef:L,isActiveTrigger:v}),R=q6e(x,{enabled:x!=null,stickIfOpen:T}),Y=oH([R]),H=y.useState("triggerProps",O),j={disabled:u,open:S},{getButtonProps:K,buttonRef:W}=iS({disabled:u,native:o}),q=J.useMemo(()=>({open(ae){return ae&&M===JN?Xdt.open(ae):V6e.open(ae)}}),[M]),ee=go("button",t,{state:j,ref:[W,A,N,L],props:[Y.getReferenceProps(),P,H,{[orA]:"",id:b},E,K],stateAttributesMapping:q}),V=J.useRef(null),Z=la(ae=>{Ul.flushSync(()=>{y.setOpen(!1,Eo($N,ae.nativeEvent,ae.currentTarget))});const ne=Kwn(V.current);ne==null||ne.focus()}),re=la(ae=>{var ge;const ne=y.select("positionerElement");if(ne&&kAe(ae,ne))(ge=y.context.beforeContentFocusGuardRef.current)==null||ge.focus();else{Ul.flushSync(()=>{y.setOpen(!1,Eo($N,ae.nativeEvent,ae.currentTarget))});let le=jwn(y.context.triggerFocusTargetRef.current||L.current);for(;le!==null&&ls(ne,le);){const Ce=le;if(le=KBt(le),le===Ce)break}le==null||le.focus()}});return v?m.jsxs(J.Fragment,{children:[m.jsx(jK,{ref:V,onFocus:Z}),m.jsx(J.Fragment,{children:ee},b),m.jsx(jK,{ref:y.context.triggerFocusTargetRef,onFocus:re})]}):m.jsx(J.Fragment,{children:ee},b)}),Mvn=J.createContext(void 0);function zta(){const e=J.useContext(Mvn);if(e===void 0)throw new Error(Cc(45));return e}const qta=J.forwardRef(function(t,A){const{keepMounted:n=!1,...i}=t,{store:u}=dDe();return u.useState("mounted")||n?m.jsx(Mvn.Provider,{value:n,children:m.jsx(zBt,{ref:A,...i})}):null}),Rvn=J.createContext(void 0);function Wta(){const e=J.useContext(Rvn);if(!e)throw new Error(Cc(46));return e}const Zta=J.forwardRef(function(t,A){const{render:n,className:i,anchor:u,positionMethod:o="absolute",side:s="bottom",align:l="center",sideOffset:d=0,alignOffset:h=0,collisionBoundary:f="clipping-ancestors",collisionPadding:B=5,arrowPadding:E=5,sticky:p=!1,disableAnchorTracking:y=!1,collisionAvoidance:b=srA,...v}=t,{store:x}=dDe(),S=zta(),L=drA(),N=x.useState("floatingRootContext"),O=x.useState("mounted"),M=x.useState("open"),T=x.useState("openChangeReason"),U=x.useState("activeTriggerElement"),P=x.useState("modal"),R=x.useState("positionerElement"),Y=x.useState("instantType"),H=x.useState("transitionStatus"),j=x.useState("hasViewport"),K=J.useRef(null),W=VBt(R,!1,!1),q=oEt({anchor:u,floatingRootContext:N,positionMethod:o,mounted:O,side:s,sideOffset:d,align:l,alignOffset:h,arrowPadding:E,collisionBoundary:f,collisionPadding:B,sticky:p,disableAnchorTracking:y,keepMounted:S,nodeId:L,collisionAvoidance:b,adaptiveOrigin:j?MrA:void 0}),ee=J.useMemo(()=>{const ge={};return M||(ge.pointerEvents="none"),{role:"presentation",hidden:!O,style:{...q.positionerStyles,...ge}}},[M,O,q.positionerStyles]),V=J.useMemo(()=>({props:ee,...q}),[ee,q]),Z=N.useState("domReferenceElement");Li(()=>{const ge=Z,le=K.current;if(ge&&(K.current=ge),le&&ge&&ge!==le){x.set("instantType",void 0);const Ce=new AbortController;return W(()=>{x.set("instantType","trigger-change")},Ce.signal),()=>{Ce.abort()}}},[Z,W,x]);const re={open:M,side:V.side,align:V.align,anchorHidden:V.anchorHidden,instant:Y},ae=J.useCallback(ge=>{x.set("positionerElement",ge)},[x]),ne=go("div",t,{state:re,props:[V.props,xJ(H),v],ref:[A,ae],stateAttributesMapping:rS});return m.jsxs(Rvn.Provider,{value:V,children:[O&&P===!0&&T!==i2&&m.jsx(QEt,{ref:x.context.internalBackdropRef,inert:X6e(!M),cutout:U}),m.jsx(lyn,{id:L,children:ne})]})}),Vta=J.createContext(void 0);function Xta(){const[e,t]=J.useState(0),A=la(()=>(t(i=>i+1),()=>{t(i=>Math.max(0,i-1))}));return{context:J.useMemo(()=>({register:A}),[A]),hasClosePart:e>0}}function eAa(e){const{value:t,children:A}=e;return m.jsx(Vta.Provider,{value:t,children:A})}const tAa={...rS,...wx},AAa=J.forwardRef(function(t,A){const{className:n,render:i,initialFocus:u,finalFocus:o,...s}=t,{store:l}=dDe(),d=Wta(),h=OiA()!=null,{context:f,hasClosePart:B}=Xta(),E=l.useState("open"),p=l.useState("openMethod"),y=l.useState("instantType"),b=l.useState("transitionStatus"),v=l.useState("popupProps"),x=l.useState("titleElementId"),S=l.useState("descriptionElementId"),L=l.useState("modal"),N=l.useState("mounted"),O=l.useState("openChangeReason"),M=l.useState("activeTriggerElement"),T=l.useState("floatingRootContext");a9({open:E,ref:l.context.popupRef,onComplete(){var ee,V;E&&((V=(ee=l.context).onOpenChangeComplete)==null||V.call(ee,!0))}});const U=l.useState("disabled"),P=l.useState("openOnHover"),R=l.useState("closeDelay");LrA(T,{enabled:P&&!U,closeDelay:R});function Y(ee){return ee==="touch"?l.context.popupRef.current:!0}const H=u===void 0?Y:u,j={open:E,side:d.side,align:d.align,instant:y,transitionStatus:b},K=L!==!1&&B,W=J.useCallback(ee=>{l.set("popupElement",ee)},[l]),q=go("div",t,{state:j,ref:[A,l.context.popupRef,W],props:[v,{"aria-labelledby":x,"aria-describedby":S,onKeyDown(ee){h&&pEt.has(ee.key)&&ee.stopPropagation()}},xJ(b),s],stateAttributesMapping:tAa});return m.jsx(qBt,{context:T,openInteractionType:p,modal:K,disabled:!N||O===i2,initialFocus:H,returnFocus:o,restoreFocus:"popup",previousFocusableElement:HC(M)?M:void 0,nextFocusableElement:l.context.triggerFocusTargetRef,beforeContentFocusGuardRef:l.context.beforeContentFocusGuardRef,children:m.jsx(eAa,{value:f,children:q})})});function Uvn({...e}){return m.jsx(Kta,{"data-slot":"popover",...e})}function Gvn({...e}){return m.jsx($ta,{"data-slot":"popover-trigger",...e})}function nAa({...e}){return m.jsx(qta,{"data-slot":"popover-portal",...e})}function Tvn({className:e,align:t="center",side:A="bottom",sideOffset:n=4,...i}){return m.jsx(nAa,{children:m.jsx(Zta,{align:t,side:A,sideOffset:n,children:m.jsx(AAa,{"data-slot":"popover-content",className:Xn("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...i})})})}const rAa={note:{icon:ZI,label:"Notes"},diagram:{icon:Z0,label:"ERD"},flowchart:{icon:qk,label:"Flowchart"},drawing:{icon:Wk,label:"Drawing"}};function iAa(){const{notes:e,diagrams:t,flowcharts:A,drawings:n,activeDocument:i,handleNoteSelect:u,handleDiagramSelect:o,handleDrawingSelect:s,handleFlowchartSelect:l}=qB(),d=(i==null?void 0:i.project_id)??null,[h,f]=J.useState(!1),[B,E]=J.useState(""),p=J.useRef(null),[y,b]=J.useState(0),v=J.useMemo(()=>{if(!d)return[];const O=[],M=d,T=(e??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.title||"Untitled",type:"note"}));T.length&&O.push({label:"Notes",items:T});const U=(t??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.name||"Untitled",type:"diagram"}));U.length&&O.push({label:"ERD",items:U});const P=(A??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.title||"Untitled",type:"flowchart"}));P.length&&O.push({label:"Flowcharts",items:P});const R=(n??[]).filter(Y=>String(Y.project_id)===String(M)).map(Y=>({uid:Y.uid??String(Y.id),id:Y.id,name:Y.title||"Untitled",type:"drawing"}));return R.length&&O.push({label:"Drawings",items:R}),O},[e,t,A,n,d]),x=J.useMemo(()=>{if(!B.trim())return v;const O=B.toLowerCase();return v.map(M=>({...M,items:M.items.filter(T=>T.name.toLowerCase().includes(O))})).filter(M=>M.items.length>0)},[v,B]),S=J.useMemo(()=>x.flatMap(O=>O.items),[x]);J.useEffect(()=>{b(0)},[B]),J.useEffect(()=>{h&&setTimeout(()=>{var O;return(O=p.current)==null?void 0:O.focus()},50)},[h]),J.useEffect(()=>{const O=M=>{(M.metaKey||M.ctrlKey)&&M.key==="k"&&!M.shiftKey&&(M.preventDefault(),f(T=>!T))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[]);const L=J.useCallback(O=>{switch(f(!1),E(""),O.type){case"note":u(O.uid);break;case"diagram":o(O.id);break;case"flowchart":l(O.uid);break;case"drawing":s(O.uid);break}},[u,o,l,s]);if(!d)return null;const N=O=>{O.key==="ArrowDown"?(O.preventDefault(),b(M=>Math.min(M+1,S.length-1))):O.key==="ArrowUp"?(O.preventDefault(),b(M=>Math.max(M-1,0))):O.key==="Enter"&&S[y]&&(O.preventDefault(),L(S[y]))};return m.jsxs(Uvn,{open:h,onOpenChange:f,children:[m.jsx(Gvn,{render:m.jsxs("button",{className:"hidden md:flex items-center gap-2 h-8 px-3 rounded-lg border border-border/50 bg-muted/30 hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors text-xs min-w-[180px] max-w-[260px]",children:[m.jsx(_D,{className:"w-3.5 h-3.5 shrink-0"}),m.jsx("span",{className:"flex-1 text-left truncate",children:"Quick jump to file..."}),m.jsxs("kbd",{className:"pointer-events-none inline-flex h-4 select-none items-center gap-0.5 rounded border bg-background px-1 font-mono text-[9px] font-medium text-muted-foreground shrink-0",children:[m.jsx("span",{className:"text-[10px]",children:"⌘"}),"K"]})]})}),m.jsxs(Tvn,{align:"center",sideOffset:8,className:"w-[360px] p-0 bg-popover border border-border shadow-xl z-[10000]",children:[m.jsxs("div",{className:"flex items-center gap-2 px-3 border-b border-border",children:[m.jsx(_D,{className:"w-4 h-4 shrink-0 text-muted-foreground"}),m.jsx(Wo,{ref:p,value:B,onChange:O=>E(O.target.value),onKeyDown:N,placeholder:"Search files...",className:"h-10 border-0 bg-transparent px-0 text-sm focus-visible:ring-0 focus-visible:ring-offset-0 placeholder:text-muted-foreground/50"})]}),m.jsx("div",{className:"max-h-[320px] overflow-y-auto py-1",children:x.length===0?m.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No files found"}):x.map(O=>{var U;const M=((U=rAa[O.items[0].type])==null?void 0:U.icon)??ZI,T=O.items[0].type==="diagram"?"text-emerald-400":O.items[0].type==="flowchart"?"text-sky-400":O.items[0].type==="drawing"?"text-purple-400":"text-amber-400";return m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:[m.jsx(M,{className:`w-3 h-3 ${T}`}),O.label]}),O.items.map((P,R)=>{const Y=x.slice(0,x.indexOf(O)).reduce((j,K)=>j+K.items.length,0)+R,H=Y===y;return m.jsxs("button",{onClick:()=>L(P),onMouseEnter:()=>b(Y),className:`flex items-center gap-2 w-full px-3 py-2 text-sm text-left transition-colors ${H?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"}`,children:[m.jsx(M,{className:`w-4 h-4 shrink-0 ${T}`}),m.jsx("span",{className:"flex-1 truncate",children:P.name}),m.jsx(lT,{className:`w-3 h-3 shrink-0 transition-opacity ${H?"opacity-60":"opacity-0"}`})]},`${P.type}-${P.uid}`)})]},O.label)})})]})]})}const aAa=Ot.memo(({featureLabel:e,activeProjectName:t,activeFileName:A,view:n,hasActiveItem:i,syncError:u,isSyncing:o,isRefreshing:s,isLocalSaving:l=!1,hasPendingSyncs:d,activeFileUid:h,activeFileId:f,initialShareSettings:B,onSettingsSaved:E,isPublicView:p=!1,isOnline:y,updatedAt:b,onDelete:v,onRename:x,onSave:S,onExportAll:L,onExportSQL:N,onExportPDF:O,onExportImage:M,onExportMarkdown:T,onCopyMarkdown:U,onImportMarkdown:P,onDuplicate:R,isGuest:Y=!1,fileSearchRef:H,fileSearchQuery:j="",onFileSearchChange:K,hideFileSearch:W,breadcrumbLabel:q,noteContent:ee})=>{const V=d2(),[Z,re]=Ot.useState(!1),[ae,ne]=Ot.useState(!1),ge=V.pathname.startsWith("/table/");return Ot.useEffect(()=>{ne(window.navigator.userAgent.toLowerCase().includes("mac"))},[]),m.jsxs("header",{className:"flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-[[data-collapsible=icon]]/sidebar-wrapper:h-12 w-full overflow-hidden border-b bg-background/50 backdrop-blur-sm",children:[m.jsxs("div",{className:"flex items-center gap-2 px-4 min-w-0 flex-none",children:[!p&&m.jsxs(m.Fragment,{children:[m.jsx(NTi,{className:"-ml-1 shrink-0"}),m.jsx(j5n,{orientation:"vertical",className:"h-4 shrink-0 bg-border/50"})]}),m.jsx(A6n,{className:"min-w-0 flex items-center",children:m.jsx(n6n,{className:"flex-nowrap items-center",children:!p&&(()=>{var Ce;const le=V.pathname;if(le==="/")return m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-semibold text-foreground",children:"Dashboard"})});if(le.startsWith("/table/")){const fe={notes:"Notes",erd:"ERD Builder",drawings:"Drawings",flowchart:"Flowcharts"},we=(Ce=le.match(/^\/table\/([^/]+)$/))==null?void 0:Ce[1],me=we?fe[we]||we:"Unknown";return m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-foreground",children:me})})}if(le.startsWith("/notes/")||le.startsWith("/diagrams/")||le.startsWith("/drawings/")||le.startsWith("/flowcharts/")){const fe={notes:{label:"Notes",href:"/table/notes"},diagrams:{label:"ERD Builder",href:"/table/erd"},drawings:{label:"Drawings",href:"/table/drawings"},flowcharts:{label:"Flowcharts",href:"/table/flowchart"}},we=le.split("/")[1],me=fe[we];return m.jsxs(m.Fragment,{children:[me&&m.jsxs(m.Fragment,{children:[m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-muted-foreground",children:me.label})}),t&&m.jsx(kWt,{className:"shrink-0"})]}),t&&m.jsxs(m.Fragment,{children:[m.jsx(j8,{className:"min-w-0 shrink",children:m.jsx(GO,{className:"max-w-[80px] sm:max-w-[150px] md:max-w-[250px] truncate text-muted-foreground",children:t})}),A&&m.jsx(kWt,{className:"shrink-0"})]}),A&&m.jsxs(j8,{className:"min-w-0 shrink flex items-center gap-2",children:[m.jsx(GO,{className:"max-w-[120px] sm:max-w-[200px] md:max-w-[300px] truncate font-semibold text-foreground",children:A}),(B==null?void 0:B.is_public)&&!p&&m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs(Lf,{variant:"outline",className:"h-5 px-1.5 gap-1.5 bg-green-500/5 text-green-500 border-green-500/20 rounded-full hover:bg-green-500/10 cursor-help shadow-sm",children:[m.jsx(zk,{className:"w-2.5 h-2.5"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Public"}),m.jsx("div",{className:"w-1 h-1 rounded-full bg-green-500 animate-pulse ml-0.5"})]})}),m.jsx(PB,{side:"bottom",align:"center",className:"text-[10px] font-medium",children:"This document is shared publicly via a secret link."})]})})]}),!A&&!t&&m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-foreground",children:(me==null?void 0:me.label)||"Document"})})]})}return le.startsWith("/trash")?m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-foreground",children:"Trash"})}):q?m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-semibold text-foreground",children:q})}):m.jsx(j8,{className:"shrink-0",children:m.jsx(GO,{className:"font-medium text-muted-foreground",children:e})})})()})})]}),m.jsx("div",{className:"flex-1 flex items-center justify-center px-2",children:!y&&!p?m.jsxs("div",{className:"hidden md:flex items-center gap-2 px-3 py-1 rounded-full bg-destructive/10 border border-destructive/20 text-destructive animate-in fade-in slide-in-from-top-1 duration-500",children:[m.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-destructive animate-pulse"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",children:"Offline Mode: Navigation Disabled"})]}):null}),m.jsxs("div",{className:"px-2 sm:px-4 flex items-center gap-1 sm:gap-4",children:[V.pathname!=="/"&&m.jsx(iAa,{}),!p&&ge&&!W&&m.jsxs("div",{className:"relative flex items-center mr-1 sm:mr-2",children:[m.jsx(_D,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 select-none text-muted-foreground"}),m.jsx(Wo,{ref:H,type:"text",placeholder:"Search files...",value:j,onChange:le=>K==null?void 0:K(le.target.value),className:"h-8 w-[120px] sm:w-[180px] md:w-[220px] pl-8 pr-8 text-xs"}),m.jsx("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none flex items-center gap-0.5 opacity-40",children:m.jsxs("kbd",{className:"pointer-events-none inline-flex h-4 select-none items-center gap-0.5 rounded border bg-muted px-1 font-mono text-[9px] font-medium text-muted-foreground",children:[m.jsx("span",{className:"text-[10px]",children:ae?"⌘":"Ctrl"}),"K"]})})]}),!!V.pathname.match(/^\/(notes|diagrams|drawings|flowcharts)\/[^/]+$/)&&m.jsxs("div",{className:"flex items-center gap-1 sm:gap-4",children:[!p&&m.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 shrink-0",children:[l?m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-amber-500/10 sm:border sm:border-amber-500/20 text-amber-500 sm:shadow-sm transition-all duration-300",children:[m.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Saving..."})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium",children:"Saving changes locally..."})]})}):u?m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-destructive/10 sm:border sm:border-destructive/20 text-destructive cursor-help sm:shadow-sm transition-all duration-300",children:[m.jsx($3e,{className:"w-3.5 h-3.5"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Sync Failed"})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium max-w-[200px] text-center",children:"Changes saved locally, but cloud sync failed. We'll retry automatically."})]})}):o?m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-primary/10 sm:border sm:border-primary/20 text-primary sm:shadow-sm transition-all duration-300",children:[m.jsx(BK,{className:"w-3.5 h-3.5 animate-bounce"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Syncing..."})]}):d?m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs(VA,{variant:"ghost",size:"sm",onClick:S,disabled:!y,className:"h-6 sm:h-7 px-1 sm:px-2 gap-1 sm:gap-2 bg-primary/10 text-primary hover:bg-primary/20 hover:text-primary-foreground border border-primary/20 transition-all duration-300 sm:shadow-sm",children:[m.jsx(gT,{className:"w-3.5 h-3.5 animate-in zoom-in-50"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Save"})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium",children:m.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[m.jsx("span",{children:"Save changes to cloud"}),m.jsxs("span",{className:"opacity-50 text-[9px]",children:[ae?"⌘":"Ctrl"," + S"]})]})})]})}):m.jsx(u3,{delay:0,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"flex items-center gap-1.5 p-0.5 sm:px-2 sm:py-1 rounded-md bg-green-500/5 sm:border sm:border-green-500/10 text-green-500/60 sm:shadow-sm transition-all duration-300",children:[m.jsx(Oh,{className:"w-3.5 h-3.5"}),m.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Synced"})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] font-medium",children:"All changes are saved and synced"})]})}),s&&m.jsx("div",{className:"flex items-center gap-2 text-primary animate-pulse ml-1 sm:ml-2",children:m.jsx("div",{className:"w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin"})})]}),!p&&b&&m.jsx(u3,{delay:200,children:m.jsxs(HB,{children:[m.jsx(YB,{render:m.jsxs("div",{className:"hidden lg:flex items-center gap-1.5 text-[11px] text-muted-foreground font-medium cursor-help hover:text-foreground transition-colors",children:[m.jsx("span",{className:"opacity-50",children:"Edited"}),m.jsx("span",{children:Nk(new Date(b),"MMM dd")})]})}),m.jsx(PB,{side:"bottom",className:"text-[10px] py-1 px-2 font-mono",children:Nk(new Date(b),"eee, dd MMM yyyy HH:mm:ss")})]})}),m.jsx(Pta,{onShare:()=>y&&re(!0),onDelete:v,onRename:x,onDuplicate:R,onExportAll:L,onExportSQL:N,onExportPDF:O,onExportImage:M,onExportMarkdown:T,onCopyMarkdown:U,onImportMarkdown:P,isOnline:y,isPublicView:p,isPublic:B==null?void 0:B.is_public,activeFileUid:h,documentType:n,noteContent:ee}),h&&f&&y&&m.jsx(Yta,{isOpen:Z,onOpenChange:re,documentType:n,documentUid:h,documentId:f,documentTitle:A||"Untitled",isPublicView:p,initialSettings:B,onSettingsSaved:E})]})]})]})});function uAa({open:e,onOpenChange:t}){const[A,n]=Ot.useState(!1),[i,u]=Ot.useState(""),[o,s]=Ot.useState("suggestion"),[l,d]=Ot.useState(""),h=async f=>{if(f.preventDefault(),!!i.trim()){n(!0);try{if((await vr("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,category:o,email:l,url:window.location.href,browser:navigator.userAgent})})).ok)gA.success("Feedback terkirim! Terima kasih masukannya."),t(!1),u("");else throw new Error}catch{gA.error("Gagal mengirim feedback. Coba lagi nanti.")}finally{n(!1)}}};return m.jsx(Hg,{open:e,onOpenChange:f=>{t(f),f||u("")},children:m.jsx(mg,{className:"sm:max-w-[425px] border-border bg-popover/95 backdrop-blur-xl shadow-2xl",children:m.jsxs("form",{onSubmit:h,className:"flex flex-col max-h-[inherit]",children:[m.jsxs(ah,{children:[m.jsx(Yg,{className:"text-xl font-bold",children:"Kirim Masukan"}),m.jsx(ip,{className:"text-sm text-muted-foreground",children:"Bantu kami membuat ERD Builder Pro jadi lebih baik. Saran Anda sangat berharga!"})]}),m.jsxs(G1,{className:"space-y-5",children:[m.jsxs("div",{className:"grid gap-2",children:[m.jsx(PC,{htmlFor:"category",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Tipe Masukan"}),m.jsxs(KB,{value:o,onValueChange:f=>f&&s(f),children:[m.jsx(_f,{id:"category",className:"bg-white/5 border-white/10 focus:ring-primary/50",children:m.jsx(JB,{placeholder:"Pilih tipe",children:o==="suggestion"?"Saran Fitur":o==="bug"?"Lapor Bug":o==="other"?"Kritik / Lainnya":o})}),m.jsxs($B,{className:"bg-popover border-border text-popover-foreground",children:[m.jsx(e0,{value:"suggestion",className:"focus:bg-muted",children:"Saran Fitur"}),m.jsx(e0,{value:"bug",className:"focus:bg-muted text-destructive",children:"Lapor Bug"}),m.jsx(e0,{value:"other",className:"focus:bg-muted",children:"Kritik / Lainnya"})]})]})]}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx(PC,{htmlFor:"content",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Pesan"}),m.jsx("textarea",{id:"content",autoComplete:"off",className:"flex min-h-[140px] w-full rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm ring-offset-background placeholder:text-muted-foreground/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-all resize-none",placeholder:"Tuliskan masukan Anda di sini...",value:i,onChange:f=>u(f.target.value),required:!0})]}),m.jsxs("div",{className:"grid gap-2",children:[m.jsx(PC,{htmlFor:"email",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email (Opsional)"}),m.jsx(Wo,{id:"email",type:"email",autoComplete:"off",placeholder:"email@contoh.com",className:"bg-muted/50 border-border focus:ring-primary/50 h-10 px-4",value:l,onChange:f=>d(f.target.value)})]})]}),m.jsxs(ep,{className:"gap-3",children:[m.jsx(VA,{variant:"ghost",type:"button",onClick:()=>t(!1),className:"hover:bg-muted",children:"Batal"}),m.jsx(VA,{type:"submit",disabled:A,className:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-lg shadow-primary/20",children:A?"Mengirim...":"Kirim Masukan"})]})]})})})}const oAa=({isOpen:e,onOpenChange:t,selectedEntity:A,deleteEntity:n,setSelectedNodeId:i})=>m.jsx(DF,{open:e,onOpenChange:t,children:m.jsxs(vF,{size:"sm",className:"max-w-[400px]",children:[m.jsxs(kF,{children:[m.jsx(Rge,{className:"bg-destructive/10",children:m.jsx(p4,{className:"w-5 h-5 text-destructive"})}),m.jsx(SF,{children:"Delete Table"})]}),m.jsx(xF,{children:m.jsxs(Qne,{children:["Are you sure you want to delete the table ",m.jsx("strong",{children:A==null?void 0:A.name}),"? This action cannot be undone."]})}),m.jsxs(FF,{children:[m.jsx(ex,{onClick:()=>t(!1),children:"Cancel"}),m.jsx(zN,{onClick:()=>{A&&(n(A.id),i(null),t(!1))},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),xHt=e=>e==="erd"?"diagram":e==="notes"?"note":e==="drawings"?"drawing":"flowchart",jnn=({isOpen:e,onOpenChange:t,mode:A="edit",view:n,activeDocument:i,newName:u,setNewName:o,projects:s,selectedProjectId:l,setSelectedProjectId:d,onCreate:h,updateDiagram:f,updateNote:B,updateDrawing:E,updateFlowchart:p,onMoveDiagramToProject:y,onMoveNoteToProject:b,onMoveDrawingToProject:v,onMoveFlowchartToProject:x,onRenameSuccess:S})=>{var O;const L=A==="create";J.useEffect(()=>{if(e&&!L&&i){const M=(i==null?void 0:i.project_id)??(i==null?void 0:i.projectId);d(M!=null?String(M):"none")}},[e]);const N=async()=>{if(!u.trim())return;if(L){h==null||h(u.trim(),l==="none"?null:l),t(!1);return}const M=n==="notes"||n==="flowchart"||n==="drawings"?i==null?void 0:i.uid:i==null?void 0:i.id;if(M&&u.trim()){const T=l==="none"?null:l,U=(i==null?void 0:i.project_id)||(i==null?void 0:i.projectId),P=u.trim()!==((i==null?void 0:i.title)||(i==null?void 0:i.name)),R=String(T)!==String(U);try{P&&(n==="erd"?await(f==null?void 0:f(M,u,{silent:!0})):n==="notes"?await(B==null?void 0:B(String(M),u,{silent:!0})):n==="drawings"?await(E==null?void 0:E(M,u,{silent:!0})):n==="flowchart"&&await(p==null?void 0:p(M,u,{silent:!0}))),R&&(n==="erd"?await(y==null?void 0:y(M,T,{silent:!0})):n==="notes"?await(b==null?void 0:b(M,T,{silent:!0})):n==="drawings"?await(v==null?void 0:v(M,T,{silent:!0})):n==="flowchart"&&await(x==null?void 0:x(M,T,{silent:!0}))),(P||R)&&S&&await S(),gA.success("Document updated successfully"),t(!1)}catch{gA.error("Failed to update document")}}};return m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsxs(ah,{children:[m.jsx(Yg,{children:L?`Create ${xHt(n)}`:"Edit Document"}),m.jsx(ip,{children:L?`Enter a name and select a workspace for your new ${xHt(n)}.`:`Update the name and project for your ${xHt(n)}.`})]}),m.jsx(G1,{children:m.jsxs("div",{className:"space-y-4",children:[m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"rename-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:L?"Name":"New Name"}),m.jsx(Wo,{id:"rename-input",type:"text",value:u,onChange:M=>o(M.target.value),onKeyDown:M=>{M.key==="Enter"&&u.trim()&&N()},autoFocus:!0})]}),m.jsxs(Ac,{children:[m.jsx(nc,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Project"}),m.jsxs(KB,{value:l,onValueChange:M=>M!==null&&d(M),children:[m.jsx(_f,{className:"h-9",children:m.jsx(JB,{children:l==="none"?"Uncategorized":((O=s.find(M=>M.id.toString()===l))==null?void 0:O.name)||"Select Project"})}),m.jsxs($B,{children:[m.jsx(e0,{value:"none",children:"Uncategorized"}),s.map(M=>m.jsx(e0,{value:M.id.toString(),children:M.name},M.id))]})]})]})]})}),m.jsxs(ep,{children:[m.jsx(lht,{render:m.jsx(VA,{variant:"outline",className:"h-9"}),children:"Cancel"}),m.jsx(VA,{disabled:!u.trim(),onClick:N,className:"h-9 px-6",children:L?"Create":"Save Changes"})]})]})})},sAa=({isOpen:e,onOpenChange:t,view:A,duplicateName:n,setDuplicateName:i,executeDuplicate:u,isRefreshing:o})=>m.jsx(Hg,{open:e,onOpenChange:t,children:m.jsxs(mg,{className:"sm:max-w-sm",children:[m.jsxs(ah,{children:[m.jsx(Yg,{children:"Duplicate Document"}),m.jsxs(ip,{children:["Create a copy of this ",A==="erd"?"diagram":A==="notes"?"note":A==="drawings"?"drawing":"flowchart","."]})]}),m.jsx(G1,{children:m.jsx("div",{className:"space-y-4",children:m.jsxs(Ac,{children:[m.jsx(nc,{htmlFor:"duplicate-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"New Name"}),m.jsx(Wo,{id:"duplicate-input",type:"text",value:n,onChange:s=>i(s.target.value),onKeyDown:s=>{s.key==="Enter"&&n.trim()&&u()},autoFocus:!0})]})})}),m.jsxs(ep,{className:"gap-2 sm:gap-0",children:[m.jsx(VA,{variant:"ghost",onClick:()=>t(!1),children:"Cancel"}),m.jsx(VA,{onClick:u,disabled:!n.trim()||o,children:o?m.jsxs(m.Fragment,{children:[m.jsx(js,{className:"mr-2 h-4 w-4 animate-spin"}),"Duplicating..."]}):"Duplicate"})]})]})});function Mk(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var FHt={exports:{}};/*!
|
|
8616
8616
|
|
|
8617
8617
|
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
|
|
8618
8618
|
<http://stuartk.com/jszip>
|
package/dist/index.html
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
})();
|
|
20
20
|
</script>
|
|
21
|
-
<script type="module" crossorigin src="/assets/index-
|
|
21
|
+
<script type="module" crossorigin src="/assets/index-OlIRVx6J.js"></script>
|
|
22
22
|
<link rel="stylesheet" crossorigin href="/assets/index-ByyJfDtW.css">
|
|
23
23
|
</head>
|
|
24
24
|
<body>
|