erdbpro 3.1.4-beta.1 → 3.1.4

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.
@@ -8641,7 +8641,7 @@ function print() { __p += __j.call(arguments, '') }
8641
8641
  `}),h+=`);
8642
8642
 
8643
8643
  `});const u=new Set;i.forEach(f=>{var x,w;const _=A.get(f.source),R=A.get(f.target);if(_&&R){const D=(x=f.sourceHandle)==null?void 0:x.replace("col-","").replace("-source-l","").replace("-source",""),M=(w=f.targetHandle)==null?void 0:w.replace("col-","").replace("-target-r","").replace("-target",""),U=_.columns.find(K=>K.id===D),H=R.columns.find(K=>K.id===M);if(U&&H){const K=`fk_${_.name}_${U.name}`.toLowerCase(),V=`${_.name}.${U.name}->${R.name}.${H.name}`;u.has(V)||(h+=`ALTER TABLE ${_.name} ADD CONSTRAINT ${K} FOREIGN KEY (${U.name}) REFERENCES ${R.name}(${H.name});
8644
- `,u.add(V))}}});const E=new Blob([h],{type:"text/plain"}),g=URL.createObjectURL(E),C=document.createElement("a");C.href=g,C.download=`${t.name.toLowerCase().replace(/\s+/g,"_")}_schema.sql`,C.click(),URL.revokeObjectURL(g)}}}function oR(s,e,t,a){if(typeof e=="function"?s!==e||!a:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(s):a?a.value:e.get(s)}function lIe(s,e,t,a,i){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}var Yoe,Kk,Cpe,u2t,pSt;const $Q="__TAURI_TO_IPC_KEY__";function J2a(s,e=!1){return window.__TAURI_INTERNALS__.transformCallback(s,e)}let Svs=class{constructor(e){Yoe.set(this,void 0),Kk.set(this,0),Cpe.set(this,[]),u2t.set(this,void 0),lIe(this,Yoe,e||(()=>{})),this.id=J2a(t=>{const a=t.index;if("end"in t){a==oR(this,Kk,"f")?this.cleanupCallback():lIe(this,u2t,a);return}const i=t.message;if(a==oR(this,Kk,"f")){for(oR(this,Yoe,"f").call(this,i),lIe(this,Kk,oR(this,Kk,"f")+1);oR(this,Kk,"f")in oR(this,Cpe,"f");){const n=oR(this,Cpe,"f")[oR(this,Kk,"f")];oR(this,Yoe,"f").call(this,n),delete oR(this,Cpe,"f")[oR(this,Kk,"f")],lIe(this,Kk,oR(this,Kk,"f")+1)}oR(this,Kk,"f")===oR(this,u2t,"f")&&this.cleanupCallback()}else oR(this,Cpe,"f")[a]=i})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){lIe(this,Yoe,e)}get onmessage(){return oR(this,Yoe,"f")}[(Yoe=new WeakMap,Kk=new WeakMap,Cpe=new WeakMap,u2t=new WeakMap,$Q)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[$Q]()}};class wd1{constructor(e,t,a){this.plugin=e,this.event=t,this.channelId=a}async unregister(){return Ki(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function dUr(s,e,t){const a=new Svs(t);try{return await Ki(`plugin:${s}|register_listener`,{event:e,handler:a}),new wd1(s,e,a.id)}catch{return await Ki(`plugin:${s}|registerListener`,{event:e,handler:a}),new wd1(s,e,a.id)}}async function Ki(s,e={},t){return window.__TAURI_INTERNALS__.invoke(s,e,t)}class Lvs{get rid(){return oR(this,pSt,"f")}constructor(e){pSt.set(this,void 0),lIe(this,pSt,e)}async close(){return Ki("plugin:resources|close",{rid:this.rid})}}pSt=new WeakMap;class X2a extends Lvs{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,t){Qvs(t);const a=new Svs;e&&(a.onmessage=e);const i=await Ki("plugin:updater|download",{onEvent:a,rid:this.rid,...t});this.downloadedBytes=new Lvs(i)}async install(){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await Ki("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(e,t){Qvs(t);const a=new Svs;e&&(a.onmessage=e),await Ki("plugin:updater|download_and_install",{onEvent:a,rid:this.rid,...t})}async close(){var e;await((e=this.downloadedBytes)==null?void 0:e.close()),await super.close()}}async function q2a(s){Qvs(s);const e=await Ki("plugin:updater|check",{...s});return e?new X2a(e):null}function Qvs(s){s!=null&&s.headers&&(s.headers=Array.from(new Headers(s.headers).entries()))}const Nd1=Object.freeze(Object.defineProperty({__proto__:null,Update:X2a,check:q2a},Symbol.toStringTag,{value:"Module"})),Dd1="erd-update-dismissed-version",kd1="erd-update-notified-version";function EUr(){return!!window.__TAURI__||!!window.__TAURI_INTERNALS__}async function HC(s,e,t){if(EUr())try{await fetch("http://localhost:3099/api/log/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:s,message:e,extra:t,timestamp:new Date().toISOString()})})}catch{}}function gUr(s,e,t){const[a,i]=ae.useState(!1),[n,A]=ae.useState(null),[h,u]=ae.useState(!1),[E,g]=ae.useState(!1),[C,f]=ae.useState(null),_=ae.useRef(s);_.current=s;const R=ae.useRef(!1),x=ae.useRef(null),w=ae.useRef(!1),D=ae.useCallback(X=>{localStorage.setItem(Dd1,X)},[]),M=ae.useCallback(X=>typeof window>"u"?!1:localStorage.getItem(Dd1)===X,[]),U=ae.useCallback(async X=>{var Z;if(HC("debug","handleDownloadUpdate called",`downloadingRef=${w.current} version=${X.version}`),w.current){HC("debug","BLOCKED: download already in progress");return}w.current=!0,g(!0),HC("info","download STARTED");const J=v0.loading("Downloading update...",{description:"Please wait, downloading the latest version."});HC("info","download_started",X.version);try{let j=0,z=0;await X.downloadAndInstall(q=>{switch(q.event){case"Started":z=q.data.contentLength||0,HC("info","download_progress",`0% of ${h2t(z)}`),v0.loading("Downloading update...",{id:J,description:`0% - ${h2t(z)}`});break;case"Progress":j+=q.data.chunkLength;const se=Math.round(j/z*100);v0.loading(`Downloading update... ${se}%`,{id:J,description:`${h2t(j)} / ${h2t(z)}`});break;case"Finished":HC("info","download_finished","ready to install");break}}),HC("info","downloadAndInstall resolved — install complete"),v0.success("Update installed successfully!",{id:J,description:"The application will now restart to apply the update.",duration:8e3}),setTimeout(async()=>{try{const{relaunch:q}=await tr(async()=>{const{relaunch:se}=await Promise.resolve().then(()=>n7n);return{relaunch:se}},[]);await q()}catch{window.location.reload()}},1e3),g(!1),w.current=!1}catch(j){const z=typeof j=="string"?j:(j==null?void 0:j.message)||((Z=j==null?void 0:j.toString)==null?void 0:Z.call(j))||JSON.stringify(j);HC("error","download_failed",z),v0.error("Update failed",{id:J,description:z||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(z).catch(()=>{})}}),g(!1),w.current=!1}},[]),H=ae.useCallback(async(X=!1)=>{var z,q;if(HC("debug","performCheck called",`isManual=${X} checkingRef=${R.current}`),!(!!window.__TAURI__||!!window.__TAURI_INTERNALS__))return HC("debug","SKIP: not Tauri"),!1;if(R.current)return HC("debug","SKIP: already checking"),!1;R.current=!0,u(!0);let Z="";try{const{getVersion:se}=await tr(async()=>{const{getVersion:ie}=await Promise.resolve().then(()=>i5a);return{getVersion:ie}},void 0);Z=await se()}catch{Z="0.0.0"}let j;X&&(j=v0.loading("Checking for updates...",{description:`ERD Builder Pro v${Z}`})),HC("info","check_started",`current=${Z} manual=${X}`);try{const se=await q2a();if(se)return i(!0),A(se.version),f(se),j&&v0.dismiss(j),!X&&(x.current===se.version||M(se.version))?(HC("debug","SKIP toast: already shown/dismissed",se.version),u(!1),R.current=!1,!0):(x.current=se.version,HC("info","update_available",`v${se.version}`),X&&localStorage.getItem(kd1)===se.version?(HC("debug","SKIP toast: already notified by auto-check",se.version),i(!0),A(se.version),f(se),(z=_.current)==null||z.call(_),u(!1),R.current=!1,!0):(HC("debug","SHOWING toast: Update Available",`v${se.version} manual=${X}`),v0.info("Update Available",{description:`New version (v${se.version}) is ready.`,duration:1/0,action:{label:"Update Now",onClick:()=>U(se)},cancel:{label:"Later",onClick:()=>D(se.version)}}),X||localStorage.setItem(kd1,se.version),(q=_.current)==null||q.call(_),u(!1),R.current=!1,!0));j&&v0.dismiss(j),X&&v0.success("You're up to date",{description:`ERD Builder Pro v${Z} is the latest version.`}),HC("info","no_update",`current=${Z}`),i(!1),A(null),f(null)}catch(se){HC("error","check_failed",(se==null?void 0:se.message)||String(se)),j&&v0.dismiss(j),X&&v0.error("Check failed",{description:"Could not check for updates. Check your internet connection."})}return u(!1),R.current=!1,!1},[M,U]),K=ae.useCallback(()=>{HC("debug","handleDownload called",`update=${C==null?void 0:C.version} downloadingRef=${w.current}`),C&&U(C)},[C,U]),V=ae.useRef(H);V.current=H;const W=ae.useCallback(()=>{HC("debug","checkNow (manual trigger)"),V.current(!0)},[]);return ae.useEffect(()=>{HC("debug","scheduling auto-check in 5s");const X=setTimeout(()=>{HC("debug","auto-check timer fired"),V.current(!1)},5e3);return()=>clearTimeout(X)},[e]),ae.useEffect(()=>{const X=()=>V.current(!0);return window.addEventListener("menu-check-update",X),()=>window.removeEventListener("menu-check-update",X)},[t]),{hasUpdate:a,latestVersion:n,isChecking:h,isDownloading:E,checkNow:W,handleDownload:K}}function h2t(s){if(s===0)return"0 B";const e=1024,t=["B","KB","MB","GB"],a=Math.floor(Math.log(s)/Math.log(e));return Math.round(s/Math.pow(e,a)*100)/100+" "+t[a]}const z2a="erd-version-check",bd1="erd-version-current",CUr=3600*1e3;function Z2a(){try{return"3.1.3"}catch{return"0.0.0"}}async function pUr(){try{const t=await fetch("/api/version/current");if(t.ok){const a=await t.json(),i=a==null?void 0:a.current;if(i&&i!=="0.0.0")return localStorage.setItem(bd1,i),i}}catch{}const s=localStorage.getItem(bd1);return s||Z2a()}function Md1(){try{const s=localStorage.getItem(z2a);if(!s)return null;const e=JSON.parse(s);return Date.now()-e.fetchedAt>CUr?null:e}catch{return null}}function IUr(s,e){try{localStorage.setItem(z2a,JSON.stringify({latest:s,current:e,fetchedAt:Date.now()}))}catch{}}function fUr(){const[s,e]=ae.useState(!1),[t,a]=ae.useState(null),[i,n]=ae.useState(Z2a()),A=ae.useRef(!1),h=ae.useCallback(async()=>{if(A.current)return;A.current=!0;const u=await pUr();n(u);const E=Md1();if(E&&E.current===u){E.latest!==u&&E.latest&&(e(!0),a(E.latest));return}try{const C=await fetch("/api/version/latest");if(!C.ok)return;const f=await C.json(),_=f==null?void 0:f.latest;if(!_)return;IUr(_,u),_!==u&&(e(!0),a(_))}catch{const g=Md1();g&&g.latest!==u&&g.latest&&(e(!0),a(g.latest))}},[]);return ae.useEffect(()=>{h()},[h]),{isOutdated:s,latestVersion:t,currentVersion:i,checkNow:h}}function _Ur(s,e){if(s.match(/^[a-z]+:\/\//i))return s;if(s.match(/^\/\//))return window.location.protocol+s;if(s.match(/^[a-z]+:/i))return s;const t=document.implementation.createHTMLDocument(),a=t.createElement("base"),i=t.createElement("a");return t.head.appendChild(a),t.body.appendChild(i),e&&(a.href=e),i.href=s,i.href}const mUr=(()=>{let s=0;const e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();function tz(s){const e=[];for(let t=0,a=s.length;t<a;t++)e.push(s[t]);return e}function XUt(s,e){const a=(s.ownerDocument.defaultView||window).getComputedStyle(s).getPropertyValue(e);return a?parseFloat(a.replace("px","")):0}function BUr(s){const e=XUt(s,"border-left-width"),t=XUt(s,"border-right-width");return s.clientWidth+e+t}function RUr(s){const e=XUt(s,"border-top-width"),t=XUt(s,"border-bottom-width");return s.clientHeight+e+t}function eAa(s,e={}){const t=e.width||BUr(s),a=e.height||RUr(s);return{width:t,height:a}}function TUr(){let s,e;try{e=process}catch{}const t=e&&e.env?e.env.devicePixelRatio:null;return t&&(s=parseInt(t,10),Number.isNaN(s)&&(s=1)),s||window.devicePixelRatio||1}const vw=16384;function yUr(s){(s.width>vw||s.height>vw)&&(s.width>vw&&s.height>vw?s.width>s.height?(s.height*=vw/s.width,s.width=vw):(s.width*=vw/s.height,s.height=vw):s.width>vw?(s.height*=vw/s.width,s.width=vw):(s.width*=vw/s.height,s.height=vw))}function qUt(s){return new Promise((e,t)=>{const a=new Image;a.decode=()=>e(a),a.onload=()=>e(a),a.onerror=t,a.crossOrigin="anonymous",a.decoding="async",a.src=s})}async function xUr(s){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(s)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function OUr(s,e,t){const a="http://www.w3.org/2000/svg",i=document.createElementNS(a,"svg"),n=document.createElementNS(a,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${t}`),i.setAttribute("viewBox",`0 0 ${e} ${t}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),i.appendChild(n),n.appendChild(s),xUr(i)}const LQ=(s,e)=>{if(s instanceof e)return!0;const t=Object.getPrototypeOf(s);return t===null?!1:t.constructor.name===e.name||LQ(t,e)};function SUr(s){const e=s.getPropertyValue("content");return`${s.cssText} content: '${e.replace(/'|"/g,"")}';`}function LUr(s){return tz(s).map(e=>{const t=s.getPropertyValue(e),a=s.getPropertyPriority(e);return`${e}: ${t}${a?" !important":""};`}).join(" ")}function QUr(s,e,t){const a=`.${s}:${e}`,i=t.cssText?SUr(t):LUr(t);return document.createTextNode(`${a}{${i}}`)}function Ud1(s,e,t){const a=window.getComputedStyle(s,t),i=a.getPropertyValue("content");if(i===""||i==="none")return;const n=mUr();try{e.className=`${e.className} ${n}`}catch{return}const A=document.createElement("style");A.appendChild(QUr(n,t,a)),e.appendChild(A)}function vUr(s,e){Ud1(s,e,":before"),Ud1(s,e,":after")}const Fd1="application/font-woff",Pd1="image/jpeg",wUr={woff:Fd1,woff2:Fd1,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Pd1,jpeg:Pd1,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function NUr(s){const e=/\.([^./]*?)$/g.exec(s);return e?e[1]:""}function OC0(s){const e=NUr(s).toLowerCase();return wUr[e]||""}function DUr(s){return s.split(/,/)[1]}function vvs(s){return s.search(/^(data:)/)!==-1}function kUr(s,e){return`data:${e};base64,${s}`}async function tAa(s,e,t){const a=await fetch(s,e);if(a.status===404)throw new Error(`Resource "${a.url}" not found`);const i=await a.blob();return new Promise((n,A)=>{const h=new FileReader;h.onerror=A,h.onloadend=()=>{try{n(t({res:a,result:h.result}))}catch(u){A(u)}},h.readAsDataURL(i)})}const lIs={};function bUr(s,e,t){let a=s.replace(/\?.*/,"");return t&&(a=s),/ttf|otf|eot|woff2?/i.test(a)&&(a=a.replace(/.*\//,"")),e?`[${e}]${a}`:a}async function SC0(s,e,t){const a=bUr(s,e,t.includeQueryParams);if(lIs[a]!=null)return lIs[a];t.cacheBust&&(s+=(/\?/.test(s)?"&":"?")+new Date().getTime());let i;try{const n=await tAa(s,t.fetchRequestInit,({res:A,result:h})=>(e||(e=A.headers.get("Content-Type")||""),DUr(h)));i=kUr(n,e)}catch(n){i=t.imagePlaceholder||"";let A=`Failed to fetch resource: ${s}`;n&&(A=typeof n=="string"?n:n.message),A&&console.warn(A)}return lIs[a]=i,i}async function MUr(s){const e=s.toDataURL();return e==="data:,"?s.cloneNode(!1):qUt(e)}async function UUr(s,e){if(s.currentSrc){const n=document.createElement("canvas"),A=n.getContext("2d");n.width=s.clientWidth,n.height=s.clientHeight,A==null||A.drawImage(s,0,0,n.width,n.height);const h=n.toDataURL();return qUt(h)}const t=s.poster,a=OC0(t),i=await SC0(t,a,e);return qUt(i)}async function FUr(s){var e;try{if(!((e=s==null?void 0:s.contentDocument)===null||e===void 0)&&e.body)return await Pqt(s.contentDocument.body,{},!0)}catch{}return s.cloneNode(!1)}async function PUr(s,e){return LQ(s,HTMLCanvasElement)?MUr(s):LQ(s,HTMLVideoElement)?UUr(s,e):LQ(s,HTMLIFrameElement)?FUr(s):s.cloneNode(!1)}const HUr=s=>s.tagName!=null&&s.tagName.toUpperCase()==="SLOT";async function GUr(s,e,t){var a,i;let n=[];return HUr(s)&&s.assignedNodes?n=tz(s.assignedNodes()):LQ(s,HTMLIFrameElement)&&(!((a=s.contentDocument)===null||a===void 0)&&a.body)?n=tz(s.contentDocument.body.childNodes):n=tz(((i=s.shadowRoot)!==null&&i!==void 0?i:s).childNodes),n.length===0||LQ(s,HTMLVideoElement)||await n.reduce((A,h)=>A.then(()=>Pqt(h,t)).then(u=>{u&&e.appendChild(u)}),Promise.resolve()),e}function YUr(s,e){const t=e.style;if(!t)return;const a=window.getComputedStyle(s);a.cssText?(t.cssText=a.cssText,t.transformOrigin=a.transformOrigin):tz(a).forEach(i=>{let n=a.getPropertyValue(i);i==="font-size"&&n.endsWith("px")&&(n=`${Math.floor(parseFloat(n.substring(0,n.length-2)))-.1}px`),LQ(s,HTMLIFrameElement)&&i==="display"&&n==="inline"&&(n="block"),i==="d"&&e.getAttribute("d")&&(n=`path(${e.getAttribute("d")})`),t.setProperty(i,n,a.getPropertyPriority(i))})}function KUr(s,e){LQ(s,HTMLTextAreaElement)&&(e.innerHTML=s.value),LQ(s,HTMLInputElement)&&e.setAttribute("value",s.value)}function VUr(s,e){if(LQ(s,HTMLSelectElement)){const a=Array.from(e.children).find(i=>s.value===i.getAttribute("value"));a&&a.setAttribute("selected","")}}function jUr(s,e){return LQ(e,Element)&&(YUr(s,e),vUr(s,e),KUr(s,e),VUr(s,e)),e}async function WUr(s,e){const t=s.querySelectorAll?s.querySelectorAll("use"):[];if(t.length===0)return s;const a={};for(let n=0;n<t.length;n++){const h=t[n].getAttribute("xlink:href");if(h){const u=s.querySelector(h),E=document.querySelector(h);!u&&E&&!a[h]&&(a[h]=await Pqt(E,e,!0))}}const i=Object.values(a);if(i.length){const n="http://www.w3.org/1999/xhtml",A=document.createElementNS(n,"svg");A.setAttribute("xmlns",n),A.style.position="absolute",A.style.width="0",A.style.height="0",A.style.overflow="hidden",A.style.display="none";const h=document.createElementNS(n,"defs");A.appendChild(h);for(let u=0;u<i.length;u++)h.appendChild(i[u]);s.appendChild(A)}return s}async function Pqt(s,e,t){return!t&&e.filter&&!e.filter(s)?null:Promise.resolve(s).then(a=>PUr(a,e)).then(a=>GUr(s,a,e)).then(a=>jUr(s,a)).then(a=>WUr(a,e))}const sAa=/url\((['"]?)([^'"]+?)\1\)/g,$Ur=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,JUr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function XUr(s){const e=s.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function qUr(s){const e=[];return s.replace(sAa,(t,a,i)=>(e.push(i),t)),e.filter(t=>!vvs(t))}async function zUr(s,e,t,a,i){try{const n=t?_Ur(e,t):e,A=OC0(e);let h;return i||(h=await SC0(n,A,a)),s.replace(XUr(e),`$1${h}$3`)}catch{}return s}function ZUr(s,{preferredFontFormat:e}){return e?s.replace(JUr,t=>{for(;;){const[a,,i]=$Ur.exec(t)||[];if(!i)return"";if(i===e)return`src: ${a};`}}):s}function aAa(s){return s.search(sAa)!==-1}async function iAa(s,e,t){if(!aAa(s))return s;const a=ZUr(s,t);return qUr(a).reduce((n,A)=>n.then(h=>zUr(h,A,e,t)),Promise.resolve(a))}async function l2t(s,e,t){var a;const i=(a=e.style)===null||a===void 0?void 0:a.getPropertyValue(s);if(i){const n=await iAa(i,null,t);return e.style.setProperty(s,n,e.style.getPropertyPriority(s)),!0}return!1}async function eFr(s,e){await l2t("background",s,e)||await l2t("background-image",s,e),await l2t("mask",s,e)||await l2t("mask-image",s,e)}async function tFr(s,e){const t=LQ(s,HTMLImageElement);if(!(t&&!vvs(s.src))&&!(LQ(s,SVGImageElement)&&!vvs(s.href.baseVal)))return;const a=t?s.src:s.href.baseVal,i=await SC0(a,OC0(a),e);await new Promise((n,A)=>{s.onload=n,s.onerror=A;const h=s;h.decode&&(h.decode=n),h.loading==="lazy"&&(h.loading="eager"),t?(s.srcset="",s.src=i):s.href.baseVal=i})}async function sFr(s,e){const a=tz(s.childNodes).map(i=>rAa(i,e));await Promise.all(a).then(()=>s)}async function rAa(s,e){LQ(s,Element)&&(await eFr(s,e),await tFr(s,e),await sFr(s,e))}function aFr(s,e){const{style:t}=s;e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.width&&(t.width=`${e.width}px`),e.height&&(t.height=`${e.height}px`);const a=e.style;return a!=null&&Object.keys(a).forEach(i=>{t[i]=a[i]}),s}const Hd1={};async function Gd1(s){let e=Hd1[s];if(e!=null)return e;const a=await(await fetch(s)).text();return e={url:s,cssText:a},Hd1[s]=e,e}async function Yd1(s,e){let t=s.cssText;const a=/url\(["']?([^"')]+)["']?\)/g,n=(t.match(/url\([^)]+\)/g)||[]).map(async A=>{let h=A.replace(a,"$1");return h.startsWith("https://")||(h=new URL(h,s.url).href),tAa(h,e.fetchRequestInit,({result:u})=>(t=t.replace(A,`url(${u})`),[A,u]))});return Promise.all(n).then(()=>t)}function Kd1(s){if(s==null)return[];const e=[],t=/(\/\*[\s\S]*?\*\/)/gi;let a=s.replace(t,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const u=i.exec(a);if(u===null)break;e.push(u[0])}a=a.replace(i,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,A="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",h=new RegExp(A,"gi");for(;;){let u=n.exec(a);if(u===null){if(u=h.exec(a),u===null)break;n.lastIndex=h.lastIndex}else h.lastIndex=n.lastIndex;e.push(u[0])}return e}async function iFr(s,e){const t=[],a=[];return s.forEach(i=>{if("cssRules"in i)try{tz(i.cssRules||[]).forEach((n,A)=>{if(n.type===CSSRule.IMPORT_RULE){let h=A+1;const u=n.href,E=Gd1(u).then(g=>Yd1(g,e)).then(g=>Kd1(g).forEach(C=>{try{i.insertRule(C,C.startsWith("@import")?h+=1:i.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:C,error:f})}})).catch(g=>{console.error("Error loading remote css",g.toString())});a.push(E)}})}catch(n){const A=s.find(h=>h.href==null)||document.styleSheets[0];i.href!=null&&a.push(Gd1(i.href).then(h=>Yd1(h,e)).then(h=>Kd1(h).forEach(u=>{A.insertRule(u,i.cssRules.length)})).catch(h=>{console.error("Error loading remote stylesheet",h)})),console.error("Error inlining remote css file",n)}}),Promise.all(a).then(()=>(s.forEach(i=>{if("cssRules"in i)try{tz(i.cssRules||[]).forEach(n=>{t.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${i.href}`,n)}}),t))}function rFr(s){return s.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>aAa(e.style.getPropertyValue("src")))}async function nFr(s,e){if(s.ownerDocument==null)throw new Error("Provided element is not within a Document");const t=tz(s.ownerDocument.styleSheets),a=await iFr(t,e);return rFr(a)}async function cFr(s,e){const t=await nFr(s,e);return(await Promise.all(t.map(i=>{const n=i.parentStyleSheet?i.parentStyleSheet.href:null;return iAa(i.cssText,n,e)}))).join(`
8644
+ `,u.add(V))}}});const E=new Blob([h],{type:"text/plain"}),g=URL.createObjectURL(E),C=document.createElement("a");C.href=g,C.download=`${t.name.toLowerCase().replace(/\s+/g,"_")}_schema.sql`,C.click(),URL.revokeObjectURL(g)}}}function oR(s,e,t,a){if(typeof e=="function"?s!==e||!a:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?a:t==="a"?a.call(s):a?a.value:e.get(s)}function lIe(s,e,t,a,i){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}var Yoe,Kk,Cpe,u2t,pSt;const $Q="__TAURI_TO_IPC_KEY__";function J2a(s,e=!1){return window.__TAURI_INTERNALS__.transformCallback(s,e)}let Svs=class{constructor(e){Yoe.set(this,void 0),Kk.set(this,0),Cpe.set(this,[]),u2t.set(this,void 0),lIe(this,Yoe,e||(()=>{})),this.id=J2a(t=>{const a=t.index;if("end"in t){a==oR(this,Kk,"f")?this.cleanupCallback():lIe(this,u2t,a);return}const i=t.message;if(a==oR(this,Kk,"f")){for(oR(this,Yoe,"f").call(this,i),lIe(this,Kk,oR(this,Kk,"f")+1);oR(this,Kk,"f")in oR(this,Cpe,"f");){const n=oR(this,Cpe,"f")[oR(this,Kk,"f")];oR(this,Yoe,"f").call(this,n),delete oR(this,Cpe,"f")[oR(this,Kk,"f")],lIe(this,Kk,oR(this,Kk,"f")+1)}oR(this,Kk,"f")===oR(this,u2t,"f")&&this.cleanupCallback()}else oR(this,Cpe,"f")[a]=i})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){lIe(this,Yoe,e)}get onmessage(){return oR(this,Yoe,"f")}[(Yoe=new WeakMap,Kk=new WeakMap,Cpe=new WeakMap,u2t=new WeakMap,$Q)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[$Q]()}};class wd1{constructor(e,t,a){this.plugin=e,this.event=t,this.channelId=a}async unregister(){return Ki(`plugin:${this.plugin}|remove_listener`,{event:this.event,channelId:this.channelId})}}async function dUr(s,e,t){const a=new Svs(t);try{return await Ki(`plugin:${s}|register_listener`,{event:e,handler:a}),new wd1(s,e,a.id)}catch{return await Ki(`plugin:${s}|registerListener`,{event:e,handler:a}),new wd1(s,e,a.id)}}async function Ki(s,e={},t){return window.__TAURI_INTERNALS__.invoke(s,e,t)}class Lvs{get rid(){return oR(this,pSt,"f")}constructor(e){pSt.set(this,void 0),lIe(this,pSt,e)}async close(){return Ki("plugin:resources|close",{rid:this.rid})}}pSt=new WeakMap;class X2a extends Lvs{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,t){Qvs(t);const a=new Svs;e&&(a.onmessage=e);const i=await Ki("plugin:updater|download",{onEvent:a,rid:this.rid,...t});this.downloadedBytes=new Lvs(i)}async install(){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await Ki("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid}),this.downloadedBytes=void 0}async downloadAndInstall(e,t){Qvs(t);const a=new Svs;e&&(a.onmessage=e),await Ki("plugin:updater|download_and_install",{onEvent:a,rid:this.rid,...t})}async close(){var e;await((e=this.downloadedBytes)==null?void 0:e.close()),await super.close()}}async function q2a(s){Qvs(s);const e=await Ki("plugin:updater|check",{...s});return e?new X2a(e):null}function Qvs(s){s!=null&&s.headers&&(s.headers=Array.from(new Headers(s.headers).entries()))}const Nd1=Object.freeze(Object.defineProperty({__proto__:null,Update:X2a,check:q2a},Symbol.toStringTag,{value:"Module"})),Dd1="erd-update-dismissed-version",kd1="erd-update-notified-version";function EUr(){return!!window.__TAURI__||!!window.__TAURI_INTERNALS__}async function HC(s,e,t){if(EUr())try{await fetch("http://localhost:3099/api/log/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({level:s,message:e,extra:t,timestamp:new Date().toISOString()})})}catch{}}function gUr(s,e,t){const[a,i]=ae.useState(!1),[n,A]=ae.useState(null),[h,u]=ae.useState(!1),[E,g]=ae.useState(!1),[C,f]=ae.useState(null),_=ae.useRef(s);_.current=s;const R=ae.useRef(!1),x=ae.useRef(null),w=ae.useRef(!1),D=ae.useCallback(X=>{localStorage.setItem(Dd1,X)},[]),M=ae.useCallback(X=>typeof window>"u"?!1:localStorage.getItem(Dd1)===X,[]),U=ae.useCallback(async X=>{var Z;if(HC("debug","handleDownloadUpdate called",`downloadingRef=${w.current} version=${X.version}`),w.current){HC("debug","BLOCKED: download already in progress");return}w.current=!0,g(!0),HC("info","download STARTED");const J=v0.loading("Downloading update...",{description:"Please wait, downloading the latest version."});HC("info","download_started",X.version);try{let j=0,z=0;await X.downloadAndInstall(q=>{switch(q.event){case"Started":z=q.data.contentLength||0,HC("info","download_progress",`0% of ${h2t(z)}`),v0.loading("Downloading update...",{id:J,description:`0% - ${h2t(z)}`});break;case"Progress":j+=q.data.chunkLength;const se=Math.round(j/z*100);v0.loading(`Downloading update... ${se}%`,{id:J,description:`${h2t(j)} / ${h2t(z)}`});break;case"Finished":HC("info","download_finished","ready to install");break}}),HC("info","downloadAndInstall resolved — install complete"),v0.success("Update installed successfully!",{id:J,description:"The application will now restart to apply the update.",duration:8e3}),setTimeout(async()=>{try{const{relaunch:q}=await tr(async()=>{const{relaunch:se}=await Promise.resolve().then(()=>n7n);return{relaunch:se}},[]);await q()}catch{window.location.reload()}},1e3),g(!1),w.current=!1}catch(j){const z=typeof j=="string"?j:(j==null?void 0:j.message)||((Z=j==null?void 0:j.toString)==null?void 0:Z.call(j))||JSON.stringify(j);HC("error","download_failed",z),v0.error("Update failed",{id:J,description:z||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(z).catch(()=>{})}}),g(!1),w.current=!1}},[]),H=ae.useCallback(async(X=!1)=>{var z,q;if(HC("debug","performCheck called",`isManual=${X} checkingRef=${R.current}`),!(!!window.__TAURI__||!!window.__TAURI_INTERNALS__))return HC("debug","SKIP: not Tauri"),!1;if(R.current)return HC("debug","SKIP: already checking"),!1;R.current=!0,u(!0);let Z="";try{const{getVersion:se}=await tr(async()=>{const{getVersion:ie}=await Promise.resolve().then(()=>i5a);return{getVersion:ie}},void 0);Z=await se()}catch{Z="0.0.0"}let j;X&&(j=v0.loading("Checking for updates...",{description:`ERD Builder Pro v${Z}`})),HC("info","check_started",`current=${Z} manual=${X}`);try{const se=await q2a();if(se)return i(!0),A(se.version),f(se),j&&v0.dismiss(j),!X&&(x.current===se.version||M(se.version))?(HC("debug","SKIP toast: already shown/dismissed",se.version),u(!1),R.current=!1,!0):(x.current=se.version,HC("info","update_available",`v${se.version}`),X&&localStorage.getItem(kd1)===se.version?(HC("debug","SKIP toast: already notified by auto-check",se.version),i(!0),A(se.version),f(se),(z=_.current)==null||z.call(_),u(!1),R.current=!1,!0):(HC("debug","SHOWING toast: Update Available",`v${se.version} manual=${X}`),v0.info("Update Available",{description:`New version (v${se.version}) is ready.`,duration:1/0,action:{label:"Update Now",onClick:()=>U(se)},cancel:{label:"Later",onClick:()=>D(se.version)}}),X||localStorage.setItem(kd1,se.version),(q=_.current)==null||q.call(_),u(!1),R.current=!1,!0));j&&v0.dismiss(j),X&&v0.success("You're up to date",{description:`ERD Builder Pro v${Z} is the latest version.`}),HC("info","no_update",`current=${Z}`),i(!1),A(null),f(null)}catch(se){HC("error","check_failed",(se==null?void 0:se.message)||String(se)),j&&v0.dismiss(j),X&&v0.error("Check failed",{description:"Could not check for updates. Check your internet connection."})}return u(!1),R.current=!1,!1},[M,U]),K=ae.useCallback(()=>{HC("debug","handleDownload called",`update=${C==null?void 0:C.version} downloadingRef=${w.current}`),C&&U(C)},[C,U]),V=ae.useRef(H);V.current=H;const W=ae.useCallback(()=>{HC("debug","checkNow (manual trigger)"),V.current(!0)},[]);return ae.useEffect(()=>{HC("debug","scheduling auto-check in 5s");const X=setTimeout(()=>{HC("debug","auto-check timer fired"),V.current(!1)},5e3);return()=>clearTimeout(X)},[e]),ae.useEffect(()=>{const X=()=>V.current(!0);return window.addEventListener("menu-check-update",X),()=>window.removeEventListener("menu-check-update",X)},[t]),{hasUpdate:a,latestVersion:n,isChecking:h,isDownloading:E,checkNow:W,handleDownload:K}}function h2t(s){if(s===0)return"0 B";const e=1024,t=["B","KB","MB","GB"],a=Math.floor(Math.log(s)/Math.log(e));return Math.round(s/Math.pow(e,a)*100)/100+" "+t[a]}const z2a="erd-version-check",bd1="erd-version-current",CUr=3600*1e3;function Z2a(){try{return"3.1.4"}catch{return"0.0.0"}}async function pUr(){try{const t=await fetch("/api/version/current");if(t.ok){const a=await t.json(),i=a==null?void 0:a.current;if(i&&i!=="0.0.0")return localStorage.setItem(bd1,i),i}}catch{}const s=localStorage.getItem(bd1);return s||Z2a()}function Md1(){try{const s=localStorage.getItem(z2a);if(!s)return null;const e=JSON.parse(s);return Date.now()-e.fetchedAt>CUr?null:e}catch{return null}}function IUr(s,e){try{localStorage.setItem(z2a,JSON.stringify({latest:s,current:e,fetchedAt:Date.now()}))}catch{}}function fUr(){const[s,e]=ae.useState(!1),[t,a]=ae.useState(null),[i,n]=ae.useState(Z2a()),A=ae.useRef(!1),h=ae.useCallback(async()=>{if(A.current)return;A.current=!0;const u=await pUr();n(u);const E=Md1();if(E&&E.current===u){E.latest!==u&&E.latest&&(e(!0),a(E.latest));return}try{const C=await fetch("/api/version/latest");if(!C.ok)return;const f=await C.json(),_=f==null?void 0:f.latest;if(!_)return;IUr(_,u),_!==u&&(e(!0),a(_))}catch{const g=Md1();g&&g.latest!==u&&g.latest&&(e(!0),a(g.latest))}},[]);return ae.useEffect(()=>{h()},[h]),{isOutdated:s,latestVersion:t,currentVersion:i,checkNow:h}}function _Ur(s,e){if(s.match(/^[a-z]+:\/\//i))return s;if(s.match(/^\/\//))return window.location.protocol+s;if(s.match(/^[a-z]+:/i))return s;const t=document.implementation.createHTMLDocument(),a=t.createElement("base"),i=t.createElement("a");return t.head.appendChild(a),t.body.appendChild(i),e&&(a.href=e),i.href=s,i.href}const mUr=(()=>{let s=0;const e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(s+=1,`u${e()}${s}`)})();function tz(s){const e=[];for(let t=0,a=s.length;t<a;t++)e.push(s[t]);return e}function XUt(s,e){const a=(s.ownerDocument.defaultView||window).getComputedStyle(s).getPropertyValue(e);return a?parseFloat(a.replace("px","")):0}function BUr(s){const e=XUt(s,"border-left-width"),t=XUt(s,"border-right-width");return s.clientWidth+e+t}function RUr(s){const e=XUt(s,"border-top-width"),t=XUt(s,"border-bottom-width");return s.clientHeight+e+t}function eAa(s,e={}){const t=e.width||BUr(s),a=e.height||RUr(s);return{width:t,height:a}}function TUr(){let s,e;try{e=process}catch{}const t=e&&e.env?e.env.devicePixelRatio:null;return t&&(s=parseInt(t,10),Number.isNaN(s)&&(s=1)),s||window.devicePixelRatio||1}const vw=16384;function yUr(s){(s.width>vw||s.height>vw)&&(s.width>vw&&s.height>vw?s.width>s.height?(s.height*=vw/s.width,s.width=vw):(s.width*=vw/s.height,s.height=vw):s.width>vw?(s.height*=vw/s.width,s.width=vw):(s.width*=vw/s.height,s.height=vw))}function qUt(s){return new Promise((e,t)=>{const a=new Image;a.decode=()=>e(a),a.onload=()=>e(a),a.onerror=t,a.crossOrigin="anonymous",a.decoding="async",a.src=s})}async function xUr(s){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(s)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function OUr(s,e,t){const a="http://www.w3.org/2000/svg",i=document.createElementNS(a,"svg"),n=document.createElementNS(a,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${t}`),i.setAttribute("viewBox",`0 0 ${e} ${t}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),i.appendChild(n),n.appendChild(s),xUr(i)}const LQ=(s,e)=>{if(s instanceof e)return!0;const t=Object.getPrototypeOf(s);return t===null?!1:t.constructor.name===e.name||LQ(t,e)};function SUr(s){const e=s.getPropertyValue("content");return`${s.cssText} content: '${e.replace(/'|"/g,"")}';`}function LUr(s){return tz(s).map(e=>{const t=s.getPropertyValue(e),a=s.getPropertyPriority(e);return`${e}: ${t}${a?" !important":""};`}).join(" ")}function QUr(s,e,t){const a=`.${s}:${e}`,i=t.cssText?SUr(t):LUr(t);return document.createTextNode(`${a}{${i}}`)}function Ud1(s,e,t){const a=window.getComputedStyle(s,t),i=a.getPropertyValue("content");if(i===""||i==="none")return;const n=mUr();try{e.className=`${e.className} ${n}`}catch{return}const A=document.createElement("style");A.appendChild(QUr(n,t,a)),e.appendChild(A)}function vUr(s,e){Ud1(s,e,":before"),Ud1(s,e,":after")}const Fd1="application/font-woff",Pd1="image/jpeg",wUr={woff:Fd1,woff2:Fd1,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Pd1,jpeg:Pd1,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function NUr(s){const e=/\.([^./]*?)$/g.exec(s);return e?e[1]:""}function OC0(s){const e=NUr(s).toLowerCase();return wUr[e]||""}function DUr(s){return s.split(/,/)[1]}function vvs(s){return s.search(/^(data:)/)!==-1}function kUr(s,e){return`data:${e};base64,${s}`}async function tAa(s,e,t){const a=await fetch(s,e);if(a.status===404)throw new Error(`Resource "${a.url}" not found`);const i=await a.blob();return new Promise((n,A)=>{const h=new FileReader;h.onerror=A,h.onloadend=()=>{try{n(t({res:a,result:h.result}))}catch(u){A(u)}},h.readAsDataURL(i)})}const lIs={};function bUr(s,e,t){let a=s.replace(/\?.*/,"");return t&&(a=s),/ttf|otf|eot|woff2?/i.test(a)&&(a=a.replace(/.*\//,"")),e?`[${e}]${a}`:a}async function SC0(s,e,t){const a=bUr(s,e,t.includeQueryParams);if(lIs[a]!=null)return lIs[a];t.cacheBust&&(s+=(/\?/.test(s)?"&":"?")+new Date().getTime());let i;try{const n=await tAa(s,t.fetchRequestInit,({res:A,result:h})=>(e||(e=A.headers.get("Content-Type")||""),DUr(h)));i=kUr(n,e)}catch(n){i=t.imagePlaceholder||"";let A=`Failed to fetch resource: ${s}`;n&&(A=typeof n=="string"?n:n.message),A&&console.warn(A)}return lIs[a]=i,i}async function MUr(s){const e=s.toDataURL();return e==="data:,"?s.cloneNode(!1):qUt(e)}async function UUr(s,e){if(s.currentSrc){const n=document.createElement("canvas"),A=n.getContext("2d");n.width=s.clientWidth,n.height=s.clientHeight,A==null||A.drawImage(s,0,0,n.width,n.height);const h=n.toDataURL();return qUt(h)}const t=s.poster,a=OC0(t),i=await SC0(t,a,e);return qUt(i)}async function FUr(s){var e;try{if(!((e=s==null?void 0:s.contentDocument)===null||e===void 0)&&e.body)return await Pqt(s.contentDocument.body,{},!0)}catch{}return s.cloneNode(!1)}async function PUr(s,e){return LQ(s,HTMLCanvasElement)?MUr(s):LQ(s,HTMLVideoElement)?UUr(s,e):LQ(s,HTMLIFrameElement)?FUr(s):s.cloneNode(!1)}const HUr=s=>s.tagName!=null&&s.tagName.toUpperCase()==="SLOT";async function GUr(s,e,t){var a,i;let n=[];return HUr(s)&&s.assignedNodes?n=tz(s.assignedNodes()):LQ(s,HTMLIFrameElement)&&(!((a=s.contentDocument)===null||a===void 0)&&a.body)?n=tz(s.contentDocument.body.childNodes):n=tz(((i=s.shadowRoot)!==null&&i!==void 0?i:s).childNodes),n.length===0||LQ(s,HTMLVideoElement)||await n.reduce((A,h)=>A.then(()=>Pqt(h,t)).then(u=>{u&&e.appendChild(u)}),Promise.resolve()),e}function YUr(s,e){const t=e.style;if(!t)return;const a=window.getComputedStyle(s);a.cssText?(t.cssText=a.cssText,t.transformOrigin=a.transformOrigin):tz(a).forEach(i=>{let n=a.getPropertyValue(i);i==="font-size"&&n.endsWith("px")&&(n=`${Math.floor(parseFloat(n.substring(0,n.length-2)))-.1}px`),LQ(s,HTMLIFrameElement)&&i==="display"&&n==="inline"&&(n="block"),i==="d"&&e.getAttribute("d")&&(n=`path(${e.getAttribute("d")})`),t.setProperty(i,n,a.getPropertyPriority(i))})}function KUr(s,e){LQ(s,HTMLTextAreaElement)&&(e.innerHTML=s.value),LQ(s,HTMLInputElement)&&e.setAttribute("value",s.value)}function VUr(s,e){if(LQ(s,HTMLSelectElement)){const a=Array.from(e.children).find(i=>s.value===i.getAttribute("value"));a&&a.setAttribute("selected","")}}function jUr(s,e){return LQ(e,Element)&&(YUr(s,e),vUr(s,e),KUr(s,e),VUr(s,e)),e}async function WUr(s,e){const t=s.querySelectorAll?s.querySelectorAll("use"):[];if(t.length===0)return s;const a={};for(let n=0;n<t.length;n++){const h=t[n].getAttribute("xlink:href");if(h){const u=s.querySelector(h),E=document.querySelector(h);!u&&E&&!a[h]&&(a[h]=await Pqt(E,e,!0))}}const i=Object.values(a);if(i.length){const n="http://www.w3.org/1999/xhtml",A=document.createElementNS(n,"svg");A.setAttribute("xmlns",n),A.style.position="absolute",A.style.width="0",A.style.height="0",A.style.overflow="hidden",A.style.display="none";const h=document.createElementNS(n,"defs");A.appendChild(h);for(let u=0;u<i.length;u++)h.appendChild(i[u]);s.appendChild(A)}return s}async function Pqt(s,e,t){return!t&&e.filter&&!e.filter(s)?null:Promise.resolve(s).then(a=>PUr(a,e)).then(a=>GUr(s,a,e)).then(a=>jUr(s,a)).then(a=>WUr(a,e))}const sAa=/url\((['"]?)([^'"]+?)\1\)/g,$Ur=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,JUr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function XUr(s){const e=s.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function qUr(s){const e=[];return s.replace(sAa,(t,a,i)=>(e.push(i),t)),e.filter(t=>!vvs(t))}async function zUr(s,e,t,a,i){try{const n=t?_Ur(e,t):e,A=OC0(e);let h;return i||(h=await SC0(n,A,a)),s.replace(XUr(e),`$1${h}$3`)}catch{}return s}function ZUr(s,{preferredFontFormat:e}){return e?s.replace(JUr,t=>{for(;;){const[a,,i]=$Ur.exec(t)||[];if(!i)return"";if(i===e)return`src: ${a};`}}):s}function aAa(s){return s.search(sAa)!==-1}async function iAa(s,e,t){if(!aAa(s))return s;const a=ZUr(s,t);return qUr(a).reduce((n,A)=>n.then(h=>zUr(h,A,e,t)),Promise.resolve(a))}async function l2t(s,e,t){var a;const i=(a=e.style)===null||a===void 0?void 0:a.getPropertyValue(s);if(i){const n=await iAa(i,null,t);return e.style.setProperty(s,n,e.style.getPropertyPriority(s)),!0}return!1}async function eFr(s,e){await l2t("background",s,e)||await l2t("background-image",s,e),await l2t("mask",s,e)||await l2t("mask-image",s,e)}async function tFr(s,e){const t=LQ(s,HTMLImageElement);if(!(t&&!vvs(s.src))&&!(LQ(s,SVGImageElement)&&!vvs(s.href.baseVal)))return;const a=t?s.src:s.href.baseVal,i=await SC0(a,OC0(a),e);await new Promise((n,A)=>{s.onload=n,s.onerror=A;const h=s;h.decode&&(h.decode=n),h.loading==="lazy"&&(h.loading="eager"),t?(s.srcset="",s.src=i):s.href.baseVal=i})}async function sFr(s,e){const a=tz(s.childNodes).map(i=>rAa(i,e));await Promise.all(a).then(()=>s)}async function rAa(s,e){LQ(s,Element)&&(await eFr(s,e),await tFr(s,e),await sFr(s,e))}function aFr(s,e){const{style:t}=s;e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.width&&(t.width=`${e.width}px`),e.height&&(t.height=`${e.height}px`);const a=e.style;return a!=null&&Object.keys(a).forEach(i=>{t[i]=a[i]}),s}const Hd1={};async function Gd1(s){let e=Hd1[s];if(e!=null)return e;const a=await(await fetch(s)).text();return e={url:s,cssText:a},Hd1[s]=e,e}async function Yd1(s,e){let t=s.cssText;const a=/url\(["']?([^"')]+)["']?\)/g,n=(t.match(/url\([^)]+\)/g)||[]).map(async A=>{let h=A.replace(a,"$1");return h.startsWith("https://")||(h=new URL(h,s.url).href),tAa(h,e.fetchRequestInit,({result:u})=>(t=t.replace(A,`url(${u})`),[A,u]))});return Promise.all(n).then(()=>t)}function Kd1(s){if(s==null)return[];const e=[],t=/(\/\*[\s\S]*?\*\/)/gi;let a=s.replace(t,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const u=i.exec(a);if(u===null)break;e.push(u[0])}a=a.replace(i,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,A="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",h=new RegExp(A,"gi");for(;;){let u=n.exec(a);if(u===null){if(u=h.exec(a),u===null)break;n.lastIndex=h.lastIndex}else h.lastIndex=n.lastIndex;e.push(u[0])}return e}async function iFr(s,e){const t=[],a=[];return s.forEach(i=>{if("cssRules"in i)try{tz(i.cssRules||[]).forEach((n,A)=>{if(n.type===CSSRule.IMPORT_RULE){let h=A+1;const u=n.href,E=Gd1(u).then(g=>Yd1(g,e)).then(g=>Kd1(g).forEach(C=>{try{i.insertRule(C,C.startsWith("@import")?h+=1:i.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:C,error:f})}})).catch(g=>{console.error("Error loading remote css",g.toString())});a.push(E)}})}catch(n){const A=s.find(h=>h.href==null)||document.styleSheets[0];i.href!=null&&a.push(Gd1(i.href).then(h=>Yd1(h,e)).then(h=>Kd1(h).forEach(u=>{A.insertRule(u,i.cssRules.length)})).catch(h=>{console.error("Error loading remote stylesheet",h)})),console.error("Error inlining remote css file",n)}}),Promise.all(a).then(()=>(s.forEach(i=>{if("cssRules"in i)try{tz(i.cssRules||[]).forEach(n=>{t.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${i.href}`,n)}}),t))}function rFr(s){return s.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>aAa(e.style.getPropertyValue("src")))}async function nFr(s,e){if(s.ownerDocument==null)throw new Error("Provided element is not within a Document");const t=tz(s.ownerDocument.styleSheets),a=await iFr(t,e);return rFr(a)}async function cFr(s,e){const t=await nFr(s,e);return(await Promise.all(t.map(i=>{const n=i.parentStyleSheet?i.parentStyleSheet.href:null;return iAa(i.cssText,n,e)}))).join(`
8645
8645
  `)}async function AFr(s,e){const t=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await cFr(s,e);if(t){const a=document.createElement("style"),i=document.createTextNode(t);a.appendChild(i),s.firstChild?s.insertBefore(a,s.firstChild):s.appendChild(a)}}async function nAa(s,e={}){const{width:t,height:a}=eAa(s,e),i=await Pqt(s,e,!0);return await AFr(i,e),await rAa(i,e),aFr(i,e),await OUr(i,t,a)}async function oFr(s,e={}){const{width:t,height:a}=eAa(s,e),i=await nAa(s,e),n=await qUt(i),A=document.createElement("canvas"),h=A.getContext("2d"),u=e.pixelRatio||TUr(),E=e.canvasWidth||t,g=e.canvasHeight||a;return A.width=E*u,A.height=g*u,e.skipAutoScale||yUr(A),A.style.width=`${E}`,A.style.height=`${g}`,e.backgroundColor&&(h.fillStyle=e.backgroundColor,h.fillRect(0,0,A.width,A.height)),h.drawImage(n,0,0,A.width,A.height),A}async function uFr(s,e={}){return(await oFr(s,e)).toDataURL()}function r5(s){"@babel/helpers - typeof";return r5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r5(s)}var $H=Uint8Array,sN=Uint16Array,LC0=Int32Array,QC0=new $H([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]),vC0=new $H([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]),Vd1=new $H([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cAa=function(s,e){for(var t=new sN(31),a=0;a<31;++a)t[a]=e+=1<<s[a-1];for(var i=new LC0(t[30]),a=1;a<30;++a)for(var n=t[a];n<t[a+1];++n)i[n]=n-t[a]<<5|a;return{b:t,r:i}},AAa=cAa(QC0,2),hFr=AAa.b,wvs=AAa.r;hFr[28]=258,wvs[258]=28;var lFr=cAa(vC0,0),jd1=lFr.r,Nvs=new sN(32768);for(var bd=0;bd<32768;++bd){var B0e=(bd&43690)>>1|(bd&21845)<<1;B0e=(B0e&52428)>>2|(B0e&13107)<<2,B0e=(B0e&61680)>>4|(B0e&3855)<<4,Nvs[bd]=((B0e&65280)>>8|(B0e&255)<<8)>>1}var OFe=(function(s,e,t){for(var a=s.length,i=0,n=new sN(e);i<a;++i)s[i]&&++n[s[i]-1];var A=new sN(e);for(i=1;i<e;++i)A[i]=A[i-1]+n[i-1]<<1;var h;if(t){h=new sN(1<<e);var u=15-e;for(i=0;i<a;++i)if(s[i])for(var E=i<<4|s[i],g=e-s[i],C=A[s[i]-1]++<<g,f=C|(1<<g)-1;C<=f;++C)h[Nvs[C]>>u]=E}else for(h=new sN(a),i=0;i<a;++i)s[i]&&(h[i]=Nvs[A[s[i]-1]++]>>15-s[i]);return h}),y5e=new $H(288);for(var bd=0;bd<144;++bd)y5e[bd]=8;for(var bd=144;bd<256;++bd)y5e[bd]=9;for(var bd=256;bd<280;++bd)y5e[bd]=7;for(var bd=280;bd<288;++bd)y5e[bd]=8;var zUt=new $H(32);for(var bd=0;bd<32;++bd)zUt[bd]=5;var dFr=OFe(y5e,9,0),EFr=OFe(zUt,5,0),oAa=function(s){return(s+7)/8|0},gFr=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new $H(s.subarray(e,t))},SX=function(s,e,t){t<<=e&7;var a=e/8|0;s[a]|=t,s[a+1]|=t>>8},wke=function(s,e,t){t<<=e&7;var a=e/8|0;s[a]|=t,s[a+1]|=t>>8,s[a+2]|=t>>16},dIs=function(s,e){for(var t=[],a=0;a<s.length;++a)s[a]&&t.push({s:a,f:s[a]});var i=t.length,n=t.slice();if(!i)return{t:hAa,l:0};if(i==1){var A=new $H(t[0].s+1);return A[t[0].s]=1,{t:A,l:1}}t.sort(function(K,V){return K.f-V.f}),t.push({s:-1,f:25001});var h=t[0],u=t[1],E=0,g=1,C=2;for(t[0]={s:-1,f:h.f+u.f,l:h,r:u};g!=i-1;)h=t[t[E].f<t[C].f?E++:C++],u=t[E!=g&&t[E].f<t[C].f?E++:C++],t[g++]={s:-1,f:h.f+u.f,l:h,r:u};for(var f=n[0].s,a=1;a<i;++a)n[a].s>f&&(f=n[a].s);var _=new sN(f+1),R=Dvs(t[g-1],_,0);if(R>e){var a=0,x=0,w=R-e,D=1<<w;for(n.sort(function(V,W){return _[W.s]-_[V.s]||V.f-W.f});a<i;++a){var M=n[a].s;if(_[M]>e)x+=D-(1<<R-_[M]),_[M]=e;else break}for(x>>=w;x>0;){var U=n[a].s;_[U]<e?x-=1<<e-_[U]++-1:++a}for(;a>=0&&x;--a){var H=n[a].s;_[H]==e&&(--_[H],++x)}R=e}return{t:new $H(_),l:R}},Dvs=function(s,e,t){return s.s==-1?Math.max(Dvs(s.l,e,t+1),Dvs(s.r,e,t+1)):e[s.s]=t},Wd1=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new sN(++e),a=0,i=s[0],n=1,A=function(u){t[a++]=u},h=1;h<=e;++h)if(s[h]==i&&h!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)A(32754);n>2&&(A(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(A(i),--n;n>6;n-=6)A(8304);n>2&&(A(n-3<<5|8208),n=0)}for(;n--;)A(i);n=1,i=s[h]}return{c:t.subarray(0,a),n:e}},Nke=function(s,e){for(var t=0,a=0;a<e.length;++a)t+=s[a]*e[a];return t},uAa=function(s,e,t){var a=t.length,i=oAa(e+2);s[i]=a&255,s[i+1]=a>>8,s[i+2]=s[i]^255,s[i+3]=s[i+1]^255;for(var n=0;n<a;++n)s[i+n+4]=t[n];return(i+4+a)*8},$d1=function(s,e,t,a,i,n,A,h,u,E,g){SX(e,g++,t),++i[256];for(var C=dIs(i,15),f=C.t,_=C.l,R=dIs(n,15),x=R.t,w=R.l,D=Wd1(f),M=D.c,U=D.n,H=Wd1(x),K=H.c,V=H.n,W=new sN(19),X=0;X<M.length;++X)++W[M[X]&31];for(var X=0;X<K.length;++X)++W[K[X]&31];for(var J=dIs(W,7),Z=J.t,j=J.l,z=19;z>4&&!Z[Vd1[z-1]];--z);var q=E+5<<3,se=Nke(i,y5e)+Nke(n,zUt)+A,ie=Nke(i,f)+Nke(n,x)+A+14+3*z+Nke(W,Z)+2*W[16]+3*W[17]+7*W[18];if(u>=0&&q<=se&&q<=ie)return uAa(e,g,s.subarray(u,u+E));var he,Ae,Ee,le;if(SX(e,g,1+(ie<se)),g+=2,ie<se){he=OFe(f,_,0),Ae=f,Ee=OFe(x,w,0),le=x;var ue=OFe(Z,j,0);SX(e,g,U-257),SX(e,g+5,V-1),SX(e,g+10,z-4),g+=14;for(var X=0;X<z;++X)SX(e,g+3*X,Z[Vd1[X]]);g+=3*z;for(var me=[M,K],Be=0;Be<2;++Be)for(var _e=me[Be],X=0;X<_e.length;++X){var ve=_e[X]&31;SX(e,g,ue[ve]),g+=Z[ve],ve>15&&(SX(e,g,_e[X]>>5&127),g+=_e[X]>>12)}}else he=dFr,Ae=y5e,Ee=EFr,le=zUt;for(var X=0;X<h;++X){var Qe=a[X];if(Qe>255){var ve=Qe>>18&31;wke(e,g,he[ve+257]),g+=Ae[ve+257],ve>7&&(SX(e,g,Qe>>23&31),g+=QC0[ve]);var Ue=Qe&31;wke(e,g,Ee[Ue]),g+=le[Ue],Ue>3&&(wke(e,g,Qe>>5&8191),g+=vC0[Ue])}else wke(e,g,he[Qe]),g+=Ae[Qe]}return wke(e,g,he[256]),g+Ae[256]},CFr=new LC0([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),hAa=new $H(0),pFr=function(s,e,t,a,i,n){var A=n.z||s.length,h=new $H(a+A+5*(1+Math.ceil(A/7e3))+i),u=h.subarray(a,h.length-i),E=n.l,g=(n.r||0)&7;if(e){g&&(u[0]=n.r>>3);for(var C=CFr[e-1],f=C>>13,_=C&8191,R=(1<<t)-1,x=n.p||new sN(32768),w=n.h||new sN(R+1),D=Math.ceil(t/3),M=2*D,U=function(He){return(s[He]^s[He+1]<<D^s[He+2]<<M)&R},H=new LC0(25e3),K=new sN(288),V=new sN(32),W=0,X=0,J=n.i||0,Z=0,j=n.w||0,z=0;J+2<A;++J){var q=U(J),se=J&32767,ie=w[q];if(x[se]=ie,w[q]=se,j<=J){var he=A-J;if((W>7e3||Z>24576)&&(he>423||!E)){g=$d1(s,u,0,H,K,V,X,Z,z,J-z,g),Z=W=X=0,z=J;for(var Ae=0;Ae<286;++Ae)K[Ae]=0;for(var Ae=0;Ae<30;++Ae)V[Ae]=0}var Ee=2,le=0,ue=_,me=se-ie&32767;if(he>2&&q==U(J-me))for(var Be=Math.min(f,he)-1,_e=Math.min(32767,J),ve=Math.min(258,he);me<=_e&&--ue&&se!=ie;){if(s[J+Ee]==s[J+Ee-me]){for(var Qe=0;Qe<ve&&s[J+Qe]==s[J+Qe-me];++Qe);if(Qe>Ee){if(Ee=Qe,le=me,Qe>Be)break;for(var Ue=Math.min(me,Qe-2),Fe=0,Ae=0;Ae<Ue;++Ae){var Xe=J-me+Ae&32767,Ve=x[Xe],Ze=Xe-Ve&32767;Ze>Fe&&(Fe=Ze,ie=Xe)}}}se=ie,ie=x[se],me+=se-ie&32767}if(le){H[Z++]=268435456|wvs[Ee]<<18|jd1[le];var Je=wvs[Ee]&31,rt=jd1[le]&31;X+=QC0[Je]+vC0[rt],++K[257+Je],++V[rt],j=J+Ee,++W}else H[Z++]=s[J],++K[s[J]]}}for(J=Math.max(J,j);J<A;++J)H[Z++]=s[J],++K[s[J]];g=$d1(s,u,E,H,K,V,X,Z,z,J-z,g),E||(n.r=g&7|u[g/8|0]<<3,g-=7,n.h=w,n.p=x,n.i=J,n.w=j)}else{for(var J=n.w||0;J<A+E;J+=65535){var nt=J+65535;nt>=A&&(u[g/8|0]=E,nt=A),g=uAa(u,g+1,s.subarray(J,nt))}n.i=A}return gFr(h,0,a+oAa(g)+i)},lAa=function(){var s=1,e=0;return{p:function(t){for(var a=s,i=e,n=t.length|0,A=0;A!=n;){for(var h=Math.min(A+2655,n);A<h;++A)i+=a+=t[A];a=(a&65535)+15*(a>>16),i=(i&65535)+15*(i>>16)}s=a,e=i},d:function(){return s%=65521,e%=65521,(s&255)<<24|(s&65280)<<8|(e&255)<<8|e>>8}}},IFr=function(s,e,t,a,i){if(!i&&(i={l:1},e.dictionary)){var n=e.dictionary.subarray(-32768),A=new $H(n.length+s.length);A.set(n),A.set(s,n.length),s=A,i.w=n.length}return pFr(s,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(s.length)))*1.5):20:12+e.mem,t,a,i)},dAa=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8},fFr=function(s,e){var t=e.level,a=t==0?0:t<6?1:t==9?3:2;if(s[0]=120,s[1]=a<<6|(e.dictionary&&32),s[1]|=31-(s[0]<<8|s[1])%31,e.dictionary){var i=lAa();i.p(e.dictionary),dAa(s,2,i.d())}};function kvs(s,e){e||(e={});var t=lAa();t.p(s);var a=IFr(s,e,e.dictionary?6:2,4);return fFr(a,e),dAa(a,a.length-4,t.d()),a}var _Fr=typeof TextDecoder<"u"&&new TextDecoder,mFr=0;try{_Fr.decode(hAa,{stream:!0}),mFr=1}catch{}function BFr(s){if(Array.isArray(s))return s}function RFr(s,e){var t=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(t!=null){var a,i,n,A,h=[],u=!0,E=!1;try{if(n=(t=t.call(s)).next,e!==0)for(;!(u=(a=n.call(t)).done)&&(h.push(a.value),h.length!==e);u=!0);}catch(g){E=!0,i=g}finally{try{if(!u&&t.return!=null&&(A=t.return(),Object(A)!==A))return}finally{if(E)throw i}}return h}}function Jd1(s,e){(e==null||e>s.length)&&(e=s.length);for(var t=0,a=Array(e);t<e;t++)a[t]=s[t];return a}function TFr(s,e){if(s){if(typeof s=="string")return Jd1(s,e);var t={}.toString.call(s).slice(8,-1);return t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set"?Array.from(s):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Jd1(s,e):void 0}}function yFr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
8646
8646
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xd1(s,e){return BFr(s)||RFr(s,e)||TFr(s,e)||yFr()}function qd1(s,e="utf8"){return new TextDecoder(e).decode(s)}const xFr=new TextEncoder;function OFr(s){return xFr.encode(s)}const SFr=1024*8,LFr=(()=>{const s=new Uint8Array(4),e=new Uint32Array(s.buffer);return!((e[0]=1)&s[0])})(),EIs={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 wC0{constructor(e=SFr,t={}){G(this,"buffer");G(this,"byteLength");G(this,"byteOffset");G(this,"length");G(this,"offset");G(this,"lastWrittenByte");G(this,"littleEndian");G(this,"_data");G(this,"_mark");G(this,"_marks");let a=!1;typeof e=="number"?e=new ArrayBuffer(e):(a=!0,this.lastWrittenByte=e.byteLength);const i=t.offset?t.offset>>>0:0,n=e.byteLength-i;let A=i;(ArrayBuffer.isView(e)||e instanceof wC0)&&(e.byteLength!==e.buffer.byteLength&&(A=e.byteOffset+i),e=e.buffer),a?this.lastWrittenByte=n:this.lastWrittenByte=0,this.buffer=e,this.length=n,this.byteLength=n,this.byteOffset=A,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,A,n),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,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 e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const a=(this.offset+e)*2,i=new Uint8Array(a);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=a,this.byteLength=a,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(e=1){return this.readArray(e,"uint8")}readArray(e,t){const a=EIs[t].BYTES_PER_ELEMENT*e,i=this.byteOffset+this.offset,n=this.buffer.slice(i,i+a);if(this.littleEndian===LFr&&t!=="uint8"&&t!=="int8"){const h=new Uint8Array(this.buffer.slice(i,i+a));h.reverse();const u=new EIs[t](h.buffer);return this.offset+=a,u.reverse(),u}const A=new EIs[t](n);return this.offset+=a,A}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let a=0;a<e;a++)t+=this.readChar();return t}readUtf8(e=1){return qd1(this.readBytes(e))}decodeText(e=1,t="utf8"){return qd1(this.readBytes(e),t)}writeBoolean(e){return this.writeUint8(e?255:0),this}writeInt8(e){return this.ensureAvailable(1),this._data.setInt8(this.offset++,e),this._updateLastWrittenByte(),this}writeUint8(e){return this.ensureAvailable(1),this._data.setUint8(this.offset++,e),this._updateLastWrittenByte(),this}writeByte(e){return this.writeUint8(e)}writeBytes(e){this.ensureAvailable(e.length);for(let t=0;t<e.length;t++)this._data.setUint8(this.offset++,e[t]);return this._updateLastWrittenByte(),this}writeInt16(e){return this.ensureAvailable(2),this._data.setInt16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(e){return this.ensureAvailable(2),this._data.setUint16(this.offset,e,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(e){return this.ensureAvailable(4),this._data.setInt32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(e){return this.ensureAvailable(4),this._data.setUint32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(e){return this.ensureAvailable(4),this._data.setFloat32(this.offset,e,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(e){return this.ensureAvailable(8),this._data.setFloat64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigInt64(e){return this.ensureAvailable(8),this._data.setBigInt64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeBigUint64(e){return this.ensureAvailable(8),this._data.setBigUint64(this.offset,e,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(e){return this.writeUint8(e.charCodeAt(0))}writeChars(e){for(let t=0;t<e.length;t++)this.writeUint8(e.charCodeAt(t));return this}writeUtf8(e){return this.writeBytes(OFr(e))}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 Ixe(s){let e=s.length;for(;--e>=0;)s[e]=0}const QFr=3,vFr=258,EAa=29,wFr=256,NFr=wFr+1+EAa,gAa=30,DFr=512,kFr=new Array((NFr+2)*2);Ixe(kFr);const bFr=new Array(gAa*2);Ixe(bFr);const MFr=new Array(DFr);Ixe(MFr);const UFr=new Array(vFr-QFr+1);Ixe(UFr);const FFr=new Array(EAa);Ixe(FFr);const PFr=new Array(gAa);Ixe(PFr);const HFr=(s,e,t,a)=>{let i=s&65535|0,n=s>>>16&65535|0,A=0;for(;t!==0;){A=t>2e3?2e3:t,t-=A;do i=i+e[a++]|0,n=n+i|0;while(--A);i%=65521,n%=65521}return i|n<<16|0};var bvs=HFr;const GFr=()=>{let s,e=[];for(var t=0;t<256;t++){s=t;for(var a=0;a<8;a++)s=s&1?3988292384^s>>>1:s>>>1;e[t]=s}return e},YFr=new Uint32Array(GFr()),KFr=(s,e,t,a)=>{const i=YFr,n=a+t;s^=-1;for(let A=a;A<n;A++)s=s>>>8^i[(s^e[A])&255];return s^-1};var tV=KFr,Mvs={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"},CAa={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 VFr=(s,e)=>Object.prototype.hasOwnProperty.call(s,e);var jFr=function(s){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const a in t)VFr(t,a)&&(s[a]=t[a])}}return s},WFr=s=>{let e=0;for(let a=0,i=s.length;a<i;a++)e+=s[a].length;const t=new Uint8Array(e);for(let a=0,i=0,n=s.length;a<n;a++){let A=s[a];t.set(A,i),i+=A.length}return t},pAa={assign:jFr,flattenChunks:WFr};let IAa=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{IAa=!1}const eYe=new Uint8Array(256);for(let s=0;s<256;s++)eYe[s]=s>=252?6:s>=248?5:s>=240?4:s>=224?3:s>=192?2:1;eYe[254]=eYe[254]=1;var $Fr=s=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(s);let e,t,a,i,n,A=s.length,h=0;for(i=0;i<A;i++)t=s.charCodeAt(i),(t&64512)===55296&&i+1<A&&(a=s.charCodeAt(i+1),(a&64512)===56320&&(t=65536+(t-55296<<10)+(a-56320),i++)),h+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(h),n=0,i=0;n<h;i++)t=s.charCodeAt(i),(t&64512)===55296&&i+1<A&&(a=s.charCodeAt(i+1),(a&64512)===56320&&(t=65536+(t-55296<<10)+(a-56320),i++)),t<128?e[n++]=t:t<2048?(e[n++]=192|t>>>6,e[n++]=128|t&63):t<65536?(e[n++]=224|t>>>12,e[n++]=128|t>>>6&63,e[n++]=128|t&63):(e[n++]=240|t>>>18,e[n++]=128|t>>>12&63,e[n++]=128|t>>>6&63,e[n++]=128|t&63);return e};const JFr=(s,e)=>{if(e<65534&&s.subarray&&IAa)return String.fromCharCode.apply(null,s.length===e?s:s.subarray(0,e));let t="";for(let a=0;a<e;a++)t+=String.fromCharCode(s[a]);return t};var XFr=(s,e)=>{const t=e||s.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(s.subarray(0,e));let a,i;const n=new Array(t*2);for(i=0,a=0;a<t;){let A=s[a++];if(A<128){n[i++]=A;continue}let h=eYe[A];if(h>4){n[i++]=65533,a+=h-1;continue}for(A&=h===2?31:h===3?15:7;h>1&&a<t;)A=A<<6|s[a++]&63,h--;if(h>1){n[i++]=65533;continue}A<65536?n[i++]=A:(A-=65536,n[i++]=55296|A>>10&1023,n[i++]=56320|A&1023)}return JFr(n,i)},qFr=(s,e)=>{e=e||s.length,e>s.length&&(e=s.length);let t=e-1;for(;t>=0&&(s[t]&192)===128;)t--;return t<0||t===0?e:t+eYe[s[t]]>e?t:e},Uvs={string2buf:$Fr,buf2string:XFr,utf8border:qFr};function zFr(){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 ZFr=zFr;const d2t=16209,ePr=16191;var tPr=function(e,t){let a,i,n,A,h,u,E,g,C,f,_,R,x,w,D,M,U,H,K,V,W,X,J,Z;const j=e.state;a=e.next_in,J=e.input,i=a+(e.avail_in-5),n=e.next_out,Z=e.output,A=n-(t-e.avail_out),h=n+(e.avail_out-257),u=j.dmax,E=j.wsize,g=j.whave,C=j.wnext,f=j.window,_=j.hold,R=j.bits,x=j.lencode,w=j.distcode,D=(1<<j.lenbits)-1,M=(1<<j.distbits)-1;e:do{R<15&&(_+=J[a++]<<R,R+=8,_+=J[a++]<<R,R+=8),U=x[_&D];t:for(;;){if(H=U>>>24,_>>>=H,R-=H,H=U>>>16&255,H===0)Z[n++]=U&65535;else if(H&16){K=U&65535,H&=15,H&&(R<H&&(_+=J[a++]<<R,R+=8),K+=_&(1<<H)-1,_>>>=H,R-=H),R<15&&(_+=J[a++]<<R,R+=8,_+=J[a++]<<R,R+=8),U=w[_&M];s:for(;;){if(H=U>>>24,_>>>=H,R-=H,H=U>>>16&255,H&16){if(V=U&65535,H&=15,R<H&&(_+=J[a++]<<R,R+=8,R<H&&(_+=J[a++]<<R,R+=8)),V+=_&(1<<H)-1,V>u){e.msg="invalid distance too far back",j.mode=d2t;break e}if(_>>>=H,R-=H,H=n-A,V>H){if(H=V-H,H>g&&j.sane){e.msg="invalid distance too far back",j.mode=d2t;break e}if(W=0,X=f,C===0){if(W+=E-H,H<K){K-=H;do Z[n++]=f[W++];while(--H);W=n-V,X=Z}}else if(C<H){if(W+=E+C-H,H-=C,H<K){K-=H;do Z[n++]=f[W++];while(--H);if(W=0,C<K){H=C,K-=H;do Z[n++]=f[W++];while(--H);W=n-V,X=Z}}}else if(W+=C-H,H<K){K-=H;do Z[n++]=f[W++];while(--H);W=n-V,X=Z}for(;K>2;)Z[n++]=X[W++],Z[n++]=X[W++],Z[n++]=X[W++],K-=3;K&&(Z[n++]=X[W++],K>1&&(Z[n++]=X[W++]))}else{W=n-V;do Z[n++]=Z[W++],Z[n++]=Z[W++],Z[n++]=Z[W++],K-=3;while(K>2);K&&(Z[n++]=Z[W++],K>1&&(Z[n++]=Z[W++]))}}else if((H&64)===0){U=w[(U&65535)+(_&(1<<H)-1)];continue s}else{e.msg="invalid distance code",j.mode=d2t;break e}break}}else if((H&64)===0){U=x[(U&65535)+(_&(1<<H)-1)];continue t}else if(H&32){j.mode=ePr;break e}else{e.msg="invalid literal/length code",j.mode=d2t;break e}break}}while(a<i&&n<h);K=R>>3,a-=K,R-=K<<3,_&=(1<<R)-1,e.next_in=a,e.next_out=n,e.avail_in=a<i?5+(i-a):5-(a-i),e.avail_out=n<h?257+(h-n):257-(n-h),j.hold=_,j.bits=R};const ppe=15,zd1=852,Zd1=592,eE1=0,gIs=1,tE1=2,sPr=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]),aPr=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]),iPr=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]),rPr=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]),nPr=(s,e,t,a,i,n,A,h)=>{const u=h.bits;let E=0,g=0,C=0,f=0,_=0,R=0,x=0,w=0,D=0,M=0,U,H,K,V,W,X=null,J;const Z=new Uint16Array(ppe+1),j=new Uint16Array(ppe+1);let z=null,q,se,ie;for(E=0;E<=ppe;E++)Z[E]=0;for(g=0;g<a;g++)Z[e[t+g]]++;for(_=u,f=ppe;f>=1&&Z[f]===0;f--);if(_>f&&(_=f),f===0)return i[n++]=1<<24|64<<16|0,i[n++]=1<<24|64<<16|0,h.bits=1,0;for(C=1;C<f&&Z[C]===0;C++);for(_<C&&(_=C),w=1,E=1;E<=ppe;E++)if(w<<=1,w-=Z[E],w<0)return-1;if(w>0&&(s===eE1||f!==1))return-1;for(j[1]=0,E=1;E<ppe;E++)j[E+1]=j[E]+Z[E];for(g=0;g<a;g++)e[t+g]!==0&&(A[j[e[t+g]]++]=g);if(s===eE1?(X=z=A,J=20):s===gIs?(X=sPr,z=aPr,J=257):(X=iPr,z=rPr,J=0),M=0,g=0,E=C,W=n,R=_,x=0,K=-1,D=1<<_,V=D-1,s===gIs&&D>zd1||s===tE1&&D>Zd1)return 1;for(;;){q=E-x,A[g]+1<J?(se=0,ie=A[g]):A[g]>=J?(se=z[A[g]-J],ie=X[A[g]-J]):(se=96,ie=0),U=1<<E-x,H=1<<R,C=H;do H-=U,i[W+(M>>x)+H]=q<<24|se<<16|ie|0;while(H!==0);for(U=1<<E-1;M&U;)U>>=1;if(U!==0?(M&=U-1,M+=U):M=0,g++,--Z[E]===0){if(E===f)break;E=e[t+A[g]]}if(E>_&&(M&V)!==K){for(x===0&&(x=_),W+=C,R=E-x,w=1<<R;R+x<f&&(w-=Z[R+x],!(w<=0));)R++,w<<=1;if(D+=1<<R,s===gIs&&D>zd1||s===tE1&&D>Zd1)return 1;K=M&V,i[K]=_<<24|R<<16|W-n|0}}return M!==0&&(i[W+M]=E-x<<24|64<<16|0),h.bits=_,0};var SFe=nPr;const cPr=0,fAa=1,_Aa=2,{Z_FINISH:sE1,Z_BLOCK:APr,Z_TREES:E2t,Z_OK:x5e,Z_STREAM_END:oPr,Z_NEED_DICT:uPr,Z_STREAM_ERROR:fM,Z_DATA_ERROR:mAa,Z_MEM_ERROR:BAa,Z_BUF_ERROR:hPr,Z_DEFLATED:aE1}=CAa,Hqt=16180,iE1=16181,rE1=16182,nE1=16183,cE1=16184,AE1=16185,oE1=16186,uE1=16187,hE1=16188,lE1=16189,ZUt=16190,LX=16191,CIs=16192,dE1=16193,pIs=16194,EE1=16195,gE1=16196,CE1=16197,pE1=16198,g2t=16199,C2t=16200,IE1=16201,fE1=16202,_E1=16203,mE1=16204,BE1=16205,IIs=16206,RE1=16207,TE1=16208,SE=16209,RAa=16210,TAa=16211,lPr=852,dPr=592,EPr=15,gPr=EPr,yE1=s=>(s>>>24&255)+(s>>>8&65280)+((s&65280)<<8)+((s&255)<<24);function CPr(){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 _9e=s=>{if(!s)return 1;const e=s.state;return!e||e.strm!==s||e.mode<Hqt||e.mode>TAa?1:0},yAa=s=>{if(_9e(s))return fM;const e=s.state;return s.total_in=s.total_out=e.total=0,s.msg="",e.wrap&&(s.adler=e.wrap&1),e.mode=Hqt,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(lPr),e.distcode=e.distdyn=new Int32Array(dPr),e.sane=1,e.back=-1,x5e},xAa=s=>{if(_9e(s))return fM;const e=s.state;return e.wsize=0,e.whave=0,e.wnext=0,yAa(s)},OAa=(s,e)=>{let t;if(_9e(s))return fM;const a=s.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?fM:(a.window!==null&&a.wbits!==e&&(a.window=null),a.wrap=t,a.wbits=e,xAa(s))},SAa=(s,e)=>{if(!s)return fM;const t=new CPr;s.state=t,t.strm=s,t.window=null,t.mode=Hqt;const a=OAa(s,e);return a!==x5e&&(s.state=null),a},pPr=s=>SAa(s,gPr);let xE1=!0,fIs,_Is;const IPr=s=>{if(xE1){fIs=new Int32Array(512),_Is=new Int32Array(32);let e=0;for(;e<144;)s.lens[e++]=8;for(;e<256;)s.lens[e++]=9;for(;e<280;)s.lens[e++]=7;for(;e<288;)s.lens[e++]=8;for(SFe(fAa,s.lens,0,288,fIs,0,s.work,{bits:9}),e=0;e<32;)s.lens[e++]=5;SFe(_Aa,s.lens,0,32,_Is,0,s.work,{bits:5}),xE1=!1}s.lencode=fIs,s.lenbits=9,s.distcode=_Is,s.distbits=5},LAa=(s,e,t,a)=>{let i;const n=s.state;return n.window===null&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new Uint8Array(n.wsize)),a>=n.wsize?(n.window.set(e.subarray(t-n.wsize,t),0),n.wnext=0,n.whave=n.wsize):(i=n.wsize-n.wnext,i>a&&(i=a),n.window.set(e.subarray(t-a,t-a+i),n.wnext),a-=i,a?(n.window.set(e.subarray(t-a,t),0),n.wnext=a,n.whave=n.wsize):(n.wnext+=i,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=i))),0},fPr=(s,e)=>{let t,a,i,n,A,h,u,E,g,C,f,_,R,x,w=0,D,M,U,H,K,V,W,X;const J=new Uint8Array(4);let Z,j;const z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(_9e(s)||!s.output||!s.input&&s.avail_in!==0)return fM;t=s.state,t.mode===LX&&(t.mode=CIs),A=s.next_out,i=s.output,u=s.avail_out,n=s.next_in,a=s.input,h=s.avail_in,E=t.hold,g=t.bits,C=h,f=u,X=x5e;e:for(;;)switch(t.mode){case Hqt:if(t.wrap===0){t.mode=CIs;break}for(;g<16;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(t.wrap&2&&E===35615){t.wbits===0&&(t.wbits=15),t.check=0,J[0]=E&255,J[1]=E>>>8&255,t.check=tV(t.check,J,2,0),E=0,g=0,t.mode=iE1;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((E&255)<<8)+(E>>8))%31){s.msg="incorrect header check",t.mode=SE;break}if((E&15)!==aE1){s.msg="unknown compression method",t.mode=SE;break}if(E>>>=4,g-=4,W=(E&15)+8,t.wbits===0&&(t.wbits=W),W>15||W>t.wbits){s.msg="invalid window size",t.mode=SE;break}t.dmax=1<<t.wbits,t.flags=0,s.adler=t.check=1,t.mode=E&512?lE1:LX,E=0,g=0;break;case iE1:for(;g<16;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(t.flags=E,(t.flags&255)!==aE1){s.msg="unknown compression method",t.mode=SE;break}if(t.flags&57344){s.msg="unknown header flags set",t.mode=SE;break}t.head&&(t.head.text=E>>8&1),t.flags&512&&t.wrap&4&&(J[0]=E&255,J[1]=E>>>8&255,t.check=tV(t.check,J,2,0)),E=0,g=0,t.mode=rE1;case rE1:for(;g<32;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}t.head&&(t.head.time=E),t.flags&512&&t.wrap&4&&(J[0]=E&255,J[1]=E>>>8&255,J[2]=E>>>16&255,J[3]=E>>>24&255,t.check=tV(t.check,J,4,0)),E=0,g=0,t.mode=nE1;case nE1:for(;g<16;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}t.head&&(t.head.xflags=E&255,t.head.os=E>>8),t.flags&512&&t.wrap&4&&(J[0]=E&255,J[1]=E>>>8&255,t.check=tV(t.check,J,2,0)),E=0,g=0,t.mode=cE1;case cE1:if(t.flags&1024){for(;g<16;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}t.length=E,t.head&&(t.head.extra_len=E),t.flags&512&&t.wrap&4&&(J[0]=E&255,J[1]=E>>>8&255,t.check=tV(t.check,J,2,0)),E=0,g=0}else t.head&&(t.head.extra=null);t.mode=AE1;case AE1:if(t.flags&1024&&(_=t.length,_>h&&(_=h),_&&(t.head&&(W=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(a.subarray(n,n+_),W)),t.flags&512&&t.wrap&4&&(t.check=tV(t.check,a,_,n)),h-=_,n+=_,t.length-=_),t.length))break e;t.length=0,t.mode=oE1;case oE1:if(t.flags&2048){if(h===0)break e;_=0;do W=a[n+_++],t.head&&W&&t.length<65536&&(t.head.name+=String.fromCharCode(W));while(W&&_<h);if(t.flags&512&&t.wrap&4&&(t.check=tV(t.check,a,_,n)),h-=_,n+=_,W)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=uE1;case uE1:if(t.flags&4096){if(h===0)break e;_=0;do W=a[n+_++],t.head&&W&&t.length<65536&&(t.head.comment+=String.fromCharCode(W));while(W&&_<h);if(t.flags&512&&t.wrap&4&&(t.check=tV(t.check,a,_,n)),h-=_,n+=_,W)break e}else t.head&&(t.head.comment=null);t.mode=hE1;case hE1:if(t.flags&512){for(;g<16;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(t.wrap&4&&E!==(t.check&65535)){s.msg="header crc mismatch",t.mode=SE;break}E=0,g=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),s.adler=t.check=0,t.mode=LX;break;case lE1:for(;g<32;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}s.adler=t.check=yE1(E),E=0,g=0,t.mode=ZUt;case ZUt:if(t.havedict===0)return s.next_out=A,s.avail_out=u,s.next_in=n,s.avail_in=h,t.hold=E,t.bits=g,uPr;s.adler=t.check=1,t.mode=LX;case LX:if(e===APr||e===E2t)break e;case CIs:if(t.last){E>>>=g&7,g-=g&7,t.mode=IIs;break}for(;g<3;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}switch(t.last=E&1,E>>>=1,g-=1,E&3){case 0:t.mode=dE1;break;case 1:if(IPr(t),t.mode=g2t,e===E2t){E>>>=2,g-=2;break e}break;case 2:t.mode=gE1;break;case 3:s.msg="invalid block type",t.mode=SE}E>>>=2,g-=2;break;case dE1:for(E>>>=g&7,g-=g&7;g<32;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if((E&65535)!==(E>>>16^65535)){s.msg="invalid stored block lengths",t.mode=SE;break}if(t.length=E&65535,E=0,g=0,t.mode=pIs,e===E2t)break e;case pIs:t.mode=EE1;case EE1:if(_=t.length,_){if(_>h&&(_=h),_>u&&(_=u),_===0)break e;i.set(a.subarray(n,n+_),A),h-=_,n+=_,u-=_,A+=_,t.length-=_;break}t.mode=LX;break;case gE1:for(;g<14;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(t.nlen=(E&31)+257,E>>>=5,g-=5,t.ndist=(E&31)+1,E>>>=5,g-=5,t.ncode=(E&15)+4,E>>>=4,g-=4,t.nlen>286||t.ndist>30){s.msg="too many length or distance symbols",t.mode=SE;break}t.have=0,t.mode=CE1;case CE1:for(;t.have<t.ncode;){for(;g<3;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}t.lens[z[t.have++]]=E&7,E>>>=3,g-=3}for(;t.have<19;)t.lens[z[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,Z={bits:t.lenbits},X=SFe(cPr,t.lens,0,19,t.lencode,0,t.work,Z),t.lenbits=Z.bits,X){s.msg="invalid code lengths set",t.mode=SE;break}t.have=0,t.mode=pE1;case pE1:for(;t.have<t.nlen+t.ndist;){for(;w=t.lencode[E&(1<<t.lenbits)-1],D=w>>>24,M=w>>>16&255,U=w&65535,!(D<=g);){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(U<16)E>>>=D,g-=D,t.lens[t.have++]=U;else{if(U===16){for(j=D+2;g<j;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(E>>>=D,g-=D,t.have===0){s.msg="invalid bit length repeat",t.mode=SE;break}W=t.lens[t.have-1],_=3+(E&3),E>>>=2,g-=2}else if(U===17){for(j=D+3;g<j;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}E>>>=D,g-=D,W=0,_=3+(E&7),E>>>=3,g-=3}else{for(j=D+7;g<j;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}E>>>=D,g-=D,W=0,_=11+(E&127),E>>>=7,g-=7}if(t.have+_>t.nlen+t.ndist){s.msg="invalid bit length repeat",t.mode=SE;break}for(;_--;)t.lens[t.have++]=W}}if(t.mode===SE)break;if(t.lens[256]===0){s.msg="invalid code -- missing end-of-block",t.mode=SE;break}if(t.lenbits=9,Z={bits:t.lenbits},X=SFe(fAa,t.lens,0,t.nlen,t.lencode,0,t.work,Z),t.lenbits=Z.bits,X){s.msg="invalid literal/lengths set",t.mode=SE;break}if(t.distbits=6,t.distcode=t.distdyn,Z={bits:t.distbits},X=SFe(_Aa,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,Z),t.distbits=Z.bits,X){s.msg="invalid distances set",t.mode=SE;break}if(t.mode=g2t,e===E2t)break e;case g2t:t.mode=C2t;case C2t:if(h>=6&&u>=258){s.next_out=A,s.avail_out=u,s.next_in=n,s.avail_in=h,t.hold=E,t.bits=g,tPr(s,f),A=s.next_out,i=s.output,u=s.avail_out,n=s.next_in,a=s.input,h=s.avail_in,E=t.hold,g=t.bits,t.mode===LX&&(t.back=-1);break}for(t.back=0;w=t.lencode[E&(1<<t.lenbits)-1],D=w>>>24,M=w>>>16&255,U=w&65535,!(D<=g);){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(M&&(M&240)===0){for(H=D,K=M,V=U;w=t.lencode[V+((E&(1<<H+K)-1)>>H)],D=w>>>24,M=w>>>16&255,U=w&65535,!(H+D<=g);){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}E>>>=H,g-=H,t.back+=H}if(E>>>=D,g-=D,t.back+=D,t.length=U,M===0){t.mode=BE1;break}if(M&32){t.back=-1,t.mode=LX;break}if(M&64){s.msg="invalid literal/length code",t.mode=SE;break}t.extra=M&15,t.mode=IE1;case IE1:if(t.extra){for(j=t.extra;g<j;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}t.length+=E&(1<<t.extra)-1,E>>>=t.extra,g-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=fE1;case fE1:for(;w=t.distcode[E&(1<<t.distbits)-1],D=w>>>24,M=w>>>16&255,U=w&65535,!(D<=g);){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if((M&240)===0){for(H=D,K=M,V=U;w=t.distcode[V+((E&(1<<H+K)-1)>>H)],D=w>>>24,M=w>>>16&255,U=w&65535,!(H+D<=g);){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}E>>>=H,g-=H,t.back+=H}if(E>>>=D,g-=D,t.back+=D,M&64){s.msg="invalid distance code",t.mode=SE;break}t.offset=U,t.extra=M&15,t.mode=_E1;case _E1:if(t.extra){for(j=t.extra;g<j;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}t.offset+=E&(1<<t.extra)-1,E>>>=t.extra,g-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){s.msg="invalid distance too far back",t.mode=SE;break}t.mode=mE1;case mE1:if(u===0)break e;if(_=f-u,t.offset>_){if(_=t.offset-_,_>t.whave&&t.sane){s.msg="invalid distance too far back",t.mode=SE;break}_>t.wnext?(_-=t.wnext,R=t.wsize-_):R=t.wnext-_,_>t.length&&(_=t.length),x=t.window}else x=i,R=A-t.offset,_=t.length;_>u&&(_=u),u-=_,t.length-=_;do i[A++]=x[R++];while(--_);t.length===0&&(t.mode=C2t);break;case BE1:if(u===0)break e;i[A++]=t.length,u--,t.mode=C2t;break;case IIs:if(t.wrap){for(;g<32;){if(h===0)break e;h--,E|=a[n++]<<g,g+=8}if(f-=u,s.total_out+=f,t.total+=f,t.wrap&4&&f&&(s.adler=t.check=t.flags?tV(t.check,i,f,A-f):bvs(t.check,i,f,A-f)),f=u,t.wrap&4&&(t.flags?E:yE1(E))!==t.check){s.msg="incorrect data check",t.mode=SE;break}E=0,g=0}t.mode=RE1;case RE1:if(t.wrap&&t.flags){for(;g<32;){if(h===0)break e;h--,E+=a[n++]<<g,g+=8}if(t.wrap&4&&E!==(t.total&4294967295)){s.msg="incorrect length check",t.mode=SE;break}E=0,g=0}t.mode=TE1;case TE1:X=oPr;break e;case SE:X=mAa;break e;case RAa:return BAa;case TAa:default:return fM}return s.next_out=A,s.avail_out=u,s.next_in=n,s.avail_in=h,t.hold=E,t.bits=g,(t.wsize||f!==s.avail_out&&t.mode<SE&&(t.mode<IIs||e!==sE1))&&LAa(s,s.output,s.next_out,f-s.avail_out),C-=s.avail_in,f-=s.avail_out,s.total_in+=C,s.total_out+=f,t.total+=f,t.wrap&4&&f&&(s.adler=t.check=t.flags?tV(t.check,i,f,s.next_out-f):bvs(t.check,i,f,s.next_out-f)),s.data_type=t.bits+(t.last?64:0)+(t.mode===LX?128:0)+(t.mode===g2t||t.mode===pIs?256:0),(C===0&&f===0||e===sE1)&&X===x5e&&(X=hPr),X},_Pr=s=>{if(_9e(s))return fM;let e=s.state;return e.window&&(e.window=null),s.state=null,x5e},mPr=(s,e)=>{if(_9e(s))return fM;const t=s.state;return(t.wrap&2)===0?fM:(t.head=e,e.done=!1,x5e)},BPr=(s,e)=>{const t=e.length;let a,i,n;return _9e(s)||(a=s.state,a.wrap!==0&&a.mode!==ZUt)?fM:a.mode===ZUt&&(i=1,i=bvs(i,e,t,0),i!==a.check)?mAa:(n=LAa(s,e,t,t),n?(a.mode=RAa,BAa):(a.havedict=1,x5e))};var RPr=xAa,TPr=OAa,yPr=yAa,xPr=pPr,OPr=SAa,SPr=fPr,LPr=_Pr,QPr=mPr,vPr=BPr,wPr="pako inflate (from Nodeca project)",cq={inflateReset:RPr,inflateReset2:TPr,inflateResetKeep:yPr,inflateInit:xPr,inflateInit2:OPr,inflate:SPr,inflateEnd:LPr,inflateGetHeader:QPr,inflateSetDictionary:vPr,inflateInfo:wPr};function NPr(){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 DPr=NPr;const QAa=Object.prototype.toString,{Z_NO_FLUSH:kPr,Z_FINISH:bPr,Z_OK:tYe,Z_STREAM_END:mIs,Z_NEED_DICT:BIs,Z_STREAM_ERROR:MPr,Z_DATA_ERROR:OE1,Z_MEM_ERROR:UPr}=CAa;function j$e(s){this.options=pAa.assign({chunkSize:1024*64,windowBits:15,to:""},s||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(s&&s.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ZFr,this.strm.avail_out=0;let t=cq.inflateInit2(this.strm,e.windowBits);if(t!==tYe)throw new Error(Mvs[t]);if(this.header=new DPr,cq.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Uvs.string2buf(e.dictionary):QAa.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=cq.inflateSetDictionary(this.strm,e.dictionary),t!==tYe)))throw new Error(Mvs[t])}j$e.prototype.push=function(s,e){const t=this.strm,a=this.options.chunkSize,i=this.options.dictionary;let n,A,h;if(this.ended)return!1;for(e===~~e?A=e:A=e===!0?bPr:kPr,QAa.call(s)==="[object ArrayBuffer]"?t.input=new Uint8Array(s):t.input=s,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(a),t.next_out=0,t.avail_out=a),n=cq.inflate(t,A),n===BIs&&i&&(n=cq.inflateSetDictionary(t,i),n===tYe?n=cq.inflate(t,A):n===OE1&&(n=BIs));t.avail_in>0&&n===mIs&&t.state.wrap>0&&s[t.next_in]!==0;)cq.inflateReset(t),n=cq.inflate(t,A);switch(n){case MPr:case OE1:case BIs:case UPr:return this.onEnd(n),this.ended=!0,!1}if(h=t.avail_out,t.next_out&&(t.avail_out===0||n===mIs))if(this.options.to==="string"){let u=Uvs.utf8border(t.output,t.next_out),E=t.next_out-u,g=Uvs.buf2string(t.output,u);t.next_out=E,t.avail_out=a-E,E&&t.output.set(t.output.subarray(u,u+E),0),this.onData(g)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(n===tYe&&h===0)){if(n===mIs)return n=cq.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};j$e.prototype.onData=function(s){this.chunks.push(s)};j$e.prototype.onEnd=function(s){s===tYe&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=pAa.flattenChunks(this.chunks)),this.chunks=[],this.err=s,this.msg=this.strm.msg};function FPr(s,e){const t=new j$e(e);if(t.push(s),t.err)throw t.msg||Mvs[t.err];return t.result}var PPr=j$e,HPr=FPr,GPr={Inflate:PPr,inflate:HPr};const{Inflate:YPr,inflate:KPr}=GPr;var SE1=YPr,VPr=KPr;const vAa=[];for(let s=0;s<256;s++){let e=s;for(let t=0;t<8;t++)e&1?e=3988292384^e>>>1:e=e>>>1;vAa[s]=e}const LE1=4294967295;function jPr(s,e,t){let a=s;for(let i=0;i<t;i++)a=vAa[(a^e[i])&255]^a>>>8;return a}function WPr(s,e){return(jPr(LE1,s,e)^LE1)>>>0}function QE1(s,e,t){const a=s.readUint32(),i=WPr(new Uint8Array(s.buffer,s.byteOffset+s.offset-e-4,e),e);if(i!==a)throw new Error(`CRC mismatch for chunk ${t}. Expected ${a}, found ${i}`)}function wAa(s,e,t){for(let a=0;a<t;a++)e[a]=s[a]}function NAa(s,e,t,a){let i=0;for(;i<a;i++)e[i]=s[i];for(;i<t;i++)e[i]=s[i]+e[i-a]&255}function DAa(s,e,t,a){let i=0;if(t.length===0)for(;i<a;i++)e[i]=s[i];else for(;i<a;i++)e[i]=s[i]+t[i]&255}function kAa(s,e,t,a,i){let n=0;if(t.length===0){for(;n<i;n++)e[n]=s[n];for(;n<a;n++)e[n]=s[n]+(e[n-i]>>1)&255}else{for(;n<i;n++)e[n]=s[n]+(t[n]>>1)&255;for(;n<a;n++)e[n]=s[n]+(e[n-i]+t[n]>>1)&255}}function bAa(s,e,t,a,i){let n=0;if(t.length===0){for(;n<i;n++)e[n]=s[n];for(;n<a;n++)e[n]=s[n]+e[n-i]&255}else{for(;n<i;n++)e[n]=s[n]+t[n]&255;for(;n<a;n++)e[n]=s[n]+$Pr(e[n-i],t[n],t[n-i])&255}}function $Pr(s,e,t){const a=s+e-t,i=Math.abs(a-s),n=Math.abs(a-e),A=Math.abs(a-t);return i<=n&&i<=A?s:n<=A?e:t}function JPr(s,e,t,a,i,n){switch(s){case 0:wAa(e,t,i);break;case 1:NAa(e,t,i,n);break;case 2:DAa(e,t,a,i);break;case 3:kAa(e,t,a,i,n);break;case 4:bAa(e,t,a,i,n);break;default:throw new Error(`Unsupported filter: ${s}`)}}const XPr=new Uint16Array([255]),qPr=new Uint8Array(XPr.buffer),zPr=qPr[0]===255;function ZPr(s){const{data:e,width:t,height:a,channels:i,depth:n}=s,A=[{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}],h=Math.ceil(n/8)*i,u=new Uint8Array(a*t*h);let E=0;for(let g=0;g<7;g++){const C=A[g],f=Math.ceil((t-C.x)/C.xStep),_=Math.ceil((a-C.y)/C.yStep);if(f<=0||_<=0)continue;const R=f*h,x=new Uint8Array(R);for(let w=0;w<_;w++){const D=e[E++],M=e.subarray(E,E+R);E+=R;const U=new Uint8Array(R);JPr(D,M,U,x,R,h),x.set(U);for(let H=0;H<f;H++){const K=C.x+H*C.xStep,V=C.y+w*C.yStep;if(!(K>=t||V>=a))for(let W=0;W<h;W++)u[(V*t+K)*h+W]=U[H*h+W]}}}if(n===16){const g=new Uint16Array(u.buffer);if(zPr)for(let C=0;C<g.length;C++)g[C]=eHr(g[C]);return g}else return u}function eHr(s){return(s&255)<<8|s>>8&255}const tHr=new Uint16Array([255]),sHr=new Uint8Array(tHr.buffer),aHr=sHr[0]===255,iHr=new Uint8Array(0);function vE1(s){const{data:e,width:t,height:a,channels:i,depth:n}=s,A=Math.ceil(n/8)*i,h=Math.ceil(n/8*i*t),u=new Uint8Array(a*h);let E=iHr,g=0,C,f;for(let _=0;_<a;_++){switch(C=e.subarray(g+1,g+1+h),f=u.subarray(_*h,(_+1)*h),e[g]){case 0:wAa(C,f,h);break;case 1:NAa(C,f,h,A);break;case 2:DAa(C,f,E,h);break;case 3:kAa(C,f,E,h,A);break;case 4:bAa(C,f,E,h,A);break;default:throw new Error(`Unsupported filter: ${e[g]}`)}E=f,g+=h+1}if(n===16){const _=new Uint16Array(u.buffer);if(aHr)for(let R=0;R<_.length;R++)_[R]=rHr(_[R]);return _}else return u}function rHr(s){return(s&255)<<8|s>>8&255}const ISt=Uint8Array.of(137,80,78,71,13,10,26,10);function wE1(s){if(!nHr(s.readBytes(ISt.length)))throw new Error("wrong PNG signature")}function nHr(s){if(s.length<ISt.length)return!1;for(let e=0;e<ISt.length;e++)if(s[e]!==ISt[e])return!1;return!0}const cHr="tEXt",AHr=0,MAa=new TextDecoder("latin1");function oHr(s){if(hHr(s),s.length===0||s.length>79)throw new Error("keyword length must be between 1 and 79")}const uHr=/^[\u0000-\u00FF]*$/;function hHr(s){if(!uHr.test(s))throw new Error("invalid latin1 text")}function lHr(s,e,t){const a=UAa(e);s[a]=dHr(e,t-a.length-1)}function UAa(s){for(s.mark();s.readByte()!==AHr;);const e=s.offset;s.reset();const t=MAa.decode(s.readBytes(e-s.offset-1));return s.skip(1),oHr(t),t}function dHr(s,e){return MAa.decode(s.readBytes(e))}const ww={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},RIs={UNKNOWN:-1,DEFLATE:0},NE1={UNKNOWN:-1,ADAPTIVE:0},TIs={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},p2t={NONE:0,BACKGROUND:1,PREVIOUS:2},yIs={SOURCE:0,OVER:1};class EHr extends wC0{constructor(t,a={}){super(t);G(this,"_checkCrc");G(this,"_inflator");G(this,"_png");G(this,"_apng");G(this,"_end");G(this,"_hasPalette");G(this,"_palette");G(this,"_hasTransparency");G(this,"_transparency");G(this,"_compressionMethod");G(this,"_filterMethod");G(this,"_interlaceMethod");G(this,"_colorType");G(this,"_isAnimated");G(this,"_numberOfFrames");G(this,"_numberOfPlays");G(this,"_frames");G(this,"_writingDataChunks");const{checkCrc:i=!1}=a;this._checkCrc=i,this._inflator=new SE1,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=RIs.UNKNOWN,this._filterMethod=NE1.UNKNOWN,this._interlaceMethod=TIs.UNKNOWN,this._colorType=ww.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(wE1(this);!this._end;){const t=this.readUint32(),a=this.readChars(4);this.decodeChunk(t,a)}return this.decodeImage(),this._png}decodeApng(){for(wE1(this);!this._end;){const t=this.readUint32(),a=this.readChars(4);this.decodeApngChunk(t,a)}return this.decodeApngImage(),this._apng}decodeChunk(t,a){const i=this.offset;switch(a){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case cHr:lHr(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-i!==t)throw new Error(`Length mismatch while decoding chunk ${a}`);this._checkCrc?QE1(this,t+4,a):this.skip(4)}decodeApngChunk(t,a){const i=this.offset;switch(a!=="fdAT"&&a!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),a){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,a),this.offset=i+t;break}if(this.offset-i!==t)throw new Error(`Length mismatch while decoding chunk ${a}`);this._checkCrc?QE1(this,t+4,a):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=gHr(this.readUint8());const a=this.readUint8();this._colorType=a;let i;switch(a){case ww.GREYSCALE:i=1;break;case ww.TRUECOLOUR:i=3;break;case ww.INDEXED_COLOUR:i=1;break;case ww.GREYSCALE_ALPHA:i=2;break;case ww.TRUECOLOUR_ALPHA:i=4;break;case ww.UNKNOWN:default:throw new Error(`Unknown color type: ${a}`)}if(this._png.channels=i,this._compressionMethod=this.readUint8(),this._compressionMethod!==RIs.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 t={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(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const a=t/3;this._hasPalette=!0;const i=[];this._palette=i;for(let n=0;n<a;n++)i.push([this.readUint8(),this.readUint8(),this.readUint8()])}decodeIDAT(t){this._writingDataChunks=!0;const a=t,i=this.offset+this.byteOffset;if(this._inflator.push(new Uint8Array(this.buffer,i,a)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodeFDAT(t){this._writingDataChunks=!0;let a=t,i=this.offset+this.byteOffset;if(i+=4,a-=4,this._inflator.push(new Uint8Array(this.buffer,i,a)),this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);this.skip(t)}decodetRNS(t){switch(this._colorType){case ww.GREYSCALE:case ww.TRUECOLOUR:{if(t%2!==0)throw new RangeError(`tRNS chunk length must be a multiple of 2. Got ${t}`);if(t/2>this._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let a=0;a<t/2;a++)this._transparency[a]=this.readUint16();break}case ww.INDEXED_COLOUR:{if(t>this._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let a=0;for(;a<t;a++){const i=this.readByte();this._palette[a].push(i)}for(;a<this._palette.length;a++)this._palette[a].push(255);break}case ww.UNKNOWN:case ww.GREYSCALE_ALPHA:case ww.TRUECOLOUR_ALPHA:default:throw new Error(`tRNS chunk is not supported for color type ${this._colorType}`)}}decodeiCCP(t){const a=UAa(this),i=this.readUint8();if(i!==RIs.DEFLATE)throw new Error(`Unsupported iCCP compression method: ${i}`);const n=this.readBytes(t-a.length-2);this._png.iccEmbeddedProfile={name:a,profile:VPr(n)}}decodepHYs(){const t=this.readUint32(),a=this.readUint32(),i=this.readByte();this._png.resolution={x:t,y:a,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 t=0;t<this._numberOfFrames;t++){const a={sequenceNumber:this._frames[t].sequenceNumber,delayNumber:this._frames[t].delayNumber,delayDenominator:this._frames[t].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(t);if(i){if(i.data=vE1({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),t===0||i.xOffset===0&&i.yOffset===0&&i.width===this._png.width&&i.height===this._png.height)a.data=i.data;else{const n=this._apng.frames.at(t-1);this.disposeFrame(i,n,a),this.addFrameDataToCanvas(a,i)}this._apng.frames.push(a)}}return this._apng}disposeFrame(t,a,i){switch(t.disposeOp){case p2t.NONE:break;case p2t.BACKGROUND:for(let n=0;n<this._png.height;n++)for(let A=0;A<this._png.width;A++){const h=(n*t.width+A)*this._png.channels;for(let u=0;u<this._png.channels;u++)i.data[h+u]=0}break;case p2t.PREVIOUS:i.data.set(a.data);break;default:throw new Error("Unknown disposeOp")}}addFrameDataToCanvas(t,a){const i=1<<this._png.depth,n=(A,h)=>{const u=((A+a.yOffset)*this._png.width+a.xOffset+h)*this._png.channels,E=(A*a.width+h)*this._png.channels;return{index:u,frameIndex:E}};switch(a.blendOp){case yIs.SOURCE:for(let A=0;A<a.height;A++)for(let h=0;h<a.width;h++){const{index:u,frameIndex:E}=n(A,h);for(let g=0;g<this._png.channels;g++)t.data[u+g]=a.data[E+g]}break;case yIs.OVER:for(let A=0;A<a.height;A++)for(let h=0;h<a.width;h++){const{index:u,frameIndex:E}=n(A,h);for(let g=0;g<this._png.channels;g++){const C=a.data[E+this._png.channels-1]/i,f=g%(this._png.channels-1)===0?1:a.data[E+g],_=Math.floor(C*f+(1-C)*t.data[u+g]);t.data[u+g]+=_}}break;default:throw new Error("Unknown blendOp")}}decodeImage(){var a;if(this._inflator.err)throw new Error(`Error while decompressing the data: ${this._inflator.err}`);const t=this._isAnimated?((a=this._frames)==null?void 0:a.at(0)).data:this._inflator.result;if(this._filterMethod!==NE1.ADAPTIVE)throw new Error(`Filter method ${this._filterMethod} not supported`);if(this._interlaceMethod===TIs.NO_INTERLACE)this._png.data=vE1({data:t,width:this._png.width,height:this._png.height,channels:this._png.channels,depth:this._png.depth});else if(this._interlaceMethod===TIs.ADAM7)this._png.data=ZPr({data:t,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 t=this._inflator.result,a=this._frames.at(-1);a?a.data=t:this._frames.push({sequenceNumber:0,width:this._png.width,height:this._png.height,xOffset:0,yOffset:0,delayNumber:0,delayDenominator:0,disposeOp:p2t.NONE,blendOp:yIs.SOURCE,data:t}),this._inflator=new SE1,this._writingDataChunks=!1}}function gHr(s){if(s!==1&&s!==2&&s!==4&&s!==8&&s!==16)throw new Error(`invalid bit depth: ${s}`);return s}var DE1;(function(s){s[s.UNKNOWN=0]="UNKNOWN",s[s.METRE=1]="METRE"})(DE1||(DE1={}));function CHr(s,e){return new EHr(s,e).decode()}var hu=(function(){return typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:this})();function xIs(){hu.console&&typeof hu.console.log=="function"&&hu.console.log.apply(hu.console,arguments)}var n8={log:xIs,warn:function(s){hu.console&&(typeof hu.console.warn=="function"?hu.console.warn.apply(hu.console,arguments):xIs.call(null,arguments))},error:function(s){hu.console&&(typeof hu.console.error=="function"?hu.console.error.apply(hu.console,arguments):xIs(s))}};function OIs(s,e,t){var a=new XMLHttpRequest;a.open("GET",s),a.responseType="blob",a.onload=function(){b4e(a.response,e,t)},a.onerror=function(){n8.error("could not download file")},a.send()}function kE1(s){var e=new XMLHttpRequest;e.open("HEAD",s,!1);try{e.send()}catch{}return e.status>=200&&e.status<=299}function I2t(s){try{s.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),s.dispatchEvent(e)}}var b4e=hu.saveAs||((typeof window>"u"?"undefined":r5(window))!=="object"||window!==hu?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(s,e,t){var a=hu.URL||hu.webkitURL,i=document.createElement("a");e=e||s.name||"download",i.download=e,i.rel="noopener",typeof s=="string"?(i.href=s,i.origin!==location.origin?kE1(i.href)?OIs(s,e,t):I2t(i,i.target="_blank"):I2t(i)):(i.href=a.createObjectURL(s),setTimeout(function(){a.revokeObjectURL(i.href)},4e4),setTimeout(function(){I2t(i)},0))}:"msSaveOrOpenBlob"in navigator?function(s,e,t){if(e=e||s.name||"download",typeof s=="string")if(kE1(s))OIs(s,e,t);else{var a=document.createElement("a");a.href=s,a.target="_blank",setTimeout(function(){I2t(a)})}else navigator.msSaveOrOpenBlob((function(i,n){return n===void 0?n={autoBom:!1}:r5(n)!=="object"&&(n8.warn("Deprecated: Expected third argument to be a object"),n={autoBom:!n}),n.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})(s,t),e)}:function(s,e,t,a){if((a=a||open("","_blank"))&&(a.document.title=a.document.body.innerText="downloading..."),typeof s=="string")return OIs(s,e,t);var i=s.type==="application/octet-stream",n=/constructor/i.test(hu.HTMLElement)||hu.safari,A=/CriOS\/[\d]+/.test(navigator.userAgent);if((A||i&&n)&&(typeof FileReader>"u"?"undefined":r5(FileReader))==="object"){var h=new FileReader;h.onloadend=function(){var g=h.result;g=A?g:g.replace(/^data:[^;]*;/,"data:attachment/file;"),a?a.location.href=g:location=g,a=null},h.readAsDataURL(s)}else{var u=hu.URL||hu.webkitURL,E=u.createObjectURL(s);a?a.location=E:location.href=E,a=null,setTimeout(function(){u.revokeObjectURL(E)},4e4)}});/**
8647
8647
  * A class to parse color values
@@ -8866,7 +8866,7 @@ end`};e.events.push(["putFont",function(n){(function(A){var h=A.font,u=A.out,E=A
8866
8866
  `))}function u(_,R,x,w){const D=x.enter("tableCell"),M=x.enter("phrasing"),U=x.containerPhrasing(_,{...w,before:n,after:n});return M(),D(),U}function E(_,R){return AXr(_,{align:R,alignDelimiters:a,padding:t,stringLength:i})}function g(_,R,x){const w=_.children;let D=-1;const M=[],U=R.enter("table");for(;++D<w.length;)M[D]=C(w[D],R,x);return U(),M}function C(_,R,x){const w=_.children;let D=-1;const M=[],U=R.enter("tableRow");for(;++D<w.length;)M[D]=u(w[D],_,R,x);return U(),M}function f(_,R,x){let w=Oua.inlineCode(_,R,x);return x.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function eqr(){return{exit:{taskListCheckValueChecked:hC1,taskListCheckValueUnchecked:hC1,paragraph:sqr}}}function tqr(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:aqr}}}function hC1(s){const e=this.stack[this.stack.length-2];e.type,e.checked=s.type==="taskListCheckValueChecked"}function sqr(s){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const t=this.stack[this.stack.length-1];t.type;const a=t.children[0];if(a&&a.type==="text"){const i=e.children;let n=-1,A;for(;++n<i.length;){const h=i[n];if(h.type==="paragraph"){A=h;break}}A===t&&(a.value=a.value.slice(1),a.value.length===0?t.children.shift():t.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,t.position.start=Object.assign({},a.position.start)))}}this.exit(s)}function aqr(s,e,t,a){const i=s.children[0],n=typeof s.checked=="boolean"&&i&&i.type==="paragraph",A="["+(s.checked?"x":" ")+"] ",h=t.createTracker(a);n&&h.move(A);let u=Oua.listItem(s,e,t,{...a,...h.current()});return n&&(u=u.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,E)),u;function E(g){return g+A}}function iqr(){return[vJr(),zJr(),sXr(),WXr(),eqr()]}function rqr(s){return{extensions:[wJr(),ZJr(s),aXr(),ZXr(s),tqr()]}}function nqr(s,e,t,a){const i=s.length;let n=0,A;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,a.length<1e4)A=Array.from(a),A.unshift(e,t),s.splice(...A);else for(t&&s.splice(e,t);n<a.length;)A=a.slice(n,n+1e4),A.unshift(e,0),s.splice(...A),n+=1e4,e+=1e4}const lC1={}.hasOwnProperty;function cqr(s){const e={};let t=-1;for(;++t<s.length;)Aqr(e,s[t]);return e}function Aqr(s,e){let t;for(t in e){const i=(lC1.call(s,t)?s[t]:void 0)||(s[t]={}),n=e[t];let A;if(n)for(A in n){lC1.call(i,A)||(i[A]=[]);const h=n[A];oqr(i[A],Array.isArray(h)?h:h?[h]:[])}}}function oqr(s,e){let t=-1;const a=[];for(;++t<e.length;)(e[t].add==="after"?s:a).push(e[t]);nqr(s,0,0,a)}const cYe=$qt(/[A-Za-z]/),rp0=$qt(/[\dA-Za-z]/);function uqr(s){return s!==null&&(s<32||s===127)}function dRe(s){return s!==null&&(s<0||s===32)}const Sua=$qt(new RegExp("\\p{P}|\\p{S}","u")),AYe=$qt(/\s/);function $qt(s){return e;function e(t){return t!==null&&t>-1&&s.test(String.fromCharCode(t))}}const hqr={tokenize:pqr,partial:!0},Lua={tokenize:Iqr,partial:!0},Qua={tokenize:fqr,partial:!0},vua={tokenize:_qr,partial:!0},lqr={tokenize:mqr,partial:!0},wua={name:"wwwAutolink",tokenize:gqr,previous:Dua},Nua={name:"protocolAutolink",tokenize:Cqr,previous:kua},LZ={name:"emailAutolink",tokenize:Eqr,previous:bua},VW={};function dqr(){return{text:VW}}let Koe=48;for(;Koe<123;)VW[Koe]=LZ,Koe++,Koe===58?Koe=65:Koe===91&&(Koe=97);VW[43]=LZ;VW[45]=LZ;VW[46]=LZ;VW[95]=LZ;VW[72]=[LZ,Nua];VW[104]=[LZ,Nua];VW[87]=[LZ,wua];VW[119]=[LZ,wua];function Eqr(s,e,t){const a=this;let i,n;return A;function A(C){return!aws(C)||!bua.call(a,a.previous)||np0(a.events)?t(C):(s.enter("literalAutolink"),s.enter("literalAutolinkEmail"),h(C))}function h(C){return aws(C)?(s.consume(C),h):C===64?(s.consume(C),u):t(C)}function u(C){return C===46?s.check(lqr,g,E)(C):C===45||C===95||rp0(C)?(n=!0,s.consume(C),u):g(C)}function E(C){return s.consume(C),i=!0,u}function g(C){return n&&i&&cYe(a.previous)?(s.exit("literalAutolinkEmail"),s.exit("literalAutolink"),e(C)):t(C)}}function gqr(s,e,t){const a=this;return i;function i(A){return A!==87&&A!==119||!Dua.call(a,a.previous)||np0(a.events)?t(A):(s.enter("literalAutolink"),s.enter("literalAutolinkWww"),s.check(hqr,s.attempt(Lua,s.attempt(Qua,n),t),t)(A))}function n(A){return s.exit("literalAutolinkWww"),s.exit("literalAutolink"),e(A)}}function Cqr(s,e,t){const a=this;let i="",n=!1;return A;function A(C){return(C===72||C===104)&&kua.call(a,a.previous)&&!np0(a.events)?(s.enter("literalAutolink"),s.enter("literalAutolinkHttp"),i+=String.fromCodePoint(C),s.consume(C),h):t(C)}function h(C){if(cYe(C)&&i.length<5)return i+=String.fromCodePoint(C),s.consume(C),h;if(C===58){const f=i.toLowerCase();if(f==="http"||f==="https")return s.consume(C),u}return t(C)}function u(C){return C===47?(s.consume(C),n?E:(n=!0,u)):t(C)}function E(C){return C===null||uqr(C)||dRe(C)||AYe(C)||Sua(C)?t(C):s.attempt(Lua,s.attempt(Qua,g),t)(C)}function g(C){return s.exit("literalAutolinkHttp"),s.exit("literalAutolink"),e(C)}}function pqr(s,e,t){let a=0;return i;function i(A){return(A===87||A===119)&&a<3?(a++,s.consume(A),i):A===46&&a===3?(s.consume(A),n):t(A)}function n(A){return A===null?t(A):e(A)}}function Iqr(s,e,t){let a,i,n;return A;function A(E){return E===46||E===95?s.check(vua,u,h)(E):E===null||dRe(E)||AYe(E)||E!==45&&Sua(E)?u(E):(n=!0,s.consume(E),A)}function h(E){return E===95?a=!0:(i=a,a=void 0),s.consume(E),A}function u(E){return i||a||!n?t(E):e(E)}}function fqr(s,e){let t=0,a=0;return i;function i(A){return A===40?(t++,s.consume(A),i):A===41&&a<t?n(A):A===33||A===34||A===38||A===39||A===41||A===42||A===44||A===46||A===58||A===59||A===60||A===63||A===93||A===95||A===126?s.check(vua,e,n)(A):A===null||dRe(A)||AYe(A)?e(A):(s.consume(A),i)}function n(A){return A===41&&a++,s.consume(A),i}}function _qr(s,e,t){return a;function a(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(s.consume(h),a):h===38?(s.consume(h),n):h===93?(s.consume(h),i):h===60||h===null||dRe(h)||AYe(h)?e(h):t(h)}function i(h){return h===null||h===40||h===91||dRe(h)||AYe(h)?e(h):a(h)}function n(h){return cYe(h)?A(h):t(h)}function A(h){return h===59?(s.consume(h),a):cYe(h)?(s.consume(h),A):t(h)}}function mqr(s,e,t){return a;function a(n){return s.consume(n),i}function i(n){return rp0(n)?t(n):e(n)}}function Dua(s){return s===null||s===40||s===42||s===95||s===91||s===93||s===126||dRe(s)}function kua(s){return!cYe(s)}function bua(s){return!(s===47||aws(s))}function aws(s){return s===43||s===45||s===46||s===95||rp0(s)}function np0(s){let e=s.length,t=!1;for(;e--;){const a=s[e][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){t=!0;break}if(a._gfmAutolinkLiteralWalkedInto){t=!1;break}}return s.length>0&&!t&&(s[s.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}function Bqr(s){return s!==null&&s<-2}function cFt(s){return s!==null&&(s<0||s===32)}function iws(s){return s===-2||s===-1||s===32}function cp0(s,e,t,a){const i=a?a-1:Number.POSITIVE_INFINITY;let n=0;return A;function A(u){return iws(u)?(s.enter(t),h(u)):e(u)}function h(u){return iws(u)&&n++<i?(s.consume(u),h):(s.exit(t),e(u))}}const Rqr={partial:!0,tokenize:Tqr};function Tqr(s,e,t){return a;function a(n){return iws(n)?cp0(s,i,"linePrefix")(n):i(n)}function i(n){return n===null||Bqr(n)?e(n):t(n)}}function Ap0(s){return s.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const yqr={tokenize:Nqr,partial:!0};function xqr(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Qqr,continuation:{tokenize:vqr},exit:wqr}},text:{91:{name:"gfmFootnoteCall",tokenize:Lqr},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Oqr,resolveTo:Sqr}}}}function Oqr(s,e,t){const a=this;let i=a.events.length;const n=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let A;for(;i--;){const u=a.events[i][1];if(u.type==="labelImage"){A=u;break}if(u.type==="gfmFootnoteCall"||u.type==="labelLink"||u.type==="label"||u.type==="image"||u.type==="link")break}return h;function h(u){if(!A||!A._balanced)return t(u);const E=Ap0(a.sliceSerialize({start:A.end,end:a.now()}));return E.codePointAt(0)!==94||!n.includes(E.slice(1))?t(u):(s.enter("gfmFootnoteCallLabelMarker"),s.consume(u),s.exit("gfmFootnoteCallLabelMarker"),e(u))}}function Sqr(s,e){let t=s.length;for(;t--;)if(s[t][1].type==="labelImage"&&s[t][0]==="enter"){s[t][1];break}s[t+1][1].type="data",s[t+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},s[t+3][1].start),end:Object.assign({},s[s.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},s[t+3][1].end),end:Object.assign({},s[t+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const n={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},s[s.length-1][1].start)},A={type:"chunkString",contentType:"string",start:Object.assign({},n.start),end:Object.assign({},n.end)},h=[s[t+1],s[t+2],["enter",a,e],s[t+3],s[t+4],["enter",i,e],["exit",i,e],["enter",n,e],["enter",A,e],["exit",A,e],["exit",n,e],s[s.length-2],s[s.length-1],["exit",a,e]];return s.splice(t,s.length-t+1,...h),s}function Lqr(s,e,t){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let n=0,A;return h;function h(C){return s.enter("gfmFootnoteCall"),s.enter("gfmFootnoteCallLabelMarker"),s.consume(C),s.exit("gfmFootnoteCallLabelMarker"),u}function u(C){return C!==94?t(C):(s.enter("gfmFootnoteCallMarker"),s.consume(C),s.exit("gfmFootnoteCallMarker"),s.enter("gfmFootnoteCallString"),s.enter("chunkString").contentType="string",E)}function E(C){if(n>999||C===93&&!A||C===null||C===91||cFt(C))return t(C);if(C===93){s.exit("chunkString");const f=s.exit("gfmFootnoteCallString");return i.includes(Ap0(a.sliceSerialize(f)))?(s.enter("gfmFootnoteCallLabelMarker"),s.consume(C),s.exit("gfmFootnoteCallLabelMarker"),s.exit("gfmFootnoteCall"),e):t(C)}return cFt(C)||(A=!0),n++,s.consume(C),C===92?g:E}function g(C){return C===91||C===92||C===93?(s.consume(C),n++,E):E(C)}}function Qqr(s,e,t){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let n,A=0,h;return u;function u(R){return s.enter("gfmFootnoteDefinition")._container=!0,s.enter("gfmFootnoteDefinitionLabel"),s.enter("gfmFootnoteDefinitionLabelMarker"),s.consume(R),s.exit("gfmFootnoteDefinitionLabelMarker"),E}function E(R){return R===94?(s.enter("gfmFootnoteDefinitionMarker"),s.consume(R),s.exit("gfmFootnoteDefinitionMarker"),s.enter("gfmFootnoteDefinitionLabelString"),s.enter("chunkString").contentType="string",g):t(R)}function g(R){if(A>999||R===93&&!h||R===null||R===91||cFt(R))return t(R);if(R===93){s.exit("chunkString");const x=s.exit("gfmFootnoteDefinitionLabelString");return n=Ap0(a.sliceSerialize(x)),s.enter("gfmFootnoteDefinitionLabelMarker"),s.consume(R),s.exit("gfmFootnoteDefinitionLabelMarker"),s.exit("gfmFootnoteDefinitionLabel"),f}return cFt(R)||(h=!0),A++,s.consume(R),R===92?C:g}function C(R){return R===91||R===92||R===93?(s.consume(R),A++,g):g(R)}function f(R){return R===58?(s.enter("definitionMarker"),s.consume(R),s.exit("definitionMarker"),i.includes(n)||i.push(n),cp0(s,_,"gfmFootnoteDefinitionWhitespace")):t(R)}function _(R){return e(R)}}function vqr(s,e,t){return s.check(Rqr,e,s.attempt(yqr,e,t))}function wqr(s){s.exit("gfmFootnoteDefinition")}function Nqr(s,e,t){const a=this;return cp0(s,i,"gfmFootnoteDefinitionIndent",5);function i(n){const A=a.events[a.events.length-1];return A&&A[1].type==="gfmFootnoteDefinitionIndent"&&A[2].sliceSerialize(A[1],!0).length===4?e(n):t(n)}}function ZIs(s,e,t,a){const i=s.length;let n=0,A;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,a.length<1e4)A=Array.from(a),A.unshift(e,t),s.splice(...A);else for(t&&s.splice(e,t);n<a.length;)A=a.slice(n,n+1e4),A.unshift(e,0),s.splice(...A),n+=1e4,e+=1e4}function Dqr(s){return s!==null&&(s<0||s===32)}const kqr=Mua(new RegExp("\\p{P}|\\p{S}","u")),bqr=Mua(/\s/);function Mua(s){return e;function e(t){return t!==null&&t>-1&&s.test(String.fromCharCode(t))}}function dC1(s){if(s===null||Dqr(s)||bqr(s))return 1;if(kqr(s))return 2}function Mqr(s,e,t){const a=[];let i=-1;for(;++i<s.length;){const n=s[i].resolveAll;n&&!a.includes(n)&&(e=n(e,t),a.push(n))}return e}function Uqr(s){let t=(s||{}).singleTilde;const a={name:"strikethrough",tokenize:n,resolveAll:i};return t==null&&(t=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function i(A,h){let u=-1;for(;++u<A.length;)if(A[u][0]==="enter"&&A[u][1].type==="strikethroughSequenceTemporary"&&A[u][1]._close){let E=u;for(;E--;)if(A[E][0]==="exit"&&A[E][1].type==="strikethroughSequenceTemporary"&&A[E][1]._open&&A[u][1].end.offset-A[u][1].start.offset===A[E][1].end.offset-A[E][1].start.offset){A[u][1].type="strikethroughSequence",A[E][1].type="strikethroughSequence";const g={type:"strikethrough",start:Object.assign({},A[E][1].start),end:Object.assign({},A[u][1].end)},C={type:"strikethroughText",start:Object.assign({},A[E][1].end),end:Object.assign({},A[u][1].start)},f=[["enter",g,h],["enter",A[E][1],h],["exit",A[E][1],h],["enter",C,h]],_=h.parser.constructs.insideSpan.null;_&&ZIs(f,f.length,0,Mqr(_,A.slice(E+1,u),h)),ZIs(f,f.length,0,[["exit",C,h],["enter",A[u][1],h],["exit",A[u][1],h],["exit",g,h]]),ZIs(A,E-1,u-E+3,f),u=E+f.length-2;break}}for(u=-1;++u<A.length;)A[u][1].type==="strikethroughSequenceTemporary"&&(A[u][1].type="data");return A}function n(A,h,u){const E=this.previous,g=this.events;let C=0;return f;function f(R){return E===126&&g[g.length-1][1].type!=="characterEscape"?u(R):(A.enter("strikethroughSequenceTemporary"),_(R))}function _(R){const x=dC1(E);if(R===126)return C>1?u(R):(A.consume(R),C++,_);if(C<2&&!t)return u(R);const w=A.exit("strikethroughSequenceTemporary"),D=dC1(R);return w._open=!D||D===2&&!!x,w._close=!x||x===2&&!!D,h(R)}}}function v2t(s){return s!==null&&s<-2}function EC1(s){return s!==null&&(s<0||s===32)}function ele(s){return s===-2||s===-1||s===32}function Pke(s,e,t,a){const i=a?a-1:Number.POSITIVE_INFINITY;let n=0;return A;function A(u){return ele(u)?(s.enter(t),h(u)):e(u)}function h(u){return ele(u)&&n++<i?(s.consume(u),h):(s.exit(t),e(u))}}class Fqr{constructor(){this.map=[]}add(e,t,a){Pqr(this,e,t,a)}consume(e){if(this.map.sort(function(n,A){return n[0]-A[0]}),this.map.length===0)return;let t=this.map.length;const a=[];for(;t>0;)t-=1,a.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];a.push(e.slice()),e.length=0;let i=a.pop();for(;i;){for(const n of i)e.push(n);i=a.pop()}this.map.length=0}}function Pqr(s,e,t,a){let i=0;if(!(t===0&&a.length===0)){for(;i<s.map.length;){if(s.map[i][0]===e){s.map[i][1]+=t,s.map[i][2].push(...a);return}i+=1}s.map.push([e,t,a])}}function Hqr(s,e){let t=!1;const a=[];for(;e<s.length;){const i=s[e];if(t){if(i[0]==="enter")i[1].type==="tableContent"&&a.push(s[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(s[e-1][1].type==="tableDelimiterMarker"){const n=a.length-1;a[n]=a[n]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(t=!0);e+=1}return a}function Gqr(){return{flow:{null:{name:"table",tokenize:Yqr,resolveAll:Kqr}}}}function Yqr(s,e,t){const a=this;let i=0,n=0,A;return h;function h(Z){let j=a.events.length-1;for(;j>-1;){const se=a.events[j][1].type;if(se==="lineEnding"||se==="linePrefix")j--;else break}const z=j>-1?a.events[j][1].type:null,q=z==="tableHead"||z==="tableRow"?V:u;return q===V&&a.parser.lazy[a.now().line]?t(Z):q(Z)}function u(Z){return s.enter("tableHead"),s.enter("tableRow"),E(Z)}function E(Z){return Z===124||(A=!0,n+=1),g(Z)}function g(Z){return Z===null?t(Z):v2t(Z)?n>1?(n=0,a.interrupt=!0,s.exit("tableRow"),s.enter("lineEnding"),s.consume(Z),s.exit("lineEnding"),_):t(Z):ele(Z)?Pke(s,g,"whitespace")(Z):(n+=1,A&&(A=!1,i+=1),Z===124?(s.enter("tableCellDivider"),s.consume(Z),s.exit("tableCellDivider"),A=!0,g):(s.enter("data"),C(Z)))}function C(Z){return Z===null||Z===124||EC1(Z)?(s.exit("data"),g(Z)):(s.consume(Z),Z===92?f:C)}function f(Z){return Z===92||Z===124?(s.consume(Z),C):C(Z)}function _(Z){return a.interrupt=!1,a.parser.lazy[a.now().line]?t(Z):(s.enter("tableDelimiterRow"),A=!1,ele(Z)?Pke(s,R,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(Z):R(Z))}function R(Z){return Z===45||Z===58?w(Z):Z===124?(A=!0,s.enter("tableCellDivider"),s.consume(Z),s.exit("tableCellDivider"),x):K(Z)}function x(Z){return ele(Z)?Pke(s,w,"whitespace")(Z):w(Z)}function w(Z){return Z===58?(n+=1,A=!0,s.enter("tableDelimiterMarker"),s.consume(Z),s.exit("tableDelimiterMarker"),D):Z===45?(n+=1,D(Z)):Z===null||v2t(Z)?H(Z):K(Z)}function D(Z){return Z===45?(s.enter("tableDelimiterFiller"),M(Z)):K(Z)}function M(Z){return Z===45?(s.consume(Z),M):Z===58?(A=!0,s.exit("tableDelimiterFiller"),s.enter("tableDelimiterMarker"),s.consume(Z),s.exit("tableDelimiterMarker"),U):(s.exit("tableDelimiterFiller"),U(Z))}function U(Z){return ele(Z)?Pke(s,H,"whitespace")(Z):H(Z)}function H(Z){return Z===124?R(Z):Z===null||v2t(Z)?!A||i!==n?K(Z):(s.exit("tableDelimiterRow"),s.exit("tableHead"),e(Z)):K(Z)}function K(Z){return t(Z)}function V(Z){return s.enter("tableRow"),W(Z)}function W(Z){return Z===124?(s.enter("tableCellDivider"),s.consume(Z),s.exit("tableCellDivider"),W):Z===null||v2t(Z)?(s.exit("tableRow"),e(Z)):ele(Z)?Pke(s,W,"whitespace")(Z):(s.enter("data"),X(Z))}function X(Z){return Z===null||Z===124||EC1(Z)?(s.exit("data"),W(Z)):(s.consume(Z),Z===92?J:X)}function J(Z){return Z===92||Z===124?(s.consume(Z),X):X(Z)}}function Kqr(s,e){let t=-1,a=!0,i=0,n=[0,0,0,0],A=[0,0,0,0],h=!1,u=0,E,g,C;const f=new Fqr;for(;++t<s.length;){const _=s[t],R=_[1];_[0]==="enter"?R.type==="tableHead"?(h=!1,u!==0&&(gC1(f,e,u,E,g),g=void 0,u=0),E={type:"table",start:Object.assign({},R.start),end:Object.assign({},R.end)},f.add(t,0,[["enter",E,e]])):R.type==="tableRow"||R.type==="tableDelimiterRow"?(a=!0,C=void 0,n=[0,0,0,0],A=[0,t+1,0,0],h&&(h=!1,g={type:"tableBody",start:Object.assign({},R.start),end:Object.assign({},R.end)},f.add(t,0,[["enter",g,e]])),i=R.type==="tableDelimiterRow"?2:g?3:1):i&&(R.type==="data"||R.type==="tableDelimiterMarker"||R.type==="tableDelimiterFiller")?(a=!1,A[2]===0&&(n[1]!==0&&(A[0]=A[1],C=w2t(f,e,n,i,void 0,C),n=[0,0,0,0]),A[2]=t)):R.type==="tableCellDivider"&&(a?a=!1:(n[1]!==0&&(A[0]=A[1],C=w2t(f,e,n,i,void 0,C)),n=A,A=[n[1],t,0,0])):R.type==="tableHead"?(h=!0,u=t):R.type==="tableRow"||R.type==="tableDelimiterRow"?(u=t,n[1]!==0?(A[0]=A[1],C=w2t(f,e,n,i,t,C)):A[1]!==0&&(C=w2t(f,e,A,i,t,C)),i=0):i&&(R.type==="data"||R.type==="tableDelimiterMarker"||R.type==="tableDelimiterFiller")&&(A[3]=t)}for(u!==0&&gC1(f,e,u,E,g),f.consume(e.events),t=-1;++t<e.events.length;){const _=e.events[t];_[0]==="enter"&&_[1].type==="table"&&(_[1]._align=Hqr(e.events,t))}return s}function w2t(s,e,t,a,i,n){const A=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",h="tableContent";t[0]!==0&&(n.end=Object.assign({},pIe(e.events,t[0])),s.add(t[0],0,[["exit",n,e]]));const u=pIe(e.events,t[1]);if(n={type:A,start:Object.assign({},u),end:Object.assign({},u)},s.add(t[1],0,[["enter",n,e]]),t[2]!==0){const E=pIe(e.events,t[2]),g=pIe(e.events,t[3]),C={type:h,start:Object.assign({},E),end:Object.assign({},g)};if(s.add(t[2],0,[["enter",C,e]]),a!==2){const f=e.events[t[2]],_=e.events[t[3]];if(f[1].end=Object.assign({},_[1].end),f[1].type="chunkText",f[1].contentType="text",t[3]>t[2]+1){const R=t[2]+1,x=t[3]-t[2]-1;s.add(R,x,[])}}s.add(t[3]+1,0,[["exit",C,e]])}return i!==void 0&&(n.end=Object.assign({},pIe(e.events,i)),s.add(i,0,[["exit",n,e]]),n=void 0),n}function gC1(s,e,t,a,i){const n=[],A=pIe(e.events,t);i&&(i.end=Object.assign({},A),n.push(["exit",i,e])),a.end=Object.assign({},A),n.push(["exit",a,e]),s.add(t+1,0,n)}function pIe(s,e){const t=s[e],a=t[0]==="enter"?"start":"end";return t[1][a]}function Vqr(s){return s!==null&&s<-2}function jqr(s){return s!==null&&(s<0||s===32)}function rws(s){return s===-2||s===-1||s===32}function Wqr(s,e,t,a){const i=Number.POSITIVE_INFINITY;let n=0;return A;function A(u){return rws(u)?(s.enter(t),h(u)):e(u)}function h(u){return rws(u)&&n++<i?(s.consume(u),h):(s.exit(t),e(u))}}const $qr={name:"tasklistCheck",tokenize:Xqr};function Jqr(){return{text:{91:$qr}}}function Xqr(s,e,t){const a=this;return i;function i(u){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?t(u):(s.enter("taskListCheck"),s.enter("taskListCheckMarker"),s.consume(u),s.exit("taskListCheckMarker"),n)}function n(u){return jqr(u)?(s.enter("taskListCheckValueUnchecked"),s.consume(u),s.exit("taskListCheckValueUnchecked"),A):u===88||u===120?(s.enter("taskListCheckValueChecked"),s.consume(u),s.exit("taskListCheckValueChecked"),A):t(u)}function A(u){return u===93?(s.enter("taskListCheckMarker"),s.consume(u),s.exit("taskListCheckMarker"),s.exit("taskListCheck"),h):t(u)}function h(u){return Vqr(u)?e(u):rws(u)?s.check({tokenize:qqr},e,t)(u):t(u)}}function qqr(s,e,t){return Wqr(s,a,"whitespace");function a(i){return i===null?t(i):e(i)}}function zqr(s){return cqr([dqr(),xqr(),Uqr(s),Gqr(),Jqr()])}const Zqr={};function Uua(s){const e=this,t=s||Zqr,a=e.data(),i=a.micromarkExtensions||(a.micromarkExtensions=[]),n=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),A=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);i.push(zqr(t)),n.push(iqr()),A.push(rqr(t))}const CC1="hadziqmtqn/erd-builder-pro",ezr=5;function tzr(s){if(!s)return 1;const e=s.match(/page=(\d+)>;\s*rel="last"/);return e?parseInt(e[1],10):1}function szr(){const[s,e]=ae.useState([]),[t,a]=ae.useState(!0),[i,n]=ae.useState(!1),[A,h]=ae.useState(null),[u,E]=ae.useState(null),[g,C]=ae.useState(1),[f,_]=ae.useState(1),R=ae.useRef(null),x=async M=>{M===1?a(!0):n(!0);try{const U=await fetch(`https://api.github.com/repos/${CC1}/releases?per_page=${ezr}&page=${M}`);if(!U.ok)throw new Error("Failed to fetch releases");const H=await U.json();e(H),_(tzr(U.headers.get("Link")))}catch(U){h(U instanceof Error?U.message:"Unknown error")}finally{a(!1),n(!1)}};ae.useEffect(()=>{x(1)},[]),ae.useEffect(()=>{var M;x(g),(M=R.current)==null||M.scrollTo({top:0,behavior:"smooth"})},[g]);const D=g===1?s.findIndex(M=>!M.prerelease):-1;return t&&s.length===0?O.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center space-y-4",children:[O.jsx(Su,{className:"w-8 h-8 text-primary animate-spin"}),O.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:"Fetching latest updates..."})]}):A?O.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center space-y-4 p-8 text-center",children:[O.jsx("div",{className:"w-12 h-12 rounded-full bg-destructive/10 flex items-center justify-center",children:O.jsx($w,{className:"w-6 h-6 text-destructive"})}),O.jsxs("div",{className:"space-y-2",children:[O.jsx("h3",{className:"font-bold text-lg",children:"Gagal memuat Changelog"}),O.jsx("p",{className:"text-sm text-muted-foreground max-w-xs",children:A})]}),O.jsx(D1,{onClick:()=>window.location.reload(),variant:"outline",children:"Coba Lagi"})]}):O.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden bg-background",children:[O.jsxs("div",{className:"flex items-center justify-between p-6 border-b bg-muted/20",children:[O.jsxs("div",{className:"space-y-1",children:[O.jsxs("h2",{className:"text-2xl font-bold tracking-tight flex items-center gap-2",children:[O.jsx($le,{className:"w-6 h-6 text-primary"}),"What's New"]}),O.jsx("p",{className:"text-sm text-muted-foreground",children:"Lacak pembaruan dan perubahan terbaru pada ERD Builder Pro."})]}),O.jsxs(D1,{variant:"outline",size:"sm",render:O.jsx("a",{href:`https://github.com/${CC1}/releases`,target:"_blank",rel:"noreferrer"}),children:[O.jsx(Eae,{className:"w-4 h-4 mr-2"}),"GitHub Releases"]})]}),O.jsx("div",{ref:R,className:"flex-1 overflow-y-auto px-6 py-8",children:O.jsxs("div",{className:"max-w-3xl mx-auto relative pl-8 space-y-12",children:[O.jsx("div",{className:"absolute left-[15px] top-2 bottom-0 w-px bg-border"}),O.jsx(KG1,{mode:"popLayout",children:s.map((M,U)=>O.jsxs(oH.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:U*.1},className:"relative",children:[O.jsx("div",{className:ei("absolute -left-[32px] top-1.5 size-8 rounded-full border-4 border-background flex items-center justify-center transition-colors",U===D&&D!==-1?"bg-primary shadow-[0_0_15px_rgba(var(--primary),0.5)]":M.prerelease?"bg-amber-500/20 border-amber-500/30":"bg-muted"),children:U===D&&D!==-1?O.jsx(ry,{className:"w-4 h-4 text-primary-foreground"}):M.prerelease?O.jsx(t7e,{className:"w-3 h-3 text-amber-400"}):O.jsx(t7e,{className:"w-3 h-3 text-muted-foreground"})}),O.jsxs("div",{className:"space-y-3",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsxs(Gg,{variant:M.prerelease?"secondary":"default",className:"font-mono text-xs px-2 pointer-events-none",children:["v",M.tag_name.replace("v","")]}),M.prerelease&&O.jsx(Gg,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-amber-500/10 text-amber-400 border-amber-500/30",children:"Pre-release"}),O.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[O.jsx(jle,{className:"w-3 h-3"}),cj(new Date(M.published_at),"MMMM d, yyyy")]}),U===D&&D!==-1&&O.jsx(Gg,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-primary/5 text-primary border-primary/20",children:"Latest"})]}),O.jsx(Xb,{className:ei("group transition-all duration-300 hover:border-primary/50 cursor-pointer overflow-hidden backdrop-blur-sm",U===D&&D!==-1?"bg-primary/5 border-primary/20 shadow-lg shadow-primary/5":M.prerelease?"bg-card/30 border-amber-500/10":"bg-card/50"),onClick:()=>E(M),children:O.jsxs(bVe,{className:"p-4 flex flex-row items-center justify-between space-y-0",children:[O.jsxs("div",{className:"space-y-1",children:[O.jsx(MVe,{className:"text-base font-bold group-hover:text-primary transition-colors",children:M.name||`Release ${M.tag_name}`}),O.jsx(JYt,{className:"line-clamp-2 text-sm leading-relaxed",children:M.body.split(`
8867
8867
  `)[0].replace(/#+\s*/,"")||"Lihat detail pembaruan..."})]}),O.jsx(qg,{className:"w-5 h-5 text-muted-foreground group-hover:text-primary group-hover:translate-x-1 transition-all"})]})})]})]},M.id))}),i&&O.jsx("div",{className:"flex justify-center pt-4",children:O.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[O.jsx(Su,{className:"w-3.5 h-3.5 animate-spin"}),"Loading page..."]})}),f>1&&!i&&O.jsxs("div",{className:"flex items-center justify-center gap-1 pt-8 pb-4",children:[O.jsx(D1,{variant:"ghost",size:"sm",disabled:g===1,onClick:()=>C(1),className:"size-9 p-0",children:O.jsx(TUe,{className:"w-4 h-4"})}),O.jsx(D1,{variant:"ghost",size:"sm",disabled:g===1,onClick:()=>C(M=>M-1),className:"size-9 p-0",children:O.jsx(fy,{className:"w-4 h-4"})}),O.jsx("div",{className:"flex items-center gap-1 px-2",children:(()=>{const M=[];for(let H=1;H<=f;H++)H===1||H===f||H>=g-1&&H<=g+1?M.push(H):M[M.length-1]!=="ellipsis"&&M.push("ellipsis");return M.map((H,K)=>H==="ellipsis"?O.jsx("span",{className:"px-1 text-xs text-muted-foreground",children:"..."},`e-${K}`):O.jsx(D1,{variant:H===g?"default":"ghost",size:"sm",onClick:()=>C(H),className:"min-w-9 h-9 p-0 text-xs font-mono",children:H},H))})()}),O.jsx(D1,{variant:"ghost",size:"sm",disabled:g===f,onClick:()=>C(M=>M+1),className:"size-9 p-0",children:O.jsx(qg,{className:"w-4 h-4"})}),O.jsx(D1,{variant:"ghost",size:"sm",disabled:g===f,onClick:()=>C(f),className:"size-9 p-0",children:O.jsx(yUe,{className:"w-4 h-4"})})]}),f>1&&!i&&O.jsxs("p",{className:"text-center text-[11px] text-muted-foreground/60 pb-2",children:["Page ",g," of ",f]})]})}),O.jsx(u5,{open:!!u,onOpenChange:M=>!M&&E(null),children:O.jsx(b7,{className:"sm:max-w-2xl",children:u&&O.jsxs(O.Fragment,{children:[O.jsxs(q6,{children:[O.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[O.jsxs(Gg,{className:"font-mono text-xs",children:["v",u.tag_name.replace("v","")]}),u.prerelease?O.jsx(Gg,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-amber-500/10 text-amber-400 border-amber-500/30",children:"Pre-release"}):O.jsx(Gg,{variant:"outline",className:"text-[10px] uppercase tracking-tighter bg-emerald-500/10 text-emerald-400 border-emerald-500/30",children:"Stable"}),O.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[O.jsx(jle,{className:"w-3 h-3"}),cj(new Date(u.published_at),"MMMM d, yyyy")]})]}),O.jsx(h5,{className:"text-2xl",children:u.name||`Release ${u.tag_name}`})]}),O.jsx(Hd,{className:"bg-muted/50",children:O.jsx("div",{className:"prose prose-invert prose-sm max-w-none prose-pre:bg-black/50 prose-pre:border prose-pre:border-border",children:O.jsx(cua,{remarkPlugins:[Uua],children:u.body})})}),O.jsx(ff,{children:O.jsxs(D1,{variant:"secondary",size:"sm",render:O.jsx("a",{href:u.html_url,target:"_blank",rel:"noreferrer"}),children:[O.jsx(Eae,{className:"w-4 h-4 mr-2"}),"View on GitHub"]})})]})})})]})}function azr(s){const e=s==null?void 0:s.data;if(!e)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 t=0,a=0,i=0;for(const A of e.diagrams||[]){t+=(A.entities||[]).length;for(const h of A.entities||[])a+=(h.columns||[]).length;i+=(A.relationships||[]).length}let n=0;for(const A of e.ai_chat_sessions||[])n+=(A.messages||[]).length;return{projects:(e.projects||[]).length,notes:(e.notes||[]).length,diagrams:(e.diagrams||[]).length,entities:t,columns:a,relationships:i,flowcharts:(e.flowcharts||[]).length,drawings:(e.drawings||[]).length,ai_chat_sessions:(e.ai_chat_sessions||[]).length,ai_chat_messages:n,skipped_existing:0}}function izr(s){const e=s==null?void 0:s.data;if(!e)return 1;let t=0;t+=(e.projects||[]).length,t+=(e.notes||[]).length;for(const a of e.diagrams||[]){t+=1;const i=a.entities||[];t+=i.length;for(const n of i)t+=(n.columns||[]).length;t+=(a.relationships||[]).length}t+=(e.flowcharts||[]).length,t+=(e.drawings||[]).length;for(const a of e.ai_chat_sessions||[])t+=1,t+=(a.messages||[]).length;return Math.max(t,1)}function rzr(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function pC1(){return sessionStorage.getItem("auth_mode")==="guest"?"guest":typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__)?"desktop":"web"}function nzr(){const s=ae.useRef(null),e=ae.useRef(null),t=ae.useRef(null),a=ae.useRef(null),i=ae.useRef(null),[n,A]=ae.useState("idle"),[h,u]=ae.useState(null),[E,g]=ae.useState(null),[C,f]=ae.useState(null),[_,R]=ae.useState(null),[x,w]=ae.useState(""),[D,M]=ae.useState({current:0,total:1,phase:""}),U=pC1();ae.useEffect(()=>(n==="done"&&(e.current=setTimeout(()=>{window.location.reload()},2500)),()=>{e.current&&(clearTimeout(e.current),e.current=null)}),[n]);const H=ae.useCallback(async ie=>{var Ee,le;const he=(Ee=ie.target.files)==null?void 0:Ee[0];if(!he)return;const Ae=(le=he.name.split(".").pop())==null?void 0:le.toLowerCase();if(Ae==="db"||Ae==="sqlite"||Ae==="sqlite3"){if(pC1()!=="desktop"){v0.error("Database file restore is only available in the Desktop app."),s.current&&(s.current.value="");return}u("db"),f({fileName:he.name,fileSize:rzr(he.size)}),g(null),w(""),A("preview"),i.current=he,s.current&&(s.current.value="");return}if(Ae==="json"){let ue;try{ue=JSON.parse(await he.text())}catch{v0.error("Invalid JSON file. Please select a valid export file."),s.current&&(s.current.value="");return}if(!ue.data||typeof ue.data!="object"){v0.error('Invalid export format. Missing "data" field.'),s.current&&(s.current.value="");return}const me=azr(ue);if(Object.values(me).reduce((_e,ve)=>_e+(ve||0),0)<=1){v0.info("The export file contains no data to import."),s.current&&(s.current.value="");return}a.current=ue,u("json"),g(me),f(null),w(""),A("preview"),s.current&&(s.current.value="");return}v0.error(`Unsupported file type ".${Ae}". Please select a .json, .db, or .sqlite file.`),s.current&&(s.current.value="")},[]),K=ae.useCallback(async()=>{var Ae;const ie=a.current;if(!ie)return;const he=izr(ie);A("importing"),w(""),M({current:0,total:he,phase:"Preparing import…"});try{const Ee=new AbortController;t.current=Ee;const le=await Ri("/api/guest/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie),signal:Ee.signal});if(!le.ok){let _e=`Server returned ${le.status}`;try{_e=(await le.json()).error||_e}catch{}throw new Error(_e)}const ue=(Ae=le.body)==null?void 0:Ae.getReader();if(!ue)throw new Error("Browser does not support streaming responses.");const me=new TextDecoder;let Be="";for(;;){const{done:_e,value:ve}=await ue.read();if(_e)break;Be+=me.decode(ve,{stream:!0});const Qe=Be.split(`
8868
8868
  `);Be=Qe.pop()||"";for(const Ue of Qe)if(Ue.trim())try{const Fe=JSON.parse(Ue);if(Fe.type==="progress")M({current:Number(Fe.current)||0,total:Number(Fe.total)||he,phase:String(Fe.phase||"")});else if(Fe.type==="complete"){R(Fe.summary),A("done"),v0.success(Fe.message||"Import completed successfully!"),t.current=null;return}else if(Fe.type==="error")throw new Error(Fe.error||"Import failed on server.")}catch(Fe){if(Fe instanceof SyntaxError)continue;throw Fe}}throw new Error("Stream ended unexpectedly. Import may be incomplete.")}catch(Ee){if(Ee.name==="AbortError")return;A("error"),w(Ee.message||"Import failed"),v0.error("Import failed: "+(Ee.message||"Unknown error"))}t.current=null},[U]),V=ae.useCallback(async()=>{var he;const ie=i.current;if(ie){A("importing"),w(""),M({current:0,total:5,phase:"Uploading database file…"});try{const Ae=new AbortController;t.current=Ae;const Ee=new FormData;Ee.append("database",ie);const le=await Ri("/api/desktop/restore/database",{method:"POST",body:Ee,signal:Ae.signal});if(!le.ok){let _e=`Server returned ${le.status}`;try{_e=(await le.json()).error||_e}catch{}throw new Error(_e)}const ue=(he=le.body)==null?void 0:he.getReader();if(!ue)throw new Error("Browser does not support streaming responses.");const me=new TextDecoder;let Be="";for(;;){const{done:_e,value:ve}=await ue.read();if(_e)break;Be+=me.decode(ve,{stream:!0});const Qe=Be.split(`
8869
- `);Be=Qe.pop()||"";for(const Ue of Qe)if(Ue.trim())try{const Fe=JSON.parse(Ue);if(Fe.type==="progress")M({current:Number(Fe.current)||0,total:Number(Fe.total)||5,phase:String(Fe.phase||"")});else if(Fe.type==="complete"){A("done"),v0.success(Fe.message||"Database restored successfully!"),t.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(Ae){if(Ae.name==="AbortError")return;A("error"),w(Ae.message||"Restore failed"),v0.error("Restore failed: "+(Ae.message||"Unknown error"))}t.current=null}},[]),W=ae.useCallback(()=>{e.current&&(clearTimeout(e.current),e.current=null),a.current=null,i.current=null,A("idle"),u(null),R(null),g(null),f(null),w(""),M({current:0,total:1,phase:""})},[]),X=ae.useCallback(()=>{a.current=null,i.current=null,g(null),f(null),A("idle"),u(null)},[]),J=ae.useCallback(()=>{e.current&&(clearTimeout(e.current),e.current=null),window.location.reload()},[]),Z=ae.useCallback(()=>{t.current&&(t.current.abort(),t.current=null),a.current=null,i.current=null,A("idle"),u(null),M({current:0,total:1,phase:""})},[]),j=ae.useCallback(()=>{h==="db"?V():K()},[h,V,K]),z=Math.min(Math.round(D.current/D.total*100),100),{accept:q,acceptLabel:se}=U==="desktop"?{accept:".json,.db,.sqlite,.sqlite3",acceptLabel:".json (data) or .db / .sqlite (database restore)"}:{accept:".json",acceptLabel:".json format from Guest Mode export"};if(n==="done")return O.jsxs("div",{className:"space-y-6",children:[O.jsxs("div",{className:"flex items-center gap-3 p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl",children:[O.jsx(aq,{className:"size-6 text-emerald-500 shrink-0"}),O.jsxs("div",{children:[O.jsx("h4",{className:"font-semibold text-sm",children:h==="db"?"Database Restored":"Import Completed"}),O.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:h==="db"?"The database file has been restored. The app will reload to apply the changes.":"Data has been added to your workspace."})]})]}),_&&O.jsx(IC1,{summary:_}),O.jsxs("div",{className:"flex gap-3",children:[O.jsxs(D1,{variant:"default",size:"sm",onClick:J,children:[O.jsx(aB,{className:"size-3.5 mr-1.5"}),"Reload App Now"]}),O.jsx(D1,{variant:"outline",size:"sm",onClick:W,children:"Import Another File"})]}),O.jsx("p",{className:"text-xs text-muted-foreground",children:"App will reload automatically in a few seconds…"})]});if(n==="preview"){if(h==="db"&&C)return O.jsxs("div",{className:"space-y-5",children:[O.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[O.jsx(vUe,{className:"size-5 text-blue-500 shrink-0"}),O.jsxs("div",{children:[O.jsx("h4",{className:"font-semibold text-sm",children:"Restore Database File"}),O.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["This will ",O.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."]}),O.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",O.jsx("code",{className:"bg-muted px-1 rounded text-[11px] mx-0.5",children:".db"})," file that you saved manually."]})]})]}),O.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-4 space-y-2",children:[O.jsxs("div",{className:"flex items-center justify-between text-sm",children:[O.jsx("span",{className:"text-muted-foreground",children:"File"}),O.jsx("span",{className:"font-medium",children:C.fileName})]}),O.jsxs("div",{className:"flex items-center justify-between text-sm",children:[O.jsx("span",{className:"text-muted-foreground",children:"Size"}),O.jsx("span",{className:"font-medium",children:C.fileSize})]})]}),O.jsxs("div",{className:"flex gap-3 pt-2",children:[O.jsxs(D1,{variant:"default",size:"sm",onClick:j,children:[O.jsx(uae,{className:"size-3.5 mr-1.5"}),"Restore Database"]}),O.jsxs(D1,{variant:"outline",size:"sm",onClick:X,children:[O.jsx(Jb,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]});if(h==="json"&&E){const ie=Object.values(E).reduce((he,Ae)=>he+(Ae||0),0);return O.jsxs("div",{className:"space-y-5",children:[O.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[O.jsx(bfe,{className:"size-5 text-blue-500 shrink-0"}),O.jsxs("div",{children:[O.jsx("h4",{className:"font-semibold text-sm",children:"Import Preview"}),O.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ie," items found in the export file. Click ",O.jsx("strong",{children:"Submit"})," to import the data."]})]})]}),O.jsx(IC1,{summary:E}),O.jsxs("div",{className:"flex gap-3 pt-2",children:[O.jsxs(D1,{variant:"default",size:"sm",onClick:j,children:[O.jsx(uae,{className:"size-3.5 mr-1.5"}),"Submit"]}),O.jsxs(D1,{variant:"outline",size:"sm",onClick:X,children:[O.jsx(Jb,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]})}}return n==="error"?O.jsx("div",{className:"space-y-5",children:O.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:[O.jsx($w,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),O.jsxs("div",{className:"text-xs text-red-600",children:[O.jsx("p",{className:"font-medium",children:h==="db"?"Database restore failed":"Import failed"}),O.jsx("p",{className:"mt-0.5",children:x}),O.jsx(D1,{variant:"ghost",size:"sm",className:"mt-2 h-auto py-1 text-xs",onClick:W,children:"Try again"})]})]})}):O.jsxs("div",{className:"space-y-5",children:[O.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[O.jsx(xb,{className:"size-5 text-blue-500 shrink-0 mt-0.5"}),O.jsxs("div",{className:"text-sm space-y-1",children:[O.jsx("p",{className:"font-medium",children:"Import Data"}),O.jsxs("p",{className:"text-xs text-muted-foreground",children:["Upload a ",O.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," file exported from Guest Mode. All data will be ",O.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."]}),O.jsx("p",{className:"text-xs text-muted-foreground",children:"Supports: Notes, ERD Diagrams (entities, columns, relationships), Flowcharts, Drawings, AI Chat sessions & messages, and Projects."}),U==="desktop"&&O.jsxs("p",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-border/40",children:[O.jsx("strong",{className:"text-amber-500",children:"Desktop only:"})," You can also restore a",O.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."]})]})]}),O.jsxs("div",{onClick:()=>{var ie;n!=="importing"&&((ie=s.current)==null||ie.click())},onKeyDown:ie=>{var he;(ie.key==="Enter"||ie.key===" ")&&n!=="importing"&&((he=s.current)==null||he.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:[O.jsx("input",{ref:s,type:"file",accept:q,className:"hidden",onChange:H}),n==="importing"?O.jsxs("div",{className:"w-full max-w-sm mx-auto space-y-4",children:[O.jsxs("div",{className:"space-y-1.5",children:[O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground truncate mr-2",children:D.phase||"Importing…"}),O.jsxs("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:[z,"%"]})]}),O.jsx("div",{className:"w-full h-2 bg-muted/50 rounded-full overflow-hidden",children:O.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300 ease-out",style:{width:`${z}%`}})}),O.jsxs("p",{className:"text-[11px] text-muted-foreground tabular-nums",children:[D.current.toLocaleString()," / ",D.total.toLocaleString()," items"]})]}),O.jsx(D1,{variant:"ghost",size:"sm",onClick:ie=>{ie.stopPropagation(),Z()},className:"text-xs",children:"Cancel"})]}):O.jsxs("div",{className:"flex flex-col items-center gap-3",children:[O.jsx("div",{className:"p-3 bg-muted/30 rounded-full",children:O.jsx(Rj,{className:"size-6 text-muted-foreground"})}),O.jsxs("div",{children:[O.jsx("p",{className:"text-sm font-medium",children:"Click to select a file"}),O.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:se})]})]})]})]})}function IC1({summary:s}){return O.jsxs("div",{className:"space-y-3",children:[O.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[O.jsx(vX,{label:"Projects",value:s.projects}),O.jsx(vX,{label:"Notes",value:s.notes}),O.jsx(vX,{label:"ERD Diagrams",value:s.diagrams}),O.jsx(vX,{label:"Tables (Entities)",value:s.entities}),O.jsx(vX,{label:"Columns",value:s.columns}),O.jsx(vX,{label:"Relationships",value:s.relationships}),O.jsx(vX,{label:"Flowcharts",value:s.flowcharts}),O.jsx(vX,{label:"Drawings",value:s.drawings}),O.jsx(vX,{label:"AI Sessions",value:s.ai_chat_sessions})]}),s.ai_chat_messages>0&&O.jsxs("p",{className:"text-[11px] text-muted-foreground px-0.5",children:["Includes ",s.ai_chat_messages.toLocaleString()," AI chat messages."]}),s.skipped_existing>0&&O.jsxs("p",{className:"text-[11px] text-amber-500 px-0.5",children:[s.skipped_existing.toLocaleString()," item(s) already existed and were skipped."]})]})}function vX({label:s,value:e}){return O.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-3 text-center",children:[O.jsx("p",{className:"text-lg font-bold",children:e.toLocaleString()}),O.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:s})]})}function czr(){return sessionStorage.getItem("auth_mode")==="guest"}function Azr(s){if(!s||typeof s!="string")return null;try{const e=JSON.parse(s);return(e==null?void 0:e.dbml_source)??(e==null?void 0:e.dbmlSource)??null}catch{return null}}function ozr(s){const e=s.dbml_source??s.dbmlSource??Azr(s.data);return{...s,dbml_source:e??null,dbmlSource:e??null}}async function Tpe(s){try{return(await pi.getAllResources(s)||[]).filter(t=>!t.is_deleted)}catch{return[]}}function uzr(s){return!s.messages||!Array.isArray(s.messages)?[]:s.messages.map(e=>({id:e.id||e.uid,role:e.role,content:e.content,selection_text:e.selection_text||null,created_at:e.created_at||null}))}async function hzr(){if(!czr()){const u=await Ri("/api/guest/export");if(!u.ok){const E=await u.json().catch(()=>({}));throw new Error(E.error||"Failed to export data")}return u.json()}const[s,e,t,a,i,n]=await Promise.all([Tpe("project"),Tpe("notes"),Tpe("erd"),Tpe("flowchart"),Tpe("drawings"),Tpe("ai_chat_session")]),A=n.map(u=>({uid:u.uid||u.id,title:u.title||"Untitled",entity_type:u.entity_type||null,entity_uid:u.entity_uid||null,project_id:u.project_id??null,created_at:u.created_at||null,updated_at:u.updated_at||null,messages:uzr(u)})),h={projects:s.length,notes:e.length,diagrams:t.length,flowcharts:a.length,drawings:i.length,ai_chat_sessions:A.length};return{version:"1.0",exported_at:new Date().toISOString(),application:"ERD Builder Pro",total_items:h,data:{projects:s,notes:e,diagrams:t.map(ozr),flowcharts:a,drawings:i,ai_chat_sessions:A}}}function lzr(s){const e=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download=`erd-data-export-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(t)}async function Fua(){const s=await hzr();lzr(s)}function dzr(){const[s,e]=ae.useState(!1),t=async()=>{e(!0);try{await Fua(),v0.success("Data exported successfully")}catch(a){v0.error("Export failed: "+(a.message||"Unknown error"))}finally{e(!1)}};return O.jsxs("div",{className:"space-y-4",children:[O.jsxs("div",{children:[O.jsx("h2",{className:"text-lg font-semibold",children:"Export Data"}),O.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Download projects, notes, ERDs, DBML, flowcharts, drawings, and AI chats as JSON."})]}),O.jsx("div",{className:"rounded-xl border border-border/40 bg-muted/10 p-5 max-w-xl",children:O.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[O.jsxs("div",{children:[O.jsx("h3",{className:"text-sm font-semibold",children:"JSON Backup"}),O.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Use this file with Import Data to restore or migrate your workspace data."})]}),O.jsxs(D1,{onClick:t,disabled:s,className:"shrink-0",children:[s?O.jsx(Su,{className:"size-3.5 mr-2 animate-spin"}):O.jsx(AB,{className:"size-3.5 mr-2"}),s?"Exporting...":"Export JSON"]})]})})]})}function Ezr(){if(!(typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli")))return O.jsx("div",{className:"p-4 md:p-8",children:O.jsx(Xb,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:O.jsxs(zq,{className:"py-12 text-center",children:[O.jsx(xb,{className:"w-8 h-8 mx-auto text-muted-foreground/40"}),O.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Storage configuration is only available in the desktop app or CLI mode."})]})})});const[e,t]=ae.useState({type:"r2",accountId:"",endpoint:"",region:"auto",accessKeyId:"",secretAccessKey:"",bucketName:"",publicUrl:""}),[a,i]=ae.useState(null),[n,A]=ae.useState("none"),[h,u]=ae.useState(!0),[E,g]=ae.useState(!1),[C,f]=ae.useState(!1),[_,R]=ae.useState({type:"",message:""}),[x,w]=ae.useState(!1),[D,M]=ae.useState(!1),U=ae.useCallback(async()=>{u(!0);try{const X=await Ri("/api/storage/config",{credentials:"include"});if(X.ok){const J=await X.json();A(J.source),J.config&&(i(J.config),t({type:J.config.type||"r2",accountId:J.config.accountId||"",endpoint:J.config.endpoint||"",region:J.config.region||"auto",accessKeyId:J.config.accessKeyId||"",secretAccessKey:J.config.secretAccessKey||"",bucketName:J.config.bucketName||"",publicUrl:J.config.publicUrl||""}))}}catch(X){console.error("Failed to load storage config:",X)}finally{u(!1)}},[]);ae.useEffect(()=>{U()},[U]);const H=async()=>{g(!0),R({type:"",message:""});try{const X=await Ri("/api/storage/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"});if(X.ok)R({type:"success",message:"Storage configuration saved successfully."}),i({...e}),await U();else{const J=await X.json();R({type:"error",message:J.error||"Failed to save configuration"})}}catch(X){R({type:"error",message:X.message||"Network error"})}finally{g(!1)}},K=async()=>{f(!0),R({type:"",message:""});try{const X=await Ri("/api/storage/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"});if(X.ok)R({type:"success",message:"Successfully connected to storage."});else{const J=await X.json();R({type:"error",message:J.error||"Connection failed"})}}catch(X){R({type:"error",message:X.message||"Network error"})}finally{f(!1)}},V=(X,J)=>{t(Z=>({...Z,[X]:J})),R({type:"",message:""})};if(h)return O.jsx("div",{className:"p-4 md:p-8",children:O.jsx(Xb,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:O.jsxs(zq,{className:"py-12 text-center",children:[O.jsx(aB,{className:"w-6 h-6 animate-spin mx-auto text-muted-foreground"}),O.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Loading storage configuration..."})]})})});const W=n==="env";return O.jsx("div",{className:"p-6 space-y-6",children:O.jsxs(Xb,{className:"border border-border/50 bg-background/50 backdrop-blur-sm shadow-lg",children:[O.jsxs(bVe,{className:"border-b border-border/30 pb-6",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsx(lae,{className:"w-6 h-6 text-blue-500"}),O.jsx(MVe,{className:"text-xl md:text-2xl font-bold",children:"Storage Configuration"})]}),O.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."})]}),O.jsxs(zq,{className:"space-y-6 p-4 md:p-6",children:[W&&O.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[O.jsx(jb,{className:"w-4 h-4 text-blue-500 shrink-0"}),O.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:"Pre-filled from environment variables. Save to override with custom settings."})]}),_.type&&O.jsxs("div",{className:`flex items-center gap-3 p-4 rounded-lg border ${_.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:[_.type==="success"?O.jsx(cb,{className:"w-5 h-5 shrink-0"}):O.jsx(KV,{className:"w-5 h-5 shrink-0"}),O.jsx("p",{className:"text-sm",children:_.message})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(xb,{className:"size-3"}),"Storage Provider"]}),O.jsxs(Bf,{value:e.type,onValueChange:(X,J)=>X&&V("type",X),children:[O.jsx(uI,{className:"h-9 text-sm",children:O.jsx(Rf,{children:e.type==="r2"?O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(lae,{className:"w-4 h-4"}),"Cloudflare R2"]}):O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(xb,{className:"w-4 h-4"}),"S3-Compatible"]})})}),O.jsxs(Tf,{children:[O.jsx(g3,{value:"r2",children:O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(lae,{className:"w-4 h-4"}),"Cloudflare R2"]})}),O.jsx(g3,{value:"s3-compatible",children:O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(xb,{className:"w-4 h-4"}),"S3-Compatible"]})})]})]})]}),e.type==="r2"&&O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Vb,{className:"size-3"}),"Account ID"]}),O.jsx(DA,{placeholder:"Your Cloudflare R2 Account ID",value:e.accountId||"",onChange:X=>V("accountId",X.target.value),className:"h-9 text-sm font-mono"}),O.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:"Found in your Cloudflare dashboard under R2 → Account ID."})]}),e.type==="s3-compatible"&&O.jsxs(O.Fragment,{children:[O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Vb,{className:"size-3"}),"Endpoint URL"]}),O.jsx(DA,{placeholder:"https://s3.us-east-1.amazonaws.com",value:e.endpoint||"",onChange:X=>V("endpoint",X.target.value),className:"h-9 text-sm font-mono"})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Vb,{className:"size-3"}),"Region"]}),O.jsx(DA,{placeholder:"us-east-1",value:e.region||"",onChange:X=>V("region",X.target.value),className:"h-9 text-sm font-mono"})]})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Hfe,{className:"size-3"}),"Access Key ID"]}),O.jsxs("div",{className:"relative",children:[O.jsx(DA,{type:D?"text":"password",placeholder:"Your access key ID",value:e.accessKeyId,onChange:X=>V("accessKeyId",X.target.value),className:"h-9 text-sm font-mono pr-10"}),O.jsx("button",{type:"button",onClick:()=>M(!D),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:D?O.jsx(mj,{className:"w-4 h-4"}):O.jsx(Xq,{className:"w-4 h-4"})})]})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Hfe,{className:"size-3"}),"Secret Access Key"]}),O.jsxs("div",{className:"relative",children:[O.jsx(DA,{type:x?"text":"password",placeholder:"Your secret access key",value:e.secretAccessKey,onChange:X=>V("secretAccessKey",X.target.value),className:"h-9 text-sm font-mono pr-10"}),O.jsx("button",{type:"button",onClick:()=>w(!x),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:x?O.jsx(mj,{className:"w-4 h-4"}):O.jsx(Xq,{className:"w-4 h-4"})})]})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Ufe,{className:"size-3"}),"Bucket Name"]}),O.jsx(DA,{placeholder:"your-bucket-name",value:e.bucketName,onChange:X=>V("bucketName",X.target.value),className:"h-9 text-sm font-mono"})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Yfe,{className:"size-3"}),"Public URL (optional)"]}),O.jsx(DA,{placeholder:"https://cdn.yourdomain.com",value:e.publicUrl||"",onChange:X=>V("publicUrl",X.target.value),className:"h-9 text-sm font-mono"}),O.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:e.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."})]})]}),O.jsxs(Ame,{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:[O.jsx("button",{type:"button",onClick:K,disabled:C||!e.bucketName||!e.accessKeyId||!e.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:C?O.jsxs(O.Fragment,{children:[O.jsx(aB,{className:"w-4 h-4 shrink-0 animate-spin pointer-events-none"}),O.jsx("span",{className:"pointer-events-none",children:"Testing..."})]}):O.jsxs(O.Fragment,{children:[O.jsx(aB,{className:"w-4 h-4 shrink-0 pointer-events-none"}),O.jsx("span",{className:"pointer-events-none",children:"Test Connection"})]})}),O.jsxs(D1,{onClick:H,className:"gap-2 px-6",disabled:E,children:[E?O.jsx(aB,{className:"w-4 h-4 animate-spin"}):O.jsx(qq,{className:"w-4 h-4"}),E?"Saving...":"Save Configuration"]})]})]})})}function gzr(){const{isSettingsOpen:s,setIsSettingsOpen:e,settingsTab:t,setSettingsTab:a}=AC(),i=typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli"),[n,A]=$s.useState("configuration"),{providers:h,configs:u,isTesting:E,isSaving:g,handleSaveConfig:C,handleTestConnection:f,updateProviderLocal:_,updateConfigLocal:R}=TGr(),{isGuest:x}=DM(),{models:w,newModel:D,editingModelId:M,isSaving:U,setNewModel:H,handleAddModel:K,handleDeleteModel:V,ensureModel:W,startEditingModel:X,cancelEdit:J,refresh:Z}=yGr(),{prompts:j,isSaving:z,handleSavePrompt:q,handleDeletePrompt:se,togglePromptDefault:ie}=xGr(),he=$s.useMemo(()=>x?[{label:"General",items:[{id:"appearance",label:"Appearance",icon:O.jsx(zle,{className:"size-4"})}]},{label:"More",items:[{id:"export-data",label:"Export Data",icon:O.jsx(AB,{className:"size-4"})},{id:"changelog",label:"What's New",icon:O.jsx($le,{className:"size-4"})}]}]:[{label:"General",items:[{id:"account",label:"Account",icon:O.jsx(Tj,{className:"size-4"})},{id:"appearance",label:"Appearance",icon:O.jsx(zle,{className:"size-4"})},...i?[{id:"storage",label:"Storage",icon:O.jsx(xb,{className:"size-4"})}]:[]]},{label:"Feature",items:[{id:"ai-config",label:"AI Configuration",icon:O.jsx(ry,{className:"size-4"})},{id:"ai-rules",label:"AI Rules",icon:O.jsx(VUe,{className:"size-4"})},{id:"ai-prompts",label:"System Prompts",icon:O.jsx(Nfe,{className:"size-4"})}]},{label:"More",items:[{id:"export-data",label:"Export Data",icon:O.jsx(AB,{className:"size-4"})},{id:"import-data",label:"Import Data",icon:O.jsx(Rj,{className:"size-4"})},{id:"backups",label:"Database Backup",icon:O.jsx(M3,{className:"size-4"})},{id:"changelog",label:"What's New",icon:O.jsx($le,{className:"size-4"})}]}],[x]),Ae=he.flatMap(le=>le.items),Ee=le=>{var ue;return((ue=Ae.find(me=>me.id===le))==null?void 0:ue.label)||""};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{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:[O.jsx(h5,{className:"sr-only",children:"Settings"}),O.jsx(j_,{className:"sr-only",children:"Manage your application settings and AI configuration."}),O.jsxs(DK1,{className:"items-start min-h-0! h-full",children:[O.jsx(kK1,{collapsible:"none",className:"w-55 border-r border-border/40 bg-muted/5 hidden md:flex h-full",children:O.jsxs(MK1,{className:"pt-4 px-2 pb-0",children:[O.jsx("div",{className:"px-4 py-2 mb-2",children:O.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[O.jsx(pae,{className:"size-4"}),"Settings"]})}),he.map(le=>O.jsxs(UOt,{className:"py-1",children:[O.jsx(rLs,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-4 mb-0.5",children:le.label}),O.jsx(nLs,{children:O.jsx(jVe,{children:le.items.map(ue=>O.jsx(lme,{children:O.jsxs($ae,{isActive:t===ue.id,onClick:()=>a(ue.id),className:`transition-all duration-200 px-4 py-2 rounded-md ${t===ue.id?"bg-sidebar-accent text-sidebar-accent-foreground font-medium":"text-muted-foreground hover:bg-sidebar-accent/50"}`,children:[ue.icon,O.jsx("span",{className:"text-xs",children:ue.label})]})},ue.id))})})]},le.label))]})}),O.jsxs("main",{className:"flex-1 flex flex-col h-150 overflow-hidden",children:[O.jsx("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-6 backdrop-blur-sm",children:O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(FK1,{className:"hidden md:flex",children:O.jsxs(PK1,{children:[O.jsx(pP,{children:O.jsx(Ipr,{href:"#",className:"text-[11px] text-muted-foreground",children:"Settings"})}),O.jsx(cLs,{}),O.jsx(pP,{children:O.jsx(_V,{className:"text-[11px] font-semibold",children:Ee(t)})})]})}),O.jsx("div",{className:"md:hidden",children:O.jsxs(MO,{children:[O.jsx(yy,{render:O.jsxs(D1,{variant:"ghost",size:"sm",className:"-ml-2 h-8 gap-2 text-xs font-semibold",children:[O.jsx(pae,{className:"size-3.5"}),Ee(t),O.jsx(Iy,{className:"size-3 opacity-50"})]})}),O.jsx(xy,{align:"start",className:"w-56",children:he.map(le=>O.jsxs(HIe,{children:[O.jsx(wPs,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-2 py-1.5",children:le.label}),le.items.map(ue=>O.jsxs(Gl,{onClick:()=>a(ue.id),className:t===ue.id?"bg-accent":"",children:[ue.icon,O.jsx("span",{className:"ml-2",children:ue.label})]},ue.id)),O.jsx(af,{})]},le.label))})]})})]})}),O.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[t==="ai-config"&&O.jsxs("div",{className:"p-4 md:p-6",children:[O.jsxs("div",{className:"flex gap-1 bg-muted border border-border rounded-lg p-1 w-full mb-4",children:[O.jsxs("button",{onClick:()=>A("configuration"),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${n==="configuration"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[O.jsx(pae,{className:"w-3.5 h-3.5"}),"Configuration"]}),O.jsxs("button",{onClick:()=>A("models"),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${n==="models"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[O.jsx(Nfe,{className:"w-3.5 h-3.5"}),"AI Models"]})]}),n==="configuration"&&O.jsx(OGr,{providers:h,configs:u,models:w,isSaving:g,isTesting:E,onSave:C,onTest:le=>f(le,Object.values(w).flat()),onUpdateProvider:_,onUpdateConfig:R,onEnsureModel:W,onRefreshModels:Z}),n==="models"&&O.jsx(gYr,{providers:h,models:Object.values(w).flat(),newModel:D,editingModelId:M,isSaving:U,onSetNewModel:H,onAddModel:K,onEditModel:X,onDeleteModel:V,onCancelEdit:J})]}),t==="ai-prompts"&&O.jsx(BYr,{prompts:j,isSaving:z,onSave:q,onDelete:se,onToggleDefault:ie}),t==="ai-rules"&&O.jsx(yYr,{}),t==="backups"&&O.jsx("div",{className:"p-6 space-y-6",children:O.jsx(sVr,{})}),t==="account"&&O.jsx(xYr,{}),t==="changelog"&&O.jsx("div",{className:"p-6 space-y-6",children:O.jsx(szr,{})}),t==="export-data"&&O.jsx("div",{className:"p-4 md:p-6 overflow-y-auto h-full",children:O.jsx(dzr,{})}),t==="import-data"&&O.jsxs("div",{className:"p-4 md:p-6 overflow-y-auto h-full",children:[O.jsxs("div",{className:"mb-6",children:[O.jsx("h2",{className:"text-lg font-semibold",children:"Import Data"}),O.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."})]}),O.jsx(nzr,{})]}),t==="appearance"&&O.jsx(LYr,{}),t==="storage"&&O.jsx(Ezr,{})]})]})]})]})})}async function Czr(){try{const{getVersion:s}=await tr(async()=>{const{getVersion:e}=await Promise.resolve().then(()=>i5a);return{getVersion:e}},void 0);return await s()}catch{return"0.0.0"}}function Pua({open:s,onOpenChange:e,hasUpdate:t=!1,latestVersion:a=null,isChecking:i=!1,isDownloading:n=!1,onCheckUpdate:A,onDownload:h}){const u=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),[E,g]=ae.useState("..."),[C,f]=ae.useState(!1),[_,R]=ae.useState(null),[x,w]=ae.useState(!1),[D,M]=ae.useState(!1),[U,H]=ae.useState(null),K=t||C,V=a||_,W=i||x,X=n||D;ae.useEffect(()=>{u?Czr().then(g):g("3.1.3")},[u]),ae.useEffect(()=>{if(!s||!u||t||i||n)return;if(A){A();return}if(h)return;w(!0);let j=!1;return(async()=>{try{const{check:q}=await tr(async()=>{const{check:ie}=await Promise.resolve().then(()=>Nd1);return{check:ie}},void 0),se=await q();if(j)return;se?(f(!0),R(se.version),H(se)):(f(!1),R(null),H(null))}catch{}finally{j||w(!1)}})(),()=>{j=!0}},[s,u]);const J=ae.useCallback(()=>{if(h)h();else if(U){if(D)return;M(!0),U.downloadAndInstall(()=>{}).catch(j=>{const z=typeof j=="string"?j:j!=null&&j.message?j.message:JSON.stringify(j);v0.error("Update failed",{description:z||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(z).catch(()=>{})}})}).finally(()=>M(!1))}},[h,U,D]),Z=ae.useCallback(()=>{if(X)return;if(A){A();return}w(!0),f(!1),R(null),(async()=>{try{const{check:z}=await tr(async()=>{const{check:se}=await Promise.resolve().then(()=>Nd1);return{check:se}},void 0),q=await z();q?(f(!0),R(q.version),H(q)):(f(!1),R(null),H(null))}catch{}finally{w(!1)}})()},[A,X]);return ae.useEffect(()=>{s||(f(!1),R(null),w(!1),H(null))},[s]),O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"max-w-sm bg-background border-border/40 shadow-2xl",children:[O.jsx(h5,{className:"sr-only",children:"About ERD Builder Pro"}),O.jsx(j_,{className:"sr-only",children:"Application information and credits."}),O.jsxs("div",{className:"flex flex-col items-center py-6 gap-4",children:[O.jsx("div",{className:"flex items-center justify-center",children:O.jsx("img",{src:"/favicon.svg",alt:"ERD Builder Pro",className:"size-14"})}),O.jsxs("div",{className:"text-center",children:[O.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"ERD Builder Pro"}),O.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Version ",E]})]}),O.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."}),u&&O.jsxs("div",{className:"w-full",children:[O.jsx("div",{className:"w-full border-t border-border/40 mb-3"}),W?O.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground py-1",children:[O.jsx(Su,{className:"size-3.5 animate-spin"}),"Checking for updates..."]}):K&&V?O.jsxs("div",{className:"flex flex-col items-center gap-2",children:[O.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-500",children:[O.jsx(AB,{className:"size-3.5"}),O.jsxs("span",{children:["Update ",O.jsxs("strong",{children:["v",V]})," available"]})]}),O.jsxs(D1,{variant:"default",size:"sm",className:"h-8 text-xs gap-1.5",onClick:J,disabled:X,children:[X?O.jsx(Su,{className:"size-3.5 animate-spin"}):O.jsx(AB,{className:"size-3.5"}),X?"Downloading...":"Download Update"]})]}):O.jsxs("div",{className:"flex flex-col items-center gap-2",children:[O.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-500",children:[O.jsx(cb,{className:"size-3.5"}),O.jsx("span",{children:"You're up to date"})]}),O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:Z,children:[O.jsx(aB,{className:"size-3"}),"Check Again"]})]})]}),O.jsx("div",{className:"w-full border-t border-border/40"}),O.jsxs("div",{className:"text-[10px] text-center text-muted-foreground/60 leading-relaxed",children:[O.jsx("p",{children:"Built with React, Tauri, Express & Prisma."}),O.jsxs("p",{className:"mt-0.5",children:["© ",new Date().getFullYear()," Bekenweb."]})]}),O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:()=>{Yvs("https://github.com/hadziqmtqn/erd-builder-pro")},children:[O.jsx(Eae,{className:"size-3"}),"GitHub"]}),O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-rose-500 hover:text-rose-600",onClick:()=>{Yvs("https://trakteer.id/khadziq_muttaqin/tip")},children:[O.jsx(HUe,{className:"size-3"}),"Support"]})]})]})]})})}function pzr(s){const[e,t]=ae.useState(!1),[a,i]=ae.useState(null),[n,A]=ae.useState(!1),[h,u]=ae.useState(null),{setViewport:E,fitView:g}=dre();return{isPublicView:e,setIsPublicView:t,publicData:a,isPublicLoading:n,forbiddenDoc:h,fetchPublicDocument:async(f,_,R,x,w)=>{A(!0),u(null);try{const D=f==="erd"?"files":f==="flowchart"?"flowcharts":f,M={"Content-Type":"application/json"};w&&(M["x-share-token"]=w);const U=await Ri(`/api/${D}/public/${_}`,{headers:M,credentials:"include"});if(!U.ok){let V="Document not found or access denied",W="Access Denied";try{V=(await U.json()).error||V,U.status===404?W="Not Found":(U.status===401||U.status===403)&&(W="Access Denied")}catch{}if(U.status===401||U.status===403||U.status===404)return u({title:W,message:V,status:U.status}),!1;throw new Error(V)}const H=U.headers.get("content-type");if(!H||!H.includes("application/json"))throw new Error("Received invalid response from server");const K=await U.json();if(i(K),s(f),f==="erd"){const V=K.entities.map(J=>({id:J.id,type:"entity",position:{x:J.x,y:J.y},data:J})),W=K.relationships.map(J=>{const Z=K.entities.find(he=>String(he.id)===String(J.source_entity_id)),j=K.entities.find(he=>String(he.id)===String(J.target_entity_id));let z=J.source_handle,q=J.target_handle;if(Z&&j){const he=Number(Z.x)||0,Ae=Number(j.x)||0,Ee=(J.source_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,""),le=(J.target_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,"");Ee&&(z=he<Ae?`col-${Ee}-source`:`col-${Ee}-source-l`),le&&(q=he<Ae?`col-${le}-target`:`col-${le}-target-r`)}const se=(J.source_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,""),ie=(J.target_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,"");return{id:J.id,source:J.source_entity_id,target:J.target_entity_id,sourceHandle:z||(se?`col-${se}-source`:void 0),targetHandle:q||(ie?`col-${ie}-target`:void 0),label:J.label,type:"smoothstep",animated:!0}});R(V),x(W);const X=(J=0)=>{K.viewport_x!==void 0&&(K.viewport_x!==0||K.viewport_y!==0)?E({x:K.viewport_x,y:K.viewport_y,zoom:K.viewport_zoom||1},{duration:J}):V.length>0&&g({padding:.2,duration:J})};setTimeout(()=>X(0),50),setTimeout(()=>X(0),300)}else if(f==="flowchart")try{const V=typeof K.data=="string"?JSON.parse(K.data):K.data;R(V.nodes||[]),x(V.edges||[]);const W=(X=0)=>{var J;K.viewport_x!==void 0&&(K.viewport_x!==0||K.viewport_y!==0)?E({x:K.viewport_x,y:K.viewport_y,zoom:K.viewport_zoom||1},{duration:X}):((J=V.nodes)==null?void 0:J.length)>0&&g({padding:.2,duration:X})};setTimeout(()=>W(0),50),setTimeout(()=>W(0),300)}catch(V){console.error("Failed to parse flowchart data:",V)}else R([]),x([]);return!0}catch(D){return v0.error(D.message||"Failed to load shared document"),setTimeout(()=>window.location.href="/",3e3),!1}finally{A(!1)}}}}function Izr(s){const{open:e,defaultOpen:t,onOpenChange:a,disabled:i}=s,n=e!==void 0,[A,h]=U7e({controlled:e,default:t,name:"Collapsible",state:"open"}),{mounted:u,setMounted:E,transitionStatus:g}=pre(A,!0,!0),[C,f]=ae.useState(A),[{height:_,width:R},x]=ae.useState({height:void 0,width:void 0}),w=pB(),[D,M]=ae.useState(),U=D??w,[H,K]=ae.useState(!1),[V,W]=ae.useState(!1),X=ae.useRef(null),J=ae.useRef(null),Z=ae.useRef(null),j=ae.useRef(null),z=bYt(j,!1),q=Dn(se=>{const ie=!A,he=yA(Fj,se.nativeEvent);if(a(ie,he),he.isCanceled)return;const Ae=j.current;J.current==="css-animation"&&Ae!=null&&Ae.style.removeProperty("animation-name"),!H&&!V&&(J.current!=null&&J.current!=="css-animation"&&!u&&ie&&E(!0),J.current==="css-animation"&&(!C&&ie&&f(!0),!u&&ie&&E(!0))),h(ie),J.current==="none"&&u&&!ie&&E(!1)});return Xr(()=>{n&&J.current==="none"&&!V&&!A&&E(!1)},[n,V,A,e,E]),ae.useMemo(()=>({abortControllerRef:X,animationTypeRef:J,disabled:i,handleTrigger:q,height:_,mounted:u,open:A,panelId:U,panelRef:j,runOnceAnimationsFinish:z,setDimensions:x,setHiddenUntilFound:K,setKeepMounted:W,setMounted:E,setOpen:h,setPanelIdState:M,setVisible:f,transitionDimensionRef:Z,transitionStatus:g,visible:C,width:R}),[X,J,i,q,_,u,A,U,j,z,x,K,W,E,h,f,Z,g,C,R])}const Hua=ae.createContext(void 0);function Gua(){const s=ae.useContext(Hua);if(s===void 0)throw new Error($l(15));return s}let wFe=(function(s){return s.open="data-open",s.closed="data-closed",s[s.startingStyle=pz.startingStyle]="startingStyle",s[s.endingStyle=pz.endingStyle]="endingStyle",s})({}),fzr=(function(s){return s.panelOpen="data-panel-open",s})({});const _zr={[wFe.open]:""},mzr={[wFe.closed]:""},Bzr={open(s){return s?{[fzr.panelOpen]:""}:null}},Rzr={open(s){return s?_zr:mzr}},Yua={...Rzr,...NM},Tzr=ae.forwardRef(function(e,t){const{render:a,className:i,defaultOpen:n=!1,disabled:A=!1,onOpenChange:h,open:u,...E}=e,g=Dn(h),C=Izr({open:u,defaultOpen:n,onOpenChange:g,disabled:A}),f=ae.useMemo(()=>({open:C.open,disabled:C.disabled,transitionStatus:C.transitionStatus}),[C.open,C.disabled,C.transitionStatus]),_=ae.useMemo(()=>({...C,onOpenChange:g,state:f}),[C,g,f]),R=IA("div",e,{state:f,ref:t,props:E,stateAttributesMapping:Yua});return O.jsx(Hua.Provider,{value:_,children:R})}),yzr={...Bzr,...NM},xzr=ae.forwardRef(function(e,t){const{panelId:a,open:i,handleTrigger:n,state:A,disabled:h}=Gua(),{className:u,disabled:E=h,id:g,render:C,nativeButton:f=!0,..._}=e,{getButtonProps:R,buttonRef:x}=cG({disabled:E,focusableWhenDisabled:!0,native:f}),w=ae.useMemo(()=>({"aria-controls":i?a:void 0,"aria-expanded":i,onClick:n}),[a,i,n]);return IA("button",e,{state:A,ref:[t,x],props:[w,_,R],stateAttributesMapping:yzr})});let Ozr=(function(s){return s.disabled="data-disabled",s.orientation="data-orientation",s})({});function Szr(s){const{abortControllerRef:e,animationTypeRef:t,externalRef:a,height:i,hiddenUntilFound:n,keepMounted:A,id:h,mounted:u,onOpenChange:E,open:g,panelRef:C,runOnceAnimationsFinish:f,setDimensions:_,setMounted:R,setOpen:x,setVisible:w,transitionDimensionRef:D,visible:M,width:U}=s,H=ae.useRef(!1),K=ae.useRef(null),V=ae.useRef(g),W=ae.useRef(g),X=QVe(),J=ae.useMemo(()=>t.current==="css-animation"?!M:!g&&!u,[g,u,M,t]),Z=Dn(z=>{if(!z)return;if(t.current==null||D.current==null){const ie=getComputedStyle(z),he=ie.animationName!=="none"&&ie.animationName!=="",Ae=ie.transitionDuration!=="0s"&&ie.transitionDuration!=="";he&&Ae||(ie.animationName==="none"&&ie.transitionDuration!=="0s"?t.current="css-transition":ie.animationName!=="none"&&ie.transitionDuration==="0s"?t.current="css-animation":t.current="none"),z.getAttribute(Ozr.orientation)==="horizontal"||ie.transitionProperty.indexOf("width")>-1?D.current="width":D.current="height"}if(t.current!=="css-transition")return;(i===void 0||U===void 0)&&(_({height:z.scrollHeight,width:z.scrollWidth}),W.current&&z.style.setProperty("transition-duration","0s"));let q=-1,se=-1;return q=$C.request(()=>{W.current=!1,se=$C.request(()=>{setTimeout(()=>{z.style.removeProperty("transition-duration")})})}),()=>{$C.cancel(q),$C.cancel(se)}}),j=LH(a,C,Z);return Xr(()=>{if(t.current!=="css-transition")return;const z=C.current;if(!z)return;let q=-1;if(e.current!=null&&(e.current.abort(),e.current=null),g){const se={"justify-content":z.style.justifyContent,"align-items":z.style.alignItems,"align-content":z.style.alignContent,"justify-items":z.style.justifyItems};Object.keys(se).forEach(ie=>{z.style.setProperty(ie,"initial","important")}),!W.current&&!A&&z.setAttribute(wFe.startingStyle,""),_({height:z.scrollHeight,width:z.scrollWidth}),q=$C.request(()=>{Object.entries(se).forEach(([ie,he])=>{he===""?z.style.removeProperty(ie):z.style.setProperty(ie,he)})})}else{if(z.scrollHeight===0&&z.scrollWidth===0)return;_({height:z.scrollHeight,width:z.scrollWidth});const se=new AbortController;e.current=se;const ie=se.signal;let he=null;const Ae=wFe.endingStyle;return he=new MutationObserver(Ee=>{Ee.some(ue=>ue.type==="attributes"&&ue.attributeName===Ae)&&(he==null||he.disconnect(),he=null,f(()=>{_({height:0,width:0}),z.style.removeProperty("content-visibility"),R(!1),e.current===se&&(e.current=null)},ie))}),he.observe(z,{attributes:!0,attributeFilter:[Ae]}),()=>{he==null||he.disconnect(),X.cancel(),e.current===se&&(se.abort(),e.current=null)}}return()=>{$C.cancel(q)}},[e,t,X,n,A,u,g,C,f,_,R]),Xr(()=>{if(t.current!=="css-animation")return;const z=C.current;z&&(K.current=z.style.animationName||K.current,z.style.setProperty("animation-name","none"),_({height:z.scrollHeight,width:z.scrollWidth}),!V.current&&!H.current&&z.style.removeProperty("animation-name"),g?(e.current!=null&&(e.current.abort(),e.current=null),R(!0),w(!0)):(e.current=new AbortController,f(()=>{R(!1),w(!1),e.current=null},e.current.signal)))},[e,t,g,C,f,_,R,w,M]),xVe(()=>{const z=$C.request(()=>{V.current=!1});return()=>$C.cancel(z)}),Xr(()=>{if(!n)return;const z=C.current;if(!z)return;let q=-1,se=-1;return g&&H.current&&(z.style.transitionDuration="0s",_({height:z.scrollHeight,width:z.scrollWidth}),q=$C.request(()=>{H.current=!1,se=$C.request(()=>{setTimeout(()=>{z.style.removeProperty("transition-duration")})})})),()=>{$C.cancel(q),$C.cancel(se)}},[n,g,C,_]),Xr(()=>{const z=C.current;z&&n&&J&&(z.setAttribute("hidden","until-found"),t.current==="css-transition"&&z.setAttribute(wFe.startingStyle,""))},[n,J,t,C]),ae.useEffect(function(){const q=C.current;if(!q)return;function se(ie){H.current=!0,x(!0),E(!0,yA(Uj,ie))}return q.addEventListener("beforematch",se),()=>{q.removeEventListener("beforematch",se)}},[E,C,x]),ae.useMemo(()=>({props:{hidden:J,id:h,ref:j}}),[J,h,j])}let fC1=(function(s){return s.collapsiblePanelHeight="--collapsible-panel-height",s.collapsiblePanelWidth="--collapsible-panel-width",s})({});const Lzr=ae.forwardRef(function(e,t){const{className:a,hiddenUntilFound:i,keepMounted:n,render:A,id:h,...u}=e,{abortControllerRef:E,animationTypeRef:g,height:C,mounted:f,onOpenChange:_,open:R,panelId:x,panelRef:w,runOnceAnimationsFinish:D,setDimensions:M,setHiddenUntilFound:U,setKeepMounted:H,setMounted:K,setPanelIdState:V,setOpen:W,setVisible:X,state:J,transitionDimensionRef:Z,visible:j,width:z,transitionStatus:q}=Gua(),se=i??!1,ie=n??!1;Xr(()=>{if(h)return V(h),()=>{V(void 0)}},[h,V]),Xr(()=>{U(se)},[U,se]),Xr(()=>{H(ie)},[H,ie]);const{props:he}=Szr({abortControllerRef:E,animationTypeRef:g,externalRef:t,height:C,hiddenUntilFound:se,id:x,keepMounted:ie,mounted:f,onOpenChange:_,open:R,panelRef:w,runOnceAnimationsFinish:D,setDimensions:M,setMounted:K,setOpen:W,setVisible:X,transitionDimensionRef:Z,visible:j,width:z});NN({open:R&&q==="idle",ref:w,onComplete(){R&&M({height:void 0,width:void 0})}});const Ae=ae.useMemo(()=>({...J,transitionStatus:q}),[J,q]),Ee=IA("div",e,{state:Ae,ref:[t,w],props:[he,{style:{[fC1.collapsiblePanelHeight]:C===void 0?"auto":`${C}px`,[fC1.collapsiblePanelWidth]:z===void 0?"auto":`${z}px`}},u],stateAttributesMapping:Yua});return ie||se||!ie&&f?Ee:null});function Qzr({...s}){return O.jsx(Tzr,{"data-slot":"collapsible",...s})}function vzr({...s}){return O.jsx(xzr,{"data-slot":"collapsible-trigger",...s})}function wzr({...s}){return O.jsx(Lzr,{"data-slot":"collapsible-content",...s})}function Nzr({items:s}){return O.jsx(jVe,{children:s.map(e=>{var t;return O.jsx(lme,{children:e.items?O.jsxs(Qzr,{defaultOpen:e.isActive,className:"group/collapsible",children:[O.jsx(vzr,{render:O.jsxs($ae,{tooltip:e.title,className:"cursor-pointer",children:[e.icon&&O.jsx(e.icon,{className:e.iconClassName}),O.jsx("span",{children:e.title}),O.jsx(qg,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),O.jsx(wzr,{children:O.jsx(Cpr,{children:(t=e.items)==null?void 0:t.map(a=>O.jsx(ppr,{children:O.jsx(UK1,{render:O.jsx("a",{href:a.url}),className:"cursor-pointer",children:O.jsx("span",{children:a.title})})},a.title))})})]}):O.jsxs($ae,{tooltip:e.title,isActive:e.isActive,onClick:e.onClick,className:"cursor-pointer",children:[e.icon&&O.jsx(e.icon,{className:e.iconClassName}),O.jsx("span",{children:e.title})]})},e.title)})})}const Kua=ae.createContext(void 0);function Vua(){const s=ae.useContext(Kua);if(s===void 0)throw new Error($l(13));return s}const op0={imageLoadingStatus:()=>null},Dzr=ae.forwardRef(function(e,t){const{className:a,render:i,...n}=e,[A,h]=ae.useState("idle"),u={imageLoadingStatus:A},E=ae.useMemo(()=>({imageLoadingStatus:A,setImageLoadingStatus:h}),[A,h]),g=IA("span",e,{state:u,ref:t,props:n,stateAttributesMapping:op0});return O.jsx(Kua.Provider,{value:E,children:g})});function kzr(s,{referrerPolicy:e,crossOrigin:t}){const[a,i]=ae.useState("idle");return Xr(()=>{if(!s)return i("error"),_O;let n=!0;const A=new window.Image,h=u=>()=>{n&&i(u)};return i("loading"),A.onload=h("loaded"),A.onerror=h("error"),e&&(A.referrerPolicy=e),A.crossOrigin=t??null,A.src=s,()=>{n=!1}},[s,t,e]),a}const bzr={...op0,...NM},Mzr=ae.forwardRef(function(e,t){const{className:a,render:i,onLoadingStatusChange:n,referrerPolicy:A,crossOrigin:h,...u}=e,E=Vua(),g=kzr(e.src,{referrerPolicy:A,crossOrigin:h}),C=g==="loaded",{mounted:f,transitionStatus:_,setMounted:R}=pre(C),x=ae.useRef(null),w=Dn(U=>{n==null||n(U),E.setImageLoadingStatus(U)});Xr(()=>{g!=="idle"&&w(g)},[g,w]);const D={imageLoadingStatus:g,transitionStatus:_};NN({open:C,ref:x,onComplete(){C||R(!1)}});const M=IA("img",e,{state:D,ref:[t,x],props:u,stateAttributesMapping:bzr,enabled:f});return f?M:null}),Uzr=ae.forwardRef(function(e,t){const{className:a,render:i,delay:n,...A}=e,{imageLoadingStatus:h}=Vua(),[u,E]=ae.useState(n===void 0),g=q8();return ae.useEffect(()=>(n!==void 0&&g.start(n,()=>E(!0)),g.clear),[g,n]),IA("span",e,{state:{imageLoadingStatus:h},ref:t,props:A,stateAttributesMapping:op0,enabled:h!=="loaded"&&u})}),nws=ae.forwardRef(({className:s,size:e="default",...t},a)=>O.jsx(Dzr,{ref:a,"data-slot":"avatar","data-size":e,className:ei("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",s),...t}));nws.displayName="Avatar";const cws=ae.forwardRef(({className:s,...e},t)=>O.jsx(Mzr,{ref:t,"data-slot":"avatar-image",className:ei("aspect-square size-full rounded-full object-cover",s),...e}));cws.displayName="AvatarImage";const Aws=ae.forwardRef(({className:s,...e},t)=>O.jsx(Uzr,{ref:t,"data-slot":"avatar-fallback",className:ei("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",s),...e}));Aws.displayName="AvatarFallback";function Fzr({open:s,onOpenChange:e}){const[t,a]=ae.useState(!1),i=async()=>{a(!0);try{await Fua(),v0.success("Data exported successfully!")}catch(n){v0.error("Export failed: "+(n.message||"Unknown error"))}finally{a(!1)}};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-105 bg-background border-border/40 shadow-2xl",children:[O.jsx(h5,{className:"sr-only",children:"Guest Data Backup"}),O.jsx(j_,{className:"sr-only",children:"Export your Guest Mode data as a JSON file for safe keeping or future import."}),O.jsxs("div",{className:"p-2 space-y-6",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsx("div",{className:"p-2.5 bg-amber-500/10 rounded-xl",children:O.jsx(Tj,{className:"size-5 text-amber-500"})}),O.jsxs("div",{children:[O.jsx("h3",{className:"font-semibold text-base",children:"Guest Mode"}),O.jsx("p",{className:"text-xs text-muted-foreground",children:"You are browsing as a guest"})]})]}),O.jsxs("div",{className:"bg-muted/10 border border-border/40 rounded-xl p-4 space-y-3",children:[O.jsxs("div",{className:"flex items-start gap-3",children:[O.jsx(M3,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),O.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:O.jsxs("p",{children:["Your data (notes, diagrams, flowcharts, drawings, and AI chats) is stored locally in your browser. Export it as a ",O.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," ","file so you can import it after signing in."]})})]}),O.jsxs("div",{className:"flex items-start gap-3",children:[O.jsx(bfe,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),O.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:O.jsxs("p",{children:["The export file can be imported into any ERD Builder Pro account via",O.jsx("strong",{children:" Settings → Guest Data Import"}),"."]})})]})]}),O.jsx(D1,{onClick:i,disabled:t,className:"w-full",children:t?O.jsxs(O.Fragment,{children:[O.jsx(Su,{className:"size-4 mr-2 animate-spin"}),"Exporting…"]}):O.jsxs(O.Fragment,{children:[O.jsx(AB,{className:"size-4 mr-2"}),"Export My Data"]})}),O.jsxs("div",{className:"relative",children:[O.jsx("div",{className:"absolute inset-0 flex items-center",children:O.jsx("span",{className:"w-full border-t border-border/30"})}),O.jsx("div",{className:"relative flex justify-center text-xs",children:O.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Need an account?"})})]}),O.jsx("div",{className:"text-center space-y-2",children:O.jsx("p",{className:"text-xs text-muted-foreground",children:"Sign up or log in from the main page to import your backup."})})]})]})})}function Pzr({user:s,onLogout:e,onViewChange:t,isOnline:a,onOpenFeedback:i}){var j,z,q;const{isMobile:n}=mre(),{isGuest:A,setIsSettingsOpen:h,setSettingsTab:u,hasUpdate:E,latestVersion:g,isCheckingUpdate:C,isDownloadingUpdate:f,isWebOutdated:_,showOutdatedBadge:R,checkForUpdates:x,downloadUpdate:w}=AC(),D=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__);if(!s)return null;const M=s.email||"",U=s.name||((j=s.user_metadata)==null?void 0:j.full_name)||((z=s.user_metadata)==null?void 0:z.name)||M.split("@")[0]||"User",H=((q=s.user_metadata)==null?void 0:q.avatar_url)||"",K=U.substring(0,2).toUpperCase(),V=se=>{u(se),h(!0)},[W,X]=ae.useState(!1),[J,Z]=ae.useState(!1);return O.jsxs(O.Fragment,{children:[O.jsx(jVe,{children:O.jsx(lme,{children:O.jsxs(MO,{children:[O.jsx(yy,{render:O.jsxs($ae,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[O.jsxs("div",{className:"relative",children:[O.jsxs(nws,{className:"h-8 w-8 rounded-lg",children:[O.jsx(cws,{src:H,alt:U}),O.jsx(Aws,{className:"rounded-lg",children:K})]}),R&&O.jsx("span",{className:"absolute -top-1 -right-1 flex size-3 rounded-full bg-amber-500 ring-2 ring-sidebar",title:D?`Update available: v${g||"?"}`:_?`New version available: v${g||"?"}. You're on v3.1.3. Pull latest Docker image or update your install.`:""})]}),O.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[O.jsx("span",{className:"truncate font-semibold",children:U}),O.jsx("span",{className:"truncate text-xs",children:M})]}),O.jsx(xUe,{className:"ml-auto size-4"})]})}),O.jsxs(xy,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:n?"bottom":"right",align:"end",sideOffset:4,children:[O.jsx(HIe,{children:O.jsx(wPs,{className:"p-0 font-normal",children:O.jsx(HIe,{children:O.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[O.jsxs(nws,{className:"h-8 w-8 rounded-lg",children:[O.jsx(cws,{src:H,alt:U}),O.jsx(Aws,{className:"rounded-lg",children:K})]}),O.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[O.jsx("span",{className:"truncate font-semibold",children:U}),O.jsx("span",{className:"truncate text-xs",children:M})]})]})})})}),O.jsx(af,{}),O.jsxs(HIe,{children:[O.jsxs(Gl,{onClick:()=>V(A?"appearance":"account"),className:"cursor-pointer",disabled:!A&&!a,children:[O.jsx(pae,{className:"mr-2 size-4"}),"Settings"]}),A&&O.jsxs(Gl,{onClick:()=>X(!0),className:"cursor-pointer",children:[O.jsx(AB,{className:"mr-2 size-4"}),"Backup Data"]}),O.jsx(af,{}),O.jsxs(Gl,{onClick:()=>Z(!0),className:"cursor-pointer",children:[E?O.jsx(c1e,{className:"mr-2 size-4 text-emerald-400"}):_?O.jsx(BUe,{className:"mr-2 size-4 text-amber-500"}):O.jsx(jb,{className:"mr-2 size-4"}),"About",R&&O.jsx("span",{className:`ml-auto flex size-2 rounded-full ${E?"bg-emerald-400":"bg-amber-500"}`})]}),O.jsxs(Gl,{render:O.jsx("a",{href:"https://github.com/hadziqmtqn/erd-builder-pro",target:"_blank",rel:"noopener noreferrer"}),className:"cursor-pointer",children:[O.jsx(DUe,{className:"mr-2 size-4"}),"Github"]}),O.jsxs(Gl,{onClick:i,className:"cursor-pointer",children:[O.jsx(XUe,{className:"mr-2 size-4"}),"Feedback"]})]}),O.jsx(af,{}),O.jsx(HIe,{children:O.jsxs(Gl,{onClick:()=>a&&t("trash"),disabled:!a,className:`text-destructive focus:bg-accent focus:text-destructive cursor-pointer ${!a&&"opacity-50 cursor-not-allowed"}`,children:[O.jsx(F5,{className:"mr-2 size-4"}),"Trash"]})}),O.jsx(af,{}),!D&&O.jsxs(Gl,{onClick:()=>a&&e(),disabled:!a,className:`cursor-pointer ${!a&&"opacity-50 cursor-not-allowed"}`,title:a?"":"Logging out while offline may cause data loss of unsynced changes",children:[O.jsx(WUe,{className:"mr-2 size-4"}),"Log out"]})]})]})})}),O.jsx(Fzr,{open:W,onOpenChange:X}),O.jsx(Pua,{open:J,onOpenChange:Z,hasUpdate:E,latestVersion:g,isChecking:C,isDownloading:f,onCheckUpdate:x,onDownload:w})]})}function Hzr({teams:s}){const{isMobile:e}=mre(),t=wM(),a=s[0];return O.jsx(jVe,{children:O.jsx(lme,{children:O.jsxs($ae,{size:"lg",onClick:()=>t("/"),className:"hover:bg-accent/50 active:bg-accent/70 transition-colors cursor-pointer",children:[O.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-brand text-white",children:O.jsx(a.logo,{className:"size-4"})}),O.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[O.jsxs("span",{className:"truncate font-semibold",children:["ERD Builder ",O.jsx("span",{className:"text-brand",children:"Pro"})]}),O.jsx("span",{className:"truncate text-xs",children:a.plan})]})]})})})}const ows=({isOpen:s,onOpenChange:e,mode:t="move-to-trash",activeDocument:a,view:i,deleteDiagram:n,deleteNote:A,deleteDrawing:h,deleteFlowchart:u,deleteProject:E,fetchTrash:g,itemType:C,onConfirm:f,onAfterDelete:_})=>{const R=async()=>{if(t==="permanent-delete"){f==null||f(),_==null||_();return}if(f){f(),_==null||_();return}const D=i==="erd"||i==="notes"||i==="flowchart"||i==="drawings"?(a==null?void 0:a.uid)??(a==null?void 0:a.id):a==null?void 0:a.id;D&&(i==="erd"?await(n==null?void 0:n(D)):i==="notes"?await(A==null?void 0:A(String(D))):i==="drawings"?await(h==null?void 0:h(D)):i==="flowchart"?await(u==null?void 0:u(D)):i==="project"&&await(E==null?void 0:E(D)),g==null||g(),e(!1),_==null||_())},x=C==="erd"?"diagram":C==="notes"?"note":C==="drawings"?"drawing":C==="project"?"workspace":"item";if(t==="permanent-delete"){const D=C==="project";return O.jsx(hH,{open:s,onOpenChange:e,children:O.jsxs(lH,{size:"sm",className:"max-w-[400px]",children:[O.jsxs(dH,{children:[O.jsx(hRe,{className:"bg-destructive/10",children:O.jsx(Jm,{className:"w-5 h-5 text-destructive"})}),O.jsx(CH,{children:"Are you absolutely sure?"})]}),O.jsx(EH,{children:O.jsx(S5e,{children:D?O.jsxs(O.Fragment,{children:["This action cannot be undone. Deleting this workspace will also permanently delete all",O.jsx("strong",{children:" notes, diagrams, drawings, and flowcharts"})," inside it."]}):O.jsxs(O.Fragment,{children:["This action cannot be undone. This will permanently delete the ",O.jsx("strong",{children:x})," from our servers."]})})}),O.jsxs(gH,{children:[O.jsx(eM,{onClick:()=>e(!1),children:"Cancel"}),O.jsx(nW,{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Permanently Delete"})]})]})})}const w=i!=="project";return O.jsx(hH,{open:s,onOpenChange:e,children:O.jsxs(lH,{size:"sm",className:"max-w-[400px]",children:[O.jsxs(dH,{children:[O.jsx(hRe,{className:"bg-destructive/10",children:O.jsx(F5,{className:"w-5 h-5 text-destructive"})}),O.jsx(CH,{children:w?"Move to Trash?":"Delete Workspace?"})]}),O.jsx(EH,{children:O.jsx(S5e,{children:w?O.jsxs(O.Fragment,{children:["Are you sure you want to move ",O.jsx("strong",{children:(a==null?void 0:a.title)||(a==null?void 0:a.name)||"this item"})," to trash?",O.jsx("br",{}),"You can restore it later from the trash bin."]}):O.jsxs(O.Fragment,{children:["This will move the workspace and all its contents to trash.",O.jsx("br",{}),"You can restore it later from the trash bin."]})})}),O.jsxs(gH,{children:[O.jsx(eM,{onClick:()=>e(!1),children:"Cancel"}),O.jsx(nW,{onClick:R,children:w?"Move to Trash":"Delete"})]})]})})},Gzr=6e3,_C1=[{logoSrc:"https://s3.erdbuilderpro.com/sponsors/Sumopod-Light.png",logoDarkSrc:"https://s3.erdbuilderpro.com/sponsors/Sumopod-Dark.png",logoAlt:"SumoPod",title:"Deploy your App in 15 Seconds!",description:"Seamless container deployment for businesses of all sizes.",buttonText:"Get Started →",buttonColor:"#2071FB",buttonHoverColor:"#1a5fd4",buttonAction:"https://sumopod.com"}];function Yzr({isCollapsed:s}){const[e,t]=ae.useState(0);if(ae.useEffect(()=>{const i=setInterval(()=>t(n=>(n+1)%_C1.length),Gzr);return()=>clearInterval(i)},[]),s)return null;const a=_C1[e];return O.jsx("div",{className:"px-3 mb-2",children:O.jsx("div",{className:"overflow-hidden rounded-xl border border-dashed border-border/80 dark:border-border/70 bg-card/85 p-3",children:O.jsxs("div",{className:"flex flex-col items-center gap-1.5 animate-in fade-in slide-in-from-right-4 duration-500",children:[a.icon?O.jsx(a.icon,{className:"w-5 h-5 text-rose-500 shrink-0"}):a.logoSrc?O.jsxs(O.Fragment,{children:[O.jsx("img",{src:a.logoSrc,alt:a.logoAlt??"",className:"h-8 w-auto max-w-full object-contain dark:hidden shrink-0"}),a.logoDarkSrc&&O.jsx("img",{src:a.logoDarkSrc,alt:a.logoAlt??"",className:"h-8 w-auto max-w-full object-contain hidden dark:block shrink-0"})]}):null,O.jsx("p",{className:"text-xs font-semibold text-foreground text-center truncate max-w-full",children:a.title}),O.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed text-center wrap-break-word",children:a.description}),O.jsx("button",{className:"w-full h-7 inline-flex items-center justify-center rounded-md text-white text-[10px] font-semibold transition-colors cursor-pointer mt-1",style:{backgroundColor:a.buttonColor||"#2071FB"},onMouseEnter:i=>{a.buttonHoverColor&&(i.currentTarget.style.backgroundColor=a.buttonHoverColor)},onMouseLeave:i=>{i.currentTarget.style.backgroundColor=a.buttonColor||"#2071FB"},onClick:()=>Yvs(a.buttonAction),children:a.buttonText})]},e)})})}const Kzr=ae.memo(({projects:s,view:e,onViewChange:t,onNoteSelect:a,onDrawingSelect:i,onProjectCreate:n,onProjectUpdate:A,onProjectDelete:h,onLogout:u,onWorkspaceFilter:E,selectedWorkspaceUid:g,searchQuery:C,onSearchChange:f,isProjectsLoading:_,user:R,isOnline:x,onOpenFeedback:w,...D})=>{const{state:M}=mre(),U=M==="collapsed",H=ae.useRef(null),[K,V]=ae.useState(null),[W,X]=ae.useState(""),[J,Z]=ae.useState(null),[j,z]=ae.useState(!1),[q,se]=ae.useState(""),ie=[{title:"Notes",url:"#",icon:P_,iconClassName:"text-yellow-400",isActive:e==="notes",onClick:()=>t("notes",!0)},{title:"ERD Builder",url:"#",icon:M3,iconClassName:"text-blue-400",isActive:e==="erd",onClick:()=>t("erd",!0)},{title:"Flowchart",url:"#",icon:AH,iconClassName:"text-green-400",isActive:e==="flowchart",onClick:()=>t("flowchart",!0)},{title:"Drawings",url:"#",icon:$b,iconClassName:"text-purple-400",isActive:e==="drawings",onClick:()=>t("drawings",!0)}],he=s.filter(Ee=>!Ee.is_deleted),Ae=(Ee,le)=>{const ue=Ee??(le!=null?String(le):null);t(e,!0,ue)};return O.jsxs(O.Fragment,{children:[O.jsxs(kK1,{collapsible:"icon",...D,children:[O.jsxs(lpr,{children:[O.jsx(Hzr,{teams:[{name:"ERD Builder Pro",logo:M3,plan:"Workspace"}]}),O.jsx(UOt,{className:"py-0 group-data-[collapsible=icon]:hidden",children:O.jsxs(nLs,{className:"relative",children:[O.jsx(bK1,{ref:H,placeholder:"search workspace",className:"pl-8",value:C,onChange:Ee=>f(Ee.target.value),disabled:!x}),O.jsx(LO,{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"})]})}),O.jsxs(UOt,{className:"group-data-[collapsible=icon]:p-0",children:[O.jsxs(rLs,{className:"flex items-center justify-between",children:["Features",!x&&O.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:[O.jsx("span",{className:"w-1 h-1 rounded-full bg-destructive animate-pulse"}),"Offline"]})]}),O.jsx(Nzr,{items:ie})]})]}),O.jsx(MK1,{children:O.jsxs(UOt,{className:"px-4 group-data-[collapsible=icon]:p-2",children:[O.jsxs(rLs,{className:"flex items-center justify-between",children:[O.jsx("span",{children:"Workspaces"}),O.jsx(qw,{children:O.jsxs(v_,{children:[O.jsx(w_,{className:"hover:bg-muted hover:text-foreground rounded-md p-0.5 cursor-pointer",onClick:()=>{se(""),z(!0)},children:O.jsx(Z8,{className:"h-3.5 w-3.5"})}),O.jsx(N_,{side:"right",children:"Create Workspace"})]})})]}),O.jsx(nLs,{children:O.jsxs(jVe,{children:[O.jsx(lme,{children:O.jsxs($ae,{tooltip:"All Workspaces",isActive:g===null||g==="",onClick:()=>Ae(null),children:[O.jsx(Bj,{className:"h-4 w-4 shrink-0"}),O.jsx("span",{children:"All Workspaces"})]})}),_?O.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground animate-pulse group-data-[collapsible=icon]:hidden",children:"Loading workspaces..."}):he.length===0?O.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground group-data-[collapsible=icon]:hidden",children:"No workspaces yet"}):he.map(Ee=>O.jsx(lme,{children:O.jsxs($ae,{tooltip:Ee.name,isActive:g===Ee.uid||String(g??"")===String(Ee.id??""),onClick:()=>Ae(Ee.uid,Ee.id),children:[O.jsx(Bj,{className:"h-4 w-4 shrink-0"}),O.jsx("span",{className:"truncate flex-1 text-left",children:Ee.name}),O.jsx("span",{onClick:le=>le.stopPropagation(),children:O.jsxs(MO,{children:[O.jsx(yy,{nativeButton:!1,render:O.jsx("span",{className:"p-1 rounded hover:bg-accent/50 cursor-pointer inline-flex items-center justify-center",children:O.jsx(fO,{className:"h-3.5 w-3.5"})})}),O.jsxs(xy,{align:"end",children:[O.jsxs(Gl,{onClick:()=>{X(Ee.name),V(Ee)},children:[O.jsx(SQ,{className:"h-3.5 w-3.5 mr-2"}),"Edit"]}),O.jsx(af,{}),O.jsxs(Gl,{onClick:()=>Z(Ee),children:[O.jsx(F5,{className:"h-3.5 w-3.5 mr-2 text-destructive"}),"Delete"]})]})]})})]})},Ee.uid??Ee.id))]})})]})}),O.jsxs(dpr,{children:[O.jsx(Yzr,{isCollapsed:U}),O.jsx(Pzr,{user:R,onLogout:u,onViewChange:t,isOnline:x,onOpenFeedback:w})]}),O.jsx(upr,{})]}),O.jsx(u5,{open:K!==null,onOpenChange:Ee=>{Ee||V(null)},children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsx(q6,{children:O.jsx(h5,{children:"Rename Workspace"})}),O.jsx(Hd,{children:O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"rename-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),O.jsx(DA,{id:"rename-project-input",type:"text",value:W,onChange:Ee=>X(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&W.trim()&&K&&(A(K.id,W.trim()),V(null))},autoFocus:!0})]})}),O.jsxs(ff,{children:[O.jsx(cvt,{render:O.jsx(D1,{variant:"outline",className:"h-9"}),children:"Cancel"}),O.jsx(D1,{className:"h-9 px-6",disabled:!W.trim(),onClick:()=>{K&&W.trim()&&(A(K.id,W.trim()),V(null))},children:"Save Changes"})]})]})}),O.jsx(u5,{open:j,onOpenChange:z,children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsx(q6,{children:O.jsx(h5,{children:"Create Workspace"})}),O.jsx(Hd,{children:O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"create-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),O.jsx(DA,{id:"create-project-input",type:"text",value:q,onChange:Ee=>se(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&q.trim()&&(n(q.trim()),z(!1),se(""))},autoFocus:!0})]})}),O.jsxs(ff,{children:[O.jsx(cvt,{render:O.jsx(D1,{variant:"outline",className:"h-9"}),children:"Cancel"}),O.jsx(D1,{className:"h-9 px-6",disabled:!q.trim(),onClick:()=>{q.trim()&&(n(q.trim()),z(!1),se(""))},children:"Create"})]})]})}),O.jsx(ows,{isOpen:J!==null,onOpenChange:Ee=>{Ee||Z(null)},mode:"move-to-trash",view:"project",activeDocument:J?{id:J.id,name:J.name}:void 0,deleteProject:h,onAfterDelete:()=>Z(null)})]})}),Md=ae.forwardRef(({className:s,...e},t)=>O.jsx("label",{ref:t,"data-slot":"label",className:ei("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",s),...e}));Md.displayName="Label";function Vzr({isOpen:s,onOpenChange:e,documentType:t,documentUid:a,documentId:i,documentTitle:n,isPublicView:A=!1,initialSettings:h,onSettingsSaved:u}){const[E,g]=$s.useState((h==null?void 0:h.share_token)||""),[C,f]=$s.useState(!1),[_,R]=$s.useState((h==null?void 0:h.is_public)||!1),[x,w]=$s.useState(""),[D,M]=$s.useState(!1);$s.useEffect(()=>{if(h!=null&&h.expiry_date){const J=new Date(h.expiry_date),Z=new Date,j=J.getTime()-Z.getTime(),z=Math.ceil(j/(1e3*60*60*24));z>0&&w(z.toString())}g((h==null?void 0:h.share_token)||""),R((h==null?void 0:h.is_public)||!1)},[h]);const H={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[t]||t,K=`${window.location.origin}/view/${H}/${a}`,V=()=>{navigator.clipboard.writeText(K),f(!0),v0.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)},W=()=>{const J=Math.random().toString(36).substring(2,10).toUpperCase();g(J),v0.info("Secure token generated")},X=async()=>{M(!0);try{const J=t==="erd"?"diagrams":t==="flowchart"?"flowcharts":t;let Z=null;if(x&&!isNaN(parseInt(x))){const z=new Date;z.setDate(z.getDate()+parseInt(x)),Z=z.toISOString()}if(!(await Ri(`/api/${J}/${i}/share`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_public:_,share_token:E,expiry_date:Z})})).ok)throw new Error("Failed to save settings");v0.success("Sharing settings updated!"),u&&u(),e(!1)}catch(J){v0.error(J.message||"Something went wrong")}finally{M(!1)}};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-md",children:[O.jsxs(q6,{children:[O.jsx(h5,{children:A?"Share Document":`Share "${n}"`}),O.jsx(j_,{children:A?"Share this link with others to view this document.":_?"Anyone with this link can view this document. No account required.":"This document is currently private. Only you can access it."})]}),O.jsxs(Hd,{className:"space-y-4",children:[!A&&O.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30 transition-colors hover:bg-muted/50",children:[O.jsxs("div",{className:"space-y-0.5",children:[O.jsxs("div",{className:"flex items-center gap-2",children:[_?O.jsx(Vb,{className:"w-4 h-4 text-primary"}):O.jsx(Wb,{className:"w-4 h-4 text-muted-foreground"}),O.jsx(Md,{htmlFor:"public-status",className:"text-sm font-bold",children:"Public Access"})]}),O.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Enable sharing via public link"})]}),O.jsx("input",{id:"public-status",type:"checkbox",checked:_,onChange:J=>R(J.target.checked),className:"w-4 h-4 cursor-pointer accent-primary"})]}),O.jsxs("div",{className:`space-y-4 transition-all duration-300 ${_||A?"opacity-100":"opacity-40 pointer-events-none grayscale-[0.5]"}`,children:[O.jsxs("div",{className:"space-y-2",children:[O.jsx(Md,{htmlFor:"share-link",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Public Link"}),O.jsxs("div",{className:"flex items-center space-x-2",children:[O.jsx(DA,{id:"share-link",readOnly:!0,value:K,className:"flex-1 bg-muted/20 font-mono text-xs"}),O.jsx(D1,{onClick:V,size:"icon",variant:"outline",className:"shrink-0 cursor-pointer hover:bg-primary/10 hover:text-primary transition-colors",disabled:!_&&!A,children:C?O.jsx(l8,{className:"w-4 h-4 text-green-500"}):O.jsx(SO,{className:"w-4 h-4"})})]})]}),!A&&O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"space-y-2 pt-2",children:[O.jsxs("div",{className:"flex items-center justify-between",children:[O.jsx(Md,{htmlFor:"access-token",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Access Token (Optional)"}),O.jsxs(D1,{variant:"link",size:"sm",onClick:W,className:"h-auto p-0 text-[10px] uppercase font-bold tracking-tighter cursor-pointer text-primary hover:no-underline",disabled:!_,children:[O.jsx(aB,{className:"w-3 h-3 mr-1"}),"Generate"]})]}),O.jsx(DA,{id:"access-token",placeholder:"Enter or generate a token...",value:E,onChange:J=>g(J.target.value),disabled:!_,className:"font-mono text-xs"})]}),O.jsxs("div",{className:"space-y-2 pt-2",children:[O.jsx(Md,{htmlFor:"valid-until",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Duration (Days)"}),O.jsx(DA,{id:"valid-until",type:"number",placeholder:"Forever",value:x,onChange:J=>w(J.target.value),disabled:!_,className:"text-xs"})]})]})]})]}),O.jsx(ff,{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:A?O.jsx(D1,{type:"button",onClick:()=>e(!1),className:"cursor-pointer w-full sm:w-auto font-bold",children:"Close"}):O.jsxs(O.Fragment,{children:[O.jsx(D1,{variant:"ghost",onClick:()=>e(!1),className:"cursor-pointer order-2 sm:order-1 font-semibold",disabled:D,children:"Cancel"}),O.jsx(D1,{type:"button",onClick:X,className:"cursor-pointer order-1 sm:order-2 font-bold min-w-[120px]",disabled:D,children:D?O.jsxs(O.Fragment,{children:[O.jsx(aB,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})})]})})}const jzr=({onShare:s,onRename:e,onDelete:t,onDuplicate:a,onExportAll:i,onExportMarkdown:n,onCopyMarkdown:A,onImportMarkdown:h,isOnline:u,isPublicView:E=!1,isPublic:g=!1,activeFileUid:C,documentType:f,noteContent:_})=>{const R=M=>M.replace(/<[^>]+>/g,"").replace(/&[^;]+;/g," ").trim(),w=(M=>{const U=M?R(M):"";if(!U)return{words:0,sentences:0,paragraphs:0,characters:0};const H=U.split(/\s+/).filter(Boolean).length,K=U.split(/[.!?]+(?:\s|$)/).filter(X=>X.trim().length>0).length,V=M?(M.match(/<p[^>]*>[\s\S]*?<\/p>/g)||[]).length||U.split(/\n\s*\n/).filter(Boolean).length:U.split(/\n\s*\n/).filter(Boolean).length,W=U.replace(/\s/g,"").length;return{words:H,sentences:K,paragraphs:V,characters:W}})(_),D=()=>{if(!C){v0.error("Document link not available");return}const U={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[f]||f,H=`${window.location.origin}/view/${U}/${C}`;navigator.clipboard.writeText(H),v0.success("Public share link copied to clipboard")};return O.jsx("div",{className:"flex items-center gap-1 sm:gap-2",children:O.jsxs(MO,{children:[O.jsx(yy,{render:O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground hover:bg-muted/80 hover:text-foreground hover:shadow-sm active:scale-95 transition-all duration-200",children:[O.jsx("span",{className:"hidden sm:inline mr-1.5 text-xs font-medium",children:"Actions"}),O.jsx(fO,{className:"h-4 w-4"})]})}),O.jsxs(xy,{align:"end",className:"w-56",children:[E?O.jsxs(Gl,{onClick:D,className:"gap-2 cursor-pointer",children:[O.jsx(Jle,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Copy Public Link"})]}):O.jsxs(O.Fragment,{children:[O.jsxs(Gl,{disabled:!u,onClick:s,className:"gap-2 cursor-pointer",children:[O.jsx(Zle,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Share"})]}),g&&O.jsxs(Gl,{disabled:!u,onClick:D,className:"gap-2 cursor-pointer",children:[O.jsx(Jle,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Copy Public Link"})]}),O.jsx(af,{}),O.jsxs(Gl,{disabled:!u,onClick:e,className:"gap-2 cursor-pointer",children:[f==="erd"?O.jsx(Jfe,{className:"h-4 w-4 text-muted-foreground"}):O.jsx(E1e,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:f==="erd"?"Settings":"Edit Document"})]}),O.jsx(af,{}),O.jsxs(Gl,{disabled:!u,onClick:t,className:"gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer",children:[O.jsx(F5,{className:"h-4 w-4"}),O.jsx("span",{children:"Move to Trash"})]})]}),(f==="notes"||f==="drawings")&&!E&&O.jsxs(O.Fragment,{children:[O.jsx(af,{}),O.jsxs(Gl,{disabled:!u,onClick:a,className:"gap-2 cursor-pointer",children:[O.jsx(SO,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Duplicate"})]})]}),f==="erd"&&!E&&O.jsxs(O.Fragment,{children:[O.jsx(af,{}),O.jsxs(Gl,{onClick:i,className:"gap-2 cursor-pointer",children:[O.jsx(AB,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Export All"})]})]}),f==="notes"&&!E&&O.jsxs(O.Fragment,{children:[O.jsx(af,{}),O.jsx(Gl,{disabled:!u,onClick:A,className:"gap-2 cursor-pointer flex items-center",children:O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(SO,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Copy Markdown"})]})}),O.jsxs(Gl,{disabled:!u,onClick:h,className:"gap-2 cursor-pointer flex items-center",children:[O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(Rj,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Import"})]}),O.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),O.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"I"})]})]}),O.jsxs(Gl,{disabled:!u,onClick:n,className:"gap-2 cursor-pointer flex items-center",children:[O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(AB,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Export"})]}),O.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),O.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"E"})]})]}),O.jsx(af,{}),O.jsxs($pr,{children:[O.jsxs(Jpr,{className:"gap-2 cursor-pointer",children:[O.jsx(n1e,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Text Stats"})]}),O.jsx(Xpr,{className:"w-52 p-1",children:O.jsxs("div",{className:"px-3 py-1.5 space-y-1",children:[O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Words"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.words.toLocaleString()})]}),O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Sentences"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.sentences.toLocaleString()})]}),O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Paragraphs"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.paragraphs.toLocaleString()})]}),O.jsx(af,{className:"my-1.5"}),O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Characters"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.characters.toLocaleString()})]})]})})]})]})]})]})})},Wzr=$s.memo(({featureLabel:s,activeProjectName:e,activeFileName:t,view:a,hasActiveItem:i,syncError:n,isSyncing:A,isRefreshing:h,isLocalSaving:u=!1,hasPendingSyncs:E,activeFileUid:g,activeFileId:C,initialShareSettings:f,onSettingsSaved:_,isPublicView:R=!1,isOnline:x,updatedAt:w,onDelete:D,onRename:M,onSave:U,onExportAll:H,onExportSQL:K,onExportPDF:V,onExportImage:W,onExportMarkdown:X,onCopyMarkdown:J,onImportMarkdown:Z,onDuplicate:j,isGuest:z=!1,breadcrumbLabel:q,noteContent:se})=>{const ie=V_(),[he,Ae]=$s.useState(!1),[Ee,le]=$s.useState(!1);return $s.useEffect(()=>{le(window.navigator.userAgent.toLowerCase().includes("mac"))},[]),O.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:[O.jsxs("div",{className:"flex items-center gap-2 px-4 min-w-0 flex-none",children:[!R&&O.jsxs(O.Fragment,{children:[O.jsx(opr,{className:"-ml-1 shrink-0"}),O.jsx(OK1,{orientation:"vertical",className:"h-4 shrink-0 bg-border/50"})]}),O.jsx(FK1,{className:"min-w-0 flex items-center",children:O.jsx(PK1,{className:"flex-nowrap items-center",children:!R&&(()=>{var me;const ue=ie.pathname;if(ue==="/")return O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-semibold text-foreground",children:"Dashboard"})});if(ue.startsWith("/table/")){const Be={notes:"Notes",erd:"ERD Builder",drawings:"Drawings",flowchart:"Flowcharts"},_e=(me=ue.match(/^\/table\/([^/]+)$/))==null?void 0:me[1],ve=_e?Be[_e]||_e:"Unknown";return O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-foreground",children:ve})})}if(ue.startsWith("/notes/")||ue.startsWith("/diagrams/")||ue.startsWith("/drawings/")||ue.startsWith("/flowcharts/")){const Be={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"}},_e=ue.split("/")[1],ve=Be[_e];return O.jsxs(O.Fragment,{children:[ve&&O.jsxs(O.Fragment,{children:[O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-muted-foreground",children:ve.label})}),e&&O.jsx(cLs,{className:"shrink-0"})]}),e&&O.jsxs(O.Fragment,{children:[O.jsx(pP,{className:"min-w-0 shrink",children:O.jsx(_V,{className:"max-w-[80px] sm:max-w-[150px] md:max-w-[250px] truncate text-muted-foreground",children:e})}),t&&O.jsx(cLs,{className:"shrink-0"})]}),t&&O.jsxs(pP,{className:"min-w-0 shrink flex items-center gap-2",children:[O.jsx(_V,{className:"max-w-[120px] sm:max-w-[200px] md:max-w-[300px] truncate font-semibold text-foreground",children:t}),(f==null?void 0:f.is_public)&&!R&&O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.jsxs(Gg,{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:[O.jsx(Vb,{className:"w-2.5 h-2.5"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Public"}),O.jsx("div",{className:"w-1 h-1 rounded-full bg-green-500 animate-pulse ml-0.5"})]})}),O.jsx(N_,{side:"bottom",align:"center",className:"text-[10px] font-medium",children:"This document is shared publicly via a secret link."})]})})]}),!t&&!e&&O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-foreground",children:(ve==null?void 0:ve.label)||"Document"})})]})}return ue.startsWith("/trash")?O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-foreground",children:"Trash"})}):q?O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-semibold text-foreground",children:q})}):O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-muted-foreground",children:s})})})()})})]}),O.jsx("div",{className:"flex-1 flex items-center justify-center px-2",children:!x&&!R?O.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:[O.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-destructive animate-pulse"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",children:"Offline Mode: Navigation Disabled"})]}):null}),O.jsx("div",{className:"px-2 sm:px-4 flex items-center gap-1 sm:gap-4",children:!!ie.pathname.match(/^\/(notes|diagrams|drawings|flowcharts)\/[^/]+$/)&&O.jsxs("div",{className:"flex items-center gap-1 sm:gap-4",children:[!R&&O.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 shrink-0",children:[u?O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.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:[O.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Saving..."})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium",children:"Saving changes locally..."})]})}):n?O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.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:[O.jsx(LUe,{className:"w-3.5 h-3.5"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Sync Failed"})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium max-w-[200px] text-center",children:"Changes saved locally, but cloud sync failed. We'll retry automatically."})]})}):A?O.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:[O.jsx(lae,{className:"w-3.5 h-3.5 animate-bounce"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Syncing..."})]}):E?O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.jsxs(D1,{variant:"ghost",size:"sm",onClick:U,disabled:!x,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:[O.jsx(qq,{className:"w-3.5 h-3.5 animate-in zoom-in-50"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Save"})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium",children:O.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[O.jsx("span",{children:"Save changes to cloud"}),O.jsxs("span",{className:"opacity-50 text-[9px]",children:[Ee?"⌘":"Ctrl"," + S"]})]})})]})}):O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.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:[O.jsx(l8,{className:"w-3.5 h-3.5"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Synced"})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium",children:"All changes are saved and synced"})]})}),h&&O.jsx("div",{className:"flex items-center gap-2 text-primary animate-pulse ml-1 sm:ml-2",children:O.jsx("div",{className:"w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin"})})]}),O.jsx(jzr,{onShare:()=>x&&Ae(!0),onDelete:D,onRename:M,onDuplicate:j,onExportAll:H,onExportSQL:K,onExportPDF:V,onExportImage:W,onExportMarkdown:X,onCopyMarkdown:J,onImportMarkdown:Z,isOnline:x,isPublicView:R,isPublic:f==null?void 0:f.is_public,activeFileUid:g,documentType:a,noteContent:se}),g&&C&&x&&O.jsx(Vzr,{isOpen:he,onOpenChange:Ae,documentType:a,documentUid:g,documentId:C,documentTitle:t||"Untitled",isPublicView:R,initialSettings:f,onSettingsSaved:_})]})})]})});function $zr({open:s,onOpenChange:e}){const[t,a]=$s.useState(!1),[i,n]=$s.useState(""),[A,h]=$s.useState("suggestion"),[u,E]=$s.useState(""),g=async C=>{if(C.preventDefault(),!!i.trim()){a(!0);try{if((await Ri("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,category:A,email:u,url:window.location.href,browser:navigator.userAgent})})).ok)v0.success("Feedback terkirim! Terima kasih masukannya."),e(!1),n("");else throw new Error}catch{v0.error("Gagal mengirim feedback. Coba lagi nanti.")}finally{a(!1)}}};return O.jsx(u5,{open:s,onOpenChange:C=>{e(C),C||n("")},children:O.jsx(b7,{className:"sm:max-w-[425px] border-border bg-popover/95 backdrop-blur-xl shadow-2xl",children:O.jsxs("form",{onSubmit:g,className:"flex flex-col max-h-[inherit]",children:[O.jsxs(q6,{children:[O.jsx(h5,{className:"text-xl font-bold",children:"Kirim Masukan"}),O.jsx(j_,{className:"text-sm text-muted-foreground",children:"Bantu kami membuat ERD Builder Pro jadi lebih baik. Saran Anda sangat berharga!"})]}),O.jsxs(Hd,{className:"space-y-5",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(Md,{htmlFor:"category",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Tipe Masukan"}),O.jsxs(Bf,{value:A,onValueChange:C=>C&&h(C),children:[O.jsx(uI,{id:"category",className:"bg-white/5 border-white/10 focus:ring-primary/50",children:O.jsx(Rf,{placeholder:"Pilih tipe",children:A==="suggestion"?"Saran Fitur":A==="bug"?"Lapor Bug":A==="other"?"Kritik / Lainnya":A})}),O.jsxs(Tf,{className:"bg-popover border-border text-popover-foreground",children:[O.jsx(g3,{value:"suggestion",className:"focus:bg-muted",children:"Saran Fitur"}),O.jsx(g3,{value:"bug",className:"focus:bg-muted text-destructive",children:"Lapor Bug"}),O.jsx(g3,{value:"other",className:"focus:bg-muted",children:"Kritik / Lainnya"})]})]})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsx(Md,{htmlFor:"content",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Pesan"}),O.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:C=>n(C.target.value),required:!0})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsx(Md,{htmlFor:"email",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email (Opsional)"}),O.jsx(DA,{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:u,onChange:C=>E(C.target.value)})]})]}),O.jsxs(ff,{className:"gap-3",children:[O.jsx(D1,{variant:"ghost",type:"button",onClick:()=>e(!1),className:"hover:bg-muted",children:"Batal"}),O.jsx(D1,{type:"submit",disabled:t,className:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-lg shadow-primary/20",children:t?"Mengirim...":"Kirim Masukan"})]})]})})})}const Jzr=({isOpen:s,onOpenChange:e,selectedEntity:t,deleteEntity:a,setSelectedNodeId:i})=>O.jsx(hH,{open:s,onOpenChange:e,children:O.jsxs(lH,{size:"sm",className:"max-w-[400px]",children:[O.jsxs(dH,{children:[O.jsx(hRe,{className:"bg-destructive/10",children:O.jsx(Jm,{className:"w-5 h-5 text-destructive"})}),O.jsx(CH,{children:"Delete Table"})]}),O.jsx(EH,{children:O.jsxs(S5e,{children:["Are you sure you want to delete the table ",O.jsx("strong",{children:t==null?void 0:t.name}),"? This action cannot be undone."]})}),O.jsxs(gH,{children:[O.jsx(eM,{onClick:()=>e(!1),children:"Cancel"}),O.jsx(nW,{onClick:()=>{t&&(a(t.id),i(null),e(!1))},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),efs=s=>s==="erd"?"diagram":s==="notes"?"note":s==="drawings"?"drawing":"flowchart",mC1=({isOpen:s,onOpenChange:e,mode:t="edit",view:a,activeDocument:i,newName:n,setNewName:A,projects:h,selectedProjectId:u,setSelectedProjectId:E,onCreate:g,updateDiagram:C,updateNote:f,updateDrawing:_,updateFlowchart:R,onMoveDiagramToProject:x,onMoveNoteToProject:w,onMoveDrawingToProject:D,onMoveFlowchartToProject:M,onRenameSuccess:U})=>{var V;const H=t==="create";ae.useEffect(()=>{if(s&&!H&&i){const W=(i==null?void 0:i.project_id)??(i==null?void 0:i.projectId);E(W!=null?String(W):"none")}},[s]);const K=async()=>{if(!n.trim())return;if(H){g==null||g(n.trim(),u==="none"?null:u),e(!1);return}const W=a==="notes"||a==="flowchart"||a==="drawings"?i==null?void 0:i.uid:i==null?void 0:i.id;if(W&&n.trim()){const X=u==="none"?null:u,J=(i==null?void 0:i.project_id)||(i==null?void 0:i.projectId),Z=n.trim()!==((i==null?void 0:i.title)||(i==null?void 0:i.name)),j=String(X)!==String(J);try{Z&&(a==="erd"?await(C==null?void 0:C(W,n,{silent:!0})):a==="notes"?await(f==null?void 0:f(String(W),n,{silent:!0})):a==="drawings"?await(_==null?void 0:_(W,n,{silent:!0})):a==="flowchart"&&await(R==null?void 0:R(W,n,{silent:!0}))),j&&(a==="erd"?await(x==null?void 0:x(W,X,{silent:!0})):a==="notes"?await(w==null?void 0:w(W,X,{silent:!0})):a==="drawings"?await(D==null?void 0:D(W,X,{silent:!0})):a==="flowchart"&&await(M==null?void 0:M(W,X,{silent:!0}))),(Z||j)&&U&&await U(),v0.success("Document updated successfully"),e(!1)}catch{v0.error("Failed to update document")}}};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsxs(q6,{children:[O.jsx(h5,{children:H?`Create ${efs(a)}`:"Edit Document"}),O.jsx(j_,{children:H?`Enter a name and select a workspace for your new ${efs(a)}.`:`Update the name and project for your ${efs(a)}.`})]}),O.jsx(Hd,{children:O.jsxs("div",{className:"space-y-4",children:[O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"rename-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:H?"Name":"New Name"}),O.jsx(DA,{id:"rename-input",type:"text",value:n,onChange:W=>A(W.target.value),onKeyDown:W=>{W.key==="Enter"&&n.trim()&&K()},autoFocus:!0})]}),O.jsxs(Il,{children:[O.jsx(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Project"}),O.jsxs(Bf,{value:u,onValueChange:W=>W!==null&&E(W),children:[O.jsx(uI,{className:"h-9",children:O.jsx(Rf,{children:u==="none"?"Uncategorized":((V=h.find(W=>W.id.toString()===u))==null?void 0:V.name)||"Select Project"})}),O.jsxs(Tf,{children:[O.jsx(g3,{value:"none",children:"Uncategorized"}),h.map(W=>O.jsx(g3,{value:W.id.toString(),children:W.name},W.id))]})]})]})]})}),O.jsxs(ff,{children:[O.jsx(cvt,{render:O.jsx(D1,{variant:"outline",className:"h-9"}),children:"Cancel"}),O.jsx(D1,{disabled:!n.trim(),onClick:K,className:"h-9 px-6",children:H?"Create":"Save Changes"})]})]})})},Xzr=({isOpen:s,onOpenChange:e,view:t,duplicateName:a,setDuplicateName:i,executeDuplicate:n,isRefreshing:A})=>O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsxs(q6,{children:[O.jsx(h5,{children:"Duplicate Document"}),O.jsxs(j_,{children:["Create a copy of this ",t==="erd"?"diagram":t==="notes"?"note":t==="drawings"?"drawing":"flowchart","."]})]}),O.jsx(Hd,{children:O.jsx("div",{className:"space-y-4",children:O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"duplicate-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"New Name"}),O.jsx(DA,{id:"duplicate-input",type:"text",value:a,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"&&a.trim()&&n()},autoFocus:!0})]})})}),O.jsxs(ff,{className:"gap-2 sm:gap-0",children:[O.jsx(D1,{variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),O.jsx(D1,{onClick:n,disabled:!a.trim()||A,children:A?O.jsxs(O.Fragment,{children:[O.jsx(Su,{className:"mr-2 h-4 w-4 animate-spin"}),"Duplicating..."]}):"Duplicate"})]})]})});function wb(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var tfs={exports:{}};/*!
8869
+ `);Be=Qe.pop()||"";for(const Ue of Qe)if(Ue.trim())try{const Fe=JSON.parse(Ue);if(Fe.type==="progress")M({current:Number(Fe.current)||0,total:Number(Fe.total)||5,phase:String(Fe.phase||"")});else if(Fe.type==="complete"){A("done"),v0.success(Fe.message||"Database restored successfully!"),t.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(Ae){if(Ae.name==="AbortError")return;A("error"),w(Ae.message||"Restore failed"),v0.error("Restore failed: "+(Ae.message||"Unknown error"))}t.current=null}},[]),W=ae.useCallback(()=>{e.current&&(clearTimeout(e.current),e.current=null),a.current=null,i.current=null,A("idle"),u(null),R(null),g(null),f(null),w(""),M({current:0,total:1,phase:""})},[]),X=ae.useCallback(()=>{a.current=null,i.current=null,g(null),f(null),A("idle"),u(null)},[]),J=ae.useCallback(()=>{e.current&&(clearTimeout(e.current),e.current=null),window.location.reload()},[]),Z=ae.useCallback(()=>{t.current&&(t.current.abort(),t.current=null),a.current=null,i.current=null,A("idle"),u(null),M({current:0,total:1,phase:""})},[]),j=ae.useCallback(()=>{h==="db"?V():K()},[h,V,K]),z=Math.min(Math.round(D.current/D.total*100),100),{accept:q,acceptLabel:se}=U==="desktop"?{accept:".json,.db,.sqlite,.sqlite3",acceptLabel:".json (data) or .db / .sqlite (database restore)"}:{accept:".json",acceptLabel:".json format from Guest Mode export"};if(n==="done")return O.jsxs("div",{className:"space-y-6",children:[O.jsxs("div",{className:"flex items-center gap-3 p-4 bg-emerald-500/10 border border-emerald-500/20 rounded-xl",children:[O.jsx(aq,{className:"size-6 text-emerald-500 shrink-0"}),O.jsxs("div",{children:[O.jsx("h4",{className:"font-semibold text-sm",children:h==="db"?"Database Restored":"Import Completed"}),O.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:h==="db"?"The database file has been restored. The app will reload to apply the changes.":"Data has been added to your workspace."})]})]}),_&&O.jsx(IC1,{summary:_}),O.jsxs("div",{className:"flex gap-3",children:[O.jsxs(D1,{variant:"default",size:"sm",onClick:J,children:[O.jsx(aB,{className:"size-3.5 mr-1.5"}),"Reload App Now"]}),O.jsx(D1,{variant:"outline",size:"sm",onClick:W,children:"Import Another File"})]}),O.jsx("p",{className:"text-xs text-muted-foreground",children:"App will reload automatically in a few seconds…"})]});if(n==="preview"){if(h==="db"&&C)return O.jsxs("div",{className:"space-y-5",children:[O.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[O.jsx(vUe,{className:"size-5 text-blue-500 shrink-0"}),O.jsxs("div",{children:[O.jsx("h4",{className:"font-semibold text-sm",children:"Restore Database File"}),O.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["This will ",O.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."]}),O.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",O.jsx("code",{className:"bg-muted px-1 rounded text-[11px] mx-0.5",children:".db"})," file that you saved manually."]})]})]}),O.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-4 space-y-2",children:[O.jsxs("div",{className:"flex items-center justify-between text-sm",children:[O.jsx("span",{className:"text-muted-foreground",children:"File"}),O.jsx("span",{className:"font-medium",children:C.fileName})]}),O.jsxs("div",{className:"flex items-center justify-between text-sm",children:[O.jsx("span",{className:"text-muted-foreground",children:"Size"}),O.jsx("span",{className:"font-medium",children:C.fileSize})]})]}),O.jsxs("div",{className:"flex gap-3 pt-2",children:[O.jsxs(D1,{variant:"default",size:"sm",onClick:j,children:[O.jsx(uae,{className:"size-3.5 mr-1.5"}),"Restore Database"]}),O.jsxs(D1,{variant:"outline",size:"sm",onClick:X,children:[O.jsx(Jb,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]});if(h==="json"&&E){const ie=Object.values(E).reduce((he,Ae)=>he+(Ae||0),0);return O.jsxs("div",{className:"space-y-5",children:[O.jsxs("div",{className:"flex items-center gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[O.jsx(bfe,{className:"size-5 text-blue-500 shrink-0"}),O.jsxs("div",{children:[O.jsx("h4",{className:"font-semibold text-sm",children:"Import Preview"}),O.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ie," items found in the export file. Click ",O.jsx("strong",{children:"Submit"})," to import the data."]})]})]}),O.jsx(IC1,{summary:E}),O.jsxs("div",{className:"flex gap-3 pt-2",children:[O.jsxs(D1,{variant:"default",size:"sm",onClick:j,children:[O.jsx(uae,{className:"size-3.5 mr-1.5"}),"Submit"]}),O.jsxs(D1,{variant:"outline",size:"sm",onClick:X,children:[O.jsx(Jb,{className:"size-3.5 mr-1.5"}),"Cancel"]})]})]})}}return n==="error"?O.jsx("div",{className:"space-y-5",children:O.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:[O.jsx($w,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),O.jsxs("div",{className:"text-xs text-red-600",children:[O.jsx("p",{className:"font-medium",children:h==="db"?"Database restore failed":"Import failed"}),O.jsx("p",{className:"mt-0.5",children:x}),O.jsx(D1,{variant:"ghost",size:"sm",className:"mt-2 h-auto py-1 text-xs",onClick:W,children:"Try again"})]})]})}):O.jsxs("div",{className:"space-y-5",children:[O.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl",children:[O.jsx(xb,{className:"size-5 text-blue-500 shrink-0 mt-0.5"}),O.jsxs("div",{className:"text-sm space-y-1",children:[O.jsx("p",{className:"font-medium",children:"Import Data"}),O.jsxs("p",{className:"text-xs text-muted-foreground",children:["Upload a ",O.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," file exported from Guest Mode. All data will be ",O.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."]}),O.jsx("p",{className:"text-xs text-muted-foreground",children:"Supports: Notes, ERD Diagrams (entities, columns, relationships), Flowcharts, Drawings, AI Chat sessions & messages, and Projects."}),U==="desktop"&&O.jsxs("p",{className:"text-xs text-muted-foreground mt-2 pt-2 border-t border-border/40",children:[O.jsx("strong",{className:"text-amber-500",children:"Desktop only:"})," You can also restore a",O.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."]})]})]}),O.jsxs("div",{onClick:()=>{var ie;n!=="importing"&&((ie=s.current)==null||ie.click())},onKeyDown:ie=>{var he;(ie.key==="Enter"||ie.key===" ")&&n!=="importing"&&((he=s.current)==null||he.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:[O.jsx("input",{ref:s,type:"file",accept:q,className:"hidden",onChange:H}),n==="importing"?O.jsxs("div",{className:"w-full max-w-sm mx-auto space-y-4",children:[O.jsxs("div",{className:"space-y-1.5",children:[O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground truncate mr-2",children:D.phase||"Importing…"}),O.jsxs("span",{className:"text-muted-foreground shrink-0 tabular-nums",children:[z,"%"]})]}),O.jsx("div",{className:"w-full h-2 bg-muted/50 rounded-full overflow-hidden",children:O.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-300 ease-out",style:{width:`${z}%`}})}),O.jsxs("p",{className:"text-[11px] text-muted-foreground tabular-nums",children:[D.current.toLocaleString()," / ",D.total.toLocaleString()," items"]})]}),O.jsx(D1,{variant:"ghost",size:"sm",onClick:ie=>{ie.stopPropagation(),Z()},className:"text-xs",children:"Cancel"})]}):O.jsxs("div",{className:"flex flex-col items-center gap-3",children:[O.jsx("div",{className:"p-3 bg-muted/30 rounded-full",children:O.jsx(Rj,{className:"size-6 text-muted-foreground"})}),O.jsxs("div",{children:[O.jsx("p",{className:"text-sm font-medium",children:"Click to select a file"}),O.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:se})]})]})]})]})}function IC1({summary:s}){return O.jsxs("div",{className:"space-y-3",children:[O.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:[O.jsx(vX,{label:"Projects",value:s.projects}),O.jsx(vX,{label:"Notes",value:s.notes}),O.jsx(vX,{label:"ERD Diagrams",value:s.diagrams}),O.jsx(vX,{label:"Tables (Entities)",value:s.entities}),O.jsx(vX,{label:"Columns",value:s.columns}),O.jsx(vX,{label:"Relationships",value:s.relationships}),O.jsx(vX,{label:"Flowcharts",value:s.flowcharts}),O.jsx(vX,{label:"Drawings",value:s.drawings}),O.jsx(vX,{label:"AI Sessions",value:s.ai_chat_sessions})]}),s.ai_chat_messages>0&&O.jsxs("p",{className:"text-[11px] text-muted-foreground px-0.5",children:["Includes ",s.ai_chat_messages.toLocaleString()," AI chat messages."]}),s.skipped_existing>0&&O.jsxs("p",{className:"text-[11px] text-amber-500 px-0.5",children:[s.skipped_existing.toLocaleString()," item(s) already existed and were skipped."]})]})}function vX({label:s,value:e}){return O.jsxs("div",{className:"bg-muted/20 border border-border/40 rounded-lg p-3 text-center",children:[O.jsx("p",{className:"text-lg font-bold",children:e.toLocaleString()}),O.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:s})]})}function czr(){return sessionStorage.getItem("auth_mode")==="guest"}function Azr(s){if(!s||typeof s!="string")return null;try{const e=JSON.parse(s);return(e==null?void 0:e.dbml_source)??(e==null?void 0:e.dbmlSource)??null}catch{return null}}function ozr(s){const e=s.dbml_source??s.dbmlSource??Azr(s.data);return{...s,dbml_source:e??null,dbmlSource:e??null}}async function Tpe(s){try{return(await pi.getAllResources(s)||[]).filter(t=>!t.is_deleted)}catch{return[]}}function uzr(s){return!s.messages||!Array.isArray(s.messages)?[]:s.messages.map(e=>({id:e.id||e.uid,role:e.role,content:e.content,selection_text:e.selection_text||null,created_at:e.created_at||null}))}async function hzr(){if(!czr()){const u=await Ri("/api/guest/export");if(!u.ok){const E=await u.json().catch(()=>({}));throw new Error(E.error||"Failed to export data")}return u.json()}const[s,e,t,a,i,n]=await Promise.all([Tpe("project"),Tpe("notes"),Tpe("erd"),Tpe("flowchart"),Tpe("drawings"),Tpe("ai_chat_session")]),A=n.map(u=>({uid:u.uid||u.id,title:u.title||"Untitled",entity_type:u.entity_type||null,entity_uid:u.entity_uid||null,project_id:u.project_id??null,created_at:u.created_at||null,updated_at:u.updated_at||null,messages:uzr(u)})),h={projects:s.length,notes:e.length,diagrams:t.length,flowcharts:a.length,drawings:i.length,ai_chat_sessions:A.length};return{version:"1.0",exported_at:new Date().toISOString(),application:"ERD Builder Pro",total_items:h,data:{projects:s,notes:e,diagrams:t.map(ozr),flowcharts:a,drawings:i,ai_chat_sessions:A}}}function lzr(s){const e=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),t=URL.createObjectURL(e),a=document.createElement("a");a.href=t,a.download=`erd-data-export-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(t)}async function Fua(){const s=await hzr();lzr(s)}function dzr(){const[s,e]=ae.useState(!1),t=async()=>{e(!0);try{await Fua(),v0.success("Data exported successfully")}catch(a){v0.error("Export failed: "+(a.message||"Unknown error"))}finally{e(!1)}};return O.jsxs("div",{className:"space-y-4",children:[O.jsxs("div",{children:[O.jsx("h2",{className:"text-lg font-semibold",children:"Export Data"}),O.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Download projects, notes, ERDs, DBML, flowcharts, drawings, and AI chats as JSON."})]}),O.jsx("div",{className:"rounded-xl border border-border/40 bg-muted/10 p-5 max-w-xl",children:O.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[O.jsxs("div",{children:[O.jsx("h3",{className:"text-sm font-semibold",children:"JSON Backup"}),O.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Use this file with Import Data to restore or migrate your workspace data."})]}),O.jsxs(D1,{onClick:t,disabled:s,className:"shrink-0",children:[s?O.jsx(Su,{className:"size-3.5 mr-2 animate-spin"}):O.jsx(AB,{className:"size-3.5 mr-2"}),s?"Exporting...":"Export JSON"]})]})})]})}function Ezr(){if(!(typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli")))return O.jsx("div",{className:"p-4 md:p-8",children:O.jsx(Xb,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:O.jsxs(zq,{className:"py-12 text-center",children:[O.jsx(xb,{className:"w-8 h-8 mx-auto text-muted-foreground/40"}),O.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Storage configuration is only available in the desktop app or CLI mode."})]})})});const[e,t]=ae.useState({type:"r2",accountId:"",endpoint:"",region:"auto",accessKeyId:"",secretAccessKey:"",bucketName:"",publicUrl:""}),[a,i]=ae.useState(null),[n,A]=ae.useState("none"),[h,u]=ae.useState(!0),[E,g]=ae.useState(!1),[C,f]=ae.useState(!1),[_,R]=ae.useState({type:"",message:""}),[x,w]=ae.useState(!1),[D,M]=ae.useState(!1),U=ae.useCallback(async()=>{u(!0);try{const X=await Ri("/api/storage/config",{credentials:"include"});if(X.ok){const J=await X.json();A(J.source),J.config&&(i(J.config),t({type:J.config.type||"r2",accountId:J.config.accountId||"",endpoint:J.config.endpoint||"",region:J.config.region||"auto",accessKeyId:J.config.accessKeyId||"",secretAccessKey:J.config.secretAccessKey||"",bucketName:J.config.bucketName||"",publicUrl:J.config.publicUrl||""}))}}catch(X){console.error("Failed to load storage config:",X)}finally{u(!1)}},[]);ae.useEffect(()=>{U()},[U]);const H=async()=>{g(!0),R({type:"",message:""});try{const X=await Ri("/api/storage/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"});if(X.ok)R({type:"success",message:"Storage configuration saved successfully."}),i({...e}),await U();else{const J=await X.json();R({type:"error",message:J.error||"Failed to save configuration"})}}catch(X){R({type:"error",message:X.message||"Network error"})}finally{g(!1)}},K=async()=>{f(!0),R({type:"",message:""});try{const X=await Ri("/api/storage/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"});if(X.ok)R({type:"success",message:"Successfully connected to storage."});else{const J=await X.json();R({type:"error",message:J.error||"Connection failed"})}}catch(X){R({type:"error",message:X.message||"Network error"})}finally{f(!1)}},V=(X,J)=>{t(Z=>({...Z,[X]:J})),R({type:"",message:""})};if(h)return O.jsx("div",{className:"p-4 md:p-8",children:O.jsx(Xb,{className:"border-border/50 bg-background/50 backdrop-blur-sm",children:O.jsxs(zq,{className:"py-12 text-center",children:[O.jsx(aB,{className:"w-6 h-6 animate-spin mx-auto text-muted-foreground"}),O.jsx("p",{className:"text-muted-foreground mt-4 text-sm",children:"Loading storage configuration..."})]})})});const W=n==="env";return O.jsx("div",{className:"p-6 space-y-6",children:O.jsxs(Xb,{className:"border border-border/50 bg-background/50 backdrop-blur-sm shadow-lg",children:[O.jsxs(bVe,{className:"border-b border-border/30 pb-6",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsx(lae,{className:"w-6 h-6 text-blue-500"}),O.jsx(MVe,{className:"text-xl md:text-2xl font-bold",children:"Storage Configuration"})]}),O.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."})]}),O.jsxs(zq,{className:"space-y-6 p-4 md:p-6",children:[W&&O.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-blue-500/10 border border-blue-500/20",children:[O.jsx(jb,{className:"w-4 h-4 text-blue-500 shrink-0"}),O.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400",children:"Pre-filled from environment variables. Save to override with custom settings."})]}),_.type&&O.jsxs("div",{className:`flex items-center gap-3 p-4 rounded-lg border ${_.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:[_.type==="success"?O.jsx(cb,{className:"w-5 h-5 shrink-0"}):O.jsx(KV,{className:"w-5 h-5 shrink-0"}),O.jsx("p",{className:"text-sm",children:_.message})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(xb,{className:"size-3"}),"Storage Provider"]}),O.jsxs(Bf,{value:e.type,onValueChange:(X,J)=>X&&V("type",X),children:[O.jsx(uI,{className:"h-9 text-sm",children:O.jsx(Rf,{children:e.type==="r2"?O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(lae,{className:"w-4 h-4"}),"Cloudflare R2"]}):O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(xb,{className:"w-4 h-4"}),"S3-Compatible"]})})}),O.jsxs(Tf,{children:[O.jsx(g3,{value:"r2",children:O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(lae,{className:"w-4 h-4"}),"Cloudflare R2"]})}),O.jsx(g3,{value:"s3-compatible",children:O.jsxs("span",{className:"flex items-center gap-2",children:[O.jsx(xb,{className:"w-4 h-4"}),"S3-Compatible"]})})]})]})]}),e.type==="r2"&&O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Vb,{className:"size-3"}),"Account ID"]}),O.jsx(DA,{placeholder:"Your Cloudflare R2 Account ID",value:e.accountId||"",onChange:X=>V("accountId",X.target.value),className:"h-9 text-sm font-mono"}),O.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:"Found in your Cloudflare dashboard under R2 → Account ID."})]}),e.type==="s3-compatible"&&O.jsxs(O.Fragment,{children:[O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Vb,{className:"size-3"}),"Endpoint URL"]}),O.jsx(DA,{placeholder:"https://s3.us-east-1.amazonaws.com",value:e.endpoint||"",onChange:X=>V("endpoint",X.target.value),className:"h-9 text-sm font-mono"})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Vb,{className:"size-3"}),"Region"]}),O.jsx(DA,{placeholder:"us-east-1",value:e.region||"",onChange:X=>V("region",X.target.value),className:"h-9 text-sm font-mono"})]})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Hfe,{className:"size-3"}),"Access Key ID"]}),O.jsxs("div",{className:"relative",children:[O.jsx(DA,{type:D?"text":"password",placeholder:"Your access key ID",value:e.accessKeyId,onChange:X=>V("accessKeyId",X.target.value),className:"h-9 text-sm font-mono pr-10"}),O.jsx("button",{type:"button",onClick:()=>M(!D),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:D?O.jsx(mj,{className:"w-4 h-4"}):O.jsx(Xq,{className:"w-4 h-4"})})]})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Hfe,{className:"size-3"}),"Secret Access Key"]}),O.jsxs("div",{className:"relative",children:[O.jsx(DA,{type:x?"text":"password",placeholder:"Your secret access key",value:e.secretAccessKey,onChange:X=>V("secretAccessKey",X.target.value),className:"h-9 text-sm font-mono pr-10"}),O.jsx("button",{type:"button",onClick:()=>w(!x),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",children:x?O.jsx(mj,{className:"w-4 h-4"}):O.jsx(Xq,{className:"w-4 h-4"})})]})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Ufe,{className:"size-3"}),"Bucket Name"]}),O.jsx(DA,{placeholder:"your-bucket-name",value:e.bucketName,onChange:X=>V("bucketName",X.target.value),className:"h-9 text-sm font-mono"})]}),O.jsxs(Il,{children:[O.jsxs(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 flex items-center gap-2 px-1",children:[O.jsx(Yfe,{className:"size-3"}),"Public URL (optional)"]}),O.jsx(DA,{placeholder:"https://cdn.yourdomain.com",value:e.publicUrl||"",onChange:X=>V("publicUrl",X.target.value),className:"h-9 text-sm font-mono"}),O.jsx("p",{className:"text-[11px] text-muted-foreground/70 mt-1 px-1",children:e.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."})]})]}),O.jsxs(Ame,{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:[O.jsx("button",{type:"button",onClick:K,disabled:C||!e.bucketName||!e.accessKeyId||!e.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:C?O.jsxs(O.Fragment,{children:[O.jsx(aB,{className:"w-4 h-4 shrink-0 animate-spin pointer-events-none"}),O.jsx("span",{className:"pointer-events-none",children:"Testing..."})]}):O.jsxs(O.Fragment,{children:[O.jsx(aB,{className:"w-4 h-4 shrink-0 pointer-events-none"}),O.jsx("span",{className:"pointer-events-none",children:"Test Connection"})]})}),O.jsxs(D1,{onClick:H,className:"gap-2 px-6",disabled:E,children:[E?O.jsx(aB,{className:"w-4 h-4 animate-spin"}):O.jsx(qq,{className:"w-4 h-4"}),E?"Saving...":"Save Configuration"]})]})]})})}function gzr(){const{isSettingsOpen:s,setIsSettingsOpen:e,settingsTab:t,setSettingsTab:a}=AC(),i=typeof window<"u"&&(!!(window.__TAURI__||window.__TAURI_INTERNALS__)||window.ERD_INSTALL_MODE==="cli"),[n,A]=$s.useState("configuration"),{providers:h,configs:u,isTesting:E,isSaving:g,handleSaveConfig:C,handleTestConnection:f,updateProviderLocal:_,updateConfigLocal:R}=TGr(),{isGuest:x}=DM(),{models:w,newModel:D,editingModelId:M,isSaving:U,setNewModel:H,handleAddModel:K,handleDeleteModel:V,ensureModel:W,startEditingModel:X,cancelEdit:J,refresh:Z}=yGr(),{prompts:j,isSaving:z,handleSavePrompt:q,handleDeletePrompt:se,togglePromptDefault:ie}=xGr(),he=$s.useMemo(()=>x?[{label:"General",items:[{id:"appearance",label:"Appearance",icon:O.jsx(zle,{className:"size-4"})}]},{label:"More",items:[{id:"export-data",label:"Export Data",icon:O.jsx(AB,{className:"size-4"})},{id:"changelog",label:"What's New",icon:O.jsx($le,{className:"size-4"})}]}]:[{label:"General",items:[{id:"account",label:"Account",icon:O.jsx(Tj,{className:"size-4"})},{id:"appearance",label:"Appearance",icon:O.jsx(zle,{className:"size-4"})},...i?[{id:"storage",label:"Storage",icon:O.jsx(xb,{className:"size-4"})}]:[]]},{label:"Feature",items:[{id:"ai-config",label:"AI Configuration",icon:O.jsx(ry,{className:"size-4"})},{id:"ai-rules",label:"AI Rules",icon:O.jsx(VUe,{className:"size-4"})},{id:"ai-prompts",label:"System Prompts",icon:O.jsx(Nfe,{className:"size-4"})}]},{label:"More",items:[{id:"export-data",label:"Export Data",icon:O.jsx(AB,{className:"size-4"})},{id:"import-data",label:"Import Data",icon:O.jsx(Rj,{className:"size-4"})},{id:"backups",label:"Database Backup",icon:O.jsx(M3,{className:"size-4"})},{id:"changelog",label:"What's New",icon:O.jsx($le,{className:"size-4"})}]}],[x]),Ae=he.flatMap(le=>le.items),Ee=le=>{var ue;return((ue=Ae.find(me=>me.id===le))==null?void 0:ue.label)||""};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{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:[O.jsx(h5,{className:"sr-only",children:"Settings"}),O.jsx(j_,{className:"sr-only",children:"Manage your application settings and AI configuration."}),O.jsxs(DK1,{className:"items-start min-h-0! h-full",children:[O.jsx(kK1,{collapsible:"none",className:"w-55 border-r border-border/40 bg-muted/5 hidden md:flex h-full",children:O.jsxs(MK1,{className:"pt-4 px-2 pb-0",children:[O.jsx("div",{className:"px-4 py-2 mb-2",children:O.jsxs("h2",{className:"text-sm font-bold flex items-center gap-2",children:[O.jsx(pae,{className:"size-4"}),"Settings"]})}),he.map(le=>O.jsxs(UOt,{className:"py-1",children:[O.jsx(rLs,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-4 mb-0.5",children:le.label}),O.jsx(nLs,{children:O.jsx(jVe,{children:le.items.map(ue=>O.jsx(lme,{children:O.jsxs($ae,{isActive:t===ue.id,onClick:()=>a(ue.id),className:`transition-all duration-200 px-4 py-2 rounded-md ${t===ue.id?"bg-sidebar-accent text-sidebar-accent-foreground font-medium":"text-muted-foreground hover:bg-sidebar-accent/50"}`,children:[ue.icon,O.jsx("span",{className:"text-xs",children:ue.label})]})},ue.id))})})]},le.label))]})}),O.jsxs("main",{className:"flex-1 flex flex-col h-150 overflow-hidden",children:[O.jsx("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b border-border/40 px-6 backdrop-blur-sm",children:O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(FK1,{className:"hidden md:flex",children:O.jsxs(PK1,{children:[O.jsx(pP,{children:O.jsx(Ipr,{href:"#",className:"text-[11px] text-muted-foreground",children:"Settings"})}),O.jsx(cLs,{}),O.jsx(pP,{children:O.jsx(_V,{className:"text-[11px] font-semibold",children:Ee(t)})})]})}),O.jsx("div",{className:"md:hidden",children:O.jsxs(MO,{children:[O.jsx(yy,{render:O.jsxs(D1,{variant:"ghost",size:"sm",className:"-ml-2 h-8 gap-2 text-xs font-semibold",children:[O.jsx(pae,{className:"size-3.5"}),Ee(t),O.jsx(Iy,{className:"size-3 opacity-50"})]})}),O.jsx(xy,{align:"start",className:"w-56",children:he.map(le=>O.jsxs(HIe,{children:[O.jsx(wPs,{className:"text-[10px] uppercase tracking-widest text-muted-foreground/60 px-2 py-1.5",children:le.label}),le.items.map(ue=>O.jsxs(Gl,{onClick:()=>a(ue.id),className:t===ue.id?"bg-accent":"",children:[ue.icon,O.jsx("span",{className:"ml-2",children:ue.label})]},ue.id)),O.jsx(af,{})]},le.label))})]})})]})}),O.jsxs("div",{className:"flex-1 overflow-y-auto custom-scrollbar",children:[t==="ai-config"&&O.jsxs("div",{className:"p-4 md:p-6",children:[O.jsxs("div",{className:"flex gap-1 bg-muted border border-border rounded-lg p-1 w-full mb-4",children:[O.jsxs("button",{onClick:()=>A("configuration"),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${n==="configuration"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[O.jsx(pae,{className:"w-3.5 h-3.5"}),"Configuration"]}),O.jsxs("button",{onClick:()=>A("models"),className:`flex-1 flex items-center justify-center gap-1.5 px-3.5 py-2 rounded-md text-xs font-semibold transition-all ${n==="models"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[O.jsx(Nfe,{className:"w-3.5 h-3.5"}),"AI Models"]})]}),n==="configuration"&&O.jsx(OGr,{providers:h,configs:u,models:w,isSaving:g,isTesting:E,onSave:C,onTest:le=>f(le,Object.values(w).flat()),onUpdateProvider:_,onUpdateConfig:R,onEnsureModel:W,onRefreshModels:Z}),n==="models"&&O.jsx(gYr,{providers:h,models:Object.values(w).flat(),newModel:D,editingModelId:M,isSaving:U,onSetNewModel:H,onAddModel:K,onEditModel:X,onDeleteModel:V,onCancelEdit:J})]}),t==="ai-prompts"&&O.jsx(BYr,{prompts:j,isSaving:z,onSave:q,onDelete:se,onToggleDefault:ie}),t==="ai-rules"&&O.jsx(yYr,{}),t==="backups"&&O.jsx("div",{className:"p-6 space-y-6",children:O.jsx(sVr,{})}),t==="account"&&O.jsx(xYr,{}),t==="changelog"&&O.jsx("div",{className:"p-6 space-y-6",children:O.jsx(szr,{})}),t==="export-data"&&O.jsx("div",{className:"p-4 md:p-6 overflow-y-auto h-full",children:O.jsx(dzr,{})}),t==="import-data"&&O.jsxs("div",{className:"p-4 md:p-6 overflow-y-auto h-full",children:[O.jsxs("div",{className:"mb-6",children:[O.jsx("h2",{className:"text-lg font-semibold",children:"Import Data"}),O.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."})]}),O.jsx(nzr,{})]}),t==="appearance"&&O.jsx(LYr,{}),t==="storage"&&O.jsx(Ezr,{})]})]})]})]})})}async function Czr(){try{const{getVersion:s}=await tr(async()=>{const{getVersion:e}=await Promise.resolve().then(()=>i5a);return{getVersion:e}},void 0);return await s()}catch{return"0.0.0"}}function Pua({open:s,onOpenChange:e,hasUpdate:t=!1,latestVersion:a=null,isChecking:i=!1,isDownloading:n=!1,onCheckUpdate:A,onDownload:h}){const u=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__),[E,g]=ae.useState("..."),[C,f]=ae.useState(!1),[_,R]=ae.useState(null),[x,w]=ae.useState(!1),[D,M]=ae.useState(!1),[U,H]=ae.useState(null),K=t||C,V=a||_,W=i||x,X=n||D;ae.useEffect(()=>{u?Czr().then(g):g("3.1.4")},[u]),ae.useEffect(()=>{if(!s||!u||t||i||n)return;if(A){A();return}if(h)return;w(!0);let j=!1;return(async()=>{try{const{check:q}=await tr(async()=>{const{check:ie}=await Promise.resolve().then(()=>Nd1);return{check:ie}},void 0),se=await q();if(j)return;se?(f(!0),R(se.version),H(se)):(f(!1),R(null),H(null))}catch{}finally{j||w(!1)}})(),()=>{j=!0}},[s,u]);const J=ae.useCallback(()=>{if(h)h();else if(U){if(D)return;M(!0),U.downloadAndInstall(()=>{}).catch(j=>{const z=typeof j=="string"?j:j!=null&&j.message?j.message:JSON.stringify(j);v0.error("Update failed",{description:z||"An error occurred while downloading the update.",duration:12e3,action:{label:"Copy Error",onClick:()=>navigator.clipboard.writeText(z).catch(()=>{})}})}).finally(()=>M(!1))}},[h,U,D]),Z=ae.useCallback(()=>{if(X)return;if(A){A();return}w(!0),f(!1),R(null),(async()=>{try{const{check:z}=await tr(async()=>{const{check:se}=await Promise.resolve().then(()=>Nd1);return{check:se}},void 0),q=await z();q?(f(!0),R(q.version),H(q)):(f(!1),R(null),H(null))}catch{}finally{w(!1)}})()},[A,X]);return ae.useEffect(()=>{s||(f(!1),R(null),w(!1),H(null))},[s]),O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"max-w-sm bg-background border-border/40 shadow-2xl",children:[O.jsx(h5,{className:"sr-only",children:"About ERD Builder Pro"}),O.jsx(j_,{className:"sr-only",children:"Application information and credits."}),O.jsxs("div",{className:"flex flex-col items-center py-6 gap-4",children:[O.jsx("div",{className:"flex items-center justify-center",children:O.jsx("img",{src:"/favicon.svg",alt:"ERD Builder Pro",className:"size-14"})}),O.jsxs("div",{className:"text-center",children:[O.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"ERD Builder Pro"}),O.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Version ",E]})]}),O.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."}),u&&O.jsxs("div",{className:"w-full",children:[O.jsx("div",{className:"w-full border-t border-border/40 mb-3"}),W?O.jsxs("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground py-1",children:[O.jsx(Su,{className:"size-3.5 animate-spin"}),"Checking for updates..."]}):K&&V?O.jsxs("div",{className:"flex flex-col items-center gap-2",children:[O.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-500",children:[O.jsx(AB,{className:"size-3.5"}),O.jsxs("span",{children:["Update ",O.jsxs("strong",{children:["v",V]})," available"]})]}),O.jsxs(D1,{variant:"default",size:"sm",className:"h-8 text-xs gap-1.5",onClick:J,disabled:X,children:[X?O.jsx(Su,{className:"size-3.5 animate-spin"}):O.jsx(AB,{className:"size-3.5"}),X?"Downloading...":"Download Update"]})]}):O.jsxs("div",{className:"flex flex-col items-center gap-2",children:[O.jsxs("div",{className:"flex items-center gap-2 text-xs text-emerald-500",children:[O.jsx(cb,{className:"size-3.5"}),O.jsx("span",{children:"You're up to date"})]}),O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:Z,children:[O.jsx(aB,{className:"size-3"}),"Check Again"]})]})]}),O.jsx("div",{className:"w-full border-t border-border/40"}),O.jsxs("div",{className:"text-[10px] text-center text-muted-foreground/60 leading-relaxed",children:[O.jsx("p",{children:"Built with React, Tauri, Express & Prisma."}),O.jsxs("p",{className:"mt-0.5",children:["© ",new Date().getFullYear()," Bekenweb."]})]}),O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-muted-foreground hover:text-foreground",onClick:()=>{Yvs("https://github.com/hadziqmtqn/erd-builder-pro")},children:[O.jsx(Eae,{className:"size-3"}),"GitHub"]}),O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-7 text-[11px] gap-1 text-rose-500 hover:text-rose-600",onClick:()=>{Yvs("https://trakteer.id/khadziq_muttaqin/tip")},children:[O.jsx(HUe,{className:"size-3"}),"Support"]})]})]})]})})}function pzr(s){const[e,t]=ae.useState(!1),[a,i]=ae.useState(null),[n,A]=ae.useState(!1),[h,u]=ae.useState(null),{setViewport:E,fitView:g}=dre();return{isPublicView:e,setIsPublicView:t,publicData:a,isPublicLoading:n,forbiddenDoc:h,fetchPublicDocument:async(f,_,R,x,w)=>{A(!0),u(null);try{const D=f==="erd"?"files":f==="flowchart"?"flowcharts":f,M={"Content-Type":"application/json"};w&&(M["x-share-token"]=w);const U=await Ri(`/api/${D}/public/${_}`,{headers:M,credentials:"include"});if(!U.ok){let V="Document not found or access denied",W="Access Denied";try{V=(await U.json()).error||V,U.status===404?W="Not Found":(U.status===401||U.status===403)&&(W="Access Denied")}catch{}if(U.status===401||U.status===403||U.status===404)return u({title:W,message:V,status:U.status}),!1;throw new Error(V)}const H=U.headers.get("content-type");if(!H||!H.includes("application/json"))throw new Error("Received invalid response from server");const K=await U.json();if(i(K),s(f),f==="erd"){const V=K.entities.map(J=>({id:J.id,type:"entity",position:{x:J.x,y:J.y},data:J})),W=K.relationships.map(J=>{const Z=K.entities.find(he=>String(he.id)===String(J.source_entity_id)),j=K.entities.find(he=>String(he.id)===String(J.target_entity_id));let z=J.source_handle,q=J.target_handle;if(Z&&j){const he=Number(Z.x)||0,Ae=Number(j.x)||0,Ee=(J.source_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,""),le=(J.target_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,"");Ee&&(z=he<Ae?`col-${Ee}-source`:`col-${Ee}-source-l`),le&&(q=he<Ae?`col-${le}-target`:`col-${le}-target-r`)}const se=(J.source_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,""),ie=(J.target_column_id||"").replace(/^col-/,"").replace(/-(source|target)(-(l|r))?$/,"");return{id:J.id,source:J.source_entity_id,target:J.target_entity_id,sourceHandle:z||(se?`col-${se}-source`:void 0),targetHandle:q||(ie?`col-${ie}-target`:void 0),label:J.label,type:"smoothstep",animated:!0}});R(V),x(W);const X=(J=0)=>{K.viewport_x!==void 0&&(K.viewport_x!==0||K.viewport_y!==0)?E({x:K.viewport_x,y:K.viewport_y,zoom:K.viewport_zoom||1},{duration:J}):V.length>0&&g({padding:.2,duration:J})};setTimeout(()=>X(0),50),setTimeout(()=>X(0),300)}else if(f==="flowchart")try{const V=typeof K.data=="string"?JSON.parse(K.data):K.data;R(V.nodes||[]),x(V.edges||[]);const W=(X=0)=>{var J;K.viewport_x!==void 0&&(K.viewport_x!==0||K.viewport_y!==0)?E({x:K.viewport_x,y:K.viewport_y,zoom:K.viewport_zoom||1},{duration:X}):((J=V.nodes)==null?void 0:J.length)>0&&g({padding:.2,duration:X})};setTimeout(()=>W(0),50),setTimeout(()=>W(0),300)}catch(V){console.error("Failed to parse flowchart data:",V)}else R([]),x([]);return!0}catch(D){return v0.error(D.message||"Failed to load shared document"),setTimeout(()=>window.location.href="/",3e3),!1}finally{A(!1)}}}}function Izr(s){const{open:e,defaultOpen:t,onOpenChange:a,disabled:i}=s,n=e!==void 0,[A,h]=U7e({controlled:e,default:t,name:"Collapsible",state:"open"}),{mounted:u,setMounted:E,transitionStatus:g}=pre(A,!0,!0),[C,f]=ae.useState(A),[{height:_,width:R},x]=ae.useState({height:void 0,width:void 0}),w=pB(),[D,M]=ae.useState(),U=D??w,[H,K]=ae.useState(!1),[V,W]=ae.useState(!1),X=ae.useRef(null),J=ae.useRef(null),Z=ae.useRef(null),j=ae.useRef(null),z=bYt(j,!1),q=Dn(se=>{const ie=!A,he=yA(Fj,se.nativeEvent);if(a(ie,he),he.isCanceled)return;const Ae=j.current;J.current==="css-animation"&&Ae!=null&&Ae.style.removeProperty("animation-name"),!H&&!V&&(J.current!=null&&J.current!=="css-animation"&&!u&&ie&&E(!0),J.current==="css-animation"&&(!C&&ie&&f(!0),!u&&ie&&E(!0))),h(ie),J.current==="none"&&u&&!ie&&E(!1)});return Xr(()=>{n&&J.current==="none"&&!V&&!A&&E(!1)},[n,V,A,e,E]),ae.useMemo(()=>({abortControllerRef:X,animationTypeRef:J,disabled:i,handleTrigger:q,height:_,mounted:u,open:A,panelId:U,panelRef:j,runOnceAnimationsFinish:z,setDimensions:x,setHiddenUntilFound:K,setKeepMounted:W,setMounted:E,setOpen:h,setPanelIdState:M,setVisible:f,transitionDimensionRef:Z,transitionStatus:g,visible:C,width:R}),[X,J,i,q,_,u,A,U,j,z,x,K,W,E,h,f,Z,g,C,R])}const Hua=ae.createContext(void 0);function Gua(){const s=ae.useContext(Hua);if(s===void 0)throw new Error($l(15));return s}let wFe=(function(s){return s.open="data-open",s.closed="data-closed",s[s.startingStyle=pz.startingStyle]="startingStyle",s[s.endingStyle=pz.endingStyle]="endingStyle",s})({}),fzr=(function(s){return s.panelOpen="data-panel-open",s})({});const _zr={[wFe.open]:""},mzr={[wFe.closed]:""},Bzr={open(s){return s?{[fzr.panelOpen]:""}:null}},Rzr={open(s){return s?_zr:mzr}},Yua={...Rzr,...NM},Tzr=ae.forwardRef(function(e,t){const{render:a,className:i,defaultOpen:n=!1,disabled:A=!1,onOpenChange:h,open:u,...E}=e,g=Dn(h),C=Izr({open:u,defaultOpen:n,onOpenChange:g,disabled:A}),f=ae.useMemo(()=>({open:C.open,disabled:C.disabled,transitionStatus:C.transitionStatus}),[C.open,C.disabled,C.transitionStatus]),_=ae.useMemo(()=>({...C,onOpenChange:g,state:f}),[C,g,f]),R=IA("div",e,{state:f,ref:t,props:E,stateAttributesMapping:Yua});return O.jsx(Hua.Provider,{value:_,children:R})}),yzr={...Bzr,...NM},xzr=ae.forwardRef(function(e,t){const{panelId:a,open:i,handleTrigger:n,state:A,disabled:h}=Gua(),{className:u,disabled:E=h,id:g,render:C,nativeButton:f=!0,..._}=e,{getButtonProps:R,buttonRef:x}=cG({disabled:E,focusableWhenDisabled:!0,native:f}),w=ae.useMemo(()=>({"aria-controls":i?a:void 0,"aria-expanded":i,onClick:n}),[a,i,n]);return IA("button",e,{state:A,ref:[t,x],props:[w,_,R],stateAttributesMapping:yzr})});let Ozr=(function(s){return s.disabled="data-disabled",s.orientation="data-orientation",s})({});function Szr(s){const{abortControllerRef:e,animationTypeRef:t,externalRef:a,height:i,hiddenUntilFound:n,keepMounted:A,id:h,mounted:u,onOpenChange:E,open:g,panelRef:C,runOnceAnimationsFinish:f,setDimensions:_,setMounted:R,setOpen:x,setVisible:w,transitionDimensionRef:D,visible:M,width:U}=s,H=ae.useRef(!1),K=ae.useRef(null),V=ae.useRef(g),W=ae.useRef(g),X=QVe(),J=ae.useMemo(()=>t.current==="css-animation"?!M:!g&&!u,[g,u,M,t]),Z=Dn(z=>{if(!z)return;if(t.current==null||D.current==null){const ie=getComputedStyle(z),he=ie.animationName!=="none"&&ie.animationName!=="",Ae=ie.transitionDuration!=="0s"&&ie.transitionDuration!=="";he&&Ae||(ie.animationName==="none"&&ie.transitionDuration!=="0s"?t.current="css-transition":ie.animationName!=="none"&&ie.transitionDuration==="0s"?t.current="css-animation":t.current="none"),z.getAttribute(Ozr.orientation)==="horizontal"||ie.transitionProperty.indexOf("width")>-1?D.current="width":D.current="height"}if(t.current!=="css-transition")return;(i===void 0||U===void 0)&&(_({height:z.scrollHeight,width:z.scrollWidth}),W.current&&z.style.setProperty("transition-duration","0s"));let q=-1,se=-1;return q=$C.request(()=>{W.current=!1,se=$C.request(()=>{setTimeout(()=>{z.style.removeProperty("transition-duration")})})}),()=>{$C.cancel(q),$C.cancel(se)}}),j=LH(a,C,Z);return Xr(()=>{if(t.current!=="css-transition")return;const z=C.current;if(!z)return;let q=-1;if(e.current!=null&&(e.current.abort(),e.current=null),g){const se={"justify-content":z.style.justifyContent,"align-items":z.style.alignItems,"align-content":z.style.alignContent,"justify-items":z.style.justifyItems};Object.keys(se).forEach(ie=>{z.style.setProperty(ie,"initial","important")}),!W.current&&!A&&z.setAttribute(wFe.startingStyle,""),_({height:z.scrollHeight,width:z.scrollWidth}),q=$C.request(()=>{Object.entries(se).forEach(([ie,he])=>{he===""?z.style.removeProperty(ie):z.style.setProperty(ie,he)})})}else{if(z.scrollHeight===0&&z.scrollWidth===0)return;_({height:z.scrollHeight,width:z.scrollWidth});const se=new AbortController;e.current=se;const ie=se.signal;let he=null;const Ae=wFe.endingStyle;return he=new MutationObserver(Ee=>{Ee.some(ue=>ue.type==="attributes"&&ue.attributeName===Ae)&&(he==null||he.disconnect(),he=null,f(()=>{_({height:0,width:0}),z.style.removeProperty("content-visibility"),R(!1),e.current===se&&(e.current=null)},ie))}),he.observe(z,{attributes:!0,attributeFilter:[Ae]}),()=>{he==null||he.disconnect(),X.cancel(),e.current===se&&(se.abort(),e.current=null)}}return()=>{$C.cancel(q)}},[e,t,X,n,A,u,g,C,f,_,R]),Xr(()=>{if(t.current!=="css-animation")return;const z=C.current;z&&(K.current=z.style.animationName||K.current,z.style.setProperty("animation-name","none"),_({height:z.scrollHeight,width:z.scrollWidth}),!V.current&&!H.current&&z.style.removeProperty("animation-name"),g?(e.current!=null&&(e.current.abort(),e.current=null),R(!0),w(!0)):(e.current=new AbortController,f(()=>{R(!1),w(!1),e.current=null},e.current.signal)))},[e,t,g,C,f,_,R,w,M]),xVe(()=>{const z=$C.request(()=>{V.current=!1});return()=>$C.cancel(z)}),Xr(()=>{if(!n)return;const z=C.current;if(!z)return;let q=-1,se=-1;return g&&H.current&&(z.style.transitionDuration="0s",_({height:z.scrollHeight,width:z.scrollWidth}),q=$C.request(()=>{H.current=!1,se=$C.request(()=>{setTimeout(()=>{z.style.removeProperty("transition-duration")})})})),()=>{$C.cancel(q),$C.cancel(se)}},[n,g,C,_]),Xr(()=>{const z=C.current;z&&n&&J&&(z.setAttribute("hidden","until-found"),t.current==="css-transition"&&z.setAttribute(wFe.startingStyle,""))},[n,J,t,C]),ae.useEffect(function(){const q=C.current;if(!q)return;function se(ie){H.current=!0,x(!0),E(!0,yA(Uj,ie))}return q.addEventListener("beforematch",se),()=>{q.removeEventListener("beforematch",se)}},[E,C,x]),ae.useMemo(()=>({props:{hidden:J,id:h,ref:j}}),[J,h,j])}let fC1=(function(s){return s.collapsiblePanelHeight="--collapsible-panel-height",s.collapsiblePanelWidth="--collapsible-panel-width",s})({});const Lzr=ae.forwardRef(function(e,t){const{className:a,hiddenUntilFound:i,keepMounted:n,render:A,id:h,...u}=e,{abortControllerRef:E,animationTypeRef:g,height:C,mounted:f,onOpenChange:_,open:R,panelId:x,panelRef:w,runOnceAnimationsFinish:D,setDimensions:M,setHiddenUntilFound:U,setKeepMounted:H,setMounted:K,setPanelIdState:V,setOpen:W,setVisible:X,state:J,transitionDimensionRef:Z,visible:j,width:z,transitionStatus:q}=Gua(),se=i??!1,ie=n??!1;Xr(()=>{if(h)return V(h),()=>{V(void 0)}},[h,V]),Xr(()=>{U(se)},[U,se]),Xr(()=>{H(ie)},[H,ie]);const{props:he}=Szr({abortControllerRef:E,animationTypeRef:g,externalRef:t,height:C,hiddenUntilFound:se,id:x,keepMounted:ie,mounted:f,onOpenChange:_,open:R,panelRef:w,runOnceAnimationsFinish:D,setDimensions:M,setMounted:K,setOpen:W,setVisible:X,transitionDimensionRef:Z,visible:j,width:z});NN({open:R&&q==="idle",ref:w,onComplete(){R&&M({height:void 0,width:void 0})}});const Ae=ae.useMemo(()=>({...J,transitionStatus:q}),[J,q]),Ee=IA("div",e,{state:Ae,ref:[t,w],props:[he,{style:{[fC1.collapsiblePanelHeight]:C===void 0?"auto":`${C}px`,[fC1.collapsiblePanelWidth]:z===void 0?"auto":`${z}px`}},u],stateAttributesMapping:Yua});return ie||se||!ie&&f?Ee:null});function Qzr({...s}){return O.jsx(Tzr,{"data-slot":"collapsible",...s})}function vzr({...s}){return O.jsx(xzr,{"data-slot":"collapsible-trigger",...s})}function wzr({...s}){return O.jsx(Lzr,{"data-slot":"collapsible-content",...s})}function Nzr({items:s}){return O.jsx(jVe,{children:s.map(e=>{var t;return O.jsx(lme,{children:e.items?O.jsxs(Qzr,{defaultOpen:e.isActive,className:"group/collapsible",children:[O.jsx(vzr,{render:O.jsxs($ae,{tooltip:e.title,className:"cursor-pointer",children:[e.icon&&O.jsx(e.icon,{className:e.iconClassName}),O.jsx("span",{children:e.title}),O.jsx(qg,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),O.jsx(wzr,{children:O.jsx(Cpr,{children:(t=e.items)==null?void 0:t.map(a=>O.jsx(ppr,{children:O.jsx(UK1,{render:O.jsx("a",{href:a.url}),className:"cursor-pointer",children:O.jsx("span",{children:a.title})})},a.title))})})]}):O.jsxs($ae,{tooltip:e.title,isActive:e.isActive,onClick:e.onClick,className:"cursor-pointer",children:[e.icon&&O.jsx(e.icon,{className:e.iconClassName}),O.jsx("span",{children:e.title})]})},e.title)})})}const Kua=ae.createContext(void 0);function Vua(){const s=ae.useContext(Kua);if(s===void 0)throw new Error($l(13));return s}const op0={imageLoadingStatus:()=>null},Dzr=ae.forwardRef(function(e,t){const{className:a,render:i,...n}=e,[A,h]=ae.useState("idle"),u={imageLoadingStatus:A},E=ae.useMemo(()=>({imageLoadingStatus:A,setImageLoadingStatus:h}),[A,h]),g=IA("span",e,{state:u,ref:t,props:n,stateAttributesMapping:op0});return O.jsx(Kua.Provider,{value:E,children:g})});function kzr(s,{referrerPolicy:e,crossOrigin:t}){const[a,i]=ae.useState("idle");return Xr(()=>{if(!s)return i("error"),_O;let n=!0;const A=new window.Image,h=u=>()=>{n&&i(u)};return i("loading"),A.onload=h("loaded"),A.onerror=h("error"),e&&(A.referrerPolicy=e),A.crossOrigin=t??null,A.src=s,()=>{n=!1}},[s,t,e]),a}const bzr={...op0,...NM},Mzr=ae.forwardRef(function(e,t){const{className:a,render:i,onLoadingStatusChange:n,referrerPolicy:A,crossOrigin:h,...u}=e,E=Vua(),g=kzr(e.src,{referrerPolicy:A,crossOrigin:h}),C=g==="loaded",{mounted:f,transitionStatus:_,setMounted:R}=pre(C),x=ae.useRef(null),w=Dn(U=>{n==null||n(U),E.setImageLoadingStatus(U)});Xr(()=>{g!=="idle"&&w(g)},[g,w]);const D={imageLoadingStatus:g,transitionStatus:_};NN({open:C,ref:x,onComplete(){C||R(!1)}});const M=IA("img",e,{state:D,ref:[t,x],props:u,stateAttributesMapping:bzr,enabled:f});return f?M:null}),Uzr=ae.forwardRef(function(e,t){const{className:a,render:i,delay:n,...A}=e,{imageLoadingStatus:h}=Vua(),[u,E]=ae.useState(n===void 0),g=q8();return ae.useEffect(()=>(n!==void 0&&g.start(n,()=>E(!0)),g.clear),[g,n]),IA("span",e,{state:{imageLoadingStatus:h},ref:t,props:A,stateAttributesMapping:op0,enabled:h!=="loaded"&&u})}),nws=ae.forwardRef(({className:s,size:e="default",...t},a)=>O.jsx(Dzr,{ref:a,"data-slot":"avatar","data-size":e,className:ei("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",s),...t}));nws.displayName="Avatar";const cws=ae.forwardRef(({className:s,...e},t)=>O.jsx(Mzr,{ref:t,"data-slot":"avatar-image",className:ei("aspect-square size-full rounded-full object-cover",s),...e}));cws.displayName="AvatarImage";const Aws=ae.forwardRef(({className:s,...e},t)=>O.jsx(Uzr,{ref:t,"data-slot":"avatar-fallback",className:ei("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",s),...e}));Aws.displayName="AvatarFallback";function Fzr({open:s,onOpenChange:e}){const[t,a]=ae.useState(!1),i=async()=>{a(!0);try{await Fua(),v0.success("Data exported successfully!")}catch(n){v0.error("Export failed: "+(n.message||"Unknown error"))}finally{a(!1)}};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-105 bg-background border-border/40 shadow-2xl",children:[O.jsx(h5,{className:"sr-only",children:"Guest Data Backup"}),O.jsx(j_,{className:"sr-only",children:"Export your Guest Mode data as a JSON file for safe keeping or future import."}),O.jsxs("div",{className:"p-2 space-y-6",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[O.jsx("div",{className:"p-2.5 bg-amber-500/10 rounded-xl",children:O.jsx(Tj,{className:"size-5 text-amber-500"})}),O.jsxs("div",{children:[O.jsx("h3",{className:"font-semibold text-base",children:"Guest Mode"}),O.jsx("p",{className:"text-xs text-muted-foreground",children:"You are browsing as a guest"})]})]}),O.jsxs("div",{className:"bg-muted/10 border border-border/40 rounded-xl p-4 space-y-3",children:[O.jsxs("div",{className:"flex items-start gap-3",children:[O.jsx(M3,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),O.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:O.jsxs("p",{children:["Your data (notes, diagrams, flowcharts, drawings, and AI chats) is stored locally in your browser. Export it as a ",O.jsx("code",{className:"bg-muted px-1 rounded text-[11px]",children:".json"})," ","file so you can import it after signing in."]})})]}),O.jsxs("div",{className:"flex items-start gap-3",children:[O.jsx(bfe,{className:"size-4 text-muted-foreground shrink-0 mt-0.5"}),O.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:O.jsxs("p",{children:["The export file can be imported into any ERD Builder Pro account via",O.jsx("strong",{children:" Settings → Guest Data Import"}),"."]})})]})]}),O.jsx(D1,{onClick:i,disabled:t,className:"w-full",children:t?O.jsxs(O.Fragment,{children:[O.jsx(Su,{className:"size-4 mr-2 animate-spin"}),"Exporting…"]}):O.jsxs(O.Fragment,{children:[O.jsx(AB,{className:"size-4 mr-2"}),"Export My Data"]})}),O.jsxs("div",{className:"relative",children:[O.jsx("div",{className:"absolute inset-0 flex items-center",children:O.jsx("span",{className:"w-full border-t border-border/30"})}),O.jsx("div",{className:"relative flex justify-center text-xs",children:O.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Need an account?"})})]}),O.jsx("div",{className:"text-center space-y-2",children:O.jsx("p",{className:"text-xs text-muted-foreground",children:"Sign up or log in from the main page to import your backup."})})]})]})})}function Pzr({user:s,onLogout:e,onViewChange:t,isOnline:a,onOpenFeedback:i}){var j,z,q;const{isMobile:n}=mre(),{isGuest:A,setIsSettingsOpen:h,setSettingsTab:u,hasUpdate:E,latestVersion:g,isCheckingUpdate:C,isDownloadingUpdate:f,isWebOutdated:_,showOutdatedBadge:R,checkForUpdates:x,downloadUpdate:w}=AC(),D=typeof window<"u"&&!!(window.__TAURI__||window.__TAURI_INTERNALS__);if(!s)return null;const M=s.email||"",U=s.name||((j=s.user_metadata)==null?void 0:j.full_name)||((z=s.user_metadata)==null?void 0:z.name)||M.split("@")[0]||"User",H=((q=s.user_metadata)==null?void 0:q.avatar_url)||"",K=U.substring(0,2).toUpperCase(),V=se=>{u(se),h(!0)},[W,X]=ae.useState(!1),[J,Z]=ae.useState(!1);return O.jsxs(O.Fragment,{children:[O.jsx(jVe,{children:O.jsx(lme,{children:O.jsxs(MO,{children:[O.jsx(yy,{render:O.jsxs($ae,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[O.jsxs("div",{className:"relative",children:[O.jsxs(nws,{className:"h-8 w-8 rounded-lg",children:[O.jsx(cws,{src:H,alt:U}),O.jsx(Aws,{className:"rounded-lg",children:K})]}),R&&O.jsx("span",{className:"absolute -top-1 -right-1 flex size-3 rounded-full bg-amber-500 ring-2 ring-sidebar",title:D?`Update available: v${g||"?"}`:_?`New version available: v${g||"?"}. You're on v3.1.4. Pull latest Docker image or update your install.`:""})]}),O.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[O.jsx("span",{className:"truncate font-semibold",children:U}),O.jsx("span",{className:"truncate text-xs",children:M})]}),O.jsx(xUe,{className:"ml-auto size-4"})]})}),O.jsxs(xy,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:n?"bottom":"right",align:"end",sideOffset:4,children:[O.jsx(HIe,{children:O.jsx(wPs,{className:"p-0 font-normal",children:O.jsx(HIe,{children:O.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[O.jsxs(nws,{className:"h-8 w-8 rounded-lg",children:[O.jsx(cws,{src:H,alt:U}),O.jsx(Aws,{className:"rounded-lg",children:K})]}),O.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[O.jsx("span",{className:"truncate font-semibold",children:U}),O.jsx("span",{className:"truncate text-xs",children:M})]})]})})})}),O.jsx(af,{}),O.jsxs(HIe,{children:[O.jsxs(Gl,{onClick:()=>V(A?"appearance":"account"),className:"cursor-pointer",disabled:!A&&!a,children:[O.jsx(pae,{className:"mr-2 size-4"}),"Settings"]}),A&&O.jsxs(Gl,{onClick:()=>X(!0),className:"cursor-pointer",children:[O.jsx(AB,{className:"mr-2 size-4"}),"Backup Data"]}),O.jsx(af,{}),O.jsxs(Gl,{onClick:()=>Z(!0),className:"cursor-pointer",children:[E?O.jsx(c1e,{className:"mr-2 size-4 text-emerald-400"}):_?O.jsx(BUe,{className:"mr-2 size-4 text-amber-500"}):O.jsx(jb,{className:"mr-2 size-4"}),"About",R&&O.jsx("span",{className:`ml-auto flex size-2 rounded-full ${E?"bg-emerald-400":"bg-amber-500"}`})]}),O.jsxs(Gl,{render:O.jsx("a",{href:"https://github.com/hadziqmtqn/erd-builder-pro",target:"_blank",rel:"noopener noreferrer"}),className:"cursor-pointer",children:[O.jsx(DUe,{className:"mr-2 size-4"}),"Github"]}),O.jsxs(Gl,{onClick:i,className:"cursor-pointer",children:[O.jsx(XUe,{className:"mr-2 size-4"}),"Feedback"]})]}),O.jsx(af,{}),O.jsx(HIe,{children:O.jsxs(Gl,{onClick:()=>a&&t("trash"),disabled:!a,className:`text-destructive focus:bg-accent focus:text-destructive cursor-pointer ${!a&&"opacity-50 cursor-not-allowed"}`,children:[O.jsx(F5,{className:"mr-2 size-4"}),"Trash"]})}),O.jsx(af,{}),!D&&O.jsxs(Gl,{onClick:()=>a&&e(),disabled:!a,className:`cursor-pointer ${!a&&"opacity-50 cursor-not-allowed"}`,title:a?"":"Logging out while offline may cause data loss of unsynced changes",children:[O.jsx(WUe,{className:"mr-2 size-4"}),"Log out"]})]})]})})}),O.jsx(Fzr,{open:W,onOpenChange:X}),O.jsx(Pua,{open:J,onOpenChange:Z,hasUpdate:E,latestVersion:g,isChecking:C,isDownloading:f,onCheckUpdate:x,onDownload:w})]})}function Hzr({teams:s}){const{isMobile:e}=mre(),t=wM(),a=s[0];return O.jsx(jVe,{children:O.jsx(lme,{children:O.jsxs($ae,{size:"lg",onClick:()=>t("/"),className:"hover:bg-accent/50 active:bg-accent/70 transition-colors cursor-pointer",children:[O.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-brand text-white",children:O.jsx(a.logo,{className:"size-4"})}),O.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[O.jsxs("span",{className:"truncate font-semibold",children:["ERD Builder ",O.jsx("span",{className:"text-brand",children:"Pro"})]}),O.jsx("span",{className:"truncate text-xs",children:a.plan})]})]})})})}const ows=({isOpen:s,onOpenChange:e,mode:t="move-to-trash",activeDocument:a,view:i,deleteDiagram:n,deleteNote:A,deleteDrawing:h,deleteFlowchart:u,deleteProject:E,fetchTrash:g,itemType:C,onConfirm:f,onAfterDelete:_})=>{const R=async()=>{if(t==="permanent-delete"){f==null||f(),_==null||_();return}if(f){f(),_==null||_();return}const D=i==="erd"||i==="notes"||i==="flowchart"||i==="drawings"?(a==null?void 0:a.uid)??(a==null?void 0:a.id):a==null?void 0:a.id;D&&(i==="erd"?await(n==null?void 0:n(D)):i==="notes"?await(A==null?void 0:A(String(D))):i==="drawings"?await(h==null?void 0:h(D)):i==="flowchart"?await(u==null?void 0:u(D)):i==="project"&&await(E==null?void 0:E(D)),g==null||g(),e(!1),_==null||_())},x=C==="erd"?"diagram":C==="notes"?"note":C==="drawings"?"drawing":C==="project"?"workspace":"item";if(t==="permanent-delete"){const D=C==="project";return O.jsx(hH,{open:s,onOpenChange:e,children:O.jsxs(lH,{size:"sm",className:"max-w-[400px]",children:[O.jsxs(dH,{children:[O.jsx(hRe,{className:"bg-destructive/10",children:O.jsx(Jm,{className:"w-5 h-5 text-destructive"})}),O.jsx(CH,{children:"Are you absolutely sure?"})]}),O.jsx(EH,{children:O.jsx(S5e,{children:D?O.jsxs(O.Fragment,{children:["This action cannot be undone. Deleting this workspace will also permanently delete all",O.jsx("strong",{children:" notes, diagrams, drawings, and flowcharts"})," inside it."]}):O.jsxs(O.Fragment,{children:["This action cannot be undone. This will permanently delete the ",O.jsx("strong",{children:x})," from our servers."]})})}),O.jsxs(gH,{children:[O.jsx(eM,{onClick:()=>e(!1),children:"Cancel"}),O.jsx(nW,{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Permanently Delete"})]})]})})}const w=i!=="project";return O.jsx(hH,{open:s,onOpenChange:e,children:O.jsxs(lH,{size:"sm",className:"max-w-[400px]",children:[O.jsxs(dH,{children:[O.jsx(hRe,{className:"bg-destructive/10",children:O.jsx(F5,{className:"w-5 h-5 text-destructive"})}),O.jsx(CH,{children:w?"Move to Trash?":"Delete Workspace?"})]}),O.jsx(EH,{children:O.jsx(S5e,{children:w?O.jsxs(O.Fragment,{children:["Are you sure you want to move ",O.jsx("strong",{children:(a==null?void 0:a.title)||(a==null?void 0:a.name)||"this item"})," to trash?",O.jsx("br",{}),"You can restore it later from the trash bin."]}):O.jsxs(O.Fragment,{children:["This will move the workspace and all its contents to trash.",O.jsx("br",{}),"You can restore it later from the trash bin."]})})}),O.jsxs(gH,{children:[O.jsx(eM,{onClick:()=>e(!1),children:"Cancel"}),O.jsx(nW,{onClick:R,children:w?"Move to Trash":"Delete"})]})]})})},Gzr=6e3,_C1=[{logoSrc:"https://s3.erdbuilderpro.com/sponsors/Sumopod-Light.png",logoDarkSrc:"https://s3.erdbuilderpro.com/sponsors/Sumopod-Dark.png",logoAlt:"SumoPod",title:"Deploy your App in 15 Seconds!",description:"Seamless container deployment for businesses of all sizes.",buttonText:"Get Started →",buttonColor:"#2071FB",buttonHoverColor:"#1a5fd4",buttonAction:"https://sumopod.com"}];function Yzr({isCollapsed:s}){const[e,t]=ae.useState(0);if(ae.useEffect(()=>{const i=setInterval(()=>t(n=>(n+1)%_C1.length),Gzr);return()=>clearInterval(i)},[]),s)return null;const a=_C1[e];return O.jsx("div",{className:"px-3 mb-2",children:O.jsx("div",{className:"overflow-hidden rounded-xl border border-dashed border-border/80 dark:border-border/70 bg-card/85 p-3",children:O.jsxs("div",{className:"flex flex-col items-center gap-1.5 animate-in fade-in slide-in-from-right-4 duration-500",children:[a.icon?O.jsx(a.icon,{className:"w-5 h-5 text-rose-500 shrink-0"}):a.logoSrc?O.jsxs(O.Fragment,{children:[O.jsx("img",{src:a.logoSrc,alt:a.logoAlt??"",className:"h-8 w-auto max-w-full object-contain dark:hidden shrink-0"}),a.logoDarkSrc&&O.jsx("img",{src:a.logoDarkSrc,alt:a.logoAlt??"",className:"h-8 w-auto max-w-full object-contain hidden dark:block shrink-0"})]}):null,O.jsx("p",{className:"text-xs font-semibold text-foreground text-center truncate max-w-full",children:a.title}),O.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed text-center wrap-break-word",children:a.description}),O.jsx("button",{className:"w-full h-7 inline-flex items-center justify-center rounded-md text-white text-[10px] font-semibold transition-colors cursor-pointer mt-1",style:{backgroundColor:a.buttonColor||"#2071FB"},onMouseEnter:i=>{a.buttonHoverColor&&(i.currentTarget.style.backgroundColor=a.buttonHoverColor)},onMouseLeave:i=>{i.currentTarget.style.backgroundColor=a.buttonColor||"#2071FB"},onClick:()=>Yvs(a.buttonAction),children:a.buttonText})]},e)})})}const Kzr=ae.memo(({projects:s,view:e,onViewChange:t,onNoteSelect:a,onDrawingSelect:i,onProjectCreate:n,onProjectUpdate:A,onProjectDelete:h,onLogout:u,onWorkspaceFilter:E,selectedWorkspaceUid:g,searchQuery:C,onSearchChange:f,isProjectsLoading:_,user:R,isOnline:x,onOpenFeedback:w,...D})=>{const{state:M}=mre(),U=M==="collapsed",H=ae.useRef(null),[K,V]=ae.useState(null),[W,X]=ae.useState(""),[J,Z]=ae.useState(null),[j,z]=ae.useState(!1),[q,se]=ae.useState(""),ie=[{title:"Notes",url:"#",icon:P_,iconClassName:"text-yellow-400",isActive:e==="notes",onClick:()=>t("notes",!0)},{title:"ERD Builder",url:"#",icon:M3,iconClassName:"text-blue-400",isActive:e==="erd",onClick:()=>t("erd",!0)},{title:"Flowchart",url:"#",icon:AH,iconClassName:"text-green-400",isActive:e==="flowchart",onClick:()=>t("flowchart",!0)},{title:"Drawings",url:"#",icon:$b,iconClassName:"text-purple-400",isActive:e==="drawings",onClick:()=>t("drawings",!0)}],he=s.filter(Ee=>!Ee.is_deleted),Ae=(Ee,le)=>{const ue=Ee??(le!=null?String(le):null);t(e,!0,ue)};return O.jsxs(O.Fragment,{children:[O.jsxs(kK1,{collapsible:"icon",...D,children:[O.jsxs(lpr,{children:[O.jsx(Hzr,{teams:[{name:"ERD Builder Pro",logo:M3,plan:"Workspace"}]}),O.jsx(UOt,{className:"py-0 group-data-[collapsible=icon]:hidden",children:O.jsxs(nLs,{className:"relative",children:[O.jsx(bK1,{ref:H,placeholder:"search workspace",className:"pl-8",value:C,onChange:Ee=>f(Ee.target.value),disabled:!x}),O.jsx(LO,{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"})]})}),O.jsxs(UOt,{className:"group-data-[collapsible=icon]:p-0",children:[O.jsxs(rLs,{className:"flex items-center justify-between",children:["Features",!x&&O.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:[O.jsx("span",{className:"w-1 h-1 rounded-full bg-destructive animate-pulse"}),"Offline"]})]}),O.jsx(Nzr,{items:ie})]})]}),O.jsx(MK1,{children:O.jsxs(UOt,{className:"px-4 group-data-[collapsible=icon]:p-2",children:[O.jsxs(rLs,{className:"flex items-center justify-between",children:[O.jsx("span",{children:"Workspaces"}),O.jsx(qw,{children:O.jsxs(v_,{children:[O.jsx(w_,{className:"hover:bg-muted hover:text-foreground rounded-md p-0.5 cursor-pointer",onClick:()=>{se(""),z(!0)},children:O.jsx(Z8,{className:"h-3.5 w-3.5"})}),O.jsx(N_,{side:"right",children:"Create Workspace"})]})})]}),O.jsx(nLs,{children:O.jsxs(jVe,{children:[O.jsx(lme,{children:O.jsxs($ae,{tooltip:"All Workspaces",isActive:g===null||g==="",onClick:()=>Ae(null),children:[O.jsx(Bj,{className:"h-4 w-4 shrink-0"}),O.jsx("span",{children:"All Workspaces"})]})}),_?O.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground animate-pulse group-data-[collapsible=icon]:hidden",children:"Loading workspaces..."}):he.length===0?O.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground group-data-[collapsible=icon]:hidden",children:"No workspaces yet"}):he.map(Ee=>O.jsx(lme,{children:O.jsxs($ae,{tooltip:Ee.name,isActive:g===Ee.uid||String(g??"")===String(Ee.id??""),onClick:()=>Ae(Ee.uid,Ee.id),children:[O.jsx(Bj,{className:"h-4 w-4 shrink-0"}),O.jsx("span",{className:"truncate flex-1 text-left",children:Ee.name}),O.jsx("span",{onClick:le=>le.stopPropagation(),children:O.jsxs(MO,{children:[O.jsx(yy,{nativeButton:!1,render:O.jsx("span",{className:"p-1 rounded hover:bg-accent/50 cursor-pointer inline-flex items-center justify-center",children:O.jsx(fO,{className:"h-3.5 w-3.5"})})}),O.jsxs(xy,{align:"end",children:[O.jsxs(Gl,{onClick:()=>{X(Ee.name),V(Ee)},children:[O.jsx(SQ,{className:"h-3.5 w-3.5 mr-2"}),"Edit"]}),O.jsx(af,{}),O.jsxs(Gl,{onClick:()=>Z(Ee),children:[O.jsx(F5,{className:"h-3.5 w-3.5 mr-2 text-destructive"}),"Delete"]})]})]})})]})},Ee.uid??Ee.id))]})})]})}),O.jsxs(dpr,{children:[O.jsx(Yzr,{isCollapsed:U}),O.jsx(Pzr,{user:R,onLogout:u,onViewChange:t,isOnline:x,onOpenFeedback:w})]}),O.jsx(upr,{})]}),O.jsx(u5,{open:K!==null,onOpenChange:Ee=>{Ee||V(null)},children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsx(q6,{children:O.jsx(h5,{children:"Rename Workspace"})}),O.jsx(Hd,{children:O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"rename-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),O.jsx(DA,{id:"rename-project-input",type:"text",value:W,onChange:Ee=>X(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&W.trim()&&K&&(A(K.id,W.trim()),V(null))},autoFocus:!0})]})}),O.jsxs(ff,{children:[O.jsx(cvt,{render:O.jsx(D1,{variant:"outline",className:"h-9"}),children:"Cancel"}),O.jsx(D1,{className:"h-9 px-6",disabled:!W.trim(),onClick:()=>{K&&W.trim()&&(A(K.id,W.trim()),V(null))},children:"Save Changes"})]})]})}),O.jsx(u5,{open:j,onOpenChange:z,children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsx(q6,{children:O.jsx(h5,{children:"Create Workspace"})}),O.jsx(Hd,{children:O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"create-project-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Name"}),O.jsx(DA,{id:"create-project-input",type:"text",value:q,onChange:Ee=>se(Ee.target.value),onKeyDown:Ee=>{Ee.key==="Enter"&&q.trim()&&(n(q.trim()),z(!1),se(""))},autoFocus:!0})]})}),O.jsxs(ff,{children:[O.jsx(cvt,{render:O.jsx(D1,{variant:"outline",className:"h-9"}),children:"Cancel"}),O.jsx(D1,{className:"h-9 px-6",disabled:!q.trim(),onClick:()=>{q.trim()&&(n(q.trim()),z(!1),se(""))},children:"Create"})]})]})}),O.jsx(ows,{isOpen:J!==null,onOpenChange:Ee=>{Ee||Z(null)},mode:"move-to-trash",view:"project",activeDocument:J?{id:J.id,name:J.name}:void 0,deleteProject:h,onAfterDelete:()=>Z(null)})]})}),Md=ae.forwardRef(({className:s,...e},t)=>O.jsx("label",{ref:t,"data-slot":"label",className:ei("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",s),...e}));Md.displayName="Label";function Vzr({isOpen:s,onOpenChange:e,documentType:t,documentUid:a,documentId:i,documentTitle:n,isPublicView:A=!1,initialSettings:h,onSettingsSaved:u}){const[E,g]=$s.useState((h==null?void 0:h.share_token)||""),[C,f]=$s.useState(!1),[_,R]=$s.useState((h==null?void 0:h.is_public)||!1),[x,w]=$s.useState(""),[D,M]=$s.useState(!1);$s.useEffect(()=>{if(h!=null&&h.expiry_date){const J=new Date(h.expiry_date),Z=new Date,j=J.getTime()-Z.getTime(),z=Math.ceil(j/(1e3*60*60*24));z>0&&w(z.toString())}g((h==null?void 0:h.share_token)||""),R((h==null?void 0:h.is_public)||!1)},[h]);const H={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[t]||t,K=`${window.location.origin}/view/${H}/${a}`,V=()=>{navigator.clipboard.writeText(K),f(!0),v0.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)},W=()=>{const J=Math.random().toString(36).substring(2,10).toUpperCase();g(J),v0.info("Secure token generated")},X=async()=>{M(!0);try{const J=t==="erd"?"diagrams":t==="flowchart"?"flowcharts":t;let Z=null;if(x&&!isNaN(parseInt(x))){const z=new Date;z.setDate(z.getDate()+parseInt(x)),Z=z.toISOString()}if(!(await Ri(`/api/${J}/${i}/share`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_public:_,share_token:E,expiry_date:Z})})).ok)throw new Error("Failed to save settings");v0.success("Sharing settings updated!"),u&&u(),e(!1)}catch(J){v0.error(J.message||"Something went wrong")}finally{M(!1)}};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-md",children:[O.jsxs(q6,{children:[O.jsx(h5,{children:A?"Share Document":`Share "${n}"`}),O.jsx(j_,{children:A?"Share this link with others to view this document.":_?"Anyone with this link can view this document. No account required.":"This document is currently private. Only you can access it."})]}),O.jsxs(Hd,{className:"space-y-4",children:[!A&&O.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30 transition-colors hover:bg-muted/50",children:[O.jsxs("div",{className:"space-y-0.5",children:[O.jsxs("div",{className:"flex items-center gap-2",children:[_?O.jsx(Vb,{className:"w-4 h-4 text-primary"}):O.jsx(Wb,{className:"w-4 h-4 text-muted-foreground"}),O.jsx(Md,{htmlFor:"public-status",className:"text-sm font-bold",children:"Public Access"})]}),O.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Enable sharing via public link"})]}),O.jsx("input",{id:"public-status",type:"checkbox",checked:_,onChange:J=>R(J.target.checked),className:"w-4 h-4 cursor-pointer accent-primary"})]}),O.jsxs("div",{className:`space-y-4 transition-all duration-300 ${_||A?"opacity-100":"opacity-40 pointer-events-none grayscale-[0.5]"}`,children:[O.jsxs("div",{className:"space-y-2",children:[O.jsx(Md,{htmlFor:"share-link",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Public Link"}),O.jsxs("div",{className:"flex items-center space-x-2",children:[O.jsx(DA,{id:"share-link",readOnly:!0,value:K,className:"flex-1 bg-muted/20 font-mono text-xs"}),O.jsx(D1,{onClick:V,size:"icon",variant:"outline",className:"shrink-0 cursor-pointer hover:bg-primary/10 hover:text-primary transition-colors",disabled:!_&&!A,children:C?O.jsx(l8,{className:"w-4 h-4 text-green-500"}):O.jsx(SO,{className:"w-4 h-4"})})]})]}),!A&&O.jsxs(O.Fragment,{children:[O.jsxs("div",{className:"space-y-2 pt-2",children:[O.jsxs("div",{className:"flex items-center justify-between",children:[O.jsx(Md,{htmlFor:"access-token",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Access Token (Optional)"}),O.jsxs(D1,{variant:"link",size:"sm",onClick:W,className:"h-auto p-0 text-[10px] uppercase font-bold tracking-tighter cursor-pointer text-primary hover:no-underline",disabled:!_,children:[O.jsx(aB,{className:"w-3 h-3 mr-1"}),"Generate"]})]}),O.jsx(DA,{id:"access-token",placeholder:"Enter or generate a token...",value:E,onChange:J=>g(J.target.value),disabled:!_,className:"font-mono text-xs"})]}),O.jsxs("div",{className:"space-y-2 pt-2",children:[O.jsx(Md,{htmlFor:"valid-until",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Duration (Days)"}),O.jsx(DA,{id:"valid-until",type:"number",placeholder:"Forever",value:x,onChange:J=>w(J.target.value),disabled:!_,className:"text-xs"})]})]})]})]}),O.jsx(ff,{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:A?O.jsx(D1,{type:"button",onClick:()=>e(!1),className:"cursor-pointer w-full sm:w-auto font-bold",children:"Close"}):O.jsxs(O.Fragment,{children:[O.jsx(D1,{variant:"ghost",onClick:()=>e(!1),className:"cursor-pointer order-2 sm:order-1 font-semibold",disabled:D,children:"Cancel"}),O.jsx(D1,{type:"button",onClick:X,className:"cursor-pointer order-1 sm:order-2 font-bold min-w-[120px]",disabled:D,children:D?O.jsxs(O.Fragment,{children:[O.jsx(aB,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})})]})})}const jzr=({onShare:s,onRename:e,onDelete:t,onDuplicate:a,onExportAll:i,onExportMarkdown:n,onCopyMarkdown:A,onImportMarkdown:h,isOnline:u,isPublicView:E=!1,isPublic:g=!1,activeFileUid:C,documentType:f,noteContent:_})=>{const R=M=>M.replace(/<[^>]+>/g,"").replace(/&[^;]+;/g," ").trim(),w=(M=>{const U=M?R(M):"";if(!U)return{words:0,sentences:0,paragraphs:0,characters:0};const H=U.split(/\s+/).filter(Boolean).length,K=U.split(/[.!?]+(?:\s|$)/).filter(X=>X.trim().length>0).length,V=M?(M.match(/<p[^>]*>[\s\S]*?<\/p>/g)||[]).length||U.split(/\n\s*\n/).filter(Boolean).length:U.split(/\n\s*\n/).filter(Boolean).length,W=U.replace(/\s/g,"").length;return{words:H,sentences:K,paragraphs:V,characters:W}})(_),D=()=>{if(!C){v0.error("Document link not available");return}const U={erd:"diagram",notes:"note",drawings:"drawing",flowchart:"flowchart"}[f]||f,H=`${window.location.origin}/view/${U}/${C}`;navigator.clipboard.writeText(H),v0.success("Public share link copied to clipboard")};return O.jsx("div",{className:"flex items-center gap-1 sm:gap-2",children:O.jsxs(MO,{children:[O.jsx(yy,{render:O.jsxs(D1,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground hover:bg-muted/80 hover:text-foreground hover:shadow-sm active:scale-95 transition-all duration-200",children:[O.jsx("span",{className:"hidden sm:inline mr-1.5 text-xs font-medium",children:"Actions"}),O.jsx(fO,{className:"h-4 w-4"})]})}),O.jsxs(xy,{align:"end",className:"w-56",children:[E?O.jsxs(Gl,{onClick:D,className:"gap-2 cursor-pointer",children:[O.jsx(Jle,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Copy Public Link"})]}):O.jsxs(O.Fragment,{children:[O.jsxs(Gl,{disabled:!u,onClick:s,className:"gap-2 cursor-pointer",children:[O.jsx(Zle,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Share"})]}),g&&O.jsxs(Gl,{disabled:!u,onClick:D,className:"gap-2 cursor-pointer",children:[O.jsx(Jle,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Copy Public Link"})]}),O.jsx(af,{}),O.jsxs(Gl,{disabled:!u,onClick:e,className:"gap-2 cursor-pointer",children:[f==="erd"?O.jsx(Jfe,{className:"h-4 w-4 text-muted-foreground"}):O.jsx(E1e,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:f==="erd"?"Settings":"Edit Document"})]}),O.jsx(af,{}),O.jsxs(Gl,{disabled:!u,onClick:t,className:"gap-2 text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer",children:[O.jsx(F5,{className:"h-4 w-4"}),O.jsx("span",{children:"Move to Trash"})]})]}),(f==="notes"||f==="drawings")&&!E&&O.jsxs(O.Fragment,{children:[O.jsx(af,{}),O.jsxs(Gl,{disabled:!u,onClick:a,className:"gap-2 cursor-pointer",children:[O.jsx(SO,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Duplicate"})]})]}),f==="erd"&&!E&&O.jsxs(O.Fragment,{children:[O.jsx(af,{}),O.jsxs(Gl,{onClick:i,className:"gap-2 cursor-pointer",children:[O.jsx(AB,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Export All"})]})]}),f==="notes"&&!E&&O.jsxs(O.Fragment,{children:[O.jsx(af,{}),O.jsx(Gl,{disabled:!u,onClick:A,className:"gap-2 cursor-pointer flex items-center",children:O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(SO,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Copy Markdown"})]})}),O.jsxs(Gl,{disabled:!u,onClick:h,className:"gap-2 cursor-pointer flex items-center",children:[O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(Rj,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Import"})]}),O.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),O.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"I"})]})]}),O.jsxs(Gl,{disabled:!u,onClick:n,className:"gap-2 cursor-pointer flex items-center",children:[O.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[O.jsx(AB,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Export"})]}),O.jsxs("div",{className:"ml-auto flex items-center gap-0.5 text-muted-foreground/60",children:[O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⌘"}),O.jsx("span",{className:"text-[13px] font-sans leading-none",children:"⇧"}),O.jsx("span",{className:"text-[15px] font-mono font-bold mt-0.5",children:"E"})]})]}),O.jsx(af,{}),O.jsxs($pr,{children:[O.jsxs(Jpr,{className:"gap-2 cursor-pointer",children:[O.jsx(n1e,{className:"h-4 w-4 text-muted-foreground"}),O.jsx("span",{children:"Text Stats"})]}),O.jsx(Xpr,{className:"w-52 p-1",children:O.jsxs("div",{className:"px-3 py-1.5 space-y-1",children:[O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Words"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.words.toLocaleString()})]}),O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Sentences"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.sentences.toLocaleString()})]}),O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Paragraphs"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.paragraphs.toLocaleString()})]}),O.jsx(af,{className:"my-1.5"}),O.jsxs("div",{className:"flex items-center justify-between text-xs",children:[O.jsx("span",{className:"text-muted-foreground",children:"Characters"}),O.jsx("span",{className:"font-medium tabular-nums",children:w.characters.toLocaleString()})]})]})})]})]})]})]})})},Wzr=$s.memo(({featureLabel:s,activeProjectName:e,activeFileName:t,view:a,hasActiveItem:i,syncError:n,isSyncing:A,isRefreshing:h,isLocalSaving:u=!1,hasPendingSyncs:E,activeFileUid:g,activeFileId:C,initialShareSettings:f,onSettingsSaved:_,isPublicView:R=!1,isOnline:x,updatedAt:w,onDelete:D,onRename:M,onSave:U,onExportAll:H,onExportSQL:K,onExportPDF:V,onExportImage:W,onExportMarkdown:X,onCopyMarkdown:J,onImportMarkdown:Z,onDuplicate:j,isGuest:z=!1,breadcrumbLabel:q,noteContent:se})=>{const ie=V_(),[he,Ae]=$s.useState(!1),[Ee,le]=$s.useState(!1);return $s.useEffect(()=>{le(window.navigator.userAgent.toLowerCase().includes("mac"))},[]),O.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:[O.jsxs("div",{className:"flex items-center gap-2 px-4 min-w-0 flex-none",children:[!R&&O.jsxs(O.Fragment,{children:[O.jsx(opr,{className:"-ml-1 shrink-0"}),O.jsx(OK1,{orientation:"vertical",className:"h-4 shrink-0 bg-border/50"})]}),O.jsx(FK1,{className:"min-w-0 flex items-center",children:O.jsx(PK1,{className:"flex-nowrap items-center",children:!R&&(()=>{var me;const ue=ie.pathname;if(ue==="/")return O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-semibold text-foreground",children:"Dashboard"})});if(ue.startsWith("/table/")){const Be={notes:"Notes",erd:"ERD Builder",drawings:"Drawings",flowchart:"Flowcharts"},_e=(me=ue.match(/^\/table\/([^/]+)$/))==null?void 0:me[1],ve=_e?Be[_e]||_e:"Unknown";return O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-foreground",children:ve})})}if(ue.startsWith("/notes/")||ue.startsWith("/diagrams/")||ue.startsWith("/drawings/")||ue.startsWith("/flowcharts/")){const Be={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"}},_e=ue.split("/")[1],ve=Be[_e];return O.jsxs(O.Fragment,{children:[ve&&O.jsxs(O.Fragment,{children:[O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-muted-foreground",children:ve.label})}),e&&O.jsx(cLs,{className:"shrink-0"})]}),e&&O.jsxs(O.Fragment,{children:[O.jsx(pP,{className:"min-w-0 shrink",children:O.jsx(_V,{className:"max-w-[80px] sm:max-w-[150px] md:max-w-[250px] truncate text-muted-foreground",children:e})}),t&&O.jsx(cLs,{className:"shrink-0"})]}),t&&O.jsxs(pP,{className:"min-w-0 shrink flex items-center gap-2",children:[O.jsx(_V,{className:"max-w-[120px] sm:max-w-[200px] md:max-w-[300px] truncate font-semibold text-foreground",children:t}),(f==null?void 0:f.is_public)&&!R&&O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.jsxs(Gg,{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:[O.jsx(Vb,{className:"w-2.5 h-2.5"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Public"}),O.jsx("div",{className:"w-1 h-1 rounded-full bg-green-500 animate-pulse ml-0.5"})]})}),O.jsx(N_,{side:"bottom",align:"center",className:"text-[10px] font-medium",children:"This document is shared publicly via a secret link."})]})})]}),!t&&!e&&O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-foreground",children:(ve==null?void 0:ve.label)||"Document"})})]})}return ue.startsWith("/trash")?O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-foreground",children:"Trash"})}):q?O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-semibold text-foreground",children:q})}):O.jsx(pP,{className:"shrink-0",children:O.jsx(_V,{className:"font-medium text-muted-foreground",children:s})})})()})})]}),O.jsx("div",{className:"flex-1 flex items-center justify-center px-2",children:!x&&!R?O.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:[O.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-destructive animate-pulse"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider",children:"Offline Mode: Navigation Disabled"})]}):null}),O.jsx("div",{className:"px-2 sm:px-4 flex items-center gap-1 sm:gap-4",children:!!ie.pathname.match(/^\/(notes|diagrams|drawings|flowcharts)\/[^/]+$/)&&O.jsxs("div",{className:"flex items-center gap-1 sm:gap-4",children:[!R&&O.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 shrink-0",children:[u?O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.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:[O.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Saving..."})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium",children:"Saving changes locally..."})]})}):n?O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.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:[O.jsx(LUe,{className:"w-3.5 h-3.5"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Sync Failed"})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium max-w-[200px] text-center",children:"Changes saved locally, but cloud sync failed. We'll retry automatically."})]})}):A?O.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:[O.jsx(lae,{className:"w-3.5 h-3.5 animate-bounce"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Syncing..."})]}):E?O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.jsxs(D1,{variant:"ghost",size:"sm",onClick:U,disabled:!x,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:[O.jsx(qq,{className:"w-3.5 h-3.5 animate-in zoom-in-50"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Save"})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium",children:O.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[O.jsx("span",{children:"Save changes to cloud"}),O.jsxs("span",{className:"opacity-50 text-[9px]",children:[Ee?"⌘":"Ctrl"," + S"]})]})})]})}):O.jsx(qw,{delay:0,children:O.jsxs(v_,{children:[O.jsx(w_,{render:O.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:[O.jsx(l8,{className:"w-3.5 h-3.5"}),O.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider hidden xs:inline",children:"Synced"})]})}),O.jsx(N_,{side:"bottom",className:"text-[10px] font-medium",children:"All changes are saved and synced"})]})}),h&&O.jsx("div",{className:"flex items-center gap-2 text-primary animate-pulse ml-1 sm:ml-2",children:O.jsx("div",{className:"w-3 h-3 border-2 border-primary border-t-transparent rounded-full animate-spin"})})]}),O.jsx(jzr,{onShare:()=>x&&Ae(!0),onDelete:D,onRename:M,onDuplicate:j,onExportAll:H,onExportSQL:K,onExportPDF:V,onExportImage:W,onExportMarkdown:X,onCopyMarkdown:J,onImportMarkdown:Z,isOnline:x,isPublicView:R,isPublic:f==null?void 0:f.is_public,activeFileUid:g,documentType:a,noteContent:se}),g&&C&&x&&O.jsx(Vzr,{isOpen:he,onOpenChange:Ae,documentType:a,documentUid:g,documentId:C,documentTitle:t||"Untitled",isPublicView:R,initialSettings:f,onSettingsSaved:_})]})})]})});function $zr({open:s,onOpenChange:e}){const[t,a]=$s.useState(!1),[i,n]=$s.useState(""),[A,h]=$s.useState("suggestion"),[u,E]=$s.useState(""),g=async C=>{if(C.preventDefault(),!!i.trim()){a(!0);try{if((await Ri("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,category:A,email:u,url:window.location.href,browser:navigator.userAgent})})).ok)v0.success("Feedback terkirim! Terima kasih masukannya."),e(!1),n("");else throw new Error}catch{v0.error("Gagal mengirim feedback. Coba lagi nanti.")}finally{a(!1)}}};return O.jsx(u5,{open:s,onOpenChange:C=>{e(C),C||n("")},children:O.jsx(b7,{className:"sm:max-w-[425px] border-border bg-popover/95 backdrop-blur-xl shadow-2xl",children:O.jsxs("form",{onSubmit:g,className:"flex flex-col max-h-[inherit]",children:[O.jsxs(q6,{children:[O.jsx(h5,{className:"text-xl font-bold",children:"Kirim Masukan"}),O.jsx(j_,{className:"text-sm text-muted-foreground",children:"Bantu kami membuat ERD Builder Pro jadi lebih baik. Saran Anda sangat berharga!"})]}),O.jsxs(Hd,{className:"space-y-5",children:[O.jsxs("div",{className:"grid gap-2",children:[O.jsx(Md,{htmlFor:"category",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Tipe Masukan"}),O.jsxs(Bf,{value:A,onValueChange:C=>C&&h(C),children:[O.jsx(uI,{id:"category",className:"bg-white/5 border-white/10 focus:ring-primary/50",children:O.jsx(Rf,{placeholder:"Pilih tipe",children:A==="suggestion"?"Saran Fitur":A==="bug"?"Lapor Bug":A==="other"?"Kritik / Lainnya":A})}),O.jsxs(Tf,{className:"bg-popover border-border text-popover-foreground",children:[O.jsx(g3,{value:"suggestion",className:"focus:bg-muted",children:"Saran Fitur"}),O.jsx(g3,{value:"bug",className:"focus:bg-muted text-destructive",children:"Lapor Bug"}),O.jsx(g3,{value:"other",className:"focus:bg-muted",children:"Kritik / Lainnya"})]})]})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsx(Md,{htmlFor:"content",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Pesan"}),O.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:C=>n(C.target.value),required:!0})]}),O.jsxs("div",{className:"grid gap-2",children:[O.jsx(Md,{htmlFor:"email",className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email (Opsional)"}),O.jsx(DA,{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:u,onChange:C=>E(C.target.value)})]})]}),O.jsxs(ff,{className:"gap-3",children:[O.jsx(D1,{variant:"ghost",type:"button",onClick:()=>e(!1),className:"hover:bg-muted",children:"Batal"}),O.jsx(D1,{type:"submit",disabled:t,className:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-lg shadow-primary/20",children:t?"Mengirim...":"Kirim Masukan"})]})]})})})}const Jzr=({isOpen:s,onOpenChange:e,selectedEntity:t,deleteEntity:a,setSelectedNodeId:i})=>O.jsx(hH,{open:s,onOpenChange:e,children:O.jsxs(lH,{size:"sm",className:"max-w-[400px]",children:[O.jsxs(dH,{children:[O.jsx(hRe,{className:"bg-destructive/10",children:O.jsx(Jm,{className:"w-5 h-5 text-destructive"})}),O.jsx(CH,{children:"Delete Table"})]}),O.jsx(EH,{children:O.jsxs(S5e,{children:["Are you sure you want to delete the table ",O.jsx("strong",{children:t==null?void 0:t.name}),"? This action cannot be undone."]})}),O.jsxs(gH,{children:[O.jsx(eM,{onClick:()=>e(!1),children:"Cancel"}),O.jsx(nW,{onClick:()=>{t&&(a(t.id),i(null),e(!1))},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),efs=s=>s==="erd"?"diagram":s==="notes"?"note":s==="drawings"?"drawing":"flowchart",mC1=({isOpen:s,onOpenChange:e,mode:t="edit",view:a,activeDocument:i,newName:n,setNewName:A,projects:h,selectedProjectId:u,setSelectedProjectId:E,onCreate:g,updateDiagram:C,updateNote:f,updateDrawing:_,updateFlowchart:R,onMoveDiagramToProject:x,onMoveNoteToProject:w,onMoveDrawingToProject:D,onMoveFlowchartToProject:M,onRenameSuccess:U})=>{var V;const H=t==="create";ae.useEffect(()=>{if(s&&!H&&i){const W=(i==null?void 0:i.project_id)??(i==null?void 0:i.projectId);E(W!=null?String(W):"none")}},[s]);const K=async()=>{if(!n.trim())return;if(H){g==null||g(n.trim(),u==="none"?null:u),e(!1);return}const W=a==="notes"||a==="flowchart"||a==="drawings"?i==null?void 0:i.uid:i==null?void 0:i.id;if(W&&n.trim()){const X=u==="none"?null:u,J=(i==null?void 0:i.project_id)||(i==null?void 0:i.projectId),Z=n.trim()!==((i==null?void 0:i.title)||(i==null?void 0:i.name)),j=String(X)!==String(J);try{Z&&(a==="erd"?await(C==null?void 0:C(W,n,{silent:!0})):a==="notes"?await(f==null?void 0:f(String(W),n,{silent:!0})):a==="drawings"?await(_==null?void 0:_(W,n,{silent:!0})):a==="flowchart"&&await(R==null?void 0:R(W,n,{silent:!0}))),j&&(a==="erd"?await(x==null?void 0:x(W,X,{silent:!0})):a==="notes"?await(w==null?void 0:w(W,X,{silent:!0})):a==="drawings"?await(D==null?void 0:D(W,X,{silent:!0})):a==="flowchart"&&await(M==null?void 0:M(W,X,{silent:!0}))),(Z||j)&&U&&await U(),v0.success("Document updated successfully"),e(!1)}catch{v0.error("Failed to update document")}}};return O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsxs(q6,{children:[O.jsx(h5,{children:H?`Create ${efs(a)}`:"Edit Document"}),O.jsx(j_,{children:H?`Enter a name and select a workspace for your new ${efs(a)}.`:`Update the name and project for your ${efs(a)}.`})]}),O.jsx(Hd,{children:O.jsxs("div",{className:"space-y-4",children:[O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"rename-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:H?"Name":"New Name"}),O.jsx(DA,{id:"rename-input",type:"text",value:n,onChange:W=>A(W.target.value),onKeyDown:W=>{W.key==="Enter"&&n.trim()&&K()},autoFocus:!0})]}),O.jsxs(Il,{children:[O.jsx(fl,{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"Project"}),O.jsxs(Bf,{value:u,onValueChange:W=>W!==null&&E(W),children:[O.jsx(uI,{className:"h-9",children:O.jsx(Rf,{children:u==="none"?"Uncategorized":((V=h.find(W=>W.id.toString()===u))==null?void 0:V.name)||"Select Project"})}),O.jsxs(Tf,{children:[O.jsx(g3,{value:"none",children:"Uncategorized"}),h.map(W=>O.jsx(g3,{value:W.id.toString(),children:W.name},W.id))]})]})]})]})}),O.jsxs(ff,{children:[O.jsx(cvt,{render:O.jsx(D1,{variant:"outline",className:"h-9"}),children:"Cancel"}),O.jsx(D1,{disabled:!n.trim(),onClick:K,className:"h-9 px-6",children:H?"Create":"Save Changes"})]})]})})},Xzr=({isOpen:s,onOpenChange:e,view:t,duplicateName:a,setDuplicateName:i,executeDuplicate:n,isRefreshing:A})=>O.jsx(u5,{open:s,onOpenChange:e,children:O.jsxs(b7,{className:"sm:max-w-sm",children:[O.jsxs(q6,{children:[O.jsx(h5,{children:"Duplicate Document"}),O.jsxs(j_,{children:["Create a copy of this ",t==="erd"?"diagram":t==="notes"?"note":t==="drawings"?"drawing":"flowchart","."]})]}),O.jsx(Hd,{children:O.jsx("div",{className:"space-y-4",children:O.jsxs(Il,{children:[O.jsx(fl,{htmlFor:"duplicate-input",className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70 px-1",children:"New Name"}),O.jsx(DA,{id:"duplicate-input",type:"text",value:a,onChange:h=>i(h.target.value),onKeyDown:h=>{h.key==="Enter"&&a.trim()&&n()},autoFocus:!0})]})})}),O.jsxs(ff,{className:"gap-2 sm:gap-0",children:[O.jsx(D1,{variant:"ghost",onClick:()=>e(!1),children:"Cancel"}),O.jsx(D1,{onClick:n,disabled:!a.trim()||A,children:A?O.jsxs(O.Fragment,{children:[O.jsx(Su,{className:"mr-2 h-4 w-4 animate-spin"}),"Duplicating..."]}):"Duplicate"})]})]})});function wb(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var tfs={exports:{}};/*!
8870
8870
 
8871
8871
  JSZip v3.10.1 - A JavaScript class for generating and reading zip files
8872
8872
  <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-DvoYprDu.js"></script>
21
+ <script type="module" crossorigin src="/assets/index-B2ODl0Tq.js"></script>
22
22
  <link rel="stylesheet" crossorigin href="/assets/index-d5kw8z7D.css">
23
23
  </head>
24
24
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "erdbpro",
3
- "version": "3.1.4-beta.1",
3
+ "version": "3.1.4",
4
4
  "description": "ERD Builder Pro CLI — one command to start your database design workspace.",
5
5
  "type": "module",
6
6
  "bin": {