=n))for(let t=f;t=r)continue;let i=(n*t+e)*4;a+=o[i+0],s+=o[i+1],c+=o[i+2],l+=o[i+3],m+=1}a/=m,s/=m,c/=m,l/=m;for(let e=u;e=n))for(let t=f;t=r)continue;let i=(n*t+e)*4;o[i+0]=a,o[i+1]=s,o[i+2]=c,o[i+3]=l}}};z.addGetterSetter(B,`pixelSize`,8,R(),z.afterSetFilter);var hs=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`blue`,0,rr,z.afterSetFilter);var _s=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),z.addGetterSetter(B,`blue`,0,rr,z.afterSetFilter),z.addGetterSetter(B,`alpha`,1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var vs=function(e){let t=e.data,n=t.length;for(let e=0;e=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},bs=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e{i(e.getAttr(r))})}}var ks=`V`;function As(e){function t(e){return e?.__konvaNode?e:e?.parent?t(e.parent):(console.error(`vue-konva error: Can not find parent node`),null)}return t(e.parent)}function js(e){return e.component?e.component.__konvaNode||js(e.component.subTree):null}function Ms(e){let{el:t,component:n}=e,r=js(e);if(t?.tagName&&n&&!r){let e=t.tagName.toLowerCase();return console.error(`vue-konva error: You are trying to render "${e}" inside your component tree. Looks like it is not a Konva node. You can render only Konva components inside the Stage.`),null}return r}function Ns(e){let t=e=>!!e&&typeof e==`object`&&`component`in e,n=e=>Array.isArray(e),r=e=>t(e)?[e,...r(e.children)]:n(e)?e.flatMap(r):[];return r(e.children)}function Ps(e,t){let n=Ns(e),r=[];n.forEach(e=>{let t=Ms(e);t&&r.push(t)});let i=!1;r.forEach((e,t)=>{e.getZIndex()!==t&&(e.setZIndex(t),i=!0)}),i&&Ss(t)}var Fs=xs.default?.Stage||xs.Stage,Is=Ce({name:`Stage`,props:{config:{type:Object,default:function(){return{}}},__useStrictMode:{type:Boolean}},inheritAttrs:!1,setup(e,{attrs:t,slots:n,expose:i}){let a=Ee();if(!a)return;let s=v({}),c=o(null),l=new Fs({width:e.config.width,height:e.config.height,container:document.createElement(`div`)});a.__konvaNode=l,p();function u(){return a?.__konvaNode}function d(){return a?.__konvaNode}function p(){if(!a)return;let n=s||{},r={...t,...e.config};Ts(a,r,n,e.__useStrictMode),Object.assign(s,r)}return r(()=>{c.value&&l.container(c.value),p(),Os(l,a)}),f(()=>{p(),Ps(a.subTree,l),Os(l,a)}),g(()=>{l.destroy()}),m(()=>e.config,p,{deep:!0}),i({getStage:d,getNode:u}),()=>Te(`div`,{ref:c,id:t?.id,accesskey:t?.accesskey,class:t?.class,role:t?.role,style:t?.style,tabindex:t?.tabindex,title:t?.title},n.default?.())}}),Ls=`.vue-konva-event`,Rs={Group:!0,Layer:!0,FastLayer:!0,Label:!0};function J(e,t){return Ce({name:e,props:{config:{type:Object,default:function(){return{}}},__useStrictMode:{type:Boolean}},setup(i,{attrs:a,slots:o,expose:s}){let c=Ee();if(!c)return;let l=v({}),u=new t;c.__konvaNode=u,c.vnode.__konvaNode=u,h();function d(){return c?.__konvaNode}function p(){return c?.__konvaNode}function h(){if(!c)return;let e={};for(let t in c?.vnode.props)t.slice(0,2)===`on`&&(e[t]=c.vnode.props[t]);let t=l||{},n={...a,...i.config,...e};Ts(c,n,t,i.__useStrictMode),Object.assign(l,n)}r(()=>{let e=As(c)?.__konvaNode;e&&`add`in e&&e.add(u),Ss(u),Os(u,c)}),n(()=>{Ss(u),u.destroy(),u.off(Ls),u.off(Es)}),f(()=>{h(),Ps(c.subTree,u),Os(u,c)}),m(()=>i.config,h,{deep:!0}),s({getStage:p,getNode:d});let g=Rs.hasOwnProperty(e);return()=>g?o.default?.():null}})}var Y=xs.default||xs,zs=J(`Arc`,Y.Arc),Bs=J(`Arrow`,Y.Arrow),Vs=J(`Circle`,Y.Circle),Hs=J(`Ellipse`,Y.Ellipse),Us=J(`FastLayer`,Y.FastLayer),Ws=J(`Group`,Y.Group),Gs=J(`Image`,Y.Image),Ks=J(`Label`,Y.Label),qs=J(`Layer`,Y.Layer),Js=J(`Line`,Y.Line),Ys=J(`Path`,Y.Path),Xs=J(`Rect`,Y.Rect),Zs=J(`RegularPolygon`,Y.RegularPolygon),Qs=J(`Ring`,Y.Ring),$s=J(`Shape`,Y.Shape),ec=J(`Sprite`,Y.Sprite),tc=J(`Star`,Y.Star),nc=J(`Tag`,Y.Tag),rc=J(`Text`,Y.Text),ic=J(`TextPath`,Y.TextPath),ac=J(`Transformer`,Y.Transformer),oc=J(`Wedge`,Y.Wedge),sc=Object.freeze(Object.defineProperty({__proto__:null,Arc:zs,Arrow:Bs,Circle:Vs,Ellipse:Hs,FastLayer:Us,Group:Ws,Image:Gs,Label:Ks,Layer:qs,Line:Js,Path:Ys,Rect:Xs,RegularPolygon:Zs,Ring:Qs,Shape:$s,Sprite:ec,Star:tc,Tag:nc,Text:rc,TextPath:ic,Transformer:ac,Wedge:oc},Symbol.toStringTag,{value:`Module`})),cc={install:(e,t)=>{let n=t?.prefix||ks,r=t?.customNodes?Object.entries(t.customNodes).map(([e,t])=>J(e,t)):[];[Is,...Object.values(sc),...r].forEach(t=>{e.component(`${n}${t.name}`,t)})}},lc=typeof document<`u`;function uc(e){return typeof e==`object`||`displayName`in e||`props`in e||`__vccOpts`in e}function dc(e){return e.__esModule||e[Symbol.toStringTag]===`Module`||e.default&&uc(e.default)}var X=Object.assign;function fc(e,t){let n={};for(let r in t){let i=t[r];n[r]=mc(i)?i.map(e):e(i)}return n}var pc=()=>{},mc=Array.isArray;function hc(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}var gc=/#/g,_c=/&/g,vc=/\//g,yc=/=/g,bc=/\?/g,xc=/\+/g,Sc=/%5B/g,Cc=/%5D/g,wc=/%5E/g,Tc=/%60/g,Ec=/%7B/g,Dc=/%7C/g,Oc=/%7D/g,kc=/%20/g;function Ac(e){return e==null?``:encodeURI(``+e).replace(Dc,`|`).replace(Sc,`[`).replace(Cc,`]`)}function jc(e){return Ac(e).replace(Ec,`{`).replace(Oc,`}`).replace(wc,`^`)}function Mc(e){return Ac(e).replace(xc,`%2B`).replace(kc,`+`).replace(gc,`%23`).replace(_c,`%26`).replace(Tc,"`").replace(Ec,`{`).replace(Oc,`}`).replace(wc,`^`)}function Nc(e){return Mc(e).replace(yc,`%3D`)}function Pc(e){return Ac(e).replace(gc,`%23`).replace(bc,`%3F`)}function Fc(e){return Pc(e).replace(vc,`%2F`)}function Ic(e){if(e==null)return null;try{return decodeURIComponent(``+e)}catch{}return``+e}var Lc=/\/$/,Rc=e=>e.replace(Lc,``);function zc(e,t,n=`/`){let r,i={},a=``,o=``,s=t.indexOf(`#`),c=t.indexOf(`?`);return c=s>=0&&c>s?-1:c,c>=0&&(r=t.slice(0,c),a=t.slice(c,s>0?s:t.length),i=e(a.slice(1))),s>=0&&(r||=t.slice(0,s),o=t.slice(s,t.length)),r=qc(r??t,n),{fullPath:r+a+o,path:r,query:i,hash:Ic(o)}}function Bc(e,t){let n=t.query?e(t.query):``;return t.path+(n&&`?`)+n+(t.hash||``)}function Vc(e,t){return!t||!e.toLowerCase().startsWith(t.toLowerCase())?e:e.slice(t.length)||`/`}function Hc(e,t,n){let r=t.matched.length-1,i=n.matched.length-1;return r>-1&&r===i&&Uc(t.matched[r],n.matched[i])&&Wc(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}function Uc(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function Wc(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n in e)if(!Gc(e[n],t[n]))return!1;return!0}function Gc(e,t){return mc(e)?Kc(e,t):mc(t)?Kc(t,e):e?.valueOf()===t?.valueOf()}function Kc(e,t){return mc(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e.length===1&&e[0]===t}function qc(e,t){if(e.startsWith(`/`))return e;if(!e)return t;let n=t.split(`/`),r=e.split(`/`),i=r[r.length-1];(i===`..`||i===`.`)&&r.push(``);let a=n.length-1,o,s;for(o=0;o1&&a--;else break;return n.slice(0,a).join(`/`)+`/`+r.slice(o).join(`/`)}var Jc={path:`/`,name:void 0,params:{},query:{},hash:``,fullPath:`/`,matched:[],meta:{},redirectedFrom:void 0},Yc=function(e){return e.pop=`pop`,e.push=`push`,e}({}),Xc=function(e){return e.back=`back`,e.forward=`forward`,e.unknown=``,e}({});function Zc(e){if(!e)if(lc){let t=document.querySelector(`base`);e=t&&t.getAttribute(`href`)||`/`,e=e.replace(/^\w+:\/\/[^\/]+/,``)}else e=`/`;return e[0]!==`/`&&e[0]!==`#`&&(e=`/`+e),Rc(e)}var Qc=/^[^#]+#/;function $c(e,t){return e.replace(Qc,`#`)+t}function el(e,t){let n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}var tl=()=>({left:window.scrollX,top:window.scrollY});function nl(e){let t;if(`el`in e){let n=e.el,r=typeof n==`string`&&n.startsWith(`#`),i=typeof n==`string`?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!i)return;t=el(i,e)}else t=e;`scrollBehavior`in document.documentElement.style?window.scrollTo(t):window.scrollTo(t.left==null?window.scrollX:t.left,t.top==null?window.scrollY:t.top)}function rl(e,t){return(history.state?history.state.position-t:-1)+e}var il=new Map;function al(e,t){il.set(e,t)}function ol(e){let t=il.get(e);return il.delete(e),t}function sl(e){return typeof e==`string`||e&&typeof e==`object`}function cl(e){return typeof e==`string`||typeof e==`symbol`}var Z=function(e){return e[e.MATCHER_NOT_FOUND=1]=`MATCHER_NOT_FOUND`,e[e.NAVIGATION_GUARD_REDIRECT=2]=`NAVIGATION_GUARD_REDIRECT`,e[e.NAVIGATION_ABORTED=4]=`NAVIGATION_ABORTED`,e[e.NAVIGATION_CANCELLED=8]=`NAVIGATION_CANCELLED`,e[e.NAVIGATION_DUPLICATED=16]=`NAVIGATION_DUPLICATED`,e}({}),ll=Symbol(``);Z.MATCHER_NOT_FOUND,Z.NAVIGATION_GUARD_REDIRECT,Z.NAVIGATION_ABORTED,Z.NAVIGATION_CANCELLED,Z.NAVIGATION_DUPLICATED;function ul(e,t){return X(Error(),{type:e,[ll]:!0},t)}function dl(e,t){return e instanceof Error&&ll in e&&(t==null||!!(e.type&t))}function fl(e){let t={};if(e===``||e===`?`)return t;let n=(e[0]===`?`?e.slice(1):e).split(`&`);for(let e=0;ee&&Mc(e)):[r&&Mc(r)]).forEach(e=>{e!==void 0&&(t+=(t.length?`&`:``)+n,e!=null&&(t+=`=`+e))})}return t}function ml(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=mc(r)?r.map(e=>e==null?null:``+e):r==null?r:``+r)}return t}var hl=Symbol(``),gl=Symbol(``),_l=Symbol(``),vl=Symbol(``),yl=Symbol(``);function bl(){let e=[];function t(t){return e.push(t),()=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)}}function n(){e=[]}return{add:t,list:()=>e.slice(),reset:n}}function xl(e,t,n,r,i,a=e=>e()){let o=r&&(r.enterCallbacks[i]=r.enterCallbacks[i]||[]);return()=>new Promise((s,c)=>{let l=e=>{e===!1?c(ul(Z.NAVIGATION_ABORTED,{from:n,to:t})):e instanceof Error?c(e):sl(e)?c(ul(Z.NAVIGATION_GUARD_REDIRECT,{from:t,to:e})):(o&&r.enterCallbacks[i]===o&&typeof e==`function`&&o.push(e),s())},u=a(()=>e.call(r&&r.instances[i],t,n,l)),d=Promise.resolve(u);e.length<3&&(d=d.then(l)),d.catch(e=>c(e))})}function Sl(e,t,n,r,i=e=>e()){let a=[];for(let o of e)for(let e in o.components){let s=o.components[e];if(!(t!==`beforeRouteEnter`&&!o.instances[e]))if(uc(s)){let c=(s.__vccOpts||s)[t];c&&a.push(xl(c,n,r,o,e,i))}else{let c=s();a.push(()=>c.then(a=>{if(!a)throw Error(`Couldn't resolve component "${e}" at "${o.path}"`);let s=dc(a)?a.default:a;o.mods[e]=a,o.components[e]=s;let c=(s.__vccOpts||s)[t];return c&&xl(c,n,r,o,e,i)()}))}}return a}function Cl(e,t){let n=[],r=[],i=[],a=Math.max(t.matched.length,e.matched.length);for(let o=0;oUc(e,a))?r.push(a):n.push(a));let s=e.matched[o];s&&(t.matched.find(e=>Uc(e,s))||i.push(s))}return[n,r,i]}var wl=()=>location.protocol+`//`+location.host;function Tl(e,t){let{pathname:n,search:r,hash:i}=t,a=e.indexOf(`#`);if(a>-1){let t=i.includes(e.slice(a))?e.slice(a).length:1,n=i.slice(t);return n[0]!==`/`&&(n=`/`+n),Vc(n,``)}return Vc(n,e)+r+i}function El(e,t,n,r){let i=[],a=[],o=null,s=({state:a})=>{let s=Tl(e,location),c=n.value,l=t.value,u=0;if(a){if(n.value=s,t.value=a,o&&o===c){o=null;return}u=l?a.position-l.position:0}else r(s);i.forEach(e=>{e(n.value,c,{delta:u,type:Yc.pop,direction:u?u>0?Xc.forward:Xc.back:Xc.unknown})})};function c(){o=n.value}function l(e){i.push(e);let t=()=>{let t=i.indexOf(e);t>-1&&i.splice(t,1)};return a.push(t),t}function u(){if(document.visibilityState===`hidden`){let{history:e}=window;if(!e.state)return;e.replaceState(X({},e.state,{scroll:tl()}),``)}}function d(){for(let e of a)e();a=[],window.removeEventListener(`popstate`,s),window.removeEventListener(`pagehide`,u),document.removeEventListener(`visibilitychange`,u)}return window.addEventListener(`popstate`,s),window.addEventListener(`pagehide`,u),document.addEventListener(`visibilitychange`,u),{pauseListeners:c,listen:l,destroy:d}}function Dl(e,t,n,r=!1,i=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:i?tl():null}}function Ol(e){let{history:t,location:n}=window,r={value:Tl(e,n)},i={value:t.state};i.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0);function a(r,a,o){let s=e.indexOf(`#`),c=s>-1?(n.host&&document.querySelector(`base`)?e:e.slice(s))+r:wl()+e+r;try{t[o?`replaceState`:`pushState`](a,``,c),i.value=a}catch(e){console.error(e),n[o?`replace`:`assign`](c)}}function o(e,n){a(e,X({},t.state,Dl(i.value.back,e,i.value.forward,!0),n,{position:i.value.position}),!0),r.value=e}function s(e,n){let o=X({},i.value,t.state,{forward:e,scroll:tl()});a(o.current,o,!0),a(e,X({},Dl(r.value,e,null),{position:o.position+1},n),!1),r.value=e}return{location:r,state:i,push:s,replace:o}}function kl(e){e=Zc(e);let t=Ol(e),n=El(e,t.state,t.location,t.replace);function r(e,t=!0){t||n.pauseListeners(),history.go(e)}let i=X({location:``,base:e,go:r,createHref:$c.bind(null,e)},t,n);return Object.defineProperty(i,`location`,{enumerable:!0,get:()=>t.location.value}),Object.defineProperty(i,`state`,{enumerable:!0,get:()=>t.state.value}),i}var Al=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.Group=2]=`Group`,e}({}),Q=function(e){return e[e.Static=0]=`Static`,e[e.Param=1]=`Param`,e[e.ParamRegExp=2]=`ParamRegExp`,e[e.ParamRegExpEnd=3]=`ParamRegExpEnd`,e[e.EscapeNext=4]=`EscapeNext`,e}(Q||{}),jl={type:Al.Static,value:``},Ml=/[a-zA-Z0-9_]/;function Nl(e){if(!e)return[[]];if(e===`/`)return[[jl]];if(!e.startsWith(`/`))throw Error(`Invalid path "${e}"`);function t(e){throw Error(`ERR (${n})/"${l}": ${e}`)}let n=Q.Static,r=n,i=[],a;function o(){a&&i.push(a),a=[]}let s=0,c,l=``,u=``;function d(){l&&=(n===Q.Static?a.push({type:Al.Static,value:l}):n===Q.Param||n===Q.ParamRegExp||n===Q.ParamRegExpEnd?(a.length>1&&(c===`*`||c===`+`)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:Al.Param,value:l,regexp:u,repeatable:c===`*`||c===`+`,optional:c===`*`||c===`?`})):t(`Invalid state to consume buffer`),``)}function f(){l+=c}for(;st.length?t.length===1&&t[0]===$.Static+$.Segment?1:-1:0}function zl(e,t){let n=0,r=e.score,i=t.score;for(;n0&&t[t.length-1]<0}var Vl={strict:!1,end:!0,sensitive:!1};function Hl(e,t,n){let r=X(Ll(Nl(e.path),n),{record:e,parent:t,children:[],alias:[]});return t&&!r.record.aliasOf==!t.record.aliasOf&&t.children.push(r),r}function Ul(e,t){let n=[],r=new Map;t=hc(Vl,t);function i(e){return r.get(e)}function a(e,n,r){let i=!r,s=Gl(e);s.aliasOf=r&&r.record;let l=hc(t,e),u=[s];if(`alias`in e){let t=typeof e.alias==`string`?[e.alias]:e.alias;for(let e of t)u.push(Gl(X({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s})))}let d,f;for(let t of u){let{path:u}=t;if(n&&u[0]!==`/`){let e=n.record.path,r=e[e.length-1]===`/`?``:`/`;t.path=n.record.path+(u&&r+u)}if(d=Hl(t,n,l),r?r.alias.push(d):(f||=d,f!==d&&f.alias.push(d),i&&e.name&&!ql(d)&&o(e.name)),Zl(d)&&c(d),s.children){let e=s.children;for(let t=0;t{o(f)}:pc}function o(e){if(cl(e)){let t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(o),t.alias.forEach(o))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(o),e.alias.forEach(o))}}function s(){return n}function c(e){let t=Yl(e,n);n.splice(t,0,e),e.record.name&&!ql(e)&&r.set(e.record.name,e)}function l(e,t){let i,a={},o,s;if(`name`in e&&e.name){if(i=r.get(e.name),!i)throw ul(Z.MATCHER_NOT_FOUND,{location:e});s=i.record.name,a=X(Wl(t.params,i.keys.filter(e=>!e.optional).concat(i.parent?i.parent.keys.filter(e=>e.optional):[]).map(e=>e.name)),e.params&&Wl(e.params,i.keys.map(e=>e.name))),o=i.stringify(a)}else if(e.path!=null)o=e.path,i=n.find(e=>e.re.test(o)),i&&(a=i.parse(o),s=i.record.name);else{if(i=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!i)throw ul(Z.MATCHER_NOT_FOUND,{location:e,currentLocation:t});s=i.record.name,a=X({},t.params,e.params),o=i.stringify(a)}let c=[],l=i;for(;l;)c.unshift(l.record),l=l.parent;return{name:s,path:o,params:a,matched:c,meta:Jl(c)}}e.forEach(e=>a(e));function u(){n.length=0,r.clear()}return{addRoute:a,resolve:l,removeRoute:o,clearRoutes:u,getRoutes:s,getRecordMatcher:i}}function Wl(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function Gl(e){let t={path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:e.aliasOf,beforeEnter:e.beforeEnter,props:Kl(e),children:e.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:`components`in e?e.components||null:e.component&&{default:e.component}};return Object.defineProperty(t,`mods`,{value:{}}),t}function Kl(e){let t={},n=e.props||!1;if(`component`in e)t.default=n;else for(let r in e.components)t[r]=typeof n==`object`?n[r]:n;return t}function ql(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function Jl(e){return e.reduce((e,t)=>X(e,t.meta),{})}function Yl(e,t){let n=0,r=t.length;for(;n!==r;){let i=n+r>>1;zl(e,t[i])<0?r=i:n=i+1}let i=Xl(e);return i&&(r=t.lastIndexOf(i,r-1)),r}function Xl(e){let t=e;for(;t=t.parent;)if(Zl(t)&&zl(e,t)===0)return t}function Zl({record:e}){return!!(e.name||e.components&&Object.keys(e.components).length||e.redirect)}function Ql(e){let t=h(_l),n=h(vl),r=xe(()=>{let n=l(e.to);return t.resolve(n)}),i=xe(()=>{let{matched:e}=r.value,{length:t}=e,i=e[t-1],a=n.matched;if(!i||!a.length)return-1;let o=a.findIndex(Uc.bind(null,i));if(o>-1)return o;let s=ru(e[t-2]);return t>1&&ru(i)===s&&a[a.length-1].path!==s?a.findIndex(Uc.bind(null,e[t-2])):o}),a=xe(()=>i.value>-1&&nu(n.params,r.value.params)),o=xe(()=>i.value>-1&&i.value===n.matched.length-1&&Wc(n.params,r.value.params));function s(n={}){if(tu(n)){let n=t[l(e.replace)?`replace`:`push`](l(e.to)).catch(pc);return e.viewTransition&&typeof document<`u`&&`startViewTransition`in document&&document.startViewTransition(()=>n),n}return Promise.resolve()}return{route:r,href:xe(()=>r.value.href),isActive:a,isExactActive:o,navigate:s}}function $l(e){return e.length===1?e[0]:e}var eu=Ce({name:`RouterLink`,compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:`page`},viewTransition:Boolean},useLink:Ql,setup(e,{slots:t}){let n=v(Ql(e)),{options:r}=h(_l),i=xe(()=>({[iu(e.activeClass,r.linkActiveClass,`router-link-active`)]:n.isActive,[iu(e.exactActiveClass,r.linkExactActiveClass,`router-link-exact-active`)]:n.isExactActive}));return()=>{let r=t.default&&$l(t.default(n));return e.custom?r:Te(`a`,{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:i.value},r)}}});function tu(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)&&!e.defaultPrevented&&!(e.button!==void 0&&e.button!==0)){if(e.currentTarget&&e.currentTarget.getAttribute){let t=e.currentTarget.getAttribute(`target`);if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}function nu(e,t){for(let n in t){let r=t[n],i=e[n];if(typeof r==`string`){if(r!==i)return!1}else if(!mc(i)||i.length!==r.length||r.some((e,t)=>e.valueOf()!==i[t].valueOf()))return!1}return!0}function ru(e){return e?e.aliasOf?e.aliasOf.path:e.path:``}var iu=(e,t,n)=>e??t??n,au=Ce({name:`RouterView`,inheritAttrs:!1,props:{name:{type:String,default:`default`},route:Object},compatConfig:{MODE:3},setup(e,{attrs:n,slots:r}){let i=h(yl),a=xe(()=>e.route||i.value),s=h(gl,0),c=xe(()=>{let e=l(s),{matched:t}=a.value,n;for(;(n=t[e])&&!n.components;)e++;return e}),u=xe(()=>a.value.matched[c.value]);t(gl,xe(()=>c.value+1)),t(hl,u),t(yl,a);let d=o();return m(()=>[d.value,u.value,e.name],([e,t,n],[r,i,a])=>{t&&(t.instances[n]=e,i&&i!==t&&e&&e===r&&(t.leaveGuards.size||(t.leaveGuards=i.leaveGuards),t.updateGuards.size||(t.updateGuards=i.updateGuards))),e&&t&&(!i||!Uc(t,i)||!r)&&(t.enterCallbacks[n]||[]).forEach(t=>t(e))},{flush:`post`}),()=>{let t=a.value,i=e.name,o=u.value,s=o&&o.components[i];if(!s)return ou(r.default,{Component:s,route:t});let c=o.props[i],l=Te(s,X({},c?c===!0?t.params:typeof c==`function`?c(t):c:null,n,{onVnodeUnmounted:e=>{e.component.isUnmounted&&(o.instances[i]=null)},ref:d}));return ou(r.default,{Component:l,route:t})||l}}});function ou(e,t){if(!e)return null;let n=e(t);return n.length===1?n[0]:n}var su=au;function cu(e){let t=Ul(e.routes,e),n=e.parseQuery||fl,r=e.stringifyQuery||pl,i=e.history,a=bl(),o=bl(),s=bl(),c=y(Jc),u=Jc;lc&&e.scrollBehavior&&`scrollRestoration`in history&&(history.scrollRestoration=`manual`);let d=fc.bind(null,e=>``+e),f=fc.bind(null,Fc),p=fc.bind(null,Ic);function m(e,n){let r,i;return cl(e)?(r=t.getRecordMatcher(e),i=n):i=e,t.addRoute(i,r)}function h(e){let n=t.getRecordMatcher(e);n&&t.removeRoute(n)}function g(){return t.getRoutes().map(e=>e.record)}function v(e){return!!t.getRecordMatcher(e)}function b(e,a){if(a=X({},a||c.value),typeof e==`string`){let r=zc(n,e,a.path),o=t.resolve({path:r.path},a),s=i.createHref(r.fullPath);return X(r,o,{params:p(o.params),hash:Ic(r.hash),redirectedFrom:void 0,href:s})}let o;if(e.path!=null)o=X({},e,{path:zc(n,e.path,a.path).path});else{let t=X({},e.params);for(let e in t)t[e]??delete t[e];o=X({},e,{params:f(t)}),a.params=f(a.params)}let s=t.resolve(o,a),l=e.hash||``;s.params=d(p(s.params));let u=Bc(r,X({},e,{hash:jc(l),path:s.path})),m=i.createHref(u);return X({fullPath:u,hash:l,query:r===pl?ml(e.query):e.query||{}},s,{redirectedFrom:void 0,href:m})}function x(e){return typeof e==`string`?zc(n,e,c.value.path):X({},e)}function S(e,t){if(u!==e)return ul(Z.NAVIGATION_CANCELLED,{from:t,to:e})}function C(e){return T(e)}function w(e){return C(X(x(e),{replace:!0}))}function ee(e,t){let n=e.matched[e.matched.length-1];if(n&&n.redirect){let{redirect:r}=n,i=typeof r==`function`?r(e,t):r;return typeof i==`string`&&(i=i.includes(`?`)||i.includes(`#`)?i=x(i):{path:i},i.params={}),X({query:e.query,hash:e.hash,params:i.path==null?e.params:{}},i)}}function T(e,t){let n=u=b(e),i=c.value,a=e.state,o=e.force,s=e.replace===!0,l=ee(n,i);if(l)return T(X(x(l),{state:typeof l==`object`?X({},a,l.state):a,force:o,replace:s}),t||n);let d=n;d.redirectedFrom=t;let f;return!o&&Hc(r,i,n)&&(f=ul(Z.NAVIGATION_DUPLICATED,{to:d,from:i}),ce(i,i,!0,!1)),(f?Promise.resolve(f):D(d,i)).catch(e=>dl(e)?dl(e,Z.NAVIGATION_GUARD_REDIRECT)?e:se(e):ae(e,d,i)).then(e=>{if(e){if(dl(e,Z.NAVIGATION_GUARD_REDIRECT))return T(X({replace:s},x(e.to),{state:typeof e.to==`object`?X({},a,e.to.state):a,force:o}),t||d)}else e=re(d,i,!0,s,a);return ne(d,i,e),e})}function te(e,t){let n=S(e,t);return n?Promise.reject(n):Promise.resolve()}function E(e){let t=de.values().next().value;return t&&typeof t.runWithContext==`function`?t.runWithContext(e):e()}function D(e,t){let n,[r,i,s]=Cl(e,t);n=Sl(r.reverse(),`beforeRouteLeave`,e,t);for(let i of r)i.leaveGuards.forEach(r=>{n.push(xl(r,e,t))});let c=te.bind(null,e,t);return n.push(c),fe(n).then(()=>{n=[];for(let r of a.list())n.push(xl(r,e,t));return n.push(c),fe(n)}).then(()=>{n=Sl(i,`beforeRouteUpdate`,e,t);for(let r of i)r.updateGuards.forEach(r=>{n.push(xl(r,e,t))});return n.push(c),fe(n)}).then(()=>{n=[];for(let r of s)if(r.beforeEnter)if(mc(r.beforeEnter))for(let i of r.beforeEnter)n.push(xl(i,e,t));else n.push(xl(r.beforeEnter,e,t));return n.push(c),fe(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=Sl(s,`beforeRouteEnter`,e,t,E),n.push(c),fe(n))).then(()=>{n=[];for(let r of o.list())n.push(xl(r,e,t));return n.push(c),fe(n)}).catch(e=>dl(e,Z.NAVIGATION_CANCELLED)?e:Promise.reject(e))}function ne(e,t,n){s.list().forEach(r=>E(()=>r(e,t,n)))}function re(e,t,n,r,a){let o=S(e,t);if(o)return o;let s=t===Jc,l=lc?history.state:{};n&&(r||s?i.replace(e.fullPath,X({scroll:s&&l&&l.scroll},a)):i.push(e.fullPath,a)),c.value=e,ce(e,t,n,s),se()}let O;function ie(){O||=i.listen((e,t,n)=>{if(!M.listening)return;let r=b(e),a=ee(r,M.currentRoute.value);if(a){T(X(a,{replace:!0,force:!0}),r).catch(pc);return}u=r;let o=c.value;lc&&al(rl(o.fullPath,n.delta),tl()),D(r,o).catch(e=>dl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_CANCELLED)?e:dl(e,Z.NAVIGATION_GUARD_REDIRECT)?(T(X(x(e.to),{force:!0}),r).then(e=>{dl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_DUPLICATED)&&!n.delta&&n.type===Yc.pop&&i.go(-1,!1)}).catch(pc),Promise.reject()):(n.delta&&i.go(-n.delta,!1),ae(e,r,o))).then(e=>{e||=re(r,o,!1),e&&(n.delta&&!dl(e,Z.NAVIGATION_CANCELLED)?i.go(-n.delta,!1):n.type===Yc.pop&&dl(e,Z.NAVIGATION_ABORTED|Z.NAVIGATION_DUPLICATED)&&i.go(-1,!1)),ne(r,o,e)}).catch(pc)})}let k=bl(),A=bl(),j;function ae(e,t,n){se(e);let r=A.list();return r.length?r.forEach(r=>r(e,t,n)):console.error(e),Promise.reject(e)}function oe(){return j&&c.value!==Jc?Promise.resolve():new Promise((e,t)=>{k.add([e,t])})}function se(e){return j||(j=!e,ie(),k.list().forEach(([t,n])=>e?n(e):t()),k.reset()),e}function ce(t,n,r,i){let{scrollBehavior:a}=e;if(!lc||!a)return Promise.resolve();let o=!r&&ol(rl(t.fullPath,0))||(i||!r)&&history.state&&history.state.scroll||null;return we().then(()=>a(t,n,o)).then(e=>e&&nl(e)).catch(e=>ae(e,t,n))}let le=e=>i.go(e),ue,de=new Set,M={currentRoute:c,listening:!0,addRoute:m,removeRoute:h,clearRoutes:t.clearRoutes,hasRoute:v,getRoutes:g,resolve:b,options:e,push:C,replace:w,go:le,back:()=>le(-1),forward:()=>le(1),beforeEach:a.add,beforeResolve:o.add,afterEach:s.add,onError:A.add,isReady:oe,install(e){e.component(`RouterLink`,eu),e.component(`RouterView`,su),e.config.globalProperties.$router=M,Object.defineProperty(e.config.globalProperties,`$route`,{enumerable:!0,get:()=>l(c)}),lc&&!ue&&c.value===Jc&&(ue=!0,C(i.location).catch(e=>{}));let t={};for(let e in Jc)Object.defineProperty(t,e,{get:()=>c.value[e],enumerable:!0});e.provide(_l,M),e.provide(vl,_(t)),e.provide(yl,c);let n=e.unmount;de.add(e),e.unmount=function(){de.delete(e),de.size<1&&(u=Jc,O&&O(),O=null,c.value=Jc,ue=!1,j=!1),n()}}};function fe(e){return e.reduce((e,t)=>e.then(()=>E(t)),Promise.resolve())}return M}function lu(){return h(_l)}function uu(e){return h(vl)}var du=he(`images`,()=>{let e=o([]),t=o(!1),n=o(null),r=o(0);async function i(r={}){r.silent||(t.value=!0),n.value=null;try{let t=await fetch(`/api/images`);if(!t.ok)throw Error(`Failed to load images`);e.value=await t.json()}catch(e){n.value=e instanceof Error?e.message:`Unknown error`}finally{t.value=!1}}async function a(t,n){let r=new FormData;r.append(`file`,t),n?.original&&r.append(`original`,n.original),n?.cropParams&&r.append(`cropParams`,JSON.stringify(n.cropParams)),n?.stickerState&&r.append(`stickerState`,JSON.stringify(n.stickerState)),n?.cropOrientation&&r.append(`cropOrientation`,n.cropOrientation);let i=await fetch(`/api/images`,{method:`POST`,body:r});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`Upload failed`)}let a=await i.json();return e.value.unshift(a),a}async function s(t,n,r){let i=new FormData;i.append(`file`,n),r?.cropParams&&i.append(`cropParams`,JSON.stringify(r.cropParams)),r?.stickerState&&i.append(`stickerState`,JSON.stringify(r.stickerState)),r?.cropOrientation&&i.append(`cropOrientation`,r.cropOrientation);let a=await fetch(`/api/images/${t}/reprocess`,{method:`POST`,body:i});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error??`Reprocess failed`)}let o=await a.json(),s=e.value.findIndex(e=>e.id===t);return s!==-1&&(e.value[s]=o),o}async function c(t){if(!(await fetch(`/api/images/${t}`,{method:`DELETE`})).ok)throw Error(`Delete failed`);e.value=e.value.filter(e=>e.id!==t)}async function l(t,n,r){let i=r?`POST`:`DELETE`,a=await fetch(`/api/images/${t}/approve/${n}`,{method:i});if(!a.ok)throw Error(`Failed to update approval`);let o=await a.json(),s=e.value.findIndex(e=>e.id===t);s!==-1&&(e.value[s]=o)}async function u(e,t=1,n=20){let r=new URLSearchParams({page:String(t),limit:String(n)});e&&r.set(`status`,e);let i=await fetch(`/api/shared-images?${r}`);if(!i.ok)throw Error(`Failed to load shared images`);return i.json()}async function d(){let e=await fetch(`/api/shared-images/pending-count`);e.ok&&(r.value=(await e.json()).count)}async function f(e,t){let n=await fetch(`/api/shared-images/${e}/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({deviceIds:t})});if(!n.ok)throw Error(`Failed to approve`);return r.value>0&&r.value--,n.json()}async function p(e){let t=await fetch(`/api/shared-images/${e}/decline`,{method:`POST`});if(!t.ok)throw Error(`Failed to decline`);return r.value>0&&r.value--,t.json()}async function m(e,t){let n=await fetch(`/api/images/${e}/share`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recipientEmail:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Failed to share`)}}return{images:e,loading:t,error:n,pendingCount:r,fetchImages:i,uploadImage:a,reprocessImage:s,deleteImage:c,setApproval:l,fetchSharedImages:u,fetchPendingCount:d,approveShared:f,declineShared:p,shareImage:m}}),fu={class:`bottom-nav`,"aria-label":`Main navigation`},pu={class:`bottom-nav__icon-wrap`,"aria-hidden":`true`},mu=[`innerHTML`],hu={key:0,class:`bottom-nav__badge`},gu={class:`bottom-nav__label`},_u=ye(Ce({__name:`BottomNav`,setup(e){let t=uu(),n=du(),r=[{name:`home`,label:`Home`,to:`/`,icon:``,isActive:e=>e.path===`/`},{name:`library`,label:`Library`,to:`/library`,icon:``,isActive:e=>e.path.startsWith(`/library`)},{name:`settings`,label:`Settings`,to:`/settings`,icon:``,isActive:e=>e.path.startsWith(`/settings`)}];return(e,i)=>{let a=d(`RouterLink`);return j(),se(`nav`,fu,[(j(),se(_e,null,A(r,e=>C(a,{key:e.name,to:e.to,class:D([`bottom-nav__tab`,{"bottom-nav__tab--active":e.isActive(l(t))}]),"aria-label":e.label,"aria-current":e.isActive(l(t))?`page`:void 0},{default:De(()=>[E(`span`,pu,[E(`span`,{class:`bottom-nav__icon`,innerHTML:e.icon},null,8,mu),e.name===`library`&&l(n).pendingCount>0?(j(),se(`span`,hu,pe(l(n).pendingCount>9?`9+`:l(n).pendingCount),1)):fe(``,!0)]),E(`span`,gu,pe(e.label),1)]),_:2},1032,[`to`,`class`,`aria-label`,`aria-current`])),64))])}}}),[[`__scopeId`,`data-v-e670448a`]]),vu=0,yu=he(`toast`,()=>{let e=o([]);function t(t,r=`info`){let i=++vu;e.value.push({id:i,message:t,type:r}),setTimeout(()=>n(i),2500)}function n(t){let n=e.value.findIndex(e=>e.id===t);n!==-1&&e.value.splice(n,1)}return{toasts:e,show:t,dismiss:n}}),bu={class:`toast-region`,"aria-live":`polite`,"aria-atomic":`false`},xu=[`onClick`],Su=ye(Ce({__name:`BaseToast`,setup(e){let t=yu();return(e,n)=>(j(),se(`div`,bu,[C(It,{name:`toast`,tag:`ul`,class:`toast-list`},{default:De(()=>[(j(!0),se(_e,null,A(l(t).toasts,e=>(j(),se(`li`,{key:e.id,class:D([`toast`,`toast--${e.type}`]),role:`status`},[O(pe(e.message)+` `,1),E(`button`,{class:`toast__close`,"aria-label":`Dismiss`,onClick:n=>l(t).dismiss(e.id)},` × `,8,xu)],2))),128))]),_:1})]))}}),[[`__scopeId`,`data-v-546af507`]]),Cu=he(`auth`,()=>{let e=o(window.__PF_USER__??null),t=xe(()=>e.value!==null);function n(t){e.value=t}return{user:e,isAuthenticated:t,setUser:n}}),wu=[{id:`warm-craft`,label:`Warm Craft`,primary:`#c97c3a`,bg:`#fdf6ee`,text:`#3a2e22`},{id:`playful-pop`,label:`Playful Pop`,primary:`#d63aab`,bg:`#fff0fb`,text:`#2d0a28`},{id:`sage-cream`,label:`Sage & Cream`,primary:`#4e7c3a`,bg:`#f6f8f3`,text:`#1e2b1a`},{id:`dusty-mauve`,label:`Dusty Mauve`,primary:`#8e4a84`,bg:`#f6f0f4`,text:`#2a1828`},{id:`ocean-dusk`,label:`Ocean Dusk`,primary:`#1a6ea8`,bg:`#eef3f8`,text:`#0e2030`},{id:`honey-slate`,label:`Honey & Slate`,primary:`#c49a20`,bg:`#f2f2ee`,text:`#1c1c18`}];function Tu(){let e=Cu(),t=yu();function n(t){document.documentElement.dataset.theme=t,e.user&&(e.user.theme=t);let n=wu.find(e=>e.id===t);if(n){let e=document.querySelector(`meta[name="theme-color"]`);e&&e.setAttribute(`content`,n.bg)}}async function r(e){n(e);try{if(!(await fetch(`/api/user/theme`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({theme:e})})).ok)throw Error(`Failed to save theme`)}catch{t.show(`Could not save theme — try again`,`error`)}}return{THEMES:wu,applyTheme:n,saveTheme:r}}var Eu=Ce({__name:`App`,setup(e){let t=uu(),n=Cu(),{applyTheme:i}=Tu();return r(()=>{let e=document.documentElement.dataset.theme||n.user?.theme;e&&i(e)}),(e,n)=>{let r=d(`RouterView`);return j(),se(_e,null,[C(r),l(t).meta.hideNav?fe(``,!0):(j(),re(_u,{key:0})),C(Su)],64)}}}),Du=`modulepreload`,Ou=function(e){return`/build/`+e},ku={},Au=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Ou(t,n),t in ku)return;ku[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Du,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ju=cu({history:kl(),routes:[{path:`/`,name:`home`,component:()=>Au(()=>import(`./HomeView-D07qrHpY.js`),__vite__mapDeps([0,1,2,3,4,5,6])),meta:{requiresAuth:!0}},{path:`/library`,name:`library`,component:()=>Au(()=>import(`./LibraryView-Czb8zdcL.js`),__vite__mapDeps([7,1,2,3,8,9,4,5,10])),meta:{requiresAuth:!0}},{path:`/upload`,name:`upload`,component:()=>Au(()=>import(`./UploadView-DaSwla70.js`),__vite__mapDeps([11,1,2,3,8,9,12])),meta:{requiresAuth:!0,hideNav:!0}},{path:`/settings`,name:`settings`,component:()=>Au(()=>import(`./SettingsView-CX4Yi75h.js`),__vite__mapDeps([13,1,14])),meta:{requiresAuth:!0}},{path:`/shared`,redirect:`/library?tab=shared`},{path:`/:pathMatch(.*)*`,redirect:`/`}]});ju.beforeEach(e=>{let t=Cu();if(e.meta.requiresAuth&&!t.isAuthenticated)return window.location.href=`/login`,!1});var Mu=ln(Eu);Mu.use(le()),Mu.use(ju),Mu.use(cc),Mu.mount(`#app`);export{du as a,Ve as c,qt as d,an as f,yu as i,Jt as l,Tu as n,uu as o,nn as p,Cu as r,lu as s,wu as t,Xt as u};