@htmlbricks/hb-stylus-paper 0.66.2 → 0.66.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.iife.js +2 -2
- package/main.iife.js.map +1 -1
- package/manifest.json +3 -1
- package/package.json +1 -1
package/main.iife.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(wr){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");const ns=1,rs=2,is=16,ss=1,os=4,as=8,ls=16,fs=2,yr="[",Pn="[!",br="[?",Ln="]",Ft={},se=Symbol(),xr="http://www.w3.org/1999/xhtml",us=!1;var Er=Array.isArray,cs=Array.prototype.indexOf,Xt=Array.prototype.includes,mn=Array.from,wn=Object.keys,yn=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,ds=Object.getOwnPropertyDescriptors,hs=Object.prototype,vs=Array.prototype,$r=Object.getPrototypeOf,Sr=Object.isExtensible;const ps=()=>{};function _s(e){for(var t=0;t<e.length;t++)e[t]()}function Tr(){var e,t,n=new Promise((r,s)=>{e=r,t=s});return{promise:n,resolve:e,reject:t}}const ie=2,zt=4,bn=8,Dr=1<<24,it=16,Le=32,st=64,qn=128,Me=512,re=1024,ce=2048,He=4096,Se=8192,ke=16384,ot=32768,Ar=1<<25,Ht=65536,Ir=1<<17,gs=1<<18,$t=1<<19,ms=1<<20,Ke=1<<25,St=65536,jn=1<<21,Yn=1<<22,at=1<<23,xn=Symbol("$state"),Mr=Symbol("legacy props"),ws=Symbol(""),Ze=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ys=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml"),En=3,en=8;function bs(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function xs(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function Es(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function $s(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Ss(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function Ts(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Ds(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function As(){throw new Error("https://svelte.dev/e/hydration_failed")}function Is(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Ms(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function ks(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Os(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function Ns(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function $n(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function Rs(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let Y=!1;function Qe(e){Y=e}let C;function Te(e){if(e===null)throw $n(),Ft;return C=e}function Sn(){return Te(Be(C))}function lt(e){if(Y){if(Be(C)!==null)throw $n(),Ft;C=e}}function Cs(e=1){if(Y){for(var t=e,n=C;t--;)n=Be(n);C=n}}function Tn(e=!0){for(var t=0,n=C;;){if(n.nodeType===en){var r=n.data;if(r===Ln){if(t===0)return n;t-=1}else(r===yr||r===Pn||r[0]==="["&&!isNaN(Number(r.slice(1))))&&(t+=1)}var s=Be(n);e&&n.remove(),n=s}}function kr(e){if(!e||e.nodeType!==en)throw $n(),Ft;return e.data}function Or(e){return e===this.v}function Ps(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Nr(e){return!Ps(e,this.v)}let Ls=!1,De=null;function Bt(e){De=e}function Rr(e,t=!1,n){De={p:De,i:!1,c:null,e:null,s:e,x:null,r:N,l:null}}function Cr(e){var t=De,n=t.e;if(n!==null){t.e=null;for(var r of n)fi(r)}return e!==void 0&&(t.x=e),t.i=!0,De=t.p,e??{}}function Pr(){return!0}let Tt=[];function Lr(){var e=Tt;Tt=[],_s(e)}function Vt(e){if(Tt.length===0&&!tn){var t=Tt;queueMicrotask(()=>{t===Tt&&Lr()})}Tt.push(e)}function qs(){for(;Tt.length>0;)Lr()}function qr(e){var t=N;if(t===null)return O.f|=at,e;if((t.f&ot)===0&&(t.f&zt)===0)throw e;ft(e,t)}function ft(e,t){for(;t!==null;){if((t.f&qn)!==0){if((t.f&ot)===0)throw e;try{t.b.error(e);return}catch(n){e=n}}t=t.parent}throw e}const js=-7169;function ee(e,t){e.f=e.f&js|t}function Fn(e){(e.f&Me)!==0||e.deps===null?ee(e,re):ee(e,He)}function jr(e){if(e!==null)for(const t of e)(t.f&ie)===0||(t.f&St)===0||(t.f^=St,jr(t.deps))}function Yr(e,t,n){(e.f&ce)!==0?t.add(e):(e.f&He)!==0&&n.add(e),jr(e.deps),ee(e,re)}let Dn=!1;function Ys(e){var t=Dn;try{return Dn=!1,[e(),Dn]}finally{Dn=t}}const ut=new Set;let V=null,qe=null,Xn=null,tn=!1,zn=!1,Wt=null,An=null;var Fr=0;let Fs=1;class et{id=Fs++;current=new Map;previous=new Map;#e=new Set;#n=new Set;#t=new Map;#i=new Map;#s=null;#r=[];#o=new Set;#a=new Set;#l=new Map;is_fork=!1;#c=!1;#f=new Set;#d(){return this.is_fork||this.#i.size>0}#v(){for(const r of this.#f)for(const s of r.#i.keys()){for(var t=!1,n=s;n.parent!==null;){if(this.#l.has(n)){t=!0;break}n=n.parent}if(!t)return!0}return!1}skip_effect(t){this.#l.has(t)||this.#l.set(t,{d:[],m:[]})}unskip_effect(t){var n=this.#l.get(t);if(n){this.#l.delete(t);for(var r of n.d)ee(r,ce),this.schedule(r);for(r of n.m)ee(r,He),this.schedule(r)}}#h(){if(Fr++>1e3&&(ut.delete(this),Xs()),!this.#d()){for(const a of this.#o)this.#a.delete(a),ee(a,ce),this.schedule(a);for(const a of this.#a)ee(a,He),this.schedule(a)}const t=this.#r;this.#r=[],this.apply();var n=Wt=[],r=[],s=An=[];for(const a of t)try{this.#u(a,n,r)}catch(f){throw Vr(a),f}if(V=null,s.length>0){var o=et.ensure();for(const a of s)o.schedule(a)}if(Wt=null,An=null,this.#d()||this.#v()){this.#p(r),this.#p(n);for(const[a,f]of this.#l)Br(a,f)}else{this.#t.size===0&&ut.delete(this),this.#o.clear(),this.#a.clear();for(const a of this.#e)a(this);this.#e.clear(),Xr(r),Xr(n),this.#s?.resolve()}var l=V;if(this.#r.length>0){const a=l??=this;a.#r.push(...this.#r.filter(f=>!a.#r.includes(f)))}l!==null&&(ut.add(l),l.#h()),ut.has(this)||this.#_()}#u(t,n,r){t.f^=re;for(var s=t.first;s!==null;){var o=s.f,l=(o&(Le|st))!==0,a=l&&(o&re)!==0,f=a||(o&Se)!==0||this.#l.has(s);if(!f&&s.fn!==null){l?s.f^=re:(o&zt)!==0?n.push(s):sn(s)&&((o&it)!==0&&this.#a.add(s),Jt(s));var c=s.first;if(c!==null){s=c;continue}}for(;s!==null;){var h=s.next;if(h!==null){s=h;break}s=s.parent}}}#p(t){for(var n=0;n<t.length;n+=1)Yr(t[n],this.#o,this.#a)}capture(t,n,r=!1){n!==se&&!this.previous.has(t)&&this.previous.set(t,n),(t.f&at)===0&&(this.current.set(t,[t.v,r]),qe?.set(t,t.v))}activate(){V=this}deactivate(){V=null,qe=null}flush(){try{zn=!0,V=this,this.#h()}finally{Fr=0,Xn=null,Wt=null,An=null,zn=!1,V=null,qe=null,ct.clear()}}discard(){for(const t of this.#n)t(this);this.#n.clear(),ut.delete(this)}#_(){for(const c of ut){var t=c.id<this.id,n=[];for(const[h,[_,v]]of this.current){if(c.current.has(h)){var r=c.current.get(h)[0];if(t&&_!==r)c.current.set(h,[_,v]);else continue}n.push(h)}var s=[...c.current.keys()].filter(h=>!this.current.has(h));if(s.length===0)t&&c.discard();else if(n.length>0){c.activate();var o=new Set,l=new Map;for(var a of n)zr(a,s,o,l);if(c.#r.length>0){c.apply();for(var f of c.#r)c.#u(f,[],[]);c.#r=[]}c.deactivate()}}for(const c of ut)c.#f.has(this)&&(c.#f.delete(this),c.#f.size===0&&!c.#d()&&(c.activate(),c.#h()))}increment(t,n){let r=this.#t.get(n)??0;if(this.#t.set(n,r+1),t){let s=this.#i.get(n)??0;this.#i.set(n,s+1)}}decrement(t,n,r){let s=this.#t.get(n)??0;if(s===1?this.#t.delete(n):this.#t.set(n,s-1),t){let o=this.#i.get(n)??0;o===1?this.#i.delete(n):this.#i.set(n,o-1)}this.#c||r||(this.#c=!0,Vt(()=>{this.#c=!1,this.flush()}))}transfer_effects(t,n){for(const r of t)this.#o.add(r);for(const r of n)this.#a.add(r);t.clear(),n.clear()}oncommit(t){this.#e.add(t)}ondiscard(t){this.#n.add(t)}settled(){return(this.#s??=Tr()).promise}static ensure(){if(V===null){const t=V=new et;zn||(ut.add(V),tn||Vt(()=>{V===t&&t.flush()}))}return V}apply(){{qe=null;return}}schedule(t){if(Xn=t,t.b?.is_pending&&(t.f&(zt|bn|Dr))!==0&&(t.f&ot)===0){t.b.defer_effect(t);return}for(var n=t;n.parent!==null;){n=n.parent;var r=n.f;if(Wt!==null&&n===N&&(O===null||(O.f&ie)===0))return;if((r&(st|Le))!==0){if((r&re)===0)return;n.f^=re}}this.#r.push(n)}}function de(e){var t=tn;tn=!0;try{for(var n;;){if(qs(),V===null)return n;V.flush()}}finally{tn=t}}function Xs(){try{Ds()}catch(e){ft(e,Xn)}}let tt=null;function Xr(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if((r.f&(ke|Se))===0&&sn(r)&&(tt=new Set,Jt(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&di(r),tt?.size>0)){ct.clear();for(const s of tt){if((s.f&(ke|Se))!==0)continue;const o=[s];let l=s.parent;for(;l!==null;)tt.has(l)&&(tt.delete(l),o.push(l)),l=l.parent;for(let a=o.length-1;a>=0;a--){const f=o[a];(f.f&(ke|Se))===0&&Jt(f)}}tt.clear()}}tt=null}}function zr(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const s of e.reactions){const o=s.f;(o&ie)!==0?zr(s,t,n,r):(o&(Yn|it))!==0&&(o&ce)===0&&Hr(s,t,r)&&(ee(s,ce),Hn(s))}}function Hr(e,t,n){const r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(const s of e.deps){if(Xt.call(t,s))return!0;if((s.f&ie)!==0&&Hr(s,t,n))return n.set(s,!0),!0}return n.set(e,!1),!1}function Hn(e){V.schedule(e)}function Br(e,t){if(!((e.f&Le)!==0&&(e.f&re)!==0)){(e.f&ce)!==0?t.d.push(e):(e.f&He)!==0&&t.m.push(e),ee(e,re);for(var n=e.first;n!==null;)Br(n,t),n=n.next}}function Vr(e){ee(e,re);for(var t=e.first;t!==null;)Vr(t),t=t.next}function zs(e){let t=0,n=Dt(0),r;return()=>{Kn()&&(i(n),ui(()=>(t===0&&(r=nr(()=>e(()=>rn(n)))),t+=1,()=>{Vt(()=>{t-=1,t===0&&(r?.(),r=void 0,rn(n))})})))}}var Hs=Ht|$t;function Bs(e,t,n,r){new Vs(e,t,n,r)}class Vs{parent;is_pending=!1;transform_error;#e;#n=Y?C:null;#t;#i;#s;#r=null;#o=null;#a=null;#l=null;#c=0;#f=0;#d=!1;#v=new Set;#h=new Set;#u=null;#p=zs(()=>(this.#u=Dt(this.#c),()=>{this.#u=null}));constructor(t,n,r,s){this.#e=t,this.#t=n,this.#i=o=>{var l=N;l.b=this,l.f|=qn,r(o)},this.parent=N.b,this.transform_error=s??this.parent?.transform_error??(o=>o),this.#s=Zn(()=>{if(Y){const o=this.#n;Sn();const l=o.data===Pn;if(o.data.startsWith(br)){const f=JSON.parse(o.data.slice(br.length));this.#b(f)}else l?this.#x():this.#_()}else this.#w()},Hs),Y&&(this.#e=C)}#_(){try{this.#r=Oe(()=>this.#i(this.#e))}catch(t){this.error(t)}}#b(t){const n=this.#t.failed;n&&(this.#a=Oe(()=>{n(this.#e,()=>t,()=>()=>{})}))}#x(){const t=this.#t.pending;t&&(this.is_pending=!0,this.#o=Oe(()=>t(this.#e)),Vt(()=>{var n=this.#l=document.createDocumentFragment(),r=je();n.append(r),this.#r=this.#m(()=>Oe(()=>this.#i(r))),this.#f===0&&(this.#e.before(n),this.#l=null,It(this.#o,()=>{this.#o=null}),this.#g(V))}))}#w(){try{if(this.is_pending=this.has_pending_snippet(),this.#f=0,this.#c=0,this.#r=Oe(()=>{this.#i(this.#e)}),this.#f>0){var t=this.#l=document.createDocumentFragment();tr(this.#r,t);const n=this.#t.pending;this.#o=Oe(()=>n(this.#e))}else this.#g(V)}catch(n){this.error(n)}}#g(t){this.is_pending=!1,t.transfer_effects(this.#v,this.#h)}defer_effect(t){Yr(t,this.#v,this.#h)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#t.pending}#m(t){var n=N,r=O,s=De;Ue(this.#s),Ne(this.#s),Bt(this.#s.ctx);try{return et.ensure(),t()}catch(o){return qr(o),null}finally{Ue(n),Ne(r),Bt(s)}}#y(t,n){if(!this.has_pending_snippet()){this.parent&&this.parent.#y(t,n);return}this.#f+=t,this.#f===0&&(this.#g(n),this.#o&&It(this.#o,()=>{this.#o=null}),this.#l&&(this.#e.before(this.#l),this.#l=null))}update_pending_count(t,n){this.#y(t,n),this.#c+=t,!(!this.#u||this.#d)&&(this.#d=!0,Vt(()=>{this.#d=!1,this.#u&&Ut(this.#u,this.#c)}))}get_effect_pending(){return this.#p(),i(this.#u)}error(t){var n=this.#t.onerror;let r=this.#t.failed;if(!n&&!r)throw t;this.#r&&(_e(this.#r),this.#r=null),this.#o&&(_e(this.#o),this.#o=null),this.#a&&(_e(this.#a),this.#a=null),Y&&(Te(this.#n),Cs(),Te(Tn()));var s=!1,o=!1;const l=()=>{if(s){Rs();return}s=!0,o&&Ns(),this.#a!==null&&It(this.#a,()=>{this.#a=null}),this.#m(()=>{this.#w()})},a=f=>{try{o=!0,n?.(f,l),o=!1}catch(c){ft(c,this.#s&&this.#s.parent)}r&&(this.#a=this.#m(()=>{try{return Oe(()=>{var c=N;c.b=this,c.f|=qn,r(this.#e,()=>f,()=>l)})}catch(c){return ft(c,this.#s.parent),null}}))};Vt(()=>{var f;try{f=this.transform_error(t)}catch(c){ft(c,this.#s&&this.#s.parent);return}f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(a,c=>ft(c,this.#s&&this.#s.parent)):a(f)})}}function Ws(e,t,n,r){const s=Bn;var o=e.filter(v=>!v.settled);if(n.length===0&&o.length===0){r(t.map(s));return}var l=N,a=Us(),f=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(v=>v.promise)):null;function c(v){a();try{r(v)}catch(g){(l.f&ke)===0&&ft(g,l)}In()}if(n.length===0){f.then(()=>c(t.map(s)));return}var h=Wr();function _(){Promise.all(n.map(v=>Js(v))).then(v=>c([...t.map(s),...v])).catch(v=>ft(v,l)).finally(()=>h())}f?f.then(()=>{a(),_(),In()}):_()}function Us(){var e=N,t=O,n=De,r=V;return function(o=!0){Ue(e),Ne(t),Bt(n),o&&(e.f&ke)===0&&(r?.activate(),r?.apply())}}function In(e=!0){Ue(null),Ne(null),Bt(null),e&&V?.deactivate()}function Wr(){var e=N,t=e.b,n=V,r=t.is_rendered();return t.update_pending_count(1,n),n.increment(r,e),(s=!1)=>{t.update_pending_count(-1,n),n.decrement(r,e,s)}}function Bn(e){var t=ie|ce,n=O!==null&&(O.f&ie)!==0?O:null;return N!==null&&(N.f|=$t),{ctx:De,deps:null,effects:null,equals:Or,f:t,fn:e,reactions:null,rv:0,v:se,wv:0,parent:n??N,ac:null}}function Js(e,t,n){let r=N;r===null&&xs();var s=void 0,o=Dt(se),l=!O,a=new Map;return oo(()=>{var f=N,c=Tr();s=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(In)}catch(g){c.reject(g),In()}var h=V;if(l){if((f.f&ot)!==0)var _=Wr();if(r.b.is_rendered())a.get(h)?.reject(Ze),a.delete(h);else{for(const g of a.values())g.reject(Ze);a.clear()}a.set(h,c)}const v=(g,d=void 0)=>{if(_){var y=d===Ze;_(y)}if(!(d===Ze||(f.f&ke)!==0)){if(h.activate(),d)o.f|=at,Ut(o,d);else{(o.f&at)!==0&&(o.f^=at),Ut(o,g);for(const[E,D]of a){if(a.delete(E),E===h)break;D.reject(Ze)}}h.deactivate()}};c.promise.then(v,g=>v(null,g||"unknown"))}),no(()=>{for(const f of a.values())f.reject(Ze)}),new Promise(f=>{function c(h){function _(){h===s?f(o):c(s)}h.then(_,_)}c(s)})}function Ur(e){const t=Bn(e);return t.equals=Nr,t}function Gs(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)_e(t[n])}}function Ks(e){for(var t=e.parent;t!==null;){if((t.f&ie)===0)return(t.f&ke)===0?t:null;t=t.parent}return null}function Vn(e){var t,n=N;Ue(Ks(e));try{e.f&=~St,Gs(e),t=yi(e)}finally{Ue(n)}return t}function Jr(e){var t=e.v,n=Vn(e);if(!e.equals(n)&&(e.wv=mi(),(!V?.is_fork||e.deps===null)&&(e.v=n,V?.capture(e,t,!0),e.deps===null))){ee(e,re);return}vt||(qe!==null?(Kn()||V?.is_fork)&&qe.set(e,n):Fn(e))}function Zs(e){if(e.effects!==null)for(const t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(Ze),t.teardown=ps,t.ac=null,on(t,0),Qn(t))}function Gr(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&Jt(t)}let Wn=new Set;const ct=new Map;let Kr=!1;function Dt(e,t){var n={f:0,v:e,reactions:null,equals:Or,rv:0,wv:0};return n}function A(e,t){const n=Dt(e);return fo(n),n}function Zr(e,t=!1,n=!0){const r=Dt(e);return t||(r.equals=Nr),r}function p(e,t,n=!1){O!==null&&(!Ye||(O.f&Ir)!==0)&&Pr()&&(O.f&(ie|it|Yn|Ir))!==0&&(Re===null||!Xt.call(Re,e))&&Os();let r=n?dt(t):t;return Ut(e,r,An)}function Ut(e,t,n=null){if(!e.equals(t)){var r=e.v;vt?ct.set(e,t):ct.set(e,r),e.v=t;var s=et.ensure();if(s.capture(e,r),(e.f&ie)!==0){const o=e;(e.f&ce)!==0&&Vn(o),qe===null&&Fn(o)}e.wv=mi(),Qr(e,ce,n),N!==null&&(N.f&re)!==0&&(N.f&(Le|st))===0&&(Ce===null?uo([e]):Ce.push(e)),!s.is_fork&&Wn.size>0&&!Kr&&Qs()}return t}function Qs(){Kr=!1;for(const e of Wn)(e.f&re)!==0&&ee(e,He),sn(e)&&Jt(e);Wn.clear()}function nn(e,t=1){var n=i(e),r=t===1?n++:n--;return p(e,n),r}function rn(e){p(e,e.v+1)}function Qr(e,t,n){var r=e.reactions;if(r!==null)for(var s=r.length,o=0;o<s;o++){var l=r[o],a=l.f,f=(a&ce)===0;if(f&&ee(l,t),(a&ie)!==0){var c=l;qe?.delete(c),(a&St)===0&&(a&Me&&(l.f|=St),Qr(c,He,n))}else if(f){var h=l;(a&it)!==0&&tt!==null&&tt.add(h),n!==null?n.push(h):Hn(h)}}}function dt(e){if(typeof e!="object"||e===null||xn in e)return e;const t=$r(e);if(t!==hs&&t!==vs)return e;var n=new Map,r=Er(e),s=A(0),o=kt,l=a=>{if(kt===o)return a();var f=O,c=kt;Ne(null),gi(o);var h=a();return Ne(f),gi(c),h};return r&&n.set("length",A(e.length)),new Proxy(e,{defineProperty(a,f,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&Ms();var h=n.get(f);return h===void 0?l(()=>{var _=A(c.value);return n.set(f,_),_}):p(h,c.value,!0),!0},deleteProperty(a,f){var c=n.get(f);if(c===void 0){if(f in a){const h=l(()=>A(se));n.set(f,h),rn(s)}}else p(c,se),rn(s);return!0},get(a,f,c){if(f===xn)return e;var h=n.get(f),_=f in a;if(h===void 0&&(!_||Et(a,f)?.writable)&&(h=l(()=>{var g=dt(_?a[f]:se),d=A(g);return d}),n.set(f,h)),h!==void 0){var v=i(h);return v===se?void 0:v}return Reflect.get(a,f,c)},getOwnPropertyDescriptor(a,f){var c=Reflect.getOwnPropertyDescriptor(a,f);if(c&&"value"in c){var h=n.get(f);h&&(c.value=i(h))}else if(c===void 0){var _=n.get(f),v=_?.v;if(_!==void 0&&v!==se)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return c},has(a,f){if(f===xn)return!0;var c=n.get(f),h=c!==void 0&&c.v!==se||Reflect.has(a,f);if(c!==void 0||N!==null&&(!h||Et(a,f)?.writable)){c===void 0&&(c=l(()=>{var v=h?dt(a[f]):se,g=A(v);return g}),n.set(f,c));var _=i(c);if(_===se)return!1}return h},set(a,f,c,h){var _=n.get(f),v=f in a;if(r&&f==="length")for(var g=c;g<_.v;g+=1){var d=n.get(g+"");d!==void 0?p(d,se):g in a&&(d=l(()=>A(se)),n.set(g+"",d))}if(_===void 0)(!v||Et(a,f)?.writable)&&(_=l(()=>A(void 0)),p(_,dt(c)),n.set(f,_));else{v=_.v!==se;var y=l(()=>dt(c));p(_,y)}var E=Reflect.getOwnPropertyDescriptor(a,f);if(E?.set&&E.set.call(h,c),!v){if(r&&typeof f=="string"){var D=n.get("length"),$=Number(f);Number.isInteger($)&&$>=D.v&&p(D,$+1)}rn(s)}return!0},ownKeys(a){i(s);var f=Reflect.ownKeys(a).filter(_=>{var v=n.get(_);return v===void 0||v.v!==se});for(var[c,h]of n)h.v!==se&&!(c in a)&&f.push(c);return f},setPrototypeOf(){ks()}})}var ei,ti,ni,ri;function Un(){if(ei===void 0){ei=window,ti=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;ni=Et(t,"firstChild").get,ri=Et(t,"nextSibling").get,Sr(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),Sr(n)&&(n.__t=void 0)}}function je(e=""){return document.createTextNode(e)}function At(e){return ni.call(e)}function Be(e){return ri.call(e)}function ht(e,t){if(!Y)return At(e);var n=At(C);if(n===null)n=C.appendChild(je());else if(t&&n.nodeType!==En){var r=je();return n?.before(r),Te(r),r}return t&&Gn(n),Te(n),n}function Ve(e,t=!1){if(!Y){var n=At(e);return n instanceof Comment&&n.data===""?Be(n):n}if(t){if(C?.nodeType!==En){var r=je();return C?.before(r),Te(r),r}Gn(C)}return C}function ii(e,t=1,n=!1){let r=Y?C:e;for(var s;t--;)s=r,r=Be(r);if(!Y)return r;if(n){if(r?.nodeType!==En){var o=je();return r===null?s?.after(o):r.before(o),Te(o),o}Gn(r)}return Te(r),r}function si(e){e.textContent=""}function oi(){return!1}function Jn(e,t,n){return document.createElementNS(xr,e,void 0)}function Gn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===En;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function ai(e){var t=O,n=N;Ne(null),Ue(null);try{return e()}finally{Ne(t),Ue(n)}}function eo(e){N===null&&(O===null&&Ts(),Ss()),vt&&$s()}function to(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function We(e,t){var n=N;n!==null&&(n.f&Se)!==0&&(e|=Se);var r={ctx:De,deps:null,nodes:null,f:e|ce|Me,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null},s=r;if((e&zt)!==0)Wt!==null?Wt.push(r):et.ensure().schedule(r);else if(t!==null){try{Jt(r)}catch(l){throw _e(r),l}s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&$t)===0&&(s=s.first,(e&it)!==0&&(e&Ht)!==0&&s!==null&&(s.f|=Ht))}if(s!==null&&(s.parent=n,n!==null&&to(s,n),O!==null&&(O.f&ie)!==0&&(e&st)===0)){var o=O;(o.effects??=[]).push(s)}return r}function Kn(){return O!==null&&!Ye}function no(e){const t=We(bn,null);return ee(t,re),t.teardown=e,t}function li(e){eo();var t=N.f,n=!O&&(t&Le)!==0&&(t&ot)===0;if(n){var r=De;(r.e??=[]).push(e)}else return fi(e)}function fi(e){return We(zt|ms,e)}function ro(e){et.ensure();const t=We(st|$t,e);return()=>{_e(t)}}function io(e){et.ensure();const t=We(st|$t,e);return(n={})=>new Promise(r=>{n.outro?It(t,()=>{_e(t),r(void 0)}):(_e(t),r(void 0))})}function so(e){return We(zt,e)}function oo(e){return We(Yn|$t,e)}function ui(e,t=0){return We(bn|t,e)}function oe(e,t=[],n=[],r=[]){Ws(r,t,n,s=>{We(bn,()=>e(...s.map(i)))})}function Zn(e,t=0){var n=We(it|t,e);return n}function Oe(e){return We(Le|$t,e)}function ci(e){var t=e.teardown;if(t!==null){const n=vt,r=O;pi(!0),Ne(null);try{t.call(null)}finally{pi(n),Ne(r)}}}function Qn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const s=n.ac;s!==null&&ai(()=>{s.abort(Ze)});var r=n.next;(n.f&st)!==0?n.parent=null:_e(n,t),n=r}}function ao(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&Le)===0&&_e(t),t=n}}function _e(e,t=!0){var n=!1;(t||(e.f&gs)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(lo(e.nodes.start,e.nodes.end),n=!0),ee(e,Ar),Qn(e,t&&!n),on(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(const o of r)o.stop();ci(e),e.f^=Ar,e.f|=ke;var s=e.parent;s!==null&&s.first!==null&&di(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function lo(e,t){for(;e!==null;){var n=e===t?null:Be(e);e.remove(),e=n}}function di(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function It(e,t,n=!0){var r=[];hi(e,r,!0);var s=()=>{n&&_e(e),t&&t()},o=r.length;if(o>0){var l=()=>--o||s();for(var a of r)a.out(l)}else s()}function hi(e,t,n){if((e.f&Se)===0){e.f^=Se;var r=e.nodes&&e.nodes.t;if(r!==null)for(const a of r)(a.is_global||n)&&t.push(a);for(var s=e.first;s!==null;){var o=s.next,l=(s.f&Ht)!==0||(s.f&Le)!==0&&(e.f&it)!==0;hi(s,t,l?n:!1),s=o}}}function er(e){vi(e,!0)}function vi(e,t){if((e.f&Se)!==0){e.f^=Se,(e.f&re)===0&&(ee(e,ce),et.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,s=(n.f&Ht)!==0||(n.f&Le)!==0;vi(n,s?t:!1),n=r}var o=e.nodes&&e.nodes.t;if(o!==null)for(const l of o)(l.is_global||t)&&l.in()}}function tr(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var s=n===r?null:Be(n);t.append(n),n=s}}let Mn=!1,vt=!1;function pi(e){vt=e}let O=null,Ye=!1;function Ne(e){O=e}let N=null;function Ue(e){N=e}let Re=null;function fo(e){O!==null&&(Re===null?Re=[e]:Re.push(e))}let we=null,Ae=0,Ce=null;function uo(e){Ce=e}let _i=1,Mt=0,kt=Mt;function gi(e){kt=e}function mi(){return++_i}function sn(e){var t=e.f;if((t&ce)!==0)return!0;if(t&ie&&(e.f&=~St),(t&He)!==0){for(var n=e.deps,r=n.length,s=0;s<r;s++){var o=n[s];if(sn(o)&&Jr(o),o.wv>e.wv)return!0}(t&Me)!==0&&qe===null&&ee(e,re)}return!1}function wi(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Re!==null&&Xt.call(Re,e)))for(var s=0;s<r.length;s++){var o=r[s];(o.f&ie)!==0?wi(o,t,!1):t===o&&(n?ee(o,ce):(o.f&re)!==0&&ee(o,He),Hn(o))}}function yi(e){var t=we,n=Ae,r=Ce,s=O,o=Re,l=De,a=Ye,f=kt,c=e.f;we=null,Ae=0,Ce=null,O=(c&(Le|st))===0?e:null,Re=null,Bt(e.ctx),Ye=!1,kt=++Mt,e.ac!==null&&(ai(()=>{e.ac.abort(Ze)}),e.ac=null);try{e.f|=jn;var h=e.fn,_=h();e.f|=ot;var v=e.deps,g=V?.is_fork;if(we!==null){var d;if(g||on(e,Ae),v!==null&&Ae>0)for(v.length=Ae+we.length,d=0;d<we.length;d++)v[Ae+d]=we[d];else e.deps=v=we;if(Kn()&&(e.f&Me)!==0)for(d=Ae;d<v.length;d++)(v[d].reactions??=[]).push(e)}else!g&&v!==null&&Ae<v.length&&(on(e,Ae),v.length=Ae);if(Pr()&&Ce!==null&&!Ye&&v!==null&&(e.f&(ie|He|ce))===0)for(d=0;d<Ce.length;d++)wi(Ce[d],e);if(s!==null&&s!==e){if(Mt++,s.deps!==null)for(let y=0;y<n;y+=1)s.deps[y].rv=Mt;if(t!==null)for(const y of t)y.rv=Mt;Ce!==null&&(r===null?r=Ce:r.push(...Ce))}return(e.f&at)!==0&&(e.f^=at),_}catch(y){return qr(y)}finally{e.f^=jn,we=t,Ae=n,Ce=r,O=s,Re=o,Bt(l),Ye=a,kt=f}}function co(e,t){let n=t.reactions;if(n!==null){var r=cs.call(n,e);if(r!==-1){var s=n.length-1;s===0?n=t.reactions=null:(n[r]=n[s],n.pop())}}if(n===null&&(t.f&ie)!==0&&(we===null||!Xt.call(we,t))){var o=t;(o.f&Me)!==0&&(o.f^=Me,o.f&=~St),Fn(o),Zs(o),on(o,0)}}function on(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)co(e,n[r])}function Jt(e){var t=e.f;if((t&ke)===0){ee(e,re);var n=N,r=Mn;N=e,Mn=!0;try{(t&(it|Dr))!==0?ao(e):Qn(e),ci(e);var s=yi(e);e.teardown=typeof s=="function"?s:null,e.wv=_i;var o;us&&Ls&&(e.f&ce)!==0&&e.deps}finally{Mn=r,N=n}}}function i(e){var t=e.f,n=(t&ie)!==0;if(O!==null&&!Ye){var r=N!==null&&(N.f&ke)!==0;if(!r&&(Re===null||!Xt.call(Re,e))){var s=O.deps;if((O.f&jn)!==0)e.rv<Mt&&(e.rv=Mt,we===null&&s!==null&&s[Ae]===e?Ae++:we===null?we=[e]:we.push(e));else{(O.deps??=[]).push(e);var o=e.reactions;o===null?e.reactions=[O]:Xt.call(o,O)||o.push(O)}}}if(vt&&ct.has(e))return ct.get(e);if(n){var l=e;if(vt){var a=l.v;return((l.f&re)===0&&l.reactions!==null||xi(l))&&(a=Vn(l)),ct.set(l,a),a}var f=(l.f&Me)===0&&!Ye&&O!==null&&(Mn||(O.f&Me)!==0),c=(l.f&ot)===0;sn(l)&&(f&&(l.f|=Me),Jr(l)),f&&!c&&(Gr(l),bi(l))}if(qe?.has(e))return qe.get(e);if((e.f&at)!==0)throw e.v;return e.v}function bi(e){if(e.f|=Me,e.deps!==null)for(const t of e.deps)(t.reactions??=[]).push(e),(t.f&ie)!==0&&(t.f&Me)===0&&(Gr(t),bi(t))}function xi(e){if(e.v===se)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(ct.has(t)||(t.f&ie)!==0&&xi(t))return!0;return!1}function nr(e){var t=Ye;try{return Ye=!0,e()}finally{Ye=t}}const an=Symbol("events"),Ei=new Set,rr=new Set;function ir(e,t,n){(t[an]??={})[e]=n}function ho(e){for(var t=0;t<e.length;t++)Ei.add(e[t]);for(var n of rr)n(e)}let $i=null;function Si(e){var t=this,n=t.ownerDocument,r=e.type,s=e.composedPath?.()||[],o=s[0]||e.target;$i=e;var l=0,a=$i===e&&e[an];if(a){var f=s.indexOf(a);if(f!==-1&&(t===document||t===window)){e[an]=t;return}var c=s.indexOf(t);if(c===-1)return;f<=c&&(l=f)}if(o=s[l]||e.target,o!==t){yn(e,"currentTarget",{configurable:!0,get(){return o||n}});var h=O,_=N;Ne(null),Ue(null);try{for(var v,g=[];o!==null;){var d=o.assignedSlot||o.parentNode||o.host||null;try{var y=o[an]?.[r];y!=null&&(!o.disabled||e.target===o)&&y.call(o,e)}catch(E){v?g.push(E):v=E}if(e.cancelBubble||d===t||d===null)break;o=d}if(v){for(let E of g)queueMicrotask(()=>{throw E});throw v}}finally{e[an]=t,delete e.currentTarget,Ne(h),Ue(_)}}}const vo=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function po(e){return vo?.createHTML(e)??e}function Ti(e){var t=Jn("template");return t.innerHTML=po(e.replaceAll("<!>","<!---->")),t.content}function Ot(e,t){var n=N;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function _o(e,t){var n=(t&fs)!==0,r,s=!e.startsWith("<!>");return()=>{if(Y)return Ot(C,null),C;r===void 0&&(r=Ti(s?e:"<!>"+e));var o=n||ti?document.importNode(r,!0):r.cloneNode(!0);{var l=At(o),a=o.lastChild;Ot(l,a)}return o}}function go(e,t,n="svg"){var r=!e.startsWith("<!>"),s=`<${n}>${r?e:"<!>"+e}</${n}>`,o;return()=>{if(Y)return Ot(C,null),C;if(!o){var l=Ti(s),a=At(l);o=At(a)}var f=o.cloneNode(!0);return Ot(f,f),f}}function ae(e,t){return go(e,t,"svg")}function nt(){if(Y)return Ot(C,null),C;var e=document.createDocumentFragment(),t=document.createComment(""),n=je();return e.append(t,n),Ot(t,n),e}function X(e,t){if(Y){var n=N;((n.f&ot)===0||n.nodes.end===null)&&(n.nodes.end=C),Sn();return}e!==null&&e.before(t)}const mo=["touchstart","touchmove"];function wo(e){return mo.includes(e)}function ln(e,t){var n=t==null?"":typeof t=="object"?`${t}`:t;n!==(e.__t??=e.nodeValue)&&(e.__t=n,e.nodeValue=`${n}`)}function Di(e,t){return Ai(e,t)}function yo(e,t){Un(),t.intro=t.intro??!1;const n=t.target,r=Y,s=C;try{for(var o=At(n);o&&(o.nodeType!==en||o.data!==yr);)o=Be(o);if(!o)throw Ft;Qe(!0),Te(o);const l=Ai(e,{...t,anchor:o});return Qe(!1),l}catch(l){if(l instanceof Error&&l.message.split(`
|
|
2
|
-
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw l;return l!==Ft&&console.warn("Failed to hydrate: ",l),t.recover===!1&&As(),Un(),si(n),Qe(!1),Di(e,t)}finally{Qe(r),Te(s)}}const kn=new Map;function Ai(e,{target:t,anchor:n,props:r={},events:s,context:o,intro:l=!0,transformError:a}){Un();var f=void 0,c=io(()=>{var h=n??t.appendChild(je());Bs(h,{pending:()=>{}},g=>{Rr({});var d=De;if(o&&(d.c=o),s&&(r.$$events=s),Y&&Ot(g,null),f=e(g,r)||{},Y&&(N.nodes.end=C,C===null||C.nodeType!==en||C.data!==Ln))throw $n(),Ft;Cr()},a);var _=new Set,v=g=>{for(var d=0;d<g.length;d++){var y=g[d];if(!_.has(y)){_.add(y);var E=wo(y);for(const z of[t,document]){var D=kn.get(z);D===void 0&&(D=new Map,kn.set(z,D));var $=D.get(y);$===void 0?(z.addEventListener(y,Si,{passive:E}),D.set(y,1)):D.set(y,$+1)}}}};return v(mn(Ei)),rr.add(v),()=>{for(var g of _)for(const E of[t,document]){var d=kn.get(E),y=d.get(g);--y==0?(E.removeEventListener(g,Si),d.delete(g),d.size===0&&kn.delete(E)):d.set(g,y)}rr.delete(v),h!==n&&h.parentNode?.removeChild(h)}});return sr.set(f,c),f}let sr=new WeakMap;function bo(e,t){const n=sr.get(e);return n?(sr.delete(e),n(t)):Promise.resolve()}class xo{anchor;#e=new Map;#n=new Map;#t=new Map;#i=new Set;#s=!0;constructor(t,n=!0){this.anchor=t,this.#s=n}#r=t=>{if(this.#e.has(t)){var n=this.#e.get(t),r=this.#n.get(n);if(r)er(r),this.#i.delete(n);else{var s=this.#t.get(n);s&&(this.#n.set(n,s.effect),this.#t.delete(n),s.fragment.lastChild.remove(),this.anchor.before(s.fragment),r=s.effect)}for(const[o,l]of this.#e){if(this.#e.delete(o),o===t)break;const a=this.#t.get(l);a&&(_e(a.effect),this.#t.delete(l))}for(const[o,l]of this.#n){if(o===n||this.#i.has(o))continue;const a=()=>{if(Array.from(this.#e.values()).includes(o)){var c=document.createDocumentFragment();tr(l,c),c.append(je()),this.#t.set(o,{effect:l,fragment:c})}else _e(l);this.#i.delete(o),this.#n.delete(o)};this.#s||!r?(this.#i.add(o),It(l,a,!1)):a()}}};#o=t=>{this.#e.delete(t);const n=Array.from(this.#e.values());for(const[r,s]of this.#t)n.includes(r)||(_e(s.effect),this.#t.delete(r))};ensure(t,n){var r=V,s=oi();if(n&&!this.#n.has(t)&&!this.#t.has(t))if(s){var o=document.createDocumentFragment(),l=je();o.append(l),this.#t.set(t,{effect:Oe(()=>n(l)),fragment:o})}else this.#n.set(t,Oe(()=>n(this.anchor)));if(this.#e.set(r,t),s){for(const[a,f]of this.#n)a===t?r.unskip_effect(f):r.skip_effect(f);for(const[a,f]of this.#t)a===t?r.unskip_effect(f.effect):r.skip_effect(f.effect);r.oncommit(this.#r),r.ondiscard(this.#o)}else Y&&(this.anchor=C),this.#r(r)}}function Eo(e){De===null&&bs(),li(()=>{const t=nr(e);if(typeof t=="function")return t})}function Je(e,t,n=!1){var r;Y&&(r=C,Sn());var s=new xo(e),o=n?Ht:0;function l(a,f){if(Y){var c=kr(r);if(a!==parseInt(c.substring(1))){var h=Tn();Te(h),s.anchor=h,Qe(!1),s.ensure(a,f),Qe(!0);return}}s.ensure(a,f)}Zn(()=>{var a=!1;t((f,c=0)=>{a=!0,l(c,f)}),a||l(-1,null)},o)}function $o(e,t,n){for(var r=[],s=t.length,o,l=t.length,a=0;a<s;a++){let _=t[a];It(_,()=>{if(o){if(o.pending.delete(_),o.done.add(_),o.pending.size===0){var v=e.outrogroups;or(e,mn(o.done)),v.delete(o),v.size===0&&(e.outrogroups=null)}}else l-=1},!1)}if(l===0){var f=r.length===0&&n!==null;if(f){var c=n,h=c.parentNode;si(h),h.append(c),e.items.clear()}or(e,t,!f)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function or(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(const l of e.pending.values())for(const a of l)r.add(e.items.get(a).e)}for(var s=0;s<t.length;s++){var o=t[s];if(r?.has(o)){o.f|=Ke;const l=document.createDocumentFragment();tr(o,l)}else _e(t[s],n)}}var Ii;function Mi(e,t,n,r,s,o=null){var l=e,a=new Map;Y&&Sn();var f=null,c=Ur(()=>{var D=n();return Er(D)?D:D==null?[]:mn(D)}),h,_=new Map,v=!0;function g(D){(E.effect.f&ke)===0&&(E.pending.delete(D),E.fallback=f,So(E,h,l,t,r),f!==null&&(h.length===0?(f.f&Ke)===0?er(f):(f.f^=Ke,un(f,null,l)):It(f,()=>{f=null})))}function d(D){E.pending.delete(D)}var y=Zn(()=>{h=i(c);var D=h.length;let $=!1;if(Y){var z=kr(l)===Pn;z!==(D===0)&&(l=Tn(),Te(l),Qe(!1),$=!0)}for(var te=new Set,P=V,ne=oi(),w=0;w<D;w+=1){Y&&C.nodeType===en&&C.data===Ln&&(l=C,$=!0,Qe(!1));var U=h[w],ye=r(U,w),F=v?null:a.get(ye);F?(F.v&&Ut(F.v,U),F.i&&Ut(F.i,w),ne&&P.unskip_effect(F.e)):(F=To(a,v?l:Ii??=je(),U,ye,w,s,t,n),v||(F.e.f|=Ke),a.set(ye,F)),te.add(ye)}if(D===0&&o&&!f&&(v?f=Oe(()=>o(l)):(f=Oe(()=>o(Ii??=je())),f.f|=Ke)),D>te.size&&Es(),Y&&D>0&&Te(Tn()),!v)if(_.set(P,te),ne){for(const[be,Fe]of a)te.has(be)||P.skip_effect(Fe.e);P.oncommit(g),P.ondiscard(d)}else g(P);$&&Qe(!0),i(c)}),E={effect:y,items:a,pending:_,outrogroups:null,fallback:f};v=!1,Y&&(l=C)}function fn(e){for(;e!==null&&(e.f&Le)===0;)e=e.next;return e}function So(e,t,n,r,s){var o=t.length,l=e.items,a=fn(e.effect.first),f,c=null,h=[],_=[],v,g,d,y;for(y=0;y<o;y+=1){if(v=t[y],g=s(v,y),d=l.get(g).e,e.outrogroups!==null)for(const U of e.outrogroups)U.pending.delete(d),U.done.delete(d);if((d.f&Se)!==0&&er(d),(d.f&Ke)!==0)if(d.f^=Ke,d===a)un(d,null,n);else{var E=c?c.next:a;d===e.effect.last&&(e.effect.last=d.prev),d.prev&&(d.prev.next=d.next),d.next&&(d.next.prev=d.prev),pt(e,c,d),pt(e,d,E),un(d,E,n),c=d,h=[],_=[],a=fn(c.next);continue}if(d!==a){if(f!==void 0&&f.has(d)){if(h.length<_.length){var D=_[0],$;c=D.prev;var z=h[0],te=h[h.length-1];for($=0;$<h.length;$+=1)un(h[$],D,n);for($=0;$<_.length;$+=1)f.delete(_[$]);pt(e,z.prev,te.next),pt(e,c,z),pt(e,te,D),a=D,c=te,y-=1,h=[],_=[]}else f.delete(d),un(d,a,n),pt(e,d.prev,d.next),pt(e,d,c===null?e.effect.first:c.next),pt(e,c,d),c=d;continue}for(h=[],_=[];a!==null&&a!==d;)(f??=new Set).add(a),_.push(a),a=fn(a.next);if(a===null)continue}(d.f&Ke)===0&&h.push(d),c=d,a=fn(d.next)}if(e.outrogroups!==null){for(const U of e.outrogroups)U.pending.size===0&&(or(e,mn(U.done)),e.outrogroups?.delete(U));e.outrogroups.size===0&&(e.outrogroups=null)}if(a!==null||f!==void 0){var P=[];if(f!==void 0)for(d of f)(d.f&Se)===0&&P.push(d);for(;a!==null;)(a.f&Se)===0&&a!==e.fallback&&P.push(a),a=fn(a.next);var ne=P.length;if(ne>0){var w=null;$o(e,P,w)}}}function To(e,t,n,r,s,o,l,a){var f=(l&ns)!==0?(l&is)===0?Zr(n,!1,!1):Dt(n):null,c=(l&rs)!==0?Dt(s):null;return{v:f,i:c,e:Oe(()=>(o(t,f??n,c??s,a),()=>{e.delete(r)}))}}function un(e,t,n){if(e.nodes)for(var r=e.nodes.start,s=e.nodes.end,o=t&&(t.f&Ke)===0?t.nodes.start:n;r!==null;){var l=Be(r);if(o.before(r),r===s)return;r=l}}function pt(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Do(e,t){so(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector("#"+t.hash)){const s=Jn("style");s.id=t.hash,s.textContent=t.code,r.appendChild(s)}})}function Ao(e,t){return e==null?null:String(e)}function ki(e,t,n,r){var s=e.__style;if(Y||s!==t){var o=Ao(t);(!Y||o!==e.getAttribute("style"))&&(o==null?e.removeAttribute("style"):e.style.cssText=o),e.__style=t}return r}const Io=Symbol("is custom element"),Mo=Symbol("is html"),ko=ys?"link":"LINK";function T(e,t,n,r){var s=Oo(e);Y&&(s[t]=e.getAttribute(t),t==="src"||t==="srcset"||t==="href"&&e.nodeName===ko)||s[t]!==(s[t]=n)&&(t==="loading"&&(e[ws]=n),n==null?e.removeAttribute(t):typeof n!="string"&&No(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Oo(e){return e.__attributes??={[Io]:e.nodeName.includes("-"),[Mo]:e.namespaceURI===xr}}var Oi=new Map;function No(e){var t=e.getAttribute("is")||e.nodeName,n=Oi.get(t);if(n)return n;Oi.set(t,n=[]);for(var r,s=e,o=Element.prototype;o!==s;){r=ds(s);for(var l in r)r[l].set&&n.push(l);s=$r(s)}return n}function ge(e,t,n,r){var s=(n&as)!==0,o=(n&ls)!==0,l=r,a=!0,f=()=>(a&&(a=!1,l=o?nr(r):r),l);let c;if(s){var h=xn in e||Mr in e;c=Et(e,t)?.set??(h&&t in e?$=>e[t]=$:void 0)}var _,v=!1;s?[_,v]=Ys(()=>e[t]):_=e[t],_===void 0&&r!==void 0&&(_=f(),c&&(Is(),c(_)));var g;if(g=()=>{var $=e[t];return $===void 0?f():(a=!0,$)},(n&os)===0)return g;if(c){var d=e.$$legacy;return(function($,z){return arguments.length>0?((!z||d||v)&&c(z?g():$),$):g()})}var y=!1,E=((n&ss)!==0?Bn:Ur)(()=>(y=!1,g()));s&&i(E);var D=N;return(function($,z){if(arguments.length>0){const te=z?i(E):s?dt($):$;return p(E,te),y=!0,l!==void 0&&(l=te),$}return vt&&y||(D.f&ke)!==0?E.v:i(E)})}function Ro(e){return new Co(e)}class Co{#e;#n;constructor(t){var n=new Map,r=(o,l)=>{var a=Zr(l,!1,!1);return n.set(o,a),a};const s=new Proxy({...t.props||{},$$events:{}},{get(o,l){return i(n.get(l)??r(l,Reflect.get(o,l)))},has(o,l){return l===Mr?!0:(i(n.get(l)??r(l,Reflect.get(o,l))),Reflect.has(o,l))},set(o,l,a){return p(n.get(l)??r(l,a),a),Reflect.set(o,l,a)}});this.#n=(t.hydrate?yo:Di)(t.component,{target:t.target,anchor:t.anchor,props:s,context:t.context,intro:t.intro??!1,recover:t.recover,transformError:t.transformError}),(!t?.props?.$$host||t.sync===!1)&&de(),this.#e=s.$$events;for(const o of Object.keys(this.#n))o==="$set"||o==="$destroy"||o==="$on"||yn(this,o,{get(){return this.#n[o]},set(l){this.#n[o]=l},enumerable:!0});this.#n.$set=o=>{Object.assign(s,o)},this.#n.$destroy=()=>{bo(this.#n)}}$set(t){this.#n.$set(t)}$on(t,n){this.#e[t]=this.#e[t]||[];const r=(...s)=>n.call(this,...s);return this.#e[t].push(r),()=>{this.#e[t]=this.#e[t].filter(s=>s!==r)}}$destroy(){this.#n.$destroy()}}let Ni;typeof HTMLElement=="function"&&(Ni=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;$$me;$$shadowRoot=null;constructor(e,t,n){super(),this.$$ctor=e,this.$$s=t,n&&(this.$$shadowRoot=this.attachShadow(n))}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const r=this.$$c.$on(e,t);this.$$l_u.set(t,r)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){const r=this.$$l_u.get(t);r&&(r(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(r){return s=>{const o=Jn("slot");r!=="default"&&(o.name=r),X(s,o)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},n=Po(this);for(const r of this.$$s)r in n&&(r==="default"&&!this.$$d.children?(this.$$d.children=e(r),t.default=!0):t[r]=e(r));for(const r of this.attributes){const s=this.$$g_p(r.name);s in this.$$d||(this.$$d[s]=On(s,r.value,this.$$p_d,"toProp"))}for(const r in this.$$p_d)!(r in this.$$d)&&this[r]!==void 0&&(this.$$d[r]=this[r],delete this[r]);this.$$c=Ro({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=ro(()=>{ui(()=>{this.$$r=!0;for(const r of wn(this.$$c)){if(!this.$$p_d[r]?.reflect)continue;this.$$d[r]=this.$$c[r];const s=On(r,this.$$d[r],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[r].attribute||r):this.setAttribute(this.$$p_d[r].attribute||r,s)}this.$$r=!1})});for(const r in this.$$l)for(const s of this.$$l[r]){const o=this.$$c.$on(r,s);this.$$l_u.set(s,o)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=On(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return wn(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function On(e,t,n,r){const s=n[e]?.type;if(t=s==="Boolean"&&typeof t!="boolean"?t!=null:t,!r||!n[e])return t;if(r==="toAttribute")switch(s){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(s){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function Po(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}function Lo(e,t,n,r,s,o){let l=class extends Ni{constructor(){super(e,n,s),this.$$p_d=t}static get observedAttributes(){return wn(t).map(a=>(t[a].attribute||a).toLowerCase())}};return wn(t).forEach(a=>{yn(l.prototype,a,{get(){return this.$$c&&a in this.$$c?this.$$c[a]:this.$$d[a]},set(f){f=On(a,f,t),this.$$d[a]=f;var c=this.$$c;if(c){var h=Et(c,a)?.get;h?c[a]=f:c.$set({[a]:f})}}})}),r.forEach(a=>{yn(l.prototype,a,{get(){return this.$$c?.[a]}})}),e.element=l,l}var Nt={},Ri;function qo(){if(Ri)return Nt;Ri=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.LanguageTranslator=void 0,Nt.getChildStyleToPass=e,Nt.addComponent=t;function e(r,s){var o,l,a="";try{if(r&&s?.length&&(!((o=Object.keys(r))===null||o===void 0)&&o.length)&&(!((l=s?.filter(function(v){return Object.keys(r).includes(v.name)}))===null||l===void 0)&&l.length))for(var f=function(v){var g=s?.filter(function(d){return d.name===v&&d.defaultValue!==r[v]});g&&(a+="".concat(v,":").concat(r[v],";"))},c=0,h=Object.keys(r);c<h.length;c++){var _=h[c];f(_)}}catch(v){console.error("error getting child style to pass",v)}finally{return a}}function t(r){var s,o=((s=r?.repoName.split("/"))===null||s===void 0?void 0:s[1])||r?.repoName;if(!o)throw new Error("wrong componentPath "+r?.repoName);if(!r?.version)throw new Error("wrong version "+r?.version);var l=r?.iifePath||"main.iife.js";if(!document.getElementById(o+"-script"))try{var a=document.createElement("script");if(a.id=o+"-script",a.src="https://cdn.jsdelivr.net/npm/".concat(r.repoName,"@").concat(r.version,"/").concat(l),r?.local)a.src="".concat(r.local);else if(location.href.includes("localhost:6006")){var f=o.split("-")[0];a.src="http://localhost:6006/webcomponents/".concat(o.replace(f+"-",""),"/").concat(l)}document.head.appendChild(a)}catch(c){console.warn(c)}}var n=(function(){function r(s){if(this.lang="",!s?.dictionary)throw new Error("no dictionary provided");this.dictionary=s.dictionary,this.setLang(s?.lang)}return r.prototype.setLang=function(s){s||(s=r.getDefaultLang()),this.lang=s},r.prototype.translateWord=function(s,o){return r.getDictionaryWord(s,this.dictionary,o||this.lang)},r.prototype.translateDate=function(s,o,l){return r.formatDate(s,o,l||this.lang)},r.getDefaultLang=function(){var s,o,l,a="en";return navigator?.languages&&(!((l=(o=(s=navigator.languages[0])===null||s===void 0?void 0:s.split("-")[0])===null||o===void 0?void 0:o.toLowerCase())===null||l===void 0)&&l.length)&&(a=navigator.languages[0].split("-")[0].toLowerCase()),a},r.getDictionaryWord=function(s,o,l){var a;if(!s)throw new Error("no wordKey provided");if(!o)throw new Error("no dictionary provided");if(l&&(!((a=o[l])===null||a===void 0)&&a[s]))return o[l][s];var f="",c=r.getDefaultLang();if(!l||c!==l){var h=o?.[c];h?.[s]&&(f=h[s])}return f},r.formatDate=function(s,o,l){if(!s)throw new Error("no date provided");if(typeof s.getMonth!="function")throw new Error("wrong date format");var a=new Intl.DateTimeFormat(l||r.getDefaultLang(),o);return a.format(s)},r})();return Nt.LanguageTranslator=n,Nt}qo();const{PI:jo}=Math,cn=jo+1e-4,Ci=.5,Pi=[1,1];function Li(e,t,n,r=s=>s){return e*r(.5-t*(.5-n))}const{min:ar}=Math;function qi(e,t,n){let r=ar(1,t/n);return ar(1,e+(ar(1,1-r)-e)*(r*.275))}function Yo(e){return[-e[0],-e[1]]}function Ge(e,t){return[e[0]+t[0],e[1]+t[1]]}function ji(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function _t(e,t){return[e[0]-t[0],e[1]-t[1]]}function lr(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function gt(e,t){return[e[0]*t,e[1]*t]}function fr(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function Fo(e,t){return[e[0]/t,e[1]/t]}function Yi(e){return[e[1],-e[0]]}function ur(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function Fi(e,t){return e[0]*t[0]+e[1]*t[1]}function Xo(e,t){return e[0]===t[0]&&e[1]===t[1]}function zo(e){return Math.hypot(e[0],e[1])}function Xi(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function zi(e){return Fo(e,zo(e))}function Ho(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function cr(e,t,n){let r=Math.sin(n),s=Math.cos(n),o=e[0]-t[0],l=e[1]-t[1],a=o*s-l*r,f=o*r+l*s;return[a+t[0],f+t[1]]}function Hi(e,t,n,r){let s=Math.sin(r),o=Math.cos(r),l=t[0]-n[0],a=t[1]-n[1],f=l*o-a*s,c=l*s+a*o;return e[0]=f+n[0],e[1]=c+n[1],e}function Bi(e,t,n){return Ge(e,gt(_t(t,e),n))}function Bo(e,t,n,r){let s=n[0]-t[0],o=n[1]-t[1];return e[0]=t[0]+s*r,e[1]=t[1]+o*r,e}function Vi(e,t,n){return Ge(e,gt(t,n))}const le=[0,0],mt=[0,0],wt=[0,0];function Vo(e,t){let n=Vi(e,zi(Yi(_t(e,Ge(e,[1,1])))),-t),r=[],s=1/13;for(let o=s;o<=1;o+=s)r.push(cr(n,e,cn*2*o));return r}function Wo(e,t,n){let r=[],s=1/n;for(let o=s;o<=1;o+=s)r.push(cr(t,e,cn*o));return r}function Uo(e,t,n){let r=_t(t,n),s=gt(r,.5),o=gt(r,.51);return[_t(e,s),_t(e,o),Ge(e,o),Ge(e,s)]}function Jo(e,t,n,r){let s=[],o=Vi(e,t,n),l=1/r;for(let a=l;a<1;a+=l)s.push(cr(o,e,cn*3*a));return s}function Go(e,t,n){return[Ge(e,gt(t,n)),Ge(e,gt(t,n*.99)),_t(e,gt(t,n*.99)),_t(e,gt(t,n))]}function Wi(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function Ko(e,t,n){return e.slice(0,10).reduce((r,s)=>{let o=s.pressure;return t&&(o=qi(r,s.distance,n)),(r+o)/2},e[0].pressure)}function Zo(e,t={}){let{size:n=16,smoothing:r=.5,thinning:s=.5,simulatePressure:o=!0,easing:l=H=>H,start:a={},end:f={},last:c=!1}=t,{cap:h=!0,easing:_=H=>H*(2-H)}=a,{cap:v=!0,easing:g=H=>--H*H*H+1}=f;if(e.length===0||n<=0)return[];let d=e[e.length-1].runningLength,y=Wi(a.taper,n,d),E=Wi(f.taper,n,d),D=(n*r)**2,$=[],z=[],te=Ko(e,o,n),P=Li(n,s,e[e.length-1].pressure,l),ne,w=e[0].vector,U=e[0].point,ye=U,F=U,be=ye,Fe=!1;for(let H=0;H<e.length;H++){let{pressure:b}=e[H],{point:me,vector:he,distance:Xe,runningLength:bt}=e[H],Pe=H===e.length-1;if(!Pe&&d-bt<3)continue;s?(o&&(b=qi(te,Xe,n)),P=Li(n,s,b,l)):P=n/2,ne===void 0&&(ne=P);let dn=bt<y?_(bt/y):1,hn=d-bt<E?g((d-bt)/E):1;P=Math.max(.01,P*Math.min(dn,hn));let xt=(Pe?e[H]:e[H+1]).vector,Gt=Pe?1:Fi(he,xt),Nn=Fi(he,w)<0&&!Fe,vn=Gt!==null&&Gt<0;if(Nn||vn){ur(le,w),fr(le,le,P);for(let Ct=0;Ct<=1;Ct+=.07692307692307693)lr(mt,me,le),Hi(mt,mt,me,cn*Ct),F=[mt[0],mt[1]],$.push(F),ji(wt,me,le),Hi(wt,wt,me,cn*-Ct),be=[wt[0],wt[1]],z.push(be);U=F,ye=be,vn&&(Fe=!0);continue}if(Fe=!1,Pe){ur(le,he),fr(le,le,P),$.push(_t(me,le)),z.push(Ge(me,le));continue}Bo(le,xt,he,Gt),ur(le,le),fr(le,le,P),lr(mt,me,le),F=[mt[0],mt[1]],(H<=1||Xi(U,F)>D)&&($.push(F),U=F),ji(wt,me,le),be=[wt[0],wt[1]],(H<=1||Xi(ye,be)>D)&&(z.push(be),ye=be),te=b,w=he}let I=[e[0].point[0],e[0].point[1]],yt=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:Ge(e[0].point,[1,1]),Rt=[],Ie=[];if(e.length===1){if(!(y||E)||c)return Vo(I,ne||P)}else{y||E&&e.length===1||(h?Rt.push(...Wo(I,z[0],13)):Rt.push(...Uo(I,$[0],z[0])));let H=Yi(Yo(e[e.length-1].vector));E||y&&e.length===1?Ie.push(yt):v?Ie.push(...Jo(yt,H,P,29)):Ie.push(...Go(yt,H,P))}return $.concat(Ie,z.reverse(),Rt)}const Ui=[0,0];function Ji(e){return e!=null&&e>=0}function Qo(e,t={}){let{streamline:n=.5,size:r=16,last:s=!1}=t;if(e.length===0)return[];let o=.15+(1-n)*.85,l=Array.isArray(e[0])?e:e.map(({x:v,y:g,pressure:d=Ci})=>[v,g,d]);if(l.length===2){let v=l[1];l=l.slice(0,-1);for(let g=1;g<5;g++)l.push(Bi(l[0],v,g/4))}l.length===1&&(l=[...l,[...Ge(l[0],Pi),...l[0].slice(2)]]);let a=[{point:[l[0][0],l[0][1]],pressure:Ji(l[0][2])?l[0][2]:.25,vector:[...Pi],distance:0,runningLength:0}],f=!1,c=0,h=a[0],_=l.length-1;for(let v=1;v<l.length;v++){let g=s&&v===_?[l[v][0],l[v][1]]:Bi(h.point,l[v],o);if(Xo(h.point,g))continue;let d=Ho(g,h.point);if(c+=d,v<_&&!f){if(c<r)continue;f=!0}lr(Ui,h.point,g),h={point:g,pressure:Ji(l[v][2])?l[v][2]:Ci,vector:zi(Ui),distance:d,runningLength:c},a.push(h)}return a[0].vector=a[1]?.vector||[0,0],a}function Gi(e,t={}){return Zo(Qo(e,t),t)}var ea=ae('<path stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></path>'),ta=ae('<image stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></image>'),na=ae('<text stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"> </text>'),ra=ae('<path class="svelte-1qsqiex"></path>'),ia=ae('<image class="svelte-1qsqiex"></image>'),sa=ae('<text class="svelte-1qsqiex"> </text>'),oa=ae('<path stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></path>'),aa=ae('<image stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></image>'),la=ae('<text stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"> </text>'),fa=ae('<path class="svelte-1qsqiex"></path>'),ua=ae('<image class="svelte-1qsqiex"></image>'),ca=ae('<text class="svelte-1qsqiex"> </text>'),da=ae('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),ha=ae('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),va=ae('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),pa=ae('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),_a=ae("<g><!><!></g>"),ga=_o('<div id="debug" class="svelte-1qsqiex"> </div> <div id="container"><svg class="svelte-1qsqiex"><!></svg></div>',1);const ma={hash:"svelte-1qsqiex",code:'@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");:host {font-family:"Roboto", sans-serif;}#debug.svelte-1qsqiex {position:absolute;width:100%;height:30px;top:0px;z-index:10;}svg.svelte-1qsqiex {position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none;}'};function Ki(e,t){Rr(t,!0),Do(e,ma);function n(u,x){t.$$host.dispatchEvent(new CustomEvent(u,{detail:x}))}const r={size:6,thinning:.7,smoothing:.5,streamline:.5},s={paperSize:"A4"},o={zoom:{type:"fit",value:1},pan:{x:0,y:0},lockPan:!1,lockZoom:!1};let l=ge(t,"id",7,""),a=ge(t,"load_draw",7),f=ge(t,"draw_id",23,()=>Math.random().toString(36)+Math.random().toString(36)+Date.now().toString()),c=ge(t,"background_color",7,"rgb(255,255,255)"),h=ge(t,"pen_color",7,"rgb(0,0,0)"),_=ge(t,"insert_image",7,void 0),v=ge(t,"insert_text",7),g=ge(t,"pen_opacity",7,1),d=ge(t,"options",7,r),y=ge(t,"goto",7,void 0),E=ge(t,"mode",7,"draw"),D=ge(t,"debug",7,"no"),$=ge(t,"save_as",7,void 0),z=ge(t,"size",23,()=>Object.assign({},s)),te=ge(t,"view",23,()=>Object.assign({},o)),P,ne,w=A(0),U=A(!1),ye=A(0),F=A(void 0),be=A(void 0),Fe=A(""),I=A(dt({})),yt=A(0),Rt=A(void 0),Ie=A(void 0),H=A(void 0),b=A(dt([])),me=A(!1),he=A("idle"),Xe=A(void 0),bt=A(void 0),Pe=A(void 0),dn=A(void 0),hn=A(void 0),xt=A(!1),Gt=A(void 0),Nn=A(void 0),vn=A(void 0),Ct=A(void 0),Pt=A(0),Lt=A(0),qt=A(0),jt=A(0),K=A(0),Z=A(0),J=A(0),G=A(0);function Zi(u){if(!u.length)return"";const x=u.reduce((S,[B,L],j,m)=>{const[k,R]=m[(j+1)%m.length];return S.push(B,L,(B+k)/2,(L+R)/2),S},["M",...u[0],"Q"]);return x.push("Z"),x.join(" ")}function wa(u){if(u)switch(u.type){case"json":const x=[];for(const S of i(b))if(S.visible){if(S.type==="stroke")S.actionIndex=0,x.push(S);else if(S.type==="multiplestroke")for(const B of S.multipath?.filter(L=>L.visible)||[])B.actionIndex=0,x.push(B)}return ba({type:"json",draw:x,id:l(),draw_id:f(),name:u.name,version:i(ye)+1,size:z()||s});default:return console.error("unknown save type")}}function ya(u){n("drawLoaded",u)}function ba(u){n("save",u)}function pn(u){n("historyIndex",u)}function xa(u){n("changeIndex",u)}function Ea(u){n("selection",u)}function Qi(u){n("startStroke",u)}function $a(u){n("endStroke",u)}function Sa(u){n("imageLoaded",u)}function Ta(u){n("txtLoaded",u)}function Da(){if(!i(F))return console.error("no svg dom found");if(!i(be))return console.error("no svg container found");p(I,i(F).getBoundingClientRect(),!0),P||(P={}),P.containerWidth=i(be).clientWidth,P.containerHeight=i(be).clientHeight,P.drawWidth=i(F).clientWidth,P.drawHeight=i(F).clientHeight,z()?.paperSize==="A3"?(P.paperWidth=297,P.paperHeight=420):(P.paperWidth=210,P.paperHeight=297)}function Aa(){if(console.log("svgDom",i(F)),i(I)||Da(),a()&&typeof a()=="object"&&(!i(ye)||i(ye)<a().version||f()!==a().draw_id)&&(console.log("load_draw",a()),p(b,a().draw,!0),p(w,i(b).length,!0),f(a().draw_id),p(ye,a().version,!0),a(void 0),ne=i(b).length,pn({index:i(w),draw_id:f(),id:l(),start_index:ne}),ya({index:i(w),draw_id:f(),id:l(),start_index:ne})),i(b)?.length&&$()&&(console.log("save_as",$()),wa($())),i(b)||(console.log("draw is empty"),p(b,[],!0)),E()&&E()!=="select"&&i(Xe)){p(Xe,0);const u=[...i(b)];u.forEach(x=>{x.selected=!1,x.type==="multiplestroke"&&x.multipath?.forEach(S=>{S.selected=!1})}),p(b,[...u],!0)}if(E()!=="select"&&(p(J,0),p(G,0),p(K,0),p(Z,0)),typeof y()=="string"&&y(Number(y())),i(b).length||(p(w,0),y(void 0)),i(w)||p(w,0),y()&&y()<0?p(w,-1):(y()||y()===0)&&(ne&&y()>ne?y(ne):y()>i(b).length&&y(i(b).length),p(w,y()+0),y(void 0),xa({index:i(w),draw_id:f(),id:l(),start_index:ne})),i(w)<0?(p(w,0),p(me,!0)):i(w)>=0&&p(me,!1),_()){console.info("inserting object");let u=!1;switch(_().type){case"jpg":case"jpeg":case"png":Ia(_()),u=!0;break;case"svg":Ma(_()),u=!0;break;default:console.error("unknown insert_object type",_().type),u=!1}u&&Sa({ok:!0,draw_id:f(),id:l()})}v()&&(console.log("insert_text",v()),ka(v()),Ta({ok:!0,draw_id:f(),id:l()})),p(bt,Gi(i(b)[i(w)]?.path||[],Object.assign({simulatePressure:i(Fe)!=="pen"},d())),!0),p(Pe,Zi(i(bt)),!0),console.log("set index to",i(w),"from goto",y(),"historyActions",i(b).length)}li(()=>{console.log("recompute");let u=!1;if(typeof z()=="string")try{z(JSON.parse(z())),u=!0}catch(x){console.error("error parsing size json",x)}if(typeof te()=="string")try{te(JSON.parse(te())),u=!0}catch(x){console.error("error parsing view json",x)}if(typeof a()=="string"&&a()?.length)try{a(JSON.parse(a())),u=!0}catch(x){console.error("error parsing json",x)}else a()||a(void 0);if(typeof $()=="string"&&$()?.length)try{$(JSON.parse($())),u=!0}catch(x){console.error("error parsing json",x)}if(D()!=="yes"&&D("no"),typeof g()=="string"&&g(Number(g())),typeof d()=="string"&&d()?.length)try{d(JSON.parse(d())),d()&&!d().size&&(d().size=r.size),d()&&!d().thinning&&(d().thinning=r.thinning),d()&&!d().smoothing&&(d().smoothing=r.smoothing),d()&&!d().streamline&&(d().streamline=r.streamline),u=!0}catch(x){console.error("error parsing json",x)}if(typeof _()=="string")try{_(JSON.parse(_())),u=!0}catch(x){console.error("error parsing insert_object json",x)}i(F)&&u&&Aa()});function Ia(u){const x=[...i(b)],S={id:Date.now().toString(),type:"image",actionIndex:i(w),visible:!0,pathData:u?.base64};x.push(S),p(b,[...x],!0),nn(w)}function Ma(u){console.info(`inserting SVG ${u?.type}`)}function ka(u){console.info(`inserting Text ${u?.content}`)}function dr(u){const x=u.target?.id?.split("_")?.[1];if(x){let S=[...i(b)],B=S.find(L=>L.id===x&&L.visible);if(!B)for(const L of S.filter(j=>j.type==="multiplestroke").sort((j,m)=>m.actionIndex-j.actionIndex)){const j=L?.multipath?.find(m=>m.id===x&&m.visible);if(j){B=j;break}}B&&(B.visible=!1,B.erasedAtIndex=i(w),console.info("erase stroke",B.id),S[S.length-1].type!=="eraser"?(S=S.slice(0,i(w)+1),S.push({type:"eraser",visible:!0,id:Math.random().toString(36)+Math.random().toString(36)+Date.now().toString(),actionIndex:i(b).length}),S.forEach((L,j)=>{!L.visible&&L.erasedAtIndex&&L.erasedAtIndex>i(w)&&(L.visible=!0,L.erasedAtIndex=void 0)}),p(b,[...S],!0),nn(w),pn({index:i(w),draw_id:f(),id:l(),start_index:ne})):p(b,[...S],!0))}}function Oa(u){if(console.log("handlePointerDown"),p(Fe,u.pointerType,!0),p(yt,u.buttons,!0),E()==="draw"&&u.buttons===1&&!(u.pointerType==="pen"&&u.pressure===0)){if(p(he,"drawing"),i(w)!==i(b).length-1){const x=[...i(b)];x.forEach((S,B)=>{!S.visible&&S.erasedAtIndex&&S.erasedAtIndex>i(w)&&(S.visible=!0,S.erasedAtIndex=void 0)}),p(b,x,!0)}if(i(b)?.length&&i(w)<i(b).length)if(i(me))p(b,[],!0),p(me,!1);else{nn(w);const x=[...i(b)];p(b,x.slice(0,i(w)),!0)}pn({index:i(w),draw_id:f(),id:l(),start_index:ne}),console.log("setup stroke"),p(H,new Date,!0),p(Ie,Date.now().toString(),!0),p(Pt,u.pageX-i(I).left),p(Lt,u.pageY-i(I).top),p(qt,u.pageX-i(I).left),p(jt,u.pageY-i(I).top),i(Rt)||(p(Rt,i(H),!0),Qi({start:i(Rt),id:l(),draw_id:f(),stroke_id:i(Ie),index:i(w)})),u.target.setPointerCapture(u.pointerId),i(b)?.length?(console.info("pushing draw"),p(b,[...i(b),{path:[[u.pageX-i(I).left,u.pageY-i(I).top,u.pressure]],color:h(),id:i(Ie),pathData:i(Pe),min:[i(Pt),i(Lt)],max:[i(qt),i(jt)],visible:!0,actionIndex:i(b).length,opacity:g(),type:"stroke"}],!0)):p(b,[{path:[[u.pageX-i(I).left,u.pageY-i(I).top,u.pressure]],color:h(),id:i(Ie),pathData:i(Pe),min:[i(Pt),i(Lt)],max:[i(qt),i(jt)],visible:!0,actionIndex:i(b).length,opacity:g(),type:"stroke"}],!0),Qi({start:i(H),stroke_id:i(Ie),index:i(w),id:l(),draw_id:f()})}else if(E()==="eraser"||E()==="draw"&&(u.pointerType==="pen"&&u.pressure===0&&u.buttons===1||u.buttons===32))u.target.setPointerCapture(u.pointerId),p(he,"erasing"),console.log("eraser down"),dr(u);else if(E()==="select"&&i(b).length){let x=!1;const S=u.pageX-i(I).left,B=u.pageY-i(I).top;if(x=S>i(K)&&S<i(J)&&B>i(Z)&&B<i(G),p(K,u.pageX-i(I).left),p(Z,u.pageY-i(I).top),p(J,u.pageX-i(I).left),p(G,u.pageY-i(I).top),!i(xt)&&!i(Xe)&&x){p(he,"idle"),p(Xe,Date.now(),!0),console.info("set move mode");const L=[...i(b)];p(dn,u.pageX-i(I).left),p(hn,u.pageY-i(I).top),L.filter(k=>k.selected).forEach(k=>{k.visible=!1,k.erasedAtIndex=i(w)}),L.filter(k=>k.type==="multiplestroke").forEach(k=>{k.multipath?.filter(R=>R.selected).forEach(R=>{R.visible=!1,R.erasedAtIndex=i(w)})});const j=[];for(const k of L.filter(R=>R.type==="multiplestroke"))for(const R of k.multipath?.filter(M=>M.selected)||[])j.push(JSON.parse(JSON.stringify(R))),R.visible=!1;const m=JSON.parse(JSON.stringify(i(b).filter(k=>k.selected))).concat(j);m.forEach(k=>{k.visible=!0}),L.push({multipath:m,id:i(Xe).toString(),type:"multiplestroke",actionIndex:i(w),visible:!0,min:[i(K),i(Z)],max:[i(J),i(G)]}),i(b)[i(b).length-1].type==="multiplestroke"&&nn(w),p(b,[...L],!0),pn({index:i(w),draw_id:f(),id:l(),start_index:ne}),p(xt,!0),p(Gt,i(K),!0),p(Nn,i(Z),!0),p(vn,i(J),!0),p(Ct,i(G),!0)}else p(he,"selecting"),p(Xe,0)}}function Na(u){if(p(Fe,u.pointerType,!0),p(yt,u.buttons+" "+[u.pageX-i(I).left,u.pageY-i(I).top,u.pressure].toString()),E()==="draw"&&i(he)==="drawing"&&u.buttons===1&&!(u.pointerType==="pen"&&u.pressure===0))i(b)[i(w)].path=[...i(b)[i(w)].path||[],[u.pageX-i(I).left,u.pageY-i(I).top,u.pressure]],i(b)[i(w)].pathData=i(Pe),u.pageX-i(I).left<i(Pt)&&p(Pt,u.pageX-i(I).left),u.pageY-i(I).top<i(Lt)&&p(Lt,u.pageY-i(I).top),u.pageX-i(I).left>i(qt)&&p(qt,u.pageX-i(I).left),u.pageY-i(I).top>i(jt)&&p(jt,u.pageY-i(I).top),i(b)[i(w)].min=[i(Pt),i(Lt)],i(b)[i(w)].max=[i(qt),i(jt)];else if(i(he)==="erasing"&&(E()==="eraser"||E()==="draw"&&(u.pointerType==="pen"&&u.pressure===0&&u.buttons===1||u.buttons===32)))console.log("eraser move"),dr(u);else if(E()==="select"&&i(he)==="selecting")p(J,u.pageX-i(I).left),p(G,u.pageY-i(I).top);else if(E()==="select"&&!i(xt)){const x=u.pageX-i(I).left,S=u.pageY-i(I).top,B=x>i(K)&&x<i(J)&&S>i(Z)&&S<i(G);B&&!i(U)?(p(U,!0),console.log("on select",i(U))):!B&&i(U)&&(p(U,!1),console.log("off select",i(U)))}else if(i(xt)&&i(b)[i(w)].type==="multiplestroke"&&i(Xe)&&i(Xe).toString()===i(b)[i(w)].id){const x=[...i(b)],S=u.pageX-i(I).left,B=u.pageY-i(I).top,L=S-(i(dn)||0),j=B-(i(hn)||0);console.info("move selected strokes on multistrokes",i(dn),i(hn),L,j),x[i(w)]?.multipath?.forEach(m=>{let k;for(const M of i(b).filter(fe=>fe.type==="multiplestroke").filter(fe=>fe.id!==i(b)[i(w)].id).sort((fe,Yt)=>Yt.actionIndex-fe.actionIndex)){const fe=M?.multipath?.find(Yt=>Yt.id===m.id);if(fe){k=fe;break}}k||(k=i(b).find(M=>M.id===m.id)),m.path?.forEach((M,fe)=>{fe===0&&console.log("debug path ",M[0],k?.path?.[fe][0],i(b)),k?.path&&(M[0]=k.path[fe][0]+L),k?.path&&(M[1]=k.path[fe][1]+j)}),k?.max&&(m.max=[k.max[0]+L,k.max[1]+j]),k?.min&&(m.min=[k.min[0]+L,k.min[1]+j]);const R=Gi(m.path||[],Object.assign({simulatePressure:i(Fe)!=="pen"},d()));m.pathData=Zi(R)}),p(K,(i(Gt)||0)+L),p(Z,(i(Nn)||0)+j),p(J,(i(vn)||0)+L),p(G,(i(Ct)||0)+j),p(b,[...x],!0)}}function Ra(u){if(p(yt,u.buttons,!0),p(xt,!1),E()==="draw"&&i(he)==="drawing"){const x=new Date;if(!i(Ie)||!i(H)||!i(Pe))return console.error("no stroke id",i(Ie),i(H),i(Pe));$a({end:x,stroke_id:i(Ie),start:i(H),min:[i(Pt),i(Lt)],max:[i(qt),i(jt)],pathData:i(Pe),pen_color:h(),index:i(w),id:l(),draw_id:f()}),nn(w),pn({index:i(w),draw_id:f(),id:l(),start_index:ne})}else if(E()==="eraser"||E()==="draw"&&i(he)!=="drawing"&&(u.pointerType==="pen"&&u.pressure===0&&u.buttons===1||u.buttons===32))console.log("eraser up"),dr(u);else if(E()==="select"){const x=[...i(b)];x.forEach(R=>{R.selected=!1,R.type==="multiplestroke"&&R.multipath?.forEach(M=>{M.selected=!1})}),p(b,[...x],!0),p(Xe,0);const S=i(K)<i(J)?i(K):i(J),B=i(Z)<i(G)?i(Z):i(G),L=i(K)>i(J)?i(K):i(J),j=i(Z)>i(G)?i(Z):i(G),m=x.filter(R=>!!(R.visible&&R.type==="stroke"&&R.min&&R.max&&R.min[0]>S&&R.min[1]>B&&R.max[0]<L&&R.max[1]<j));let k=!1;for(const R of x.filter(M=>M.type==="multiplestroke"))for(const M of R.multipath||[])M.visible&&M.type==="stroke"&&M.min&&M.max&&M.min[0]>S&&M.min[1]>B&&M.max[0]<L&&M.max[1]<j&&(k=!0);if(m.length>0||k){for(const R of x.filter(M=>M.type==="multiplestroke"))for(const M of R?.multipath||[])M.visible&&M.min&&M.max&&M.min[0]>S&&M.min[1]>B&&M.max[0]<L&&M.max[1]<j&&(M.selected=!0);for(const R of m)R.selected=!0;p(b,[...x],!0),console.log(m),Ea({minX:i(K),minY:i(Z),maxX:i(J),maxY:i(G),strokes:m,id:l(),draw_id:f()})}else p(K,0),p(Z,0),p(J,0),p(G,0)}p(he,"idle"),u?.pointerId&&u.target?.releasePointerCapture?.(u.pointerId)}Eo(()=>{p(F,t.$$host?.shadowRoot?.querySelector("svg"),!0),p(be,t.$$host?.shadowRoot?.querySelector("#container"),!0);let u=0;const x=setInterval(()=>{p(F,t.$$host?.shadowRoot?.querySelector("svg"),!0),i(F)?clearInterval(x):(u++,u>10?(clearInterval(x),console.warn("no canvas found on check "+u)):console.error("no canvas found on check "+u+" end"))},100);if(!i(F))return console.error("no canvas found on mount")});var Ca={get id(){return l()},set id(u=""){l(u),de()},get load_draw(){return a()},set load_draw(u){a(u),de()},get draw_id(){return f()},set draw_id(u=Math.random().toString(36)+Math.random().toString(36)+Date.now().toString()){f(u),de()},get background_color(){return c()},set background_color(u="rgb(255,255,255)"){c(u),de()},get pen_color(){return h()},set pen_color(u="rgb(0,0,0)"){h(u),de()},get insert_image(){return _()},set insert_image(u=void 0){_(u),de()},get insert_text(){return v()},set insert_text(u){v(u),de()},get pen_opacity(){return g()},set pen_opacity(u=1){g(u),de()},get options(){return d()},set options(u=r){d(u),de()},get goto(){return y()},set goto(u=void 0){y(u),de()},get mode(){return E()},set mode(u="draw"){E(u),de()},get debug(){return D()},set debug(u="no"){D(u),de()},get save_as(){return $()},set save_as(u=void 0){$(u),de()},get size(){return z()},set size(u=Object.assign({},s)){z(u),de()},get view(){return te()},set view(u=Object.assign({},o)){te(u),de()}},es=ga(),Rn=Ve(es),Pa=ht(Rn);lt(Rn);var ts=ii(Rn,2),Kt=ht(ts),La=ht(Kt);{var qa=u=>{var x=_a(),S=ht(x);Mi(S,17,()=>i(b),j=>j.id,(j,m,k,R)=>{var M=nt(),fe=Ve(M);{var Yt=ve=>{var W=nt(),ja=Ve(W);{var Ya=Zt=>{var _n=nt(),hr=Ve(_n);{var gn=xe=>{var Q=nt(),Qt=Ve(Q);{var pr=ze=>{var pe=ea();oe(()=>{T(pe,"id","path_"+i(m).id),T(pe,"d",i(m).pathData),T(pe,"fill",i(m).color),T(pe,"fill-opacity",i(m).opacity)}),X(ze,pe)},_r=ze=>{var pe=ta();oe(()=>{T(pe,"id","path_"+i(m).id),T(pe,"href",i(m).pathData)}),X(ze,pe)},gr=ze=>{var pe=na(),Ee=ht(pe,!0);lt(pe),oe(()=>{T(pe,"id","path_"+i(m).id),ln(Ee,i(m).pathData)}),X(ze,pe)};Je(Qt,ze=>{i(m).type==="stroke"?ze(pr):i(m).type==="image"?ze(_r,1):i(m).type==="text"&&ze(gr,2)})}X(xe,Q)},q=xe=>{var Q=ra();oe(()=>{T(Q,"id","path_"+i(m).id),T(Q,"d",i(m).pathData),T(Q,"fill",i(m).color),T(Q,"fill-opacity",i(m).opacity)}),X(xe,Q)},Cn=xe=>{var Q=ia();oe(()=>{T(Q,"id","path_"+i(m).id),T(Q,"href",i(m).pathData)}),X(xe,Q)},vr=xe=>{var Q=sa(),Qt=ht(Q,!0);lt(Q),oe(()=>{T(Q,"id","path_"+i(m).id),ln(Qt,i(m).pathData)}),X(xe,Q)};Je(hr,xe=>{i(m).selected?xe(gn):!i(m).selected&&i(m).type==="stroke"?xe(q,1):!i(m).selected&&i(m).type==="image"?xe(Cn,2):!i(m).selected&&i(m).type==="text"&&xe(vr,3)})}X(Zt,_n)},Fa=Zt=>{var _n=nt(),hr=Ve(_n);Mi(hr,17,()=>i(m).multipath,gn=>gn.id+i(m).id,(gn,q)=>{var Cn=nt(),vr=Ve(Cn);{var xe=Q=>{var Qt=nt(),pr=Ve(Qt);{var _r=Ee=>{var ue=nt(),mr=Ve(ue);{var Xa=rt=>{var $e=oa();oe(()=>{T($e,"id","path_"+i(q).id+"_"+i(m).id),T($e,"d",i(q).pathData),T($e,"fill",i(q).color),T($e,"fill-opacity",i(q).opacity)}),X(rt,$e)},za=rt=>{var $e=aa();oe(()=>{T($e,"id","path_"+i(q).id+"_"+i(m).id),T($e,"href",i(q).pathData)}),X(rt,$e)},Ha=rt=>{var $e=la(),Ba=ht($e,!0);lt($e),oe(()=>{T($e,"id","path_"+i(q).id+"_"+i(m).id),ln(Ba,i(q).pathData)}),X(rt,$e)};Je(mr,rt=>{i(q).type==="stroke"?rt(Xa):i(q).type==="image"?rt(za,1):i(q).type==="text"&&rt(Ha,2)})}X(Ee,ue)},gr=Ee=>{var ue=fa();oe(()=>{T(ue,"id","path_"+i(q).id+"_"+i(m).id),T(ue,"d",i(q).pathData),T(ue,"fill",i(q).color),T(ue,"fill-opacity",i(q).opacity)}),X(Ee,ue)},ze=Ee=>{var ue=ua();oe(()=>{T(ue,"id","path_"+i(q).id+"_"+i(m).id),T(ue,"href",i(q).pathData)}),X(Ee,ue)},pe=Ee=>{var ue=ca(),mr=ht(ue,!0);lt(ue),oe(()=>{T(ue,"id","path_"+i(q).id+"_"+i(m).id),ln(mr,i(q).pathData)}),X(Ee,ue)};Je(pr,Ee=>{i(q).selected?Ee(_r):!i(q).selected&&i(q).type==="stroke"?Ee(gr,1):!i(q).selected&&i(q).type==="image"?Ee(ze,2):!i(q).selected&&i(q).type==="text"&&Ee(pe,3)})}X(Q,Qt)};Je(vr,Q=>{i(q).actionIndex<=i(w)&&!i(me)&&(i(q).visible||i(q).erasedAtIndex&&i(q).erasedAtIndex>i(w))&&Q(xe)})}X(gn,Cn)}),X(Zt,_n)};Je(ja,Zt=>{i(m).type==="stroke"||i(m).type==="image"||i(m).type==="text"?Zt(Ya):i(m).type==="multiplestroke"&&i(m).multipath&&Zt(Fa,1)})}X(ve,W)};Je(fe,ve=>{i(m).actionIndex<=i(w)&&!i(me)&&(i(m).visible||i(m).erasedAtIndex&&i(m).erasedAtIndex>i(w))&&ve(Yt)})}X(j,M)});var B=ii(S);{var L=j=>{var m=nt(),k=Ve(m);{var R=ve=>{var W=da();oe(()=>{T(W,"x",i(K)),T(W,"y",i(Z)),T(W,"width",i(J)-i(K)),T(W,"height",i(G)-i(Z))}),X(ve,W)},M=ve=>{var W=ha();oe(()=>{T(W,"x",i(J)),T(W,"y",i(Z)),T(W,"width",i(K)-i(J)),T(W,"height",i(G)-i(Z))}),X(ve,W)},fe=ve=>{var W=va();oe(()=>{T(W,"x",i(K)),T(W,"y",i(G)),T(W,"width",i(J)-i(K)),T(W,"height",i(Z)-i(G))}),X(ve,W)},Yt=ve=>{var W=pa();oe(()=>{T(W,"x",i(J)),T(W,"y",i(G)),T(W,"width",i(K)-i(J)),T(W,"height",i(Z)-i(G))}),X(ve,W)};Je(k,ve=>{i(K)<=i(J)&&i(Z)<=i(G)?ve(R):i(K)>i(J)&&i(Z)<i(G)?ve(M,1):i(K)<i(J)&&i(Z)>i(G)?ve(fe,2):ve(Yt,-1)})}X(j,m)};Je(B,j=>{E()==="select"&&j(L)})}lt(x),X(u,x)};Je(La,u=>{i(F)&&u(qa)})}return lt(Kt),lt(ts),oe(()=>{ki(Rn,`display:${D()==="yes"?"block":"none"}`),ln(Pa,`${i(Fe)??""} b: ${i(yt)??""}`),ki(Kt,`background-color:${c()??""};cursor:${i(U)===!0?"move":"default"}`)}),ir("pointerdown",Kt,Oa),ir("pointermove",Kt,Na),ir("pointerup",Kt,Ra),X(e,es),Cr(Ca)}ho(["pointerdown","pointermove","pointerup"]),customElements.define("hb-stylus-paper",Lo(Ki,{id:{},load_draw:{},draw_id:{},background_color:{},pen_color:{},insert_image:{},insert_text:{},pen_opacity:{},options:{},goto:{},mode:{},debug:{},save_as:{},size:{},view:{}},[],[],{mode:"open"})),wr.Component=Ki,Object.defineProperty(wr,Symbol.toStringTag,{value:"Module"})})(this["stylus-paper"]=this["stylus-paper"]||{});
|
|
1
|
+
(function(mr){"use strict";typeof window<"u"&&((window.__svelte??={}).v??=new Set).add("5");const es=1,ts=2,ns=16,rs=1,is=4,ss=8,os=16,ls=2,wr="[",Cn="[!",yr="[?",Pn="]",jt={},se=Symbol(),br="http://www.w3.org/1999/xhtml",as=!1;var xr=Array.isArray,fs=Array.prototype.indexOf,Ft=Array.prototype.includes,gn=Array.from,mn=Object.keys,wn=Object.defineProperty,St=Object.getOwnPropertyDescriptor,us=Object.getOwnPropertyDescriptors,cs=Object.prototype,ds=Array.prototype,Sr=Object.getPrototypeOf,$r=Object.isExtensible;const hs=()=>{};function ps(e){for(var t=0;t<e.length;t++)e[t]()}function Er(){var e,t,n=new Promise((i,s)=>{e=i,t=s});return{promise:n,resolve:e,reject:t}}const ie=2,Xt=4,yn=8,Tr=1<<24,it=16,qe=32,st=64,qn=128,Me=512,re=1024,ce=2048,He=4096,Ee=8192,ke=16384,ot=32768,Ar=1<<25,zt=65536,Ir=1<<17,vs=1<<18,$t=1<<19,_s=1<<20,Ke=1<<25,Et=65536,Ln=1<<21,Yn=1<<22,lt=1<<23,bn=Symbol("$state"),Dr=Symbol("legacy props"),gs=Symbol(""),Ze=new class extends Error{name="StaleReactionError";message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ms=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml"),xn=3,Qt=8;function ws(e){throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function ys(){throw new Error("https://svelte.dev/e/async_derived_orphan")}function bs(e,t,n){throw new Error("https://svelte.dev/e/each_key_duplicate")}function xs(e){throw new Error("https://svelte.dev/e/effect_in_teardown")}function Ss(){throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function $s(e){throw new Error("https://svelte.dev/e/effect_orphan")}function Es(){throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function Ts(){throw new Error("https://svelte.dev/e/hydration_failed")}function As(e){throw new Error("https://svelte.dev/e/props_invalid_value")}function Is(){throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function Ds(){throw new Error("https://svelte.dev/e/state_prototype_fixed")}function Ms(){throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function ks(){throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}function Sn(e){console.warn("https://svelte.dev/e/hydration_mismatch")}function Os(){console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}let j=!1;function Qe(e){j=e}let C;function Te(e){if(e===null)throw Sn(),jt;return C=e}function $n(){return Te(Be(C))}function at(e){if(j){if(Be(C)!==null)throw Sn(),jt;C=e}}function Ns(e=1){if(j){for(var t=e,n=C;t--;)n=Be(n);C=n}}function En(e=!0){for(var t=0,n=C;;){if(n.nodeType===Qt){var i=n.data;if(i===Pn){if(t===0)return n;t-=1}else(i===wr||i===Cn||i[0]==="["&&!isNaN(Number(i.slice(1))))&&(t+=1)}var s=Be(n);e&&n.remove(),n=s}}function Mr(e){if(!e||e.nodeType!==Qt)throw Sn(),jt;return e.data}function kr(e){return e===this.v}function Rs(e,t){return e!=e?t==t:e!==t||e!==null&&typeof e=="object"||typeof e=="function"}function Or(e){return!Rs(e,this.v)}let Cs=!1,Ae=null;function Ht(e){Ae=e}function Nr(e,t=!1,n){Ae={p:Ae,i:!1,c:null,e:null,s:e,x:null,r:N,l:null}}function Rr(e){var t=Ae,n=t.e;if(n!==null){t.e=null;for(var i of n)ai(i)}return e!==void 0&&(t.x=e),t.i=!0,Ae=t.p,e??{}}function Cr(){return!0}let Tt=[];function Pr(){var e=Tt;Tt=[],ps(e)}function Bt(e){if(Tt.length===0&&!en){var t=Tt;queueMicrotask(()=>{t===Tt&&Pr()})}Tt.push(e)}function Ps(){for(;Tt.length>0;)Pr()}function qr(e){var t=N;if(t===null)return O.f|=lt,e;if((t.f&ot)===0&&(t.f&Xt)===0)throw e;ft(e,t)}function ft(e,t){for(;t!==null;){if((t.f&qn)!==0){if((t.f&ot)===0)throw e;try{t.b.error(e);return}catch(n){e=n}}t=t.parent}throw e}const qs=-7169;function ee(e,t){e.f=e.f&qs|t}function jn(e){(e.f&Me)!==0||e.deps===null?ee(e,re):ee(e,He)}function Lr(e){if(e!==null)for(const t of e)(t.f&ie)===0||(t.f&Et)===0||(t.f^=Et,Lr(t.deps))}function Yr(e,t,n){(e.f&ce)!==0?t.add(e):(e.f&He)!==0&&n.add(e),Lr(e.deps),ee(e,re)}let Tn=!1;function Ls(e){var t=Tn;try{return Tn=!1,[e(),Tn]}finally{Tn=t}}const ut=new Set;let V=null,Le=null,Fn=null,en=!1,Xn=!1,Vt=null,An=null;var jr=0;let Ys=1;class et{id=Ys++;current=new Map;previous=new Map;#e=new Set;#n=new Set;#t=new Map;#i=new Map;#s=null;#r=[];#o=new Set;#l=new Set;#a=new Map;is_fork=!1;#c=!1;#f=new Set;#d(){return this.is_fork||this.#i.size>0}#p(){for(const i of this.#f)for(const s of i.#i.keys()){for(var t=!1,n=s;n.parent!==null;){if(this.#a.has(n)){t=!0;break}n=n.parent}if(!t)return!0}return!1}skip_effect(t){this.#a.has(t)||this.#a.set(t,{d:[],m:[]})}unskip_effect(t){var n=this.#a.get(t);if(n){this.#a.delete(t);for(var i of n.d)ee(i,ce),this.schedule(i);for(i of n.m)ee(i,He),this.schedule(i)}}#h(){if(jr++>1e3&&(ut.delete(this),js()),!this.#d()){for(const l of this.#o)this.#l.delete(l),ee(l,ce),this.schedule(l);for(const l of this.#l)ee(l,He),this.schedule(l)}const t=this.#r;this.#r=[],this.apply();var n=Vt=[],i=[],s=An=[];for(const l of t)try{this.#u(l,n,i)}catch(f){throw Br(l),f}if(V=null,s.length>0){var o=et.ensure();for(const l of s)o.schedule(l)}if(Vt=null,An=null,this.#d()||this.#p()){this.#v(i),this.#v(n);for(const[l,f]of this.#a)Hr(l,f)}else{this.#t.size===0&&ut.delete(this),this.#o.clear(),this.#l.clear();for(const l of this.#e)l(this);this.#e.clear(),Fr(i),Fr(n),this.#s?.resolve()}var a=V;if(this.#r.length>0){const l=a??=this;l.#r.push(...this.#r.filter(f=>!l.#r.includes(f)))}a!==null&&(ut.add(a),a.#h()),ut.has(this)||this.#_()}#u(t,n,i){t.f^=re;for(var s=t.first;s!==null;){var o=s.f,a=(o&(qe|st))!==0,l=a&&(o&re)!==0,f=l||(o&Ee)!==0||this.#a.has(s);if(!f&&s.fn!==null){a?s.f^=re:(o&Xt)!==0?n.push(s):rn(s)&&((o&it)!==0&&this.#l.add(s),Jt(s));var c=s.first;if(c!==null){s=c;continue}}for(;s!==null;){var h=s.next;if(h!==null){s=h;break}s=s.parent}}}#v(t){for(var n=0;n<t.length;n+=1)Yr(t[n],this.#o,this.#l)}capture(t,n,i=!1){n!==se&&!this.previous.has(t)&&this.previous.set(t,n),(t.f<)===0&&(this.current.set(t,[t.v,i]),Le?.set(t,t.v))}activate(){V=this}deactivate(){V=null,Le=null}flush(){try{Xn=!0,V=this,this.#h()}finally{jr=0,Fn=null,Vt=null,An=null,Xn=!1,V=null,Le=null,ct.clear()}}discard(){for(const t of this.#n)t(this);this.#n.clear(),ut.delete(this)}#_(){for(const c of ut){var t=c.id<this.id,n=[];for(const[h,[_,v]]of this.current){if(c.current.has(h)){var i=c.current.get(h)[0];if(t&&_!==i)c.current.set(h,[_,v]);else continue}n.push(h)}var s=[...c.current.keys()].filter(h=>!this.current.has(h));if(s.length===0)t&&c.discard();else if(n.length>0){c.activate();var o=new Set,a=new Map;for(var l of n)Xr(l,s,o,a);if(c.#r.length>0){c.apply();for(var f of c.#r)c.#u(f,[],[]);c.#r=[]}c.deactivate()}}for(const c of ut)c.#f.has(this)&&(c.#f.delete(this),c.#f.size===0&&!c.#d()&&(c.activate(),c.#h()))}increment(t,n){let i=this.#t.get(n)??0;if(this.#t.set(n,i+1),t){let s=this.#i.get(n)??0;this.#i.set(n,s+1)}}decrement(t,n,i){let s=this.#t.get(n)??0;if(s===1?this.#t.delete(n):this.#t.set(n,s-1),t){let o=this.#i.get(n)??0;o===1?this.#i.delete(n):this.#i.set(n,o-1)}this.#c||i||(this.#c=!0,Bt(()=>{this.#c=!1,this.flush()}))}transfer_effects(t,n){for(const i of t)this.#o.add(i);for(const i of n)this.#l.add(i);t.clear(),n.clear()}oncommit(t){this.#e.add(t)}ondiscard(t){this.#n.add(t)}settled(){return(this.#s??=Er()).promise}static ensure(){if(V===null){const t=V=new et;Xn||(ut.add(V),en||Bt(()=>{V===t&&t.flush()}))}return V}apply(){{Le=null;return}}schedule(t){if(Fn=t,t.b?.is_pending&&(t.f&(Xt|yn|Tr))!==0&&(t.f&ot)===0){t.b.defer_effect(t);return}for(var n=t;n.parent!==null;){n=n.parent;var i=n.f;if(Vt!==null&&n===N&&(O===null||(O.f&ie)===0))return;if((i&(st|qe))!==0){if((i&re)===0)return;n.f^=re}}this.#r.push(n)}}function de(e){var t=en;en=!0;try{for(var n;;){if(Ps(),V===null)return n;V.flush()}}finally{en=t}}function js(){try{Es()}catch(e){ft(e,Fn)}}let tt=null;function Fr(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var i=e[n++];if((i.f&(ke|Ee))===0&&rn(i)&&(tt=new Set,Jt(i),i.deps===null&&i.first===null&&i.nodes===null&&i.teardown===null&&i.ac===null&&ci(i),tt?.size>0)){ct.clear();for(const s of tt){if((s.f&(ke|Ee))!==0)continue;const o=[s];let a=s.parent;for(;a!==null;)tt.has(a)&&(tt.delete(a),o.push(a)),a=a.parent;for(let l=o.length-1;l>=0;l--){const f=o[l];(f.f&(ke|Ee))===0&&Jt(f)}}tt.clear()}}tt=null}}function Xr(e,t,n,i){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(const s of e.reactions){const o=s.f;(o&ie)!==0?Xr(s,t,n,i):(o&(Yn|it))!==0&&(o&ce)===0&&zr(s,t,i)&&(ee(s,ce),zn(s))}}function zr(e,t,n){const i=n.get(e);if(i!==void 0)return i;if(e.deps!==null)for(const s of e.deps){if(Ft.call(t,s))return!0;if((s.f&ie)!==0&&zr(s,t,n))return n.set(s,!0),!0}return n.set(e,!1),!1}function zn(e){V.schedule(e)}function Hr(e,t){if(!((e.f&qe)!==0&&(e.f&re)!==0)){(e.f&ce)!==0?t.d.push(e):(e.f&He)!==0&&t.m.push(e),ee(e,re);for(var n=e.first;n!==null;)Hr(n,t),n=n.next}}function Br(e){ee(e,re);for(var t=e.first;t!==null;)Br(t),t=t.next}function Fs(e){let t=0,n=At(0),i;return()=>{Gn()&&(r(n),fi(()=>(t===0&&(i=tr(()=>e(()=>nn(n)))),t+=1,()=>{Bt(()=>{t-=1,t===0&&(i?.(),i=void 0,nn(n))})})))}}var Xs=zt|$t;function zs(e,t,n,i){new Hs(e,t,n,i)}class Hs{parent;is_pending=!1;transform_error;#e;#n=j?C:null;#t;#i;#s;#r=null;#o=null;#l=null;#a=null;#c=0;#f=0;#d=!1;#p=new Set;#h=new Set;#u=null;#v=Fs(()=>(this.#u=At(this.#c),()=>{this.#u=null}));constructor(t,n,i,s){this.#e=t,this.#t=n,this.#i=o=>{var a=N;a.b=this,a.f|=qn,i(o)},this.parent=N.b,this.transform_error=s??this.parent?.transform_error??(o=>o),this.#s=Kn(()=>{if(j){const o=this.#n;$n();const a=o.data===Cn;if(o.data.startsWith(yr)){const f=JSON.parse(o.data.slice(yr.length));this.#b(f)}else a?this.#x():this.#_()}else this.#w()},Xs),j&&(this.#e=C)}#_(){try{this.#r=Oe(()=>this.#i(this.#e))}catch(t){this.error(t)}}#b(t){const n=this.#t.failed;n&&(this.#l=Oe(()=>{n(this.#e,()=>t,()=>()=>{})}))}#x(){const t=this.#t.pending;t&&(this.is_pending=!0,this.#o=Oe(()=>t(this.#e)),Bt(()=>{var n=this.#a=document.createDocumentFragment(),i=Ye();n.append(i),this.#r=this.#m(()=>Oe(()=>this.#i(i))),this.#f===0&&(this.#e.before(n),this.#a=null,Dt(this.#o,()=>{this.#o=null}),this.#g(V))}))}#w(){try{if(this.is_pending=this.has_pending_snippet(),this.#f=0,this.#c=0,this.#r=Oe(()=>{this.#i(this.#e)}),this.#f>0){var t=this.#a=document.createDocumentFragment();er(this.#r,t);const n=this.#t.pending;this.#o=Oe(()=>n(this.#e))}else this.#g(V)}catch(n){this.error(n)}}#g(t){this.is_pending=!1,t.transfer_effects(this.#p,this.#h)}defer_effect(t){Yr(t,this.#p,this.#h)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#t.pending}#m(t){var n=N,i=O,s=Ae;Je(this.#s),Ne(this.#s),Ht(this.#s.ctx);try{return et.ensure(),t()}catch(o){return qr(o),null}finally{Je(n),Ne(i),Ht(s)}}#y(t,n){if(!this.has_pending_snippet()){this.parent&&this.parent.#y(t,n);return}this.#f+=t,this.#f===0&&(this.#g(n),this.#o&&Dt(this.#o,()=>{this.#o=null}),this.#a&&(this.#e.before(this.#a),this.#a=null))}update_pending_count(t,n){this.#y(t,n),this.#c+=t,!(!this.#u||this.#d)&&(this.#d=!0,Bt(()=>{this.#d=!1,this.#u&&Ut(this.#u,this.#c)}))}get_effect_pending(){return this.#v(),r(this.#u)}error(t){var n=this.#t.onerror;let i=this.#t.failed;if(!n&&!i)throw t;this.#r&&(_e(this.#r),this.#r=null),this.#o&&(_e(this.#o),this.#o=null),this.#l&&(_e(this.#l),this.#l=null),j&&(Te(this.#n),Ns(),Te(En()));var s=!1,o=!1;const a=()=>{if(s){Os();return}s=!0,o&&ks(),this.#l!==null&&Dt(this.#l,()=>{this.#l=null}),this.#m(()=>{this.#w()})},l=f=>{try{o=!0,n?.(f,a),o=!1}catch(c){ft(c,this.#s&&this.#s.parent)}i&&(this.#l=this.#m(()=>{try{return Oe(()=>{var c=N;c.b=this,c.f|=qn,i(this.#e,()=>f,()=>a)})}catch(c){return ft(c,this.#s.parent),null}}))};Bt(()=>{var f;try{f=this.transform_error(t)}catch(c){ft(c,this.#s&&this.#s.parent);return}f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(l,c=>ft(c,this.#s&&this.#s.parent)):l(f)})}}function Bs(e,t,n,i){const s=Hn;var o=e.filter(v=>!v.settled);if(n.length===0&&o.length===0){i(t.map(s));return}var a=N,l=Vs(),f=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(v=>v.promise)):null;function c(v){l();try{i(v)}catch(m){(a.f&ke)===0&&ft(m,a)}In()}if(n.length===0){f.then(()=>c(t.map(s)));return}var h=Vr();function _(){Promise.all(n.map(v=>Us(v))).then(v=>c([...t.map(s),...v])).catch(v=>ft(v,a)).finally(()=>h())}f?f.then(()=>{l(),_(),In()}):_()}function Vs(){var e=N,t=O,n=Ae,i=V;return function(o=!0){Je(e),Ne(t),Ht(n),o&&(e.f&ke)===0&&(i?.activate(),i?.apply())}}function In(e=!0){Je(null),Ne(null),Ht(null),e&&V?.deactivate()}function Vr(){var e=N,t=e.b,n=V,i=t.is_rendered();return t.update_pending_count(1,n),n.increment(i,e),(s=!1)=>{t.update_pending_count(-1,n),n.decrement(i,e,s)}}function Hn(e){var t=ie|ce,n=O!==null&&(O.f&ie)!==0?O:null;return N!==null&&(N.f|=$t),{ctx:Ae,deps:null,effects:null,equals:kr,f:t,fn:e,reactions:null,rv:0,v:se,wv:0,parent:n??N,ac:null}}function Us(e,t,n){let i=N;i===null&&ys();var s=void 0,o=At(se),a=!O,l=new Map;return io(()=>{var f=N,c=Er();s=c.promise;try{Promise.resolve(e()).then(c.resolve,c.reject).finally(In)}catch(m){c.reject(m),In()}var h=V;if(a){if((f.f&ot)!==0)var _=Vr();if(i.b.is_rendered())l.get(h)?.reject(Ze),l.delete(h);else{for(const m of l.values())m.reject(Ze);l.clear()}l.set(h,c)}const v=(m,d=void 0)=>{if(_){var y=d===Ze;_(y)}if(!(d===Ze||(f.f&ke)!==0)){if(h.activate(),d)o.f|=lt,Ut(o,d);else{(o.f<)!==0&&(o.f^=lt),Ut(o,m);for(const[S,A]of l){if(l.delete(S),S===h)break;A.reject(Ze)}}h.deactivate()}};c.promise.then(v,m=>v(null,m||"unknown"))}),eo(()=>{for(const f of l.values())f.reject(Ze)}),new Promise(f=>{function c(h){function _(){h===s?f(o):c(s)}h.then(_,_)}c(s)})}function Ur(e){const t=Hn(e);return t.equals=Or,t}function Js(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)_e(t[n])}}function Ws(e){for(var t=e.parent;t!==null;){if((t.f&ie)===0)return(t.f&ke)===0?t:null;t=t.parent}return null}function Bn(e){var t,n=N;Je(Ws(e));try{e.f&=~Et,Js(e),t=wi(e)}finally{Je(n)}return t}function Jr(e){var t=e.v,n=Bn(e);if(!e.equals(n)&&(e.wv=gi(),(!V?.is_fork||e.deps===null)&&(e.v=n,V?.capture(e,t,!0),e.deps===null))){ee(e,re);return}pt||(Le!==null?(Gn()||V?.is_fork)&&Le.set(e,n):jn(e))}function Gs(e){if(e.effects!==null)for(const t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(Ze),t.teardown=hs,t.ac=null,sn(t,0),Zn(t))}function Wr(e){if(e.effects!==null)for(const t of e.effects)t.teardown&&Jt(t)}let Vn=new Set;const ct=new Map;let Gr=!1;function At(e,t){var n={f:0,v:e,reactions:null,equals:kr,rv:0,wv:0};return n}function I(e,t){const n=At(e);return lo(n),n}function Kr(e,t=!1,n=!0){const i=At(e);return t||(i.equals=Or),i}function p(e,t,n=!1){O!==null&&(!je||(O.f&Ir)!==0)&&Cr()&&(O.f&(ie|it|Yn|Ir))!==0&&(Re===null||!Ft.call(Re,e))&&Ms();let i=n?dt(t):t;return Ut(e,i,An)}function Ut(e,t,n=null){if(!e.equals(t)){var i=e.v;pt?ct.set(e,t):ct.set(e,i),e.v=t;var s=et.ensure();if(s.capture(e,i),(e.f&ie)!==0){const o=e;(e.f&ce)!==0&&Bn(o),Le===null&&jn(o)}e.wv=gi(),Zr(e,ce,n),N!==null&&(N.f&re)!==0&&(N.f&(qe|st))===0&&(Ce===null?ao([e]):Ce.push(e)),!s.is_fork&&Vn.size>0&&!Gr&&Ks()}return t}function Ks(){Gr=!1;for(const e of Vn)(e.f&re)!==0&&ee(e,He),rn(e)&&Jt(e);Vn.clear()}function tn(e,t=1){var n=r(e),i=t===1?n++:n--;return p(e,n),i}function nn(e){p(e,e.v+1)}function Zr(e,t,n){var i=e.reactions;if(i!==null)for(var s=i.length,o=0;o<s;o++){var a=i[o],l=a.f,f=(l&ce)===0;if(f&&ee(a,t),(l&ie)!==0){var c=a;Le?.delete(c),(l&Et)===0&&(l&Me&&(a.f|=Et),Zr(c,He,n))}else if(f){var h=a;(l&it)!==0&&tt!==null&&tt.add(h),n!==null?n.push(h):zn(h)}}}function dt(e){if(typeof e!="object"||e===null||bn in e)return e;const t=Sr(e);if(t!==cs&&t!==ds)return e;var n=new Map,i=xr(e),s=I(0),o=kt,a=l=>{if(kt===o)return l();var f=O,c=kt;Ne(null),_i(o);var h=l();return Ne(f),_i(c),h};return i&&n.set("length",I(e.length)),new Proxy(e,{defineProperty(l,f,c){(!("value"in c)||c.configurable===!1||c.enumerable===!1||c.writable===!1)&&Is();var h=n.get(f);return h===void 0?a(()=>{var _=I(c.value);return n.set(f,_),_}):p(h,c.value,!0),!0},deleteProperty(l,f){var c=n.get(f);if(c===void 0){if(f in l){const h=a(()=>I(se));n.set(f,h),nn(s)}}else p(c,se),nn(s);return!0},get(l,f,c){if(f===bn)return e;var h=n.get(f),_=f in l;if(h===void 0&&(!_||St(l,f)?.writable)&&(h=a(()=>{var m=dt(_?l[f]:se),d=I(m);return d}),n.set(f,h)),h!==void 0){var v=r(h);return v===se?void 0:v}return Reflect.get(l,f,c)},getOwnPropertyDescriptor(l,f){var c=Reflect.getOwnPropertyDescriptor(l,f);if(c&&"value"in c){var h=n.get(f);h&&(c.value=r(h))}else if(c===void 0){var _=n.get(f),v=_?.v;if(_!==void 0&&v!==se)return{enumerable:!0,configurable:!0,value:v,writable:!0}}return c},has(l,f){if(f===bn)return!0;var c=n.get(f),h=c!==void 0&&c.v!==se||Reflect.has(l,f);if(c!==void 0||N!==null&&(!h||St(l,f)?.writable)){c===void 0&&(c=a(()=>{var v=h?dt(l[f]):se,m=I(v);return m}),n.set(f,c));var _=r(c);if(_===se)return!1}return h},set(l,f,c,h){var _=n.get(f),v=f in l;if(i&&f==="length")for(var m=c;m<_.v;m+=1){var d=n.get(m+"");d!==void 0?p(d,se):m in l&&(d=a(()=>I(se)),n.set(m+"",d))}if(_===void 0)(!v||St(l,f)?.writable)&&(_=a(()=>I(void 0)),p(_,dt(c)),n.set(f,_));else{v=_.v!==se;var y=a(()=>dt(c));p(_,y)}var S=Reflect.getOwnPropertyDescriptor(l,f);if(S?.set&&S.set.call(h,c),!v){if(i&&typeof f=="string"){var A=n.get("length"),$=Number(f);Number.isInteger($)&&$>=A.v&&p(A,$+1)}nn(s)}return!0},ownKeys(l){r(s);var f=Reflect.ownKeys(l).filter(_=>{var v=n.get(_);return v===void 0||v.v!==se});for(var[c,h]of n)h.v!==se&&!(c in l)&&f.push(c);return f},setPrototypeOf(){Ds()}})}var Qr,ei,ti,ni;function Un(){if(Qr===void 0){Qr=window,ei=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;ti=St(t,"firstChild").get,ni=St(t,"nextSibling").get,$r(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),$r(n)&&(n.__t=void 0)}}function Ye(e=""){return document.createTextNode(e)}function It(e){return ti.call(e)}function Be(e){return ni.call(e)}function ht(e,t){if(!j)return It(e);var n=It(C);if(n===null)n=C.appendChild(Ye());else if(t&&n.nodeType!==xn){var i=Ye();return n?.before(i),Te(i),i}return t&&Wn(n),Te(n),n}function Ve(e,t=!1){if(!j){var n=It(e);return n instanceof Comment&&n.data===""?Be(n):n}if(t){if(C?.nodeType!==xn){var i=Ye();return C?.before(i),Te(i),i}Wn(C)}return C}function ri(e,t=1,n=!1){let i=j?C:e;for(var s;t--;)s=i,i=Be(i);if(!j)return i;if(n){if(i?.nodeType!==xn){var o=Ye();return i===null?s?.after(o):i.before(o),Te(o),o}Wn(i)}return Te(i),i}function ii(e){e.textContent=""}function si(){return!1}function Jn(e,t,n){return document.createElementNS(br,e,void 0)}function Wn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===xn;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function oi(e){var t=O,n=N;Ne(null),Je(null);try{return e()}finally{Ne(t),Je(n)}}function Zs(e){N===null&&(O===null&&$s(),Ss()),pt&&xs()}function Qs(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function Ue(e,t){var n=N;n!==null&&(n.f&Ee)!==0&&(e|=Ee);var i={ctx:Ae,deps:null,nodes:null,f:e|ce|Me,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null},s=i;if((e&Xt)!==0)Vt!==null?Vt.push(i):et.ensure().schedule(i);else if(t!==null){try{Jt(i)}catch(a){throw _e(i),a}s.deps===null&&s.teardown===null&&s.nodes===null&&s.first===s.last&&(s.f&$t)===0&&(s=s.first,(e&it)!==0&&(e&zt)!==0&&s!==null&&(s.f|=zt))}if(s!==null&&(s.parent=n,n!==null&&Qs(s,n),O!==null&&(O.f&ie)!==0&&(e&st)===0)){var o=O;(o.effects??=[]).push(s)}return i}function Gn(){return O!==null&&!je}function eo(e){const t=Ue(yn,null);return ee(t,re),t.teardown=e,t}function li(e){Zs();var t=N.f,n=!O&&(t&qe)!==0&&(t&ot)===0;if(n){var i=Ae;(i.e??=[]).push(e)}else return ai(e)}function ai(e){return Ue(Xt|_s,e)}function to(e){et.ensure();const t=Ue(st|$t,e);return()=>{_e(t)}}function no(e){et.ensure();const t=Ue(st|$t,e);return(n={})=>new Promise(i=>{n.outro?Dt(t,()=>{_e(t),i(void 0)}):(_e(t),i(void 0))})}function ro(e){return Ue(Xt,e)}function io(e){return Ue(Yn|$t,e)}function fi(e,t=0){return Ue(yn|t,e)}function oe(e,t=[],n=[],i=[]){Bs(i,t,n,s=>{Ue(yn,()=>e(...s.map(r)))})}function Kn(e,t=0){var n=Ue(it|t,e);return n}function Oe(e){return Ue(qe|$t,e)}function ui(e){var t=e.teardown;if(t!==null){const n=pt,i=O;pi(!0),Ne(null);try{t.call(null)}finally{pi(n),Ne(i)}}}function Zn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){const s=n.ac;s!==null&&oi(()=>{s.abort(Ze)});var i=n.next;(n.f&st)!==0?n.parent=null:_e(n,t),n=i}}function so(e){for(var t=e.first;t!==null;){var n=t.next;(t.f&qe)===0&&_e(t),t=n}}function _e(e,t=!0){var n=!1;(t||(e.f&vs)!==0)&&e.nodes!==null&&e.nodes.end!==null&&(oo(e.nodes.start,e.nodes.end),n=!0),ee(e,Ar),Zn(e,t&&!n),sn(e,0);var i=e.nodes&&e.nodes.t;if(i!==null)for(const o of i)o.stop();ui(e),e.f^=Ar,e.f|=ke;var s=e.parent;s!==null&&s.first!==null&&ci(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function oo(e,t){for(;e!==null;){var n=e===t?null:Be(e);e.remove(),e=n}}function ci(e){var t=e.parent,n=e.prev,i=e.next;n!==null&&(n.next=i),i!==null&&(i.prev=n),t!==null&&(t.first===e&&(t.first=i),t.last===e&&(t.last=n))}function Dt(e,t,n=!0){var i=[];di(e,i,!0);var s=()=>{n&&_e(e),t&&t()},o=i.length;if(o>0){var a=()=>--o||s();for(var l of i)l.out(a)}else s()}function di(e,t,n){if((e.f&Ee)===0){e.f^=Ee;var i=e.nodes&&e.nodes.t;if(i!==null)for(const l of i)(l.is_global||n)&&t.push(l);for(var s=e.first;s!==null;){var o=s.next,a=(s.f&zt)!==0||(s.f&qe)!==0&&(e.f&it)!==0;di(s,t,a?n:!1),s=o}}}function Qn(e){hi(e,!0)}function hi(e,t){if((e.f&Ee)!==0){e.f^=Ee,(e.f&re)===0&&(ee(e,ce),et.ensure().schedule(e));for(var n=e.first;n!==null;){var i=n.next,s=(n.f&zt)!==0||(n.f&qe)!==0;hi(n,s?t:!1),n=i}var o=e.nodes&&e.nodes.t;if(o!==null)for(const a of o)(a.is_global||t)&&a.in()}}function er(e,t){if(e.nodes)for(var n=e.nodes.start,i=e.nodes.end;n!==null;){var s=n===i?null:Be(n);t.append(n),n=s}}let Dn=!1,pt=!1;function pi(e){pt=e}let O=null,je=!1;function Ne(e){O=e}let N=null;function Je(e){N=e}let Re=null;function lo(e){O!==null&&(Re===null?Re=[e]:Re.push(e))}let we=null,Ie=0,Ce=null;function ao(e){Ce=e}let vi=1,Mt=0,kt=Mt;function _i(e){kt=e}function gi(){return++vi}function rn(e){var t=e.f;if((t&ce)!==0)return!0;if(t&ie&&(e.f&=~Et),(t&He)!==0){for(var n=e.deps,i=n.length,s=0;s<i;s++){var o=n[s];if(rn(o)&&Jr(o),o.wv>e.wv)return!0}(t&Me)!==0&&Le===null&&ee(e,re)}return!1}function mi(e,t,n=!0){var i=e.reactions;if(i!==null&&!(Re!==null&&Ft.call(Re,e)))for(var s=0;s<i.length;s++){var o=i[s];(o.f&ie)!==0?mi(o,t,!1):t===o&&(n?ee(o,ce):(o.f&re)!==0&&ee(o,He),zn(o))}}function wi(e){var t=we,n=Ie,i=Ce,s=O,o=Re,a=Ae,l=je,f=kt,c=e.f;we=null,Ie=0,Ce=null,O=(c&(qe|st))===0?e:null,Re=null,Ht(e.ctx),je=!1,kt=++Mt,e.ac!==null&&(oi(()=>{e.ac.abort(Ze)}),e.ac=null);try{e.f|=Ln;var h=e.fn,_=h();e.f|=ot;var v=e.deps,m=V?.is_fork;if(we!==null){var d;if(m||sn(e,Ie),v!==null&&Ie>0)for(v.length=Ie+we.length,d=0;d<we.length;d++)v[Ie+d]=we[d];else e.deps=v=we;if(Gn()&&(e.f&Me)!==0)for(d=Ie;d<v.length;d++)(v[d].reactions??=[]).push(e)}else!m&&v!==null&&Ie<v.length&&(sn(e,Ie),v.length=Ie);if(Cr()&&Ce!==null&&!je&&v!==null&&(e.f&(ie|He|ce))===0)for(d=0;d<Ce.length;d++)mi(Ce[d],e);if(s!==null&&s!==e){if(Mt++,s.deps!==null)for(let y=0;y<n;y+=1)s.deps[y].rv=Mt;if(t!==null)for(const y of t)y.rv=Mt;Ce!==null&&(i===null?i=Ce:i.push(...Ce))}return(e.f<)!==0&&(e.f^=lt),_}catch(y){return qr(y)}finally{e.f^=Ln,we=t,Ie=n,Ce=i,O=s,Re=o,Ht(a),je=l,kt=f}}function fo(e,t){let n=t.reactions;if(n!==null){var i=fs.call(n,e);if(i!==-1){var s=n.length-1;s===0?n=t.reactions=null:(n[i]=n[s],n.pop())}}if(n===null&&(t.f&ie)!==0&&(we===null||!Ft.call(we,t))){var o=t;(o.f&Me)!==0&&(o.f^=Me,o.f&=~Et),jn(o),Gs(o),sn(o,0)}}function sn(e,t){var n=e.deps;if(n!==null)for(var i=t;i<n.length;i++)fo(e,n[i])}function Jt(e){var t=e.f;if((t&ke)===0){ee(e,re);var n=N,i=Dn;N=e,Dn=!0;try{(t&(it|Tr))!==0?so(e):Zn(e),ui(e);var s=wi(e);e.teardown=typeof s=="function"?s:null,e.wv=vi;var o;as&&Cs&&(e.f&ce)!==0&&e.deps}finally{Dn=i,N=n}}}function r(e){var t=e.f,n=(t&ie)!==0;if(O!==null&&!je){var i=N!==null&&(N.f&ke)!==0;if(!i&&(Re===null||!Ft.call(Re,e))){var s=O.deps;if((O.f&Ln)!==0)e.rv<Mt&&(e.rv=Mt,we===null&&s!==null&&s[Ie]===e?Ie++:we===null?we=[e]:we.push(e));else{(O.deps??=[]).push(e);var o=e.reactions;o===null?e.reactions=[O]:Ft.call(o,O)||o.push(O)}}}if(pt&&ct.has(e))return ct.get(e);if(n){var a=e;if(pt){var l=a.v;return((a.f&re)===0&&a.reactions!==null||bi(a))&&(l=Bn(a)),ct.set(a,l),l}var f=(a.f&Me)===0&&!je&&O!==null&&(Dn||(O.f&Me)!==0),c=(a.f&ot)===0;rn(a)&&(f&&(a.f|=Me),Jr(a)),f&&!c&&(Wr(a),yi(a))}if(Le?.has(e))return Le.get(e);if((e.f<)!==0)throw e.v;return e.v}function yi(e){if(e.f|=Me,e.deps!==null)for(const t of e.deps)(t.reactions??=[]).push(e),(t.f&ie)!==0&&(t.f&Me)===0&&(Wr(t),yi(t))}function bi(e){if(e.v===se)return!0;if(e.deps===null)return!1;for(const t of e.deps)if(ct.has(t)||(t.f&ie)!==0&&bi(t))return!0;return!1}function tr(e){var t=je;try{return je=!0,e()}finally{je=t}}const on=Symbol("events"),xi=new Set,nr=new Set;function rr(e,t,n){(t[on]??={})[e]=n}function uo(e){for(var t=0;t<e.length;t++)xi.add(e[t]);for(var n of nr)n(e)}let Si=null;function $i(e){var t=this,n=t.ownerDocument,i=e.type,s=e.composedPath?.()||[],o=s[0]||e.target;Si=e;var a=0,l=Si===e&&e[on];if(l){var f=s.indexOf(l);if(f!==-1&&(t===document||t===window)){e[on]=t;return}var c=s.indexOf(t);if(c===-1)return;f<=c&&(a=f)}if(o=s[a]||e.target,o!==t){wn(e,"currentTarget",{configurable:!0,get(){return o||n}});var h=O,_=N;Ne(null),Je(null);try{for(var v,m=[];o!==null;){var d=o.assignedSlot||o.parentNode||o.host||null;try{var y=o[on]?.[i];y!=null&&(!o.disabled||e.target===o)&&y.call(o,e)}catch(S){v?m.push(S):v=S}if(e.cancelBubble||d===t||d===null)break;o=d}if(v){for(let S of m)queueMicrotask(()=>{throw S});throw v}}finally{e[on]=t,delete e.currentTarget,Ne(h),Je(_)}}}const co=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:e=>e});function ho(e){return co?.createHTML(e)??e}function Ei(e){var t=Jn("template");return t.innerHTML=ho(e.replaceAll("<!>","<!---->")),t.content}function Ot(e,t){var n=N;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function po(e,t){var n=(t&ls)!==0,i,s=!e.startsWith("<!>");return()=>{if(j)return Ot(C,null),C;i===void 0&&(i=Ei(s?e:"<!>"+e));var o=n||ei?document.importNode(i,!0):i.cloneNode(!0);{var a=It(o),l=o.lastChild;Ot(a,l)}return o}}function vo(e,t,n="svg"){var i=!e.startsWith("<!>"),s=`<${n}>${i?e:"<!>"+e}</${n}>`,o;return()=>{if(j)return Ot(C,null),C;if(!o){var a=Ei(s),l=It(a);o=It(l)}var f=o.cloneNode(!0);return Ot(f,f),f}}function le(e,t){return vo(e,t,"svg")}function nt(){if(j)return Ot(C,null),C;var e=document.createDocumentFragment(),t=document.createComment(""),n=Ye();return e.append(t,n),Ot(t,n),e}function X(e,t){if(j){var n=N;((n.f&ot)===0||n.nodes.end===null)&&(n.nodes.end=C),$n();return}e!==null&&e.before(t)}const _o=["touchstart","touchmove"];function go(e){return _o.includes(e)}function ln(e,t){var n=t==null?"":typeof t=="object"?`${t}`:t;n!==(e.__t??=e.nodeValue)&&(e.__t=n,e.nodeValue=`${n}`)}function Ti(e,t){return Ai(e,t)}function mo(e,t){Un(),t.intro=t.intro??!1;const n=t.target,i=j,s=C;try{for(var o=It(n);o&&(o.nodeType!==Qt||o.data!==wr);)o=Be(o);if(!o)throw jt;Qe(!0),Te(o);const a=Ai(e,{...t,anchor:o});return Qe(!1),a}catch(a){if(a instanceof Error&&a.message.split(`
|
|
2
|
+
`).some(l=>l.startsWith("https://svelte.dev/e/")))throw a;return a!==jt&&console.warn("Failed to hydrate: ",a),t.recover===!1&&Ts(),Un(),ii(n),Qe(!1),Ti(e,t)}finally{Qe(i),Te(s)}}const Mn=new Map;function Ai(e,{target:t,anchor:n,props:i={},events:s,context:o,intro:a=!0,transformError:l}){Un();var f=void 0,c=no(()=>{var h=n??t.appendChild(Ye());zs(h,{pending:()=>{}},m=>{Nr({});var d=Ae;if(o&&(d.c=o),s&&(i.$$events=s),j&&Ot(m,null),f=e(m,i)||{},j&&(N.nodes.end=C,C===null||C.nodeType!==Qt||C.data!==Pn))throw Sn(),jt;Rr()},l);var _=new Set,v=m=>{for(var d=0;d<m.length;d++){var y=m[d];if(!_.has(y)){_.add(y);var S=go(y);for(const z of[t,document]){var A=Mn.get(z);A===void 0&&(A=new Map,Mn.set(z,A));var $=A.get(y);$===void 0?(z.addEventListener(y,$i,{passive:S}),A.set(y,1)):A.set(y,$+1)}}}};return v(gn(xi)),nr.add(v),()=>{for(var m of _)for(const S of[t,document]){var d=Mn.get(S),y=d.get(m);--y==0?(S.removeEventListener(m,$i),d.delete(m),d.size===0&&Mn.delete(S)):d.set(m,y)}nr.delete(v),h!==n&&h.parentNode?.removeChild(h)}});return ir.set(f,c),f}let ir=new WeakMap;function wo(e,t){const n=ir.get(e);return n?(ir.delete(e),n(t)):Promise.resolve()}class yo{anchor;#e=new Map;#n=new Map;#t=new Map;#i=new Set;#s=!0;constructor(t,n=!0){this.anchor=t,this.#s=n}#r=t=>{if(this.#e.has(t)){var n=this.#e.get(t),i=this.#n.get(n);if(i)Qn(i),this.#i.delete(n);else{var s=this.#t.get(n);s&&(this.#n.set(n,s.effect),this.#t.delete(n),s.fragment.lastChild.remove(),this.anchor.before(s.fragment),i=s.effect)}for(const[o,a]of this.#e){if(this.#e.delete(o),o===t)break;const l=this.#t.get(a);l&&(_e(l.effect),this.#t.delete(a))}for(const[o,a]of this.#n){if(o===n||this.#i.has(o))continue;const l=()=>{if(Array.from(this.#e.values()).includes(o)){var c=document.createDocumentFragment();er(a,c),c.append(Ye()),this.#t.set(o,{effect:a,fragment:c})}else _e(a);this.#i.delete(o),this.#n.delete(o)};this.#s||!i?(this.#i.add(o),Dt(a,l,!1)):l()}}};#o=t=>{this.#e.delete(t);const n=Array.from(this.#e.values());for(const[i,s]of this.#t)n.includes(i)||(_e(s.effect),this.#t.delete(i))};ensure(t,n){var i=V,s=si();if(n&&!this.#n.has(t)&&!this.#t.has(t))if(s){var o=document.createDocumentFragment(),a=Ye();o.append(a),this.#t.set(t,{effect:Oe(()=>n(a)),fragment:o})}else this.#n.set(t,Oe(()=>n(this.anchor)));if(this.#e.set(i,t),s){for(const[l,f]of this.#n)l===t?i.unskip_effect(f):i.skip_effect(f);for(const[l,f]of this.#t)l===t?i.unskip_effect(f.effect):i.skip_effect(f.effect);i.oncommit(this.#r),i.ondiscard(this.#o)}else j&&(this.anchor=C),this.#r(i)}}function bo(e){Ae===null&&ws(),li(()=>{const t=tr(e);if(typeof t=="function")return t})}function We(e,t,n=!1){var i;j&&(i=C,$n());var s=new yo(e),o=n?zt:0;function a(l,f){if(j){var c=Mr(i);if(l!==parseInt(c.substring(1))){var h=En();Te(h),s.anchor=h,Qe(!1),s.ensure(l,f),Qe(!0);return}}s.ensure(l,f)}Kn(()=>{var l=!1;t((f,c=0)=>{l=!0,a(c,f)}),l||a(-1,null)},o)}function xo(e,t,n){for(var i=[],s=t.length,o,a=t.length,l=0;l<s;l++){let _=t[l];Dt(_,()=>{if(o){if(o.pending.delete(_),o.done.add(_),o.pending.size===0){var v=e.outrogroups;sr(e,gn(o.done)),v.delete(o),v.size===0&&(e.outrogroups=null)}}else a-=1},!1)}if(a===0){var f=i.length===0&&n!==null;if(f){var c=n,h=c.parentNode;ii(h),h.append(c),e.items.clear()}sr(e,t,!f)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function sr(e,t,n=!0){var i;if(e.pending.size>0){i=new Set;for(const a of e.pending.values())for(const l of a)i.add(e.items.get(l).e)}for(var s=0;s<t.length;s++){var o=t[s];if(i?.has(o)){o.f|=Ke;const a=document.createDocumentFragment();er(o,a)}else _e(t[s],n)}}var Ii;function Di(e,t,n,i,s,o=null){var a=e,l=new Map;j&&$n();var f=null,c=Ur(()=>{var A=n();return xr(A)?A:A==null?[]:gn(A)}),h,_=new Map,v=!0;function m(A){(S.effect.f&ke)===0&&(S.pending.delete(A),S.fallback=f,So(S,h,a,t,i),f!==null&&(h.length===0?(f.f&Ke)===0?Qn(f):(f.f^=Ke,fn(f,null,a)):Dt(f,()=>{f=null})))}function d(A){S.pending.delete(A)}var y=Kn(()=>{h=r(c);var A=h.length;let $=!1;if(j){var z=Mr(a)===Cn;z!==(A===0)&&(a=En(),Te(a),Qe(!1),$=!0)}for(var te=new Set,P=V,ne=si(),w=0;w<A;w+=1){j&&C.nodeType===Qt&&C.data===Pn&&(a=C,$=!0,Qe(!1));var J=h[w],ye=i(J,w),F=v?null:l.get(ye);F?(F.v&&Ut(F.v,J),F.i&&Ut(F.i,w),ne&&P.unskip_effect(F.e)):(F=$o(l,v?a:Ii??=Ye(),J,ye,w,s,t,n),v||(F.e.f|=Ke),l.set(ye,F)),te.add(ye)}if(A===0&&o&&!f&&(v?f=Oe(()=>o(a)):(f=Oe(()=>o(Ii??=Ye())),f.f|=Ke)),A>te.size&&bs(),j&&A>0&&Te(En()),!v)if(_.set(P,te),ne){for(const[be,Fe]of l)te.has(be)||P.skip_effect(Fe.e);P.oncommit(m),P.ondiscard(d)}else m(P);$&&Qe(!0),r(c)}),S={effect:y,items:l,pending:_,outrogroups:null,fallback:f};v=!1,j&&(a=C)}function an(e){for(;e!==null&&(e.f&qe)===0;)e=e.next;return e}function So(e,t,n,i,s){var o=t.length,a=e.items,l=an(e.effect.first),f,c=null,h=[],_=[],v,m,d,y;for(y=0;y<o;y+=1){if(v=t[y],m=s(v,y),d=a.get(m).e,e.outrogroups!==null)for(const J of e.outrogroups)J.pending.delete(d),J.done.delete(d);if((d.f&Ee)!==0&&Qn(d),(d.f&Ke)!==0)if(d.f^=Ke,d===l)fn(d,null,n);else{var S=c?c.next:l;d===e.effect.last&&(e.effect.last=d.prev),d.prev&&(d.prev.next=d.next),d.next&&(d.next.prev=d.prev),vt(e,c,d),vt(e,d,S),fn(d,S,n),c=d,h=[],_=[],l=an(c.next);continue}if(d!==l){if(f!==void 0&&f.has(d)){if(h.length<_.length){var A=_[0],$;c=A.prev;var z=h[0],te=h[h.length-1];for($=0;$<h.length;$+=1)fn(h[$],A,n);for($=0;$<_.length;$+=1)f.delete(_[$]);vt(e,z.prev,te.next),vt(e,c,z),vt(e,te,A),l=A,c=te,y-=1,h=[],_=[]}else f.delete(d),fn(d,l,n),vt(e,d.prev,d.next),vt(e,d,c===null?e.effect.first:c.next),vt(e,c,d),c=d;continue}for(h=[],_=[];l!==null&&l!==d;)(f??=new Set).add(l),_.push(l),l=an(l.next);if(l===null)continue}(d.f&Ke)===0&&h.push(d),c=d,l=an(d.next)}if(e.outrogroups!==null){for(const J of e.outrogroups)J.pending.size===0&&(sr(e,gn(J.done)),e.outrogroups?.delete(J));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||f!==void 0){var P=[];if(f!==void 0)for(d of f)(d.f&Ee)===0&&P.push(d);for(;l!==null;)(l.f&Ee)===0&&l!==e.fallback&&P.push(l),l=an(l.next);var ne=P.length;if(ne>0){var w=null;xo(e,P,w)}}}function $o(e,t,n,i,s,o,a,l){var f=(a&es)!==0?(a&ns)===0?Kr(n,!1,!1):At(n):null,c=(a&ts)!==0?At(s):null;return{v:f,i:c,e:Oe(()=>(o(t,f??n,c??s,l),()=>{e.delete(i)}))}}function fn(e,t,n){if(e.nodes)for(var i=e.nodes.start,s=e.nodes.end,o=t&&(t.f&Ke)===0?t.nodes.start:n;i!==null;){var a=Be(i);if(o.before(i),i===s)return;i=a}}function vt(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Eo(e,t){ro(()=>{var n=e.getRootNode(),i=n.host?n:n.head??n.ownerDocument.head;if(!i.querySelector("#"+t.hash)){const s=Jn("style");s.id=t.hash,s.textContent=t.code,i.appendChild(s)}})}function To(e,t){return e==null?null:String(e)}function Mi(e,t,n,i){var s=e.__style;if(j||s!==t){var o=To(t);(!j||o!==e.getAttribute("style"))&&(o==null?e.removeAttribute("style"):e.style.cssText=o),e.__style=t}return i}const Ao=Symbol("is custom element"),Io=Symbol("is html"),Do=ms?"link":"LINK";function T(e,t,n,i){var s=Mo(e);j&&(s[t]=e.getAttribute(t),t==="src"||t==="srcset"||t==="href"&&e.nodeName===Do)||s[t]!==(s[t]=n)&&(t==="loading"&&(e[gs]=n),n==null?e.removeAttribute(t):typeof n!="string"&&ko(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Mo(e){return e.__attributes??={[Ao]:e.nodeName.includes("-"),[Io]:e.namespaceURI===br}}var ki=new Map;function ko(e){var t=e.getAttribute("is")||e.nodeName,n=ki.get(t);if(n)return n;ki.set(t,n=[]);for(var i,s=e,o=Element.prototype;o!==s;){i=us(s);for(var a in i)i[a].set&&n.push(a);s=Sr(s)}return n}function ge(e,t,n,i){var s=(n&ss)!==0,o=(n&os)!==0,a=i,l=!0,f=()=>(l&&(l=!1,a=o?tr(i):i),a);let c;if(s){var h=bn in e||Dr in e;c=St(e,t)?.set??(h&&t in e?$=>e[t]=$:void 0)}var _,v=!1;s?[_,v]=Ls(()=>e[t]):_=e[t],_===void 0&&i!==void 0&&(_=f(),c&&(As(),c(_)));var m;if(m=()=>{var $=e[t];return $===void 0?f():(l=!0,$)},(n&is)===0)return m;if(c){var d=e.$$legacy;return(function($,z){return arguments.length>0?((!z||d||v)&&c(z?m():$),$):m()})}var y=!1,S=((n&rs)!==0?Hn:Ur)(()=>(y=!1,m()));s&&r(S);var A=N;return(function($,z){if(arguments.length>0){const te=z?r(S):s?dt($):$;return p(S,te),y=!0,a!==void 0&&(a=te),$}return pt&&y||(A.f&ke)!==0?S.v:r(S)})}function Oo(e){return new No(e)}class No{#e;#n;constructor(t){var n=new Map,i=(o,a)=>{var l=Kr(a,!1,!1);return n.set(o,l),l};const s=new Proxy({...t.props||{},$$events:{}},{get(o,a){return r(n.get(a)??i(a,Reflect.get(o,a)))},has(o,a){return a===Dr?!0:(r(n.get(a)??i(a,Reflect.get(o,a))),Reflect.has(o,a))},set(o,a,l){return p(n.get(a)??i(a,l),l),Reflect.set(o,a,l)}});this.#n=(t.hydrate?mo:Ti)(t.component,{target:t.target,anchor:t.anchor,props:s,context:t.context,intro:t.intro??!1,recover:t.recover,transformError:t.transformError}),(!t?.props?.$$host||t.sync===!1)&&de(),this.#e=s.$$events;for(const o of Object.keys(this.#n))o==="$set"||o==="$destroy"||o==="$on"||wn(this,o,{get(){return this.#n[o]},set(a){this.#n[o]=a},enumerable:!0});this.#n.$set=o=>{Object.assign(s,o)},this.#n.$destroy=()=>{wo(this.#n)}}$set(t){this.#n.$set(t)}$on(t,n){this.#e[t]=this.#e[t]||[];const i=(...s)=>n.call(this,...s);return this.#e[t].push(i),()=>{this.#e[t]=this.#e[t].filter(s=>s!==i)}}$destroy(){this.#n.$destroy()}}let Oi;typeof HTMLElement=="function"&&(Oi=class extends HTMLElement{$$ctor;$$s;$$c;$$cn=!1;$$d={};$$r=!1;$$p_d={};$$l={};$$l_u=new Map;$$me;$$shadowRoot=null;constructor(e,t,n){super(),this.$$ctor=e,this.$$s=t,n&&(this.$$shadowRoot=this.attachShadow(n))}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){const i=this.$$c.$on(e,t);this.$$l_u.set(t,i)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){const i=this.$$l_u.get(t);i&&(i(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(i){return s=>{const o=Jn("slot");i!=="default"&&(o.name=i),X(s,o)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;const t={},n=Ro(this);for(const i of this.$$s)i in n&&(i==="default"&&!this.$$d.children?(this.$$d.children=e(i),t.default=!0):t[i]=e(i));for(const i of this.attributes){const s=this.$$g_p(i.name);s in this.$$d||(this.$$d[s]=kn(s,i.value,this.$$p_d,"toProp"))}for(const i in this.$$p_d)!(i in this.$$d)&&this[i]!==void 0&&(this.$$d[i]=this[i],delete this[i]);this.$$c=Oo({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=to(()=>{fi(()=>{this.$$r=!0;for(const i of mn(this.$$c)){if(!this.$$p_d[i]?.reflect)continue;this.$$d[i]=this.$$c[i];const s=kn(i,this.$$d[i],this.$$p_d,"toAttribute");s==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,s)}this.$$r=!1})});for(const i in this.$$l)for(const s of this.$$l[i]){const o=this.$$c.$on(i,s);this.$$l_u.set(s,o)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=kn(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return mn(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function kn(e,t,n,i){const s=n[e]?.type;if(t=s==="Boolean"&&typeof t!="boolean"?t!=null:t,!i||!n[e])return t;if(i==="toAttribute")switch(s){case"Object":case"Array":return t==null?null:JSON.stringify(t);case"Boolean":return t?"":null;case"Number":return t??null;default:return t}else switch(s){case"Object":case"Array":return t&&JSON.parse(t);case"Boolean":return t;case"Number":return t!=null?+t:t;default:return t}}function Ro(e){const t={};return e.childNodes.forEach(n=>{t[n.slot||"default"]=!0}),t}function Co(e,t,n,i,s,o){let a=class extends Oi{constructor(){super(e,n,s),this.$$p_d=t}static get observedAttributes(){return mn(t).map(l=>(t[l].attribute||l).toLowerCase())}};return mn(t).forEach(l=>{wn(a.prototype,l,{get(){return this.$$c&&l in this.$$c?this.$$c[l]:this.$$d[l]},set(f){f=kn(l,f,t),this.$$d[l]=f;var c=this.$$c;if(c){var h=St(c,l)?.get;h?c[l]=f:c.$set({[l]:f})}}})}),i.forEach(l=>{wn(a.prototype,l,{get(){return this.$$c?.[l]}})}),e.element=a,a}const{PI:Po}=Math,un=Po+1e-4,Ni=.5,Ri=[1,1];function Ci(e,t,n,i=s=>s){return e*i(.5-t*(.5-n))}const{min:or}=Math;function Pi(e,t,n){let i=or(1,t/n);return or(1,e+(or(1,1-i)-e)*(i*.275))}function qo(e){return[-e[0],-e[1]]}function Ge(e,t){return[e[0]+t[0],e[1]+t[1]]}function qi(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function _t(e,t){return[e[0]-t[0],e[1]-t[1]]}function lr(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function gt(e,t){return[e[0]*t,e[1]*t]}function ar(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function Lo(e,t){return[e[0]/t,e[1]/t]}function Li(e){return[e[1],-e[0]]}function fr(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function Yi(e,t){return e[0]*t[0]+e[1]*t[1]}function Yo(e,t){return e[0]===t[0]&&e[1]===t[1]}function jo(e){return Math.hypot(e[0],e[1])}function ji(e,t){let n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}function Fi(e){return Lo(e,jo(e))}function Fo(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function ur(e,t,n){let i=Math.sin(n),s=Math.cos(n),o=e[0]-t[0],a=e[1]-t[1],l=o*s-a*i,f=o*i+a*s;return[l+t[0],f+t[1]]}function Xi(e,t,n,i){let s=Math.sin(i),o=Math.cos(i),a=t[0]-n[0],l=t[1]-n[1],f=a*o-l*s,c=a*s+l*o;return e[0]=f+n[0],e[1]=c+n[1],e}function zi(e,t,n){return Ge(e,gt(_t(t,e),n))}function Xo(e,t,n,i){let s=n[0]-t[0],o=n[1]-t[1];return e[0]=t[0]+s*i,e[1]=t[1]+o*i,e}function Hi(e,t,n){return Ge(e,gt(t,n))}const ae=[0,0],mt=[0,0],wt=[0,0];function zo(e,t){let n=Hi(e,Fi(Li(_t(e,Ge(e,[1,1])))),-t),i=[],s=1/13;for(let o=s;o<=1;o+=s)i.push(ur(n,e,un*2*o));return i}function Ho(e,t,n){let i=[],s=1/n;for(let o=s;o<=1;o+=s)i.push(ur(t,e,un*o));return i}function Bo(e,t,n){let i=_t(t,n),s=gt(i,.5),o=gt(i,.51);return[_t(e,s),_t(e,o),Ge(e,o),Ge(e,s)]}function Vo(e,t,n,i){let s=[],o=Hi(e,t,n),a=1/i;for(let l=a;l<1;l+=a)s.push(ur(o,e,un*3*l));return s}function Uo(e,t,n){return[Ge(e,gt(t,n)),Ge(e,gt(t,n*.99)),_t(e,gt(t,n*.99)),_t(e,gt(t,n))]}function Bi(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function Jo(e,t,n){return e.slice(0,10).reduce((i,s)=>{let o=s.pressure;return t&&(o=Pi(i,s.distance,n)),(i+o)/2},e[0].pressure)}function Wo(e,t={}){let{size:n=16,smoothing:i=.5,thinning:s=.5,simulatePressure:o=!0,easing:a=H=>H,start:l={},end:f={},last:c=!1}=t,{cap:h=!0,easing:_=H=>H*(2-H)}=l,{cap:v=!0,easing:m=H=>--H*H*H+1}=f;if(e.length===0||n<=0)return[];let d=e[e.length-1].runningLength,y=Bi(l.taper,n,d),S=Bi(f.taper,n,d),A=(n*i)**2,$=[],z=[],te=Jo(e,o,n),P=Ci(n,s,e[e.length-1].pressure,a),ne,w=e[0].vector,J=e[0].point,ye=J,F=J,be=ye,Fe=!1;for(let H=0;H<e.length;H++){let{pressure:b}=e[H],{point:me,vector:he,distance:Xe,runningLength:bt}=e[H],Pe=H===e.length-1;if(!Pe&&d-bt<3)continue;s?(o&&(b=Pi(te,Xe,n)),P=Ci(n,s,b,a)):P=n/2,ne===void 0&&(ne=P);let cn=bt<y?_(bt/y):1,dn=d-bt<S?m((d-bt)/S):1;P=Math.max(.01,P*Math.min(cn,dn));let xt=(Pe?e[H]:e[H+1]).vector,Wt=Pe?1:Yi(he,xt),On=Yi(he,w)<0&&!Fe,hn=Wt!==null&&Wt<0;if(On||hn){fr(ae,w),ar(ae,ae,P);for(let Rt=0;Rt<=1;Rt+=.07692307692307693)lr(mt,me,ae),Xi(mt,mt,me,un*Rt),F=[mt[0],mt[1]],$.push(F),qi(wt,me,ae),Xi(wt,wt,me,un*-Rt),be=[wt[0],wt[1]],z.push(be);J=F,ye=be,hn&&(Fe=!0);continue}if(Fe=!1,Pe){fr(ae,he),ar(ae,ae,P),$.push(_t(me,ae)),z.push(Ge(me,ae));continue}Xo(ae,xt,he,Wt),fr(ae,ae),ar(ae,ae,P),lr(mt,me,ae),F=[mt[0],mt[1]],(H<=1||ji(J,F)>A)&&($.push(F),J=F),qi(wt,me,ae),be=[wt[0],wt[1]],(H<=1||ji(ye,be)>A)&&(z.push(be),ye=be),te=b,w=he}let D=[e[0].point[0],e[0].point[1]],yt=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:Ge(e[0].point,[1,1]),Nt=[],De=[];if(e.length===1){if(!(y||S)||c)return zo(D,ne||P)}else{y||S&&e.length===1||(h?Nt.push(...Ho(D,z[0],13)):Nt.push(...Bo(D,$[0],z[0])));let H=Li(qo(e[e.length-1].vector));S||y&&e.length===1?De.push(yt):v?De.push(...Vo(yt,H,P,29)):De.push(...Uo(yt,H,P))}return $.concat(De,z.reverse(),Nt)}const Vi=[0,0];function Ui(e){return e!=null&&e>=0}function Go(e,t={}){let{streamline:n=.5,size:i=16,last:s=!1}=t;if(e.length===0)return[];let o=.15+(1-n)*.85,a=Array.isArray(e[0])?e:e.map(({x:v,y:m,pressure:d=Ni})=>[v,m,d]);if(a.length===2){let v=a[1];a=a.slice(0,-1);for(let m=1;m<5;m++)a.push(zi(a[0],v,m/4))}a.length===1&&(a=[...a,[...Ge(a[0],Ri),...a[0].slice(2)]]);let l=[{point:[a[0][0],a[0][1]],pressure:Ui(a[0][2])?a[0][2]:.25,vector:[...Ri],distance:0,runningLength:0}],f=!1,c=0,h=l[0],_=a.length-1;for(let v=1;v<a.length;v++){let m=s&&v===_?[a[v][0],a[v][1]]:zi(h.point,a[v],o);if(Yo(h.point,m))continue;let d=Fo(m,h.point);if(c+=d,v<_&&!f){if(c<i)continue;f=!0}lr(Vi,h.point,m),h={point:m,pressure:Ui(a[v][2])?a[v][2]:Ni,vector:Fi(Vi),distance:d,runningLength:c},l.push(h)}return l[0].vector=l[1]?.vector||[0,0],l}function Ji(e,t={}){return Wo(Go(e,t),t)}var Ko=le('<path stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></path>'),Zo=le('<image stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></image>'),Qo=le('<text stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"> </text>'),el=le('<path class="svelte-1qsqiex"></path>'),tl=le('<image class="svelte-1qsqiex"></image>'),nl=le('<text class="svelte-1qsqiex"> </text>'),rl=le('<path stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></path>'),il=le('<image stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></image>'),sl=le('<text stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"> </text>'),ol=le('<path class="svelte-1qsqiex"></path>'),ll=le('<image class="svelte-1qsqiex"></image>'),al=le('<text class="svelte-1qsqiex"> </text>'),fl=le('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),ul=le('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),cl=le('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),dl=le('<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>'),hl=le("<g><!><!></g>"),pl=po('<div id="debug" class="svelte-1qsqiex"> </div> <div id="container"><svg class="svelte-1qsqiex"><!></svg></div>',1);const vl={hash:"svelte-1qsqiex",code:'@import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");:host {font-family:"Roboto", sans-serif;}#debug.svelte-1qsqiex {position:absolute;width:100%;height:30px;top:0px;z-index:10;}svg.svelte-1qsqiex {position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none;}'};function Wi(e,t){Nr(t,!0),Eo(e,vl);function n(u,x){t.$$host.dispatchEvent(new CustomEvent(u,{detail:x}))}const i={size:6,thinning:.7,smoothing:.5,streamline:.5},s={paperSize:"A4"},o={zoom:{type:"fit",value:1},pan:{x:0,y:0},lockPan:!1,lockZoom:!1};let a=ge(t,"id",7,""),l=ge(t,"load_draw",7),f=ge(t,"draw_id",23,()=>Math.random().toString(36)+Math.random().toString(36)+Date.now().toString()),c=ge(t,"background_color",7,"rgb(255,255,255)"),h=ge(t,"pen_color",7,"rgb(0,0,0)"),_=ge(t,"insert_image",7,void 0),v=ge(t,"insert_text",7),m=ge(t,"pen_opacity",7,1),d=ge(t,"options",7,i),y=ge(t,"goto",7,void 0),S=ge(t,"mode",7,"draw"),A=ge(t,"debug",7,"no"),$=ge(t,"save_as",7,void 0),z=ge(t,"size",23,()=>Object.assign({},s)),te=ge(t,"view",23,()=>Object.assign({},o)),P,ne,w=I(0),J=I(!1),ye=I(0),F=I(void 0),be=I(void 0),Fe=I(""),D=I(dt({})),yt=I(0),Nt=I(void 0),De=I(void 0),H=I(void 0),b=I(dt([])),me=I(!1),he=I("idle"),Xe=I(void 0),bt=I(void 0),Pe=I(void 0),cn=I(void 0),dn=I(void 0),xt=I(!1),Wt=I(void 0),On=I(void 0),hn=I(void 0),Rt=I(void 0),Ct=I(0),Pt=I(0),qt=I(0),Lt=I(0),K=I(0),Z=I(0),W=I(0),G=I(0);function Gi(u){if(!u.length)return"";const x=u.reduce((E,[B,q],Y,g)=>{const[k,R]=g[(Y+1)%g.length];return E.push(B,q,(B+k)/2,(q+R)/2),E},["M",...u[0],"Q"]);return x.push("Z"),x.join(" ")}function _l(u){if(u)switch(u.type){case"json":const x=[];for(const E of r(b))if(E.visible){if(E.type==="stroke")E.actionIndex=0,x.push(E);else if(E.type==="multiplestroke")for(const B of E.multipath?.filter(q=>q.visible)||[])B.actionIndex=0,x.push(B)}return ml({type:"json",draw:x,id:a(),draw_id:f(),name:u.name,version:r(ye)+1,size:z()||s});default:return console.error("unknown save type")}}function gl(u){n("drawLoaded",u)}function ml(u){n("save",u)}function pn(u){n("historyIndex",u)}function wl(u){n("changeIndex",u)}function yl(u){n("selection",u)}function Ki(u){n("startStroke",u)}function bl(u){n("endStroke",u)}function xl(u){n("imageLoaded",u)}function Sl(u){n("txtLoaded",u)}function $l(){if(!r(F))return console.error("no svg dom found");if(!r(be))return console.error("no svg container found");p(D,r(F).getBoundingClientRect(),!0),P||(P={}),P.containerWidth=r(be).clientWidth,P.containerHeight=r(be).clientHeight,P.drawWidth=r(F).clientWidth,P.drawHeight=r(F).clientHeight,z()?.paperSize==="A3"?(P.paperWidth=297,P.paperHeight=420):(P.paperWidth=210,P.paperHeight=297)}function El(){if(console.log("svgDom",r(F)),r(D)||$l(),l()&&typeof l()=="object"&&(!r(ye)||r(ye)<l().version||f()!==l().draw_id)&&(console.log("load_draw",l()),p(b,l().draw,!0),p(w,r(b).length,!0),f(l().draw_id),p(ye,l().version,!0),l(void 0),ne=r(b).length,pn({index:r(w),draw_id:f(),id:a(),start_index:ne}),gl({index:r(w),draw_id:f(),id:a(),start_index:ne})),r(b)?.length&&$()&&(console.log("save_as",$()),_l($())),r(b)||(console.log("draw is empty"),p(b,[],!0)),S()&&S()!=="select"&&r(Xe)){p(Xe,0);const u=[...r(b)];u.forEach(x=>{x.selected=!1,x.type==="multiplestroke"&&x.multipath?.forEach(E=>{E.selected=!1})}),p(b,[...u],!0)}if(S()!=="select"&&(p(W,0),p(G,0),p(K,0),p(Z,0)),typeof y()=="string"&&y(Number(y())),r(b).length||(p(w,0),y(void 0)),r(w)||p(w,0),y()&&y()<0?p(w,-1):(y()||y()===0)&&(ne&&y()>ne?y(ne):y()>r(b).length&&y(r(b).length),p(w,y()+0),y(void 0),wl({index:r(w),draw_id:f(),id:a(),start_index:ne})),r(w)<0?(p(w,0),p(me,!0)):r(w)>=0&&p(me,!1),_()){console.info("inserting object");let u=!1;switch(_().type){case"jpg":case"jpeg":case"png":Tl(_()),u=!0;break;case"svg":Al(_()),u=!0;break;default:console.error("unknown insert_object type",_().type),u=!1}u&&xl({ok:!0,draw_id:f(),id:a()})}v()&&(console.log("insert_text",v()),Il(v()),Sl({ok:!0,draw_id:f(),id:a()})),p(bt,Ji(r(b)[r(w)]?.path||[],Object.assign({simulatePressure:r(Fe)!=="pen"},d())),!0),p(Pe,Gi(r(bt)),!0),console.log("set index to",r(w),"from goto",y(),"historyActions",r(b).length)}li(()=>{console.log("recompute");let u=!1;if(typeof z()=="string")try{z(JSON.parse(z())),u=!0}catch(x){console.error("error parsing size json",x)}if(typeof te()=="string")try{te(JSON.parse(te())),u=!0}catch(x){console.error("error parsing view json",x)}if(typeof l()=="string"&&l()?.length)try{l(JSON.parse(l())),u=!0}catch(x){console.error("error parsing json",x)}else l()||l(void 0);if(typeof $()=="string"&&$()?.length)try{$(JSON.parse($())),u=!0}catch(x){console.error("error parsing json",x)}if(A()!=="yes"&&A("no"),typeof m()=="string"&&m(Number(m())),typeof d()=="string"&&d()?.length)try{d(JSON.parse(d())),d()&&!d().size&&(d().size=i.size),d()&&!d().thinning&&(d().thinning=i.thinning),d()&&!d().smoothing&&(d().smoothing=i.smoothing),d()&&!d().streamline&&(d().streamline=i.streamline),u=!0}catch(x){console.error("error parsing json",x)}if(typeof _()=="string")try{_(JSON.parse(_())),u=!0}catch(x){console.error("error parsing insert_object json",x)}r(F)&&u&&El()});function Tl(u){const x=[...r(b)],E={id:Date.now().toString(),type:"image",actionIndex:r(w),visible:!0,pathData:u?.base64};x.push(E),p(b,[...x],!0),tn(w)}function Al(u){console.info(`inserting SVG ${u?.type}`)}function Il(u){console.info(`inserting Text ${u?.content}`)}function cr(u){const x=u.target?.id?.split("_")?.[1];if(x){let E=[...r(b)],B=E.find(q=>q.id===x&&q.visible);if(!B)for(const q of E.filter(Y=>Y.type==="multiplestroke").sort((Y,g)=>g.actionIndex-Y.actionIndex)){const Y=q?.multipath?.find(g=>g.id===x&&g.visible);if(Y){B=Y;break}}B&&(B.visible=!1,B.erasedAtIndex=r(w),console.info("erase stroke",B.id),E[E.length-1].type!=="eraser"?(E=E.slice(0,r(w)+1),E.push({type:"eraser",visible:!0,id:Math.random().toString(36)+Math.random().toString(36)+Date.now().toString(),actionIndex:r(b).length}),E.forEach((q,Y)=>{!q.visible&&q.erasedAtIndex&&q.erasedAtIndex>r(w)&&(q.visible=!0,q.erasedAtIndex=void 0)}),p(b,[...E],!0),tn(w),pn({index:r(w),draw_id:f(),id:a(),start_index:ne})):p(b,[...E],!0))}}function Dl(u){if(console.log("handlePointerDown"),p(Fe,u.pointerType,!0),p(yt,u.buttons,!0),S()==="draw"&&u.buttons===1&&!(u.pointerType==="pen"&&u.pressure===0)){if(p(he,"drawing"),r(w)!==r(b).length-1){const x=[...r(b)];x.forEach((E,B)=>{!E.visible&&E.erasedAtIndex&&E.erasedAtIndex>r(w)&&(E.visible=!0,E.erasedAtIndex=void 0)}),p(b,x,!0)}if(r(b)?.length&&r(w)<r(b).length)if(r(me))p(b,[],!0),p(me,!1);else{tn(w);const x=[...r(b)];p(b,x.slice(0,r(w)),!0)}pn({index:r(w),draw_id:f(),id:a(),start_index:ne}),console.log("setup stroke"),p(H,new Date,!0),p(De,Date.now().toString(),!0),p(Ct,u.pageX-r(D).left),p(Pt,u.pageY-r(D).top),p(qt,u.pageX-r(D).left),p(Lt,u.pageY-r(D).top),r(Nt)||(p(Nt,r(H),!0),Ki({start:r(Nt),id:a(),draw_id:f(),stroke_id:r(De),index:r(w)})),u.target.setPointerCapture(u.pointerId),r(b)?.length?(console.info("pushing draw"),p(b,[...r(b),{path:[[u.pageX-r(D).left,u.pageY-r(D).top,u.pressure]],color:h(),id:r(De),pathData:r(Pe),min:[r(Ct),r(Pt)],max:[r(qt),r(Lt)],visible:!0,actionIndex:r(b).length,opacity:m(),type:"stroke"}],!0)):p(b,[{path:[[u.pageX-r(D).left,u.pageY-r(D).top,u.pressure]],color:h(),id:r(De),pathData:r(Pe),min:[r(Ct),r(Pt)],max:[r(qt),r(Lt)],visible:!0,actionIndex:r(b).length,opacity:m(),type:"stroke"}],!0),Ki({start:r(H),stroke_id:r(De),index:r(w),id:a(),draw_id:f()})}else if(S()==="eraser"||S()==="draw"&&(u.pointerType==="pen"&&u.pressure===0&&u.buttons===1||u.buttons===32))u.target.setPointerCapture(u.pointerId),p(he,"erasing"),console.log("eraser down"),cr(u);else if(S()==="select"&&r(b).length){let x=!1;const E=u.pageX-r(D).left,B=u.pageY-r(D).top;if(x=E>r(K)&&E<r(W)&&B>r(Z)&&B<r(G),p(K,u.pageX-r(D).left),p(Z,u.pageY-r(D).top),p(W,u.pageX-r(D).left),p(G,u.pageY-r(D).top),!r(xt)&&!r(Xe)&&x){p(he,"idle"),p(Xe,Date.now(),!0),console.info("set move mode");const q=[...r(b)];p(cn,u.pageX-r(D).left),p(dn,u.pageY-r(D).top),q.filter(k=>k.selected).forEach(k=>{k.visible=!1,k.erasedAtIndex=r(w)}),q.filter(k=>k.type==="multiplestroke").forEach(k=>{k.multipath?.filter(R=>R.selected).forEach(R=>{R.visible=!1,R.erasedAtIndex=r(w)})});const Y=[];for(const k of q.filter(R=>R.type==="multiplestroke"))for(const R of k.multipath?.filter(M=>M.selected)||[])Y.push(JSON.parse(JSON.stringify(R))),R.visible=!1;const g=JSON.parse(JSON.stringify(r(b).filter(k=>k.selected))).concat(Y);g.forEach(k=>{k.visible=!0}),q.push({multipath:g,id:r(Xe).toString(),type:"multiplestroke",actionIndex:r(w),visible:!0,min:[r(K),r(Z)],max:[r(W),r(G)]}),r(b)[r(b).length-1].type==="multiplestroke"&&tn(w),p(b,[...q],!0),pn({index:r(w),draw_id:f(),id:a(),start_index:ne}),p(xt,!0),p(Wt,r(K),!0),p(On,r(Z),!0),p(hn,r(W),!0),p(Rt,r(G),!0)}else p(he,"selecting"),p(Xe,0)}}function Ml(u){if(p(Fe,u.pointerType,!0),p(yt,u.buttons+" "+[u.pageX-r(D).left,u.pageY-r(D).top,u.pressure].toString()),S()==="draw"&&r(he)==="drawing"&&u.buttons===1&&!(u.pointerType==="pen"&&u.pressure===0))r(b)[r(w)].path=[...r(b)[r(w)].path||[],[u.pageX-r(D).left,u.pageY-r(D).top,u.pressure]],r(b)[r(w)].pathData=r(Pe),u.pageX-r(D).left<r(Ct)&&p(Ct,u.pageX-r(D).left),u.pageY-r(D).top<r(Pt)&&p(Pt,u.pageY-r(D).top),u.pageX-r(D).left>r(qt)&&p(qt,u.pageX-r(D).left),u.pageY-r(D).top>r(Lt)&&p(Lt,u.pageY-r(D).top),r(b)[r(w)].min=[r(Ct),r(Pt)],r(b)[r(w)].max=[r(qt),r(Lt)];else if(r(he)==="erasing"&&(S()==="eraser"||S()==="draw"&&(u.pointerType==="pen"&&u.pressure===0&&u.buttons===1||u.buttons===32)))console.log("eraser move"),cr(u);else if(S()==="select"&&r(he)==="selecting")p(W,u.pageX-r(D).left),p(G,u.pageY-r(D).top);else if(S()==="select"&&!r(xt)){const x=u.pageX-r(D).left,E=u.pageY-r(D).top,B=x>r(K)&&x<r(W)&&E>r(Z)&&E<r(G);B&&!r(J)?(p(J,!0),console.log("on select",r(J))):!B&&r(J)&&(p(J,!1),console.log("off select",r(J)))}else if(r(xt)&&r(b)[r(w)].type==="multiplestroke"&&r(Xe)&&r(Xe).toString()===r(b)[r(w)].id){const x=[...r(b)],E=u.pageX-r(D).left,B=u.pageY-r(D).top,q=E-(r(cn)||0),Y=B-(r(dn)||0);console.info("move selected strokes on multistrokes",r(cn),r(dn),q,Y),x[r(w)]?.multipath?.forEach(g=>{let k;for(const M of r(b).filter(fe=>fe.type==="multiplestroke").filter(fe=>fe.id!==r(b)[r(w)].id).sort((fe,Yt)=>Yt.actionIndex-fe.actionIndex)){const fe=M?.multipath?.find(Yt=>Yt.id===g.id);if(fe){k=fe;break}}k||(k=r(b).find(M=>M.id===g.id)),g.path?.forEach((M,fe)=>{fe===0&&console.log("debug path ",M[0],k?.path?.[fe][0],r(b)),k?.path&&(M[0]=k.path[fe][0]+q),k?.path&&(M[1]=k.path[fe][1]+Y)}),k?.max&&(g.max=[k.max[0]+q,k.max[1]+Y]),k?.min&&(g.min=[k.min[0]+q,k.min[1]+Y]);const R=Ji(g.path||[],Object.assign({simulatePressure:r(Fe)!=="pen"},d()));g.pathData=Gi(R)}),p(K,(r(Wt)||0)+q),p(Z,(r(On)||0)+Y),p(W,(r(hn)||0)+q),p(G,(r(Rt)||0)+Y),p(b,[...x],!0)}}function kl(u){if(p(yt,u.buttons,!0),p(xt,!1),S()==="draw"&&r(he)==="drawing"){const x=new Date;if(!r(De)||!r(H)||!r(Pe))return console.error("no stroke id",r(De),r(H),r(Pe));bl({end:x,stroke_id:r(De),start:r(H),min:[r(Ct),r(Pt)],max:[r(qt),r(Lt)],pathData:r(Pe),pen_color:h(),index:r(w),id:a(),draw_id:f()}),tn(w),pn({index:r(w),draw_id:f(),id:a(),start_index:ne})}else if(S()==="eraser"||S()==="draw"&&r(he)!=="drawing"&&(u.pointerType==="pen"&&u.pressure===0&&u.buttons===1||u.buttons===32))console.log("eraser up"),cr(u);else if(S()==="select"){const x=[...r(b)];x.forEach(R=>{R.selected=!1,R.type==="multiplestroke"&&R.multipath?.forEach(M=>{M.selected=!1})}),p(b,[...x],!0),p(Xe,0);const E=r(K)<r(W)?r(K):r(W),B=r(Z)<r(G)?r(Z):r(G),q=r(K)>r(W)?r(K):r(W),Y=r(Z)>r(G)?r(Z):r(G),g=x.filter(R=>!!(R.visible&&R.type==="stroke"&&R.min&&R.max&&R.min[0]>E&&R.min[1]>B&&R.max[0]<q&&R.max[1]<Y));let k=!1;for(const R of x.filter(M=>M.type==="multiplestroke"))for(const M of R.multipath||[])M.visible&&M.type==="stroke"&&M.min&&M.max&&M.min[0]>E&&M.min[1]>B&&M.max[0]<q&&M.max[1]<Y&&(k=!0);if(g.length>0||k){for(const R of x.filter(M=>M.type==="multiplestroke"))for(const M of R?.multipath||[])M.visible&&M.min&&M.max&&M.min[0]>E&&M.min[1]>B&&M.max[0]<q&&M.max[1]<Y&&(M.selected=!0);for(const R of g)R.selected=!0;p(b,[...x],!0),console.log(g),yl({minX:r(K),minY:r(Z),maxX:r(W),maxY:r(G),strokes:g,id:a(),draw_id:f()})}else p(K,0),p(Z,0),p(W,0),p(G,0)}p(he,"idle"),u?.pointerId&&u.target?.releasePointerCapture?.(u.pointerId)}bo(()=>{p(F,t.$$host?.shadowRoot?.querySelector("svg"),!0),p(be,t.$$host?.shadowRoot?.querySelector("#container"),!0);let u=0;const x=setInterval(()=>{p(F,t.$$host?.shadowRoot?.querySelector("svg"),!0),r(F)?clearInterval(x):(u++,u>10?(clearInterval(x),console.warn("no canvas found on check "+u)):console.error("no canvas found on check "+u+" end"))},100);if(!r(F))return console.error("no canvas found on mount")});var Ol={get id(){return a()},set id(u=""){a(u),de()},get load_draw(){return l()},set load_draw(u){l(u),de()},get draw_id(){return f()},set draw_id(u=Math.random().toString(36)+Math.random().toString(36)+Date.now().toString()){f(u),de()},get background_color(){return c()},set background_color(u="rgb(255,255,255)"){c(u),de()},get pen_color(){return h()},set pen_color(u="rgb(0,0,0)"){h(u),de()},get insert_image(){return _()},set insert_image(u=void 0){_(u),de()},get insert_text(){return v()},set insert_text(u){v(u),de()},get pen_opacity(){return m()},set pen_opacity(u=1){m(u),de()},get options(){return d()},set options(u=i){d(u),de()},get goto(){return y()},set goto(u=void 0){y(u),de()},get mode(){return S()},set mode(u="draw"){S(u),de()},get debug(){return A()},set debug(u="no"){A(u),de()},get save_as(){return $()},set save_as(u=void 0){$(u),de()},get size(){return z()},set size(u=Object.assign({},s)){z(u),de()},get view(){return te()},set view(u=Object.assign({},o)){te(u),de()}},Zi=pl(),Nn=Ve(Zi),Nl=ht(Nn);at(Nn);var Qi=ri(Nn,2),Gt=ht(Qi),Rl=ht(Gt);{var Cl=u=>{var x=hl(),E=ht(x);Di(E,17,()=>r(b),Y=>Y.id,(Y,g,k,R)=>{var M=nt(),fe=Ve(M);{var Yt=pe=>{var U=nt(),Pl=Ve(U);{var ql=Kt=>{var vn=nt(),dr=Ve(vn);{var _n=xe=>{var Q=nt(),Zt=Ve(Q);{var pr=ze=>{var ve=Ko();oe(()=>{T(ve,"id","path_"+r(g).id),T(ve,"d",r(g).pathData),T(ve,"fill",r(g).color),T(ve,"fill-opacity",r(g).opacity)}),X(ze,ve)},vr=ze=>{var ve=Zo();oe(()=>{T(ve,"id","path_"+r(g).id),T(ve,"href",r(g).pathData)}),X(ze,ve)},_r=ze=>{var ve=Qo(),Se=ht(ve,!0);at(ve),oe(()=>{T(ve,"id","path_"+r(g).id),ln(Se,r(g).pathData)}),X(ze,ve)};We(Zt,ze=>{r(g).type==="stroke"?ze(pr):r(g).type==="image"?ze(vr,1):r(g).type==="text"&&ze(_r,2)})}X(xe,Q)},L=xe=>{var Q=el();oe(()=>{T(Q,"id","path_"+r(g).id),T(Q,"d",r(g).pathData),T(Q,"fill",r(g).color),T(Q,"fill-opacity",r(g).opacity)}),X(xe,Q)},Rn=xe=>{var Q=tl();oe(()=>{T(Q,"id","path_"+r(g).id),T(Q,"href",r(g).pathData)}),X(xe,Q)},hr=xe=>{var Q=nl(),Zt=ht(Q,!0);at(Q),oe(()=>{T(Q,"id","path_"+r(g).id),ln(Zt,r(g).pathData)}),X(xe,Q)};We(dr,xe=>{r(g).selected?xe(_n):!r(g).selected&&r(g).type==="stroke"?xe(L,1):!r(g).selected&&r(g).type==="image"?xe(Rn,2):!r(g).selected&&r(g).type==="text"&&xe(hr,3)})}X(Kt,vn)},Ll=Kt=>{var vn=nt(),dr=Ve(vn);Di(dr,17,()=>r(g).multipath,_n=>_n.id+r(g).id,(_n,L)=>{var Rn=nt(),hr=Ve(Rn);{var xe=Q=>{var Zt=nt(),pr=Ve(Zt);{var vr=Se=>{var ue=nt(),gr=Ve(ue);{var Yl=rt=>{var $e=rl();oe(()=>{T($e,"id","path_"+r(L).id+"_"+r(g).id),T($e,"d",r(L).pathData),T($e,"fill",r(L).color),T($e,"fill-opacity",r(L).opacity)}),X(rt,$e)},jl=rt=>{var $e=il();oe(()=>{T($e,"id","path_"+r(L).id+"_"+r(g).id),T($e,"href",r(L).pathData)}),X(rt,$e)},Fl=rt=>{var $e=sl(),Xl=ht($e,!0);at($e),oe(()=>{T($e,"id","path_"+r(L).id+"_"+r(g).id),ln(Xl,r(L).pathData)}),X(rt,$e)};We(gr,rt=>{r(L).type==="stroke"?rt(Yl):r(L).type==="image"?rt(jl,1):r(L).type==="text"&&rt(Fl,2)})}X(Se,ue)},_r=Se=>{var ue=ol();oe(()=>{T(ue,"id","path_"+r(L).id+"_"+r(g).id),T(ue,"d",r(L).pathData),T(ue,"fill",r(L).color),T(ue,"fill-opacity",r(L).opacity)}),X(Se,ue)},ze=Se=>{var ue=ll();oe(()=>{T(ue,"id","path_"+r(L).id+"_"+r(g).id),T(ue,"href",r(L).pathData)}),X(Se,ue)},ve=Se=>{var ue=al(),gr=ht(ue,!0);at(ue),oe(()=>{T(ue,"id","path_"+r(L).id+"_"+r(g).id),ln(gr,r(L).pathData)}),X(Se,ue)};We(pr,Se=>{r(L).selected?Se(vr):!r(L).selected&&r(L).type==="stroke"?Se(_r,1):!r(L).selected&&r(L).type==="image"?Se(ze,2):!r(L).selected&&r(L).type==="text"&&Se(ve,3)})}X(Q,Zt)};We(hr,Q=>{r(L).actionIndex<=r(w)&&!r(me)&&(r(L).visible||r(L).erasedAtIndex&&r(L).erasedAtIndex>r(w))&&Q(xe)})}X(_n,Rn)}),X(Kt,vn)};We(Pl,Kt=>{r(g).type==="stroke"||r(g).type==="image"||r(g).type==="text"?Kt(ql):r(g).type==="multiplestroke"&&r(g).multipath&&Kt(Ll,1)})}X(pe,U)};We(fe,pe=>{r(g).actionIndex<=r(w)&&!r(me)&&(r(g).visible||r(g).erasedAtIndex&&r(g).erasedAtIndex>r(w))&&pe(Yt)})}X(Y,M)});var B=ri(E);{var q=Y=>{var g=nt(),k=Ve(g);{var R=pe=>{var U=fl();oe(()=>{T(U,"x",r(K)),T(U,"y",r(Z)),T(U,"width",r(W)-r(K)),T(U,"height",r(G)-r(Z))}),X(pe,U)},M=pe=>{var U=ul();oe(()=>{T(U,"x",r(W)),T(U,"y",r(Z)),T(U,"width",r(K)-r(W)),T(U,"height",r(G)-r(Z))}),X(pe,U)},fe=pe=>{var U=cl();oe(()=>{T(U,"x",r(K)),T(U,"y",r(G)),T(U,"width",r(W)-r(K)),T(U,"height",r(Z)-r(G))}),X(pe,U)},Yt=pe=>{var U=dl();oe(()=>{T(U,"x",r(W)),T(U,"y",r(G)),T(U,"width",r(K)-r(W)),T(U,"height",r(Z)-r(G))}),X(pe,U)};We(k,pe=>{r(K)<=r(W)&&r(Z)<=r(G)?pe(R):r(K)>r(W)&&r(Z)<r(G)?pe(M,1):r(K)<r(W)&&r(Z)>r(G)?pe(fe,2):pe(Yt,-1)})}X(Y,g)};We(B,Y=>{S()==="select"&&Y(q)})}at(x),X(u,x)};We(Rl,u=>{r(F)&&u(Cl)})}return at(Gt),at(Qi),oe(()=>{Mi(Nn,`display:${A()==="yes"?"block":"none"}`),ln(Nl,`${r(Fe)??""} b: ${r(yt)??""}`),Mi(Gt,`background-color:${c()??""};cursor:${r(J)===!0?"move":"default"}`)}),rr("pointerdown",Gt,Dl),rr("pointermove",Gt,Ml),rr("pointerup",Gt,kl),X(e,Zi),Rr(Ol)}uo(["pointerdown","pointermove","pointerup"]),customElements.define("hb-stylus-paper",Co(Wi,{id:{},load_draw:{},draw_id:{},background_color:{},pen_color:{},insert_image:{},insert_text:{},pen_opacity:{},options:{},goto:{},mode:{},debug:{},save_as:{},size:{},view:{}},[],[],{mode:"open"})),mr.Component=Wi,Object.defineProperty(mr,Symbol.toStringTag,{value:"Module"})})(this["stylus-paper"]=this["stylus-paper"]||{});
|
|
3
3
|
//# sourceMappingURL=main.iife.js.map
|