@htmlbricks/hb-stylus-paper 0.66.6 → 0.66.7

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 CHANGED
@@ -1,3 +1,3 @@
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&lt)===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&lt)!==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&lt)!==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&lt)!==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
- //# sourceMappingURL=main.iife.js.map
1
+ (function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var t={},n=Symbol(),r=`http://www.w3.org/1999/xhtml`,i=Array.isArray,a=Array.prototype.indexOf,o=Array.prototype.includes,s=Array.from,c=Object.keys,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyDescriptors,f=Object.prototype,p=Array.prototype,m=Object.getPrototypeOf,h=Object.isExtensible,g=()=>{};function _(e){for(var t=0;t<e.length;t++)e[t]()}function v(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var y=1024,b=2048,x=4096,S=8192,C=16384,w=32768,ee=1<<25,T=65536,E=1<<19,te=1<<20,D=1<<25,ne=65536,re=1<<21,O=1<<22,ie=1<<23,k=Symbol(`$state`),ae=Symbol(`legacy props`),oe=Symbol(``),A=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},se=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`);function ce(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function le(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function ue(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function de(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function fe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function pe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function me(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function he(){throw Error(`https://svelte.dev/e/hydration_failed`)}function ge(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function _e(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ve(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function ye(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function j(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}function M(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function N(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var P=!1;function be(e){P=e}var F;function I(e){if(e===null)throw M(),t;return F=e}function xe(){return I(Kt(F))}function Se(e){if(P){if(Kt(F)!==null)throw M(),t;F=e}}function Ce(e=1){if(P){for(var t=e,n=F;t--;)n=Kt(n);F=n}}function we(e=!0){for(var t=0,n=F;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else (r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Kt(n);e&&n.remove(),n=i}}function Te(e){if(!e||e.nodeType!==8)throw M(),t;return e.data}function Ee(e){return e===this.v}function De(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Oe(e){return!De(e,this.v)}var ke=!1,Ae=!1,L=null;function je(e){L=e}function Me(e,t=!1,n){L={p:L,i:!1,c:null,e:null,s:e,x:null,r:q,l:Ae&&!t?{s:null,u:null,$:[]}:null}}function Ne(e){var t=L,n=t.e;if(n!==null){t.e=null;for(var r of n)cn(r)}return e!==void 0&&(t.x=e),t.i=!0,L=t.p,e??{}}function Pe(){return!Ae||L!==null&&L.l===null}var Fe=[];function Ie(){var e=Fe;Fe=[],_(e)}function Le(e){if(Fe.length===0&&!Xe){var t=Fe;queueMicrotask(()=>{t===Fe&&Ie()})}Fe.push(e)}function Re(){for(;Fe.length>0;)Ie()}function ze(e){var t=q;if(t===null)return K.f|=ie,e;if(!(t.f&32768)&&!(t.f&4))throw e;Be(e,t)}function Be(e,t){for(;t!==null;){if(t.f&128){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}var Ve=~(b|x|y);function R(e,t){e.f=e.f&Ve|t}function He(e){e.f&512||e.deps===null?R(e,y):R(e,x)}function Ue(e){if(e!==null)for(let t of e)!(t.f&2)||!(t.f&65536)||(t.f^=ne,Ue(t.deps))}function We(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),Ue(e.deps),R(e,y)}var Ge=!1,Ke=!1;function qe(e){var t=Ke;try{return Ke=!1,[e(),Ke]}finally{Ke=t}}var Je=new Set,z=null,B=null,Ye=null,Xe=!1,Ze=!1,Qe=null,$e=null,et=0,tt=1,nt=class e{id=tt++;current=new Map;previous=new Map;#e=new Set;#t=new Set;#n=new Map;#r=new Map;#i=null;#a=[];#o=new Set;#s=new Set;#c=new Map;is_fork=!1;#l=!1;#u=new Set;#d(){return this.is_fork||this.#r.size>0}#f(){for(let n of this.#u)for(let r of n.#r.keys()){for(var e=!1,t=r;t.parent!==null;){if(this.#c.has(t)){e=!0;break}t=t.parent}if(!e)return!0}return!1}skip_effect(e){this.#c.has(e)||this.#c.set(e,{d:[],m:[]})}unskip_effect(e){var t=this.#c.get(e);if(t){this.#c.delete(e);for(var n of t.d)R(n,b),this.schedule(n);for(n of t.m)R(n,x),this.schedule(n)}}#p(){if(et++>1e3&&(Je.delete(this),rt()),!this.#d()){for(let e of this.#o)this.#s.delete(e),R(e,b),this.schedule(e);for(let e of this.#s)R(e,x),this.schedule(e)}let t=this.#a;this.#a=[],this.apply();var n=Qe=[],r=[],i=$e=[];for(let e of t)try{this.#m(e,n,r)}catch(t){throw ut(e),t}if(z=null,i.length>0){var a=e.ensure();for(let e of i)a.schedule(e)}if(Qe=null,$e=null,this.#d()||this.#f()){this.#h(r),this.#h(n);for(let[e,t]of this.#c)lt(e,t)}else{this.#n.size===0&&Je.delete(this),this.#o.clear(),this.#s.clear();for(let e of this.#e)e(this);this.#e.clear(),at(r),at(n),this.#i?.resolve()}var o=z;if(this.#a.length>0){let e=o??=this;e.#a.push(...this.#a.filter(t=>!e.#a.includes(t)))}o!==null&&(Je.add(o),o.#p()),Je.has(this)||this.#g()}#m(e,t,n){e.f^=y;for(var r=e.first;r!==null;){var i=r.f,a=(i&96)!=0;if(!(a&&i&1024||i&8192||this.#c.has(r))&&r.fn!==null){a?r.f^=y:i&4?t.push(r):ke&&i&16777224?n.push(r):Wn(r)&&(i&16&&this.#s.add(r),Yn(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#h(e){for(var t=0;t<e.length;t+=1)We(e[t],this.#o,this.#s)}capture(e,t,r=!1){t!==n&&!this.previous.has(e)&&this.previous.set(e,t),e.f&8388608||(this.current.set(e,[e.v,r]),B?.set(e,e.v))}activate(){z=this}deactivate(){z=null,B=null}flush(){try{Ze=!0,z=this,this.#p()}finally{et=0,Ye=null,Qe=null,$e=null,Ze=!1,z=null,B=null,kt.clear()}}discard(){for(let e of this.#t)e(this);this.#t.clear(),Je.delete(this)}#g(){for(let c of Je){var e=c.id<this.id,t=[];for(let[r,[i,a]]of this.current){if(c.current.has(r)){var n=c.current.get(r)[0];if(e&&i!==n)c.current.set(r,[i,a]);else continue}t.push(r)}var r=[...c.current.keys()].filter(e=>!this.current.has(e));if(r.length===0)e&&c.discard();else if(t.length>0){c.activate();var i=new Set,a=new Map;for(var o of t)ot(o,r,i,a);if(c.#a.length>0){c.apply();for(var s of c.#a)c.#m(s,[],[]);c.#a=[]}c.deactivate()}}for(let e of Je)e.#u.has(this)&&(e.#u.delete(this),e.#u.size===0&&!e.#d()&&(e.activate(),e.#p()))}increment(e,t){let n=this.#n.get(t)??0;if(this.#n.set(t,n+1),e){let e=this.#r.get(t)??0;this.#r.set(t,e+1)}}decrement(e,t,n){let r=this.#n.get(t)??0;if(r===1?this.#n.delete(t):this.#n.set(t,r-1),e){let e=this.#r.get(t)??0;e===1?this.#r.delete(t):this.#r.set(t,e-1)}this.#l||n||(this.#l=!0,Le(()=>{this.#l=!1,this.flush()}))}transfer_effects(e,t){for(let t of e)this.#o.add(t);for(let e of t)this.#s.add(e);e.clear(),t.clear()}oncommit(e){this.#e.add(e)}ondiscard(e){this.#t.add(e)}settled(){return(this.#i??=v()).promise}static ensure(){if(z===null){let t=z=new e;Ze||(Je.add(z),Xe||Le(()=>{z===t&&t.flush()}))}return z}apply(){if(!ke||!this.is_fork&&Je.size===1){B=null;return}B=new Map;for(let[e,[t]]of this.current)B.set(e,t);for(let n of Je)if(!(n===this||n.is_fork)){var e=!1,t=!1;if(n.id<this.id)for(let[r,[,i]]of n.current)i||(e||=this.current.has(r),t||=!this.current.has(r));if(e&&t)this.#u.add(n);else for(let[e,t]of n.previous)B.has(e)||B.set(e,t)}}schedule(e){if(Ye=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Qe!==null&&t===q&&(ke||(K===null||!(K.f&2))&&!Ge))return;if(n&96){if(!(n&1024))return;t.f^=y}}this.#a.push(t)}};function V(e){var t=Xe;Xe=!0;try{var n;for(e&&(z!==null&&!z.is_fork&&z.flush(),n=e());;){if(Re(),z===null)return n;z.flush()}}finally{Xe=t}}function rt(){try{me()}catch(e){Be(e,Ye)}}var it=null;function at(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Wn(r)&&(it=new Set,Yn(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&bn(r),it?.size>0)){kt.clear();for(let e of it){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)it.has(n)&&(it.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||Yn(n)}}it.clear()}}it=null}}function ot(e,t,n,r){if(!n.has(e)&&(n.add(e),e.reactions!==null))for(let i of e.reactions){let e=i.f;e&2?ot(i,t,n,r):e&4194320&&!(e&2048)&&st(i,t,r)&&(R(i,b),ct(i))}}function st(e,t,n){let r=n.get(e);if(r!==void 0)return r;if(e.deps!==null)for(let r of e.deps){if(o.call(t,r))return!0;if(r.f&2&&st(r,t,n))return n.set(r,!0),!0}return n.set(e,!1),!1}function ct(e){z.schedule(e)}function lt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),R(e,y);for(var n=e.first;n!==null;)lt(n,t),n=n.next}}function ut(e){R(e,y);for(var t=e.first;t!==null;)ut(t),t=t.next}function dt(e){let t=0,n=jt(0),r;return()=>{an()&&(J(n),pn(()=>(t===0&&(r=Qn(()=>e(()=>It(n)))),t+=1,()=>{Le(()=>{--t,t===0&&(r?.(),r=void 0,It(n))})})))}}var ft=T|E;function pt(e,t,n,r){new mt(e,t,n,r)}var mt=class{parent;is_pending=!1;transform_error;#e;#t=P?F:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=dt(()=>(this.#m=jt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=q;t.b=this,t.f|=128,n(e)},this.parent=q.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=mn(()=>{if(P){let e=this.#t;xe();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#v():this.#g()}else this.#y()},ft),P&&(this.#e=F)}#g(){try{this.#a=hn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed;t&&(this.#s=hn(()=>{t(this.#e,()=>e,()=>()=>{})}))}#v(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=hn(()=>e(this.#e)),Le(()=>{var e=this.#c=document.createDocumentFragment(),t=Wt();e.append(t),this.#a=this.#x(()=>hn(()=>this.#r(t))),this.#u===0&&(this.#e.before(e),this.#c=null,xn(this.#o,()=>{this.#o=null}),this.#b(z))}))}#y(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=hn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Tn(this.#a,e);let t=this.#n.pending;this.#o=hn(()=>t(this.#e))}else this.#b(z)}catch(e){this.error(e)}}#b(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){We(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#x(e){var t=q,n=K,r=L;Mn(this.#i),jn(this.#i),je(this.#i.ctx);try{return nt.ensure(),e()}catch(e){return ze(e),null}finally{Mn(t),jn(n),je(r)}}#S(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#S(e,t);return}this.#u+=e,this.#u===0&&(this.#b(t),this.#o&&xn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#S(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Le(()=>{this.#d=!1,this.#m&&Nt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),J(this.#m)}error(e){var t=this.#n.onerror;let n=this.#n.failed;if(!t&&!n)throw e;this.#a&&=(G(this.#a),null),this.#o&&=(G(this.#o),null),this.#s&&=(G(this.#s),null),P&&(I(this.#t),Ce(),I(we()));var r=!1,i=!1;let a=()=>{if(r){N();return}r=!0,i&&j(),this.#s!==null&&xn(this.#s,()=>{this.#s=null}),this.#x(()=>{this.#y()})},o=e=>{try{i=!0,t?.(e,a),i=!1}catch(e){Be(e,this.#i&&this.#i.parent)}n&&(this.#s=this.#x(()=>{try{return hn(()=>{var t=q;t.b=this,t.f|=128,n(this.#e,()=>e,()=>a)})}catch(e){return Be(e,this.#i.parent),null}}))};Le(()=>{var t;try{t=this.transform_error(e)}catch(e){Be(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(o,e=>Be(e,this.#i&&this.#i.parent)):o(t)})}};function ht(e,t,n,r){let i=Pe()?yt:xt;var a=e.filter(e=>!e.settled);if(n.length===0&&a.length===0){r(t.map(i));return}var o=q,s=gt(),c=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function l(e){s();try{r(e)}catch(e){o.f&16384||Be(e,o)}_t()}if(n.length===0){c.then(()=>l(t.map(i)));return}var u=vt();function d(){Promise.all(n.map(e=>bt(e))).then(e=>l([...t.map(i),...e])).catch(e=>Be(e,o)).finally(()=>u())}c?c.then(()=>{s(),d(),_t()}):d()}function gt(){var e=q,t=K,n=L,r=z;return function(i=!0){Mn(e),jn(t),je(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function _t(e=!0){Mn(null),jn(null),je(null),e&&z?.deactivate()}function vt(){var e=q,t=e.b,n=z,r=t.is_rendered();return t.update_pending_count(1,n),n.increment(r,e),(i=!1)=>{t.update_pending_count(-1,n),n.decrement(r,e,i)}}function yt(e){var t=2|b,r=K!==null&&K.f&2?K:null;return q!==null&&(q.f|=E),{ctx:L,deps:null,effects:null,equals:Ee,f:t,fn:e,reactions:null,rv:0,v:n,wv:0,parent:r??q,ac:null}}function bt(e,t,r){let i=q;i===null&&le();var a=void 0,o=jt(n),s=!K,c=new Map;return fn(()=>{var t=q,n=v();a=n.promise;try{Promise.resolve(e()).then(n.resolve,n.reject).finally(_t)}catch(e){n.reject(e),_t()}var r=z;if(s){if(t.f&32768)var l=vt();if(i.b.is_rendered())c.get(r)?.reject(A),c.delete(r);else{for(let e of c.values())e.reject(A);c.clear()}c.set(r,n)}let u=(e,n=void 0)=>{if(l&&l(n===A),!(n===A||t.f&16384)){if(r.activate(),n)o.f|=ie,Nt(o,n);else{o.f&8388608&&(o.f^=ie),Nt(o,e);for(let[e,t]of c){if(c.delete(e),e===r)break;t.reject(A)}}r.deactivate()}};n.promise.then(u,e=>u(null,e||`unknown`))}),on(()=>{for(let e of c.values())e.reject(A)}),new Promise(e=>{function t(n){function r(){n===a?e(o):t(a)}n.then(r,r)}t(a)})}function xt(e){let t=yt(e);return t.equals=Oe,t}function St(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)G(t[n])}}function Ct(e){for(var t=e.parent;t!==null;){if(!(t.f&2))return t.f&16384?null:t;t=t.parent}return null}function wt(e){var t,n=q;Mn(Ct(e));try{e.f&=~ne,St(e),t=Kn(e)}finally{Mn(n)}return t}function Tt(e){var t=e.v,n=wt(e);if(!e.equals(n)&&(e.wv=Un(),(!z?.is_fork||e.deps===null)&&(e.v=n,z?.capture(e,t,!0),e.deps===null))){R(e,y);return}On||(B===null?He(e):(an()||z?.is_fork)&&B.set(e,n))}function Et(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac?.abort(A),t.teardown=g,t.ac=null,Jn(t,0),_n(t))}function Dt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&Yn(t)}var Ot=new Set,kt=new Map,At=!1;function jt(e,t){return{f:0,v:e,reactions:null,equals:Ee,rv:0,wv:0}}function H(e,t){let n=jt(e,t);return Pn(n),n}function Mt(e,t=!1,n=!0){let r=jt(e);return t||(r.equals=Oe),Ae&&n&&L!==null&&L.l!==null&&(L.l.s??=[]).push(r),r}function U(e,t,n=!1){return K!==null&&(!An||K.f&131072)&&Pe()&&K.f&4325394&&(Nn===null||!o.call(Nn,e))&&ye(),Nt(e,n?Rt(t):t,$e)}function Nt(e,t,n=null){if(!e.equals(t)){var r=e.v;On?kt.set(e,t):kt.set(e,r),e.v=t;var i=nt.ensure();if(i.capture(e,r),e.f&2){let t=e;e.f&2048&&wt(t),B===null&&He(t)}e.wv=Un(),Lt(e,b,n),Pe()&&q!==null&&q.f&1024&&!(q.f&96)&&(Ln===null?Rn([e]):Ln.push(e)),!i.is_fork&&Ot.size>0&&!At&&Pt()}return t}function Pt(){At=!1;for(let e of Ot)e.f&1024&&R(e,x),Wn(e)&&Yn(e);Ot.clear()}function Ft(e,t=1){var n=J(e),r=t===1?n++:n--;return U(e,n),r}function It(e){U(e,e.v+1)}function Lt(e,t,n){var r=e.reactions;if(r!==null)for(var i=Pe(),a=r.length,o=0;o<a;o++){var s=r[o],c=s.f;if(!(!i&&s===q)){var l=(c&b)===0;if(l&&R(s,t),c&2){var u=s;B?.delete(u),c&65536||(c&512&&(s.f|=ne),Lt(u,x,n))}else if(l){var d=s;c&16&&it!==null&&it.add(d),n===null?ct(d):n.push(d)}}}}function Rt(e){if(typeof e!=`object`||!e||k in e)return e;let t=m(e);if(t!==f&&t!==p)return e;var r=new Map,a=i(e),o=H(0),s=null,c=Vn,l=e=>{if(Vn===c)return e();var t=K,n=Vn;jn(null),Hn(c);var r=e();return jn(t),Hn(n),r};return a&&r.set(`length`,H(e.length,s)),new Proxy(e,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&_e();var i=r.get(t);return i===void 0?l(()=>{var e=H(n.value,s);return r.set(t,e),e}):U(i,n.value,!0),!0},deleteProperty(e,t){var i=r.get(t);if(i===void 0){if(t in e){let e=l(()=>H(n,s));r.set(t,e),It(o)}}else U(i,n),It(o);return!0},get(t,i,a){if(i===k)return e;var o=r.get(i),c=i in t;if(o===void 0&&(!c||u(t,i)?.writable)&&(o=l(()=>H(Rt(c?t[i]:n),s)),r.set(i,o)),o!==void 0){var d=J(o);return d===n?void 0:d}return Reflect.get(t,i,a)},getOwnPropertyDescriptor(e,t){var i=Reflect.getOwnPropertyDescriptor(e,t);if(i&&`value`in i){var a=r.get(t);a&&(i.value=J(a))}else if(i===void 0){var o=r.get(t),s=o?.v;if(o!==void 0&&s!==n)return{enumerable:!0,configurable:!0,value:s,writable:!0}}return i},has(e,t){if(t===k)return!0;var i=r.get(t),a=i!==void 0&&i.v!==n||Reflect.has(e,t);return(i!==void 0||q!==null&&(!a||u(e,t)?.writable))&&(i===void 0&&(i=l(()=>H(a?Rt(e[t]):n,s)),r.set(t,i)),J(i)===n)?!1:a},set(e,t,i,c){var d=r.get(t),f=t in e;if(a&&t===`length`)for(var p=i;p<d.v;p+=1){var m=r.get(p+``);m===void 0?p in e&&(m=l(()=>H(n,s)),r.set(p+``,m)):U(m,n)}if(d===void 0)(!f||u(e,t)?.writable)&&(d=l(()=>H(void 0,s)),U(d,Rt(i)),r.set(t,d));else{f=d.v!==n;var h=l(()=>Rt(i));U(d,h)}var g=Reflect.getOwnPropertyDescriptor(e,t);if(g?.set&&g.set.call(c,i),!f){if(a&&typeof t==`string`){var _=r.get(`length`),v=Number(t);Number.isInteger(v)&&v>=_.v&&U(_,v+1)}It(o)}return!0},ownKeys(e){J(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==n});for(var[i,a]of r)a.v!==n&&!(i in e)&&t.push(i);return t},setPrototypeOf(){ve()}})}var zt,Bt,Vt,Ht;function Ut(){if(zt===void 0){zt=window,Bt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Vt=u(t,`firstChild`).get,Ht=u(t,`nextSibling`).get,h(e)&&(e.__click=void 0,e.__className=void 0,e.__attributes=null,e.__style=void 0,e.__e=void 0),h(n)&&(n.__t=void 0)}}function Wt(e=``){return document.createTextNode(e)}function Gt(e){return Vt.call(e)}function Kt(e){return Ht.call(e)}function qt(e,t){if(!P)return Gt(e);var n=Gt(F);if(n===null)n=F.appendChild(Wt());else if(t&&n.nodeType!==3){var r=Wt();return n?.before(r),I(r),r}return t&&$t(n),I(n),n}function Jt(e,t=!1){if(!P){var n=Gt(e);return n instanceof Comment&&n.data===``?Kt(n):n}if(t){if(F?.nodeType!==3){var r=Wt();return F?.before(r),I(r),r}$t(F)}return F}function Yt(e,t=1,n=!1){let r=P?F:e;for(var i;t--;)i=r,r=Kt(r);if(!P)return r;if(n){if(r?.nodeType!==3){var a=Wt();return r===null?i?.after(a):r.before(a),I(a),a}$t(r)}return I(r),r}function Xt(e){e.textContent=``}function Zt(){return!ke||it!==null?!1:(q.f&w)!==0}function Qt(e,t,n){let r=n?{is:n}:void 0;return document.createElementNS(t??`http://www.w3.org/1999/xhtml`,e,r)}function $t(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function en(e){var t=K,n=q;jn(null),Mn(null);try{return e()}finally{jn(t),Mn(n)}}function tn(e){q===null&&(K===null&&pe(e),fe()),On&&de(e)}function nn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function rn(e,t){var n=q;n!==null&&n.f&8192&&(e|=S);var r={ctx:L,deps:null,nodes:null,f:e|b|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null},i=r;if(e&4)Qe===null?nt.ensure().schedule(r):Qe.push(r);else if(t!==null){try{Yn(r)}catch(e){throw G(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&nn(i,n),K!==null&&K.f&2&&!(e&64))){var a=K;(a.effects??=[]).push(i)}return r}function an(){return K!==null&&!An}function on(e){let t=rn(8,null);return R(t,y),t.teardown=e,t}function sn(e){tn(`$effect`);var t=q.f;if(!K&&t&32&&!(t&32768)){var n=L;(n.e??=[]).push(e)}else return cn(e)}function cn(e){return rn(4|te,e)}function ln(e){nt.ensure();let t=rn(64|E,e);return()=>{G(t)}}function un(e){nt.ensure();let t=rn(64|E,e);return(e={})=>new Promise(n=>{e.outro?xn(t,()=>{G(t),n(void 0)}):(G(t),n(void 0))})}function dn(e){return rn(4,e)}function fn(e){return rn(O|E,e)}function pn(e,t=0){return rn(8|t,e)}function W(e,t=[],n=[],r=[]){ht(r,t,n,t=>{rn(8,()=>e(...t.map(J)))})}function mn(e,t=0){return rn(16|t,e)}function hn(e){return rn(32|E,e)}function gn(e){var t=e.teardown;if(t!==null){let e=On,n=K;kn(!0),jn(null);try{t.call(null)}finally{kn(e),jn(n)}}}function _n(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&en(()=>{e.abort(A)});var r=n.next;n.f&64?n.parent=null:G(n,t),n=r}}function vn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||G(t),t=n}}function G(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(yn(e.nodes.start,e.nodes.end),n=!0),R(e,ee),_n(e,t&&!n),Jn(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();gn(e),e.f^=ee,e.f|=C;var i=e.parent;i!==null&&i.first!==null&&bn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function yn(e,t){for(;e!==null;){var n=e===t?null:Kt(e);e.remove(),e=n}}function bn(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 xn(e,t,n=!0){var r=[];Sn(e,r,!0);var i=()=>{n&&G(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Sn(e,t,n){if(!(e.f&8192)){e.f^=S;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next,o=(i.f&65536)!=0||(i.f&32)!=0&&(e.f&16)!=0;Sn(i,t,o?n:!1),i=a}}}function Cn(e){wn(e,!0)}function wn(e,t){if(e.f&8192){e.f^=S,e.f&1024||(R(e,b),nt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=(n.f&65536)!=0||(n.f&32)!=0;wn(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Tn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Kt(n);t.append(n),n=i}}var En=null,Dn=!1,On=!1;function kn(e){On=e}var K=null,An=!1;function jn(e){K=e}var q=null;function Mn(e){q=e}var Nn=null;function Pn(e){K!==null&&(!ke||K.f&2)&&(Nn===null?Nn=[e]:Nn.push(e))}var Fn=null,In=0,Ln=null;function Rn(e){Ln=e}var zn=1,Bn=0,Vn=Bn;function Hn(e){Vn=e}function Un(){return++zn}function Wn(e){var t=e.f;if(t&2048)return!0;if(t&2&&(e.f&=~ne),t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Wn(a)&&Tt(a),a.wv>e.wv)return!0}t&512&&B===null&&R(e,y)}return!1}function Gn(e,t,n=!0){var r=e.reactions;if(r!==null&&!(!ke&&Nn!==null&&o.call(Nn,e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Gn(a,t,!1):t===a&&(n?R(a,b):a.f&1024&&R(a,x),ct(a))}}function Kn(e){var t=Fn,n=In,r=Ln,i=K,a=Nn,o=L,s=An,c=Vn,l=e.f;Fn=null,In=0,Ln=null,K=l&96?null:e,Nn=null,je(e.ctx),An=!1,Vn=++Bn,e.ac!==null&&(en(()=>{e.ac.abort(A)}),e.ac=null);try{e.f|=re;var u=e.fn,d=u();e.f|=w;var f=e.deps,p=z?.is_fork;if(Fn!==null){var m;if(p||Jn(e,In),f!==null&&In>0)for(f.length=In+Fn.length,m=0;m<Fn.length;m++)f[In+m]=Fn[m];else e.deps=f=Fn;if(an()&&e.f&512)for(m=In;m<f.length;m++)(f[m].reactions??=[]).push(e)}else !p&&f!==null&&In<f.length&&(Jn(e,In),f.length=In);if(Pe()&&Ln!==null&&!An&&f!==null&&!(e.f&6146))for(m=0;m<Ln.length;m++)Gn(Ln[m],e);if(i!==null&&i!==e){if(Bn++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=Bn;if(t!==null)for(let e of t)e.rv=Bn;Ln!==null&&(r===null?r=Ln:r.push(...Ln))}return e.f&8388608&&(e.f^=ie),d}catch(e){return ze(e)}finally{e.f^=re,Fn=t,In=n,Ln=r,K=i,Nn=a,je(o),An=s,Vn=c}}function qn(e,t){let n=t.reactions;if(n!==null){var r=a.call(n,e);if(r!==-1){var i=n.length-1;i===0?n=t.reactions=null:(n[r]=n[i],n.pop())}}if(n===null&&t.f&2&&(Fn===null||!o.call(Fn,t))){var s=t;s.f&512&&(s.f^=512,s.f&=~ne),He(s),Et(s),Jn(s,0)}}function Jn(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)qn(e,n[r])}function Yn(e){var t=e.f;if(!(t&16384)){R(e,y);var n=q,r=Dn;q=e,Dn=!0;try{t&16777232?vn(e):_n(e),gn(e);var i=Kn(e);e.teardown=typeof i==`function`?i:null,e.wv=zn}finally{Dn=r,q=n}}}function J(e){var t=(e.f&2)!=0;if(En?.add(e),K!==null&&!An&&!(q!==null&&q.f&16384)&&(Nn===null||!o.call(Nn,e))){var n=K.deps;if(K.f&2097152)e.rv<Bn&&(e.rv=Bn,Fn===null&&n!==null&&n[In]===e?In++:Fn===null?Fn=[e]:Fn.push(e));else{(K.deps??=[]).push(e);var r=e.reactions;r===null?e.reactions=[K]:o.call(r,K)||r.push(K)}}if(On&&kt.has(e))return kt.get(e);if(t){var i=e;if(On){var a=i.v;return(!(i.f&1024)&&i.reactions!==null||Zn(i))&&(a=wt(i)),kt.set(i,a),a}var s=(i.f&512)==0&&!An&&K!==null&&(Dn||(K.f&512)!=0),c=(i.f&w)===0;Wn(i)&&(s&&(i.f|=512),Tt(i)),s&&!c&&(Dt(i),Xn(i))}if(B?.has(e))return B.get(e);if(e.f&8388608)throw e.v;return e.v}function Xn(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(Dt(t),Xn(t))}function Zn(e){if(e.v===n)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(kt.has(t)||t.f&2&&Zn(t))return!0;return!1}function Qn(e){var t=An;try{return An=!0,e()}finally{An=t}}var $n=Symbol(`events`),er=new Set,tr=new Set;function nr(e,t,n){(t[$n]??={})[e]=n}function rr(e){for(var t=0;t<e.length;t++)er.add(e[t]);for(var n of tr)n(e)}var ir=null;function ar(e){var t=this,n=t.ownerDocument,r=e.type,i=e.composedPath?.()||[],a=i[0]||e.target;ir=e;var o=0,s=ir===e&&e[$n];if(s){var c=i.indexOf(s);if(c!==-1&&(t===document||t===window)){e[$n]=t;return}var u=i.indexOf(t);if(u===-1)return;c<=u&&(o=c)}if(a=i[o]||e.target,a!==t){l(e,`currentTarget`,{configurable:!0,get(){return a||n}});var d=K,f=q;jn(null),Mn(null);try{for(var p,m=[];a!==null;){var h=a.assignedSlot||a.parentNode||a.host||null;try{var g=a[$n]?.[r];g!=null&&(!a.disabled||e.target===a)&&g.call(a,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble||h===t||h===null)break;a=h}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[$n]=t,delete e.currentTarget,jn(d),Mn(f)}}}var or=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function sr(e){return or?.createHTML(e)??e}function cr(e){var t=Qt(`template`);return t.innerHTML=sr(e.replaceAll(`<!>`,`<!---->`)),t.content}function lr(e,t){var n=q;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function ur(e,t){var n=(t&1)!=0,r=(t&2)!=0,i,a=!e.startsWith(`<!>`);return()=>{if(P)return lr(F,null),F;i===void 0&&(i=cr(a?e:`<!>`+e),n||(i=Gt(i)));var t=r||Bt?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=Gt(t),s=t.lastChild;lr(o,s)}else lr(t,t);return t}}function dr(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=(t&1)!=0,a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(P)return lr(F,null),F;if(!o){var e=Gt(cr(a));if(i)for(o=document.createDocumentFragment();Gt(e);)o.appendChild(Gt(e));else o=Gt(e)}var t=o.cloneNode(!0);if(i){var n=Gt(t),r=t.lastChild;lr(n,r)}else lr(t,t);return t}}function Y(e,t){return dr(e,t,`svg`)}function fr(){if(P)return lr(F,null),F;var e=document.createDocumentFragment(),t=document.createComment(``),n=Wt();return e.append(t,n),lr(t,n),e}function X(e,t){if(P){var n=q;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=F),xe();return}e!==null&&e.before(t)}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var pr=[`touchstart`,`touchmove`];function mr(e){return pr.includes(e)}function hr(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e.__t??=e.nodeValue)&&(e.__t=n,e.nodeValue=`${n}`)}function gr(e,t){return yr(e,t)}function _r(e,n){Ut(),n.intro=n.intro??!1;let r=n.target,i=P,a=F;try{for(var o=Gt(r);o&&(o.nodeType!==8||o.data!==`[`);)o=Kt(o);if(!o)throw t;be(!0),I(o);let i=yr(e,{...n,anchor:o});return be(!1),i}catch(i){if(i instanceof Error&&i.message.split(`
2
+ `).some(e=>e.startsWith(`https://svelte.dev/e/`)))throw i;return i!==t&&console.warn(`Failed to hydrate: `,i),n.recover===!1&&he(),Ut(),Xt(r),be(!1),gr(e,n)}finally{be(i),I(a)}}var vr=new Map;function yr(e,{target:n,anchor:r,props:i={},events:a,context:o,intro:c=!0,transformError:l}){Ut();var u=void 0,d=un(()=>{var c=r??n.appendChild(Wt());pt(c,{pending:()=>{}},n=>{Me({});var r=L;if(o&&(r.c=o),a&&(i.$$events=a),P&&lr(n,null),u=e(n,i)||{},P&&(q.nodes.end=F,F===null||F.nodeType!==8||F.data!==`]`))throw M(),t;Ne()},l);var d=new Set,f=e=>{for(var t=0;t<e.length;t++){var r=e[t];if(!d.has(r)){d.add(r);var i=mr(r);for(let e of[n,document]){var a=vr.get(e);a===void 0&&(a=new Map,vr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,ar,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return f(s(er)),tr.add(f),()=>{for(var e of d)for(let r of[n,document]){var t=vr.get(r),i=t.get(e);--i==0?(r.removeEventListener(e,ar),t.delete(e),t.size===0&&vr.delete(r)):t.set(e,i)}tr.delete(f),c!==r&&c.parentNode?.removeChild(c)}});return br.set(u,d),u}var br=new WeakMap;function xr(e,t){let n=br.get(e);return n?(br.delete(e),n(t)):Promise.resolve()}var Sr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Cn(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(G(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Tn(r,t),t.append(Wt()),this.#n.set(e,{effect:r,fragment:t})}else G(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),xn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(G(n.effect),this.#n.delete(e))};ensure(e,t){var n=z,r=Zt();if(t&&!this.#t.has(e)&&!this.#n.has(e))if(r){var i=document.createDocumentFragment(),a=Wt();i.append(a),this.#n.set(e,{effect:hn(()=>t(a)),fragment:i})}else this.#t.set(e,hn(()=>t(this.anchor)));if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else P&&(this.anchor=F),this.#a(n)}};function Cr(e){L===null&&ce(`onMount`),Ae&&L.l!==null?wr(L).m.push(e):sn(()=>{let t=Qn(e);if(typeof t==`function`)return t})}function wr(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}function Tr(e,t,n=!1){var r;P&&(r=F,xe());var i=new Sr(e),a=n?T:0;function o(e,t){if(P){var n=Te(r);if(e!==parseInt(n.substring(1))){var a=we();I(a),i.anchor=a,be(!1),i.ensure(e,t),be(!0);return}}i.ensure(e,t)}mn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function Er(e,t,n){for(var r=[],i=t.length,a,o=t.length,c=0;c<i;c++){let n=t[c];xn(n,()=>{if(a){if(a.pending.delete(n),a.done.add(n),a.pending.size===0){var t=e.outrogroups;Dr(e,s(a.done)),t.delete(a),t.size===0&&(e.outrogroups=null)}}else --o},!1)}if(o===0){var l=r.length===0&&n!==null;if(l){var u=n,d=u.parentNode;Xt(d),d.append(u),e.items.clear()}Dr(e,t,!l)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function Dr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=D,Tn(a,document.createDocumentFragment())):G(t[i],n)}}var Or;function kr(e,t,n,r,a,o=null){var c=e,l=new Map;if(t&4){var u=e;c=P?I(Gt(u)):u.appendChild(Wt())}P&&xe();var d=null,f=xt(()=>{var e=n();return i(e)?e:e==null?[]:s(e)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,jr(v,p,c,t,r),d!==null&&(p.length===0?d.f&33554432?(d.f^=D,Nr(d,null,c)):Cn(d):xn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:mn(()=>{p=J(f);var e=p.length;let i=!1;P&&Te(c)===`[!`!=(e===0)&&(c=we(),I(c),be(!1),i=!0);for(var s=new Set,u=z,v=Zt(),y=0;y<e;y+=1){P&&F.nodeType===8&&F.data===`]`&&(c=F,i=!0,be(!1));var b=p[y],x=r(b,y),S=h?null:l.get(x);S?(S.v&&Nt(S.v,b),S.i&&Nt(S.i,y),v&&u.unskip_effect(S.e)):(S=Mr(l,h?c:Or??=Wt(),b,x,y,a,t,n),h||(S.e.f|=D),l.set(x,S)),s.add(x)}if(e===0&&o&&!d&&(h?d=hn(()=>o(c)):(d=hn(()=>o(Or??=Wt())),d.f|=D)),e>s.size&&ue(``,``,``),P&&e>0&&I(we()),!h)if(m.set(u,s),v){for(let[e,t]of l)s.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u);i&&be(!0),J(f)}),flags:t,items:l,pending:m,outrogroups:null,fallback:d};h=!1,P&&(c=F)}function Ar(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function jr(e,t,n,r,i){var a=(r&8)!=0,o=t.length,c=e.items,l=Ar(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(a)for(v=0;v<o;v+=1)h=t[v],g=i(h,v),_=c.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(f??=new Set).add(_));for(v=0;v<o;v+=1){if(h=t[v],g=i(h,v),_=c.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(Cn(_),a&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432)if(_.f^=D,_===l)Nr(_,null,n);else{var y=d?d.next:l;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),Pr(e,d,_),Pr(e,_,y),Nr(_,y,n),d=_,p=[],m=[],l=Ar(d.next);continue}if(_!==l){if(u!==void 0&&u.has(_)){if(p.length<m.length){var b=m[0],x;d=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)Nr(p[x],b,n);for(x=0;x<m.length;x+=1)u.delete(m[x]);Pr(e,S.prev,C.next),Pr(e,d,S),Pr(e,C,b),l=b,d=C,--v,p=[],m=[]}else u.delete(_),Nr(_,l,n),Pr(e,_.prev,_.next),Pr(e,_,d===null?e.effect.first:d.next),Pr(e,d,_),d=_;continue}for(p=[],m=[];l!==null&&l!==_;)(u??=new Set).add(l),m.push(l),l=Ar(l.next);if(l===null)continue}_.f&33554432||p.push(_),d=_,l=Ar(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(Dr(e,s(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var w=[];if(u!==void 0)for(_ of u)_.f&8192||w.push(_);for(;l!==null;)!(l.f&8192)&&l!==e.fallback&&w.push(l),l=Ar(l.next);var ee=w.length;if(ee>0){var T=r&4&&o===0?n:null;if(a){for(v=0;v<ee;v+=1)w[v].nodes?.a?.measure();for(v=0;v<ee;v+=1)w[v].nodes?.a?.fix()}Er(e,w,T)}}a&&Le(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function Mr(e,t,n,r,i,a,o,s){var c=o&1?o&16?jt(n):Mt(n,!1,!1):null,l=o&2?jt(i):null;return{v:c,i:l,e:hn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function Nr(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=Kt(r);if(a.before(r),r===i)return;r=o}}function Pr(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Fr(e,t){dn(()=>{var n=e.getRootNode(),r=n.host?n:n.head??n.ownerDocument.head;if(!r.querySelector(`#`+t.hash)){let e=Qt(`style`);e.id=t.hash,e.textContent=t.code,r.appendChild(e)}})}function Ir(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Lr(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Rr(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\s*\/\*.*?\*\/\s*/g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Lr)),i&&c.push(...Object.keys(i).map(Lr));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=Lr(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=Ir(r)),i&&(n+=Ir(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function zr(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function Br(e,t,n,r){var i=e.__style;if(P||i!==t){var a=Rr(t,r);(!P||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e.__style=t}else r&&(Array.isArray(r)?(zr(e,n?.[0],r[0]),zr(e,n?.[1],r[1],`important`)):zr(e,n,r));return r}var Vr=Symbol(`is custom element`),Hr=Symbol(`is html`),Ur=se?`link`:`LINK`;function Z(e,t,n,r){var i=Wr(e);P&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===Ur)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[oe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Kr(e).includes(t)?e[t]=n:e.setAttribute(t,n))}function Wr(e){return e.__attributes??={[Vr]:e.nodeName.includes(`-`),[Hr]:e.namespaceURI===r}}var Gr=new Map;function Kr(e){var t=e.getAttribute(`is`)||e.nodeName,n=Gr.get(t);if(n)return n;Gr.set(t,n=[]);for(var r,i=e,a=Element.prototype;a!==i;){for(var o in r=d(i),r)r[o].set&&n.push(o);i=m(i)}return n}function Q(e,t,n,r){var i=!Ae||(n&2)!=0,a=(n&8)!=0,o=(n&16)!=0,s=r,c=!0,l=()=>(c&&(c=!1,s=o?Qn(r):r),s);let d;if(a){var f=k in e||ae in e;d=u(e,t)?.set??(f&&t in e?n=>e[t]=n:void 0)}var p,m=!1;a?[p,m]=qe(()=>e[t]):p=e[t],p===void 0&&r!==void 0&&(p=l(),d&&(i&&ge(t),d(p)));var h=i?()=>{var n=e[t];return n===void 0?l():(c=!0,n)}:()=>{var n=e[t];return n!==void 0&&(s=void 0),n===void 0?s:n};if(i&&!(n&4))return h;if(d){var g=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||g||m)&&d(t?h():e),e):h()})}var _=!1,v=(n&1?yt:xt)(()=>(_=!1,h()));a&&J(v);var y=q;return(function(e,t){if(arguments.length>0){let n=t?J(v):i&&a?Rt(e):e;return U(v,n),_=!0,s!==void 0&&(s=n),e}return On&&_||y.f&16384?v.v:J(v)})}function qr(e){return new Jr(e)}var Jr=class{#e;#t;constructor(e){var t=new Map,n=(e,n)=>{var r=Mt(n,!1,!1);return t.set(e,r),r};let r=new Proxy({...e.props||{},$$events:{}},{get(e,r){return J(t.get(r)??n(r,Reflect.get(e,r)))},has(e,r){return r===ae?!0:(J(t.get(r)??n(r,Reflect.get(e,r))),Reflect.has(e,r))},set(e,r,i){return U(t.get(r)??n(r,i),i),Reflect.set(e,r,i)}});this.#t=(e.hydrate?_r:gr)(e.component,{target:e.target,anchor:e.anchor,props:r,context:e.context,intro:e.intro??!1,recover:e.recover,transformError:e.transformError}),!ke&&(!e?.props?.$$host||e.sync===!1)&&V(),this.#e=r.$$events;for(let e of Object.keys(this.#t))e===`$set`||e===`$destroy`||e===`$on`||l(this,e,{get(){return this.#t[e]},set(t){this.#t[e]=t},enumerable:!0});this.#t.$set=e=>{Object.assign(r,e)},this.#t.$destroy=()=>{xr(this.#t)}}$set(e){this.#t.$set(e)}$on(e,t){this.#e[e]=this.#e[e]||[];let n=(...e)=>t.call(this,...e);return this.#e[e].push(n),()=>{this.#e[e]=this.#e[e].filter(e=>e!==n)}}$destroy(){this.#t.$destroy()}},Yr;typeof HTMLElement==`function`&&(Yr=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){let n=this.$$c.$on(e,t);this.$$l_u.set(t,n)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){let e=this.$$l_u.get(t);e&&(e(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){if(await Promise.resolve(),!this.$$cn||this.$$c)return;function e(e){return t=>{let n=Qt(`slot`);e!==`default`&&(n.name=e),X(t,n)}}let t={},n=Zr(this);for(let 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(let e of this.attributes){let t=this.$$g_p(e.name);t in this.$$d||(this.$$d[t]=Xr(t,e.value,this.$$p_d,`toProp`))}for(let e in this.$$p_d)!(e in this.$$d)&&this[e]!==void 0&&(this.$$d[e]=this[e],delete this[e]);this.$$c=qr({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=ln(()=>{pn(()=>{this.$$r=!0;for(let e of c(this.$$c)){if(!this.$$p_d[e]?.reflect)continue;this.$$d[e]=this.$$c[e];let t=Xr(e,this.$$d[e],this.$$p_d,`toAttribute`);t==null?this.removeAttribute(this.$$p_d[e].attribute||e):this.setAttribute(this.$$p_d[e].attribute||e,t)}this.$$r=!1})});for(let e in this.$$l)for(let t of this.$$l[e]){let n=this.$$c.$on(e,t);this.$$l_u.set(t,n)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=Xr(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 c(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function Xr(e,t,n,r){let i=n[e]?.type;if(t=i===`Boolean`&&typeof t!=`boolean`?t!=null:t,!r||!n[e])return t;if(r===`toAttribute`)switch(i){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(i){case`Object`:case`Array`:return t&&JSON.parse(t);case`Boolean`:return t;case`Number`:return t==null?t:+t;default:return t}}function Zr(e){let t={};return e.childNodes.forEach(e=>{t[e.slot||`default`]=!0}),t}function Qr(e,t,n,r,i,a){let o=class extends Yr{constructor(){super(e,n,i),this.$$p_d=t}static get observedAttributes(){return c(t).map(e=>(t[e].attribute||e).toLowerCase())}};return c(t).forEach(e=>{l(o.prototype,e,{get(){return this.$$c&&e in this.$$c?this.$$c[e]:this.$$d[e]},set(n){n=Xr(e,n,t),this.$$d[e]=n;var r=this.$$c;r&&(u(r,e)?.get?r[e]=n:r.$set({[e]:n}))}})}),r.forEach(e=>{l(o.prototype,e,{get(){return this.$$c?.[e]}})}),a&&(o=a(o)),e.element=o,o}var{PI:$r}=Math,ei=$r+1e-4,ti=.5,ni=[1,1];function ri(e,t,n,r=e=>e){return e*r(.5-t*(.5-n))}var{min:ii}=Math;function ai(e,t,n){let r=ii(1,t/n);return ii(1,e+(ii(1,1-r)-e)*(r*.275))}function oi(e){return[-e[0],-e[1]]}function si(e,t){return[e[0]+t[0],e[1]+t[1]]}function ci(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function li(e,t){return[e[0]-t[0],e[1]-t[1]]}function ui(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function di(e,t){return[e[0]*t,e[1]*t]}function fi(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function pi(e,t){return[e[0]/t,e[1]/t]}function mi(e){return[e[1],-e[0]]}function hi(e,t){let n=t[0];return e[0]=t[1],e[1]=-n,e}function gi(e,t){return e[0]*t[0]+e[1]*t[1]}function _i(e,t){return e[0]===t[0]&&e[1]===t[1]}function vi(e){return Math.hypot(e[0],e[1])}function yi(e,t){let n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function bi(e){return pi(e,vi(e))}function xi(e,t){return Math.hypot(e[1]-t[1],e[0]-t[0])}function Si(e,t,n){let r=Math.sin(n),i=Math.cos(n),a=e[0]-t[0],o=e[1]-t[1],s=a*i-o*r,c=a*r+o*i;return[s+t[0],c+t[1]]}function Ci(e,t,n,r){let i=Math.sin(r),a=Math.cos(r),o=t[0]-n[0],s=t[1]-n[1],c=o*a-s*i,l=o*i+s*a;return e[0]=c+n[0],e[1]=l+n[1],e}function wi(e,t,n){return si(e,di(li(t,e),n))}function Ti(e,t,n,r){let i=n[0]-t[0],a=n[1]-t[1];return e[0]=t[0]+i*r,e[1]=t[1]+a*r,e}function Ei(e,t,n){return si(e,di(t,n))}var $=[0,0],Di=[0,0],Oi=[0,0];function ki(e,t){let n=Ei(e,bi(mi(li(e,si(e,[1,1])))),-t),r=[],i=1/13;for(let t=i;t<=1;t+=i)r.push(Si(n,e,ei*2*t));return r}function Ai(e,t,n){let r=[],i=1/n;for(let n=i;n<=1;n+=i)r.push(Si(t,e,ei*n));return r}function ji(e,t,n){let r=li(t,n),i=di(r,.5),a=di(r,.51);return[li(e,i),li(e,a),si(e,a),si(e,i)]}function Mi(e,t,n,r){let i=[],a=Ei(e,t,n),o=1/r;for(let t=o;t<1;t+=o)i.push(Si(a,e,ei*3*t));return i}function Ni(e,t,n){return[si(e,di(t,n)),si(e,di(t,n*.99)),li(e,di(t,n*.99)),li(e,di(t,n))]}function Pi(e,t,n){return e===!1||e===void 0?0:e===!0?Math.max(t,n):e}function Fi(e,t,n){return e.slice(0,10).reduce((e,r)=>{let i=r.pressure;return t&&(i=ai(e,r.distance,n)),(e+i)/2},e[0].pressure)}function Ii(e,t={}){let{size:n=16,smoothing:r=.5,thinning:i=.5,simulatePressure:a=!0,easing:o=e=>e,start:s={},end:c={},last:l=!1}=t,{cap:u=!0,easing:d=e=>e*(2-e)}=s,{cap:f=!0,easing:p=e=>--e*e*e+1}=c;if(e.length===0||n<=0)return[];let m=e[e.length-1].runningLength,h=Pi(s.taper,n,m),g=Pi(c.taper,n,m),_=(n*r)**2,v=[],y=[],b=Fi(e,a,n),x=ri(n,i,e[e.length-1].pressure,o),S,C=e[0].vector,w=e[0].point,ee=w,T=w,E=ee,te=!1;for(let t=0;t<e.length;t++){let{pressure:r}=e[t],{point:s,vector:c,distance:l,runningLength:u}=e[t],f=t===e.length-1;if(!f&&m-u<3)continue;i?(a&&(r=ai(b,l,n)),x=ri(n,i,r,o)):x=n/2,S===void 0&&(S=x);let D=u<h?d(u/h):1,ne=m-u<g?p((m-u)/g):1;x=Math.max(.01,x*Math.min(D,ne));let re=(f?e[t]:e[t+1]).vector,O=f?1:gi(c,re),ie=gi(c,C)<0&&!te,k=O!==null&&O<0;if(ie||k){hi($,C),fi($,$,x);for(let e=0;e<=1;e+=.07692307692307693)ui(Di,s,$),Ci(Di,Di,s,ei*e),T=[Di[0],Di[1]],v.push(T),ci(Oi,s,$),Ci(Oi,Oi,s,ei*-e),E=[Oi[0],Oi[1]],y.push(E);w=T,ee=E,k&&(te=!0);continue}if(te=!1,f){hi($,c),fi($,$,x),v.push(li(s,$)),y.push(si(s,$));continue}Ti($,re,c,O),hi($,$),fi($,$,x),ui(Di,s,$),T=[Di[0],Di[1]],(t<=1||yi(w,T)>_)&&(v.push(T),w=T),ci(Oi,s,$),E=[Oi[0],Oi[1]],(t<=1||yi(ee,E)>_)&&(y.push(E),ee=E),b=r,C=c}let D=[e[0].point[0],e[0].point[1]],ne=e.length>1?[e[e.length-1].point[0],e[e.length-1].point[1]]:si(e[0].point,[1,1]),re=[],O=[];if(e.length===1){if(!(h||g)||l)return ki(D,S||x)}else{h||g&&e.length===1||(u?re.push(...Ai(D,y[0],13)):re.push(...ji(D,v[0],y[0])));let t=mi(oi(e[e.length-1].vector));g||h&&e.length===1?O.push(ne):f?O.push(...Mi(ne,t,x,29)):O.push(...Ni(ne,t,x))}return v.concat(O,y.reverse(),re)}var Li=[0,0];function Ri(e){return e!=null&&e>=0}function zi(e,t={}){let{streamline:n=.5,size:r=16,last:i=!1}=t;if(e.length===0)return[];let a=.15+(1-n)*.85,o=Array.isArray(e[0])?e:e.map(({x:e,y:t,pressure:n=ti})=>[e,t,n]);if(o.length===2){let e=o[1];o=o.slice(0,-1);for(let t=1;t<5;t++)o.push(wi(o[0],e,t/4))}o.length===1&&(o=[...o,[...si(o[0],ni),...o[0].slice(2)]]);let s=[{point:[o[0][0],o[0][1]],pressure:Ri(o[0][2])?o[0][2]:.25,vector:[...ni],distance:0,runningLength:0}],c=!1,l=0,u=s[0],d=o.length-1;for(let e=1;e<o.length;e++){let t=i&&e===d?[o[e][0],o[e][1]]:wi(u.point,o[e],a);if(_i(u.point,t))continue;let n=xi(t,u.point);if(l+=n,e<d&&!c){if(l<r)continue;c=!0}ui(Li,u.point,t),u={point:t,pressure:Ri(o[e][2])?o[e][2]:ti,vector:bi(Li),distance:n,runningLength:l},s.push(u)}return s[0].vector=s[1]?.vector||[0,0],s}function Bi(e,t={}){return Ii(zi(e,t),t)}var Vi=Y(`<path stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></path>`),Hi=Y(`<image stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></image>`),Ui=Y(`<text stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"> </text>`),Wi=Y(`<path class="svelte-1qsqiex"></path>`),Gi=Y(`<image class="svelte-1qsqiex"></image>`),Ki=Y(`<text class="svelte-1qsqiex"> </text>`),qi=Y(`<path stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></path>`),Ji=Y(`<image stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"></image>`),Yi=Y(`<text stroke-linecap="round" stroke="red" stroke-width="2" class="svelte-1qsqiex"> </text>`),Xi=Y(`<path class="svelte-1qsqiex"></path>`),Zi=Y(`<image class="svelte-1qsqiex"></image>`),Qi=Y(`<text class="svelte-1qsqiex"> </text>`),$i=Y(`<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>`),ea=Y(`<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>`),ta=Y(`<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>`),na=Y(`<rect id="selector" fill="none" stroke="red" stroke-width="1"></rect>`),ra=Y(`<g><!><!></g>`),ia=ur(`<div id="debug" class="svelte-1qsqiex"> </div> <div id="container"><svg class="svelte-1qsqiex"><!></svg></div>`,1),aa={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 oa(e,t){Me(t,!0),Fr(e,aa);function n(e,n){t.$$host.dispatchEvent(new CustomEvent(e,{detail:n}))}let r={size:6,thinning:.7,smoothing:.5,streamline:.5},i={paperSize:`A4`},a={zoom:{type:`fit`,value:1},pan:{x:0,y:0},lockPan:!1,lockZoom:!1},o=Q(t,`id`,7,``),s=Q(t,`load_draw`,7),c=Q(t,`draw_id`,23,()=>Math.random().toString(36)+Math.random().toString(36)+Date.now().toString()),l=Q(t,`background_color`,7,`rgb(255,255,255)`),u=Q(t,`pen_color`,7,`rgb(0,0,0)`),d=Q(t,`insert_image`,7,void 0),f=Q(t,`insert_text`,7),p=Q(t,`pen_opacity`,7,1),m=Q(t,`options`,7,r),h=Q(t,`goto`,7,void 0),g=Q(t,`mode`,7,`draw`),_=Q(t,`debug`,7,`no`),v=Q(t,`save_as`,7,void 0),y=Q(t,`size`,23,()=>Object.assign({},i)),b=Q(t,`view`,23,()=>Object.assign({},a)),x,S,C=H(0),w=H(!1),ee=H(0),T=H(void 0),E=H(void 0),te=H(``),D=H(Rt({})),ne=H(0),re=H(void 0),O=H(void 0),ie=H(void 0),k=H(Rt([])),ae=H(!1),oe=H(`idle`),A=H(void 0),se=H(void 0),ce=H(void 0),le=H(void 0),ue=H(void 0),de=H(!1),fe=H(void 0),pe=H(void 0),me=H(void 0),he=H(void 0),ge=H(0),_e=H(0),ve=H(0),ye=H(0),j=H(0),M=H(0),N=H(0),P=H(0);function be(e){if(!e.length)return``;let t=e.reduce((e,[t,n],r,i)=>{let[a,o]=i[(r+1)%i.length];return e.push(t,n,(t+a)/2,(n+o)/2),e},[`M`,...e[0],`Q`]);return t.push(`Z`),t.join(` `)}function F(e){if(e)switch(e.type){case`json`:let t=[];for(let e of J(k))if(e.visible){if(e.type===`stroke`)e.actionIndex=0,t.push(e);else if(e.type===`multiplestroke`)for(let n of e.multipath?.filter(e=>e.visible)||[])n.actionIndex=0,t.push(n)}return xe({type:`json`,draw:t,id:o(),draw_id:c(),name:e.name,version:J(ee)+1,size:y()||i});default:return console.error(`unknown save type`)}}function I(e){n(`drawLoaded`,e)}function xe(e){n(`save`,e)}function Ce(e){n(`historyIndex`,e)}function we(e){n(`changeIndex`,e)}function Te(e){n(`selection`,e)}function Ee(e){n(`startStroke`,e)}function De(e){n(`endStroke`,e)}function Oe(e){n(`imageLoaded`,e)}function ke(e){n(`txtLoaded`,e)}function Ae(){if(!J(T))return console.error(`no svg dom found`);if(!J(E))return console.error(`no svg container found`);switch(U(D,J(T).getBoundingClientRect(),!0),x||={},x.containerWidth=J(E).clientWidth,x.containerHeight=J(E).clientHeight,x.drawWidth=J(T).clientWidth,x.drawHeight=J(T).clientHeight,y()?.paperSize){case`A3`:x.paperWidth=297,x.paperHeight=420;break;default:x.paperWidth=210,x.paperHeight=297;break}}function L(){if(console.log(`svgDom`,J(T)),J(D)||Ae(),s()&&typeof s()==`object`&&(!J(ee)||J(ee)<s().version||c()!==s().draw_id)&&(console.log(`load_draw`,s()),U(k,s().draw,!0),U(C,J(k).length,!0),c(s().draw_id),U(ee,s().version,!0),s(void 0),S=J(k).length,Ce({index:J(C),draw_id:c(),id:o(),start_index:S}),I({index:J(C),draw_id:c(),id:o(),start_index:S})),J(k)?.length&&v()&&(console.log(`save_as`,v()),F(v())),J(k)||(console.log(`draw is empty`),U(k,[],!0)),g()&&g()!==`select`&&J(A)){U(A,0);let e=[...J(k)];e.forEach(e=>{e.selected=!1,e.type===`multiplestroke`&&e.multipath?.forEach(e=>{e.selected=!1})}),U(k,[...e],!0)}if(g()!==`select`&&(U(N,0),U(P,0),U(j,0),U(M,0)),typeof h()==`string`&&h(Number(h())),J(k).length||(U(C,0),h(void 0)),J(C)||U(C,0),h()&&h()<0?U(C,-1):(h()||h()===0)&&(S&&h()>S?h(S):h()>J(k).length&&h(J(k).length),U(C,h()+0),h(void 0),we({index:J(C),draw_id:c(),id:o(),start_index:S})),J(C)<0?(U(C,0),U(ae,!0)):J(C)>=0&&U(ae,!1),d()){console.info(`inserting object`);let e=!1;switch(d().type){case`jpg`:case`jpeg`:case`png`:je(d()),e=!0;break;case`svg`:Pe(d()),e=!0;break;default:console.error(`unknown insert_object type`,d().type),e=!1}e&&Oe({ok:!0,draw_id:c(),id:o()})}f()&&(console.log(`insert_text`,f()),Fe(f()),ke({ok:!0,draw_id:c(),id:o()})),U(se,Bi(J(k)[J(C)]?.path||[],Object.assign({simulatePressure:J(te)!==`pen`},m())),!0),U(ce,be(J(se)),!0),console.log(`set index to`,J(C),`from goto`,h(),`historyActions`,J(k).length)}sn(()=>{console.log(`recompute`);let e=!1;if(typeof y()==`string`)try{y(JSON.parse(y())),e=!0}catch(e){console.error(`error parsing size json`,e)}if(typeof b()==`string`)try{b(JSON.parse(b())),e=!0}catch(e){console.error(`error parsing view json`,e)}if(typeof s()==`string`&&s()?.length)try{s(JSON.parse(s())),e=!0}catch(e){console.error(`error parsing json`,e)}else s()||s(void 0);if(typeof v()==`string`&&v()?.length)try{v(JSON.parse(v())),e=!0}catch(e){console.error(`error parsing json`,e)}if(_()!==`yes`&&_(`no`),typeof p()==`string`&&p(Number(p())),typeof m()==`string`&&m()?.length)try{m(JSON.parse(m())),m()&&!m().size&&(m().size=r.size),m()&&!m().thinning&&(m().thinning=r.thinning),m()&&!m().smoothing&&(m().smoothing=r.smoothing),m()&&!m().streamline&&(m().streamline=r.streamline),e=!0}catch(e){console.error(`error parsing json`,e)}if(typeof d()==`string`)try{d(JSON.parse(d())),e=!0}catch(e){console.error(`error parsing insert_object json`,e)}J(T)&&e&&L()});function je(e){let t=[...J(k)],n={id:Date.now().toString(),type:`image`,actionIndex:J(C),visible:!0,pathData:e?.base64};t.push(n),U(k,[...t],!0),Ft(C)}function Pe(e){console.info(`inserting SVG ${e?.type}`)}function Fe(e){console.info(`inserting Text ${e?.content}`)}function Ie(e){let t=e.target?.id?.split(`_`)?.[1];if(t){let e=[...J(k)],n=e.find(e=>e.id===t&&e.visible);if(!n)for(let r of e.filter(e=>e.type===`multiplestroke`).sort((e,t)=>t.actionIndex-e.actionIndex)){let e=r?.multipath?.find(e=>e.id===t&&e.visible);if(e){n=e;break}}n&&(n.visible=!1,n.erasedAtIndex=J(C),console.info(`erase stroke`,n.id),e[e.length-1].type===`eraser`?U(k,[...e],!0):(e=e.slice(0,J(C)+1),e.push({type:`eraser`,visible:!0,id:Math.random().toString(36)+Math.random().toString(36)+Date.now().toString(),actionIndex:J(k).length}),e.forEach((e,t)=>{!e.visible&&e.erasedAtIndex&&e.erasedAtIndex>J(C)&&(e.visible=!0,e.erasedAtIndex=void 0)}),U(k,[...e],!0),Ft(C),Ce({index:J(C),draw_id:c(),id:o(),start_index:S})))}}function Le(e){if(console.log(`handlePointerDown`),U(te,e.pointerType,!0),U(ne,e.buttons,!0),g()===`draw`&&e.buttons===1&&!(e.pointerType===`pen`&&e.pressure===0)){if(U(oe,`drawing`),J(C)!==J(k).length-1){let e=[...J(k)];e.forEach((e,t)=>{!e.visible&&e.erasedAtIndex&&e.erasedAtIndex>J(C)&&(e.visible=!0,e.erasedAtIndex=void 0)}),U(k,e,!0)}J(k)?.length&&J(C)<J(k).length&&(J(ae)?(U(k,[],!0),U(ae,!1)):(Ft(C),U(k,[...J(k)].slice(0,J(C)),!0))),Ce({index:J(C),draw_id:c(),id:o(),start_index:S}),console.log(`setup stroke`),U(ie,new Date,!0),U(O,Date.now().toString(),!0),U(ge,e.pageX-J(D).left),U(_e,e.pageY-J(D).top),U(ve,e.pageX-J(D).left),U(ye,e.pageY-J(D).top),J(re)||(U(re,J(ie),!0),Ee({start:J(re),id:o(),draw_id:c(),stroke_id:J(O),index:J(C)})),e.target.setPointerCapture(e.pointerId),J(k)?.length?(console.info(`pushing draw`),U(k,[...J(k),{path:[[e.pageX-J(D).left,e.pageY-J(D).top,e.pressure]],color:u(),id:J(O),pathData:J(ce),min:[J(ge),J(_e)],max:[J(ve),J(ye)],visible:!0,actionIndex:J(k).length,opacity:p(),type:`stroke`}],!0)):U(k,[{path:[[e.pageX-J(D).left,e.pageY-J(D).top,e.pressure]],color:u(),id:J(O),pathData:J(ce),min:[J(ge),J(_e)],max:[J(ve),J(ye)],visible:!0,actionIndex:J(k).length,opacity:p(),type:`stroke`}],!0),Ee({start:J(ie),stroke_id:J(O),index:J(C),id:o(),draw_id:c()})}else if(g()===`eraser`||g()===`draw`&&(e.pointerType===`pen`&&e.pressure===0&&e.buttons===1||e.buttons===32))e.target.setPointerCapture(e.pointerId),U(oe,`erasing`),console.log(`eraser down`),Ie(e);else if(g()===`select`&&J(k).length){let t=!1,n=e.pageX-J(D).left,r=e.pageY-J(D).top;if(t=n>J(j)&&n<J(N)&&r>J(M)&&r<J(P),U(j,e.pageX-J(D).left),U(M,e.pageY-J(D).top),U(N,e.pageX-J(D).left),U(P,e.pageY-J(D).top),!J(de)&&!J(A)&&t){U(oe,`idle`),U(A,Date.now(),!0),console.info(`set move mode`);let t=[...J(k)];U(le,e.pageX-J(D).left),U(ue,e.pageY-J(D).top),t.filter(e=>e.selected).forEach(e=>{e.visible=!1,e.erasedAtIndex=J(C)}),t.filter(e=>e.type===`multiplestroke`).forEach(e=>{e.multipath?.filter(e=>e.selected).forEach(e=>{e.visible=!1,e.erasedAtIndex=J(C)})});let n=[];for(let e of t.filter(e=>e.type===`multiplestroke`))for(let t of e.multipath?.filter(e=>e.selected)||[])n.push(JSON.parse(JSON.stringify(t))),t.visible=!1;let r=JSON.parse(JSON.stringify(J(k).filter(e=>e.selected))).concat(n);r.forEach(e=>{e.visible=!0}),t.push({multipath:r,id:J(A).toString(),type:`multiplestroke`,actionIndex:J(C),visible:!0,min:[J(j),J(M)],max:[J(N),J(P)]}),J(k)[J(k).length-1].type===`multiplestroke`&&Ft(C),U(k,[...t],!0),Ce({index:J(C),draw_id:c(),id:o(),start_index:S}),U(de,!0),U(fe,J(j),!0),U(pe,J(M),!0),U(me,J(N),!0),U(he,J(P),!0)}else U(oe,`selecting`),U(A,0)}}function Re(e){if(U(te,e.pointerType,!0),U(ne,e.buttons+` `+[e.pageX-J(D).left,e.pageY-J(D).top,e.pressure].toString()),g()===`draw`&&J(oe)===`drawing`&&e.buttons===1&&!(e.pointerType===`pen`&&e.pressure===0))J(k)[J(C)].path=[...J(k)[J(C)].path||[],[e.pageX-J(D).left,e.pageY-J(D).top,e.pressure]],J(k)[J(C)].pathData=J(ce),e.pageX-J(D).left<J(ge)&&U(ge,e.pageX-J(D).left),e.pageY-J(D).top<J(_e)&&U(_e,e.pageY-J(D).top),e.pageX-J(D).left>J(ve)&&U(ve,e.pageX-J(D).left),e.pageY-J(D).top>J(ye)&&U(ye,e.pageY-J(D).top),J(k)[J(C)].min=[J(ge),J(_e)],J(k)[J(C)].max=[J(ve),J(ye)];else if(J(oe)===`erasing`&&(g()===`eraser`||g()===`draw`&&(e.pointerType===`pen`&&e.pressure===0&&e.buttons===1||e.buttons===32)))console.log(`eraser move`),Ie(e);else if(g()===`select`&&J(oe)===`selecting`)U(N,e.pageX-J(D).left),U(P,e.pageY-J(D).top);else if(g()===`select`&&!J(de)){let t=e.pageX-J(D).left,n=e.pageY-J(D).top,r=t>J(j)&&t<J(N)&&n>J(M)&&n<J(P);r&&!J(w)?(U(w,!0),console.log(`on select`,J(w))):!r&&J(w)&&(U(w,!1),console.log(`off select`,J(w)))}else if(J(de)&&J(k)[J(C)].type===`multiplestroke`&&J(A)&&J(A).toString()===J(k)[J(C)].id){let t=[...J(k)],n=e.pageX-J(D).left,r=e.pageY-J(D).top,i=n-(J(le)||0),a=r-(J(ue)||0);console.info(`move selected strokes on multistrokes`,J(le),J(ue),i,a),t[J(C)]?.multipath?.forEach(e=>{let t;for(let n of J(k).filter(e=>e.type===`multiplestroke`).filter(e=>e.id!==J(k)[J(C)].id).sort((e,t)=>t.actionIndex-e.actionIndex)){let r=n?.multipath?.find(t=>t.id===e.id);if(r){t=r;break}}t||=J(k).find(t=>t.id===e.id),e.path?.forEach((e,n)=>{n===0&&console.log(`debug path `,e[0],t?.path?.[n][0],J(k)),t?.path&&(e[0]=t.path[n][0]+i),t?.path&&(e[1]=t.path[n][1]+a)}),t?.max&&(e.max=[t.max[0]+i,t.max[1]+a]),t?.min&&(e.min=[t.min[0]+i,t.min[1]+a]),e.pathData=be(Bi(e.path||[],Object.assign({simulatePressure:J(te)!==`pen`},m())))}),U(j,(J(fe)||0)+i),U(M,(J(pe)||0)+a),U(N,(J(me)||0)+i),U(P,(J(he)||0)+a),U(k,[...t],!0)}}function ze(e){if(U(ne,e.buttons,!0),U(de,!1),g()===`draw`&&J(oe)===`drawing`){let e=new Date;if(!J(O)||!J(ie)||!J(ce))return console.error(`no stroke id`,J(O),J(ie),J(ce));De({end:e,stroke_id:J(O),start:J(ie),min:[J(ge),J(_e)],max:[J(ve),J(ye)],pathData:J(ce),pen_color:u(),index:J(C),id:o(),draw_id:c()}),Ft(C),Ce({index:J(C),draw_id:c(),id:o(),start_index:S})}else if(g()===`eraser`||g()===`draw`&&J(oe)!==`drawing`&&(e.pointerType===`pen`&&e.pressure===0&&e.buttons===1||e.buttons===32))console.log(`eraser up`),Ie(e);else if(g()===`select`){let e=[...J(k)];e.forEach(e=>{e.selected=!1,e.type===`multiplestroke`&&e.multipath?.forEach(e=>{e.selected=!1})}),U(k,[...e],!0),U(A,0);let t=J(j)<J(N)?J(j):J(N),n=J(M)<J(P)?J(M):J(P),r=J(j)>J(N)?J(j):J(N),i=J(M)>J(P)?J(M):J(P),a=e.filter(e=>!!(e.visible&&e.type===`stroke`&&e.min&&e.max&&e.min[0]>t&&e.min[1]>n&&e.max[0]<r&&e.max[1]<i)),s=!1;for(let a of e.filter(e=>e.type===`multiplestroke`))for(let e of a.multipath||[])e.visible&&e.type===`stroke`&&e.min&&e.max&&e.min[0]>t&&e.min[1]>n&&e.max[0]<r&&e.max[1]<i&&(s=!0);if(a.length>0||s){for(let a of e.filter(e=>e.type===`multiplestroke`))for(let e of a?.multipath||[])e.visible&&e.min&&e.max&&e.min[0]>t&&e.min[1]>n&&e.max[0]<r&&e.max[1]<i&&(e.selected=!0);for(let e of a)e.selected=!0;U(k,[...e],!0),console.log(a),Te({minX:J(j),minY:J(M),maxX:J(N),maxY:J(P),strokes:a,id:o(),draw_id:c()})}else U(j,0),U(M,0),U(N,0),U(P,0)}U(oe,`idle`),e?.pointerId&&e.target?.releasePointerCapture?.(e.pointerId)}Cr(()=>{U(T,t.$$host?.shadowRoot?.querySelector(`svg`),!0),U(E,t.$$host?.shadowRoot?.querySelector(`#container`),!0);let e=0,n=setInterval(()=>{U(T,t.$$host?.shadowRoot?.querySelector(`svg`),!0),J(T)?clearInterval(n):(e++,e>10?(clearInterval(n),console.warn(`no canvas found on check `+e)):console.error(`no canvas found on check `+e+` end`))},100);if(!J(T))return console.error(`no canvas found on mount`)});var Be={get id(){return o()},set id(e=``){o(e),V()},get load_draw(){return s()},set load_draw(e){s(e),V()},get draw_id(){return c()},set draw_id(e=Math.random().toString(36)+Math.random().toString(36)+Date.now().toString()){c(e),V()},get background_color(){return l()},set background_color(e=`rgb(255,255,255)`){l(e),V()},get pen_color(){return u()},set pen_color(e=`rgb(0,0,0)`){u(e),V()},get insert_image(){return d()},set insert_image(e=void 0){d(e),V()},get insert_text(){return f()},set insert_text(e){f(e),V()},get pen_opacity(){return p()},set pen_opacity(e=1){p(e),V()},get options(){return m()},set options(e=r){m(e),V()},get goto(){return h()},set goto(e=void 0){h(e),V()},get mode(){return g()},set mode(e=`draw`){g(e),V()},get debug(){return _()},set debug(e=`no`){_(e),V()},get save_as(){return v()},set save_as(e=void 0){v(e),V()},get size(){return y()},set size(e=Object.assign({},i)){y(e),V()},get view(){return b()},set view(e=Object.assign({},a)){b(e),V()}},Ve=ia(),R=Jt(Ve),He=qt(R);Se(R);var Ue=Yt(R,2),We=qt(Ue),Ge=qt(We),Ke=e=>{var t=ra(),n=qt(t);kr(n,17,()=>J(k),e=>e.id,(e,t,n,r)=>{var i=fr(),a=Jt(i),o=e=>{var n=fr(),r=Jt(n),i=e=>{var n=fr(),r=Jt(n),i=e=>{var n=fr(),r=Jt(n),i=e=>{var n=Vi();W(()=>{Z(n,`id`,`path_`+J(t).id),Z(n,`d`,J(t).pathData),Z(n,`fill`,J(t).color),Z(n,`fill-opacity`,J(t).opacity)}),X(e,n)},a=e=>{var n=Hi();W(()=>{Z(n,`id`,`path_`+J(t).id),Z(n,`href`,J(t).pathData)}),X(e,n)},o=e=>{var n=Ui(),r=qt(n,!0);Se(n),W(()=>{Z(n,`id`,`path_`+J(t).id),hr(r,J(t).pathData)}),X(e,n)};Tr(r,e=>{J(t).type===`stroke`?e(i):J(t).type===`image`?e(a,1):J(t).type===`text`&&e(o,2)}),X(e,n)},a=e=>{var n=Wi();W(()=>{Z(n,`id`,`path_`+J(t).id),Z(n,`d`,J(t).pathData),Z(n,`fill`,J(t).color),Z(n,`fill-opacity`,J(t).opacity)}),X(e,n)},o=e=>{var n=Gi();W(()=>{Z(n,`id`,`path_`+J(t).id),Z(n,`href`,J(t).pathData)}),X(e,n)},s=e=>{var n=Ki(),r=qt(n,!0);Se(n),W(()=>{Z(n,`id`,`path_`+J(t).id),hr(r,J(t).pathData)}),X(e,n)};Tr(r,e=>{J(t).selected?e(i):!J(t).selected&&J(t).type===`stroke`?e(a,1):!J(t).selected&&J(t).type===`image`?e(o,2):!J(t).selected&&J(t).type===`text`&&e(s,3)}),X(e,n)},a=e=>{var n=fr();kr(Jt(n),17,()=>J(t).multipath,e=>e.id+J(t).id,(e,n)=>{var r=fr(),i=Jt(r),a=e=>{var r=fr(),i=Jt(r),a=e=>{var r=fr(),i=Jt(r),a=e=>{var r=qi();W(()=>{Z(r,`id`,`path_`+J(n).id+`_`+J(t).id),Z(r,`d`,J(n).pathData),Z(r,`fill`,J(n).color),Z(r,`fill-opacity`,J(n).opacity)}),X(e,r)},o=e=>{var r=Ji();W(()=>{Z(r,`id`,`path_`+J(n).id+`_`+J(t).id),Z(r,`href`,J(n).pathData)}),X(e,r)},s=e=>{var r=Yi(),i=qt(r,!0);Se(r),W(()=>{Z(r,`id`,`path_`+J(n).id+`_`+J(t).id),hr(i,J(n).pathData)}),X(e,r)};Tr(i,e=>{J(n).type===`stroke`?e(a):J(n).type===`image`?e(o,1):J(n).type===`text`&&e(s,2)}),X(e,r)},o=e=>{var r=Xi();W(()=>{Z(r,`id`,`path_`+J(n).id+`_`+J(t).id),Z(r,`d`,J(n).pathData),Z(r,`fill`,J(n).color),Z(r,`fill-opacity`,J(n).opacity)}),X(e,r)},s=e=>{var r=Zi();W(()=>{Z(r,`id`,`path_`+J(n).id+`_`+J(t).id),Z(r,`href`,J(n).pathData)}),X(e,r)},c=e=>{var r=Qi(),i=qt(r,!0);Se(r),W(()=>{Z(r,`id`,`path_`+J(n).id+`_`+J(t).id),hr(i,J(n).pathData)}),X(e,r)};Tr(i,e=>{J(n).selected?e(a):!J(n).selected&&J(n).type===`stroke`?e(o,1):!J(n).selected&&J(n).type===`image`?e(s,2):!J(n).selected&&J(n).type===`text`&&e(c,3)}),X(e,r)};Tr(i,e=>{J(n).actionIndex<=J(C)&&!J(ae)&&(J(n).visible||J(n).erasedAtIndex&&J(n).erasedAtIndex>J(C))&&e(a)}),X(e,r)}),X(e,n)};Tr(r,e=>{J(t).type===`stroke`||J(t).type===`image`||J(t).type===`text`?e(i):J(t).type===`multiplestroke`&&J(t).multipath&&e(a,1)}),X(e,n)};Tr(a,e=>{J(t).actionIndex<=J(C)&&!J(ae)&&(J(t).visible||J(t).erasedAtIndex&&J(t).erasedAtIndex>J(C))&&e(o)}),X(e,i)});var r=Yt(n),i=e=>{var t=fr(),n=Jt(t),r=e=>{var t=$i();W(()=>{Z(t,`x`,J(j)),Z(t,`y`,J(M)),Z(t,`width`,J(N)-J(j)),Z(t,`height`,J(P)-J(M))}),X(e,t)},i=e=>{var t=ea();W(()=>{Z(t,`x`,J(N)),Z(t,`y`,J(M)),Z(t,`width`,J(j)-J(N)),Z(t,`height`,J(P)-J(M))}),X(e,t)},a=e=>{var t=ta();W(()=>{Z(t,`x`,J(j)),Z(t,`y`,J(P)),Z(t,`width`,J(N)-J(j)),Z(t,`height`,J(M)-J(P))}),X(e,t)},o=e=>{var t=na();W(()=>{Z(t,`x`,J(N)),Z(t,`y`,J(P)),Z(t,`width`,J(j)-J(N)),Z(t,`height`,J(M)-J(P))}),X(e,t)};Tr(n,e=>{J(j)<=J(N)&&J(M)<=J(P)?e(r):J(j)>J(N)&&J(M)<J(P)?e(i,1):J(j)<J(N)&&J(M)>J(P)?e(a,2):e(o,-1)}),X(e,t)};Tr(r,e=>{g()===`select`&&e(i)}),Se(t),X(e,t)};return Tr(Ge,e=>{J(T)&&e(Ke)}),Se(We),Se(Ue),W(()=>{Br(R,`display:${_()===`yes`?`block`:`none`}`),hr(He,`${J(te)??``} b: ${J(ne)??``}`),Br(We,`background-color:${l()??``};cursor:${J(w)===!0?`move`:`default`}`)}),nr(`pointerdown`,We,Le),nr(`pointermove`,We,Re),nr(`pointerup`,We,ze),X(e,Ve),Ne(Be)}rr([`pointerdown`,`pointermove`,`pointerup`]),customElements.define(`hb-stylus-paper`,Qr(oa,{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`})),e.Component=oa})(this[`stylus-paper`]=this[`stylus-paper`]||{});
3
+ //# sourceMappingURL=main.iife.js.map