Incorporo-user commited on
Commit
9a5a587
·
verified ·
1 Parent(s): 8010824

Inkvec 0.2: the presentation page, and Inkvec Studio Lite under studio/

Browse files
studio/assets/{main-ai0rIBhL.js → main-DD_Xvh8j.js} RENAMED
@@ -1,9 +1,9 @@
1
  var No=Object.defineProperty;var Io=(e,t,s)=>t in e?No(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Y=(e,t,s)=>Io(e,typeof t!="symbol"?t+"":t,s);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();async function Dt(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}function Oo(){return!!(globalThis||window).isTauri}var Hn;(function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_SUSPENDED="tauri://suspended",e.WINDOW_RESUMED="tauri://resumed",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"})(Hn||(Hn={}));var Un;(function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"})(Un||(Un={}));var jn;(function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"})(jn||(jn={}));var Vn;(function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"})(Vn||(Vn={}));var Yn;(function(e){e.Default="default",e.FluentOverlay="fluentOverlay"})(Yn||(Yn={}));var Zn;(function(e){e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight"})(Zn||(Zn={}));var Jn;(function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"})(Jn||(Jn={}));const _o=`<!-- Generated by studio/tools/make_assets.py from web/logo.svg. Do not edit. -->
2
  <svg color="#c9754a" xmlns="http://www.w3.org/2000/svg" viewBox="254.5 140.5 514.25 742.25"><path d="M511.3 140.6c-23.3 79.8-103 178.5-144.9 232.75L335.45 415.4a467.73 467.73 0 00-64.8 115.4c-65.5 193.1 80.8 351.3 237.85 351.7 21.26 1.1 42.56-1.3 63.06-7 90.8-18.87 211.87-120.04 195.47-280.9-17.9-164.8-187.55-272.65-251.8-443.84Zm10.2 374.9a61.05 61.05 0 00-67.1 81.6 61.05 61.05 0 00104.3 17.26 61.05 61.05 0 00-37.2-98.86ZM511.4 817.65l177.16-201.3-43-.15a44.56 44.56 0 00-36.2 18.47l-97.8 111.67-102.2-116.67c-16.06-18.94-38.06-12-74.9-13.4 5.7 7.3 159.75 179.73 176.93 201.4Z" fill="currentColor" fill-rule="evenodd"/></svg>
3
- `;function n(e,t=null,...s){const[o,...a]=e.split("."),i=document.createElement(o||"div");return a.length&&(i.className=a.join(" ")),Bo(i,t),mn(i,s),i}function xe(e,t=null,...s){const[o,...a]=e.split("."),i=document.createElementNS("http://www.w3.org/2000/svg",o||"g");a.length&&i.setAttribute("class",a.join(" "));for(const[r,l]of Object.entries(t??{}))l==null||l===!1||(r.startsWith("on")&&typeof l=="function"?i.addEventListener(r.slice(2),l):i.setAttribute(r,String(l)));return mn(i,s),i}function Bo(e,t){for(const[s,o]of Object.entries(t??{}))o==null||o===!1||(s==="class"?e.className=e.className?`${e.className} ${o}`:String(o):s==="style"&&typeof o=="object"?Object.assign(e.style,o):s.startsWith("on")&&typeof o=="function"?e.addEventListener(s.slice(2),o):s==="value"&&e instanceof HTMLInputElement?e.value=String(o):o===!0?e.setAttribute(s,""):e.setAttribute(s,String(o)))}function mn(e,t){for(const s of t.flat(8))s==null||s===!1||e.append(s instanceof Node?s:document.createTextNode(String(s)))}function F(e,...t){e.replaceChildren(),mn(e,t)}const Xn={image:"M3 3h18v18H3zM3 15l5-5 4 4 3-3 6 6M8.5 8.5h.01",type:"M4 7V4h16v3M9 20h6M12 4v16",droplet:"M12 2.7 6.7 8a7.5 7.5 0 1 0 10.6 0Z",wand:"m3 21 9-9M15 4V2M15 16v-2M8 9h2M20 9h2M17.8 11.8 19 13M15 9h.01M17.8 6.2 19 5M12.8 6.2 11.6 5",layers:"m12 2 9 5-9 5-9-5 9-5M3 12l9 5 9-5M3 17l9 5 9-5",palette:"M12 21a9 9 0 1 1 0-18c4.97 0 9 3.58 9 8 0 1.66-1.34 3-3 3h-2a2 2 0 0 0-1.6 3.2 2 2 0 0 1-1.6 3.2ZM7.5 10.5h.01M10.5 7.5h.01M14 7.5h.01M16.5 10.5h.01",check:"m20 6-11 11-5-5",checkCircle:"M22 11.1V12a10 10 0 1 1-5.9-9.1M22 4 12 14.01l-3-3",x:"M18 6 6 18M6 6l12 12",alert:"M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",info:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 16v-4M12 8h.01",clock:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 6v6l4 2",download:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3",upload:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12",globe:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10Z",copy:"M20 9H11a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2ZM5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",folder:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",settings:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6 1.65 1.65 0 0 0 10 3.09V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z",chevronDown:"m6 9 6 6 6-6",chevronRight:"m9 18 6-6-6-6",minus:"M5 12h14",pen:"M21.17 6.81a2.82 2.82 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5Z",square:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Z",crosshair:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM22 12h-4M6 12H2M12 6V2M12 22v-4",zap:"M4 14h7l-3 8 12-12h-7l3-8Z",play:"m6 3 14 9-14 9V3Z",pause:"M14 4h4v16h-4zM6 4h4v16H6z",rotate:"M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5",share:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M16 6l-4-4-4 4M12 2v13",file:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7ZM14 2v6h6",maximize:"M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3",external:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"};function Z(e,t=16){const s=Xn[e]??Xn.info;return xe("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",focusable:"false"},xe("path",{d:s}))}function Ds(e=18){const t=Ro.cloneNode(!0);t.removeAttribute("color");const[,,s,o]=(t.getAttribute("viewBox")??"0 0 1 1").split(/\s+/).map(Number);return t.setAttribute("height",String(e)),t.setAttribute("width",String(Math.round(e*s/o))),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false"),t}const Ro=(()=>{const e=new DOMParser().parseFromString(_o,"image/svg+xml").documentElement;return document.importNode(e,!0)})();function Go(e,t){let s=0;const o=i=>[...i.dataTransfer?.types??[]].includes("Files"),a=()=>{s=0,e.set({dragging:!1}),document.body.classList.remove("dragging")};window.addEventListener("dragenter",i=>{o(i)&&(s++,e.set({dragging:!0}),document.body.classList.add("dragging"))}),window.addEventListener("dragover",i=>{o(i)&&(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="copy"))}),window.addEventListener("dragleave",i=>{o(i)&&(s=Math.max(0,s-1),s===0&&a())}),window.addEventListener("drop",i=>{if(!o(i))return;i.preventDefault(),a();const r=[...i.dataTransfer?.files??[]];r.length&&t(r)}),Wo(t)}function Wo(e){window.addEventListener("paste",t=>{if(t.target?.closest?.("input, textarea, [contenteditable]"))return;let o=[...t.clipboardData?.files??[]];o.length||(o=[...t.clipboardData?.items??[]].filter(a=>a.kind==="file").map(a=>a.getAsFile()).filter(a=>a!==null)),o.length&&(t.preventDefault(),e(o))})}const qo=760;function Ho(e){const t=window.matchMedia(`(max-width: ${qo}px)`).matches,s=window.matchMedia("(pointer: coarse)").matches;if(!(t&&s))return;const o=n("div.phonenote",{role:"dialog","aria-label":"Best on a larger screen"},n("div.phonecard",null,n("span.serif",{style:{fontSize:"22px"}},"Best on a larger screen"),n("p",null,"Inkvec Studio Lite is a full editor: a viewer, a rail of controls and a palette side by side. On a phone they do not fit. Open this page on a laptop or desktop to use it; everything runs in your browser and nothing is uploaded."),n("button.btn",{onclick:()=>o.remove()},"Continue anyway")));e.append(o)}async function Uo(){const e=new URLSearchParams(window.location.search),t=e.get("sample"),s=e.get("open")==="handoff";return!t&&!s?null:(window.history.replaceState(null,"",window.location.pathname),t?{sample:t}:new Promise(o=>{let a;try{a=indexedDB.open("inkvec-handoff",1)}catch{o(null);return}a.onupgradeneeded=()=>a.result.createObjectStore("files"),a.onerror=()=>o(null),a.onsuccess=()=>{const i=a.result.transaction("files","readwrite").objectStore("files"),r=i.get("open");r.onsuccess=()=>{i.delete("open");const l=r.result;o(l?.bytes?{name:l.name??"image",bytes:l.bytes}:null)},r.onerror=()=>o(null)}}))}let vt=0,Mt=null,rn=0,tt=!1,Fs=performance.now();const Ut=e=>(e/(1024*1024)).toFixed(1);function jo(){rn=0;const e=Mt;if(Mt=null,!e||tt)return;vt=e.fraction;const t=document.getElementById("boot-bar"),s=document.getElementById("boot-fill"),o=document.getElementById("boot-status"),a=document.getElementById("boot-pct"),i=document.getElementById("boot-detail"),r=Math.round(vt*100);s&&(s.style.transform=`scaleX(${vt})`),t?.setAttribute("aria-valuenow",String(r)),o&&(o.textContent=e.text),a&&(a.textContent=`${r}%`),i&&(i.textContent=e.detail)}function at(e,t,s=""){tt||(Fs=performance.now(),Mt={text:e,fraction:Math.max(vt,Mt?.fraction??0,Math.min(1,t)),detail:s},rn||(rn=requestAnimationFrame(jo)))}function Vo(e,t){const s=t>0?Math.min(1,e/t):0;at("Downloading the engine",.04+.8*s,t>0?`${Ut(e)} of ${Ut(t)} MB`:`${Ut(e)} MB`)}function Yo(){at("Starting the engine",.88,"Compiling, and starting a thread per core")}function Zo(e,t){at(e,.9+.1*Math.min(1,Math.max(0,t)))}function Jo(){if(tt)return;const e=document.getElementById("boot-fill");e&&(e.style.transitionDuration="0.12s"),at("Ready",1),window.setTimeout(()=>{tt=!0;const t=document.getElementById("boot");t&&(t.classList.add("leaving"),window.setTimeout(()=>t.remove(),260))},130)}{window.__inkvecBoot=!0,at("Loading the Studio",.03);const e=window.setInterval(()=>{if(tt){window.clearInterval(e);return}if(performance.now()-Fs>2e4){const t=document.getElementById("boot-detail");t&&(t.textContent="Still waiting for the network. On a slow connection the first visit can take a minute; later ones start from the browser's cache.")}},2e3)}function Xo(){let e;try{e=window.self!==window.top}catch{e=!0}const t=window.location.ancestorOrigins;if(t)for(let a=0;a<t.length;a++)/(^|\.)huggingface\.co(:\d+)?$/.test(t[a].replace(/^[a-z]+:\/\//,""))&&(e=!0);const s=document.documentElement;s.classList.toggle("framed",e);const o=()=>s.classList.toggle("fullscreen",!!document.fullscreenElement);document.addEventListener("fullscreenchange",o),o()}function Re(e,t,s="application/octet-stream"){const o=t instanceof Blob?t:new Blob([t],{type:s}),a=URL.createObjectURL(o),i=document.createElement("a");i.href=a,i.download=e,i.style.display="none",document.body.append(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(a),6e4)}var Ko={pkg:5813486,"pkg-threads":5845653};const Kn="inkvec-studio-lite:prefs",Qn="inkvec-denoiser-v1",Qo="inkvec-ort-",ea=3e4,ta=700,es="Not available in the browser. Inkvec Studio, the desktop app, has it.",ts=[["flat-logo.png","Flat logo"],["icon-64.png","Icon, 64 px"],["crest-filigree.png","Crest, filigree"],["signature-bw.png","Signature, B&W"]];class na{constructor(){Y(this,"worker",null);Y(this,"ready",null);Y(this,"queue",[]);Y(this,"running",null);Y(this,"nextId",1);Y(this,"listeners",new Map);Y(this,"generation",0);Y(this,"previewGeneration",0);Y(this,"shared",null);Y(this,"source",null);Y(this,"prefs",null);Y(this,"prefsTimer",0);Y(this,"denoiser",null);Y(this,"denoiserPort",null);Y(this,"downloading",!1);Y(this,"fetchState",{phase:"idle",got:0,total:null});Y(this,"wanted",!1);Y(this,"cancelled",!1);Y(this,"retried",!1);Y(this,"info",null);Y(this,"restartMs",null);Y(this,"stopped",[]);Y(this,"stopTimer",0);Y(this,"denoiserRuns",0);Y(this,"last",null)}base(){return new URL("./",document.baseURI).href}start(){const t=typeof crossOriginIsolated<"u"&&crossOriginIsolated;t&&!this.shared&&(this.shared=new Int32Array(new SharedArrayBuffer(4)));const s=new Worker(new URL(""+new URL("engine.worker-wbMABDxy.js",import.meta.url).href,import.meta.url),{type:"module",name:"inkvec-engine"});this.worker=s;let o=null;if(t){const i=new MessageChannel;o=i.port1,this.denoiser?this.denoiser.postMessage({type:"port",port:i.port2},[i.port2]):this.denoiserPort=i.port2}this.ready=new Promise((i,r)=>{s.onmessage=l=>{const c=l.data;c.type==="loading"?(Vo(c.got,c.total),c.done&&Yo()):c.type==="instantiated"?t&&(this.startDenoiser(c.denoiserUrl,c.denoiserSha256),this.prefetchDenoiser()):c.type==="ready"?(this.info={threads:c.threads,isolated:c.isolated,version:c.version},c.poolError&&console.warn("inkvec: thread pool did not start:",c.poolError),t&&this.startDenoiser(c.denoiserUrl,c.denoiserSha256),i(c)):c.type==="loadfail"?r(new Error(`The engine could not load: ${c.error}`)):c.type==="progress"?c.generation===this.generation&&this.emit("trace:progress",{generation:c.generation,...JSON.parse(c.json)}):c.type==="reply"&&this.finish(c)},s.onerror=l=>{r(new Error(`The engine stopped: ${l.message||"unknown error"}`)),this.crashed("The engine stopped unexpectedly.")}});const a=o?[o]:[];return s.postMessage({type:"init",base:this.base(),token:"05758cc93999",generations:this.shared?this.shared.buffer:null,denoiserPort:o,wasmBytes:Ko},a),this.ready}whenReady(){return this.ready??this.start()}crashed(t){const s=this.running;this.running=null,window.clearTimeout(this.stopTimer),this.worker?.terminate(),this.worker=null,this.ready=null,s&&s.reject(new Error(t)),s?.op==="open_bytes"&&(this.source=null);const o=this.source,a=performance.now();this.whenReady().then(async()=>{o&&await this.enqueue("open_bytes",-1,{bytes:o.bytes.slice(),name:o.name}).catch(()=>{}),this.restartMs=performance.now()-a,this.pump()})}supersede(t,s){window.clearTimeout(this.stopTimer);const o=this.running;if(o?.op!=="trace"||o.payload.generation===this.generation||!t&&s&&sa(o.payload.request,s))return;const a=performance.now(),i=()=>{this.running!==o||o.payload.generation===this.generation||(this.stopped.push({generation:o.payload.generation,asked:a,killed:performance.now()}),this.crashed("superseded by a newer request"))},r=a-(o.started??a),l=t?0:Math.max(0,(this.restartMs??ta)-r);l===0?i():this.stopTimer=window.setTimeout(i,l)}finish(t){const s=this.running;if(!(!s||s.id!==t.id)){if(this.last={op:s.op,ms:t.ms??0,mem:t.mem??null},this.running=null,window.clearTimeout(this.stopTimer),t.ok)s.resolve(t.value);else if(t.crashed){this.crashed(t.error??"The engine stopped."),s.reject(new Error(t.error??"The engine stopped."));return}else s.reject(new Error(t.error??"failed"));this.pump()}}enqueue(t,s,o,a){return new Promise((i,r)=>{if(a){for(const l of this.queue.filter(c=>c.kind===a))l.reject(new Error("superseded by a newer request"));this.queue=this.queue.filter(l=>l.kind!==a)}this.queue.push({id:this.nextId++,op:t,priority:s,kind:a,payload:o,resolve:i,reject:r}),this.queue.sort((l,c)=>l.priority-c.priority||l.id-c.id),this.whenReady().then(()=>this.pump(),l=>{for(const c of this.queue)c.reject(l);this.queue=[]})})}pump(){if(this.running||!this.worker||!this.info)return;const t=this.queue.shift();if(!t)return;if(t.op==="trace"&&t.payload.generation!==this.generation)return t.resolve(null),this.pump();if(t.op==="preview"&&t.payload.generation!==this.previewGeneration)return t.resolve(null),this.pump();this.running=t,t.started=performance.now();const s=[];t.op==="open_bytes"&&s.push(t.payload.bytes.buffer),this.worker.postMessage({type:"job",id:t.id,op:t.op,...t.payload},s)}emit(t,s){for(const o of this.listeners.get(t)??[])o(s)}async listen(t,s){const o=i=>s({payload:i});let a=this.listeners.get(t);return a||this.listeners.set(t,a=new Set),a.add(o),()=>void a?.delete(o)}async invoke(t,s={}){return await this.dispatch(t,s)}async dispatch(t,s){switch(t){case"capabilities":{const o=await this.denoiserStatus();return this.enqueue("capabilities",0,{supported:o.supported,installed:o.installed,bytes:o.bytes})}case"startup_progress":return Zo(String(s.text??""),Number(s.progress??0)),null;case"app_ready":return Jo(),null;case"open_path":throw new Error("A browser opens files you choose or drop, not paths.");case"open_bytes":{const o=s.bytes,a=o instanceof Uint8Array?o:new Uint8Array(o);return this.open(a,s.name??null)}case"open_sample":{const o=String(s.name);if(!ts.some(([i])=>i===o))throw new Error(`${o} is not one of the bundled samples`);const a=await fetch(new URL(`samples/${o}`,this.base()));if(!a.ok)throw new Error(`cannot fetch the sample ${o}: HTTP ${a.status}`);return this.open(new Uint8Array(await a.arrayBuffer()),o)}case"list_samples":return ts.map(([o,a])=>({file:o,label:a,preview:new URL(`samples/${o}`,this.base()).href}));case"launch_path":return null;case"start_trace":{const o=s.request,a=this.bump();this.rememberTrace(o.settings);const i=this.withoutUnreadyDenoiser(o);this.supersede(!1,i);const r=await this.loadPrefs();return this.enqueue("trace",1,{request:i,draftPx:r.draftPx??512,draftSeconds:r.draftSeconds??.4,generation:a},"trace").then(l=>{l&&a===this.generation&&this.emit("trace:done",{generation:a,outcome:l})},l=>{a===this.generation&&!/superseded/.test(l.message)&&this.emit("trace:done",{generation:a,outcome:{state:"failed",message:l.message}})}),a}case"cancel_trace":return this.bump(),this.queue=this.queue.filter(o=>o.kind==="trace"?(o.resolve(null),!1):!0),this.supersede(!0),null;case"start_preview":{const o=this.withoutUnreadyDenoiser(s.request),a=++this.previewGeneration,i=await this.loadPrefs();return this.enqueue("preview",2,{request:o,draftPx:i.draftPx??512,draftSeconds:i.draftSeconds??.4,generation:a},"preview").then(r=>{r&&a===this.previewGeneration&&this.emit("preview:done",{generation:a,outcome:r})},r=>{a===this.previewGeneration&&!/superseded/.test(r.message)&&this.emit("preview:done",{generation:a,outcome:{state:"failed",message:r.message}})}),a}case"cancel_previews":{this.previewGeneration++,this.queue=this.queue.filter(a=>a.kind==="preview"?(a.resolve(null),!1):!0);const o=this.running;return o?.op==="preview"&&o.started!==void 0&&performance.now()-o.started>500&&this.crashed("superseded by a newer request"),null}case"source_facts":case"trace_bands":case"snap_inks":case"match_palette":case"plan_export":case"minify_svg":case"fab_analyze":return this.enqueue(t,0,{args:s});case"fab_prepare":return this.enqueue(t,0,{args:s},"fab");case"write_export":{const o=s.request,a=await this.enqueue("export",0,{request:o,zip:!0}),i=(this.source?.name??"image").replace(/\.[^.]+$/,"")||"image";if(a.length===1&&a[0].name)return Re(a[0].name,a[0].data),[a[0].name];const r=`${i}-inkvec.zip`;return a[0]&&Re(r,a[0].data,"application/zip"),[r]}case"read_text_file":throw new Error("A browser reads files you choose or drop, not paths.");case"save_bytes":{const o=String(s.path);return Re(o.split(/[\\/]/).pop()||"download",new Uint8Array(s.bytes)),null}case"batch_scan":case"batch_start":case"batch_stats_csv":throw new Error(es);case"batch_pause":case"batch_cancel":return null;case"denoiser_status":return this.denoiserStatus();case"denoiser_download":return this.downloadDenoiser();case"denoiser_cancel":return this.fetchState.phase==="downloading"&&(this.cancelled=!0,this.wanted=!1,this.denoiser?.postMessage({type:"abort"})),this.downloading&&(this.downloading=!1,this.emit("denoiser:done",{ok:!1,message:"cancelled",status:await this.denoiserStatus()})),null;case"denoiser_remove":try{await caches.delete(Qn);for(const o of await caches.keys())o.startsWith(Qo)&&await caches.delete(o)}catch{}return this.denoiser?.postMessage({type:"forget"}),this.fetchState.phase!=="ready"&&this.setFetch({phase:"idle",got:0,total:null}),this.denoiserStatus();case"load_prefs":return this.loadPrefs();case"save_prefs":{this.prefs={...this.prefs??{},...s.prefs},this.storePrefs();const o=await this.enqueue("sanitise_prefs",0,{args:{prefs:s.prefs}});return this.prefs=o,this.storePrefs(),o}case"reset_prefs":{const o=await this.loadPrefs();return this.prefs=await this.enqueue("reset_prefs",0,{args:{prefs:o}}),this.storePrefs(),this.prefs}case"third_party_notices":{const a=(await Promise.all(["STUDIO_THIRD_PARTY.md","THIRD_PARTY.md"].map(i=>fetch(new URL(i,this.base())).then(r=>r.ok?r.text():null,()=>null)))).filter(i=>!!i);if(!a.length)throw new Error("the notices could not be fetched");return a.join(`
4
 
5
 
6
- `)}case"check_update":return{latest:null,newer:!1,url:"https://github.com/logolabs/inkvec/releases",offline:"a web page is always the version it is served as"};case"cli_status":case"context_menu_status":case"install_cli":case"remove_cli":case"install_context_menu":case"remove_context_menu":return{available:!1,installed:!1,path:null,note:es}}throw new Error(`${t} is not something the browser build does`)}bump(){return this.generation++,this.shared&&Atomics.store(this.shared,0,this.generation),this.generation}async open(t,s){return this.source={bytes:t.slice(),name:s},this.bump(),this.queue=this.queue.filter(o=>o.kind?(o.resolve(null),!1):!0),this.supersede(!0),this.enqueue("open_bytes",0,{bytes:t,name:s})}async loadPrefs(){if(this.prefs)return this.prefs;let t=null;try{const s=localStorage.getItem(Kn);t=s?JSON.parse(s):null}catch{t=null}return this.prefs=await(t?this.enqueue("sanitise_prefs",0,{args:{prefs:t}}):this.enqueue("default_prefs",0,{args:{}})),this.prefs}rememberTrace(t){if(!this.prefs)return;const s={...t};delete s.colourGroups,this.prefs={...this.prefs,trace:s},window.clearTimeout(this.prefsTimer),this.prefsTimer=window.setTimeout(()=>this.storePrefs(),1e3)}storePrefs(){try{localStorage.setItem(Kn,JSON.stringify(this.prefs))}catch{}}startDenoiser(t,s){if(this.denoiser||!this.denoiserPort)return;const o=new Worker(new URL(""+new URL("denoiser.worker-DjPuHhk4.js",import.meta.url).href,import.meta.url),{type:"module",name:"inkvec-denoiser"});this.denoiser=o,o.onmessage=a=>void this.denoiserMessage(a.data),o.postMessage({type:"init",base:this.base(),token:"05758cc93999",url:t,sha256:s,port:this.denoiserPort},[this.denoiserPort])}setFetch(t){this.fetchState={...this.fetchState,retrace:void 0,...t},this.emit("denoiser:fetch",this.fetchState)}get denoiserFetch(){return this.fetchState}async denoiserMessage(t){const s=this.fetchState.phase;switch(t.type){case"progress":if(s==="preparing"||s==="ready")return;this.setFetch({phase:"downloading",got:t.got??0,total:t.total??null,message:void 0,saveData:void 0}),this.downloading&&this.emit("denoiser:progress",{got:t.got,total:t.total});return;case"stored":{if(s==="preparing"||s==="ready")return;const o=this.fetchState.total??this.fetchState.got;this.setFetch({phase:"stored",got:o,total:o,message:void 0}),this.downloading&&(this.downloading=!1,this.emit("denoiser:done",{ok:!0,status:await this.denoiserStatus()}));return}case"preparing":this.setFetch({phase:"preparing",message:void 0});return;case"ran":this.denoiserRuns++;return;case"loaded":{const o=this.wanted;this.wanted=!1,this.setFetch({phase:"ready",message:void 0,retrace:o});return}case"failed":{const o=t.message??"the download did not finish";if(this.cancelled||/abort/i.test(o)){this.cancelled=!1,this.setFetch({phase:"idle",message:void 0});return}this.setFetch({phase:"failed",message:o}),this.downloading&&(this.downloading=!1,this.emit("denoiser:done",{ok:!1,message:o,status:await this.denoiserStatus()})),t.during==="download"&&!this.retried&&(this.retried=!0,window.setTimeout(()=>{this.fetchState.phase==="failed"&&this.denoiser?.postMessage({type:this.wanted?"prepare":"prefetch"})},ea));return}}}prefetchDenoiser(){if(navigator.connection?.saveData){this.setFetch({phase:"idle",saveData:!0});return}this.denoiser?.postMessage({type:"prefetch"})}withoutUnreadyDenoiser(t){const s=t.settings?.cleanUpDamage;return!s||s==="off"||!this.denoiser||this.fetchState.phase==="ready"?t:(this.wanted=!0,this.cancelled=!1,this.denoiser.postMessage({type:"prepare"}),{...t,settings:{...t.settings,cleanUpDamage:"off"}})}async denoiserStatus(){const t=await this.whenReady();let s=!1,o=null;try{const a=await(await caches.open(Qn)).match(t.denoiserUrl);a&&(s=!0,o=Number(a.headers.get("content-length"))||(await a.blob()).size)}catch{}return{supported:t.isolated,installed:s,path:null,bytes:o,repo:t.denoiserRepo,sha256:t.denoiserSha256}}async downloadDenoiser(){if(await this.whenReady(),!this.denoiser)throw new Error("The denoiser needs a cross-origin isolated page.");return this.downloading=!0,this.cancelled=!1,this.denoiser.postMessage({type:this.wanted?"prepare":"download"}),null}}function sa(e,t){const s=o=>{const a={...o?.settings??{}};return delete a.minify,delete a.margin,JSON.stringify(Object.keys(a).sort().map(i=>[i,a[i]]))};return s(e)===s(t)}let dt=null;function Ns(){return dt||(dt=new na,globalThis.__inkvecStudioLite=dt),dt}function R(e,t){return Ns().invoke(e,t)}function ve(e,t){return Ns().listen(e,t)}const B={capabilities:()=>R("capabilities"),startupProgress:(e,t)=>R("startup_progress",{text:e,progress:t}),appReady:()=>R("app_ready"),openPath:e=>R("open_path",{path:e}),openBytes:(e,t)=>R("open_bytes",{bytes:e,name:t??null}),openSample:e=>R("open_sample",{name:e}),listSamples:()=>R("list_samples"),startTrace:(e,t)=>R("start_trace",{request:{settings:e,tier:t}}),cancelTrace:()=>R("cancel_trace"),startPreview:e=>R("start_preview",{request:{settings:e,tier:"draft"}}),cancelPreviews:()=>R("cancel_previews"),sourceFacts:e=>R("source_facts",{maxDim:e}),launchPath:()=>R("launch_path"),traceBands:e=>R("trace_bands",{generation:e}),snapInks:(e,t,s,o)=>R("snap_inks",{svg:e,snaps:t,width:s,height:o}),matchPalette:(e,t)=>R("match_palette",{traced:e,pasted:t}),planExport:e=>R("plan_export",{request:e}),writeExport:(e,t)=>R("write_export",{request:e,destination:t}),minify:(e,t)=>R("minify_svg",{svg:e,settings:t}),fabAnalyze:e=>R("fab_analyze",{svg:e}),fabPrepare:(e,t)=>R("fab_prepare",{svg:e,options:t}),readTextFile:e=>R("read_text_file",{path:e}),saveBytes:(e,t)=>R("save_bytes",{path:e,bytes:t}),batchScan:e=>R("batch_scan",{folder:e}),batchStart:e=>R("batch_start",{plan:e}),batchPause:e=>R("batch_pause",{paused:e}),batchCancel:()=>R("batch_cancel"),batchStatsCsv:()=>R("batch_stats_csv"),denoiserStatus:()=>R("denoiser_status"),denoiserDownload:()=>R("denoiser_download"),denoiserCancel:()=>R("denoiser_cancel"),denoiserRemove:()=>R("denoiser_remove"),loadPrefs:()=>R("load_prefs"),savePrefs:e=>R("save_prefs",{prefs:e}),resetPrefs:()=>R("reset_prefs"),thirdPartyNotices:()=>R("third_party_notices"),checkUpdate:()=>R("check_update"),cliStatus:()=>R("cli_status"),installCli:()=>R("install_cli"),removeCli:()=>R("remove_cli"),contextMenuStatus:()=>R("context_menu_status"),installContextMenu:()=>R("install_context_menu"),removeContextMenu:()=>R("remove_context_menu")},ke={traceProgress:e=>ve("trace:progress",t=>e(t.payload)),traceDone:e=>ve("trace:done",t=>e(t.payload)),previewDone:e=>ve("preview:done",t=>e(t.payload)),openPath:e=>ve("open:path",t=>e(t.payload)),batchRow:e=>ve("batch:row",t=>e(t.payload)),batchTotals:e=>ve("batch:totals",t=>e(t.payload)),batchFinished:e=>ve("batch:finished",t=>e(t.payload)),denoiserProgress:e=>ve("denoiser:progress",t=>e(t.payload)),denoiserDone:e=>ve("denoiser:done",t=>e(t.payload)),denoiserFetch:e=>ve("denoiser:fetch",t=>e(t.payload))};function oa(e,t){return{caps:null,prefs:null,tab:"vectorize",screen:null,source:null,settings:e,preset:"logo",generation:0,tracing:!1,tracingTier:"final",liveStages:[],traceStarted:0,traceEnded:0,liveNow:null,traceLog:[],logOpen:!0,result:null,resultGeneration:0,bandsMissing:!1,previous:null,svg:null,palette:[],snaps:[],colourGroups:[],groupSuggestions:null,resultGroups:[],dismissedGroups:[],simplifyTo:null,paletteSelection:[],hoverFill:null,losses:[],report:null,worstCorner:null,stageState:{kind:"empty"},justSwapped:!1,view:"side",show:{fill:!0,wireframe:!1,anchors:!1,handles:!1,certainty:!1},zoom:1,pan:{x:0,y:0},fitted:!0,flicked:!1,wipe:.5,detail:!1,railTab:"result",groupsOpen:{Detail:!0,Colour:!0,Shape:!0,Output:!1},exportOpen:!1,dragging:!1,minify:{name:null,before:null,settings:t,result:null,error:null},fab:{name:null,svg:null,analysis:null,options:Is(),plan:null,error:null,shown:-1,unit:"mm",showProblems:!0,preset:null,dxf:!1,gcode:!1},batch:{folder:null,outputDir:null,preset:"logo",skipExisting:!0,rows:[],totals:null,running:!1,paused:!1,failuresFirst:!1},update:null,denoiserFetch:null,auto:null,facts:null,chooser:!1,wizard:null,compare:null,autoNoteHidden:!1}}function Is(){return{mode:"singleColour",widthMm:100,include:[],order:[],bleedMm:.8,minFeatureMm:.8,removeThin:!1,stickerMarginMm:3,bridgeMm:1.5,stencilMarginMm:10,maxLineMm:0,penMm:.4,registration:!0,weedBorderMm:0,mirror:!1,cutStyle:"filled",sizeCheckMm:0,dogboneMm:0,gcodeFeedMmMin:1e3,gcodePower:1e3,gcodePasses:1,fileUnits:"mm",kerfMm:0,toleranceMm:.05,mergeDeltaE:3}}class aa{constructor(t){Y(this,"listeners",new Set);this.state=t}set(t){const s=new Set;for(const[o,a]of Object.entries(t))this.state[o]!==a&&(this.state[o]=a,s.add(o));s.size&&this.emit(s)}touch(...t){this.emit(new Set(t))}on(t,s){const o=new Set(t),a=i=>{for(const r of i)if(o.has(r)){s();return}};return this.listeners.add(a),()=>this.listeners.delete(a)}emit(t){for(const s of[...this.listeners])s(t)}}function oe(e){return e.toLocaleString("en-US")}function ie(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function re(e){return e==null?"—":e.toFixed(2)}function nt(e){return e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`}function bn(e,t){if(!e.source)return null;const s=Math.max(e.source.width,e.source.height),o=t==="draft"?Math.min(e.prefs?.draftPx??512,e.settings.traceSize):e.settings.traceSize;return Math.min(o,s)}function it(e,t){const s=t.mode==="fast"&&!t.blackAndWhite&&!t.lineArt;return e.modes==="qualityOnly"?!s:e.modes==="fastOnly"?s:!0}function $e(e,t=0){return`${(e*100).toFixed(t)}%`}function ia(e){const t=Math.max(0,Math.round(e));return t<60?`${t} s`:`${Math.floor(t/60)} min ${t%60} s`}function Os(e){return e==="macos"?"⌘":"Ctrl"}function ra(){return{preset:"logo",tab:"vectorize",railTab:"result",groupsOpen:{},view:"side",wipe:.5,show:{fill:!0,wireframe:!1,anchors:!1,handles:!1,certainty:!1},detail:!1,export:null,minify:null,minifyBackdrop:"auto",minifyView:"side",fab:null,fabUnit:"mm",fabShowProblems:!0,fabPreset:null,fabDxf:!1,fabGcode:!1,batchPreset:null,batchSkipExisting:!0,batchFailuresFirst:!1}}const Ce={export:null,minifyBackdrop:"auto",minifyView:"side"};let ln=()=>{};function la(){return{...Ce}}function cn(e){Object.assign(Ce,e),ln()}function ca(e){const t=Ce.export;return t?{...e,...t,pngSizes:[...t.pngSizes??e.pngSizes]}:e}function un(e){const t={...e.fab.options};return delete t.include,delete t.order,{preset:e.preset,tab:e.tab,railTab:e.railTab,groupsOpen:{...e.groupsOpen},view:e.view,wipe:e.wipe,show:{...e.show},detail:e.detail,export:Ce.export,minify:{...e.minify.settings},minifyBackdrop:Ce.minifyBackdrop,minifyView:Ce.minifyView,fab:t,fabUnit:e.fab.unit,fabShowProblems:e.fab.showProblems,fabPreset:e.fab.preset,fabDxf:e.fab.dxf,fabGcode:e.fab.gcode,batchPreset:e.batch.preset,batchSkipExisting:e.batch.skipExisting,batchFailuresFirst:e.batch.failuresFirst}}function dn(e){const t={...e};return delete t.colourGroups,t}function ua(e,t,s,o){const a=e.state,i={...ra(),...t.ui??{}};Ce.export=i.export,Ce.minifyBackdrop=i.minifyBackdrop,Ce.minifyView=i.minifyView,e.set({preset:i.preset&&o(i.preset)?i.preset:null,tab:s.includes(i.tab)?i.tab:"vectorize",railTab:i.railTab,groupsOpen:{...a.groupsOpen,...i.groupsOpen},view:i.view,wipe:i.wipe,show:{...a.show,...i.show},detail:i.detail,minify:{...a.minify,settings:{...a.minify.settings,...i.minify??{}}},fab:{...a.fab,options:{...Is(),...i.fab??{},include:[],order:[]},unit:i.fabUnit,showProblems:i.fabShowProblems,preset:i.fabPreset,dxf:i.fabDxf,gcode:i.fabGcode},batch:{...a.batch,preset:i.batchPreset&&o(i.batchPreset)?i.batchPreset:a.batch.preset,skipExisting:i.batchSkipExisting,failuresFirst:i.batchFailuresFirst}})}const da=["settings","preset","tab","railTab","groupsOpen","view","wipe","show","detail","minify","fab","batch"];function pa(e,t,s=500){let o=0,a=JSON.stringify({ui:un(e.state),trace:dn(e.state.settings)});const i=()=>{if(window.clearTimeout(o),o=0,!e.state.prefs)return;const c={ui:un(e.state),trace:dn(e.state.settings)},d=JSON.stringify(c);d!==a&&(a=d,t(c))};ln=()=>{window.clearTimeout(o),o=window.setTimeout(i,s)};const r=e.on(da,ln),l=()=>{document.visibilityState==="hidden"&&o&&i()};return window.addEventListener("pagehide",i),document.addEventListener("visibilitychange",l),()=>{r(),window.removeEventListener("pagehide",i),document.removeEventListener("visibilitychange",l)}}const ha="modulepreload",fa=function(e,t){return new URL(e,t).href},ns={},ga=function(t,s,o){let a=Promise.resolve();if(s&&s.length>0){let r=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const l=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),d=c?.nonce||c?.getAttribute("nonce");a=r(s.map(p=>{if(p=fa(p,o),p in ns)return;ns[p]=!0;const h=p.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!o)for(let b=l.length-1;b>=0;b--){const x=l[b];if(x.href===p&&(!h||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${p}"]${f}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":ha,h||(g.as="script"),g.crossOrigin="",g.href=p,d&&g.setAttribute("nonce",d),document.head.appendChild(g),h)return new Promise((b,x)=>{g.addEventListener("load",b),g.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return a.then(r=>{for(const l of r||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};async function ma(e={}){return typeof e=="object"&&Object.freeze(e),await Dt("plugin:dialog|open",{options:e})}async function ba(e={}){return typeof e=="object"&&Object.freeze(e),await Dt("plugin:dialog|save",{options:e})}async function ya(e,t){await Dt("plugin:opener|open_url",{url:e,with:t})}async function wa(e){return Dt("plugin:opener|reveal_item_in_dir",{paths:typeof e=="string"?[e]:e})}const Ft="Inkvec Studio Lite",_s="https://github.com/logolabs/inkvec/releases",va="Inkvec Studio for Windows, macOS and Linux: the native engine is faster, it traces whole folders in one batch, has no browser memory limit (traces up to 16384 px), and works offline.";function Bs(e){return{name:e.name||"pasted image",path:null,file:e}}async function yn(e,t=!1){return new Promise(s=>{const o=document.createElement("input");o.type="file",o.multiple=t,o.accept=e.flatMap(r=>r.extensions.map(l=>`.${l}`)).join(","),o.style.display="none";let a=!1;const i=r=>{a||(a=!0,o.remove(),s(r))};o.addEventListener("change",()=>i([...o.files??[]].map(Bs))),o.addEventListener("cancel",()=>i([])),document.body.append(o),o.click()})}async function Ct(e){if(e.file)return e.file.text();if(e.path)return B.readTextFile(e.path);throw new Error("nothing to read")}const ss=!1;async function Rs(e,t,s){const o=typeof t=="string"?new TextEncoder().encode(t):t;return Re(e,o),{path:null,name:e}}async function xa(e,t,s){const o=new TextEncoder,a=i=>typeof i=="string"?o.encode(i):i;{if(e.length===1)Re(e[0].name,a(e[0].data));else{const{zipStore:i}=await ga(async()=>{const{zipStore:r}=await import("./zip-DlX9-WSC.js");return{zipStore:r}},[],import.meta.url);Re(t,i(e.map(r=>({name:r.name,data:a(r.data)}))))}return{folder:null,first:null}}}const ka=!1;async function Nt(e){await navigator.clipboard.writeText(e)}async function It(e){{window.open(e,"_blank","noopener,noreferrer");return}}function Ot(e){return e&&ka?{label:"Show in folder",run:()=>void 0}:void 0}function Pe(e){const t={...e,cleanUpDamage:"off"};return JSON.stringify(Object.keys(t).sort().map(s=>[s,t[s]]))}class Sa{constructor(){Y(this,"results",new Map);Y(this,"queue",[]);Y(this,"running",null);Y(this,"epoch",0);Y(this,"early",new Map);Y(this,"listeners",new Set);ke.previewDone(({generation:t,outcome:s})=>this.done(t,s))}get(t){return this.results.get(t)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}want(t){const s=new Set,o=t.filter(a=>{if(s.has(a.key))return!1;s.add(a.key);const i=this.results.get(a.key)?.state;return i!=="done"&&i!=="running"});if(o.map(a=>a.key).join(`
7
  `)!==this.queue.map(a=>a.key).join(`
8
  `)){for(const a of this.queue)this.results.get(a.key)?.state==="queued"&&this.results.delete(a.key);this.queue=o;for(const a of this.queue)this.results.set(a.key,{state:"queued"});this.emit(),this.next()}}pause(){this.want([])}reset(){this.epoch++;for(const t of this.results.values())t.state==="done"&&URL.revokeObjectURL(t.url);this.results.clear(),this.queue=[],this.early.clear(),this.running&&B.cancelPreviews().catch(()=>{}),this.running=null,this.emit()}pending(){return this.queue.length+(this.running?1:0)}next(){if(this.running)return;const t=this.queue.shift();if(!t)return;const s=this.epoch;this.running={key:t.key,generation:null,epoch:s},this.results.set(t.key,{state:"running"}),this.emit(),B.startPreview(t.settings).then(o=>{if(this.running?.epoch!==s||this.running.key!==t.key)return;this.running.generation=o;const a=this.early.get(o);a&&(this.early.delete(o),this.done(o,a))},o=>{this.running?.epoch===s&&this.finish(t.key,{state:"failed",message:String(o)})})}done(t,s){const o=this.running;if(o){if(o.generation===null){this.early.set(t,s);return}if(o.generation===t)if(s.state==="traced"){const a=URL.createObjectURL(new Blob([s.svg],{type:"image/svg+xml"}));this.finish(o.key,{state:"done",svg:s.svg,url:a,report:s.report})}else{const a="message"in s?s.message:s.state==="flat"?"one flat colour":s.state==="cancelled"?"stopped":"out of memory";this.finish(o.key,{state:"failed",message:a})}}}finish(t,s){this.results.set(t,s),this.running=null,this.emit(),this.next()}emit(){for(const t of[...this.listeners])t()}}const os=400;function $a(e,t,s){let o=e.liveStages,a=e.liveNow;const i=[...e.traceLog],r=c=>{for(let d=i.length-1;d>=0;d--){const p=i[d];if(p.kind==="stage")return p.what===c&&p.ms===void 0?d:-1}return-1};for(const c of t.entries)if(c.kind==="begin")a={stage:c.stage,what:c.what,since:s,step:null},i.push({at:c.at,kind:"stage",stage:c.stage,what:c.what});else if(c.kind==="end"){if(c.stage!=="measure"){const p=o.findIndex(h=>h.name===c.stage);o=p>=0?o.map((h,f)=>f===p?{...h,ms:h.ms+c.ms}:h):[...o,{name:c.stage,ms:c.ms}]}const d=r(c.what);d>=0?i[d]={...i[d],ms:c.ms,step:i[d].step??null}:i.push({at:Math.max(0,c.at-c.ms),kind:"stage",stage:c.stage,what:c.what,ms:c.ms}),a&&a.what===c.what&&(a=null)}else i.push({at:c.at,kind:"note",stage:c.stage,what:c.what,text:c.text});const l=t.step;if(l){!a||a.what!==l.what?a={stage:l.stage,what:l.what,since:s,step:l}:a={...a,step:l};const c=r(l.what);c>=0&&(i[c]={...i[c],step:l})}return{liveStages:o,liveNow:a,traceLog:i.length>os?i.slice(i.length-os):i}}function wn(e){return e.total>0?`${e.done} / ${e.total} ${e.unit}`:`${e.unit} ${e.done}`}function Ge(e){const t=Math.max(0,e)/1e3;return t<60?`${t.toFixed(1)} s`:`${Math.floor(t/60)} min ${String(Math.floor(t%60)).padStart(2,"0")} s`}function as(e){return`${(Math.max(0,e)/1e3).toFixed(2)}`}function Ma(e,t,s){let o=0;const a=()=>{const r=performance.now(),l=t(),c=s();for(const d of document.querySelectorAll('[data-live="elapsed"]'))d.textContent=Ge(r-l);for(const d of document.querySelectorAll('[data-live="stage"]'))d.textContent=c===null?"":Ge(r-c)},i=()=>{e()&&!o?(a(),o=window.setInterval(a,100)):!e()&&o&&(window.clearInterval(o),o=0)};return()=>{i(),o&&a()}}function _t(e){const t=e.liveNow;if(t){const s=t.stage==="measure"?"measuring":t.stage;return t.step?`${s} · ${wn(t.step)}`:`${s} · ${t.what}`}return e.liveStages[e.liveStages.length-1]?.name??"starting"}function Bt(e){return Ge(performance.now()-e.traceStarted)}const vn=()=>document.getElementById("overlays"),Ca=()=>document.getElementById("toasts");function W(e,t={}){const s=t.kind??"plain",o=s==="good"?"checkCircle":s==="bad"?"alert":"info",a=n("div.toast",{role:"status"},n(`span.glyph.${s}`,null,Z(o,16)),n("span.text",null,e),t.action&&n("button",{class:"reset",onclick:()=>{t.action?.run(),a.remove()}},t.action.label));Ca().append(a),window.setTimeout(()=>a.remove(),6e3)}function ue(){F(vn()),document.removeEventListener("keydown",xn,!0)}function xn(e){e.key==="Escape"&&(e.stopPropagation(),ue())}function Ye(e){const t=n("div.scrim",{onmousedown:s=>{s.target===t&&ue()}});e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),t.append(e),F(vn(),t),document.addEventListener("keydown",xn,!0),(e.querySelector("button, input, [tabindex]")??e).focus()}function Rt(e,t,s=[]){return n("div.modal",{tabindex:"-1"},n("h2",null,e),...t.filter(Boolean).map(o=>typeof o=="string"?n("p",null,o):o),s.length?n("div.actions",null,...s):null)}function kn(e,t){const s=n("div.popover",null,t),o=n("div",{style:{position:"fixed",inset:"0",zIndex:"44"},onmousedown:ue});F(vn(),o,s),document.addEventListener("keydown",xn,!0);const a=e.getBoundingClientRect(),i=s.getBoundingClientRect(),r=8,l=Math.min(Math.max(r,a.left),window.innerWidth-i.width-r),c=a.bottom+6,d=c+i.height+r>window.innerHeight?a.top-i.height-6:c;s.style.left=`${Math.round(l)}px`,s.style.top=`${Math.round(Math.max(r,d))}px`,(s.querySelector("button, input, [tabindex]")??s).focus?.()}let _e=null,Sn=0;function st(){window.cancelAnimationFrame(Sn),_e?.node.remove(),_e=null}function Gs(){const e=_e;if(!e)return;if(!(e.el.isConnected&&(e.el.matches(":hover")||e.el.matches(":focus-visible")))){st();return}Sn=window.requestAnimationFrame(Gs)}function Fe(e,t){let s=0;const o=()=>{if(!e.isConnected||_e?.el===e)return;st();const i=n("div.tooltip",{role:"tooltip"},t);document.body.append(i);const r=e.getBoundingClientRect(),l=i.getBoundingClientRect(),c=Math.min(Math.max(8,r.left),window.innerWidth-l.width-8),d=r.top-l.height-8;i.style.left=`${Math.round(c)}px`,i.style.top=`${Math.round(d<8?r.bottom+8:d)}px`,_e={node:i,el:e},Sn=window.requestAnimationFrame(Gs)},a=()=>{window.clearTimeout(s),_e?.el===e&&st()};return e.addEventListener("pointerenter",()=>{window.clearTimeout(s),s=window.setTimeout(o,350)}),e.addEventListener("pointerleave",a),e.addEventListener("pointerdown",a),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&o()}),e.addEventListener("blur",a),e}document.addEventListener("keydown",e=>{e.key==="Escape"&&_e&&st()},!0);window.addEventListener("blur",st);function Ta(e,t,s,o,a=!1){Ye(Rt(e,[t],[n("button.btn",{onclick:ue},"Cancel"),n(`button.btn.primary${a?".danger":""}`,{onclick:()=>{ue(),o()}},s)]))}function Ws(e){const t=e.trim().replace(/^#/,""),s=t.length===3?[...t].map(o=>o+o).join(""):t;return/^[0-9a-fA-F]{6}$/.test(s)?[0,2,4].map(o=>parseInt(s.slice(o,o+2),16)/255):null}function qs([e,t,s]){const o=g=>g<=.04045?g/12.92:((g+.055)/1.055)**2.4,[a,i,r]=[o(e),o(t),o(s)],l=(.4124564*a+.3575761*i+.1804375*r)/.95047,c=.2126729*a+.7151522*i+.072175*r,d=(.0193339*a+.119192*i+.9503041*r)/1.08883,p=g=>g>216/24389?Math.cbrt(g):(24389/27*g+16)/116,[h,f,u]=[p(l),p(c),p(d)];return[116*f-16,500*(h-f),200*(f-u)]}function Aa(e,t){const[s,o,a]=e,[i,r,l]=t,c=Math.PI/180,d=Math.hypot(o,a),p=Math.hypot(r,l),h=((d+p)/2)**7,f=.5*(1-Math.sqrt(h/(h+25**7))),u=(1+f)*o,g=(1+f)*r,b=Math.hypot(u,a),x=Math.hypot(g,l),M=(pe,Te)=>{if(pe===0&&Te===0)return 0;const fe=Math.atan2(Te,pe)/c;return fe<0?fe+360:fe},v=M(u,a),S=M(g,l),y=i-s,$=x-b;let C=0;b*x!==0&&(C=S-v,C>180?C-=360:C<-180&&(C+=360));const D=2*Math.sqrt(b*x)*Math.sin(C*c/2),z=(s+i)/2,O=(b+x)/2;let A=v+S;b*x!==0&&(A=Math.abs(v-S)<=180?(v+S)/2:v+S<360?(v+S+360)/2:(v+S-360)/2);const P=1-.17*Math.cos((A-30)*c)+.24*Math.cos(2*A*c)+.32*Math.cos((3*A+6)*c)-.2*Math.cos((4*A-63)*c),J=30*Math.exp(-(((A-275)/25)**2)),H=O**7,X=2*Math.sqrt(H/(H+25**7)),se=1+.015*(z-50)**2/Math.sqrt(20+(z-50)**2),ee=1+.045*O,Q=1+.015*O*P,j=-Math.sin(2*J*c)*X,ne=y/se,ae=$/ee,te=D/Q;return Math.sqrt(ne*ne+ae*ae+te*te+j*ae*te)}function Tt(e){return e.kind==="gradient"&&e.stops.length>1?e.stops.map(t=>t.toLowerCase()).join(">"):e.traced.toLowerCase()}function qe(e){return e.split(">").map(t=>t.trim().toLowerCase())}function rt(e){return e.includes(">")}function $n(e,t=!1){const s=qe(e);return s.length<2?s[0]??"transparent":t?`radial-gradient(circle, ${s.join(", ")})`:`linear-gradient(90deg, ${s.join(", ")})`}const pt=new Map;function is(e){const t=pt.get(e);if(t)return t;const s=Ws(e);if(!s)return null;const o=qs(s);return pt.size>4096&&pt.clear(),pt.set(e,o),o}function Mn(e,t){const s=qe(e).map(is),o=qe(t).map(is);if(s.some(l=>!l)||o.some(l=>!l)||!s.length||!o.length)return 1/0;const a=s,i=o,r=(l,c)=>l.reduce((d,p)=>d+Math.min(...c.map(h=>Aa(p,h))),0)/l.length;return Math.max(r(a,i),r(i,a))}const Ea=2;function Gt(e,t){const s=rt(e),o=t.find(r=>Tt(r)===e);if(o)return o;let a=null,i=Ea;for(const r of t){if(r.kind==="gradient"!==s)continue;const l=Mn(e,Tt(r));l<=i&&(i=l,a=r)}return a}function Se(e,t){return e===t||Mn(e,t)<.5}const za=2,La=240;function Pa(e,t={}){const s=t.skip??[],o=e.filter(p=>p.share>0),a=[...o].sort((p,h)=>h.share-p.share).slice(0,La).map(p=>({member:Tt(p),share:p.share})).filter(p=>!s.some(h=>Se(h,p.member))),i=a.length;if(i<2)return[];const r=a.map((p,h)=>a.map((f,u)=>h===u?0:Mn(p.member,f.member))),l=a.map((p,h)=>[h]);let c=i;const d=t.count?Math.max(1,Math.round(t.count)-(o.length-i)):null;for(;!(d!==null&&c<=d);){let p=1/0,h=-1,f=-1;for(let u=0;u<i;u++)if(l[u])for(let g=u+1;g<i;g++)l[g]&&r[u][g]<p&&(p=r[u][g],h=u,f=g);if(h<0||d===null&&p>za)break;l[h]=[...l[h],...l[f]],l[f]=null,c--;for(let u=0;u<i;u++){if(u===h||!l[u])continue;const g=Math.max(r[h][u],r[f][u]);r[h][u]=g,r[u][h]=g}}return l.filter(Boolean).filter(p=>p.length>1).map(p=>p.map(h=>a[h]).sort((h,f)=>f.share-h.share)).sort((p,h)=>h.reduce((f,u)=>f+u.share,0)-p.reduce((f,u)=>f+u.share,0)).map(p=>({members:p.map(h=>h.member),target:null}))}function Cn(e){return[...e.members].sort().join(",")}function Da(e){return e.filter(t=>t.trimStart().startsWith("merge colors")).map(t=>{const s=t.trim().replace(/^merge colors\s+/,""),o=/;\s*(?:not found in the trace:|no ink near)\s*(.*)$/.exec(s),a=(o?.[1]??"").split(",").map(i=>i.trim().toLowerCase()).filter(i=>/^#[0-9a-f]{6}(>#[0-9a-f]{6})*$/.test(i));return{line:o?s.slice(0,o.index).trim():s,unmatched:a,leftAlone:s.startsWith("group left alone")}})}function Fa(e,t){return e?e.unmatched.some(s=>s===t||qe(t).includes(s)||Se(s,t)):!1}function Hs(e){const t=(e.groupSuggestions??[]).filter(a=>a.edited),s=[...e.colourGroups.flatMap(a=>a.members),...t.flatMap(a=>a.members)],o=Pa(e.palette,{count:e.simplifyTo,skip:s}).filter(a=>!e.dismissedGroups.includes(Cn(a)));return[...t,...o]}function Na(e,t){const s=e.members.filter(a=>Gt(a,t));if(s.length<2)return null;let o=e.target;if(o?.startsWith("@")){const a=e.members[Number(o.slice(1))-1],i=a?s.indexOf(a):-1;o=i>=0?`@${i+1}`:null}return{...e,members:s,target:o}}function Tn(e){return(e.groupSuggestions??[]).map((t,s)=>({g:Na(t,e.palette),index:s})).filter(t=>t.g!==null)}function Us(e,t){let s=e.target;if(s?.startsWith("@")){const o=Number(s.slice(1))-1;s=o===t?null:o>t?`@${o}`:s}return{...e,members:e.members.filter((o,a)=>a!==t),target:s}}function be(e,t,s=-1,o=!1){return e.map((a,i)=>{if(i===s)return a;const r=a.members.findIndex(l=>Se(l,t));return r<0?a:{...Us(a,r),...o?{edited:!0}:{}}})}const He=e=>e.filter(t=>t.members.length>1);function Ia(e,t,s,o,a){const i=e.state;let r=i.colourGroups.map(f=>({...f,members:[...f.members]})),l=(i.groupSuggestions??[]).map(f=>({...f,members:[...f.members]}));const c=a?.closest("[data-drop]")??null,d=c?.dataset.drop??null,p=Number(c?.dataset.index??-1);if((d==="group"||d==="sugg")&&o.kind===d&&o.index===p||d==="ink"&&Se(c?.dataset.member??"",s))return;if(d==="group")r=be(r,s,p),l=be(l,s,-1,!0),r[p].members.some(f=>Se(f,s))||r[p].members.push(s);else if(d==="sugg")r=be(r,s),l=be(l,s,p,!0),l[p].members.some(f=>Se(f,s))||(l[p]={...l[p],members:[...l[p].members,s],edited:!0});else if(d==="ink"){const f=c?.dataset.member??"";r=be(r,s),l=be(l,s,-1,!0);const u=r.findIndex(g=>g.members.some(b=>Se(b,f)));u>=0?r[u].members.push(s):(l=be(l,f,-1,!0),r.push({members:[f,s],target:null}))}else{if(o.kind==="palette")return;o.kind==="group"?r=be(r,s):l=be(l,s,-1,!0)}const h=He(r);e.set({groupSuggestions:He(l),paletteSelection:[]}),JSON.stringify(h)!==JSON.stringify(i.colourGroups)&&t.setColourGroups(h)}function Oa(e,t){const s=e.state,o=s.paletteSelection;if(o.length<2)return;let a=s.colourGroups.map(l=>({...l,members:[...l.members]}));const i=a.findIndex(l=>l.members.some(c=>o.some(d=>Se(d,c))));let r=s.groupSuggestions??[];for(const l of o)a=be(a,l,i),r=be(r,l,-1,!0);if(i>=0)for(const l of o)a[i].members.some(c=>Se(c,l))||a[i].members.push(l);else a.push({members:[...o],target:null});e.set({groupSuggestions:He(r),paletteSelection:[]}),t.setColourGroups(He(a))}const _a=4;function js(e,t,s,o,a,i){e.addEventListener("pointerdown",r=>{if(r.button!==0)return;const l=r.clientX,c=r.clientY;let d=null,p=null;const h=g=>{g!==p&&(p?.classList.remove("dropping"),p=g,p?.classList.add("dropping"))},f=g=>{if(!d){if(Math.hypot(g.clientX-l,g.clientY-c)<_a)return;d=n("div.dragghost",null,n("span.swatch",null,n("i",{style:{background:$n(o,i)}}))),document.body.append(d),document.body.classList.add("dragging-ink")}d.style.left=`${g.clientX+8}px`,d.style.top=`${g.clientY+8}px`;const b=document.elementFromPoint(g.clientX,g.clientY);h(b?.closest("[data-drop]")??null)},u=g=>{if(window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u),!d)return;d.remove(),document.body.classList.remove("dragging-ink"),h(null);const b=x=>x.stopPropagation();window.addEventListener("click",b,!0),window.setTimeout(()=>window.removeEventListener("click",b,!0),0),g.type!=="pointercancel"&&Ia(t,s,o,a,document.elementFromPoint(g.clientX,g.clientY))};window.addEventListener("pointermove",f),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u)})}function ht(e,t){return Gt(e,t)?.keys??[]}function Vs(e,t){let s=0;const o=()=>{let i=[...e.querySelectorAll("[data-fill]:hover")].pop()??null;if(!i){const l=document.activeElement;l instanceof HTMLElement&&e.contains(l)&&l.matches(":focus-visible")&&(i=l.closest("[data-fill]"))}const r=i?JSON.parse(i.dataset.fill??"[]"):[];return r.length?r:null},a=()=>{const i=o(),r=t.state.hoverFill;(i??[]).join(`
9
  `)!==(r??[]).join(`
 
1
  var No=Object.defineProperty;var Io=(e,t,s)=>t in e?No(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var Y=(e,t,s)=>Io(e,typeof t!="symbol"?t+"":t,s);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))o(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&o(r)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();async function Dt(e,t={},s){return window.__TAURI_INTERNALS__.invoke(e,t,s)}function Oo(){return!!(globalThis||window).isTauri}var Hn;(function(e){e.WINDOW_RESIZED="tauri://resize",e.WINDOW_MOVED="tauri://move",e.WINDOW_CLOSE_REQUESTED="tauri://close-requested",e.WINDOW_DESTROYED="tauri://destroyed",e.WINDOW_FOCUS="tauri://focus",e.WINDOW_BLUR="tauri://blur",e.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",e.WINDOW_THEME_CHANGED="tauri://theme-changed",e.WINDOW_CREATED="tauri://window-created",e.WINDOW_SUSPENDED="tauri://suspended",e.WINDOW_RESUMED="tauri://resumed",e.WEBVIEW_CREATED="tauri://webview-created",e.DRAG_ENTER="tauri://drag-enter",e.DRAG_OVER="tauri://drag-over",e.DRAG_DROP="tauri://drag-drop",e.DRAG_LEAVE="tauri://drag-leave"})(Hn||(Hn={}));var Un;(function(e){e[e.Critical=1]="Critical",e[e.Informational=2]="Informational"})(Un||(Un={}));var jn;(function(e){e.None="none",e.Normal="normal",e.Indeterminate="indeterminate",e.Paused="paused",e.Error="error"})(jn||(jn={}));var Vn;(function(e){e.Disabled="disabled",e.Throttle="throttle",e.Suspend="suspend"})(Vn||(Vn={}));var Yn;(function(e){e.Default="default",e.FluentOverlay="fluentOverlay"})(Yn||(Yn={}));var Zn;(function(e){e.AppearanceBased="appearanceBased",e.Light="light",e.Dark="dark",e.MediumLight="mediumLight",e.UltraDark="ultraDark",e.Titlebar="titlebar",e.Selection="selection",e.Menu="menu",e.Popover="popover",e.Sidebar="sidebar",e.HeaderView="headerView",e.Sheet="sheet",e.WindowBackground="windowBackground",e.HudWindow="hudWindow",e.FullScreenUI="fullScreenUI",e.Tooltip="tooltip",e.ContentBackground="contentBackground",e.UnderWindowBackground="underWindowBackground",e.UnderPageBackground="underPageBackground",e.Mica="mica",e.Blur="blur",e.Acrylic="acrylic",e.Tabbed="tabbed",e.TabbedDark="tabbedDark",e.TabbedLight="tabbedLight"})(Zn||(Zn={}));var Jn;(function(e){e.FollowsWindowActiveState="followsWindowActiveState",e.Active="active",e.Inactive="inactive"})(Jn||(Jn={}));const _o=`<!-- Generated by studio/tools/make_assets.py from web/logo.svg. Do not edit. -->
2
  <svg color="#c9754a" xmlns="http://www.w3.org/2000/svg" viewBox="254.5 140.5 514.25 742.25"><path d="M511.3 140.6c-23.3 79.8-103 178.5-144.9 232.75L335.45 415.4a467.73 467.73 0 00-64.8 115.4c-65.5 193.1 80.8 351.3 237.85 351.7 21.26 1.1 42.56-1.3 63.06-7 90.8-18.87 211.87-120.04 195.47-280.9-17.9-164.8-187.55-272.65-251.8-443.84Zm10.2 374.9a61.05 61.05 0 00-67.1 81.6 61.05 61.05 0 00104.3 17.26 61.05 61.05 0 00-37.2-98.86ZM511.4 817.65l177.16-201.3-43-.15a44.56 44.56 0 00-36.2 18.47l-97.8 111.67-102.2-116.67c-16.06-18.94-38.06-12-74.9-13.4 5.7 7.3 159.75 179.73 176.93 201.4Z" fill="currentColor" fill-rule="evenodd"/></svg>
3
+ `;function n(e,t=null,...s){const[o,...a]=e.split("."),i=document.createElement(o||"div");return a.length&&(i.className=a.join(" ")),Bo(i,t),mn(i,s),i}function xe(e,t=null,...s){const[o,...a]=e.split("."),i=document.createElementNS("http://www.w3.org/2000/svg",o||"g");a.length&&i.setAttribute("class",a.join(" "));for(const[r,l]of Object.entries(t??{}))l==null||l===!1||(r.startsWith("on")&&typeof l=="function"?i.addEventListener(r.slice(2),l):i.setAttribute(r,String(l)));return mn(i,s),i}function Bo(e,t){for(const[s,o]of Object.entries(t??{}))o==null||o===!1||(s==="class"?e.className=e.className?`${e.className} ${o}`:String(o):s==="style"&&typeof o=="object"?Object.assign(e.style,o):s.startsWith("on")&&typeof o=="function"?e.addEventListener(s.slice(2),o):s==="value"&&e instanceof HTMLInputElement?e.value=String(o):o===!0?e.setAttribute(s,""):e.setAttribute(s,String(o)))}function mn(e,t){for(const s of t.flat(8))s==null||s===!1||e.append(s instanceof Node?s:document.createTextNode(String(s)))}function F(e,...t){e.replaceChildren(),mn(e,t)}const Xn={image:"M3 3h18v18H3zM3 15l5-5 4 4 3-3 6 6M8.5 8.5h.01",type:"M4 7V4h16v3M9 20h6M12 4v16",droplet:"M12 2.7 6.7 8a7.5 7.5 0 1 0 10.6 0Z",wand:"m3 21 9-9M15 4V2M15 16v-2M8 9h2M20 9h2M17.8 11.8 19 13M15 9h.01M17.8 6.2 19 5M12.8 6.2 11.6 5",layers:"m12 2 9 5-9 5-9-5 9-5M3 12l9 5 9-5M3 17l9 5 9-5",palette:"M12 21a9 9 0 1 1 0-18c4.97 0 9 3.58 9 8 0 1.66-1.34 3-3 3h-2a2 2 0 0 0-1.6 3.2 2 2 0 0 1-1.6 3.2ZM7.5 10.5h.01M10.5 7.5h.01M14 7.5h.01M16.5 10.5h.01",check:"m20 6-11 11-5-5",checkCircle:"M22 11.1V12a10 10 0 1 1-5.9-9.1M22 4 12 14.01l-3-3",x:"M18 6 6 18M6 6l12 12",alert:"M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0Z",info:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 16v-4M12 8h.01",clock:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM12 6v6l4 2",download:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3",upload:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12",globe:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10Z",copy:"M20 9H11a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2ZM5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",folder:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",settings:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6 1.65 1.65 0 0 0 10 3.09V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1Z",chevronDown:"m6 9 6 6 6-6",chevronRight:"m9 18 6-6-6-6",minus:"M5 12h14",pen:"M21.17 6.81a2.82 2.82 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5Z",square:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Z",crosshair:"M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20ZM22 12h-4M6 12H2M12 6V2M12 22v-4",zap:"M4 14h7l-3 8 12-12h-7l3-8Z",play:"m6 3 14 9-14 9V3Z",pause:"M14 4h4v16h-4zM6 4h4v16H6z",rotate:"M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5",share:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M16 6l-4-4-4 4M12 2v13",file:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7ZM14 2v6h6",maximize:"M8 3H5a2 2 0 0 0-2 2v3M21 8V5a2 2 0 0 0-2-2h-3M3 16v3a2 2 0 0 0 2 2h3M16 21h3a2 2 0 0 0 2-2v-3",external:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"};function Z(e,t=16){const s=Xn[e]??Xn.info;return xe("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",focusable:"false"},xe("path",{d:s}))}function Ds(e=18){const t=Ro.cloneNode(!0);t.removeAttribute("color");const[,,s,o]=(t.getAttribute("viewBox")??"0 0 1 1").split(/\s+/).map(Number);return t.setAttribute("height",String(e)),t.setAttribute("width",String(Math.round(e*s/o))),t.setAttribute("aria-hidden","true"),t.setAttribute("focusable","false"),t}const Ro=(()=>{const e=new DOMParser().parseFromString(_o,"image/svg+xml").documentElement;return document.importNode(e,!0)})();function Go(e,t){let s=0;const o=i=>[...i.dataTransfer?.types??[]].includes("Files"),a=()=>{s=0,e.set({dragging:!1}),document.body.classList.remove("dragging")};window.addEventListener("dragenter",i=>{o(i)&&(s++,e.set({dragging:!0}),document.body.classList.add("dragging"))}),window.addEventListener("dragover",i=>{o(i)&&(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="copy"))}),window.addEventListener("dragleave",i=>{o(i)&&(s=Math.max(0,s-1),s===0&&a())}),window.addEventListener("drop",i=>{if(!o(i))return;i.preventDefault(),a();const r=[...i.dataTransfer?.files??[]];r.length&&t(r)}),Wo(t)}function Wo(e){window.addEventListener("paste",t=>{if(t.target?.closest?.("input, textarea, [contenteditable]"))return;let o=[...t.clipboardData?.files??[]];o.length||(o=[...t.clipboardData?.items??[]].filter(a=>a.kind==="file").map(a=>a.getAsFile()).filter(a=>a!==null)),o.length&&(t.preventDefault(),e(o))})}const qo=760;function Ho(e){const t=window.matchMedia(`(max-width: ${qo}px)`).matches,s=window.matchMedia("(pointer: coarse)").matches;if(!(t&&s))return;const o=n("div.phonenote",{role:"dialog","aria-label":"Best on a larger screen"},n("div.phonecard",null,n("span.serif",{style:{fontSize:"22px"}},"Best on a larger screen"),n("p",null,"Inkvec Studio Lite is a full editor: a viewer, a rail of controls and a palette side by side. On a phone they do not fit. Open this page on a laptop or desktop to use it; everything runs in your browser and nothing is uploaded."),n("button.btn",{onclick:()=>o.remove()},"Continue anyway")));e.append(o)}async function Uo(){const e=new URLSearchParams(window.location.search),t=e.get("sample"),s=e.get("open")==="handoff";return!t&&!s?null:(window.history.replaceState(null,"",window.location.pathname),t?{sample:t}:new Promise(o=>{let a;try{a=indexedDB.open("inkvec-handoff",1)}catch{o(null);return}a.onupgradeneeded=()=>a.result.createObjectStore("files"),a.onerror=()=>o(null),a.onsuccess=()=>{const i=a.result.transaction("files","readwrite").objectStore("files"),r=i.get("open");r.onsuccess=()=>{i.delete("open");const l=r.result;o(l?.bytes?{name:l.name??"image",bytes:l.bytes}:null)},r.onerror=()=>o(null)}}))}let vt=0,Mt=null,rn=0,tt=!1,Fs=performance.now();const Ut=e=>(e/(1024*1024)).toFixed(1);function jo(){rn=0;const e=Mt;if(Mt=null,!e||tt)return;vt=e.fraction;const t=document.getElementById("boot-bar"),s=document.getElementById("boot-fill"),o=document.getElementById("boot-status"),a=document.getElementById("boot-pct"),i=document.getElementById("boot-detail"),r=Math.round(vt*100);s&&(s.style.transform=`scaleX(${vt})`),t?.setAttribute("aria-valuenow",String(r)),o&&(o.textContent=e.text),a&&(a.textContent=`${r}%`),i&&(i.textContent=e.detail)}function at(e,t,s=""){tt||(Fs=performance.now(),Mt={text:e,fraction:Math.max(vt,Mt?.fraction??0,Math.min(1,t)),detail:s},rn||(rn=requestAnimationFrame(jo)))}function Vo(e,t){const s=t>0?Math.min(1,e/t):0;at("Downloading the engine",.04+.8*s,t>0?`${Ut(e)} of ${Ut(t)} MB`:`${Ut(e)} MB`)}function Yo(){at("Starting the engine",.88,"Compiling, and starting a thread per core")}function Zo(e,t){at(e,.9+.1*Math.min(1,Math.max(0,t)))}function Jo(){if(tt)return;const e=document.getElementById("boot-fill");e&&(e.style.transitionDuration="0.12s"),at("Ready",1),window.setTimeout(()=>{tt=!0;const t=document.getElementById("boot");t&&(t.classList.add("leaving"),window.setTimeout(()=>t.remove(),260))},130)}{window.__inkvecBoot=!0,at("Loading the Studio",.03);const e=window.setInterval(()=>{if(tt){window.clearInterval(e);return}if(performance.now()-Fs>2e4){const t=document.getElementById("boot-detail");t&&(t.textContent="Still waiting for the network. On a slow connection the first visit can take a minute; later ones start from the browser's cache.")}},2e3)}function Xo(){let e;try{e=window.self!==window.top}catch{e=!0}const t=window.location.ancestorOrigins;if(t)for(let a=0;a<t.length;a++)/(^|\.)huggingface\.co(:\d+)?$/.test(t[a].replace(/^[a-z]+:\/\//,""))&&(e=!0);const s=document.documentElement;s.classList.toggle("framed",e);const o=()=>s.classList.toggle("fullscreen",!!document.fullscreenElement);document.addEventListener("fullscreenchange",o),o()}function Re(e,t,s="application/octet-stream"){const o=t instanceof Blob?t:new Blob([t],{type:s}),a=URL.createObjectURL(o),i=document.createElement("a");i.href=a,i.download=e,i.style.display="none",document.body.append(i),i.click(),i.remove(),window.setTimeout(()=>URL.revokeObjectURL(a),6e4)}var Ko={pkg:5814248,"pkg-threads":5846361};const Kn="inkvec-studio-lite:prefs",Qn="inkvec-denoiser-v1",Qo="inkvec-ort-",ea=3e4,ta=700,es="Not available in the browser. Inkvec Studio, the desktop app, has it.",ts=[["flat-logo.png","Flat logo"],["icon-64.png","Icon, 64 px"],["crest-filigree.png","Crest, filigree"],["signature-bw.png","Signature, B&W"]];class na{constructor(){Y(this,"worker",null);Y(this,"ready",null);Y(this,"queue",[]);Y(this,"running",null);Y(this,"nextId",1);Y(this,"listeners",new Map);Y(this,"generation",0);Y(this,"previewGeneration",0);Y(this,"shared",null);Y(this,"source",null);Y(this,"prefs",null);Y(this,"prefsTimer",0);Y(this,"denoiser",null);Y(this,"denoiserPort",null);Y(this,"downloading",!1);Y(this,"fetchState",{phase:"idle",got:0,total:null});Y(this,"wanted",!1);Y(this,"cancelled",!1);Y(this,"retried",!1);Y(this,"info",null);Y(this,"restartMs",null);Y(this,"stopped",[]);Y(this,"stopTimer",0);Y(this,"denoiserRuns",0);Y(this,"last",null)}base(){return new URL("./",document.baseURI).href}start(){const t=typeof crossOriginIsolated<"u"&&crossOriginIsolated;t&&!this.shared&&(this.shared=new Int32Array(new SharedArrayBuffer(4)));const s=new Worker(new URL(""+new URL("engine.worker-wbMABDxy.js",import.meta.url).href,import.meta.url),{type:"module",name:"inkvec-engine"});this.worker=s;let o=null;if(t){const i=new MessageChannel;o=i.port1,this.denoiser?this.denoiser.postMessage({type:"port",port:i.port2},[i.port2]):this.denoiserPort=i.port2}this.ready=new Promise((i,r)=>{s.onmessage=l=>{const c=l.data;c.type==="loading"?(Vo(c.got,c.total),c.done&&Yo()):c.type==="instantiated"?t&&(this.startDenoiser(c.denoiserUrl,c.denoiserSha256),this.prefetchDenoiser()):c.type==="ready"?(this.info={threads:c.threads,isolated:c.isolated,version:c.version},c.poolError&&console.warn("inkvec: thread pool did not start:",c.poolError),t&&this.startDenoiser(c.denoiserUrl,c.denoiserSha256),i(c)):c.type==="loadfail"?r(new Error(`The engine could not load: ${c.error}`)):c.type==="progress"?c.generation===this.generation&&this.emit("trace:progress",{generation:c.generation,...JSON.parse(c.json)}):c.type==="reply"&&this.finish(c)},s.onerror=l=>{r(new Error(`The engine stopped: ${l.message||"unknown error"}`)),this.crashed("The engine stopped unexpectedly.")}});const a=o?[o]:[];return s.postMessage({type:"init",base:this.base(),token:"3fbf0151b8d5",generations:this.shared?this.shared.buffer:null,denoiserPort:o,wasmBytes:Ko},a),this.ready}whenReady(){return this.ready??this.start()}crashed(t){const s=this.running;this.running=null,window.clearTimeout(this.stopTimer),this.worker?.terminate(),this.worker=null,this.ready=null,s&&s.reject(new Error(t)),s?.op==="open_bytes"&&(this.source=null);const o=this.source,a=performance.now();this.whenReady().then(async()=>{o&&await this.enqueue("open_bytes",-1,{bytes:o.bytes.slice(),name:o.name}).catch(()=>{}),this.restartMs=performance.now()-a,this.pump()})}supersede(t,s){window.clearTimeout(this.stopTimer);const o=this.running;if(o?.op!=="trace"||o.payload.generation===this.generation||!t&&s&&sa(o.payload.request,s))return;const a=performance.now(),i=()=>{this.running!==o||o.payload.generation===this.generation||(this.stopped.push({generation:o.payload.generation,asked:a,killed:performance.now()}),this.crashed("superseded by a newer request"))},r=a-(o.started??a),l=t?0:Math.max(0,(this.restartMs??ta)-r);l===0?i():this.stopTimer=window.setTimeout(i,l)}finish(t){const s=this.running;if(!(!s||s.id!==t.id)){if(this.last={op:s.op,ms:t.ms??0,mem:t.mem??null},this.running=null,window.clearTimeout(this.stopTimer),t.ok)s.resolve(t.value);else if(t.crashed){this.crashed(t.error??"The engine stopped."),s.reject(new Error(t.error??"The engine stopped."));return}else s.reject(new Error(t.error??"failed"));this.pump()}}enqueue(t,s,o,a){return new Promise((i,r)=>{if(a){for(const l of this.queue.filter(c=>c.kind===a))l.reject(new Error("superseded by a newer request"));this.queue=this.queue.filter(l=>l.kind!==a)}this.queue.push({id:this.nextId++,op:t,priority:s,kind:a,payload:o,resolve:i,reject:r}),this.queue.sort((l,c)=>l.priority-c.priority||l.id-c.id),this.whenReady().then(()=>this.pump(),l=>{for(const c of this.queue)c.reject(l);this.queue=[]})})}pump(){if(this.running||!this.worker||!this.info)return;const t=this.queue.shift();if(!t)return;if(t.op==="trace"&&t.payload.generation!==this.generation)return t.resolve(null),this.pump();if(t.op==="preview"&&t.payload.generation!==this.previewGeneration)return t.resolve(null),this.pump();this.running=t,t.started=performance.now();const s=[];t.op==="open_bytes"&&s.push(t.payload.bytes.buffer),this.worker.postMessage({type:"job",id:t.id,op:t.op,...t.payload},s)}emit(t,s){for(const o of this.listeners.get(t)??[])o(s)}async listen(t,s){const o=i=>s({payload:i});let a=this.listeners.get(t);return a||this.listeners.set(t,a=new Set),a.add(o),()=>void a?.delete(o)}async invoke(t,s={}){return await this.dispatch(t,s)}async dispatch(t,s){switch(t){case"capabilities":{const o=await this.denoiserStatus();return this.enqueue("capabilities",0,{supported:o.supported,installed:o.installed,bytes:o.bytes})}case"startup_progress":return Zo(String(s.text??""),Number(s.progress??0)),null;case"app_ready":return Jo(),null;case"open_path":throw new Error("A browser opens files you choose or drop, not paths.");case"open_bytes":{const o=s.bytes,a=o instanceof Uint8Array?o:new Uint8Array(o);return this.open(a,s.name??null)}case"open_sample":{const o=String(s.name);if(!ts.some(([i])=>i===o))throw new Error(`${o} is not one of the bundled samples`);const a=await fetch(new URL(`samples/${o}`,this.base()));if(!a.ok)throw new Error(`cannot fetch the sample ${o}: HTTP ${a.status}`);return this.open(new Uint8Array(await a.arrayBuffer()),o)}case"list_samples":return ts.map(([o,a])=>({file:o,label:a,preview:new URL(`samples/${o}`,this.base()).href}));case"launch_path":return null;case"start_trace":{const o=s.request,a=this.bump();this.rememberTrace(o.settings);const i=this.withoutUnreadyDenoiser(o);this.supersede(!1,i);const r=await this.loadPrefs();return this.enqueue("trace",1,{request:i,draftPx:r.draftPx??512,draftSeconds:r.draftSeconds??.4,generation:a},"trace").then(l=>{l&&a===this.generation&&this.emit("trace:done",{generation:a,outcome:l})},l=>{a===this.generation&&!/superseded/.test(l.message)&&this.emit("trace:done",{generation:a,outcome:{state:"failed",message:l.message}})}),a}case"cancel_trace":return this.bump(),this.queue=this.queue.filter(o=>o.kind==="trace"?(o.resolve(null),!1):!0),this.supersede(!0),null;case"start_preview":{const o=this.withoutUnreadyDenoiser(s.request),a=++this.previewGeneration,i=await this.loadPrefs();return this.enqueue("preview",2,{request:o,draftPx:i.draftPx??512,draftSeconds:i.draftSeconds??.4,generation:a},"preview").then(r=>{r&&a===this.previewGeneration&&this.emit("preview:done",{generation:a,outcome:r})},r=>{a===this.previewGeneration&&!/superseded/.test(r.message)&&this.emit("preview:done",{generation:a,outcome:{state:"failed",message:r.message}})}),a}case"cancel_previews":{this.previewGeneration++,this.queue=this.queue.filter(a=>a.kind==="preview"?(a.resolve(null),!1):!0);const o=this.running;return o?.op==="preview"&&o.started!==void 0&&performance.now()-o.started>500&&this.crashed("superseded by a newer request"),null}case"source_facts":case"trace_bands":case"snap_inks":case"match_palette":case"plan_export":case"minify_svg":case"fab_analyze":return this.enqueue(t,0,{args:s});case"fab_prepare":return this.enqueue(t,0,{args:s},"fab");case"write_export":{const o=s.request,a=await this.enqueue("export",0,{request:o,zip:!0}),i=(this.source?.name??"image").replace(/\.[^.]+$/,"")||"image";if(a.length===1&&a[0].name)return Re(a[0].name,a[0].data),[a[0].name];const r=`${i}-inkvec.zip`;return a[0]&&Re(r,a[0].data,"application/zip"),[r]}case"read_text_file":throw new Error("A browser reads files you choose or drop, not paths.");case"save_bytes":{const o=String(s.path);return Re(o.split(/[\\/]/).pop()||"download",new Uint8Array(s.bytes)),null}case"batch_scan":case"batch_start":case"batch_stats_csv":throw new Error(es);case"batch_pause":case"batch_cancel":return null;case"denoiser_status":return this.denoiserStatus();case"denoiser_download":return this.downloadDenoiser();case"denoiser_cancel":return this.fetchState.phase==="downloading"&&(this.cancelled=!0,this.wanted=!1,this.denoiser?.postMessage({type:"abort"})),this.downloading&&(this.downloading=!1,this.emit("denoiser:done",{ok:!1,message:"cancelled",status:await this.denoiserStatus()})),null;case"denoiser_remove":try{await caches.delete(Qn);for(const o of await caches.keys())o.startsWith(Qo)&&await caches.delete(o)}catch{}return this.denoiser?.postMessage({type:"forget"}),this.fetchState.phase!=="ready"&&this.setFetch({phase:"idle",got:0,total:null}),this.denoiserStatus();case"load_prefs":return this.loadPrefs();case"save_prefs":{this.prefs={...this.prefs??{},...s.prefs},this.storePrefs();const o=await this.enqueue("sanitise_prefs",0,{args:{prefs:s.prefs}});return this.prefs=o,this.storePrefs(),o}case"reset_prefs":{const o=await this.loadPrefs();return this.prefs=await this.enqueue("reset_prefs",0,{args:{prefs:o}}),this.storePrefs(),this.prefs}case"third_party_notices":{const a=(await Promise.all(["STUDIO_THIRD_PARTY.md","THIRD_PARTY.md"].map(i=>fetch(new URL(i,this.base())).then(r=>r.ok?r.text():null,()=>null)))).filter(i=>!!i);if(!a.length)throw new Error("the notices could not be fetched");return a.join(`
4
 
5
 
6
+ `)}case"check_update":return{latest:null,newer:!1,url:"https://github.com/logolabs/inkvec/releases",offline:"a web page is always the version it is served as"};case"cli_status":case"context_menu_status":case"install_cli":case"remove_cli":case"install_context_menu":case"remove_context_menu":return{available:!1,installed:!1,path:null,note:es}}throw new Error(`${t} is not something the browser build does`)}bump(){return this.generation++,this.shared&&Atomics.store(this.shared,0,this.generation),this.generation}async open(t,s){return this.source={bytes:t.slice(),name:s},this.bump(),this.queue=this.queue.filter(o=>o.kind?(o.resolve(null),!1):!0),this.supersede(!0),this.enqueue("open_bytes",0,{bytes:t,name:s})}async loadPrefs(){if(this.prefs)return this.prefs;let t=null;try{const s=localStorage.getItem(Kn);t=s?JSON.parse(s):null}catch{t=null}return this.prefs=await(t?this.enqueue("sanitise_prefs",0,{args:{prefs:t}}):this.enqueue("default_prefs",0,{args:{}})),this.prefs}rememberTrace(t){if(!this.prefs)return;const s={...t};delete s.colourGroups,this.prefs={...this.prefs,trace:s},window.clearTimeout(this.prefsTimer),this.prefsTimer=window.setTimeout(()=>this.storePrefs(),1e3)}storePrefs(){try{localStorage.setItem(Kn,JSON.stringify(this.prefs))}catch{}}startDenoiser(t,s){if(this.denoiser||!this.denoiserPort)return;const o=new Worker(new URL(""+new URL("denoiser.worker-DjPuHhk4.js",import.meta.url).href,import.meta.url),{type:"module",name:"inkvec-denoiser"});this.denoiser=o,o.onmessage=a=>void this.denoiserMessage(a.data),o.postMessage({type:"init",base:this.base(),token:"3fbf0151b8d5",url:t,sha256:s,port:this.denoiserPort},[this.denoiserPort])}setFetch(t){this.fetchState={...this.fetchState,retrace:void 0,...t},this.emit("denoiser:fetch",this.fetchState)}get denoiserFetch(){return this.fetchState}async denoiserMessage(t){const s=this.fetchState.phase;switch(t.type){case"progress":if(s==="preparing"||s==="ready")return;this.setFetch({phase:"downloading",got:t.got??0,total:t.total??null,message:void 0,saveData:void 0}),this.downloading&&this.emit("denoiser:progress",{got:t.got,total:t.total});return;case"stored":{if(s==="preparing"||s==="ready")return;const o=this.fetchState.total??this.fetchState.got;this.setFetch({phase:"stored",got:o,total:o,message:void 0}),this.downloading&&(this.downloading=!1,this.emit("denoiser:done",{ok:!0,status:await this.denoiserStatus()}));return}case"preparing":this.setFetch({phase:"preparing",message:void 0});return;case"ran":this.denoiserRuns++;return;case"loaded":{const o=this.wanted;this.wanted=!1,this.setFetch({phase:"ready",message:void 0,retrace:o});return}case"failed":{const o=t.message??"the download did not finish";if(this.cancelled||/abort/i.test(o)){this.cancelled=!1,this.setFetch({phase:"idle",message:void 0});return}this.setFetch({phase:"failed",message:o}),this.downloading&&(this.downloading=!1,this.emit("denoiser:done",{ok:!1,message:o,status:await this.denoiserStatus()})),t.during==="download"&&!this.retried&&(this.retried=!0,window.setTimeout(()=>{this.fetchState.phase==="failed"&&this.denoiser?.postMessage({type:this.wanted?"prepare":"prefetch"})},ea));return}}}prefetchDenoiser(){if(navigator.connection?.saveData){this.setFetch({phase:"idle",saveData:!0});return}this.denoiser?.postMessage({type:"prefetch"})}withoutUnreadyDenoiser(t){const s=t.settings?.cleanUpDamage;return!s||s==="off"||!this.denoiser||this.fetchState.phase==="ready"?t:(this.wanted=!0,this.cancelled=!1,this.denoiser.postMessage({type:"prepare"}),{...t,settings:{...t.settings,cleanUpDamage:"off"}})}async denoiserStatus(){const t=await this.whenReady();let s=!1,o=null;try{const a=await(await caches.open(Qn)).match(t.denoiserUrl);a&&(s=!0,o=Number(a.headers.get("content-length"))||(await a.blob()).size)}catch{}return{supported:t.isolated,installed:s,path:null,bytes:o,repo:t.denoiserRepo,sha256:t.denoiserSha256}}async downloadDenoiser(){if(await this.whenReady(),!this.denoiser)throw new Error("The denoiser needs a cross-origin isolated page.");return this.downloading=!0,this.cancelled=!1,this.denoiser.postMessage({type:this.wanted?"prepare":"download"}),null}}function sa(e,t){const s=o=>{const a={...o?.settings??{}};return delete a.minify,delete a.margin,JSON.stringify(Object.keys(a).sort().map(i=>[i,a[i]]))};return s(e)===s(t)}let dt=null;function Ns(){return dt||(dt=new na,globalThis.__inkvecStudioLite=dt),dt}function R(e,t){return Ns().invoke(e,t)}function ve(e,t){return Ns().listen(e,t)}const B={capabilities:()=>R("capabilities"),startupProgress:(e,t)=>R("startup_progress",{text:e,progress:t}),appReady:()=>R("app_ready"),openPath:e=>R("open_path",{path:e}),openBytes:(e,t)=>R("open_bytes",{bytes:e,name:t??null}),openSample:e=>R("open_sample",{name:e}),listSamples:()=>R("list_samples"),startTrace:(e,t)=>R("start_trace",{request:{settings:e,tier:t}}),cancelTrace:()=>R("cancel_trace"),startPreview:e=>R("start_preview",{request:{settings:e,tier:"draft"}}),cancelPreviews:()=>R("cancel_previews"),sourceFacts:e=>R("source_facts",{maxDim:e}),launchPath:()=>R("launch_path"),traceBands:e=>R("trace_bands",{generation:e}),snapInks:(e,t,s,o)=>R("snap_inks",{svg:e,snaps:t,width:s,height:o}),matchPalette:(e,t)=>R("match_palette",{traced:e,pasted:t}),planExport:e=>R("plan_export",{request:e}),writeExport:(e,t)=>R("write_export",{request:e,destination:t}),minify:(e,t)=>R("minify_svg",{svg:e,settings:t}),fabAnalyze:e=>R("fab_analyze",{svg:e}),fabPrepare:(e,t)=>R("fab_prepare",{svg:e,options:t}),readTextFile:e=>R("read_text_file",{path:e}),saveBytes:(e,t)=>R("save_bytes",{path:e,bytes:t}),batchScan:e=>R("batch_scan",{folder:e}),batchStart:e=>R("batch_start",{plan:e}),batchPause:e=>R("batch_pause",{paused:e}),batchCancel:()=>R("batch_cancel"),batchStatsCsv:()=>R("batch_stats_csv"),denoiserStatus:()=>R("denoiser_status"),denoiserDownload:()=>R("denoiser_download"),denoiserCancel:()=>R("denoiser_cancel"),denoiserRemove:()=>R("denoiser_remove"),loadPrefs:()=>R("load_prefs"),savePrefs:e=>R("save_prefs",{prefs:e}),resetPrefs:()=>R("reset_prefs"),thirdPartyNotices:()=>R("third_party_notices"),checkUpdate:()=>R("check_update"),cliStatus:()=>R("cli_status"),installCli:()=>R("install_cli"),removeCli:()=>R("remove_cli"),contextMenuStatus:()=>R("context_menu_status"),installContextMenu:()=>R("install_context_menu"),removeContextMenu:()=>R("remove_context_menu")},ke={traceProgress:e=>ve("trace:progress",t=>e(t.payload)),traceDone:e=>ve("trace:done",t=>e(t.payload)),previewDone:e=>ve("preview:done",t=>e(t.payload)),openPath:e=>ve("open:path",t=>e(t.payload)),batchRow:e=>ve("batch:row",t=>e(t.payload)),batchTotals:e=>ve("batch:totals",t=>e(t.payload)),batchFinished:e=>ve("batch:finished",t=>e(t.payload)),denoiserProgress:e=>ve("denoiser:progress",t=>e(t.payload)),denoiserDone:e=>ve("denoiser:done",t=>e(t.payload)),denoiserFetch:e=>ve("denoiser:fetch",t=>e(t.payload))};function oa(e,t){return{caps:null,prefs:null,tab:"vectorize",screen:null,source:null,settings:e,preset:"logo",generation:0,tracing:!1,tracingTier:"final",liveStages:[],traceStarted:0,traceEnded:0,liveNow:null,traceLog:[],logOpen:!0,result:null,resultGeneration:0,bandsMissing:!1,previous:null,svg:null,palette:[],snaps:[],colourGroups:[],groupSuggestions:null,resultGroups:[],dismissedGroups:[],simplifyTo:null,paletteSelection:[],hoverFill:null,losses:[],report:null,worstCorner:null,stageState:{kind:"empty"},justSwapped:!1,view:"side",show:{fill:!0,wireframe:!1,anchors:!1,handles:!1,certainty:!1},zoom:1,pan:{x:0,y:0},fitted:!0,flicked:!1,wipe:.5,detail:!1,railTab:"result",groupsOpen:{Detail:!0,Colour:!0,Shape:!0,Output:!1},exportOpen:!1,dragging:!1,minify:{name:null,before:null,settings:t,result:null,error:null},fab:{name:null,svg:null,analysis:null,options:Is(),plan:null,error:null,shown:-1,unit:"mm",showProblems:!0,preset:null,dxf:!1,gcode:!1},batch:{folder:null,outputDir:null,preset:"logo",skipExisting:!0,rows:[],totals:null,running:!1,paused:!1,failuresFirst:!1},update:null,denoiserFetch:null,auto:null,facts:null,chooser:!1,wizard:null,compare:null,autoNoteHidden:!1}}function Is(){return{mode:"singleColour",widthMm:100,include:[],order:[],bleedMm:.8,minFeatureMm:.8,removeThin:!1,stickerMarginMm:3,bridgeMm:1.5,stencilMarginMm:10,maxLineMm:0,penMm:.4,registration:!0,weedBorderMm:0,mirror:!1,cutStyle:"filled",sizeCheckMm:0,dogboneMm:0,gcodeFeedMmMin:1e3,gcodePower:1e3,gcodePasses:1,fileUnits:"mm",kerfMm:0,toleranceMm:.05,mergeDeltaE:3}}class aa{constructor(t){Y(this,"listeners",new Set);this.state=t}set(t){const s=new Set;for(const[o,a]of Object.entries(t))this.state[o]!==a&&(this.state[o]=a,s.add(o));s.size&&this.emit(s)}touch(...t){this.emit(new Set(t))}on(t,s){const o=new Set(t),a=i=>{for(const r of i)if(o.has(r)){s();return}};return this.listeners.add(a),()=>this.listeners.delete(a)}emit(t){for(const s of[...this.listeners])s(t)}}function oe(e){return e.toLocaleString("en-US")}function ie(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function re(e){return e==null?"—":e.toFixed(2)}function nt(e){return e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`}function bn(e,t){if(!e.source)return null;const s=Math.max(e.source.width,e.source.height),o=t==="draft"?Math.min(e.prefs?.draftPx??512,e.settings.traceSize):e.settings.traceSize;return Math.min(o,s)}function it(e,t){const s=t.mode==="fast"&&!t.blackAndWhite&&!t.lineArt;return e.modes==="qualityOnly"?!s:e.modes==="fastOnly"?s:!0}function $e(e,t=0){return`${(e*100).toFixed(t)}%`}function ia(e){const t=Math.max(0,Math.round(e));return t<60?`${t} s`:`${Math.floor(t/60)} min ${t%60} s`}function Os(e){return e==="macos"?"⌘":"Ctrl"}function ra(){return{preset:"logo",tab:"vectorize",railTab:"result",groupsOpen:{},view:"side",wipe:.5,show:{fill:!0,wireframe:!1,anchors:!1,handles:!1,certainty:!1},detail:!1,export:null,minify:null,minifyBackdrop:"auto",minifyView:"side",fab:null,fabUnit:"mm",fabShowProblems:!0,fabPreset:null,fabDxf:!1,fabGcode:!1,batchPreset:null,batchSkipExisting:!0,batchFailuresFirst:!1}}const Ce={export:null,minifyBackdrop:"auto",minifyView:"side"};let ln=()=>{};function la(){return{...Ce}}function cn(e){Object.assign(Ce,e),ln()}function ca(e){const t=Ce.export;return t?{...e,...t,pngSizes:[...t.pngSizes??e.pngSizes]}:e}function un(e){const t={...e.fab.options};return delete t.include,delete t.order,{preset:e.preset,tab:e.tab,railTab:e.railTab,groupsOpen:{...e.groupsOpen},view:e.view,wipe:e.wipe,show:{...e.show},detail:e.detail,export:Ce.export,minify:{...e.minify.settings},minifyBackdrop:Ce.minifyBackdrop,minifyView:Ce.minifyView,fab:t,fabUnit:e.fab.unit,fabShowProblems:e.fab.showProblems,fabPreset:e.fab.preset,fabDxf:e.fab.dxf,fabGcode:e.fab.gcode,batchPreset:e.batch.preset,batchSkipExisting:e.batch.skipExisting,batchFailuresFirst:e.batch.failuresFirst}}function dn(e){const t={...e};return delete t.colourGroups,t}function ua(e,t,s,o){const a=e.state,i={...ra(),...t.ui??{}};Ce.export=i.export,Ce.minifyBackdrop=i.minifyBackdrop,Ce.minifyView=i.minifyView,e.set({preset:i.preset&&o(i.preset)?i.preset:null,tab:s.includes(i.tab)?i.tab:"vectorize",railTab:i.railTab,groupsOpen:{...a.groupsOpen,...i.groupsOpen},view:i.view,wipe:i.wipe,show:{...a.show,...i.show},detail:i.detail,minify:{...a.minify,settings:{...a.minify.settings,...i.minify??{}}},fab:{...a.fab,options:{...Is(),...i.fab??{},include:[],order:[]},unit:i.fabUnit,showProblems:i.fabShowProblems,preset:i.fabPreset,dxf:i.fabDxf,gcode:i.fabGcode},batch:{...a.batch,preset:i.batchPreset&&o(i.batchPreset)?i.batchPreset:a.batch.preset,skipExisting:i.batchSkipExisting,failuresFirst:i.batchFailuresFirst}})}const da=["settings","preset","tab","railTab","groupsOpen","view","wipe","show","detail","minify","fab","batch"];function pa(e,t,s=500){let o=0,a=JSON.stringify({ui:un(e.state),trace:dn(e.state.settings)});const i=()=>{if(window.clearTimeout(o),o=0,!e.state.prefs)return;const c={ui:un(e.state),trace:dn(e.state.settings)},d=JSON.stringify(c);d!==a&&(a=d,t(c))};ln=()=>{window.clearTimeout(o),o=window.setTimeout(i,s)};const r=e.on(da,ln),l=()=>{document.visibilityState==="hidden"&&o&&i()};return window.addEventListener("pagehide",i),document.addEventListener("visibilitychange",l),()=>{r(),window.removeEventListener("pagehide",i),document.removeEventListener("visibilitychange",l)}}const ha="modulepreload",fa=function(e,t){return new URL(e,t).href},ns={},ga=function(t,s,o){let a=Promise.resolve();if(s&&s.length>0){let r=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const l=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),d=c?.nonce||c?.getAttribute("nonce");a=r(s.map(p=>{if(p=fa(p,o),p in ns)return;ns[p]=!0;const h=p.endsWith(".css"),f=h?'[rel="stylesheet"]':"";if(!!o)for(let b=l.length-1;b>=0;b--){const x=l[b];if(x.href===p&&(!h||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${p}"]${f}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":ha,h||(g.as="script"),g.crossOrigin="",g.href=p,d&&g.setAttribute("nonce",d),document.head.appendChild(g),h)return new Promise((b,x)=>{g.addEventListener("load",b),g.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return a.then(r=>{for(const l of r||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})};async function ma(e={}){return typeof e=="object"&&Object.freeze(e),await Dt("plugin:dialog|open",{options:e})}async function ba(e={}){return typeof e=="object"&&Object.freeze(e),await Dt("plugin:dialog|save",{options:e})}async function ya(e,t){await Dt("plugin:opener|open_url",{url:e,with:t})}async function wa(e){return Dt("plugin:opener|reveal_item_in_dir",{paths:typeof e=="string"?[e]:e})}const Ft="Inkvec Studio Lite",_s="https://github.com/logolabs/inkvec/releases",va="Inkvec Studio for Windows, macOS and Linux: the native engine is faster, it traces whole folders in one batch, has no browser memory limit (traces up to 16384 px), and works offline.";function Bs(e){return{name:e.name||"pasted image",path:null,file:e}}async function yn(e,t=!1){return new Promise(s=>{const o=document.createElement("input");o.type="file",o.multiple=t,o.accept=e.flatMap(r=>r.extensions.map(l=>`.${l}`)).join(","),o.style.display="none";let a=!1;const i=r=>{a||(a=!0,o.remove(),s(r))};o.addEventListener("change",()=>i([...o.files??[]].map(Bs))),o.addEventListener("cancel",()=>i([])),document.body.append(o),o.click()})}async function Ct(e){if(e.file)return e.file.text();if(e.path)return B.readTextFile(e.path);throw new Error("nothing to read")}const ss=!1;async function Rs(e,t,s){const o=typeof t=="string"?new TextEncoder().encode(t):t;return Re(e,o),{path:null,name:e}}async function xa(e,t,s){const o=new TextEncoder,a=i=>typeof i=="string"?o.encode(i):i;{if(e.length===1)Re(e[0].name,a(e[0].data));else{const{zipStore:i}=await ga(async()=>{const{zipStore:r}=await import("./zip-DlX9-WSC.js");return{zipStore:r}},[],import.meta.url);Re(t,i(e.map(r=>({name:r.name,data:a(r.data)}))))}return{folder:null,first:null}}}const ka=!1;async function Nt(e){await navigator.clipboard.writeText(e)}async function It(e){{window.open(e,"_blank","noopener,noreferrer");return}}function Ot(e){return e&&ka?{label:"Show in folder",run:()=>void 0}:void 0}function Pe(e){const t={...e,cleanUpDamage:"off"};return JSON.stringify(Object.keys(t).sort().map(s=>[s,t[s]]))}class Sa{constructor(){Y(this,"results",new Map);Y(this,"queue",[]);Y(this,"running",null);Y(this,"epoch",0);Y(this,"early",new Map);Y(this,"listeners",new Set);ke.previewDone(({generation:t,outcome:s})=>this.done(t,s))}get(t){return this.results.get(t)}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}want(t){const s=new Set,o=t.filter(a=>{if(s.has(a.key))return!1;s.add(a.key);const i=this.results.get(a.key)?.state;return i!=="done"&&i!=="running"});if(o.map(a=>a.key).join(`
7
  `)!==this.queue.map(a=>a.key).join(`
8
  `)){for(const a of this.queue)this.results.get(a.key)?.state==="queued"&&this.results.delete(a.key);this.queue=o;for(const a of this.queue)this.results.set(a.key,{state:"queued"});this.emit(),this.next()}}pause(){this.want([])}reset(){this.epoch++;for(const t of this.results.values())t.state==="done"&&URL.revokeObjectURL(t.url);this.results.clear(),this.queue=[],this.early.clear(),this.running&&B.cancelPreviews().catch(()=>{}),this.running=null,this.emit()}pending(){return this.queue.length+(this.running?1:0)}next(){if(this.running)return;const t=this.queue.shift();if(!t)return;const s=this.epoch;this.running={key:t.key,generation:null,epoch:s},this.results.set(t.key,{state:"running"}),this.emit(),B.startPreview(t.settings).then(o=>{if(this.running?.epoch!==s||this.running.key!==t.key)return;this.running.generation=o;const a=this.early.get(o);a&&(this.early.delete(o),this.done(o,a))},o=>{this.running?.epoch===s&&this.finish(t.key,{state:"failed",message:String(o)})})}done(t,s){const o=this.running;if(o){if(o.generation===null){this.early.set(t,s);return}if(o.generation===t)if(s.state==="traced"){const a=URL.createObjectURL(new Blob([s.svg],{type:"image/svg+xml"}));this.finish(o.key,{state:"done",svg:s.svg,url:a,report:s.report})}else{const a="message"in s?s.message:s.state==="flat"?"one flat colour":s.state==="cancelled"?"stopped":"out of memory";this.finish(o.key,{state:"failed",message:a})}}}finish(t,s){this.results.set(t,s),this.running=null,this.emit(),this.next()}emit(){for(const t of[...this.listeners])t()}}const os=400;function $a(e,t,s){let o=e.liveStages,a=e.liveNow;const i=[...e.traceLog],r=c=>{for(let d=i.length-1;d>=0;d--){const p=i[d];if(p.kind==="stage")return p.what===c&&p.ms===void 0?d:-1}return-1};for(const c of t.entries)if(c.kind==="begin")a={stage:c.stage,what:c.what,since:s,step:null},i.push({at:c.at,kind:"stage",stage:c.stage,what:c.what});else if(c.kind==="end"){if(c.stage!=="measure"){const p=o.findIndex(h=>h.name===c.stage);o=p>=0?o.map((h,f)=>f===p?{...h,ms:h.ms+c.ms}:h):[...o,{name:c.stage,ms:c.ms}]}const d=r(c.what);d>=0?i[d]={...i[d],ms:c.ms,step:i[d].step??null}:i.push({at:Math.max(0,c.at-c.ms),kind:"stage",stage:c.stage,what:c.what,ms:c.ms}),a&&a.what===c.what&&(a=null)}else i.push({at:c.at,kind:"note",stage:c.stage,what:c.what,text:c.text});const l=t.step;if(l){!a||a.what!==l.what?a={stage:l.stage,what:l.what,since:s,step:l}:a={...a,step:l};const c=r(l.what);c>=0&&(i[c]={...i[c],step:l})}return{liveStages:o,liveNow:a,traceLog:i.length>os?i.slice(i.length-os):i}}function wn(e){return e.total>0?`${e.done} / ${e.total} ${e.unit}`:`${e.unit} ${e.done}`}function Ge(e){const t=Math.max(0,e)/1e3;return t<60?`${t.toFixed(1)} s`:`${Math.floor(t/60)} min ${String(Math.floor(t%60)).padStart(2,"0")} s`}function as(e){return`${(Math.max(0,e)/1e3).toFixed(2)}`}function Ma(e,t,s){let o=0;const a=()=>{const r=performance.now(),l=t(),c=s();for(const d of document.querySelectorAll('[data-live="elapsed"]'))d.textContent=Ge(r-l);for(const d of document.querySelectorAll('[data-live="stage"]'))d.textContent=c===null?"":Ge(r-c)},i=()=>{e()&&!o?(a(),o=window.setInterval(a,100)):!e()&&o&&(window.clearInterval(o),o=0)};return()=>{i(),o&&a()}}function _t(e){const t=e.liveNow;if(t){const s=t.stage==="measure"?"measuring":t.stage;return t.step?`${s} · ${wn(t.step)}`:`${s} · ${t.what}`}return e.liveStages[e.liveStages.length-1]?.name??"starting"}function Bt(e){return Ge(performance.now()-e.traceStarted)}const vn=()=>document.getElementById("overlays"),Ca=()=>document.getElementById("toasts");function W(e,t={}){const s=t.kind??"plain",o=s==="good"?"checkCircle":s==="bad"?"alert":"info",a=n("div.toast",{role:"status"},n(`span.glyph.${s}`,null,Z(o,16)),n("span.text",null,e),t.action&&n("button",{class:"reset",onclick:()=>{t.action?.run(),a.remove()}},t.action.label));Ca().append(a),window.setTimeout(()=>a.remove(),6e3)}function ue(){F(vn()),document.removeEventListener("keydown",xn,!0)}function xn(e){e.key==="Escape"&&(e.stopPropagation(),ue())}function Ye(e){const t=n("div.scrim",{onmousedown:s=>{s.target===t&&ue()}});e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),t.append(e),F(vn(),t),document.addEventListener("keydown",xn,!0),(e.querySelector("button, input, [tabindex]")??e).focus()}function Rt(e,t,s=[]){return n("div.modal",{tabindex:"-1"},n("h2",null,e),...t.filter(Boolean).map(o=>typeof o=="string"?n("p",null,o):o),s.length?n("div.actions",null,...s):null)}function kn(e,t){const s=n("div.popover",null,t),o=n("div",{style:{position:"fixed",inset:"0",zIndex:"44"},onmousedown:ue});F(vn(),o,s),document.addEventListener("keydown",xn,!0);const a=e.getBoundingClientRect(),i=s.getBoundingClientRect(),r=8,l=Math.min(Math.max(r,a.left),window.innerWidth-i.width-r),c=a.bottom+6,d=c+i.height+r>window.innerHeight?a.top-i.height-6:c;s.style.left=`${Math.round(l)}px`,s.style.top=`${Math.round(Math.max(r,d))}px`,(s.querySelector("button, input, [tabindex]")??s).focus?.()}let _e=null,Sn=0;function st(){window.cancelAnimationFrame(Sn),_e?.node.remove(),_e=null}function Gs(){const e=_e;if(!e)return;if(!(e.el.isConnected&&(e.el.matches(":hover")||e.el.matches(":focus-visible")))){st();return}Sn=window.requestAnimationFrame(Gs)}function Fe(e,t){let s=0;const o=()=>{if(!e.isConnected||_e?.el===e)return;st();const i=n("div.tooltip",{role:"tooltip"},t);document.body.append(i);const r=e.getBoundingClientRect(),l=i.getBoundingClientRect(),c=Math.min(Math.max(8,r.left),window.innerWidth-l.width-8),d=r.top-l.height-8;i.style.left=`${Math.round(c)}px`,i.style.top=`${Math.round(d<8?r.bottom+8:d)}px`,_e={node:i,el:e},Sn=window.requestAnimationFrame(Gs)},a=()=>{window.clearTimeout(s),_e?.el===e&&st()};return e.addEventListener("pointerenter",()=>{window.clearTimeout(s),s=window.setTimeout(o,350)}),e.addEventListener("pointerleave",a),e.addEventListener("pointerdown",a),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&o()}),e.addEventListener("blur",a),e}document.addEventListener("keydown",e=>{e.key==="Escape"&&_e&&st()},!0);window.addEventListener("blur",st);function Ta(e,t,s,o,a=!1){Ye(Rt(e,[t],[n("button.btn",{onclick:ue},"Cancel"),n(`button.btn.primary${a?".danger":""}`,{onclick:()=>{ue(),o()}},s)]))}function Ws(e){const t=e.trim().replace(/^#/,""),s=t.length===3?[...t].map(o=>o+o).join(""):t;return/^[0-9a-fA-F]{6}$/.test(s)?[0,2,4].map(o=>parseInt(s.slice(o,o+2),16)/255):null}function qs([e,t,s]){const o=g=>g<=.04045?g/12.92:((g+.055)/1.055)**2.4,[a,i,r]=[o(e),o(t),o(s)],l=(.4124564*a+.3575761*i+.1804375*r)/.95047,c=.2126729*a+.7151522*i+.072175*r,d=(.0193339*a+.119192*i+.9503041*r)/1.08883,p=g=>g>216/24389?Math.cbrt(g):(24389/27*g+16)/116,[h,f,u]=[p(l),p(c),p(d)];return[116*f-16,500*(h-f),200*(f-u)]}function Aa(e,t){const[s,o,a]=e,[i,r,l]=t,c=Math.PI/180,d=Math.hypot(o,a),p=Math.hypot(r,l),h=((d+p)/2)**7,f=.5*(1-Math.sqrt(h/(h+25**7))),u=(1+f)*o,g=(1+f)*r,b=Math.hypot(u,a),x=Math.hypot(g,l),M=(pe,Te)=>{if(pe===0&&Te===0)return 0;const fe=Math.atan2(Te,pe)/c;return fe<0?fe+360:fe},v=M(u,a),S=M(g,l),y=i-s,$=x-b;let C=0;b*x!==0&&(C=S-v,C>180?C-=360:C<-180&&(C+=360));const D=2*Math.sqrt(b*x)*Math.sin(C*c/2),z=(s+i)/2,O=(b+x)/2;let A=v+S;b*x!==0&&(A=Math.abs(v-S)<=180?(v+S)/2:v+S<360?(v+S+360)/2:(v+S-360)/2);const P=1-.17*Math.cos((A-30)*c)+.24*Math.cos(2*A*c)+.32*Math.cos((3*A+6)*c)-.2*Math.cos((4*A-63)*c),J=30*Math.exp(-(((A-275)/25)**2)),H=O**7,X=2*Math.sqrt(H/(H+25**7)),se=1+.015*(z-50)**2/Math.sqrt(20+(z-50)**2),ee=1+.045*O,Q=1+.015*O*P,j=-Math.sin(2*J*c)*X,ne=y/se,ae=$/ee,te=D/Q;return Math.sqrt(ne*ne+ae*ae+te*te+j*ae*te)}function Tt(e){return e.kind==="gradient"&&e.stops.length>1?e.stops.map(t=>t.toLowerCase()).join(">"):e.traced.toLowerCase()}function qe(e){return e.split(">").map(t=>t.trim().toLowerCase())}function rt(e){return e.includes(">")}function $n(e,t=!1){const s=qe(e);return s.length<2?s[0]??"transparent":t?`radial-gradient(circle, ${s.join(", ")})`:`linear-gradient(90deg, ${s.join(", ")})`}const pt=new Map;function is(e){const t=pt.get(e);if(t)return t;const s=Ws(e);if(!s)return null;const o=qs(s);return pt.size>4096&&pt.clear(),pt.set(e,o),o}function Mn(e,t){const s=qe(e).map(is),o=qe(t).map(is);if(s.some(l=>!l)||o.some(l=>!l)||!s.length||!o.length)return 1/0;const a=s,i=o,r=(l,c)=>l.reduce((d,p)=>d+Math.min(...c.map(h=>Aa(p,h))),0)/l.length;return Math.max(r(a,i),r(i,a))}const Ea=2;function Gt(e,t){const s=rt(e),o=t.find(r=>Tt(r)===e);if(o)return o;let a=null,i=Ea;for(const r of t){if(r.kind==="gradient"!==s)continue;const l=Mn(e,Tt(r));l<=i&&(i=l,a=r)}return a}function Se(e,t){return e===t||Mn(e,t)<.5}const za=2,La=240;function Pa(e,t={}){const s=t.skip??[],o=e.filter(p=>p.share>0),a=[...o].sort((p,h)=>h.share-p.share).slice(0,La).map(p=>({member:Tt(p),share:p.share})).filter(p=>!s.some(h=>Se(h,p.member))),i=a.length;if(i<2)return[];const r=a.map((p,h)=>a.map((f,u)=>h===u?0:Mn(p.member,f.member))),l=a.map((p,h)=>[h]);let c=i;const d=t.count?Math.max(1,Math.round(t.count)-(o.length-i)):null;for(;!(d!==null&&c<=d);){let p=1/0,h=-1,f=-1;for(let u=0;u<i;u++)if(l[u])for(let g=u+1;g<i;g++)l[g]&&r[u][g]<p&&(p=r[u][g],h=u,f=g);if(h<0||d===null&&p>za)break;l[h]=[...l[h],...l[f]],l[f]=null,c--;for(let u=0;u<i;u++){if(u===h||!l[u])continue;const g=Math.max(r[h][u],r[f][u]);r[h][u]=g,r[u][h]=g}}return l.filter(Boolean).filter(p=>p.length>1).map(p=>p.map(h=>a[h]).sort((h,f)=>f.share-h.share)).sort((p,h)=>h.reduce((f,u)=>f+u.share,0)-p.reduce((f,u)=>f+u.share,0)).map(p=>({members:p.map(h=>h.member),target:null}))}function Cn(e){return[...e.members].sort().join(",")}function Da(e){return e.filter(t=>t.trimStart().startsWith("merge colors")).map(t=>{const s=t.trim().replace(/^merge colors\s+/,""),o=/;\s*(?:not found in the trace:|no ink near)\s*(.*)$/.exec(s),a=(o?.[1]??"").split(",").map(i=>i.trim().toLowerCase()).filter(i=>/^#[0-9a-f]{6}(>#[0-9a-f]{6})*$/.test(i));return{line:o?s.slice(0,o.index).trim():s,unmatched:a,leftAlone:s.startsWith("group left alone")}})}function Fa(e,t){return e?e.unmatched.some(s=>s===t||qe(t).includes(s)||Se(s,t)):!1}function Hs(e){const t=(e.groupSuggestions??[]).filter(a=>a.edited),s=[...e.colourGroups.flatMap(a=>a.members),...t.flatMap(a=>a.members)],o=Pa(e.palette,{count:e.simplifyTo,skip:s}).filter(a=>!e.dismissedGroups.includes(Cn(a)));return[...t,...o]}function Na(e,t){const s=e.members.filter(a=>Gt(a,t));if(s.length<2)return null;let o=e.target;if(o?.startsWith("@")){const a=e.members[Number(o.slice(1))-1],i=a?s.indexOf(a):-1;o=i>=0?`@${i+1}`:null}return{...e,members:s,target:o}}function Tn(e){return(e.groupSuggestions??[]).map((t,s)=>({g:Na(t,e.palette),index:s})).filter(t=>t.g!==null)}function Us(e,t){let s=e.target;if(s?.startsWith("@")){const o=Number(s.slice(1))-1;s=o===t?null:o>t?`@${o}`:s}return{...e,members:e.members.filter((o,a)=>a!==t),target:s}}function be(e,t,s=-1,o=!1){return e.map((a,i)=>{if(i===s)return a;const r=a.members.findIndex(l=>Se(l,t));return r<0?a:{...Us(a,r),...o?{edited:!0}:{}}})}const He=e=>e.filter(t=>t.members.length>1);function Ia(e,t,s,o,a){const i=e.state;let r=i.colourGroups.map(f=>({...f,members:[...f.members]})),l=(i.groupSuggestions??[]).map(f=>({...f,members:[...f.members]}));const c=a?.closest("[data-drop]")??null,d=c?.dataset.drop??null,p=Number(c?.dataset.index??-1);if((d==="group"||d==="sugg")&&o.kind===d&&o.index===p||d==="ink"&&Se(c?.dataset.member??"",s))return;if(d==="group")r=be(r,s,p),l=be(l,s,-1,!0),r[p].members.some(f=>Se(f,s))||r[p].members.push(s);else if(d==="sugg")r=be(r,s),l=be(l,s,p,!0),l[p].members.some(f=>Se(f,s))||(l[p]={...l[p],members:[...l[p].members,s],edited:!0});else if(d==="ink"){const f=c?.dataset.member??"";r=be(r,s),l=be(l,s,-1,!0);const u=r.findIndex(g=>g.members.some(b=>Se(b,f)));u>=0?r[u].members.push(s):(l=be(l,f,-1,!0),r.push({members:[f,s],target:null}))}else{if(o.kind==="palette")return;o.kind==="group"?r=be(r,s):l=be(l,s,-1,!0)}const h=He(r);e.set({groupSuggestions:He(l),paletteSelection:[]}),JSON.stringify(h)!==JSON.stringify(i.colourGroups)&&t.setColourGroups(h)}function Oa(e,t){const s=e.state,o=s.paletteSelection;if(o.length<2)return;let a=s.colourGroups.map(l=>({...l,members:[...l.members]}));const i=a.findIndex(l=>l.members.some(c=>o.some(d=>Se(d,c))));let r=s.groupSuggestions??[];for(const l of o)a=be(a,l,i),r=be(r,l,-1,!0);if(i>=0)for(const l of o)a[i].members.some(c=>Se(c,l))||a[i].members.push(l);else a.push({members:[...o],target:null});e.set({groupSuggestions:He(r),paletteSelection:[]}),t.setColourGroups(He(a))}const _a=4;function js(e,t,s,o,a,i){e.addEventListener("pointerdown",r=>{if(r.button!==0)return;const l=r.clientX,c=r.clientY;let d=null,p=null;const h=g=>{g!==p&&(p?.classList.remove("dropping"),p=g,p?.classList.add("dropping"))},f=g=>{if(!d){if(Math.hypot(g.clientX-l,g.clientY-c)<_a)return;d=n("div.dragghost",null,n("span.swatch",null,n("i",{style:{background:$n(o,i)}}))),document.body.append(d),document.body.classList.add("dragging-ink")}d.style.left=`${g.clientX+8}px`,d.style.top=`${g.clientY+8}px`;const b=document.elementFromPoint(g.clientX,g.clientY);h(b?.closest("[data-drop]")??null)},u=g=>{if(window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u),!d)return;d.remove(),document.body.classList.remove("dragging-ink"),h(null);const b=x=>x.stopPropagation();window.addEventListener("click",b,!0),window.setTimeout(()=>window.removeEventListener("click",b,!0),0),g.type!=="pointercancel"&&Ia(t,s,o,a,document.elementFromPoint(g.clientX,g.clientY))};window.addEventListener("pointermove",f),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u)})}function ht(e,t){return Gt(e,t)?.keys??[]}function Vs(e,t){let s=0;const o=()=>{let i=[...e.querySelectorAll("[data-fill]:hover")].pop()??null;if(!i){const l=document.activeElement;l instanceof HTMLElement&&e.contains(l)&&l.matches(":focus-visible")&&(i=l.closest("[data-fill]"))}const r=i?JSON.parse(i.dataset.fill??"[]"):[];return r.length?r:null},a=()=>{const i=o(),r=t.state.hoverFill;(i??[]).join(`
9
  `)!==(r??[]).join(`
studio/index.html CHANGED
@@ -11,7 +11,7 @@
11
  <meta name="description" content="Turn a raster logo into an exact SVG, in your browser. Nothing is uploaded." />
12
  <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
13
  <title>Inkvec Studio Lite</title>
14
- <script type="module" crossorigin src="./assets/main-ai0rIBhL.js"></script>
15
  <link rel="stylesheet" crossorigin href="./assets/main-BwYpaGSz.css">
16
  <link rel="preload" href="./fonts/playfair-latin.woff2" as="font" type="font/woff2" crossorigin />
17
  <link rel="preload" href="./fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin />
 
11
  <meta name="description" content="Turn a raster logo into an exact SVG, in your browser. Nothing is uploaded." />
12
  <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
13
  <title>Inkvec Studio Lite</title>
14
+ <script type="module" crossorigin src="./assets/main-DD_Xvh8j.js"></script>
15
  <link rel="stylesheet" crossorigin href="./assets/main-BwYpaGSz.css">
16
  <link rel="preload" href="./fonts/playfair-latin.woff2" as="font" type="font/woff2" crossorigin />
17
  <link rel="preload" href="./fonts/inter-latin.woff2" as="font" type="font/woff2" crossorigin />
studio/pkg-threads/inkvec_studio_wasm_bg.wasm CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7f5572bed15d6a7884fb4af79ba6b34949ebd9cc0ffdbe4328565d87d24178ce
3
- size 5845653
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3896e09d72fe42e6ed1cf1fb55dca075601b7de2838da16e0b2348fa1a24acb
3
+ size 5846361
studio/pkg-threads/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js CHANGED
@@ -51,7 +51,7 @@ waitForMsgType(self, 'wasm_bindgen_worker_init').then(async ({ init, receiver })
51
  // OTOH, even though it can't be inlined, it should be still reasonably
52
  // cheap since the requested file is already in cache (it was loaded by
53
  // the main thread).
54
- const pkg = await import('../../../inkvec_studio_wasm.js?v=05758cc93999');
55
  await pkg.default(init);
56
  postMessage({ type: 'wasm_bindgen_worker_ready' });
57
  pkg.wbg_rayon_start_worker(receiver);
 
51
  // OTOH, even though it can't be inlined, it should be still reasonably
52
  // cheap since the requested file is already in cache (it was loaded by
53
  // the main thread).
54
+ const pkg = await import('../../../inkvec_studio_wasm.js?v=3fbf0151b8d5');
55
  await pkg.default(init);
56
  postMessage({ type: 'wasm_bindgen_worker_ready' });
57
  pkg.wbg_rayon_start_worker(receiver);
studio/pkg/inkvec_studio_wasm_bg.wasm CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cfdf37c0cc3d661558b7a9e0338d9715b9a1b41f8305808e9750b71e188063df
3
- size 5813486
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2aa44e079999a68522f2e9395e2c6a12b53eb8141c069d11ef4ca3ee49dcbcc5
3
+ size 5814248