diff --git "a/static/_app/immutable/components/pages/_page.svelte-5dd8964a.js" "b/static/_app/immutable/components/pages/_page.svelte-5dd8964a.js"
deleted file mode 100644--- "a/static/_app/immutable/components/pages/_page.svelte-5dd8964a.js"
+++ /dev/null
@@ -1,9 +0,0 @@
-import{S as De,i as $e,s as ze,B as Cr,C as Ur,D as Mr,E as Dr,f as H,t as q,H as $r,I as zr,J as Zt,k as te,K as Kt,a as ce,q as Ee,l as ne,m as Z,L as Ht,h as D,c as ue,r as ke,n as P,b as ae,F as M,u as Vt,A as me,v as Oe,w as Ie,x as Se,y as Pe,G as fe,o as Rn,M as se,N as yn,O as ut,P as Fr,Q as Wn,R as oo,T as so,U as ao,V as lo,W as co,g as Ve,d as Be,X as uo,e as Ce,Y as fo,Z as ho,_ as po}from"../../chunks/index-082e1333.js";import{w as Te}from"../../chunks/index-a187b223.js";var _o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ae={},N={};Object.defineProperty(N,"__esModule",{value:!0});var mo=Object.defineProperty,go=Object.defineProperties,vo=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,Kr=Object.prototype.hasOwnProperty,Hr=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?mo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,St=(e,t)=>{for(var n in t||(t={}))Kr.call(t,n)&&Zn(e,n,t[n]);if(Bt)for(var n of Bt(t))Hr.call(t,n)&&Zn(e,n,t[n]);return e},Qt=(e,t)=>go(e,vo(t)),yo=(e,t)=>{var n={};for(var r in e)Kr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Bt)for(var r of Bt(e))t.indexOf(r)<0&&Hr.call(e,r)&&(n[r]=e[r]);return n},wo=(e,t,n)=>new Promise((r,i)=>{var o=l=>{try{a(n.next(l))}catch(c){i(c)}},s=l=>{try{a(n.throw(l))}catch(c){i(c)}},a=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(e,t)).next())});function bo(e,t=e){}function Eo(e,t,n=t){}function ko(e){}function xo(e,t){}function Je(e,t){throw new Error(t)}function V(e,t="Expected value to be non-nullable"){return e}var Vr=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.BROADCAST_EVENT=103]="BROADCAST_EVENT",e[e.FETCH_STORAGE=200]="FETCH_STORAGE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(Vr||{}),Br=(e=>(e[e.INIT=0]="INIT",e[e.SET_PARENT_KEY=1]="SET_PARENT_KEY",e[e.CREATE_LIST=2]="CREATE_LIST",e[e.UPDATE_OBJECT=3]="UPDATE_OBJECT",e[e.CREATE_OBJECT=4]="CREATE_OBJECT",e[e.DELETE_CRDT=5]="DELETE_CRDT",e[e.DELETE_OBJECT_KEY=6]="DELETE_OBJECT_KEY",e[e.CREATE_MAP=7]="CREATE_MAP",e[e.CREATE_REGISTER=8]="CREATE_REGISTER",e))(Br||{}),Xr=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(Xr||{});function Oo(e){return e.type===0&&!qr(e)}function qr(e){return e.parentId!==void 0&&e.parentKey!==void 0}var Yr=(e=>(e[e.UPDATE_PRESENCE=100]="UPDATE_PRESENCE",e[e.USER_JOINED=101]="USER_JOINED",e[e.USER_LEFT=102]="USER_LEFT",e[e.BROADCASTED_EVENT=103]="BROADCASTED_EVENT",e[e.ROOM_STATE=104]="ROOM_STATE",e[e.INITIAL_STORAGE_STATE=200]="INITIAL_STORAGE_STATE",e[e.UPDATE_STORAGE=201]="UPDATE_STORAGE",e))(Yr||{});function Io(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var Gr=(e=>(e[e.CLOSE_ABNORMAL=1006]="CLOSE_ABNORMAL",e[e.INVALID_MESSAGE_FORMAT=4e3]="INVALID_MESSAGE_FORMAT",e[e.NOT_ALLOWED=4001]="NOT_ALLOWED",e[e.MAX_NUMBER_OF_MESSAGES_PER_SECONDS=4002]="MAX_NUMBER_OF_MESSAGES_PER_SECONDS",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS=4003]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS",e[e.MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP=4004]="MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP",e[e.MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM=4005]="MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM",e[e.CLOSE_WITHOUT_RETRY=4999]="CLOSE_WITHOUT_RETRY",e))(Gr||{}),ot=32,Nn=126;function Ne(e,t){return e!==void 0&&t!==void 0?Xt(Jr(dt(e),dt(t))):e!==void 0?Po(e):t!==void 0?So(t):Xt([ot+1])}function So(e){const t=[],n=dt(e);for(let r=0;r<n.length;r++){const i=n[r];if(i<=ot+1){if(t.push(ot),n.length-1===r){t.push(Nn);break}}else{t.push(i-1);break}}return Xt(t)}function Po(e){const t=[],n=dt(e);for(let r=0;r<n.length;r++){const i=n[r];if(i===Nn){if(t.push(i),n.length-1===r){t.push(ot+1);break}}else{t.push(i+1);break}}return Xt(t)}function Jr(e,t){let n=0;const r=[];for(;;){const i=e[n]||ot,o=t[n]||Nn;if(i>o)throw new Error(`Impossible to generate position between ${e} and ${t}`);if(i===o){r.push(i),n++;continue}if(o-i===1){r.push(i),r.push(...Jr(e.slice(n+1),[]));break}const s=o+i>>1;r.push(s);break}return r}function dt(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}function Xt(e){return String.fromCharCode(...e)}function jr(e,t){const n=dt(e),r=dt(t),i=Math.max(n.length,r.length);for(let o=0;o<i;o++){const s=n[o]===void 0?ot:n[o],a=r[o]===void 0?ot:r[o];if(s!==a)return s-a}throw new Error(`Impossible to compare similar position "${e}" and "${t}"`)}function Qn(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var er=Object.freeze({type:"NoParent"});function tr(e){return Object.freeze({type:"Orphaned",oldKey:e})}var en=class{constructor(){this._parent=er}_getParentKeyOrThrow(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":throw new Error("Parent key is missing");case"Orphaned":return this.parent.oldKey;default:return Je(this.parent,"Unknown state")}}get _pool(){return this.__pool}get roomId(){return this.__pool?this.__pool.roomId:null}get _id(){return this.__id}get parent(){return this._parent}get _parentNode(){switch(this.parent.type){case"HasParent":return this.parent.node;case"NoParent":return null;case"Orphaned":return null;default:return Je(this.parent,"Unknown state")}}get _parentKey(){switch(this.parent.type){case"HasParent":return this.parent.key;case"NoParent":return null;case"Orphaned":return this.parent.oldKey;default:return Je(this.parent,"Unknown state")}}_apply(e,t){switch(e.type){case 5:return this.parent.type==="HasParent"?this.parent.node._detachChild(this):{modified:!1}}return{modified:!1}}_setParentLink(e,t){switch(this.parent.type){case"HasParent":if(this.parent.node!==e)throw new Error("Cannot set parent: node already has a parent");this._parent=Qn(e,t);return;case"Orphaned":case"NoParent":{this._parent=Qn(e,t);return}default:return Je(this.parent,"Unknown state")}}_attach(e,t){if(this.__id||this.__pool)throw new Error("Cannot attach node: already attached");t.addNode(e,this),this.__id=e,this.__pool=t}_detach(){switch(this.__pool&&this.__id&&this.__pool.deleteNode(this.__id),this.parent.type){case"HasParent":{this._parent=tr(this.parent.key);break}case"NoParent":{this._parent=er;break}case"Orphaned":{this._parent=tr(this.parent.oldKey);break}default:Je(this.parent,"Unknown state")}this.__pool=void 0}invalidate(){this._cachedImmutable!==void 0&&(this._cachedImmutable=void 0,this.parent.type==="HasParent"&&this.parent.node.invalidate())}toImmutable(){return this._cachedImmutable===void 0&&(this._cachedImmutable=this._toImmutable()),this._cachedImmutable}},Ye=class extends en{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new Ye(t.data);return i._attach(e,r),i}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize register if parentId or parentKey is undefined");return[{type:8,opId:n==null?void 0:n.generateOpId(),id:this._id,parentId:e,parentKey:t,data:this.data}]}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveRegister if parent is missing");return{type:3,parentId:V(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key,data:this.data}}_attachChild(e){throw new Error("Method not implemented.")}_detachChild(e){throw new Error("Method not implemented.")}_apply(e,t){return super._apply(e,t)}_toImmutable(){return this._data}},We=class extends en{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=ft(n[1]);r._setParentLink(this,n[0]),t.push([n[0],r])}this._map=new Map(t)}else this._map=new Map}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:7,parentId:e,parentKey:t};r.push(i);for(const[o,s]of this._map)r.push(...s._toOps(this._id,o,n));return r}static _deserialize([e,t],n,r){const i=new We;i._attach(e,r);const o=n.get(e);if(o===void 0)return i;for(const[s,a]of o){const l=Qr([s,a],n,r);l._setParentLink(i,a.parentKey),i._map.set(a.parentKey,l),i.invalidate()}return i}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)le(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,parentKey:r,opId:i}=e,o=r,s=vt(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const c=this.unacknowledgedSet.get(o);if(c===i)return this.unacknowledgedSet.delete(o),{modified:!1};if(c!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(o);const a=this._map.get(o);let l;if(a){const c=V(this._id);l=a._toOps(c,o),a._detach()}else l=[{type:5,id:n}];return s._setParentLink(this,o),s._attach(n,this._pool),this._map.set(o,s),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[o]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=V(this._id),n=V(e._parentKey),r=e._toOps(t,n,this._pool);for(const[o,s]of this._map)s===e&&(this._map.delete(o),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveMap",updates:{[n]:{type:"delete"}}},reverse:r}}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveMap if parent is missing");return{type:2,parentId:V(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get(e){const t=this._map.get(e);if(t!==void 0)return rt(t)}set(e,t){const n=this._map.get(e);n&&n._detach();const r=ft(t);if(r._setParentLink(this,e),this._map.set(e,r),this.invalidate(),this._pool&&this._id){const i=this._pool.generateId();r._attach(i,this._pool);const o=new Map;o.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const s=r._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,V(s[0].opId)),this._pool.dispatch(r._toOps(this._id,e,this._pool),n?n._toOps(this._id,e):[{type:5,id:i}],o)}}get size(){return this._map.size}has(e){return this._map.has(e)}delete(e){const t=this._map.get(e);if(t===void 0)return!1;if(t._detach(),this._map.delete(e),this.invalidate(),this._pool&&t._id){const n=V(this._id),r=new Map;r.set(n,{node:this,type:"LiveMap",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:t._id,opId:this._pool.generateOpId()}],t._toOps(n,e),r)}return!0}entries(){const e=this._map.entries();return{[Symbol.iterator](){return this},next(){const t=e.next();if(t.done)return{done:!0,value:void 0};const r=t.value[0],i=rt(t.value[1]);return{value:[r,i]}}}}[Symbol.iterator](){return this.entries()}keys(){return this._map.keys()}values(){const e=this._map.values();return{[Symbol.iterator](){return this},next(){const t=e.next();return t.done?{done:!0,value:void 0}:{value:rt(t.value)}}}}forEach(e){for(const t of this)e(t[1],t[0],this)}toImmutable(){return super.toImmutable()}_toImmutable(){const e=new Map;for(const[t,n]of this._map)e.set(t,n.toImmutable());return Cn(e)}},Ze=class extends en{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&le(n)&&n._setParentLink(this,t)}this._map=new Map(Object.entries(e))}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=n==null?void 0:n.generateOpId(),i=[],o=e!==void 0&&t!==void 0?{type:4,id:this._id,opId:r,parentId:e,parentKey:t,data:{}}:{type:4,id:this._id,opId:r,data:{}};i.push(o);for(const[s,a]of this._map)le(a)?i.push(...a._toOps(this._id,s,n)):o.data[s]=a;return i}static _deserialize([e,t],n,r){const i=new Ze(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(V(e._id));if(r===void 0)return e;for(const[i,o]of r){const s=Lo([i,o],t,n);Mt(s)&&s._setParentLink(e,o.parentKey),e._map.set(o.parentKey,s),e.invalidate()}return e}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)le(r)&&r._attach(t.generateId(),t)}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:n,opId:r,parentKey:i}=e,o=Wr(e);if(this._pool.getNode(n)!==void 0)return this._propToLastUpdate.get(i)===r&&this._propToLastUpdate.delete(i),{modified:!1};if(t===0)this._propToLastUpdate.set(i,V(r));else if(this._propToLastUpdate.get(i)!==void 0)return this._propToLastUpdate.get(i)===r?(this._propToLastUpdate.delete(i),{modified:!1}):{modified:!1};const s=V(this._id),a=this._map.get(i);let l;return le(a)?(l=a._toOps(s,i),a._detach()):a===void 0?l=[{type:6,id:s,key:i}]:l=[{type:3,id:s,data:{[i]:a}}],this._map.set(i,o),this.invalidate(),Mt(o)&&(o._setParentLink(this,i),o._attach(n,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}}}}}_detachChild(e){if(e){const t=V(this._id),n=V(e._parentKey),r=e._toOps(t,n,this._pool);for(const[o,s]of this._map)s===e&&(this._map.delete(o),this.invalidate());return e._detach(),{modified:{node:this,type:"LiveObject",updates:{[n]:{type:"delete"}}},reverse:r}}return{modified:!1}}_detach(){super._detach();for(const e of this._map.values())le(e)&&e._detach()}_apply(e,t){return e.type===3?this._applyUpdate(e,t):e.type===6?this._applyDeleteObjectKey(e):super._apply(e,t)}_serialize(){const e={};for(const[t,n]of this._map)le(n)||(e[t]=n);return this.parent.type==="HasParent"&&this.parent.node._id?{type:0,parentId:this.parent.node._id,parentKey:this.parent.key,data:e}:{type:0,data:e}}_applyUpdate(e,t){let n=!1;const r=V(this._id),i=[],o={type:3,id:r,data:{}};i.push(o);for(const a in e.data){const l=this._map.get(a);le(l)?(i.push(...l._toOps(r,a)),l._detach()):l!==void 0?o.data[a]=l:l===void 0&&i.push({type:6,id:r,key:a})}const s={};for(const a in e.data){const l=e.data[a];if(l===void 0)continue;if(t)this._propToLastUpdate.set(a,V(e.opId));else if(this._propToLastUpdate.get(a)===void 0)n=!0;else if(this._propToLastUpdate.get(a)===e.opId){this._propToLastUpdate.delete(a);continue}else continue;const c=this._map.get(a);le(c)&&c._detach(),n=!0,s[a]={type:"update"},this._map.set(a,l),this.invalidate()}return Object.keys(o.data).length!==0&&i.unshift(o),n?{modified:{node:this,type:"LiveObject",updates:s},reverse:i}:{modified:!1}}_applyDeleteObjectKey(e){const t=e.key;if(this._map.has(t)===!1)return{modified:!1};if(this._propToLastUpdate.get(t)!==void 0)return{modified:!1};const n=this._map.get(t),r=V(this._id);let i=[];return le(n)?(i=n._toOps(r,e.key),n._detach()):n!==void 0&&(i=[{type:3,id:r,data:{[t]:n}}]),this._map.delete(t),this.invalidate(),{modified:{node:this,type:"LiveObject",updates:{[e.key]:{type:"delete"}}},reverse:i}}toObject(){return zo(this._map)}set(e,t){this.update({[e]:t})}get(e){return this._map.get(e)}delete(e){const t=e,n=this._map.get(t);if(n===void 0)return;if(this._pool===void 0||this._id===void 0){le(n)&&n._detach(),this._map.delete(t),this.invalidate();return}let r;le(n)?(n._detach(),r=n._toOps(this._id,t)):r=[{type:3,data:{[t]:n},id:this._id}],this._map.delete(t),this.invalidate();const i=new Map;i.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:t,id:this._id,opId:this._pool.generateOpId()}],r,i)}update(e){if(this._pool===void 0||this._id===void 0){for(const l in e){const c=e[l];if(c===void 0)continue;const u=this._map.get(l);le(u)&&u._detach(),le(c)&&c._setParentLink(this,l),this._map.set(l,c),this.invalidate()}return}const t=[],n=[],r=this._pool.generateOpId(),i={},o={id:this._id,type:3,data:{}},s={};for(const l in e){const c=e[l];if(c===void 0)continue;const u=this._map.get(l);if(le(u)?(n.push(...u._toOps(this._id,l)),u._detach()):u===void 0?n.push({type:6,id:this._id,key:l}):o.data[l]=u,le(c)){c._setParentLink(this,l),c._attach(this._pool.generateId(),this._pool);const h=c._toOps(this._id,l,this._pool),p=h.find(y=>y.parentId===this._id);p&&this._propToLastUpdate.set(l,V(p.opId)),t.push(...h)}else i[l]=c,this._propToLastUpdate.set(l,r);this._map.set(l,c),this.invalidate(),s[l]={type:"update"}}Object.keys(o.data).length!==0&&n.unshift(o),Object.keys(i).length!==0&&t.unshift({opId:r,id:this._id,type:3,data:i});const a=new Map;a.set(this._id,{node:this,type:"LiveObject",updates:s}),this._pool.dispatch(t,n,a)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=Mt(n)?n.toImmutable():n;return e}},Cn=e=>e;function To(e){return e.filter(t=>t!=null)}function Ao(e){const t=St({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function vt(e){return ft(Wr(e))}function Wr(e){switch(e.type){case 8:return e.data;case 4:return new Ze(e.data);case 7:return new We;case 2:return new Qe;default:return Je(e,"Unknown creation Op")}}function Zr(e,t){return e===t?!0:e.parent.type==="HasParent"?Zr(e.parent.node,t):!1}function Qr([e,t],n,r){switch(t.type){case 0:return Ze._deserialize([e,t],n,r);case 1:return Qe._deserialize([e,t],n,r);case 2:return We._deserialize([e,t],n,r);case 3:return Ye._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function Lo([e,t],n,r){switch(t.type){case 0:return Ze._deserialize([e,t],n,r);case 1:return Qe._deserialize([e,t],n,r);case 2:return We._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function Mt(e){return ei(e)||Ro(e)||ti(e)}function le(e){return Mt(e)||No(e)}function ei(e){return e instanceof Qe}function Ro(e){return e instanceof We}function ti(e){return e instanceof Ze}function No(e){return e instanceof Ye}function rt(e){return e instanceof Ye?e.data:e instanceof Qe||e instanceof We||e instanceof Ze?e:Je(e,"Unknown AbstractCrdt")}function ft(e){return e instanceof Ze||e instanceof We||e instanceof Qe?e:new Ye(e)}function Co(e,t){const n=[];return e.forEach((r,i)=>{t.get(i)||n.push({type:5,id:i})}),t.forEach((r,i)=>{const o=e.get(i);if(o)r.type===0&&(o.type!==0||JSON.stringify(r.data)!==JSON.stringify(o.data))&&n.push({type:3,id:i,data:r.data}),r.parentKey!==o.parentKey&&n.push({type:1,id:i,parentKey:V(r.parentKey,"Parent key must not be missing")});else switch(r.type){case 3:n.push({type:8,id:i,parentId:r.parentId,parentKey:r.parentKey,data:r.data});break;case 1:n.push({type:2,id:i,parentId:r.parentId,parentKey:r.parentKey});break;case 0:n.push(r.parentId?{type:4,id:i,parentId:r.parentId,parentKey:r.parentKey,data:r.data}:{type:4,id:i,data:r.data});break;case 2:n.push({type:7,id:i,parentId:r.parentId,parentKey:r.parentKey});break}}),n}function Uo(e,t){const n=e.updates;for(const[r,i]of ri(t.updates))n[r]=i;return Qt(St({},t),{updates:n})}function Mo(e,t){const n=e.updates;for(const[r,i]of ri(t.updates))n[r]=i;return Qt(St({},t),{updates:n})}function Do(e,t){const n=e.updates;return Qt(St({},t),{updates:n.concat(t.updates)})}function $o(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?Uo(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?Mo(e,t):e.type==="LiveList"&&t.type==="LiveList"?Do(e,t):t:t}function nr(e){const t=typeof e;return e==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(e)||Un(e)}function Un(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ni(e,t=""){if(!nr)return{path:t||"root",value:e};if(typeof e!="object"||e===null)return!1;for(const[n,r]of Object.entries(e)){const i=t?t+"."+n:n;if(!nr(r))return{path:i,value:r};if(typeof r=="object"){const o=ni(r,i);if(o)return o}}return!1}function zo(e){const t={};for(const[n,r]of e)t[n]=r;return t}function ri(e){return Object.entries(e)}function ii(e){try{return JSON.parse(e)}catch{return}}function oi(e){try{const t=e.replace(/-/g,"+").replace(/_/g,"/");return decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""))}catch{return atob(e)}}function Fo(e,t){return jr(e._getParentKeyOrThrow(),t._getParentKeyOrThrow())}var Qe=class extends en{constructor(e=[]){super(),this._items=[],this._implicitlyDeletedItems=new WeakSet,this._unacknowledgedSets=new Map;let t;for(let n=0;n<e.length;n++){const r=Ne(t),i=ft(e[n]);i._setParentLink(this,r),this._items.push(i),t=r}}static _deserialize([e],t,n){const r=new Qe;r._attach(e,n);const i=t.get(e);if(i===void 0)return r;for(const[o,s]of i){const a=Qr([o,s],t,n);a._setParentLink(r,s.parentKey),r._insertAndSort(a)}return r}_toOps(e,t,n){if(this._id===void 0)throw new Error("Cannot serialize item is not attached");const r=[],i={id:this._id,opId:n==null?void 0:n.generateOpId(),type:2,parentId:e,parentKey:t};r.push(i);for(const o of this._items)r.push(...o._toOps(this._id,o._getParentKeyOrThrow(),n));return r}_insertAndSort(e){this._items.push(e),this._sortItems()}_sortItems(){this._items.sort(Fo),this.invalidate()}_indexOfPosition(e){return this._items.findIndex(t=>t._getParentKeyOrThrow()===e)}_attach(e,t){super._attach(e,t);for(const n of this._items)n._attach(t.generateId(),t)}_detach(){super._detach();for(const e of this._items)e._detach()}_applySetRemote(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const{id:t,parentKey:n}=e,r=vt(e);r._attach(t,this._pool),r._setParentLink(this,n);const i=e.deletedId,o=this._indexOfPosition(n);if(o!==-1){const s=this._items[o];if(s._id===i)return s._detach(),this._items[o]=r,{modified:j(this,[lt(o,r)]),reverse:[]};{this._implicitlyDeletedItems.add(s),this._items[o]=r;const a=[lt(o,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&a.push(l),{modified:j(this,a),reverse:[]}}}else{const s=[],a=this._detachItemAssociatedToSetOperation(e.deletedId);return a&&s.push(a),this._insertAndSort(r),s.push(Re(this._indexOfPosition(n),r)),{reverse:[],modified:j(this,s)}}}_applySetAck(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=[],n=this._detachItemAssociatedToSetOperation(e.deletedId);n&&t.push(n);const r=this._unacknowledgedSets.get(e.parentKey);if(r!==void 0){if(r!==e.opId)return t.length===0?{modified:!1}:{modified:j(this,t),reverse:[]};this._unacknowledgedSets.delete(e.parentKey)}const i=this._indexOfPosition(e.parentKey),o=this._items.find(s=>s._id===e.id);if(o!==void 0){if(o._parentKey===e.parentKey)return{modified:t.length>0?j(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(At(i)));const s=this._items.indexOf(o);o._setParentLink(this,e.parentKey),this._sortItems();const a=this._items.indexOf(o);return a!==s&&t.push(et(s,a,o)),{modified:t.length>0?j(this,t):!1,reverse:[]}}else{const s=this._pool.getNode(e.id);if(s&&this._implicitlyDeletedItems.has(s)){s._setParentLink(this,e.parentKey),this._implicitlyDeletedItems.delete(s),this._insertAndSort(s);const a=this._items.indexOf(s);return{modified:j(this,[i===-1?Re(a,s):lt(a,s),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:a,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:j(this,[i===-1?Re(l,a):lt(l,a),...t]),reverse:[]}}}}_detachItemAssociatedToSetOperation(e){if(e===void 0||this._pool===void 0)return null;const t=this._pool.getNode(e);if(t===void 0)return null;const n=this._detachChild(t);return n.modified===!1?null:n.modified.updates[0]}_applyRemoteInsert(e){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");const t=e.parentKey,n=this._indexOfPosition(t);n!==-1&&this._shiftItemPosition(n,t);const{newItem:r,newIndex:i}=this._createAttachItemAndSort(e,t);return{modified:j(this,[Re(i,r)]),reverse:[]}}_applyInsertAck(e){const t=this._items.find(i=>i._id===e.id),n=e.parentKey,r=this._indexOfPosition(n);if(t){if(t._parentKey===n)return{modified:!1};{const i=this._items.indexOf(t);r!==-1&&this._shiftItemPosition(r,n),t._setParentLink(this,n),this._sortItems();const o=this._indexOfPosition(n);return o===i?{modified:!1}:{modified:j(this,[et(i,o,t)]),reverse:[]}}}else{const i=V(this._pool).getNode(e.id);if(i&&this._implicitlyDeletedItems.has(i)){i._setParentLink(this,n),this._implicitlyDeletedItems.delete(i),this._insertAndSort(i);const o=this._indexOfPosition(n);return{modified:j(this,[Re(o,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:o,newIndex:s}=this._createAttachItemAndSort(e,n);return{modified:j(this,[Re(s,o)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=vt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};i._attach(n,V(this._pool)),i._setParentLink(this,r);const o=this._indexOfPosition(r);let s=r;if(o!==-1){const l=this._items[o]?this._items[o]._getParentKeyOrThrow():void 0,c=this._items[o+1]?this._items[o+1]._getParentKeyOrThrow():void 0;s=Ne(l,c),i._setParentLink(this,s)}this._insertAndSort(i);const a=this._indexOfPosition(s);return{modified:j(this,[Re(a,i)]),reverse:[{type:5,id:n}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=vt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,V(e.opId));const o=this._indexOfPosition(r);i._attach(n,V(this._pool)),i._setParentLink(this,r);const s=r;if(o!==-1){const a=this._items[o];a._detach(),this._items[o]=i;const l=a._toOps(V(this._id),r,this._pool);un(l,e.id);const c=[lt(o,i)],u=this._detachItemAssociatedToSetOperation(e.deletedId);return u&&c.push(u),{modified:j(this,c),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const a=this._indexOfPosition(s);return{reverse:[{type:5,id:n}],modified:j(this,[Re(a,i)])}}}_attachChild(e,t){if(this._pool===void 0)throw new Error("Can't attach child if managed pool is not present");let n;return e.intent==="set"?t===1?n=this._applySetRemote(e):t===2?n=this._applySetAck(e):n=this._applySetUndoRedo(e):t===1?n=this._applyRemoteInsert(e):t===2?n=this._applyInsertAck(e):n=this._applyInsertUndoRedo(e),n.modified!==!1&&this.invalidate(),n}_detachChild(e){if(e){const t=V(e._parentKey),n=e._toOps(V(this._id),t,this._pool),r=this._items.indexOf(e);return r===-1?{modified:!1}:(this._items.splice(r,1),this.invalidate(),e._detach(),{modified:j(this,[At(r)]),reverse:n})}return{modified:!1}}_applySetChildKeyRemote(e,t){var n;if(this._implicitlyDeletedItems.has(t)){this._implicitlyDeletedItems.delete(t),t._setParentLink(this,e),this._insertAndSort(t);const o=this._items.indexOf(t);return{modified:j(this,[Re(o,t)]),reverse:[]}}const r=t._parentKey;if(e===r)return{modified:!1};const i=this._indexOfPosition(e);if(i===-1){const o=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const s=this._items.indexOf(t);return s===o?{modified:!1}:{modified:j(this,[et(o,s,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Ne(e,(n=this._items[i+1])==null?void 0:n._getParentKeyOrThrow()));const o=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const s=this._items.indexOf(t);return s===o?{modified:!1}:{modified:j(this,[et(o,s,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=V(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const o=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),o!==-1&&this._items[o]._setParentLink(this,Ne(e,(n=this._items[o+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._insertAndSort(t),{modified:!1}}else{if(e===i)return{modified:!1};const o=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Ne(e,(r=this._items[s+1])==null?void 0:r._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return o===a?{modified:!1}:{modified:j(this,[et(o,a,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=V(t._parentKey),i=this._items.indexOf(t),o=this._indexOfPosition(e);o!==-1&&this._items[o]._setParentLink(this,Ne(e,(n=this._items[o+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const s=this._items.indexOf(t);return i===s?{modified:!1}:{modified:j(this,[et(i,s,t)]),reverse:[{type:1,id:V(t._id),parentKey:r}]}}_setChildKey(e,t,n){return n===1?this._applySetChildKeyRemote(e,t):n===2?this._applySetChildKeyAck(e,t):this._applySetChildKeyUndoRedo(e,t)}_apply(e,t){return super._apply(e,t)}_serialize(){if(this.parent.type!=="HasParent")throw new Error("Cannot serialize LiveList if parent is missing");return{type:1,parentId:V(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this._items.length}push(e){return this.insert(e,this.length)}insert(e,t){if(t<0||t>this._items.length)throw new Error(`Cannot insert list item at index "${t}". index should be between 0 and ${this._items.length}`);const n=this._items[t-1]?this._items[t-1]._getParentKeyOrThrow():void 0,r=this._items[t]?this._items[t]._getParentKeyOrThrow():void 0,i=Ne(n,r),o=ft(e);if(o._setParentLink(this,i),this._insertAndSort(o),this._pool&&this._id){const s=this._pool.generateId();o._attach(s,this._pool),this._pool.dispatch(o._toOps(this._id,i,this._pool),[{type:5,id:s}],new Map([[this._id,j(this,[Re(t,o)])]]))}}move(e,t){if(t<0)throw new Error("targetIndex cannot be less than 0");if(t>=this._items.length)throw new Error("targetIndex cannot be greater or equal than the list length");if(e<0)throw new Error("index cannot be less than 0");if(e>=this._items.length)throw new Error("index cannot be greater or equal than the list length");let n=null,r=null;e<t?(r=t===this._items.length-1?void 0:this._items[t+1]._getParentKeyOrThrow(),n=this._items[t]._getParentKeyOrThrow()):(r=this._items[t]._getParentKeyOrThrow(),n=t===0?void 0:this._items[t-1]._getParentKeyOrThrow());const i=Ne(n,r),o=this._items[e],s=o._getParentKeyOrThrow();if(o._setParentLink(this,i),this._sortItems(),this._pool&&this._id){const a=new Map([[this._id,j(this,[et(e,t,o)])]]);this._pool.dispatch([{type:1,id:V(o._id),opId:this._pool.generateOpId(),parentKey:i}],[{type:1,id:V(o._id),parentKey:s}],a)}}delete(e){if(e<0||e>=this._items.length)throw new Error(`Cannot delete list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const t=this._items[e];if(t._detach(),this._items.splice(e,1),this.invalidate(),this._pool){const n=t._id;if(n){const r=new Map;r.set(V(this._id),j(this,[At(e)])),this._pool.dispatch([{id:n,opId:this._pool.generateOpId(),type:5}],t._toOps(V(this._id),t._getParentKeyOrThrow()),r)}}}clear(){if(this._pool){const e=[],t=[],n=[];for(const i of this._items){i._detach();const o=i._id;o&&(e.push({type:5,id:o,opId:this._pool.generateOpId()}),t.push(...i._toOps(V(this._id),i._getParentKeyOrThrow())),n.push(At(0)))}this._items=[],this.invalidate();const r=new Map;r.set(V(this._id),j(this,n)),this._pool.dispatch(e,t,r)}else{for(const e of this._items)e._detach();this._items=[],this.invalidate()}}set(e,t){if(e<0||e>=this._items.length)throw new Error(`Cannot set list item at index "${e}". index should be between 0 and ${this._items.length-1}`);const n=this._items[e],r=n._getParentKeyOrThrow(),i=n._id;n._detach();const o=ft(t);if(o._setParentLink(this,r),this._items[e]=o,this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();o._attach(s,this._pool);const a=new Map;a.set(this._id,j(this,[lt(e,o)]));const l=o._toOps(this._id,r,this._pool);un(l,i),this._unacknowledgedSets.set(r,V(l[0].opId));const c=n._toOps(this._id,r,void 0);un(c,s),this._pool.dispatch(l,c,a)}}toArray(){return this._items.map(e=>rt(e))}every(e){return this.toArray().every(e)}filter(e){return this.toArray().filter(e)}find(e){return this.toArray().find(e)}findIndex(e){return this.toArray().findIndex(e)}forEach(e){return this.toArray().forEach(e)}get(e){if(!(e<0||e>=this._items.length))return rt(this._items[e])}indexOf(e,t){return this.toArray().indexOf(e,t)}lastIndexOf(e,t){return this.toArray().lastIndexOf(e,t)}map(e){return this._items.map((t,n)=>e(rt(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new Ko(this._items)}_createAttachItemAndSort(e,t){const n=vt(e);n._attach(e.id,V(this._pool)),n._setParentLink(this,t),this._insertAndSort(n);const r=this._indexOfPosition(t);return{newItem:n,newIndex:r}}_shiftItemPosition(e,t){var n;const r=Ne(t,this._items.length>e+1?(n=this._items[e+1])==null?void 0:n._getParentKeyOrThrow():void 0);this._items[e]._setParentLink(this,r)}toImmutable(){return super.toImmutable()}_toImmutable(){return this._items.map(t=>t.toImmutable())}},Ko=class{constructor(e){this._innerIterator=e[Symbol.iterator]()}[Symbol.iterator](){return this}next(){const e=this._innerIterator.next();return e.done?{done:!0,value:void 0}:{value:rt(e.value)}}};function j(e,t){return{node:e,type:"LiveList",updates:t}}function lt(e,t){return{index:e,type:"set",item:t instanceof Ye?t.data:t}}function At(e){return{index:e,type:"delete"}}function Re(e,t){return{index:e,type:"insert",item:t instanceof Ye?t.data:t}}function et(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof Ye?n.data:n}}function un(e,t){if(e.length===0)throw new Error("Internal error. Serialized LiveStructure should have at least 1 operation");const n=e[0];n.intent="set",n.deletedId=t}var Ho=["websocket:presence","websocket:storage","room:read","room:write","rooms:read","rooms:write"];function Vo(e){if(!Un(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function Bo(e){const t=Date.now()/1e3;return t>e.exp-300||t<e.iat+300}function Xo(e){return Ho.includes(e)}function si(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function ai(e){return typeof e.appId=="string"&&e.roomId===void 0&&si(e.scopes)}function Mn(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&si(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function qo(e){return ai(e)||Mn(e)}function Yo(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=ii(oi(t[1]));if(n&&Vo(n))return n;throw new Error("Authentication error: missing JWT metadata")}function Go(e){const t=Yo(e);if(t&&Mn(t))return yo(t,["maxConnections"]);throw new Error("Authentication error: we expected a room token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback")}function Jo(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Cn(e)}function li(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function ci(e){return Array.isArray(e)}function jo(e){return!li(e)&&!ci(e)}N.__spreadValues=St;N.__spreadProps=Qt;N.__async=wo;N.deprecate=bo;N.deprecateIf=Eo;N.throwUsageError=ko;N.errorIf=xo;N.assertNever=Je;N.nn=V;N.ClientMsgCode=Vr;N.OpCode=Br;N.CrdtType=Xr;N.isRootCrdt=Oo;N.isChildCrdt=qr;N.ServerMsgCode=Yr;N.isRoomEventName=Io;N.WebsocketCloseCodes=Gr;N.LiveRegister=Ye;N.makePosition=Ne;N.comparePosition=jr;N.LiveList=Qe;N.LiveMap=We;N.LiveObject=Ze;N.freeze=Cn;N.compact=To;N.compactObject=Ao;N.isSameNodeOrChildOf=Zr;N.isLiveNode=le;N.isLiveList=ei;N.isLiveObject=ti;N.getTreesDiffOperations=Co;N.mergeStorageUpdates=$o;N.isPlainObject=Un;N.findNonSerializableValue=ni;N.tryParseJson=ii;N.b64decode=oi;N.isTokenExpired=Bo;N.isScope=Xo;N.isAppOnlyAuthToken=ai;N.isRoomAuthToken=Mn;N.isAuthToken=qo;N.parseRoomAuthToken=Go;N.asArrayWithLegacyMethods=Jo;N.isJsonScalar=li;N.isJsonArray=ci;N.isJsonObject=jo;Object.defineProperty(Ae,"__esModule",{value:!0});var T=N;function He(){const e=new Set,t=new Set;function n(s){return t.add(s),()=>t.delete(s)}function r(s){return e.add(s),()=>e.delete(s)}function i(s){e.forEach(a=>a(s)),e.clear(),t.forEach(a=>a(s))}function o(){e.clear(),t.clear()}return{notify:i,subscribe:n,subscribeOnce:r,clear:o,observable:{subscribe:n,subscribeOnce:r}}}function ui(e,t){let n=!1;const r=T.__spreadValues.call(void 0,{},e);return Object.keys(t).forEach(i=>{const o=i,s=t[o];r[o]!==s&&(s===void 0?delete r[o]:r[o]=s,n=!0)}),n?r:e}var tn=class{constructor(){this._ev=He()}get didInvalidate(){return this._ev.observable}invalidate(){this._cache!==void 0&&(this._cache=void 0,this._ev.notify())}get current(){var e;return(e=this._cache)!=null?e:this._cache=this._toImmutable()}},Wo=class extends tn{constructor(e){super(),this._me=T.freeze.call(void 0,T.compactObject.call(void 0,e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=ui(t,e);t!==n&&(this._me=T.freeze.call(void 0,n),this.invalidate())}};function Zo(e,t){return T.freeze.call(void 0,T.compactObject.call(void 0,T.__spreadProps.call(void 0,T.__spreadValues.call(void 0,{},e),{presence:t})))}var Qo=class extends tn{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=T.compact.call(void 0,Object.keys(this._presences).map(t=>this.getUser(Number(t))));return T.asArrayWithLegacyMethods.call(void 0,e)}clearOthers(){this._connections={},this._presences={},this._users={},this.invalidate()}_getUser(e){const t=this._connections[e],n=this._presences[e];if(t!==void 0&&n!==void 0)return Zo(t,n)}getUser(e){const t=this._users[e];if(t)return t;const n=this._getUser(e);if(n)return this._users[e]=n,n}_invalidateUser(e){this._users[e]!==void 0&&delete this._users[e],this.invalidate()}setConnection(e,t,n){this._connections[e]=T.freeze.call(void 0,{connectionId:e,id:t,info:n}),this._presences[e]!==void 0&&this._invalidateUser(e)}removeConnection(e){delete this._connections[e],delete this._presences[e],this._invalidateUser(e)}setOther(e,t){this._presences[e]=T.freeze.call(void 0,T.compactObject.call(void 0,t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=ui(n,t);n!==r&&(this._presences[e]=T.freeze.call(void 0,r),this._invalidateUser(e))}},es=class extends tn{constructor(e){super(),this._value=T.freeze.call(void 0,T.compactObject.call(void 0,e))}_toImmutable(){return this._value}set(e){this._value=T.freeze.call(void 0,e),this.invalidate()}},ts=class extends tn{constructor(e,t){super(),this._refs=e,this._refs.forEach(n=>{n.didInvalidate.subscribe(()=>this.invalidate())}),this._transform=t}_toImmutable(){return this._transform(this._refs[0].current,this._refs[1].current)}},fn=[250,500,1e3,2e3,4e3,8e3,1e4],hn=[2e3,3e4,6e4,3e5],ns=3e4,rs=2e3;function is(e){let t=0;return()=>`${e}:${t++}`}function dn(e){return e.state==="open"||e.state==="connecting"}function os(e,t,n){var r;const i=f=>f(),o=(r=t.unstable_batchedUpdates)!=null?r:i,s={roomId:t.roomId,getNode:f=>e.nodes.get(f),addNode:(f,m)=>void e.nodes.set(f,m),deleteNode:f=>void e.nodes.delete(f),generateId:()=>`${b()}:${e.clock++}`,generateOpId:()=>`${b()}:${e.opClock++}`,dispatch(f,m,v){const k=e.activeBatch;k?(k.ops.push(...f),v.forEach((S,ee)=>{k.updates.storageUpdates.set(ee,T.mergeStorageUpdates.call(void 0,k.updates.storageUpdates.get(ee),S))}),k.reverseOps.push(...m)):o(()=>{O(m,i),e.redoStack=[],Yn(f),C({storageUpdates:v},i)})}},a={customEvent:He(),me:He(),others:He(),error:He(),connection:He(),storage:He(),history:He(),storageDidLoad:He()},l=n||{authenticate(f,m){const v=e.token,k=v!==null&&T.parseRoomAuthToken.call(void 0,v);if(k&&!T.isTokenExpired.call(void 0,k)){const S=m(v);L(k,S)}else return f(t.roomId).then(({token:S})=>{if(e.connection.current.state!=="authenticating")return;const ee=T.parseRoomAuthToken.call(void 0,S),J=m(S);L(ee,J),e.token=S}).catch(S=>Q())},send(f){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(f))},delayFlush(f){return setTimeout(be,f)},startHeartbeatInterval(){return setInterval(de,ns)},schedulePongTimeout(){return setTimeout(we,rs)},scheduleReconnect(f){return setTimeout(R,f)}},c=new ts([e.connection,e.me],(f,m)=>dn(f)?{connectionId:f.id,id:f.userId,info:f.userInfo,presence:m}:null);function u(f,m){if(f.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?p(f.items,m):e.root=y(f.items);for(const v in e.initialStorage)e.root.get(v)===void 0&&e.root.set(v,e.initialStorage[v])}function h(f){const m=new Map;let v=null;for(const[k,S]of f)if(T.isRootCrdt.call(void 0,S))v=[k,S];else{const ee=[k,S],J=m.get(S.parentId);J!==void 0?J.push(ee):m.set(S.parentId,[ee])}if(v===null)throw new Error("Root can't be null");return[v,m]}function p(f,m){if(!e.root)return;const v=new Map;e.nodes.forEach((ee,J)=>{v.set(J,ee._serialize())});const k=T.getTreesDiffOperations.call(void 0,v,new Map(f)),S=A(k,!1);C(S.updates,m)}function y(f){const[m,v]=h(f);return T.LiveObject._deserialize(m,v,s)}function E(f,m){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(f),I(m)}function O(f,m){e.pausedHistory!==null?e.pausedHistory.unshift(...f):E(f,m)}function C({storageUpdates:f=new Map,presence:m=!1,others:v=[]},k){k(()=>{if(v.length>0){const S=e.others.current;for(const ee of v)a.others.notify({others:S,event:ee})}if(m&&a.me.notify(e.me.current),f.size>0){const S=Array.from(f.values());a.storage.notify(S)}})}function b(){const f=e.connection.current;if(dn(f))return f.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function A(f,m){const v={reverse:[],updates:{storageUpdates:new Map,presence:!1}},k=new Set;for(const S of f)if(S.type==="presence"){const ee={type:"presence",data:{}};for(const J in S.data)ee.data[J]=e.me.current[J];if(e.me.patch(S.data),e.buffer.me===null)e.buffer.me={type:"partial",data:S.data};else for(const J in S.data)e.buffer.me.data[J]=S.data[J];v.reverse.unshift(ee),v.updates.presence=!0}else{let ee;S.opId||(S.opId=s.generateOpId()),m?ee=0:ee=e.offlineOperations.delete(T.nn.call(void 0,S.opId))?2:1;const J=G(S,ee);if(J.modified){const cn=J.modified.node.parent.type==="HasParent"?T.nn.call(void 0,J.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!cn||!k.has(cn))&&(v.updates.storageUpdates.set(T.nn.call(void 0,J.modified.node._id),T.mergeStorageUpdates.call(void 0,v.updates.storageUpdates.get(T.nn.call(void 0,J.modified.node._id)),J.modified)),v.reverse.unshift(...J.reverse)),(S.type===2||S.type===7||S.type===4)&&k.add(T.nn.call(void 0,J.modified.node._id))}}return v}function G(f,m){switch(f.type){case 6:case 3:case 5:{const v=e.nodes.get(f.id);return v===void 0?{modified:!1}:v._apply(f,m===0)}case 1:{const v=e.nodes.get(f.id);return v===void 0?{modified:!1}:v.parent.type==="HasParent"&&T.isLiveList.call(void 0,v.parent.node)?v.parent.node._setChildKey(f.parentKey,v,m):{modified:!1}}case 4:case 2:case 7:case 8:{if(f.parentId===void 0)return{modified:!1};const v=e.nodes.get(f.parentId);return v===void 0?{modified:!1}:v._attachChild(f,m)}}}function re(f,m){return a.storage.subscribe(v=>{const k=v.filter(S=>T.isSameNodeOrChildOf.call(void 0,S.node,f));k.length>0&&m(k)})}function $(f,m){return a.storage.subscribe(v=>{for(const k of v)k.node._id===f._id&&m(k.node)})}function F(f,m,v){if(typeof f=="string"&&T.isRoomEventName.call(void 0,f)){if(typeof m!="function")throw new Error("Second argument must be a callback function");const k=m;switch(f){case"event":return a.customEvent.subscribe(k);case"my-presence":return a.me.subscribe(k);case"others":{const S=k;return a.others.subscribe(({others:ee,event:J})=>S(ee,J))}case"error":return a.error.subscribe(k);case"connection":return a.connection.subscribe(k);case"storage":return a.storage.subscribe(k);case"history":return a.history.subscribe(k);default:return T.assertNever.call(void 0,f,"Unknown event")}}if(m===void 0||typeof f=="function")if(typeof f=="function"){const k=f;return a.storage.subscribe(k)}else throw new Error("Please specify a listener callback");if(T.isLiveNode.call(void 0,f)){const k=f;return v!=null&&v.isDeep?re(k,m):$(k,m)}throw new Error(`"${f}" is not a valid event name`)}function _(){return e.connection.current.state}function R(){var f,m,v,k;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return null;const S=us(t.authentication,(m=(f=t.polyfills)==null?void 0:f.fetch)!=null?m:t.fetchPolyfill),ee=cs(t.liveblocksServer,(k=(v=t.polyfills)==null?void 0:v.WebSocket)!=null?k:t.WebSocketPolyfill);ie({state:"authenticating"},o),l.authenticate(S,ee)}function w(f,m){const v={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const k in f){const S=f[k];S!==void 0&&(e.buffer.me.data[k]=S,v[k]=e.me.current[k])}e.me.patch(f),e.activeBatch?(m!=null&&m.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:v}),e.activeBatch.updates.presence=!0):(be(),o(()=>{m!=null&&m.addToHistory&&O([{type:"presence",data:v}],i),C({presence:!0},i)}))}function L(f,m){m.addEventListener("message",B),m.addEventListener("open",_e),m.addEventListener("close",Y),m.addEventListener("error",he),ie({state:"connecting",id:f.actor,userInfo:f.info,userId:f.id},o),e.idFactory=is(f.actor),e.socket=m}function Q(f){e.token=null,ie({state:"unavailable"},o),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(oe())}function X(f){f==="visible"&&e.connection.current.state==="open"&&de()}function ve(f){if(f.targetActor!==void 0){const v=e.others.getUser(f.actor);e.others.setOther(f.actor,f.data);const k=e.others.getUser(f.actor);if(v===void 0&&k!==void 0)return{type:"enter",user:k}}else e.others.patchOther(f.actor,f.data);const m=e.others.getUser(f.actor);if(m)return{type:"update",updates:f.data,user:m}}function d(f){const m=e.others.getUser(f.actor);return m?(e.others.removeConnection(f.actor),{type:"leave",user:m}):null}function x(f){for(const m in f.users){const v=f.users[m],k=Number(m);e.others.setConnection(k,v.id,v.info)}return{type:"reset"}}function g(){e.connection.current.state==="unavailable"&&at()}function I(f){f(()=>{a.history.notify({canUndo:Jn(),canRedo:jn()})})}function U(f){e.others.setConnection(f.actor,f.id,f.info),e.buffer.messages.push({type:100,data:e.me.current,targetActor:f.actor}),be();const m=e.others.getUser(f.actor);return m?{type:"enter",user:m}:void 0}function z(f){return T.isJsonObject.call(void 0,f)?f:null}function K(f){const m=T.tryParseJson.call(void 0,f);return m===void 0?null:T.isJsonArray.call(void 0,m)?T.compact.call(void 0,m.map(v=>z(v))):T.compact.call(void 0,[z(m)])}function B(f){if(f.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const m=K(f.data);if(m===null||m.length===0)return;const v={storageUpdates:new Map,others:[]};o(()=>{for(const k of m)switch(k.type){case 101:{const S=U(k);S&&v.others.push(S);break}case 100:{const S=ve(k);S&&v.others.push(S);break}case 103:{a.customEvent.notify({connectionId:k.actor,event:k.event});break}case 102:{const S=d(k);S&&v.others.push(S);break}case 104:{v.others.push(x(k));break}case 200:{const S=new Map(e.offlineOperations);u(k,i),Bi(S,i),ln==null||ln(),a.storageDidLoad.notify();break}case 201:{A(k.ops,!1).updates.storageUpdates.forEach((ee,J)=>{v.storageUpdates.set(J,T.mergeStorageUpdates.call(void 0,v.storageUpdates.get(J),ee))});break}}C(v,i)})}function Y(f){e.socket=null,clearTimeout(e.timeoutHandles.pongTimeout),clearInterval(e.intervalHandles.heartbeat),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),e.others.clearOthers(),o(()=>{if(C({others:[{type:"reset"}]},i),f.code>=4e3&&f.code<=4100){ie({state:"failed"},i);const m=new ls(f.reason,f.code);a.error.notify(m);const v=oe(!0);e.numberOfRetry++,ie({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(v)}else if(f.code===4999)ie({state:"closed"},i);else{const m=oe();e.numberOfRetry++,ie({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(m)}})}function ie(f,m){e.connection.set(f),m(()=>{a.connection.notify(f.state)})}function oe(f=!1){return f?hn[e.numberOfRetry<hn.length?e.numberOfRetry:hn.length-1]:fn[e.numberOfRetry<fn.length?e.numberOfRetry:fn.length-1]}function he(){}function _e(){clearInterval(e.intervalHandles.heartbeat),e.intervalHandles.heartbeat=l.startHeartbeatInterval(),e.connection.current.state==="connecting"&&(ie(T.__spreadProps.call(void 0,T.__spreadValues.call(void 0,{},e.connection.current),{state:"open"}),o),e.numberOfRetry=0,e.lastConnectionId!==void 0&&(e.buffer.me={type:"full",data:T.__spreadValues.call(void 0,{},e.me.current)},be()),e.lastConnectionId=e.connection.current.id,e.root&&e.buffer.messages.push({type:200}),be())}function de(){e.socket!==null&&(clearTimeout(e.timeoutHandles.pongTimeout),e.timeoutHandles.pongTimeout=l.schedulePongTimeout(),e.socket.readyState===e.socket.OPEN&&e.socket.send("ping"))}function we(){at()}function at(){e.socket&&(e.socket.removeEventListener("open",_e),e.socket.removeEventListener("message",B),e.socket.removeEventListener("close",Y),e.socket.removeEventListener("error",he),e.socket.close(),e.socket=null),ie({state:"unavailable"},o),clearTimeout(e.timeoutHandles.pongTimeout),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),clearInterval(e.intervalHandles.heartbeat),R()}function Bi(f,m){if(f.size===0)return;const v=[],k=Array.from(f.values()),S=A(k,!0);v.push({type:201,ops:k}),C(S.updates,m),l.send(v)}function be(){const f=e.buffer.storageOperations;if(f.length>0&&f.forEach(k=>{e.offlineOperations.set(T.nn.call(void 0,k.opId),k)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const m=Date.now();if(m-e.lastFlushTime>t.throttleDelay){const k=Xi(e);if(k.length===0)return;l.send(k),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=m}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(m-e.lastFlushTime))}function Xi(f){const m=[];f.buffer.me&&m.push(f.buffer.me.type==="full"?{type:100,targetActor:-1,data:f.buffer.me.data}:{type:100,data:f.buffer.me.data});for(const v of f.buffer.messages)m.push(v);return f.buffer.storageOperations.length>0&&m.push({type:201,ops:f.buffer.storageOperations}),m}function qi(){e.socket&&(e.socket.removeEventListener("open",_e),e.socket.removeEventListener("message",B),e.socket.removeEventListener("close",Y),e.socket.removeEventListener("error",he),e.socket.close(),e.socket=null),o(()=>{ie({state:"closed"},i),e.timeoutHandles.flush&&clearTimeout(e.timeoutHandles.flush),clearTimeout(e.timeoutHandles.reconnect),clearTimeout(e.timeoutHandles.pongTimeout),clearInterval(e.intervalHandles.heartbeat),e.others.clearOthers(),C({others:[{type:"reset"}]},i),Object.values(a).forEach(f=>f.clear())})}function Yi(){return e.me.current}function Gi(){return e.others.current}function Ji(f,m={shouldQueueEventIfNotReady:!1}){e.socket===null&&!m.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:f}),be())}function Yn(f){e.buffer.storageOperations.push(...f),be()}let an=null,ln=null;function Gn(){return an===null&&(e.buffer.messages.push({type:200}),be(),an=new Promise(f=>ln=f)),an}function ji(){const f=e.root;return f!==void 0?f:(Gn(),null)}function Wi(){return T.__async.call(void 0,this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield Gn(),{root:T.nn.call(void 0,e.root)})})}function Zi(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const f=e.undoStack.pop();if(f===void 0)return;e.pausedHistory=null;const m=A(f,!0);o(()=>{C(m.updates,i),e.redoStack.push(m.reverse),I(i)});for(const v of f)v.type!=="presence"&&e.buffer.storageOperations.push(v);be()}function Jn(){return e.undoStack.length>0}function Qi(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const f=e.redoStack.pop();if(f===void 0)return;e.pausedHistory=null;const m=A(f,!0);o(()=>{C(m.updates,i),e.undoStack.push(m.reverse),I(i)});for(const v of f)v.type!=="presence"&&e.buffer.storageOperations.push(v);be()}function jn(){return e.redoStack.length>0}function eo(f){if(e.activeBatch)return f();let m;return o(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{m=f()}finally{const v=e.activeBatch;e.activeBatch=null,v.reverseOps.length>0&&O(v.reverseOps,i),v.ops.length>0&&(e.redoStack=[]),v.ops.length>0&&Yn(v.ops),C(v.updates,i),be()}}),m}function to(){e.pausedHistory=[]}function no(){const f=e.pausedHistory;e.pausedHistory=null,f!==null&&f.length>0&&E(f,o)}function ro(){e.socket&&(e.socket=null)}function io(f){Y(f)}return{onClose:Y,onMessage:B,authenticationSuccess:L,heartbeat:de,onNavigatorOnline:g,simulateSocketClose:ro,simulateSendCloseEvent:io,onVisibilityChange:X,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:R,disconnect:qi,subscribe:F,updatePresence:w,broadcastEvent:Ji,batch:eo,undo:Zi,redo:Qi,canUndo:Jn,canRedo:jn,pauseHistory:to,resumeHistory:no,getStorage:Wi,getStorageSnapshot:ji,events:{customEvent:a.customEvent.observable,others:a.others.observable,me:a.me.observable,error:a.error.observable,connection:a.connection.observable,storage:a.storage.observable,history:a.history.observable,storageDidLoad:a.storageDidLoad.observable},getConnectionState:_,isSelfAware:()=>dn(e.connection.current),getSelf:()=>c.current,getPresence:Yi,getOthers:Gi}}function ss(e,t){const n=new Qo,r=new es({state:"closed"});return{token:null,lastConnectionId:null,socket:null,numberOfRetry:0,lastFlushTime:0,timeoutHandles:{flush:null,reconnect:0,pongTimeout:0},buffer:{me:{type:"full",data:e},messages:[],storageOperations:[]},intervalHandles:{heartbeat:0},connection:r,me:new Wo(e),others:n,initialStorage:t,idFactory:null,clock:0,opClock:0,nodes:new Map,root:void 0,undoStack:[],redoStack:[],pausedHistory:null,activeBatch:null,offlineOperations:new Map}}function as(e,t){const{initialPresence:n,initialStorage:r}=e,i=ss(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),o=os(i,t),s={id:t.roomId,getConnectionState:o.getConnectionState,isSelfAware:o.isSelfAware,getSelf:o.getSelf,subscribe:o.subscribe,getPresence:o.getPresence,updatePresence:o.updatePresence,getOthers:o.getOthers,broadcastEvent:o.broadcastEvent,getStorage:o.getStorage,getStorageSnapshot:o.getStorageSnapshot,events:o.events,batch:o.batch,history:{undo:o.undo,redo:o.redo,canUndo:o.canUndo,canRedo:o.canRedo,pause:o.pauseHistory,resume:o.resumeHistory},__INTERNAL_DO_NOT_USE:{simulateCloseWebsocket:o.simulateSocketClose,simulateSendCloseEvent:o.simulateSendCloseEvent}};return{connect:o.connect,disconnect:o.disconnect,onNavigatorOnline:o.onNavigatorOnline,onVisibilityChange:o.onVisibilityChange,room:s}}var ls=class extends Error{constructor(e,t){super(e),this.code=t}};function cs(e,t){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment, you need to provide a WebSocket polyfill.");const n=t||WebSocket;return r=>new n(`${e}/?token=${r}&version=0.18.3`)}function us(e,t){if(e.type==="public"){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment with a publicApiKey, you need to provide a fetch polyfill.");return n=>rr(t||fetch,e.url,{room:n,publicApiKey:e.publicApiKey})}if(e.type==="private"){if(typeof window>"u"&&t===void 0)throw new Error("To use Liveblocks client in a non-dom environment with a url as auth endpoint, you need to provide a fetch polyfill.");return n=>rr(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>T.__async.call(void 0,this,null,function*(){const r=yield e.callback(n);if(!r||!r.token)throw new Error('Authentication error. We expect the authentication callback to return a token, but it does not. Hint: the return value should look like: { token: "..." }');return r});throw new Error("Internal error. Unexpected authentication type")}function rr(e,t,n){return T.__async.call(void 0,this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new pn(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(s){throw new pn(`Expected a JSON response when doing a POST request on "${t}". ${s}`)}if(!T.isPlainObject.call(void 0,i)||typeof i.token!="string")throw new pn(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${JSON.stringify(i)}`);const{token:o}=i;return{token:o}})}var pn=class extends Error{constructor(e){super(e)}};function fs(e){const t=e,n=hs(e),r=new Map;function i(a){const l=r.get(a);return l?l.room:null}function o(a,l){var c,u;let h=r.get(a);if(h)return h.room;if(T.deprecateIf.call(void 0,l.initialPresence===null||l.initialPresence===void 0,"Please provide an initial presence value for the current user when entering the room."),h=as({initialPresence:(c=l.initialPresence)!=null?c:{},initialStorage:l.initialStorage},{roomId:a,throttleDelay:n,polyfills:t.polyfills,WebSocketPolyfill:t.WebSocketPolyfill,fetchPolyfill:t.fetchPolyfill,unstable_batchedUpdates:l==null?void 0:l.unstable_batchedUpdates,liveblocksServer:(t==null?void 0:t.liveblocksServer)||"wss://api.liveblocks.io/v6",authentication:ds(t,a)}),r.set(a,h),!l.DO_NOT_USE_withoutConnecting){if(typeof atob>"u"){if(((u=t.polyfills)==null?void 0:u.atob)===void 0)throw new Error("You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill");_o.atob=t.polyfills.atob}h.connect()}return h.room}function s(a){const l=r.get(a);l&&(l.disconnect(),r.delete(a))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,a]of r)a.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,a]of r)a.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:o,leave:s}}function hs(e){if(e.throttle===void 0)return 100;if(typeof e.throttle!="number"||e.throttle<80||e.throttle>1e3)throw new Error("throttle should be a number between 80 and 1000.");return e.throttle}function ds(e,t){const{publicApiKey:n,authEndpoint:r}=e;if(r!==void 0&&n!==void 0)throw new Error("You cannot use both publicApiKey and authEndpoint. Please use either publicApiKey or authEndpoint, but not both. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient");if(typeof n=="string"){if(n.startsWith("sk_"))throw new Error("Invalid publicApiKey. You are using the secret key which is not supported. Please use the public key instead. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");if(!n.startsWith("pk_"))throw new Error("Invalid key. Please use the public key format: pk_<public key>. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:n,url:ps(e,t)}}if(typeof r=="string")return{type:"private",url:r};if(typeof r=="function")return{type:"custom",callback:r};throw r!==void 0?new Error("authEndpoint must be a string or a function. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientAuthEndpoint"):new Error("Invalid Liveblocks client options. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient")}function ps(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function _s(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function ms(e,t){if(typeof e!="object"||e===null||typeof t!="object"||t===null||Object.prototype.toString.call(e)!=="[object Object]"||Object.prototype.toString.call(t)!=="[object Object]")return!1;const n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function gs(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:_s(e,t):ms(e,t)}Ae.LiveList=T.LiveList;Ae.LiveMap=T.LiveMap;Ae.LiveObject=T.LiveObject;Ae.createClient=fs;Ae.shallow=gs;Ae.LiveList;Ae.LiveMap;const vs=Ae.LiveObject,ys=Ae.createClient;Ae.shallow;const fi=Symbol(),hi=Symbol();function ws(e){let t;const n=e[2].default,r=Cr(n,e,e[1],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),t=!0},p(i,[o]){r&&r.p&&(!t||o&2)&&Ur(r,n,i,i[1],t?Dr(n,i[1],o,null):Mr(i[1]),null)},i(i){t||(H(r,i),t=!0)},o(i){q(r,i),t=!1},d(i){r&&r.d(i)}}}function bs(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:o}=t;if(!o)throw new Error("LiveblocksProvider requires a client");return $r(fi,o),e.$$set=s=>{"client"in s&&n(0,o=s.client),"$$scope"in s&&n(1,i=s.$$scope)},[o,i,r]}class Es extends De{constructor(t){super(),$e(this,t,bs,ws,ze,{client:0})}}function ks(e){let t;const n=e[3].default,r=Cr(n,e,e[2],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,o){r&&r.m(i,o),t=!0},p(i,[o]){r&&r.p&&(!t||o&4)&&Ur(r,n,i,i[2],t?Dr(n,i[2],o,null):Mr(i[2]),null)},i(i){t||(H(r,i),t=!0)},o(i){q(r,i),t=!1},d(i){r&&r.d(i)}}}function xs(e,t,n){let{$$slots:r={},$$scope:i}=t,{id:o}=t,{defaultPresence:s=()=>({})}=t;if(!o)throw new Error("RoomProvider requires an id");const a=zr(fi);if(a){const l=a.enter(o,s());$r(hi,l),Zt(()=>{a.leave(o)})}return e.$$set=l=>{"id"in l&&n(0,o=l.id),"defaultPresence"in l&&n(1,s=l.defaultPresence),"$$scope"in l&&n(2,i=l.$$scope)},[o,s,i,r]}class Os extends De{constructor(t){super(),$e(this,t,xs,ks,ze,{id:0,defaultPresence:1})}}function Is(e){let t,n,r,i,o,s,a,l;return{c(){t=te("div"),n=Kt("svg"),r=Kt("path"),i=ce(),o=te("div"),s=Ee(e[2]),this.h()},l(c){t=ne(c,"DIV",{class:!0,style:!0});var u=Z(t);n=Ht(u,"svg",{class:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var h=Z(n);r=Ht(h,"path",{d:!0,fill:!0}),Z(r).forEach(D),h.forEach(D),i=ue(u),o=ne(u,"DIV",{class:!0,style:!0});var p=Z(o);s=ke(p,e[2]),p.forEach(D),u.forEach(D),this.h()},h(){P(r,"d","M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"),P(r,"fill","#FFB800"),P(n,"class","block z-0 col-span-2 row-span-2"),P(n,"width","40"),P(n,"viewBox","0 0 15 15"),P(n,"fill","currentColor"),P(n,"xmlns","http://www.w3.org/2000/svg"),P(o,"class","absolute right-0 text-4xl col-start-2 row-start-2"),P(o,"style",a=`text-shadow: 0px 5px 5px ${e[1]}`),P(t,"class","cursor svelte-14ka0w3"),P(t,"style",l=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});`)},m(c,u){ae(c,t,u),M(t,n),M(n,r),M(t,i),M(t,o),M(o,s)},p(c,[u]){u&4&&Vt(s,c[2]),u&2&&a!==(a=`text-shadow: 0px 5px 5px ${c[1]}`)&&P(o,"style",a),u&9&&l!==(l=`transform: translateX(${c[3].x}px) translateY(${c[3].y}px) scale(${c[0].k});`)&&P(t,"style",l)},i:me,o:me,d(c){c&&D(t)}}}function Ss(e,t,n){let r,{transform:i}=t,{color:o=""}=t,{emoji:s=""}=t,{position:a={x:0,y:0}}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"color"in l&&n(1,o=l.color),"emoji"in l&&n(2,s=l.emoji),"position"in l&&n(4,a=l.position)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(a.x),y:i.applyY(a.y)})},[i,o,s,r,a]}class di extends De{constructor(t){super(),$e(this,t,Ss,Is,ze,{transform:0,color:1,emoji:2,position:4})}}function Ps(e){let t,n;return{c(){t=Kt("svg"),n=Kt("path"),this.h()},l(r){t=Ht(r,"svg",{xmlns:!0,fill:!0,width:!0,viewBox:!0,class:!0});var i=Z(t);n=Ht(i,"path",{fill:!0,d:!0}),Z(n).forEach(D),i.forEach(D),this.h()},h(){P(n,"fill","currentColor"),P(n,"d","M20 12a8 8 0 0 1-8 8v4a12 12 0 0 0 12-12h-4Zm-2-5.3a8 8 0 0 1 2 5.3h4c0-3-1.1-5.8-3-8l-3 2.7Z"),P(t,"xmlns","http://www.w3.org/2000/svg"),P(t,"fill","none"),P(t,"width","50"),P(t,"viewBox","0 0 24 24"),P(t,"class","animate-spin max-w-[1rem] inline-block")},m(r,i){ae(r,t,i),M(t,n)},p:me,i:me,o:me,d(r){r&&D(t)}}}class Ts extends De{constructor(t){super(),$e(this,t,null,Ps,ze,{})}}function As(e){let t,n,r,i,o,s,a,l,c,u,h,p,y;return i=new Ts({}),{c(){t=te("div"),n=te("div"),r=ce(),Oe(i.$$.fragment),o=ce(),s=te("h2"),a=Ee("Click to paint"),l=ce(),c=te("div"),u=Ee(e[2]),h=Ee("}"),this.h()},l(E){t=ne(E,"DIV",{class:!0,style:!0});var O=Z(t);n=ne(O,"DIV",{class:!0}),Z(n).forEach(D),r=ue(O),Ie(i.$$.fragment,O),o=ue(O),s=ne(O,"H2",{class:!0});var C=Z(s);a=ke(C,"Click to paint"),C.forEach(D),l=ue(O),c=ne(O,"DIV",{class:!0});var b=Z(c);u=ke(b,e[2]),h=ke(b,"}"),b.forEach(D),O.forEach(D),this.h()},h(){P(n,"class","small-frame z-0 flex relative svelte-1spk1c1"),P(s,"class","text-lg"),P(c,"class","absolute bottom-0 font-bold"),P(t,"class","frame z-0 flex relative svelte-1spk1c1"),P(t,"style",p=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});
-			background-image: linear-gradient(${e[1]}, rgba(255,255,255,0));
-			color: ${e[1]};
-	`)},m(E,O){ae(E,t,O),M(t,n),M(t,r),Se(i,t,null),M(t,o),M(t,s),M(s,a),M(t,l),M(t,c),M(c,u),M(c,h),y=!0},p(E,[O]){(!y||O&4)&&Vt(u,E[2]),(!y||O&11&&p!==(p=`transform: translateX(${E[3].x}px) translateY(${E[3].y}px) scale(${E[0].k});
-			background-image: linear-gradient(${E[1]}, rgba(255,255,255,0));
-			color: ${E[1]};
-	`))&&P(t,"style",p)},i(E){y||(H(i.$$.fragment,E),y=!0)},o(E){q(i.$$.fragment,E),y=!1},d(E){E&&D(t),Pe(i)}}}function Ls(e,t,n){let r,{transform:i}=t,{color:o=""}=t,{position:s={x:0,y:0}}=t,{prompt:a=""}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"color"in l&&n(1,o=l.color),"position"in l&&n(4,s=l.position),"prompt"in l&&n(2,a=l.prompt)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,o,a,r,s]}class pi extends De{constructor(t){super(),$e(this,t,Ls,As,ze,{transform:0,color:1,position:4,prompt:2})}}var Rs={value:()=>{}};function Dn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Dt(n)}function Dt(e){this._=e}function Ns(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Dt.prototype=Dn.prototype={constructor:Dt,on:function(e,t){var n=this._,r=Ns(e+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o<s;)if((i=(e=r[o]).type)&&(i=Cs(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(i=(e=r[o]).type)n[i]=ir(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ir(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Dt(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function Cs(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function ir(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Rs,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var wn="http://www.w3.org/1999/xhtml";const or={svg:"http://www.w3.org/2000/svg",xhtml:wn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function nn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),or.hasOwnProperty(t)?{space:or[t],local:e}:e}function Us(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===wn&&t.documentElement.namespaceURI===wn?t.createElement(e):t.createElementNS(n,e)}}function Ms(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function _i(e){var t=nn(e);return(t.local?Ms:Us)(t)}function Ds(){}function $n(e){return e==null?Ds:function(){return this.querySelector(e)}}function $s(e){typeof e!="function"&&(e=$n(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=new Array(s),l,c,u=0;u<s;++u)(l=o[u])&&(c=e.call(l,l.__data__,u,o))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new ge(r,this._parents)}function zs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Fs(){return[]}function mi(e){return e==null?Fs:function(){return this.querySelectorAll(e)}}function Ks(e){return function(){return zs(e.apply(this,arguments))}}function Hs(e){typeof e=="function"?e=Ks(e):e=mi(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var s=t[o],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(r.push(e.call(l,l.__data__,c,s)),i.push(l));return new ge(r,i)}function gi(e){return function(){return this.matches(e)}}function vi(e){return function(t){return t.matches(e)}}var Vs=Array.prototype.find;function Bs(e){return function(){return Vs.call(this.children,e)}}function Xs(){return this.firstElementChild}function qs(e){return this.select(e==null?Xs:Bs(typeof e=="function"?e:vi(e)))}var Ys=Array.prototype.filter;function Gs(){return Array.from(this.children)}function Js(e){return function(){return Ys.call(this.children,e)}}function js(e){return this.selectAll(e==null?Gs:Js(typeof e=="function"?e:vi(e)))}function Ws(e){typeof e!="function"&&(e=gi(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=[],l,c=0;c<s;++c)(l=o[c])&&e.call(l,l.__data__,c,o)&&a.push(l);return new ge(r,this._parents)}function yi(e){return new Array(e.length)}function Zs(){return new ge(this._enter||this._groups.map(yi),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Qs(e){return function(){return e}}function ea(e,t,n,r,i,o){for(var s=0,a,l=t.length,c=o.length;s<c;++s)(a=t[s])?(a.__data__=o[s],r[s]=a):n[s]=new qt(e,o[s]);for(;s<l;++s)(a=t[s])&&(i[s]=a)}function ta(e,t,n,r,i,o,s){var a,l,c=new Map,u=t.length,h=o.length,p=new Array(u),y;for(a=0;a<u;++a)(l=t[a])&&(p[a]=y=s.call(l,l.__data__,a,t)+"",c.has(y)?i[a]=l:c.set(y,l));for(a=0;a<h;++a)y=s.call(e,o[a],a,o)+"",(l=c.get(y))?(r[a]=l,l.__data__=o[a],c.delete(y)):n[a]=new qt(e,o[a]);for(a=0;a<u;++a)(l=t[a])&&c.get(p[a])===l&&(i[a]=l)}function na(e){return e.__data__}function ra(e,t){if(!arguments.length)return Array.from(this,na);var n=t?ta:ea,r=this._parents,i=this._groups;typeof e!="function"&&(e=Qs(e));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),c=0;c<o;++c){var u=r[c],h=i[c],p=h.length,y=ia(e.call(u,u&&u.__data__,c,r)),E=y.length,O=a[c]=new Array(E),C=s[c]=new Array(E),b=l[c]=new Array(p);n(u,h,O,C,b,y,t);for(var A=0,G=0,re,$;A<E;++A)if(re=O[A]){for(A>=G&&(G=A+1);!($=C[G])&&++G<E;);re._next=$||null}}return s=new ge(s,r),s._enter=a,s._exit=l,s}function ia(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function oa(){return new ge(this._exit||this._groups.map(yi),this._parents)}function sa(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function aa(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var c=n[l],u=r[l],h=c.length,p=a[l]=new Array(h),y,E=0;E<h;++E)(y=c[E]||u[E])&&(p[E]=y);for(;l<i;++l)a[l]=n[l];return new ge(a,this._parents)}function la(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],s;--i>=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function ca(e){e||(e=ua);function t(h,p){return h&&p?e(h.__data__,p.__data__):!h-!p}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s=n[o],a=s.length,l=i[o]=new Array(a),c,u=0;u<a;++u)(c=s[u])&&(l[u]=c);l.sort(t)}return new ge(i,this._parents).order()}function ua(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function fa(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ha(){return Array.from(this)}function da(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}return null}function pa(){let e=0;for(const t of this)++e;return e}function _a(){return!this.node()}function ma(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,s=i.length,a;o<s;++o)(a=i[o])&&e.call(a,a.__data__,o,i);return this}function ga(e){return function(){this.removeAttribute(e)}}function va(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ya(e,t){return function(){this.setAttribute(e,t)}}function wa(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ba(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Ea(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ka(e,t){var n=nn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?va:ga:typeof t=="function"?n.local?Ea:ba:n.local?wa:ya)(n,t))}function wi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function xa(e){return function(){this.style.removeProperty(e)}}function Oa(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Ia(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Sa(e,t,n){return arguments.length>1?this.each((t==null?xa:typeof t=="function"?Ia:Oa)(e,t,n==null?"":n)):pt(this.node(),e)}function pt(e,t){return e.style.getPropertyValue(t)||wi(e).getComputedStyle(e,null).getPropertyValue(t)}function Pa(e){return function(){delete this[e]}}function Ta(e,t){return function(){this[e]=t}}function Aa(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function La(e,t){return arguments.length>1?this.each((t==null?Pa:typeof t=="function"?Aa:Ta)(e,t)):this.node()[e]}function bi(e){return e.trim().split(/^|\s+/)}function zn(e){return e.classList||new Ei(e)}function Ei(e){this._node=e,this._names=bi(e.getAttribute("class")||"")}Ei.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ki(e,t){for(var n=zn(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function xi(e,t){for(var n=zn(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Ra(e){return function(){ki(this,e)}}function Na(e){return function(){xi(this,e)}}function Ca(e,t){return function(){(t.apply(this,arguments)?ki:xi)(this,e)}}function Ua(e,t){var n=bi(e+"");if(arguments.length<2){for(var r=zn(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?Ca:t?Ra:Na)(n,t))}function Ma(){this.textContent=""}function Da(e){return function(){this.textContent=e}}function $a(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function za(e){return arguments.length?this.each(e==null?Ma:(typeof e=="function"?$a:Da)(e)):this.node().textContent}function Fa(){this.innerHTML=""}function Ka(e){return function(){this.innerHTML=e}}function Ha(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Va(e){return arguments.length?this.each(e==null?Fa:(typeof e=="function"?Ha:Ka)(e)):this.node().innerHTML}function Ba(){this.nextSibling&&this.parentNode.appendChild(this)}function Xa(){return this.each(Ba)}function qa(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ya(){return this.each(qa)}function Ga(e){var t=typeof e=="function"?e:_i(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ja(){return null}function ja(e,t){var n=typeof e=="function"?e:_i(e),r=t==null?Ja:typeof t=="function"?t:$n(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Wa(){var e=this.parentNode;e&&e.removeChild(this)}function Za(){return this.each(Wa)}function Qa(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function el(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tl(e){return this.select(e?el:Qa)}function nl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rl(e){return function(t){e.call(this,t,this.__data__)}}function il(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function ol(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function sl(e,t,n){return function(){var r=this.__on,i,o=rl(t);if(r){for(var s=0,a=r.length;s<a;++s)if((i=r[s]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function al(e,t,n){var r=il(e+""),i,o=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(i=0,u=a[l];i<o;++i)if((s=r[i]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?sl:ol,i=0;i<o;++i)this.each(a(r[i],t,n));return this}function Oi(e,t,n){var r=wi(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function ll(e,t){return function(){return Oi(this,e,t)}}function cl(e,t){return function(){return Oi(this,e,t.apply(this,arguments))}}function ul(e,t){return this.each((typeof t=="function"?cl:ll)(e,t))}function*fl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,s;i<o;++i)(s=r[i])&&(yield s)}var Ii=[null];function ge(e,t){this._groups=e,this._parents=t}function Pt(){return new ge([[document.documentElement]],Ii)}function hl(){return this}ge.prototype=Pt.prototype={constructor:ge,select:$s,selectAll:Hs,selectChild:qs,selectChildren:js,filter:Ws,data:ra,enter:Zs,exit:oa,join:sa,merge:aa,selection:hl,order:la,sort:ca,call:fa,nodes:ha,node:da,size:pa,empty:_a,each:ma,attr:ka,style:Sa,property:La,classed:Ua,text:za,html:Va,raise:Xa,lower:Ya,append:Ga,insert:ja,remove:Za,clone:tl,datum:nl,on:al,dispatch:ul,[Symbol.iterator]:fl};function je(e){return typeof e=="string"?new ge([[document.querySelector(e)]],[document.documentElement]):new ge([[e]],Ii)}function dl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function tt(e,t){if(e=dl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const bn={capture:!0,passive:!1};function En(e){e.preventDefault(),e.stopImmediatePropagation()}function pl(e){var t=e.document.documentElement,n=je(e).on("dragstart.drag",En,bn);"onselectstart"in t?n.on("selectstart.drag",En,bn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function _l(e,t){var n=e.document.documentElement,r=je(e).on("dragstart.drag",null);t&&(r.on("click.drag",En,bn),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Fn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Si(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Tt(){}var kt=.7,Yt=1/kt,ht="\\s*([+-]?\\d+)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Me="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ml=/^#([0-9a-f]{3,8})$/,gl=new RegExp(`^rgb\\(${ht},${ht},${ht}\\)$`),vl=new RegExp(`^rgb\\(${Me},${Me},${Me}\\)$`),yl=new RegExp(`^rgba\\(${ht},${ht},${ht},${xt}\\)$`),wl=new RegExp(`^rgba\\(${Me},${Me},${Me},${xt}\\)$`),bl=new RegExp(`^hsl\\(${xt},${Me},${Me}\\)$`),El=new RegExp(`^hsla\\(${xt},${Me},${Me},${xt}\\)$`),sr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Fn(Tt,Ot,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ar,formatHex:ar,formatHex8:kl,formatHsl:xl,formatRgb:lr,toString:lr});function ar(){return this.rgb().formatHex()}function kl(){return this.rgb().formatHex8()}function xl(){return Pi(this).formatHsl()}function lr(){return this.rgb().formatRgb()}function Ot(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ml.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?cr(t):n===3?new pe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Lt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Lt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=gl.exec(e))?new pe(t[1],t[2],t[3],1):(t=vl.exec(e))?new pe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=yl.exec(e))?Lt(t[1],t[2],t[3],t[4]):(t=wl.exec(e))?Lt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=bl.exec(e))?hr(t[1],t[2]/100,t[3]/100,1):(t=El.exec(e))?hr(t[1],t[2]/100,t[3]/100,t[4]):sr.hasOwnProperty(e)?cr(sr[e]):e==="transparent"?new pe(NaN,NaN,NaN,0):null}function cr(e){return new pe(e>>16&255,e>>8&255,e&255,1)}function Lt(e,t,n,r){return r<=0&&(e=t=n=NaN),new pe(e,t,n,r)}function Ol(e){return e instanceof Tt||(e=Ot(e)),e?(e=e.rgb(),new pe(e.r,e.g,e.b,e.opacity)):new pe}function kn(e,t,n,r){return arguments.length===1?Ol(e):new pe(e,t,n,r==null?1:r)}function pe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Fn(pe,kn,Si(Tt,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new pe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?kt:Math.pow(kt,e),new pe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new pe(it(this.r),it(this.g),it(this.b),Gt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ur,formatHex:ur,formatHex8:Il,formatRgb:fr,toString:fr}));function ur(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}`}function Il(){return`#${nt(this.r)}${nt(this.g)}${nt(this.b)}${nt((isNaN(this.opacity)?1:this.opacity)*255)}`}function fr(){const e=Gt(this.opacity);return`${e===1?"rgb(":"rgba("}${it(this.r)}, ${it(this.g)}, ${it(this.b)}${e===1?")":`, ${e})`}`}function Gt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function it(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function nt(e){return e=it(e),(e<16?"0":"")+e.toString(16)}function hr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new xe(e,t,n,r)}function Pi(e){if(e instanceof xe)return new xe(e.h,e.s,e.l,e.opacity);if(e instanceof Tt||(e=Ot(e)),!e)return new xe;if(e instanceof xe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),s=NaN,a=o-i,l=(o+i)/2;return a?(t===o?s=(n-r)/a+(n<r)*6:n===o?s=(r-t)/a+2:s=(t-n)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new xe(s,a,l,e.opacity)}function Sl(e,t,n,r){return arguments.length===1?Pi(e):new xe(e,t,n,r==null?1:r)}function xe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Fn(xe,Sl,Si(Tt,{brighter(e){return e=e==null?Yt:Math.pow(Yt,e),new xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kt:Math.pow(kt,e),new xe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new pe(_n(e>=240?e-240:e+120,i,r),_n(e,i,r),_n(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new xe(dr(this.h),Rt(this.s),Rt(this.l),Gt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Gt(this.opacity);return`${e===1?"hsl(":"hsla("}${dr(this.h)}, ${Rt(this.s)*100}%, ${Rt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function dr(e){return e=(e||0)%360,e<0?e+360:e}function Rt(e){return Math.max(0,Math.min(1,e||0))}function _n(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ti=e=>()=>e;function Pl(e,t){return function(n){return e+n*t}}function Tl(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Al(e){return(e=+e)==1?Ai:function(t,n){return n-t?Tl(t,n,e):Ti(isNaN(t)?n:t)}}function Ai(e,t){var n=t-e;return n?Pl(e,n):Ti(isNaN(e)?t:e)}const pr=function e(t){var n=Al(t);function r(i,o){var s=n((i=kn(i)).r,(o=kn(o)).r),a=n(i.g,o.g),l=n(i.b,o.b),c=Ai(i.opacity,o.opacity);return function(u){return i.r=s(u),i.g=a(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=e,r}(1);function Ge(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var xn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(xn.source,"g");function Ll(e){return function(){return e}}function Rl(e){return function(t){return e(t)+""}}function Nl(e,t){var n=xn.lastIndex=mn.lastIndex=0,r,i,o,s=-1,a=[],l=[];for(e=e+"",t=t+"";(r=xn.exec(e))&&(i=mn.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,l.push({i:s,x:Ge(r,i)})),n=mn.lastIndex;return n<t.length&&(o=t.slice(n),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?Rl(l[0].x):Ll(t):(t=l.length,function(c){for(var u=0,h;u<t;++u)a[(h=l[u]).i]=h.x(c);return a.join("")})}var _r=180/Math.PI,On={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Li(e,t,n,r,i,o){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),e*r<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*_r,skewX:Math.atan(l)*_r,scaleX:s,scaleY:a}}var Nt;function Cl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?On:Li(t.a,t.b,t.c,t.d,t.e,t.f)}function Ul(e){return e==null||(Nt||(Nt=document.createElementNS("http://www.w3.org/2000/svg","g")),Nt.setAttribute("transform",e),!(e=Nt.transform.baseVal.consolidate()))?On:(e=e.matrix,Li(e.a,e.b,e.c,e.d,e.e,e.f))}function Ri(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function o(c,u,h,p,y,E){if(c!==h||u!==p){var O=y.push("translate(",null,t,null,n);E.push({i:O-4,x:Ge(c,h)},{i:O-2,x:Ge(u,p)})}else(h||p)&&y.push("translate("+h+t+p+n)}function s(c,u,h,p){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),p.push({i:h.push(i(h)+"rotate(",null,r)-2,x:Ge(c,u)})):u&&h.push(i(h)+"rotate("+u+r)}function a(c,u,h,p){c!==u?p.push({i:h.push(i(h)+"skewX(",null,r)-2,x:Ge(c,u)}):u&&h.push(i(h)+"skewX("+u+r)}function l(c,u,h,p,y,E){if(c!==h||u!==p){var O=y.push(i(y)+"scale(",null,",",null,")");E.push({i:O-4,x:Ge(c,h)},{i:O-2,x:Ge(u,p)})}else(h!==1||p!==1)&&y.push(i(y)+"scale("+h+","+p+")")}return function(c,u){var h=[],p=[];return c=e(c),u=e(u),o(c.translateX,c.translateY,u.translateX,u.translateY,h,p),s(c.rotate,u.rotate,h,p),a(c.skewX,u.skewX,h,p),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,h,p),c=u=null,function(y){for(var E=-1,O=p.length,C;++E<O;)h[(C=p[E]).i]=C.x(y);return h.join("")}}}var Ml=Ri(Cl,"px, ","px)","deg)"),Dl=Ri(Ul,", ",")",")"),$l=1e-12;function mr(e){return((e=Math.exp(e))+1/e)/2}function zl(e){return((e=Math.exp(e))-1/e)/2}function Fl(e){return((e=Math.exp(2*e))-1)/(e+1)}const Kl=function e(t,n,r){function i(o,s){var a=o[0],l=o[1],c=o[2],u=s[0],h=s[1],p=s[2],y=u-a,E=h-l,O=y*y+E*E,C,b;if(O<$l)b=Math.log(p/c)/t,C=function(_){return[a+_*y,l+_*E,c*Math.exp(t*_*b)]};else{var A=Math.sqrt(O),G=(p*p-c*c+r*O)/(2*c*n*A),re=(p*p-c*c-r*O)/(2*p*n*A),$=Math.log(Math.sqrt(G*G+1)-G),F=Math.log(Math.sqrt(re*re+1)-re);b=(F-$)/t,C=function(_){var R=_*b,w=mr($),L=c/(n*A)*(w*Fl(t*R+$)-zl($));return[a+L*y,l+L*E,c*w/mr(t*R+$)]}}return C.duration=b*1e3*t/Math.SQRT2,C}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,l=a*a;return e(s,a,l)},i}(Math.SQRT2,2,4);var _t=0,yt=0,mt=0,Ni=1e3,Jt,wt,jt=0,st=0,rn=0,It=typeof performance=="object"&&performance.now?performance:Date,Ci=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Kn(){return st||(Ci(Hl),st=It.now()+rn)}function Hl(){st=0}function Wt(){this._call=this._time=this._next=null}Wt.prototype=Ui.prototype={constructor:Wt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Kn():+n)+(t==null?0:+t),!this._next&&wt!==this&&(wt?wt._next=this:Jt=this,wt=this),this._call=e,this._time=n,In()},stop:function(){this._call&&(this._call=null,this._time=1/0,In())}};function Ui(e,t,n){var r=new Wt;return r.restart(e,t,n),r}function Vl(){Kn(),++_t;for(var e=Jt,t;e;)(t=st-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_t}function gr(){st=(jt=It.now())+rn,_t=yt=0;try{Vl()}finally{_t=0,Xl(),st=0}}function Bl(){var e=It.now(),t=e-jt;t>Ni&&(rn-=t,jt=e)}function Xl(){for(var e,t=Jt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);wt=e,In(r)}function In(e){if(!_t){yt&&(yt=clearTimeout(yt));var t=e-st;t>24?(e<1/0&&(yt=setTimeout(gr,e-It.now()-rn)),mt&&(mt=clearInterval(mt))):(mt||(jt=It.now(),mt=setInterval(Bl,Ni)),_t=1,Ci(gr))}}function vr(e,t,n){var r=new Wt;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var ql=Dn("start","end","cancel","interrupt"),Yl=[],Mi=0,yr=1,Sn=2,$t=3,wr=4,Pn=5,zt=6;function on(e,t,n,r,i,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Gl(e,n,{name:t,index:r,group:i,on:ql,tween:Yl,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Mi})}function Hn(e,t){var n=Le(e,t);if(n.state>Mi)throw new Error("too late; already scheduled");return n}function Fe(e,t){var n=Le(e,t);if(n.state>$t)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Gl(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ui(o,0,n.time);function o(c){n.state=yr,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,h,p,y;if(n.state!==yr)return l();for(u in r)if(y=r[u],y.name===n.name){if(y.state===$t)return vr(s);y.state===wr?(y.state=zt,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[u]):+u<t&&(y.state=zt,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[u])}if(vr(function(){n.state===$t&&(n.state=wr,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Sn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Sn){for(n.state=$t,i=new Array(p=n.tween.length),u=0,h=-1;u<p;++u)(y=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(i[++h]=y);i.length=h+1}}function a(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Pn,1),h=-1,p=i.length;++h<p;)i[h].call(e,u);n.state===Pn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=zt,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function Ft(e,t){var n=e.__transition,r,i,o=!0,s;if(!!n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){o=!1;continue}i=r.state>Sn&&r.state<Pn,r.state=zt,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}o&&delete e.__transition}}function Jl(e){return this.each(function(){Ft(this,e)})}function jl(e,t){var n,r;return function(){var i=Fe(this,e),o=i.tween;if(o!==n){r=n=o;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}i.tween=r}}function Wl(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Fe(this,e),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=a;break}l===c&&i.push(a)}o.tween=i}}function Zl(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Le(this.node(),n).tween,i=0,o=r.length,s;i<o;++i)if((s=r[i]).name===e)return s.value;return null}return this.each((t==null?jl:Wl)(n,e,t))}function Vn(e,t,n){var r=e._id;return e.each(function(){var i=Fe(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Le(i,r).value[t]}}function Di(e,t){var n;return(typeof t=="number"?Ge:t instanceof Ot?pr:(n=Ot(t))?(t=n,pr):Nl)(e,t)}function Ql(e){return function(){this.removeAttribute(e)}}function ec(e){return function(){this.removeAttributeNS(e.space,e.local)}}function tc(e,t,n){var r,i=n+"",o;return function(){var s=this.getAttribute(e);return s===i?null:s===r?o:o=t(r=s,n)}}function nc(e,t,n){var r,i=n+"",o;return function(){var s=this.getAttributeNS(e.space,e.local);return s===i?null:s===r?o:o=t(r=s,n)}}function rc(e,t,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a)))}}function ic(e,t,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a)))}}function oc(e,t){var n=nn(e),r=n==="transform"?Dl:Di;return this.attrTween(e,typeof t=="function"?(n.local?ic:rc)(n,r,Vn(this,"attr."+e,t)):t==null?(n.local?ec:Ql)(n):(n.local?nc:tc)(n,r,t))}function sc(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ac(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function lc(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&ac(e,o)),n}return i._value=t,i}function cc(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&sc(e,o)),n}return i._value=t,i}function uc(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=nn(e);return this.tween(n,(r.local?lc:cc)(r,t))}function fc(e,t){return function(){Hn(this,e).delay=+t.apply(this,arguments)}}function hc(e,t){return t=+t,function(){Hn(this,e).delay=t}}function dc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?fc:hc)(t,e)):Le(this.node(),t).delay}function pc(e,t){return function(){Fe(this,e).duration=+t.apply(this,arguments)}}function _c(e,t){return t=+t,function(){Fe(this,e).duration=t}}function mc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pc:_c)(t,e)):Le(this.node(),t).duration}function gc(e,t){if(typeof t!="function")throw new Error;return function(){Fe(this,e).ease=t}}function vc(e){var t=this._id;return arguments.length?this.each(gc(t,e)):Le(this.node(),t).ease}function yc(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Fe(this,e).ease=n}}function wc(e){if(typeof e!="function")throw new Error;return this.each(yc(this._id,e))}function bc(e){typeof e!="function"&&(e=gi(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=[],l,c=0;c<s;++c)(l=o[c])&&e.call(l,l.__data__,c,o)&&a.push(l);return new qe(r,this._parents,this._name,this._id)}function Ec(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var l=t[a],c=n[a],u=l.length,h=s[a]=new Array(u),p,y=0;y<u;++y)(p=l[y]||c[y])&&(h[y]=p);for(;a<r;++a)s[a]=t[a];return new qe(s,this._parents,this._name,this._id)}function kc(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function xc(e,t,n){var r,i,o=kc(t)?Hn:Fe;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}function Oc(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(xc(n,e,t))}function Ic(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Sc(){return this.on("end.remove",Ic(this._id))}function Pc(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$n(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a=r[s],l=a.length,c=o[s]=new Array(l),u,h,p=0;p<l;++p)(u=a[p])&&(h=e.call(u,u.__data__,p,a))&&("__data__"in u&&(h.__data__=u.__data__),c[p]=h,on(c[p],t,n,p,c,Le(u,n)));return new qe(o,this._parents,t,n)}function Tc(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mi(e));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var l=r[a],c=l.length,u,h=0;h<c;++h)if(u=l[h]){for(var p=e.call(u,u.__data__,h,l),y,E=Le(u,n),O=0,C=p.length;O<C;++O)(y=p[O])&&on(y,t,n,O,p,E);o.push(p),s.push(u)}return new qe(o,s,t,n)}var Ac=Pt.prototype.constructor;function Lc(){return new Ac(this._groups,this._parents)}function Rc(e,t){var n,r,i;return function(){var o=pt(this,e),s=(this.style.removeProperty(e),pt(this,e));return o===s?null:o===n&&s===r?i:i=t(n=o,r=s)}}function $i(e){return function(){this.style.removeProperty(e)}}function Nc(e,t,n){var r,i=n+"",o;return function(){var s=pt(this,e);return s===i?null:s===r?o:o=t(r=s,n)}}function Cc(e,t,n){var r,i,o;return function(){var s=pt(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),pt(this,e))),s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a))}}function Uc(e,t){var n,r,i,o="style."+t,s="end."+o,a;return function(){var l=Fe(this,e),c=l.on,u=l.value[o]==null?a||(a=$i(t)):void 0;(c!==n||i!==u)&&(r=(n=c).copy()).on(s,i=u),l.on=r}}function Mc(e,t,n){var r=(e+="")=="transform"?Ml:Di;return t==null?this.styleTween(e,Rc(e,r)).on("end.style."+e,$i(e)):typeof t=="function"?this.styleTween(e,Cc(e,r,Vn(this,"style."+e,t))).each(Uc(this._id,e)):this.styleTween(e,Nc(e,r,t),n).on("end.style."+e,null)}function Dc(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function $c(e,t,n){var r,i;function o(){var s=t.apply(this,arguments);return s!==i&&(r=(i=s)&&Dc(e,s,n)),r}return o._value=t,o}function zc(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,$c(e,t,n==null?"":n))}function Fc(e){return function(){this.textContent=e}}function Kc(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Hc(e){return this.tween("text",typeof e=="function"?Kc(Vn(this,"text",e)):Fc(e==null?"":e+""))}function Vc(e){return function(t){this.textContent=e.call(this,t)}}function Bc(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Vc(i)),t}return r._value=e,r}function Xc(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Bc(e))}function qc(){for(var e=this._name,t=this._id,n=zi(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var u=Le(l,t);on(l,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new qe(r,this._parents,e,n)}function Yc(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--i===0&&o()}};n.each(function(){var c=Fe(this,r),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),i===0&&o()})}var Gc=0;function qe(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function zi(){return++Gc}var Ke=Pt.prototype;qe.prototype={constructor:qe,select:Pc,selectAll:Tc,selectChild:Ke.selectChild,selectChildren:Ke.selectChildren,filter:bc,merge:Ec,selection:Lc,transition:qc,call:Ke.call,nodes:Ke.nodes,node:Ke.node,size:Ke.size,empty:Ke.empty,each:Ke.each,on:Oc,attr:oc,attrTween:uc,style:Mc,styleTween:zc,text:Hc,textTween:Xc,remove:Sc,tween:Zl,delay:dc,duration:mc,ease:vc,easeVarying:wc,end:Yc,[Symbol.iterator]:Ke[Symbol.iterator]};function Jc(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jc={time:null,delay:0,duration:250,ease:Jc};function Wc(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Zc(e){var t,n;e instanceof qe?(t=e._id,e=e._name):(t=zi(),(n=jc).time=Kn(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,c=0;c<a;++c)(l=s[c])&&on(l,e,t,c,s,n||Wc(l,t));return new qe(r,this._parents,e,t)}Pt.prototype.interrupt=Jl;Pt.prototype.transition=Zc;const Ct=e=>()=>e;function Qc(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Xe(e,t,n){this.k=e,this.x=t,this.y=n}Xe.prototype={constructor:Xe,scale:function(e){return e===1?this:new Xe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Xe(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Bn=new Xe(1,0,0);Xe.prototype;function gn(e){e.stopImmediatePropagation()}function gt(e){e.preventDefault(),e.stopImmediatePropagation()}function eu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function tu(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function br(){return this.__zoom||Bn}function nu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ru(){return navigator.maxTouchPoints||"ontouchstart"in this}function iu(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function ou(){var e=eu,t=tu,n=iu,r=nu,i=ru,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Kl,c=Dn("start","zoom","end"),u,h,p,y=500,E=150,O=0,C=10;function b(d){d.property("__zoom",br).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",w).on("dblclick.zoom",L).filter(i).on("touchstart.zoom",Q).on("touchmove.zoom",X).on("touchend.zoom touchcancel.zoom",ve).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(d,x,g,I){var U=d.selection?d.selection():d;U.property("__zoom",br),d!==U?$(d,x,g,I):U.interrupt().each(function(){F(this,arguments).event(I).start().zoom(null,typeof x=="function"?x.apply(this,arguments):x).end()})},b.scaleBy=function(d,x,g,I){b.scaleTo(d,function(){var U=this.__zoom.k,z=typeof x=="function"?x.apply(this,arguments):x;return U*z},g,I)},b.scaleTo=function(d,x,g,I){b.transform(d,function(){var U=t.apply(this,arguments),z=this.__zoom,K=g==null?re(U):typeof g=="function"?g.apply(this,arguments):g,B=z.invert(K),Y=typeof x=="function"?x.apply(this,arguments):x;return n(G(A(z,Y),K,B),U,s)},g,I)},b.translateBy=function(d,x,g,I){b.transform(d,function(){return n(this.__zoom.translate(typeof x=="function"?x.apply(this,arguments):x,typeof g=="function"?g.apply(this,arguments):g),t.apply(this,arguments),s)},null,I)},b.translateTo=function(d,x,g,I,U){b.transform(d,function(){var z=t.apply(this,arguments),K=this.__zoom,B=I==null?re(z):typeof I=="function"?I.apply(this,arguments):I;return n(Bn.translate(B[0],B[1]).scale(K.k).translate(typeof x=="function"?-x.apply(this,arguments):-x,typeof g=="function"?-g.apply(this,arguments):-g),z,s)},I,U)};function A(d,x){return x=Math.max(o[0],Math.min(o[1],x)),x===d.k?d:new Xe(x,d.x,d.y)}function G(d,x,g){var I=x[0]-g[0]*d.k,U=x[1]-g[1]*d.k;return I===d.x&&U===d.y?d:new Xe(d.k,I,U)}function re(d){return[(+d[0][0]+ +d[1][0])/2,(+d[0][1]+ +d[1][1])/2]}function $(d,x,g,I){d.on("start.zoom",function(){F(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){F(this,arguments).event(I).end()}).tween("zoom",function(){var U=this,z=arguments,K=F(U,z).event(I),B=t.apply(U,z),Y=g==null?re(B):typeof g=="function"?g.apply(U,z):g,ie=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),oe=U.__zoom,he=typeof x=="function"?x.apply(U,z):x,_e=l(oe.invert(Y).concat(ie/oe.k),he.invert(Y).concat(ie/he.k));return function(de){if(de===1)de=he;else{var we=_e(de),at=ie/we[2];de=new Xe(at,Y[0]-we[0]*at,Y[1]-we[1]*at)}K.zoom(null,de)}})}function F(d,x,g){return!g&&d.__zooming||new _(d,x)}function _(d,x){this.that=d,this.args=x,this.active=0,this.sourceEvent=null,this.extent=t.apply(d,x),this.taps=0}_.prototype={event:function(d){return d&&(this.sourceEvent=d),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(d,x){return this.mouse&&d!=="mouse"&&(this.mouse[1]=x.invert(this.mouse[0])),this.touch0&&d!=="touch"&&(this.touch0[1]=x.invert(this.touch0[0])),this.touch1&&d!=="touch"&&(this.touch1[1]=x.invert(this.touch1[0])),this.that.__zoom=x,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(d){var x=je(this.that).datum();c.call(d,this.that,new Qc(d,{sourceEvent:this.sourceEvent,target:b,type:d,transform:this.that.__zoom,dispatch:c}),x)}};function R(d,...x){if(!e.apply(this,arguments))return;var g=F(this,x).event(d),I=this.__zoom,U=Math.max(o[0],Math.min(o[1],I.k*Math.pow(2,r.apply(this,arguments)))),z=tt(d);if(g.wheel)(g.mouse[0][0]!==z[0]||g.mouse[0][1]!==z[1])&&(g.mouse[1]=I.invert(g.mouse[0]=z)),clearTimeout(g.wheel);else{if(I.k===U)return;g.mouse=[z,I.invert(z)],Ft(this),g.start()}gt(d),g.wheel=setTimeout(K,E),g.zoom("mouse",n(G(A(I,U),g.mouse[0],g.mouse[1]),g.extent,s));function K(){g.wheel=null,g.end()}}function w(d,...x){if(p||!e.apply(this,arguments))return;var g=d.currentTarget,I=F(this,x,!0).event(d),U=je(d.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",ie,!0),z=tt(d,g),K=d.clientX,B=d.clientY;pl(d.view),gn(d),I.mouse=[z,this.__zoom.invert(z)],Ft(this),I.start();function Y(oe){if(gt(oe),!I.moved){var he=oe.clientX-K,_e=oe.clientY-B;I.moved=he*he+_e*_e>O}I.event(oe).zoom("mouse",n(G(I.that.__zoom,I.mouse[0]=tt(oe,g),I.mouse[1]),I.extent,s))}function ie(oe){U.on("mousemove.zoom mouseup.zoom",null),_l(oe.view,I.moved),gt(oe),I.event(oe).end()}}function L(d,...x){if(!!e.apply(this,arguments)){var g=this.__zoom,I=tt(d.changedTouches?d.changedTouches[0]:d,this),U=g.invert(I),z=g.k*(d.shiftKey?.5:2),K=n(G(A(g,z),I,U),t.apply(this,x),s);gt(d),a>0?je(this).transition().duration(a).call($,K,I,d):je(this).call(b.transform,K,I,d)}}function Q(d,...x){if(!!e.apply(this,arguments)){var g=d.touches,I=g.length,U=F(this,x,d.changedTouches.length===I).event(d),z,K,B,Y;for(gn(d),K=0;K<I;++K)B=g[K],Y=tt(B,this),Y=[Y,this.__zoom.invert(Y),B.identifier],U.touch0?!U.touch1&&U.touch0[2]!==Y[2]&&(U.touch1=Y,U.taps=0):(U.touch0=Y,z=!0,U.taps=1+!!u);u&&(u=clearTimeout(u)),z&&(U.taps<2&&(h=Y[0],u=setTimeout(function(){u=null},y)),Ft(this),U.start())}}function X(d,...x){if(!!this.__zooming){var g=F(this,x).event(d),I=d.changedTouches,U=I.length,z,K,B,Y;for(gt(d),z=0;z<U;++z)K=I[z],B=tt(K,this),g.touch0&&g.touch0[2]===K.identifier?g.touch0[0]=B:g.touch1&&g.touch1[2]===K.identifier&&(g.touch1[0]=B);if(K=g.that.__zoom,g.touch1){var ie=g.touch0[0],oe=g.touch0[1],he=g.touch1[0],_e=g.touch1[1],de=(de=he[0]-ie[0])*de+(de=he[1]-ie[1])*de,we=(we=_e[0]-oe[0])*we+(we=_e[1]-oe[1])*we;K=A(K,Math.sqrt(de/we)),B=[(ie[0]+he[0])/2,(ie[1]+he[1])/2],Y=[(oe[0]+_e[0])/2,(oe[1]+_e[1])/2]}else if(g.touch0)B=g.touch0[0],Y=g.touch0[1];else return;g.zoom("touch",n(G(K,B,Y),g.extent,s))}}function ve(d,...x){if(!!this.__zooming){var g=F(this,x).event(d),I=d.changedTouches,U=I.length,z,K;for(gn(d),p&&clearTimeout(p),p=setTimeout(function(){p=null},y),z=0;z<U;++z)K=I[z],g.touch0&&g.touch0[2]===K.identifier?delete g.touch0:g.touch1&&g.touch1[2]===K.identifier&&delete g.touch1;if(g.touch1&&!g.touch0&&(g.touch0=g.touch1,delete g.touch1),g.touch0)g.touch0[1]=this.__zoom.invert(g.touch0[0]);else if(g.end(),g.taps===2&&(K=tt(K,this),Math.hypot(h[0]-K[0],h[1]-K[1])<C)){var B=je(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return b.wheelDelta=function(d){return arguments.length?(r=typeof d=="function"?d:Ct(+d),b):r},b.filter=function(d){return arguments.length?(e=typeof d=="function"?d:Ct(!!d),b):e},b.touchable=function(d){return arguments.length?(i=typeof d=="function"?d:Ct(!!d),b):i},b.extent=function(d){return arguments.length?(t=typeof d=="function"?d:Ct([[+d[0][0],+d[0][1]],[+d[1][0],+d[1][1]]]),b):t},b.scaleExtent=function(d){return arguments.length?(o[0]=+d[0],o[1]=+d[1],b):[o[0],o[1]]},b.translateExtent=function(d){return arguments.length?(s[0][0]=+d[0][0],s[1][0]=+d[1][0],s[0][1]=+d[0][1],s[1][1]=+d[1][1],b):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},b.constrain=function(d){return arguments.length?(n=d,b):n},b.duration=function(d){return arguments.length?(a=+d,b):a},b.interpolate=function(d){return arguments.length?(l=d,b):l},b.on=function(){var d=c.on.apply(c,arguments);return d===c?b:d},b.clickDistance=function(d){return arguments.length?(O=(d=+d)*d,b):Math.sqrt(O)},b.tapDistance=function(d){return arguments.length?(C=+d,b):C},b}const su="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join",au="https://hf.space/embed/huggingface-projects/stable-diffusion-multiplayer/uploads",ye=Te(""),ct=Te(!1),Et=Te(!1),Tn=Te(),An=Te(!1),Er=Te(!1),Ln=Te(Bn);function sn(){const e=zr(hi);if(!e)throw new Error("Use RoomProvider as parent with id prop");return e}function Xn(){const e=sn(),{subscribe:t,set:n}=Te();function r(o){e.updatePresence(o)}const i=e.subscribe("my-presence",o=>{n(o)});return Zt(()=>{i()}),{subscribe:t,update:r}}function lu(){const e=sn(),t=Te(),n=e.subscribe("others",r=>{t.set(r)});return Zt(n),t}function cu(){const e=sn(),t=Te();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function Fi(e,t){const n=sn(),r=cu(),i=Te();let o=()=>{};const s=r.subscribe(a=>{!a||(a.get(e)||a.set(e,new vs(t)),i.set(a.get(e)),o(),o=n.subscribe(a.get(e),l=>{i.set(l)}))});return Zt(s),i}function uu(e){let t,n;return{c(){t=te("div"),n=te("canvas"),this.h()},l(r){t=ne(r,"DIV",{class:!0});var i=Z(t);n=ne(i,"CANVAS",{width:!0,height:!0,class:!0}),Z(n).forEach(D),i.forEach(D),this.h()},h(){P(n,"width",e[5]),P(n,"height",e[4]),P(n,"class","absolute top-0 left-0 svelte-6dcxg7"),P(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0")},m(r,i){ae(r,t,i),M(t,n),e[8](n),e[9](t)},p:me,i:me,o:me,d(r){r&&D(t),e[8](null),e[9](null)}}}const Ut=10;function fu(){}function hu(e,t,n){let r,i,o,s,a;fe(e,Ln,_=>n(11,r=_)),fe(e,Tn,_=>n(12,i=_)),fe(e,Et,_=>n(14,s=_));const l=Xn();fe(e,l,_=>n(13,o=_));const c=Fi("promptImgStorage");fe(e,c,_=>n(7,a=_));const u=512*5,h=512*5;let{value:p}=t,y,E;const O=new Set;function C(_){return _?Object.values(_).sort((w,L)=>w.date-L.date).filter(({id:w})=>!O.has(w)):[]}let b=[];Rn(()=>{const _=h/y.clientWidth,R=ou().scaleExtent([1/_/1.5,1]).translateExtent([[-h*.1,-u*.1],[h*1.1,u*1.1]]).tapDistance(10).on("zoom",G);je(p.parentElement).call(R).on("dblclick.zoom",()=>(se(Et,s=!0,s),se(Tn,i=o.cursor,i),console.log("clicked",i),null)).on("pointermove",re).on("pointerleave",fu),E=p.getContext("2d"),E.strokeStyle="blue",E.lineWidth=10,E.strokeRect(0,0,h,u)});function A(_){Promise.all(_.map(({imgURL:R,position:w,id:L})=>new Promise(Q=>{const X=new Image;X.crossOrigin="anonymous",X.onload=()=>{Q({img:X,position:w,id:L})};const ve=R.split("/");X.src=`${au}/${ve.slice(3).join("/")}`}))).then(R=>{R.forEach(({img:w,position:L,id:Q})=>{O.add(Q),E.drawImage(w,L.x,L.y,w.width,w.height)})})}function G(_){const R=se(Ln,r=_.transform,r);n(0,p.style.transform=`translate(${R.x}px, ${R.y}px) scale(${R.k})`,p)}function re(_){_.preventDefault();const R=Math.round(r.invertX(_.layerX)/Ut)*Ut,w=Math.round(r.invertY(_.layerY)/Ut)*Ut;l.update({cursor:{x:R,y:w}})}function $(_){yn[_?"unshift":"push"](()=>{p=_,n(0,p)})}function F(_){yn[_?"unshift":"push"](()=>{y=_,n(1,y)})}return e.$$set=_=>{"value"in _&&n(0,p=_.value)},e.$$.update=()=>{e.$$.dirty&128&&n(6,b=C(a==null?void 0:a.toObject())),e.$$.dirty&64&&b&&A(b)},[p,y,l,c,u,h,b,a,$,F]}class du extends De{constructor(t){super(),$e(this,t,hu,uu,ze,{value:0})}}function pu(e){let t,n,r,i,o,s,a,l,c,u,h,p,y,E,O,C,b,A,G,re,$,F;return{c(){t=te("div"),n=te("div"),r=te("input"),i=ce(),o=te("label"),s=Ee("Show Frames"),a=ce(),l=te("div"),c=te("input"),u=ce(),h=te("label"),p=Ee("Text2Image"),y=ce(),E=te("button"),O=Ee("Add Prompt"),C=ce(),b=te("button"),A=te("span"),G=Ee("+"),re=Ee(`
-		Paint`),this.h()},l(_){t=ne(_,"DIV",{class:!0});var R=Z(t);n=ne(R,"DIV",{class:!0});var w=Z(n);r=ne(w,"INPUT",{id:!0,type:!0,class:!0}),i=ue(w),o=ne(w,"LABEL",{for:!0,class:!0});var L=Z(o);s=ke(L,"Show Frames"),L.forEach(D),w.forEach(D),a=ue(R),l=ne(R,"DIV",{class:!0});var Q=Z(l);c=ne(Q,"INPUT",{id:!0,type:!0,class:!0}),u=ue(Q),h=ne(Q,"LABEL",{for:!0,class:!0});var X=Z(h);p=ke(X,"Text2Image"),X.forEach(D),Q.forEach(D),y=ue(R),E=ne(R,"BUTTON",{class:!0,title:!0});var ve=Z(E);O=ke(ve,"Add Prompt"),ve.forEach(D),C=ue(R),b=ne(R,"BUTTON",{class:!0,title:!0});var d=Z(b);A=ne(d,"SPAN",{class:!0});var x=Z(A);G=ke(x,"+"),x.forEach(D),re=ke(d,`
-		Paint`),d.forEach(D),R.forEach(D),this.h()},h(){P(r,"id","showframes"),P(r,"type","checkbox"),P(r,"class","w-4 h-4 text-blue-600 bg-gray-100 rounded border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 cursor-pointer"),P(o,"for","showframes"),P(o,"class","text-black dark:text-white cursor-pointer ml-2"),P(n,"class","flex items-center"),P(c,"id","txt2img"),P(c,"type","checkbox"),P(c,"class","w-4 h-4 text-blue-600 bg-gray-100 rounded border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600 cursor-pointer"),P(h,"for","txt2img"),P(h,"class","text-black dark:text-white cursor-pointer ml-2"),P(l,"class","flex items-center"),P(E,"class","button svelte-3z1a8v"),P(E,"title","Add Prompt"),P(A,"class","rounded-sm h-5 w-5 m-1 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2"),P(b,"class","button-paint bg-violet-100 text-violet-900 svelte-3z1a8v"),P(b,"title","New Paint Frame"),P(t,"class","grid grid-cols-4 gap-3 text-sm w-max mx-auto")},m(_,R){ae(_,t,R),M(t,n),M(n,r),r.checked=e[0],M(n,i),M(n,o),M(o,s),M(t,a),M(t,l),M(l,c),c.checked=e[1],M(l,u),M(l,h),M(h,p),M(t,y),M(t,E),M(E,O),M(t,C),M(t,b),M(b,A),M(A,G),M(b,re),$||(F=[ut(r,"change",e[2]),ut(c,"change",e[3])],$=!0)},p(_,[R]){R&1&&(r.checked=_[0]),R&2&&(c.checked=_[1])},i:me,o:me,d(_){_&&D(t),$=!1,Fr(F)}}}function _u(e,t,n){let r,i;fe(e,An,a=>n(0,r=a)),fe(e,Er,a=>n(1,i=a));function o(){r=this.checked,An.set(r)}function s(){i=this.checked,Er.set(i)}return[r,i,o,s]}class mu extends De{constructor(t){super(),$e(this,t,_u,pu,ze,{})}}function gu(e){let t,n,r,i;return{c(){t=te("form"),n=te("input"),this.h()},l(o){t=ne(o,"FORM",{class:!0});var s=Z(t);n=ne(s,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),s.forEach(D),this.h()},h(){P(n,"class","input svelte-4r5yqh"),P(n,"placeholder","Type a prompt..."),P(n,"title","Input prompt to generate image and obtain palette"),P(n,"type","text"),P(n,"name","prompt"),P(t,"class","fixed w-screen top-0 left-0 bottom-0 right-0 max-h-screen z-50 flex items-center justify-center bg-black bg-opacity-80 px-3")},m(o,s){ae(o,t,s),M(t,n),Wn(n,e[0]),r||(i=[ut(n,"click",oo(e[2])),ut(n,"input",e[3]),ut(t,"submit",so(e[4])),ut(t,"click",e[5])],r=!0)},p(o,[s]){s&1&&n.value!==o[0]&&Wn(n,o[0])},i:me,o:me,d(o){o&&D(t),r=!1,Fr(i)}}}function vu(e,t,n){const r=ao();let i;const o=Xn(),s=h=>{h.key==="Escape"&&(r("close"),o.update({currentPrompt:"",isPrompting:!1}))};Rn(()=>(window.addEventListener("keyup",s),()=>{window.removeEventListener("keyup",s)}));function a(h){lo.call(this,e,h)}function l(){i=this.value,n(0,i)}const c=()=>r("prompt",{prompt:i}),u=()=>r("close");return e.$$.update=()=>{e.$$.dirty&1&&o.update({currentPrompt:i,isPrompting:!0})},[i,r,a,l,c,u]}class yu extends De{constructor(t){super(),$e(this,t,vu,gu,ze,{})}}var Ki={},Hi={},qn={exports:{}},W=String,Vi=function(){return{isColorSupported:!1,reset:W,bold:W,dim:W,italic:W,underline:W,inverse:W,hidden:W,strikethrough:W,black:W,red:W,green:W,yellow:W,blue:W,magenta:W,cyan:W,white:W,gray:W,bgBlack:W,bgRed:W,bgGreen:W,bgYellow:W,bgBlue:W,bgMagenta:W,bgCyan:W,bgWhite:W}};qn.exports=Vi();qn.exports.createColors=Vi;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,c){for(var u in c)Object.defineProperty(l,u,{enumerable:!0,get:c[u]})}t(e,{dim:()=>s,default:()=>a});const n=r(qn.exports);function r(l){return l&&l.__esModule?l:{default:l}}let i=new Set;function o(l,c,u){typeof process<"u"&&process.env.JEST_WORKER_ID||u&&i.has(u)||(u&&i.add(u),console.warn(""),c.forEach(h=>console.warn(l,"-",h)))}function s(l){return n.default.dim(l)}const a={info(l,c){o(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[c,l])},warn(l,c){o(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[c,l])},risk(l,c){o(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[c,l])}}})(Hi);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:()=>i});const t=n(Hi);function n(o){return o&&o.__esModule?o:{default:o}}function r({version:o,from:s,to:a}){t.default.warn(`${s}-color-renamed`,[`As of Tailwind CSS ${o}, \`${s}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const i={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}})(Ki);let vn=Ki;var wu=(vn.__esModule?vn:{default:vn}).default;const Ue=Object.values(wu).filter(e=>typeof e=="object").map(e=>e[200]).slice(0,18),bt=["\u{1F436}","\u{1F431}","\u{1F42D}","\u{1F439}","\u{1F430}","\u{1F98A}","\u{1F43B}","\u{1F43C}","\u{1F428}","\u{1F42F}","\u{1F981}","\u{1F42E}","\u{1F432}","\u{1F31A}","\u{1F31D}","\u{1F31E}","\u{1F31B}","\u{1F31C}"];function bu(e){return new Promise(t=>{const n=new Image;n.onload=async()=>{const r=n.width,i=n.height,o=document.createElement("canvas");o.width=r,o.height=i,o.getContext("2d").drawImage(n,0,0,r,i);const a=await new Promise(l=>o.toBlob(l,"image/jpeg",.95));t(a)},n.src=e})}async function Eu(e,t){const n=ku(t),r="https://huggingface.co/uploads",o=`color-palette-${crypto.randomUUID().split("-")[0]}-${n}.jpeg`,s=new File([e],o,{type:"image/jpeg"});console.log("uploading image",s);const l=await(await fetch(r,{method:"POST",headers:{"Content-Type":s.type,"X-Requested-With":"XMLHttpRequest"},body:s})).text();return console.log("uploaded images",l),l}function ku(e){return e?e.toString().toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,""):""}let xu=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");function kr(e,t,n){const r=e.slice();return r[20]=t[n].connectionId,r[21]=t[n].presence,r}function xr(e,t,n){const r=e.slice();return r[24]=t[n],r[26]=n,r}function Or(e){let t,n;return t=new yu({}),t.$on("prompt",e[13]),t.$on("close",e[12]),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},p:me,i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Ir(e){let t,n,r=e[1],i=[];for(let s=0;s<r.length;s+=1)i[s]=Sr(xr(e,r,s));const o=s=>q(i[s],1,1,()=>{i[s]=null});return{c(){for(let s=0;s<i.length;s+=1)i[s].c();t=Ce()},l(s){for(let a=0;a<i.length;a+=1)i[a].l(s);t=Ce()},m(s,a){for(let l=0;l<i.length;l+=1)i[l].m(s,a);ae(s,t,a),n=!0},p(s,a){if(a&130){r=s[1];let l;for(l=0;l<r.length;l+=1){const c=xr(s,r,l);i[l]?(i[l].p(c,a),H(i[l],1)):(i[l]=Sr(c),i[l].c(),H(i[l],1),i[l].m(t.parentNode,t))}for(Ve(),l=r.length;l<i.length;l+=1)o(l);Be()}},i(s){if(!n){for(let a=0;a<r.length;a+=1)H(i[a]);n=!0}},o(s){i=i.filter(Boolean);for(let a=0;a<i.length;a+=1)q(i[a]);n=!1},d(s){fo(i,s),s&&D(t)}}}function Sr(e){var r,i;let t,n;return t=new pi({props:{color:Ue[0],transform:e[7],position:(r=e[24])==null?void 0:r.position,prompt:(i=e[24])==null?void 0:i.prompt}}),{c(){Oe(t.$$.fragment)},l(o){Ie(t.$$.fragment,o)},m(o,s){Se(t,o,s),n=!0},p(o,s){var l,c;const a={};s&128&&(a.transform=o[7]),s&2&&(a.position=(l=o[24])==null?void 0:l.position),s&2&&(a.prompt=(c=o[24])==null?void 0:c.prompt),t.$set(a)},i(o){n||(H(t.$$.fragment,o),n=!0)},o(o){q(t.$$.fragment,o),n=!1},d(o){Pe(t,o)}}}function Pr(e){let t,n;return t=new di({props:{emoji:bt[0],color:Ue[0],position:e[8].cursor,transform:e[7]}}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},p(r,i){const o={};i&256&&(o.position=r[8].cursor),i&128&&(o.transform=r[7]),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Tr(e){let t=[],n=new Map,r,i,o=[...e[0]];const s=a=>a[20];for(let a=0;a<o.length;a+=1){let l=kr(e,o,a),c=s(l);n.set(c,t[a]=Rr(c,l))}return{c(){for(let a=0;a<t.length;a+=1)t[a].c();r=Ce()},l(a){for(let l=0;l<t.length;l+=1)t[l].l(a);r=Ce()},m(a,l){for(let c=0;c<t.length;c+=1)t[c].m(a,l);ae(a,r,l),i=!0},p(a,l){l&129&&(o=[...a[0]],Ve(),t=ho(t,l,s,1,a,o,n,r.parentNode,po,Rr,r,kr),Be())},i(a){if(!i){for(let l=0;l<o.length;l+=1)H(t[l]);i=!0}},o(a){for(let l=0;l<t.length;l+=1)q(t[l]);i=!1},d(a){for(let l=0;l<t.length;l+=1)t[l].d(a);a&&D(r)}}}function Ar(e){var r,i;let t,n;return t=new pi({props:{color:Ue[1+e[20]%(Ue.length-1)],position:(r=e[21])==null?void 0:r.cursor,prompt:(i=e[21])==null?void 0:i.currentPrompt,transform:e[7]}}),{c(){Oe(t.$$.fragment)},l(o){Ie(t.$$.fragment,o)},m(o,s){Se(t,o,s),n=!0},p(o,s){var l,c;const a={};s&1&&(a.color=Ue[1+o[20]%(Ue.length-1)]),s&1&&(a.position=(l=o[21])==null?void 0:l.cursor),s&1&&(a.prompt=(c=o[21])==null?void 0:c.currentPrompt),s&128&&(a.transform=o[7]),t.$set(a)},i(o){n||(H(t.$$.fragment,o),n=!0)},o(o){q(t.$$.fragment,o),n=!1},d(o){Pe(t,o)}}}function Lr(e){var r;let t,n;return t=new di({props:{emoji:bt[1+e[20]%(bt.length-1)],color:Ue[1+e[20]%(Ue.length-1)],position:(r=e[21])==null?void 0:r.cursor,transform:e[7]}}),{c(){Oe(t.$$.fragment)},l(i){Ie(t.$$.fragment,i)},m(i,o){Se(t,i,o),n=!0},p(i,o){var a;const s={};o&1&&(s.emoji=bt[1+i[20]%(bt.length-1)]),o&1&&(s.color=Ue[1+i[20]%(Ue.length-1)]),o&1&&(s.position=(a=i[21])==null?void 0:a.cursor),o&128&&(s.transform=i[7]),t.$set(s)},i(i){n||(H(t.$$.fragment,i),n=!0)},o(i){q(t.$$.fragment,i),n=!1},d(i){Pe(t,i)}}}function Rr(e,t){var l,c,u;let n,r,i,o,s=((l=t[21])==null?void 0:l.isPrompting)&&((c=t[21])==null?void 0:c.cursor)&&Ar(t),a=((u=t[21])==null?void 0:u.cursor)&&Lr(t);return{key:e,first:null,c(){n=Ce(),s&&s.c(),r=ce(),a&&a.c(),i=Ce(),this.h()},l(h){n=Ce(),s&&s.l(h),r=ue(h),a&&a.l(h),i=Ce(),this.h()},h(){this.first=n},m(h,p){ae(h,n,p),s&&s.m(h,p),ae(h,r,p),a&&a.m(h,p),ae(h,i,p),o=!0},p(h,p){var y,E,O;t=h,((y=t[21])==null?void 0:y.isPrompting)&&((E=t[21])==null?void 0:E.cursor)?s?(s.p(t,p),p&1&&H(s,1)):(s=Ar(t),s.c(),H(s,1),s.m(r.parentNode,r)):s&&(Ve(),q(s,1,1,()=>{s=null}),Be()),(O=t[21])!=null&&O.cursor?a?(a.p(t,p),p&1&&H(a,1)):(a=Lr(t),a.c(),H(a,1),a.m(i.parentNode,i)):a&&(Ve(),q(a,1,1,()=>{a=null}),Be())},i(h){o||(H(s),H(a),o=!0)},o(h){q(s),q(a),o=!1},d(h){h&&D(n),s&&s.d(h),h&&D(r),a&&a.d(h),h&&D(i)}}}function Ou(e){var R;let t,n,r,i,o,s,a,l,c,u,h,p,y,E,O,C,b,A=e[5]&&Or(e);function G(w){e[15](w)}let re={};e[2]!==void 0&&(re.value=e[2]),l=new du({props:re}),yn.push(()=>co(l,"value",G));let $=e[1]&&e[6]&&Ir(e),F=((R=e[8])==null?void 0:R.cursor)&&Pr(e),_=e[0]&&Tr(e);return C=new mu({}),{c(){t=te("div"),n=Ee(e[3]),r=ce(),i=Ee(e[4]),o=ce(),A&&A.c(),s=ce(),a=te("div"),Oe(l.$$.fragment),u=ce(),h=te("main"),$&&$.c(),p=ce(),F&&F.c(),y=ce(),_&&_.c(),E=ce(),O=te("div"),Oe(C.$$.fragment),this.h()},l(w){t=ne(w,"DIV",{class:!0});var L=Z(t);n=ke(L,e[3]),r=ue(L),i=ke(L,e[4]),L.forEach(D),o=ue(w),A&&A.l(w),s=ue(w),a=ne(w,"DIV",{class:!0});var Q=Z(a);Ie(l.$$.fragment,Q),u=ue(Q),h=ne(Q,"MAIN",{class:!0});var X=Z(h);$&&$.l(X),p=ue(X),F&&F.l(X),y=ue(X),_&&_.l(X),X.forEach(D),Q.forEach(D),E=ue(w),O=ne(w,"DIV",{class:!0});var ve=Z(O);Ie(C.$$.fragment,ve),ve.forEach(D),this.h()},h(){P(t,"class","text touch-none pointer-events-none"),P(h,"class","z-10 relative"),P(a,"class","fixed top-0 left-0 z-0 w-screen h-screen"),P(O,"class","fixed bottom-0 left-0 right-0 z-10 my-2")},m(w,L){ae(w,t,L),M(t,n),M(t,r),M(t,i),ae(w,o,L),A&&A.m(w,L),ae(w,s,L),ae(w,a,L),Se(l,a,null),M(a,u),M(a,h),$&&$.m(h,null),M(h,p),F&&F.m(h,null),M(h,y),_&&_.m(h,null),ae(w,E,L),ae(w,O,L),Se(C,O,null),b=!0},p(w,[L]){var X;(!b||L&8)&&Vt(n,w[3]),(!b||L&16)&&Vt(i,w[4]),w[5]?A?(A.p(w,L),L&32&&H(A,1)):(A=Or(w),A.c(),H(A,1),A.m(s.parentNode,s)):A&&(Ve(),q(A,1,1,()=>{A=null}),Be());const Q={};!c&&L&4&&(c=!0,Q.value=w[2],uo(()=>c=!1)),l.$set(Q),w[1]&&w[6]?$?($.p(w,L),L&66&&H($,1)):($=Ir(w),$.c(),H($,1),$.m(h,p)):$&&(Ve(),q($,1,1,()=>{$=null}),Be()),(X=w[8])!=null&&X.cursor?F?(F.p(w,L),L&256&&H(F,1)):(F=Pr(w),F.c(),H(F,1),F.m(h,y)):F&&(Ve(),q(F,1,1,()=>{F=null}),Be()),w[0]?_?(_.p(w,L),L&1&&H(_,1)):(_=Tr(w),_.c(),H(_,1),_.m(h,null)):_&&(Ve(),q(_,1,1,()=>{_=null}),Be())},i(w){b||(H(A),H(l.$$.fragment,w),H($),H(F),H(_),H(C.$$.fragment,w),b=!0)},o(w){q(A),q(l.$$.fragment,w),q($),q(F),q(_),q(C.$$.fragment,w),b=!1},d(w){w&&D(t),w&&D(o),A&&A.d(w),w&&D(s),w&&D(a),Pe(l),$&&$.d(),F&&F.d(),_&&_.d(),w&&D(E),w&&D(O),Pe(C)}}}function Iu({position:e}){return`${e.x}_${e.y}`}function Su(e,t,n){let r,i,o,s,a,l,c,u,h;fe(e,ye,_=>n(3,r=_)),fe(e,ct,_=>n(4,i=_)),fe(e,Tn,_=>n(16,s=_)),fe(e,Et,_=>n(5,a=_)),fe(e,An,_=>n(6,c=_)),fe(e,Ln,_=>n(7,u=_));const p=Xn();fe(e,p,_=>n(8,h=_));const y=lu();fe(e,y,_=>n(0,l=_)),p.update({name:"",cursor:null,isPrompting:!1,currentPrompt:""});const E=Fi("promptImgStorage");fe(e,E,_=>n(14,o=_));function O(_){return _?Object.values(_).sort((w,L)=>w.date-L.date):[]}let C=[],b;async function A(_){se(Et,a=!1,a)}async function G(_){const R=_.detail.prompt,w=await $(R);se(Et,a=!1,a),console.log("prompt",R,w)}function re(_){const R=document.createElement("canvas");R.width=512,R.height=512;const w=R.getContext("2d");return w.save(),w.clearRect(0,0,512,512),w.globalCompositeOperation="source-over",w.drawImage(b,_.x,_.y,512,512,0,0,512,512),w.restore(),R.toDataURL("image/png")}async function $(_){if(!_||i==!0)return;se(ye,r="Pending",r),se(ct,i=!0,i),p.update({currentPrompt:_,isPrompting:!0,cursor:s});const R=crypto.randomUUID(),w={fn_index:0,data:[re(s),_,.75,7.5,30,"patchmatch"],session_hash:R};console.log("payload",w);const L=new WebSocket(su);L.onclose=Q=>{Q.wasClean||(se(ye,r="Error",r),se(ct,i=!1,i))},L.onmessage=async function(Q){try{const X=JSON.parse(Q.data);switch(se(ye,r="",r),X.msg){case"send_data":se(ye,r="Sending Data",r),L.send(JSON.stringify(w));break;case"queue_full":se(ye,r="Queue full",r),L.close(),se(ct,i=!1,i);return;case"estimation":const{msg:ve,rank:d,queue_size:x}=X;se(ye,r=`On queue ${d}/${x}`,r);break;case"process_generating":se(ye,r=X.success?"Generating":"Error",r);break;case"process_completed":try{const g=X.output.data[0];if(X.output.data[1])throw new Error("Potential NFSW content, please try again");const U=await bu(g),z=await Eu(U,_),K={prompt:_,imgURL:z,position:s,date:new Date().getTime(),id:xu()},B=Iu(K);o.set(B,K),console.log(z),se(ye,r=X.success?"Complete":"Error",r)}catch(g){const I=g;se(ye,r=I==null?void 0:I.message,r)}L.close(),se(ct,i=!1,i);return;case"process_starts":se(ye,r="Processing",r);break}}catch(X){console.error(X),se(ct,i=!1,i),se(ye,r="Error",r)}}}function F(_){b=_,n(2,b)}return e.$$.update=()=>{e.$$.dirty&1&&console.log(l),e.$$.dirty&16384&&n(1,C=O(o==null?void 0:o.toObject()))},[l,C,b,r,i,a,c,u,h,p,y,E,A,G,o,F]}class Pu extends De{constructor(t){super(),$e(this,t,Su,Ou,ze,{})}}function Nr(e){let t,n;return t=new Es({props:{client:e[2],$$slots:{default:[Au]},$$scope:{ctx:e}}}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},p(r,i){const o={};i&4&&(o.client=r[2]),i&9&&(o.$$scope={dirty:i,ctx:r}),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Tu(e){let t,n;return t=new Pu({}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Au(e){let t,n;return t=new Os({props:{id:e[0],$$slots:{default:[Tu]},$$scope:{ctx:e}}}),{c(){Oe(t.$$.fragment)},l(r){Ie(t.$$.fragment,r)},m(r,i){Se(t,r,i),n=!0},p(r,i){const o={};i&1&&(o.id=r[0]),i&8&&(o.$$scope={dirty:i,ctx:r}),t.$set(o)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){q(t.$$.fragment,r),n=!1},d(r){Pe(t,r)}}}function Lu(e){let t,n,r=e[1]&&Nr(e);return{c(){r&&r.c(),t=Ce()},l(i){r&&r.l(i),t=Ce()},m(i,o){r&&r.m(i,o),ae(i,t,o),n=!0},p(i,[o]){i[1]?r?(r.p(i,o),o&2&&H(r,1)):(r=Nr(i),r.c(),H(r,1),r.m(t.parentNode,t)):r&&(Ve(),q(r,1,1,()=>{r=null}),Be())},i(i){n||(H(r),n=!0)},o(i){q(r),n=!1},d(i){r&&r.d(i),i&&D(t)}}}const Uu=!0;function Ru(e,t,n){let r,i=!1,o;return Rn(()=>{n(0,r="multiplayer-SD"),n(2,o=ys({publicApiKey:"pk_test_JlUZGH3kQmhmZQiqU2l8eIi5"})),n(1,i=!0)}),[r,i,o]}class Mu extends De{constructor(t){super(),$e(this,t,Ru,Lu,ze,{})}}export{Mu as default,Uu as prerender};