diff --git "a/static/_app/immutable/components/pages/_page.svelte-f8380cd2.js" "b/static/_app/immutable/components/pages/_page.svelte-f8380cd2.js" deleted file mode 100644--- "a/static/_app/immutable/components/pages/_page.svelte-f8380cd2.js" +++ /dev/null @@ -1 +0,0 @@ -import{S as he,i as de,s as pe,C as qn,D as Wn,E as Gn,F as Zn,f as H,t as X,I as li,J as ui,K as hn,L as me,M as _e,m as C,h as w,n as f,b as J,G as L,B as ye,k as K,w as se,a as W,l as B,x as oe,c as G,y as ae,z as le,q as ge,r as ve,u as ot,g as Te,d as Ce,N as Ve,O as Dt,H as Ae,P as Qn,o as Et,Q as dt,R as Oe,T as Ns,U as Mn,V as Rs,W as Ms,e as st,X as Ds,Y as Us}from"../../chunks/index-4b3edc7c.js";import{w as at}from"../../chunks/index-f611e2e3.js";var zs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Hs(e){var t=e.default;if(typeof t=="function"){var n=function(){return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}),n}var ze={},M={};Object.defineProperty(M,"__esModule",{value:!0});var Fs=Object.defineProperty,Ks=Object.defineProperties,Bs=Object.getOwnPropertyDescriptors,rn=Object.getOwnPropertySymbols,ci=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,vr=(e,t,n)=>t in e?Fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qe=(e,t)=>{for(var n in t||(t={}))ci.call(t,n)&&vr(e,n,t[n]);if(rn)for(var n of rn(t))fi.call(t,n)&&vr(e,n,t[n]);return e},xt=(e,t)=>Ks(e,Bs(t)),Vs=(e,t)=>{var n={};for(var r in e)ci.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&rn)for(var r of rn(e))t.indexOf(r)<0&&fi.call(e,r)&&(n[r]=e[r]);return n},er=(e,t,n)=>new Promise((r,i)=>{var s=l=>{try{o(n.next(l))}catch(u){i(u)}},a=l=>{try{o(n.throw(l))}catch(u){i(u)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(s,a);o((n=n.apply(e,t)).next())});function Ge(e,t){throw new Error(t)}function q(e,t="Expected value to be non-nullable"){return e}var hi=(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))(hi||{}),di=(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))(di||{}),pi=(e=>(e[e.OBJECT=0]="OBJECT",e[e.LIST=1]="LIST",e[e.MAP=2]="MAP",e[e.REGISTER=3]="REGISTER",e))(pi||{});function mi(e){return e.type===0&&!_i(e)}function _i(e){return e.parentId!==void 0&&e.parentKey!==void 0}var gi=(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))(gi||{});function js(e){return e==="my-presence"||e==="others"||e==="event"||e==="error"||e==="connection"||e==="history"}var vi=(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))(vi||{});function yr(e,t){return Object.freeze({type:"HasParent",node:e,key:t})}var wr=Object.freeze({type:"NoParent"});function br(e){return Object.freeze({type:"Orphaned",oldKey:e})}var dn=class{constructor(){this._parent=wr}_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 Ge(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 Ge(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 Ge(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=yr(e,t);return;case"Orphaned":case"NoParent":{this._parent=yr(e,t);return}default:return Ge(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=br(this.parent.key);break}case"NoParent":{this._parent=wr;break}case"Orphaned":{this._parent=br(this.parent.oldKey);break}default:Ge(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}},nt=class extends dn{constructor(e){super(),this._data=e}get data(){return this._data}static _deserialize([e,t],n,r){const i=new nt(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:q(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}},pt=32,tr=126;function Be(e,t){return e!==void 0&&t!==void 0?sn(yi(wt(e),wt(t))):e!==void 0?Ys(e):t!==void 0?Xs(t):sn([pt+1])}function Xs(e){const t=[],n=wt(e);for(let r=0;rs)throw new Error(`Impossible to generate position between ${e} and ${t}`);if(i===s){r.push(i),n++;continue}if(s-i===1){r.push(i),r.push(...yi(e.slice(n+1),[]));break}const a=s+i>>1;r.push(a);break}return r}function wt(e){const t=[];for(let n=0;nt._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=Pt(e);r._attach(t,this._pool),r._setParentLink(this,n);const i=e.deletedId,s=this._indexOfPosition(n);if(s!==-1){const a=this._items[s];if(a._id===i)return a._detach(),this._items[s]=r,{modified:ie(this,[_t(s,r)]),reverse:[]};{this._implicitlyDeletedItems.add(a),this._items[s]=r;const o=[_t(s,r)],l=this._detachItemAssociatedToSetOperation(e.deletedId);return l&&o.push(l),{modified:ie(this,o),reverse:[]}}}else{const a=[],o=this._detachItemAssociatedToSetOperation(e.deletedId);return o&&a.push(o),this._insertAndSort(r),a.push(Ke(this._indexOfPosition(n),r)),{reverse:[],modified:ie(this,a)}}}_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:ie(this,t),reverse:[]};this._unacknowledgedSets.delete(e.parentKey)}const i=this._indexOfPosition(e.parentKey),s=this._items.find(a=>a._id===e.id);if(s!==void 0){if(s._parentKey===e.parentKey)return{modified:t.length>0?ie(this,t):!1,reverse:[]};i!==-1&&(this._implicitlyDeletedItems.add(this._items[i]),this._items.splice(i,1),t.push(Ft(i)));const a=this._items.indexOf(s);s._setParentLink(this,e.parentKey),this._sortItems();const o=this._items.indexOf(s);return o!==a&&t.push(lt(a,o,s)),{modified:t.length>0?ie(this,t):!1,reverse:[]}}else{const a=this._pool.getNode(e.id);if(a&&this._implicitlyDeletedItems.has(a)){a._setParentLink(this,e.parentKey),this._implicitlyDeletedItems.delete(a),this._insertAndSort(a);const o=this._items.indexOf(a);return{modified:ie(this,[i===-1?Ke(o,a):_t(o,a),...t]),reverse:[]}}else{i!==-1&&this._items.splice(i,1);const{newItem:o,newIndex:l}=this._createAttachItemAndSort(e,e.parentKey);return{modified:ie(this,[i===-1?Ke(l,o):_t(l,o),...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:ie(this,[Ke(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 s=this._indexOfPosition(n);return s===i?{modified:!1}:{modified:ie(this,[lt(i,s,t)]),reverse:[]}}}else{const i=q(this._pool).getNode(e.id);if(i&&this._implicitlyDeletedItems.has(i)){i._setParentLink(this,n),this._implicitlyDeletedItems.delete(i),this._insertAndSort(i);const s=this._indexOfPosition(n);return{modified:ie(this,[Ke(s,i)]),reverse:[]}}else{r!==-1&&this._shiftItemPosition(r,n);const{newItem:s,newIndex:a}=this._createAttachItemAndSort(e,n);return{modified:ie(this,[Ke(a,s)]),reverse:[]}}}}_applyInsertUndoRedo(e){var t,n,r;const{id:i,parentKey:s}=e,a=Pt(e);if(((t=this._pool)==null?void 0:t.getNode(i))!==void 0)return{modified:!1};a._attach(i,q(this._pool)),a._setParentLink(this,s);const o=this._indexOfPosition(s);let l=s;if(o!==-1){const c=(n=this._items[o])==null?void 0:n._getParentKeyOrThrow(),g=(r=this._items[o+1])==null?void 0:r._getParentKeyOrThrow();l=Be(c,g),a._setParentLink(this,l)}this._insertAndSort(a);const u=this._indexOfPosition(l);return{modified:ie(this,[Ke(u,a)]),reverse:[{type:5,id:i}]}}_applySetUndoRedo(e){var t;const{id:n,parentKey:r}=e,i=Pt(e);if(((t=this._pool)==null?void 0:t.getNode(n))!==void 0)return{modified:!1};this._unacknowledgedSets.set(r,q(e.opId));const s=this._indexOfPosition(r);i._attach(n,q(this._pool)),i._setParentLink(this,r);const a=r;if(s!==-1){const o=this._items[s];o._detach(),this._items[s]=i;const l=o._toOps(q(this._id),r,this._pool);On(l,e.id);const u=[_t(s,i)],c=this._detachItemAssociatedToSetOperation(e.deletedId);return c&&u.push(c),{modified:ie(this,u),reverse:l}}else{this._insertAndSort(i),this._detachItemAssociatedToSetOperation(e.deletedId);const o=this._indexOfPosition(a);return{reverse:[{type:5,id:n}],modified:ie(this,[Ke(o,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=q(e._parentKey),n=e._toOps(q(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:ie(this,[Ft(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 s=this._items.indexOf(t);return{modified:ie(this,[Ke(s,t)]),reverse:[]}}const r=t._parentKey;if(e===r)return{modified:!1};const i=this._indexOfPosition(e);if(i===-1){const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return a===s?{modified:!1}:{modified:ie(this,[lt(s,a,t)]),reverse:[]}}else{this._items[i]._setParentLink(this,Be(e,(n=this._items[i+1])==null?void 0:n._getParentKeyOrThrow()));const s=this._items.indexOf(t);t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return a===s?{modified:!1}:{modified:ie(this,[lt(s,a,t)]),reverse:[]}}}_applySetChildKeyAck(e,t){var n,r;const i=q(t._parentKey);if(this._implicitlyDeletedItems.has(t)){const s=this._indexOfPosition(e);return this._implicitlyDeletedItems.delete(t),s!==-1&&this._items[s]._setParentLink(this,Be(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._insertAndSort(t),{modified:!1}}else{if(e===i)return{modified:!1};const s=this._items.indexOf(t),a=this._indexOfPosition(e);a!==-1&&this._items[a]._setParentLink(this,Be(e,(r=this._items[a+1])==null?void 0:r._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const o=this._items.indexOf(t);return s===o?{modified:!1}:{modified:ie(this,[lt(s,o,t)]),reverse:[]}}}_applySetChildKeyUndoRedo(e,t){var n;const r=q(t._parentKey),i=this._items.indexOf(t),s=this._indexOfPosition(e);s!==-1&&this._items[s]._setParentLink(this,Be(e,(n=this._items[s+1])==null?void 0:n._getParentKeyOrThrow())),t._setParentLink(this,e),this._sortItems();const a=this._items.indexOf(t);return i===a?{modified:!1}:{modified:ie(this,[lt(i,a,t)]),reverse:[{type:1,id:q(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:q(this.parent.node._id,"Parent node expected to have ID"),parentKey:this.parent.key}}get length(){return this._items.length}push(e){var t;return(t=this._pool)==null||t.assertStorageIsWritable(),this.insert(e,this.length)}insert(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),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 r=this._items[t-1]?this._items[t-1]._getParentKeyOrThrow():void 0,i=this._items[t]?this._items[t]._getParentKeyOrThrow():void 0,s=Be(r,i),a=gt(e);if(a._setParentLink(this,s),this._insertAndSort(a),this._pool&&this._id){const o=this._pool.generateId();a._attach(o,this._pool),this._pool.dispatch(a._toOps(this._id,s,this._pool),[{type:5,id:o}],new Map([[this._id,ie(this,[Ke(t,a)])]]))}}move(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),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 r=null,i=null;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 n=this._items[e];if(n._detach(),this._items.splice(e,1),this.invalidate(),this._pool){const r=n._id;if(r){const i=new Map;i.set(q(this._id),ie(this,[Ft(e)])),this._pool.dispatch([{id:r,opId:this._pool.generateOpId(),type:5}],n._toOps(q(this._id),n._getParentKeyOrThrow()),i)}}}clear(){var e;if((e=this._pool)==null||e.assertStorageIsWritable(),this._pool){const t=[],n=[],r=[];for(const s of this._items){s._detach();const a=s._id;a&&(t.push({type:5,id:a,opId:this._pool.generateOpId()}),n.push(...s._toOps(q(this._id),s._getParentKeyOrThrow())),r.push(Ft(0)))}this._items=[],this.invalidate();const i=new Map;i.set(q(this._id),ie(this,r)),this._pool.dispatch(t,n,i)}else{for(const t of this._items)t._detach();this._items=[],this.invalidate()}}set(e,t){var n;if((n=this._pool)==null||n.assertStorageIsWritable(),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 r=this._items[e],i=r._getParentKeyOrThrow(),s=r._id;r._detach();const a=gt(t);if(a._setParentLink(this,i),this._items[e]=a,this.invalidate(),this._pool&&this._id){const o=this._pool.generateId();a._attach(o,this._pool);const l=new Map;l.set(this._id,ie(this,[_t(e,a)]));const u=a._toOps(this._id,i,this._pool);On(u,s),this._unacknowledgedSets.set(i,q(u[0].opId));const c=r._toOps(this._id,i,void 0);On(c,o),this._pool.dispatch(u,c,l)}}toArray(){return this._items.map(e=>ct(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 ct(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(ct(t),n))}some(e){return this.toArray().some(e)}[Symbol.iterator](){return new qs(this._items)}_createAttachItemAndSort(e,t){const n=Pt(e);n._attach(e.id,q(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=Be(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())}},qs=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:ct(e.value)}}};function ie(e,t){return{node:e,type:"LiveList",updates:t}}function _t(e,t){return{index:e,type:"set",item:t instanceof nt?t.data:t}}function Ft(e){return{index:e,type:"delete"}}function Ke(e,t){return{index:e,type:"insert",item:t instanceof nt?t.data:t}}function lt(e,t,n){return{index:t,type:"move",previousIndex:e,item:n instanceof nt?n.data:n}}function On(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 rt=class extends dn{constructor(e){if(super(),this.unacknowledgedSet=new Map,e){const t=[];for(const n of e){const r=gt(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[s,a]of this._map)r.push(...a._toOps(this._id,s,n));return r}static _deserialize([e,t],n,r){const i=new rt;i._attach(e,r);const s=n.get(e);if(s===void 0)return i;for(const[a,o]of s){const l=Ei([a,o],n,r);l._setParentLink(i,o.parentKey),i._map.set(o.parentKey,l),i.invalidate()}return i}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)be(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,s=r,a=Pt(e);if(this._pool.getNode(n)!==void 0)return{modified:!1};if(t===2){const u=this.unacknowledgedSet.get(s);if(u===i)return this.unacknowledgedSet.delete(s),{modified:!1};if(u!==void 0)return{modified:!1}}else t===1&&this.unacknowledgedSet.delete(s);const o=this._map.get(s);let l;if(o){const u=q(this._id);l=o._toOps(u,s),o._detach()}else l=[{type:5,id:n}];return a._setParentLink(this,s),a._attach(n,this._pool),this._map.set(s,a),this.invalidate(),{modified:{node:this,type:"LiveMap",updates:{[s]:{type:"update"}}},reverse:l}}_detach(){super._detach();for(const e of this._map.values())e._detach()}_detachChild(e){const t=q(this._id),n=q(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,a]of this._map)a===e&&(this._map.delete(s),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:q(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 ct(t)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable();const r=this._map.get(e);r&&r._detach();const i=gt(t);if(i._setParentLink(this,e),this._map.set(e,i),this.invalidate(),this._pool&&this._id){const s=this._pool.generateId();i._attach(s,this._pool);const a=new Map;a.set(this._id,{node:this,type:"LiveMap",updates:{[e]:{type:"update"}}});const o=i._toOps(this._id,e,this._pool);this.unacknowledgedSet.set(e,q(o[0].opId)),this._pool.dispatch(i._toOps(this._id,e,this._pool),r?r._toOps(this._id,e):[{type:5,id:s}],a)}}get size(){return this._map.size}has(e){return this._map.has(e)}delete(e){var t;(t=this._pool)==null||t.assertStorageIsWritable();const n=this._map.get(e);if(n===void 0)return!1;if(n._detach(),this._map.delete(e),this.invalidate(),this._pool&&n._id){const r=q(this._id),i=new Map;i.set(r,{node:this,type:"LiveMap",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:5,id:n._id,opId:this._pool.generateOpId()}],n._toOps(r,e),i)}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=ct(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:ct(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 Ue(e)}},He=class extends dn{constructor(e={}){super(),this._propToLastUpdate=new Map;for(const t in e){const n=e[t];n!==void 0&&be(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=[],s=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(s);for(const[a,o]of this._map)be(o)?i.push(...o._toOps(this._id,a,n)):s.data[a]=o;return i}static _deserialize([e,t],n,r){const i=new He(t.data);return i._attach(e,r),this._deserializeChildren(i,n,r)}static _deserializeChildren(e,t,n){const r=t.get(q(e._id));if(r===void 0)return e;for(const[i,s]of r){const a=Ws([i,s],t,n);Gt(a)&&a._setParentLink(e,s.parentKey),e._map.set(s.parentKey,a),e.invalidate()}return e}_attach(e,t){super._attach(e,t);for(const[n,r]of this._map)be(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,s=bi(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,q(r));else if(this._propToLastUpdate.get(i)!==void 0)return this._propToLastUpdate.get(i)===r?(this._propToLastUpdate.delete(i),{modified:!1}):{modified:!1};const a=q(this._id),o=this._map.get(i);let l;return be(o)?(l=o._toOps(a,i),o._detach()):o===void 0?l=[{type:6,id:a,key:i}]:l=[{type:3,id:a,data:{[i]:o}}],this._map.set(i,s),this.invalidate(),Gt(s)&&(s._setParentLink(this,i),s._attach(n,this._pool)),{reverse:l,modified:{node:this,type:"LiveObject",updates:{[i]:{type:"update"}}}}}_detachChild(e){if(e){const t=q(this._id),n=q(e._parentKey),r=e._toOps(t,n,this._pool);for(const[s,a]of this._map)a===e&&(this._map.delete(s),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())be(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)be(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=q(this._id),i=[],s={type:3,id:r,data:{}};i.push(s);for(const o in e.data){const l=this._map.get(o);be(l)?(i.push(...l._toOps(r,o)),l._detach()):l!==void 0?s.data[o]=l:l===void 0&&i.push({type:6,id:r,key:o})}const a={};for(const o in e.data){const l=e.data[o];if(l===void 0)continue;if(t)this._propToLastUpdate.set(o,q(e.opId));else if(this._propToLastUpdate.get(o)===void 0)n=!0;else if(this._propToLastUpdate.get(o)===e.opId){this._propToLastUpdate.delete(o);continue}else continue;const u=this._map.get(o);be(u)&&u._detach(),n=!0,a[o]={type:"update"},this._map.set(o,l),this.invalidate()}return Object.keys(s.data).length!==0&&i.unshift(s),n?{modified:{node:this,type:"LiveObject",updates:a},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=q(this._id);let i=[];return be(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 ro(this._map)}set(e,t){var n;(n=this._pool)==null||n.assertStorageIsWritable(),this.update({[e]:t})}get(e){return this._map.get(e)}delete(e){var t;(t=this._pool)==null||t.assertStorageIsWritable();const n=e,r=this._map.get(n);if(r===void 0)return;if(this._pool===void 0||this._id===void 0){be(r)&&r._detach(),this._map.delete(n),this.invalidate();return}let i;be(r)?(r._detach(),i=r._toOps(this._id,n)):i=[{type:3,data:{[n]:r},id:this._id}],this._map.delete(n),this.invalidate();const s=new Map;s.set(this._id,{node:this,type:"LiveObject",updates:{[e]:{type:"delete"}}}),this._pool.dispatch([{type:6,key:n,id:this._id,opId:this._pool.generateOpId()}],i,s)}update(e){var t;if((t=this._pool)==null||t.assertStorageIsWritable(),this._pool===void 0||this._id===void 0){for(const u in e){const c=e[u];if(c===void 0)continue;const g=this._map.get(u);be(g)&&g._detach(),be(c)&&c._setParentLink(this,u),this._map.set(u,c),this.invalidate()}return}const n=[],r=[],i=this._pool.generateOpId(),s={},a={id:this._id,type:3,data:{}},o={};for(const u in e){const c=e[u];if(c===void 0)continue;const g=this._map.get(u);if(be(g)?(r.push(...g._toOps(this._id,u)),g._detach()):g===void 0?r.push({type:6,id:this._id,key:u}):a.data[u]=g,be(c)){c._setParentLink(this,u),c._attach(this._pool.generateId(),this._pool);const h=c._toOps(this._id,u,this._pool),v=h.find(A=>A.parentId===this._id);v&&this._propToLastUpdate.set(u,q(v.opId)),n.push(...h)}else s[u]=c,this._propToLastUpdate.set(u,i);this._map.set(u,c),this.invalidate(),o[u]={type:"update"}}Object.keys(a.data).length!==0&&r.unshift(a),Object.keys(s).length!==0&&n.unshift({opId:i,id:this._id,type:3,data:s});const l=new Map;l.set(this._id,{node:this,type:"LiveObject",updates:o}),this._pool.dispatch(n,r,l)}toImmutable(){return super.toImmutable()}_toImmutable(){const e={};for(const[t,n]of this._map)e[t]=Gt(n)?n.toImmutable():n;return e}},Ue=e=>e;function Dn(e){return e.filter(t=>t!=null)}function pn(e){const t=Qe({},e);return Object.keys(e).forEach(n=>{const r=n;t[r]===void 0&&delete t[r]}),t}function Pt(e){return gt(bi(e))}function bi(e){switch(e.type){case 8:return e.data;case 4:return new He(e.data);case 7:return new rt;case 2:return new Xe;default:return Ge(e,"Unknown creation Op")}}function ki(e,t){return e===t?!0:e.parent.type==="HasParent"?ki(e.parent.node,t):!1}function Ei([e,t],n,r){switch(t.type){case 0:return He._deserialize([e,t],n,r);case 1:return Xe._deserialize([e,t],n,r);case 2:return rt._deserialize([e,t],n,r);case 3:return nt._deserialize([e,t],n,r);default:throw new Error("Unexpected CRDT type")}}function Ws([e,t],n,r){switch(t.type){case 0:return He._deserialize([e,t],n,r);case 1:return Xe._deserialize([e,t],n,r);case 2:return rt._deserialize([e,t],n,r);case 3:return t.data;default:throw new Error("Unexpected CRDT type")}}function Gt(e){return mn(e)||Gs(e)||nr(e)}function be(e){return Gt(e)||Zs(e)}function mn(e){return e instanceof Xe}function Gs(e){return e instanceof rt}function nr(e){return e instanceof He}function Zs(e){return e instanceof nt}function ct(e){return e instanceof nt?e.data:e instanceof Xe||e instanceof rt||e instanceof He?e:Ge(e,"Unknown AbstractCrdt")}function gt(e){return e instanceof He||e instanceof rt||e instanceof Xe?e:new nt(e)}function Qs(e,t){const n=[];return e.forEach((r,i)=>{t.get(i)||n.push({type:5,id:i})}),t.forEach((r,i)=>{const s=e.get(i);if(s)r.type===0&&(s.type!==0||JSON.stringify(r.data)!==JSON.stringify(s.data))&&n.push({type:3,id:i,data:r.data}),r.parentKey!==s.parentKey&&n.push({type:1,id:i,parentKey:q(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 eo(e,t){const n=e.updates;for(const[r,i]of xi(t.updates))n[r]=i;return xt(Qe({},t),{updates:n})}function to(e,t){const n=e.updates;for(const[r,i]of xi(t.updates))n[r]=i;return xt(Qe({},t),{updates:n})}function no(e,t){const n=e.updates;return xt(Qe({},t),{updates:n.concat(t.updates)})}function Sn(e,t){return e?e.type==="LiveObject"&&t.type==="LiveObject"?eo(e,t):e.type==="LiveMap"&&t.type==="LiveMap"?to(e,t):e.type==="LiveList"&&t.type==="LiveList"?no(e,t):t:t}function et(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function ro(e){const t={};for(const[n,r]of e)t[n]=r;return t}function xi(e){return Object.entries(e)}function rr(e){try{return JSON.parse(e)}catch{return}}function Ii(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 io(e){if(!et(e))return!1;const{iat:t,exp:n}=e;return typeof t=="number"&&typeof n=="number"}function so(e){const t=Date.now()/1e3;return t>e.exp-300||ttypeof t=="string")}function Si(e){return typeof e.appId=="string"&&e.roomId===void 0&&Oi(e.scopes)}function ir(e){return typeof e.appId=="string"&&typeof e.roomId=="string"&&typeof e.actor=="number"&&(e.id===void 0||typeof e.id=="string")&&Oi(e.scopes)&&(e.maxConnectionsPerRoom===void 0||typeof e.maxConnectionsPerRoom=="number")}function oo(e){return Si(e)||ir(e)}function ao(e){const t=e.split(".");if(t.length!==3)throw new Error("Authentication error: invalid JWT token");const n=rr(Ii(t[1]));if(n&&io(n))return n;throw new Error("Authentication error: missing JWT metadata")}function kr(e){const t=ao(e);if(t&&ir(t))return Vs(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 lo(e,t=e){}function uo(e,t,n=t){}function co(e){}function fo(e,t){}function qe(){const e=new Set,t=new Set;function n(a){return t.add(a),()=>t.delete(a)}function r(a){return e.add(a),()=>e.delete(a)}function i(a){e.forEach(o=>o(a)),e.clear(),t.forEach(o=>o(a))}function s(){e.clear(),t.clear()}return{notify:i,subscribe:n,subscribeOnce:r,clear:s,observable:{subscribe:n,subscribeOnce:r}}}function Pi(e,t){let n=!1;const r=Qe({},e);return Object.keys(t).forEach(i=>{const s=i,a=t[s];r[s]!==a&&(a===void 0?delete r[s]:r[s]=a,n=!0)}),n?r:e}var _n=class{constructor(){this._ev=qe()}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()}},ho=class extends _n{constructor(e){super(),this._me=Ue(pn(e))}_toImmutable(){return this._me}patch(e){const t=this._me,n=Pi(t,e);t!==n&&(this._me=Ue(n),this.invalidate())}};function Li(e){return Object.defineProperty(e,"count",{value:e.length,enumerable:!1}),Object.defineProperty(e,"toArray",{value:()=>e,enumerable:!1}),Ue(e)}function po(e,t){return Ue(pn(xt(Qe({},e),{presence:t})))}var mo=class extends _n{constructor(){super(),this._connections={},this._presences={},this._users={}}_toImmutable(){const e=Dn(Object.keys(this._presences).map(t=>this.getUser(Number(t))));return Li(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 po(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,r){this._connections[e]=Ue({connectionId:e,id:t,info:n,isReadOnly:r}),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]=Ue(pn(t)),this._connections[e]!==void 0&&this._invalidateUser(e)}patchOther(e,t){const n=this._presences[e];if(n===void 0)return;const r=Pi(n,t);n!==r&&(this._presences[e]=Ue(r),this._invalidateUser(e))}};function Ai(e){return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function sr(e){return Array.isArray(e)}function Ti(e){return!Ai(e)&&!sr(e)}var _o=class extends _n{constructor(e){super(),this._value=Ue(pn(e))}_toImmutable(){return this._value}set(e){this._value=Ue(e),this.invalidate()}},go=class extends _n{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)}},Pn=[250,500,1e3,2e3,4e3,8e3,1e4],Ln=[2e3,3e4,6e4,3e5],vo=3e4,yo=2e3;function wo(e){let t=0;return()=>`${e}:${t++}`}function Kt(e){return e.state==="open"||e.state==="connecting"}function bo(e,t,n){var r;const i=d=>d(),s=(r=t.unstable_batchedUpdates)!=null?r:i,a={roomId:t.roomId,getNode:d=>e.nodes.get(d),addNode:(d,I)=>void e.nodes.set(d,I),deleteNode:d=>void e.nodes.delete(d),generateId:()=>`${p()}:${e.clock++}`,generateOpId:()=>`${p()}:${e.opClock++}`,dispatch(d,I,T){const R=e.activeBatch;R?(R.ops.push(...d),T.forEach((F,fe)=>{R.updates.storageUpdates.set(fe,Sn(R.updates.storageUpdates.get(fe),F))}),R.reverseOps.push(...I)):s(()=>{P(I,i),e.redoStack=[],pr(d),b({storageUpdates:T},i)})},assertStorageIsWritable:()=>{if(Kt(e.connection.current)&&e.connection.current.isReadOnly)throw new Error("Cannot write to storage with a read only user, please ensure the user has write permissions")}},o={customEvent:qe(),me:qe(),others:qe(),error:qe(),connection:qe(),storage:qe(),history:qe(),storageDidLoad:qe()},l=n||{authenticate(d,I){const T=e.token,R=T!==null&&kr(T);if(R&&!so(R)){const F=I(T);Z(R,F);return}else return d(t.roomId).then(({token:F})=>{if(e.connection.current.state!=="authenticating")return;const fe=kr(F),re=I(F);Z(fe,re),e.token=F}).catch(F=>ee())},send(d){if(e.socket===null)throw new Error("Can't send message if socket is null");e.socket.send(JSON.stringify(d))},delayFlush(d){return setTimeout(Re,d)},startHeartbeatInterval(){return setInterval(Le,vo)},schedulePongTimeout(){return setTimeout(It,yo)},scheduleReconnect(d){return setTimeout(N,d)}},u=new go([e.connection,e.me],(d,I)=>Kt(d)?{connectionId:d.id,id:d.userId,info:d.userInfo,presence:I,isReadOnly:d.isReadOnly}:null);function c(d,I){if(d.items.length===0)throw new Error("Internal error: cannot load storage without items");e.root?h(d.items,I):e.root=v(d.items);for(const T in e.initialStorage)e.root.get(T)===void 0&&e.root.set(T,e.initialStorage[T])}function g(d){const I=new Map;let T=null;for(const[R,F]of d)if(mi(F))T=[R,F];else{const fe=[R,F],re=I.get(F.parentId);re!==void 0?re.push(fe):I.set(F.parentId,[fe])}if(T===null)throw new Error("Root can't be null");return[T,I]}function h(d,I){if(!e.root)return;const T=new Map;e.nodes.forEach((fe,re)=>{T.set(re,fe._serialize())});const R=Qs(T,new Map(d)),F=m(R,!1);b(F.updates,I)}function v(d){const[I,T]=g(d);return He._deserialize(I,T,a)}function A(d,I){e.undoStack.length>=50&&e.undoStack.shift(),e.undoStack.push(d),D(I)}function P(d,I){e.pausedHistory!==null?e.pausedHistory.unshift(...d):A(d,I)}function b({storageUpdates:d=new Map,presence:I=!1,others:T=[]},R){R(()=>{if(T.length>0){const F=e.others.current;for(const fe of T)o.others.notify({others:F,event:fe})}if(I&&o.me.notify(e.me.current),d.size>0){const F=Array.from(d.values());o.storage.notify(F)}})}function p(){const d=e.connection.current;if(Kt(d))return d.id;if(e.lastConnectionId!==null)return e.lastConnectionId;throw new Error("Internal. Tried to get connection id but connection was never open")}function m(d,I){const T={reverse:[],updates:{storageUpdates:new Map,presence:!1}},R=new Set;for(const F of d)if(F.type==="presence"){const fe={type:"presence",data:{}};for(const re in F.data)fe.data[re]=e.me.current[re];if(e.me.patch(F.data),e.buffer.me===null)e.buffer.me={type:"partial",data:F.data};else for(const re in F.data)e.buffer.me.data[re]=F.data[re];T.reverse.unshift(fe),T.updates.presence=!0}else{let fe;F.opId||(F.opId=a.generateOpId()),I?fe=0:fe=e.offlineOperations.delete(q(F.opId))?2:1;const re=k(F,fe);if(re.modified){const In=re.modified.node.parent.type==="HasParent"?q(re.modified.node.parent.node._id,"Expected parent node to have an ID"):void 0;(!In||!R.has(In))&&(T.updates.storageUpdates.set(q(re.modified.node._id),Sn(T.updates.storageUpdates.get(q(re.modified.node._id)),re.modified)),T.reverse.unshift(...re.reverse)),(F.type===2||F.type===7||F.type===4)&&R.add(q(re.modified.node._id))}}return T}function k(d,I){switch(d.type){case 6:case 3:case 5:{const T=e.nodes.get(d.id);return T===void 0?{modified:!1}:T._apply(d,I===0)}case 1:{const T=e.nodes.get(d.id);return T===void 0?{modified:!1}:T.parent.type==="HasParent"&&mn(T.parent.node)?T.parent.node._setChildKey(d.parentKey,T,I):{modified:!1}}case 4:case 2:case 7:case 8:{if(d.parentId===void 0)return{modified:!1};const T=e.nodes.get(d.parentId);return T===void 0?{modified:!1}:T._attachChild(d,I)}}}function _(d,I){return o.storage.subscribe(T=>{const R=T.filter(F=>ki(F.node,d));R.length>0&&I(R)})}function $(d,I){return o.storage.subscribe(T=>{for(const R of T)R.node._id===d._id&&I(R.node)})}function E(d,I,T){if(typeof d=="string"&&js(d)){if(typeof I!="function")throw new Error("Second argument must be a callback function");const R=I;switch(d){case"event":return o.customEvent.subscribe(R);case"my-presence":return o.me.subscribe(R);case"others":{const F=R;return o.others.subscribe(({others:fe,event:re})=>F(fe,re))}case"error":return o.error.subscribe(R);case"connection":return o.connection.subscribe(R);case"storage":return o.storage.subscribe(R);case"history":return o.history.subscribe(R);default:return Ge(d,"Unknown event")}}if(I===void 0||typeof d=="function")if(typeof d=="function"){const R=d;return o.storage.subscribe(R)}else throw new Error("Please specify a listener callback");if(be(d)){const R=d;return T!=null&&T.isDeep?_(R,I):$(R,I)}throw new Error(`"${d}" is not a valid event name`)}function O(){return e.connection.current.state}function N(){var d,I,T,R;if(e.connection.current.state!=="closed"&&e.connection.current.state!=="unavailable")return;const F=Oo(t.authentication,(I=(d=t.polyfills)==null?void 0:d.fetch)!=null?I:t.fetchPolyfill),fe=Io(t.liveblocksServer,(R=(T=t.polyfills)==null?void 0:T.WebSocket)!=null?R:t.WebSocketPolyfill);te({state:"authenticating"},s),l.authenticate(F,fe)}function U(d,I){const T={};e.buffer.me===null&&(e.buffer.me={type:"partial",data:{}});for(const R in d){const F=d[R];F!==void 0&&(e.buffer.me.data[R]=F,T[R]=e.me.current[R])}e.me.patch(d),e.activeBatch?(I!=null&&I.addToHistory&&e.activeBatch.reverseOps.push({type:"presence",data:T}),e.activeBatch.updates.presence=!0):(Re(),s(()=>{I!=null&&I.addToHistory&&P([{type:"presence",data:T}],i),b({presence:!0},i)}))}function V(d){return d.includes("room:read")&&d.includes("room:presence:write")&&!d.includes("room:write")}function Z(d,I){I.addEventListener("message",ne),I.addEventListener("open",xe),I.addEventListener("close",ke),I.addEventListener("error",Pe),te({state:"connecting",id:d.actor,userInfo:d.info,userId:d.id,isReadOnly:V(d.scopes)},s),e.idFactory=wo(d.actor),e.socket=I}function ee(d){e.token=null,te({state:"unavailable"},s),e.numberOfRetry++,e.timeoutHandles.reconnect=l.scheduleReconnect(Ee())}function we(d){d==="visible"&&e.connection.current.state==="open"&&Le()}function y(d){if(d.targetActor!==void 0){const T=e.others.getUser(d.actor);e.others.setOther(d.actor,d.data);const R=e.others.getUser(d.actor);if(T===void 0&&R!==void 0)return{type:"enter",user:R}}else e.others.patchOther(d.actor,d.data);const I=e.others.getUser(d.actor);if(I)return{type:"update",updates:d.data,user:I}}function S(d){const I=e.others.getUser(d.actor);return I?(e.others.removeConnection(d.actor),{type:"leave",user:I}):null}function x(d){for(const I in d.users){const T=d.users[I],R=Number(I);e.others.setConnection(R,T.id,T.info,V(T.scopes))}return{type:"reset"}}function z(){e.connection.current.state==="unavailable"&&dr()}function D(d){d(()=>{o.history.notify({canUndo:_r(),canRedo:gr()})})}function j(d){e.others.setConnection(d.actor,d.id,d.info,V(d.scopes)),e.buffer.messages.push({type:100,data:e.me.current,targetActor:d.actor}),Re();const I=e.others.getUser(d.actor);return I?{type:"enter",user:I}:void 0}function Y(d){return Ti(d)?d:null}function Q(d){const I=rr(d);return I===void 0?null:sr(I)?Dn(I.map(T=>Y(T))):Dn([Y(I)])}function ne(d){if(d.data==="pong"){clearTimeout(e.timeoutHandles.pongTimeout);return}const I=Q(d.data);if(I===null||I.length===0)return;const T={storageUpdates:new Map,others:[]};s(()=>{for(const R of I)switch(R.type){case 101:{const F=j(R);F&&T.others.push(F);break}case 100:{const F=y(R);F&&T.others.push(F);break}case 103:{o.customEvent.notify({connectionId:R.actor,event:R.event});break}case 102:{const F=S(R);F&&T.others.push(F);break}case 104:{T.others.push(x(R));break}case 200:{const F=new Map(e.offlineOperations);c(R,i),ys(F,i),xn==null||xn(),o.storageDidLoad.notify();break}case 201:{m(R.ops,!1).updates.storageUpdates.forEach((fe,re)=>{T.storageUpdates.set(re,Sn(T.storageUpdates.get(re),fe))});break}}b(T,i)})}function ke(d){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(),s(()=>{if(b({others:[{type:"reset"}]},i),d.code>=4e3&&d.code<=4100){te({state:"failed"},i);const I=new xo(d.reason,d.code);o.error.notify(I);const T=Ee(!0);e.numberOfRetry++,te({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(T)}else if(d.code===4999)te({state:"closed"},i);else{const I=Ee();e.numberOfRetry++,te({state:"unavailable"},i),e.timeoutHandles.reconnect=l.scheduleReconnect(I)}})}function te(d,I){e.connection.set(d),I(()=>{o.connection.notify(d.state)})}function Ee(d=!1){return d?Ln[e.numberOfRetry0&&d.forEach(R=>{e.offlineOperations.set(q(R.opId),R)}),e.socket===null||e.socket.readyState!==e.socket.OPEN){e.buffer.storageOperations=[];return}const I=Date.now();if(I-e.lastFlushTime>t.throttleDelay){const R=ws(e);if(R.length===0)return;l.send(R),e.buffer={messages:[],storageOperations:[],me:null},e.lastFlushTime=I}else e.timeoutHandles.flush!==null&&clearTimeout(e.timeoutHandles.flush),e.timeoutHandles.flush=l.delayFlush(t.throttleDelay-(I-e.lastFlushTime))}function ws(d){const I=[];d.buffer.me&&I.push(d.buffer.me.type==="full"?{type:100,targetActor:-1,data:d.buffer.me.data}:{type:100,data:d.buffer.me.data});for(const T of d.buffer.messages)I.push(T);return d.buffer.storageOperations.length>0&&I.push({type:201,ops:d.buffer.storageOperations}),I}function bs(){e.socket&&(e.socket.removeEventListener("open",xe),e.socket.removeEventListener("message",ne),e.socket.removeEventListener("close",ke),e.socket.removeEventListener("error",Pe),e.socket.close(),e.socket=null),s(()=>{te({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(),b({others:[{type:"reset"}]},i),Object.values(o).forEach(d=>d.clear())})}function ks(){return e.me.current}function Es(){return e.others.current}function xs(d,I={shouldQueueEventIfNotReady:!1}){e.socket===null&&!I.shouldQueueEventIfNotReady||(e.buffer.messages.push({type:103,event:d}),Re())}function pr(d){e.buffer.storageOperations.push(...d),Re()}let En=null,xn=null;function mr(){return En===null&&(e.buffer.messages.push({type:200}),Re(),En=new Promise(d=>xn=d)),En}function Is(){const d=e.root;return d!==void 0?d:(mr(),null)}function Os(){return er(this,null,function*(){return e.root?Promise.resolve({root:e.root}):(yield mr(),{root:q(e.root)})})}function Ss(){if(e.activeBatch)throw new Error("undo is not allowed during a batch");const d=e.undoStack.pop();if(d===void 0)return;e.pausedHistory=null;const I=m(d,!0);s(()=>{b(I.updates,i),e.redoStack.push(I.reverse),D(i)});for(const T of d)T.type!=="presence"&&e.buffer.storageOperations.push(T);Re()}function _r(){return e.undoStack.length>0}function Ps(){if(e.activeBatch)throw new Error("redo is not allowed during a batch");const d=e.redoStack.pop();if(d===void 0)return;e.pausedHistory=null;const I=m(d,!0);s(()=>{b(I.updates,i),e.undoStack.push(I.reverse),D(i)});for(const T of d)T.type!=="presence"&&e.buffer.storageOperations.push(T);Re()}function gr(){return e.redoStack.length>0}function Ls(d){if(e.activeBatch)return d();let I;return s(()=>{e.activeBatch={ops:[],updates:{storageUpdates:new Map,presence:!1,others:[]},reverseOps:[]};try{I=d()}finally{const T=e.activeBatch;e.activeBatch=null,T.reverseOps.length>0&&P(T.reverseOps,i),T.ops.length>0&&(e.redoStack=[]),T.ops.length>0&&pr(T.ops),b(T.updates,i),Re()}}),I}function As(){e.pausedHistory=[]}function Ts(){const d=e.pausedHistory;e.pausedHistory=null,d!==null&&d.length>0&&A(d,s)}function Cs(){e.socket&&(e.socket=null)}function $s(d){ke(d)}return{onClose:ke,onMessage:ne,authenticationSuccess:Z,heartbeat:Le,onNavigatorOnline:z,simulateSocketClose:Cs,simulateSendCloseEvent:$s,onVisibilityChange:we,getUndoStack:()=>e.undoStack,getItemsCount:()=>e.nodes.size,connect:N,disconnect:bs,subscribe:E,updatePresence:U,broadcastEvent:xs,batch:Ls,undo:Ss,redo:Ps,canUndo:_r,canRedo:gr,pauseHistory:As,resumeHistory:Ts,getStorage:Os,getStorageSnapshot:Is,events:{customEvent:o.customEvent.observable,others:o.others.observable,me:o.me.observable,error:o.error.observable,connection:o.connection.observable,storage:o.storage.observable,history:o.history.observable,storageDidLoad:o.storageDidLoad.observable},getConnectionState:O,isSelfAware:()=>Kt(e.connection.current),getSelf:()=>u.current,getPresence:ks,getOthers:Es}}function ko(e,t){const n=new mo,r=new _o({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 ho(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 Eo(e,t){const{initialPresence:n,initialStorage:r}=e,i=ko(typeof n=="function"?n(t.roomId):n,typeof r=="function"?r(t.roomId):r),s=bo(i,t),a={id:t.roomId,getConnectionState:s.getConnectionState,isSelfAware:s.isSelfAware,getSelf:s.getSelf,subscribe:s.subscribe,getPresence:s.getPresence,updatePresence:s.updatePresence,getOthers:s.getOthers,broadcastEvent:s.broadcastEvent,getStorage:s.getStorage,getStorageSnapshot:s.getStorageSnapshot,events:s.events,batch:s.batch,history:{undo:s.undo,redo:s.redo,canUndo:s.canUndo,canRedo:s.canRedo,pause:s.pauseHistory,resume:s.resumeHistory},__INTERNAL_DO_NOT_USE:{simulateCloseWebsocket:s.simulateSocketClose,simulateSendCloseEvent:s.simulateSendCloseEvent}};return{connect:s.connect,disconnect:s.disconnect,onNavigatorOnline:s.onNavigatorOnline,onVisibilityChange:s.onVisibilityChange,room:a}}var xo=class extends Error{constructor(e,t){super(e),this.code=t}};function Io(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.5`)}function Oo(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=>Er(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=>Er(t||fetch,e.url,{room:n})}if(e.type==="custom")return n=>er(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 Er(e,t,n){return er(this,null,function*(){const r=yield e(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new An(`Expected a status 200 but got ${r.status} when doing a POST request on "${t}"`);let i;try{i=yield r.json()}catch(a){throw new An(`Expected a JSON response when doing a POST request on "${t}". ${a}`)}if(!et(i)||typeof i.token!="string")throw new An(`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${t}", but got ${JSON.stringify(i)}`);const{token:s}=i;return{token:s}})}var An=class extends Error{constructor(e){super(e)}};function So(e){const t=e,n=Po(e),r=new Map;function i(o){const l=r.get(o);return l?l.room:null}function s(o,l){var u,c;const g=l.shouldInitiallyConnect===void 0?!0:l.shouldInitiallyConnect;let h=r.get(o);if(h)return h.room;if(l.initialPresence===null||l.initialPresence,h=Eo({initialPresence:(u=l.initialPresence)!=null?u:{},initialStorage:l.initialStorage},{roomId:o,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:Lo(t,o)}),r.set(o,h),g){if(typeof atob>"u"){if(((c=t.polyfills)==null?void 0:c.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");zs.atob=t.polyfills.atob}h.connect()}return h.room}function a(o){const l=r.get(o);l&&(l.disconnect(),r.delete(o))}return typeof window<"u"&&typeof window.addEventListener<"u"&&window.addEventListener("online",()=>{for(const[,o]of r)o.onNavigatorOnline()}),typeof document<"u"&&document.addEventListener("visibilitychange",()=>{for(const[,o]of r)o.onVisibilityChange(document.visibilityState)}),{getRoom:i,enter:s,leave:a}}function Po(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 Lo(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_. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientPublicKey");return{type:"public",publicApiKey:n,url:Ao(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 Ao(e,t){return e.publicAuthorizeEndpoint?e.publicAuthorizeEndpoint.replace("{roomId}",t):`https://api.liveblocks.io/v2/rooms/${encodeURIComponent(t)}/public/authorize`}function Ci(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=Me(r))}return t}function To(e){return Ci(e.toObject())}function Co(e){const t={};for(const[n,r]of e.entries())t[n]=Me(r);return t}function $i(e){return e.map(Me)}function $o(e){return $i(e.toArray())}function Me(e){return e instanceof He?To(e):e instanceof Xe?$o(e):e instanceof rt?Co(e):e instanceof nt?e.data:Array.isArray(e)?$i(e):et(e)?Ci(e):e}function ft(e){if(Array.isArray(e))return new Xe(e.map(ft));if(et(e)){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=ft(r))}return new He(t)}else return e}function No(e,t,n){let r=0,i=t.length-1,s=n.length-1,a=t[0],o=n[0];e:{for(;a===o;){if(++r,r>i||r>s)break e;a=t[r],o=n[r]}for(a=t[i],o=n[s];a===o;){if(i--,s--,r>i||r>s)break e;a=t[i],o=n[s]}}if(r>i){if(r<=s)for(;r<=s;)e.insert(ft(n[r]),r),r++}else if(r>s){let l=r;for(;l<=i;)e.delete(r),l++}else{for(;r<=i&&r<=s;){a=t[r],o=n[r];const u=e.get(r);nr(u)&&et(a)&&et(o)?Ri(u,a,o):e.set(r,ft(o)),r++}for(;r<=s;)e.insert(ft(n[r]),r),r++;let l=r;for(;l<=i;)e.delete(r),l++}}function Ni(e,t,n,r){const i=e.get(t);if(r===void 0)e.delete(t);else if(i===void 0)e.set(t,ft(r));else{if(n===r)return;mn(i)&&Array.isArray(n)&&Array.isArray(r)?No(i,n,r):nr(i)&&et(n)&&et(r)?Ri(i,n,r):e.set(t,ft(r))}}function Ri(e,t,n){const r={};for(const i in n)Ni(e,i,t[i],n[i]);for(const i in t)n[i]===void 0&&e.delete(i);Object.keys(r).length>0&&e.update(r)}function Ro(e){const t=[];for(;e.parent.type==="HasParent";)mn(e.parent.node)?t.push(e.parent.node._indexOfPosition(e.parent.key)):t.push(e.parent.key),e=e.parent.node;return t}function Mo(e,t){return t.reduce((n,r)=>Do(n,r),e)}function Do(e,t){const n=Ro(t.node);return Un(e,n,t)}function Un(e,t,n){var r,i,s,a;const o=t.pop();if(o===void 0)switch(n.type){case"LiveObject":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveObject but state was not an object");const l=Object.assign({},e);for(const u in n.updates)if(((r=n.updates[u])==null?void 0:r.type)==="update"){const c=n.node.get(u);c!==void 0&&(l[u]=Me(c))}else((i=n.updates[u])==null?void 0:i.type)==="delete"&&delete l[u];return l}case"LiveList":{if(!Array.isArray(e))throw new Error("Internal: received update on LiveList but state was not an array");let l=e.map(u=>u);for(const u of n.updates)u.type==="set"?l=l.map((c,g)=>g===u.index?Me(u.item):c):u.type==="insert"?u.index===l.length?l.push(Me(u.item)):l=[...l.slice(0,u.index),Me(u.item),...l.slice(u.index)]:u.type==="delete"?l.splice(u.index,1):u.type==="move"&&(u.previousIndex>u.index?l=[...l.slice(0,u.index),Me(u.item),...l.slice(u.index,u.previousIndex),...l.slice(u.previousIndex+1)]:l=[...l.slice(0,u.previousIndex),...l.slice(u.previousIndex+1,u.index+1),Me(u.item),...l.slice(u.index+1)]);return l}case"LiveMap":{if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("Internal: received update on LiveMap but state was not an object");const l=Object.assign({},e);for(const u in n.updates)if(((s=n.updates[u])==null?void 0:s.type)==="update"){const c=n.node.get(u);c!==void 0&&(l[u]=Me(c))}else((a=n.updates[u])==null?void 0:a.type)==="delete"&&delete l[u];return l}}if(Array.isArray(e)){const l=[...e];return l[o]=Un(e[o],t,n),l}else if(e!==null&&typeof e=="object"){const l=e[o];return l===void 0?e:xt(Qe({},e),{[o]:Un(l,t,n)})}else return e}function Uo(e,t){if(e.length!==t.length)return!1;for(let n=0;nObject.prototype.hasOwnProperty.call(t,r)&&Object.is(e[r],t[r]))}function Ho(e,t){if(Object.is(e,t))return!0;const n=Array.isArray(e),r=Array.isArray(t);return n||r?!n||!r?!1:Uo(e,t):zo(e,t)}M.ClientMsgCode=hi;M.CrdtType=pi;M.LiveList=Xe;M.LiveMap=rt;M.LiveObject=He;M.OpCode=di;M.ServerMsgCode=gi;M.WebsocketCloseCodes=vi;M.asArrayWithLegacyMethods=Li;M.assertNever=Ge;M.b64decode=Ii;M.comparePosition=wi;M.createClient=So;M.deprecate=lo;M.deprecateIf=uo;M.errorIf=fo;M.freeze=Ue;M.isAppOnlyAuthToken=Si;M.isAuthToken=oo;M.isChildCrdt=_i;M.isJsonArray=sr;M.isJsonObject=Ti;M.isJsonScalar=Ai;M.isPlainObject=et;M.isRoomAuthToken=ir;M.isRootCrdt=mi;M.legacy_patchImmutableObject=Mo;M.lsonToJson=Me;M.makePosition=Be;M.nn=q;M.patchLiveObjectKey=Ni;M.shallow=Ho;M.throwUsageError=co;M.tryParseJson=rr;const Fo=M.ClientMsgCode,Ko=M.CrdtType,Bo=M.LiveList,Vo=M.LiveMap,jo=M.LiveObject,Xo=M.OpCode,Yo=M.ServerMsgCode,Jo=M.WebsocketCloseCodes,qo=M.asArrayWithLegacyMethods,Wo=M.assertNever,Go=M.b64decode,Zo=M.comparePosition,Qo=M.createClient,ea=M.deprecate,ta=M.deprecateIf,na=M.errorIf,ra=M.freeze,ia=M.isAppOnlyAuthToken,sa=M.isAuthToken,oa=M.isChildCrdt,aa=M.isJsonArray,la=M.isJsonObject,ua=M.isJsonScalar,ca=M.isPlainObject,fa=M.isRoomAuthToken,ha=M.isRootCrdt,da=M.legacy_patchImmutableObject,pa=M.lsonToJson,ma=M.makePosition,_a=M.nn,ga=M.patchLiveObjectKey,va=M.shallow,ya=M.throwUsageError,wa=M.tryParseJson,ba=Object.freeze(Object.defineProperty({__proto__:null,default:M,ClientMsgCode:Fo,CrdtType:Ko,LiveList:Bo,LiveMap:Vo,LiveObject:jo,OpCode:Xo,ServerMsgCode:Yo,WebsocketCloseCodes:Jo,asArrayWithLegacyMethods:qo,assertNever:Wo,b64decode:Go,comparePosition:Zo,createClient:Qo,deprecate:ea,deprecateIf:ta,errorIf:na,freeze:ra,isAppOnlyAuthToken:ia,isAuthToken:sa,isChildCrdt:oa,isJsonArray:aa,isJsonObject:la,isJsonScalar:ua,isPlainObject:ca,isRoomAuthToken:fa,isRootCrdt:ha,legacy_patchImmutableObject:da,lsonToJson:pa,makePosition:ma,nn:_a,patchLiveObjectKey:ga,shallow:va,throwUsageError:ya,tryParseJson:wa},Symbol.toStringTag,{value:"Module"})),ka=Hs(ba);Object.defineProperty(ze,"__esModule",{value:!0});var Ut=ka;ze.LiveList=Ut.LiveList;ze.LiveMap=Ut.LiveMap;ze.LiveObject=Ut.LiveObject;ze.createClient=Ut.createClient;ze.shallow=Ut.shallow;ze.LiveList;ze.LiveMap;const Ea=ze.LiveObject,xa=ze.createClient;ze.shallow;const Mi=Symbol(),Di=Symbol();function Ia(e){let t;const n=e[2].default,r=qn(n,e,e[1],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&2)&&Wn(r,n,i,i[1],t?Zn(n,i[1],s,null):Gn(i[1]),null)},i(i){t||(H(r,i),t=!0)},o(i){X(r,i),t=!1},d(i){r&&r.d(i)}}}function Oa(e,t,n){let{$$slots:r={},$$scope:i}=t,{client:s}=t;if(!s)throw new Error("LiveblocksProvider requires a client");return li(Mi,s),e.$$set=a=>{"client"in a&&n(0,s=a.client),"$$scope"in a&&n(1,i=a.$$scope)},[s,i,r]}class Sa extends he{constructor(t){super(),de(this,t,Oa,Ia,pe,{client:0})}}function Pa(e){let t;const n=e[3].default,r=qn(n,e,e[2],null);return{c(){r&&r.c()},l(i){r&&r.l(i)},m(i,s){r&&r.m(i,s),t=!0},p(i,[s]){r&&r.p&&(!t||s&4)&&Wn(r,n,i,i[2],t?Zn(n,i[2],s,null):Gn(i[2]),null)},i(i){t||(H(r,i),t=!0)},o(i){X(r,i),t=!1},d(i){r&&r.d(i)}}}function La(e,t,n){let{$$slots:r={},$$scope:i}=t,{id:s}=t,{defaultPresence:a=()=>({})}=t;if(!s)throw new Error("RoomProvider requires an id");const o=ui(Mi);if(o){const l=o.enter(s,a());li(Di,l),hn(()=>{o.leave(s)})}return e.$$set=l=>{"id"in l&&n(0,s=l.id),"defaultPresence"in l&&n(1,a=l.defaultPresence),"$$scope"in l&&n(2,i=l.$$scope)},[s,a,i,r]}class Aa extends he{constructor(t){super(),de(this,t,La,Pa,pe,{id:0,defaultPresence:1})}}function Ta(e){let t,n;return{c(){t=me("svg"),n=me("path"),this.h()},l(r){t=_e(r,"svg",{class:!0,width:!0,viewBox:!0,fill:!0,xmlns:!0});var i=C(t);n=_e(i,"path",{d:!0,fill:!0}),C(n).forEach(w),i.forEach(w),this.h()},h(){f(n,"d","M0.91603 0.916054L7.09131 14.9234L8.89871 8.89873L14.9234 7.09133L0.91603 0.916054Z"),f(n,"fill","#FFB800"),f(t,"class",e[0]),f(t,"width","40"),f(t,"viewBox","0 0 15 15"),f(t,"fill","currentColor"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){J(r,t,i),L(t,n)},p(r,[i]){i&1&&f(t,"class",r[0])},i:ye,o:ye,d(r){r&&w(t)}}}function Ca(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class $a extends he{constructor(t){super(),de(this,t,Ca,Ta,pe,{classList:0})}}function xr(e){let t,n,r;return{c(){t=K("div"),n=ge(e[2]),this.h()},l(i){t=B(i,"DIV",{class:!0,style:!0});var s=C(t);n=ve(s,e[2]),s.forEach(w),this.h()},h(){f(t,"class","absolute right-0 text-4xl col-start-2 row-start-2"),f(t,"style",r=`text-shadow: 0px 5px 5px ${e[1]}`)},m(i,s){J(i,t,s),L(t,n)},p(i,s){s&4&&ot(n,i[2]),s&2&&r!==(r=`text-shadow: 0px 5px 5px ${i[1]}`)&&f(t,"style",r)},d(i){i&&w(t)}}}function Na(e){let t,n,r,i,s;n=new $a({props:{classList:"block z-0 col-span-2 row-span-2"}});let a=e[2]&&xr(e);return{c(){t=K("div"),se(n.$$.fragment),r=W(),a&&a.c(),this.h()},l(o){t=B(o,"DIV",{class:!0,style:!0});var l=C(t);oe(n.$$.fragment,l),r=G(l),a&&a.l(l),l.forEach(w),this.h()},h(){f(t,"class","cursor svelte-14ka0w3"),f(t,"style",i=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k});`)},m(o,l){J(o,t,l),ae(n,t,null),L(t,r),a&&a.m(t,null),s=!0},p(o,[l]){o[2]?a?a.p(o,l):(a=xr(o),a.c(),a.m(t,null)):a&&(a.d(1),a=null),(!s||l&9&&i!==(i=`transform: translateX(${o[3].x}px) translateY(${o[3].y}px) scale(${o[0].k});`))&&f(t,"style",i)},i(o){s||(H(n.$$.fragment,o),s=!0)},o(o){X(n.$$.fragment,o),s=!1},d(o){o&&w(t),le(n),a&&a.d()}}}function Ra(e,t,n){let r,{transform:i}=t,{color:s=""}=t,{emoji:a}=t,{position:o={x:0,y:0}}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"color"in l&&n(1,s=l.color),"emoji"in l&&n(2,a=l.emoji),"position"in l&&n(4,o=l.position)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(o.x),y:i.applyY(o.y)})},[i,s,a,r,o]}class Ma extends he{constructor(t){super(),de(this,t,Ra,Na,pe,{transform:0,color:1,emoji:2,position:4})}}function Da(e){let t,n,r;return{c(){t=me("svg"),n=me("path"),r=me("path"),this.h()},l(i){t=_e(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=C(t);n=_e(s,"path",{d:!0,fill:!0}),C(n).forEach(w),r=_e(s,"path",{d:!0,fill:!0}),C(r).forEach(w),s.forEach(w),this.h()},h(){f(n,"d","M21 10.5C21 4.70101 16.299 0 10.5 0C4.70101 0 0 4.70101 0 10.5C0 16.299 4.70101 21 10.5 21C16.299 21 21 16.299 21 10.5Z"),f(n,"fill","white"),f(r,"d","M10.5006 17C9.6233 17 8.77136 16.8286 7.97021 16.4896C7.19572 16.1621 6.50122 15.6924 5.90448 15.0957C5.30774 14.499 4.83797 13.8046 4.5104 13.0302C4.1714 12.2291 4 11.3772 4 10.5C4 10.2474 4.20441 10.043 4.45708 10.043C4.70974 10.043 4.91415 10.2474 4.91415 10.5C4.91415 11.2541 5.06143 11.9854 5.35345 12.6747C5.63532 13.3399 6.0378 13.9379 6.55074 14.4508C7.06368 14.9637 7.66169 15.3674 8.32698 15.6479C9.01514 15.9387 9.74646 16.0859 10.5006 16.0859C11.2548 16.0859 11.9861 15.9387 12.6756 15.6467C13.3409 15.3648 13.9389 14.9624 14.4518 14.4495C14.9647 13.9366 15.3685 13.3387 15.6491 12.6734C15.9398 11.9854 16.0871 11.2541 16.0871 10.5C16.0871 9.7459 15.9398 9.01465 15.6478 8.32529C15.3669 7.66166 14.9604 7.05857 14.4505 6.54922C13.9417 6.03876 13.3384 5.63215 12.6743 5.35205C11.9861 5.06133 11.2548 4.91406 10.5006 4.91406C10.248 4.91406 10.0436 4.70967 10.0436 4.45703C10.0436 4.20439 10.248 4 10.5006 4C11.378 4 12.2299 4.17139 13.0311 4.51035C13.8055 4.83789 14.5 5.30762 15.0968 5.9043C15.6935 6.50098 16.162 7.19668 16.4896 7.96982C16.8286 8.7709 17 9.62275 17 10.5C17 11.3772 16.8286 12.2291 16.4896 13.0302C16.1633 13.8046 15.6935 14.499 15.0968 15.0957C14.5 15.6924 13.8043 16.1608 13.0311 16.4884C12.2299 16.8286 11.378 17 10.5006 17Z"),f(r,"fill","currentColor"),f(t,"class","animate-spin"),f(t,"width","51"),f(t,"height","51"),f(t,"viewBox","0 0 21 21"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){J(i,t,s),L(t,n),L(t,r)},p:ye,i:ye,o:ye,d(i){i&&w(t)}}}class Ui extends he{constructor(t){super(),de(this,t,null,Da,pe,{})}}function Ir(e){let t,n,r;return n=new Ui({}),{c(){t=K("div"),se(n.$$.fragment),this.h()},l(i){t=B(i,"DIV",{class:!0});var s=C(t);oe(n.$$.fragment,s),s.forEach(w),this.h()},h(){f(t,"class","absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2")},m(i,s){J(i,t,s),ae(n,t,null),r=!0},i(i){r||(H(n.$$.fragment,i),r=!0)},o(i){X(n.$$.fragment,i),r=!1},d(i){i&&w(t),le(n)}}}function Ua(e){let t,n,r,i,s,a,o,l=e[2]&&Ir();return{c(){t=K("div"),n=K("div"),r=K("div"),i=ge(e[1]),s=W(),l&&l.c(),this.h()},l(u){t=B(u,"DIV",{class:!0,style:!0});var c=C(t);n=B(c,"DIV",{class:!0});var g=C(n);r=B(g,"DIV",{class:!0});var h=C(r);i=ve(h,e[1]),h.forEach(w),g.forEach(w),s=G(c),l&&l.l(c),c.forEach(w),this.h()},h(){f(r,"class","font-bold text-xl text-[#EC8E65] text-center px-2 line-clamp-4"),f(n,"class","pointer-events-none touch-none"),f(t,"class","frame @apply absolute top-0 left-0 ring-8 ring-[#EC8E65] w-[512px] h-[512px]"),f(t,"style",a=`transform: translateX(${e[3].x}px) translateY(${e[3].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(u,c){J(u,t,c),L(t,n),L(n,r),L(r,i),L(t,s),l&&l.m(t,null),o=!0},p(u,[c]){(!o||c&2)&&ot(i,u[1]),u[2]?l?c&4&&H(l,1):(l=Ir(),l.c(),H(l,1),l.m(t,null)):l&&(Te(),X(l,1,1,()=>{l=null}),Ce()),(!o||c&9&&a!==(a=`transform: translateX(${u[3].x}px) translateY(${u[3].y}px) scale(${u[0].k}); transform-origin: 0 0;`))&&f(t,"style",a)},i(u){o||(H(l),o=!0)},o(u){X(l),o=!1},d(u){u&&w(t),l&&l.d()}}}function za(e,t,n){let r,{transform:i}=t,{position:s={x:0,y:0}}=t,{prompt:a=""}=t,{isLoading:o=!1}=t;return e.$$set=l=>{"transform"in l&&n(0,i=l.transform),"position"in l&&n(4,s=l.position),"prompt"in l&&n(1,a=l.prompt),"isLoading"in l&&n(2,o=l.isLoading)},e.$$.update=()=>{e.$$.dirty&17&&n(3,r={x:i.applyX(s.x),y:i.applyY(s.y)})},[i,a,o,r,s]}class Ha extends he{constructor(t){super(),de(this,t,za,Ua,pe,{transform:0,position:4,prompt:1,isLoading:2})}}function Fa(e){let t,n,r,i,s;return{c(){t=K("span"),n=ge("+"),r=W(),i=K("span"),s=ge("Prompt + Paint"),this.h()},l(a){t=B(a,"SPAN",{class:!0});var o=C(t);n=ve(o,"+"),o.forEach(w),r=G(a),i=B(a,"SPAN",{});var l=C(i);s=ve(l,"Prompt + Paint"),l.forEach(w),this.h()},h(){f(t,"class","rounded-sm h-6 w-6 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2")},m(a,o){J(a,t,o),L(t,n),J(a,r,o),J(a,i,o),L(i,s)},d(a){a&&w(t),a&&w(r),a&&w(i)}}}function Ka(e){let t,n;return{c(){t=K("span"),n=ge("paiting...")},l(r){t=B(r,"SPAN",{});var i=C(t);n=ve(i,"paiting..."),i.forEach(w)},m(r,i){J(r,t,i),L(t,n)},d(r){r&&w(t)}}}function Ba(e){let t,n,r,i;function s(l,u){return l[0]?Ka:Fa}let a=s(e),o=a(e);return{c(){t=K("button"),o.c(),this.h()},l(l){t=B(l,"BUTTON",{class:!0,title:!0});var u=C(t);o.l(u),u.forEach(w),this.h()},h(){t.disabled=e[0],f(t,"class",n="button-paint "+(e[0]?"cursor-wait":"cursor-pointer")+" svelte-1h65rpr"),f(t,"title","New Paint Frame")},m(l,u){J(l,t,u),o.m(t,null),r||(i=Ve(t,"click",e[1]),r=!0)},p(l,[u]){a!==(a=s(l))&&(o.d(1),o=a(l),o&&(o.c(),o.m(t,null))),u&1&&(t.disabled=l[0]),u&1&&n!==(n="button-paint "+(l[0]?"cursor-wait":"cursor-pointer")+" svelte-1h65rpr")&&f(t,"class",n)},i:ye,o:ye,d(l){l&&w(t),o.d(),r=!1,i()}}}function Va(e,t,n){let{isLoading:r=!1}=t;function i(s){Dt.call(this,e,s)}return e.$$set=s=>{"isLoading"in s&&n(0,r=s.isLoading)},[r,i]}class zi extends he{constructor(t){super(),de(this,t,Va,Ba,pe,{isLoading:0})}}function ja(e){let t,n;return{c(){t=me("svg"),n=me("path"),this.h()},l(r){t=_e(r,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=C(t);n=_e(i,"path",{d:!0,stroke:!0,"stroke-width":!0,"stroke-linecap":!0,"stroke-linejoin":!0}),C(n).forEach(w),i.forEach(w),this.h()},h(){f(n,"d","M2.4 4.26667L1 5.66667L2.4 7.06667M4.26667 2.4L5.66667 1L7.06667 2.4M7.06667 8.93333L5.66667 10.3333L4.26667 8.93333M8.93333 4.26667L10.3333 5.66667L8.93333 7.06667M1 5.66667H10.3333M5.66667 1V10.3333"),f(n,"stroke","currentColor"),f(n,"stroke-width","0.933333"),f(n,"stroke-linecap","round"),f(n,"stroke-linejoin","round"),f(t,"class",e[0]),f(t,"width","40"),f(t,"height","40"),f(t,"viewBox","0 0 11 11"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){J(r,t,i),L(t,n)},p(r,[i]){i&1&&f(t,"class",r[0])},i:ye,o:ye,d(r){r&&w(t)}}}function Xa(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Ya extends he{constructor(t){super(),de(this,t,Xa,ja,pe,{classList:0})}}function Ja(e){let t,n,r,i,s,a;return n=new Ya({}),{c(){t=K("button"),se(n.$$.fragment),this.h()},l(o){t=B(o,"BUTTON",{class:!0,title:!0});var l=C(t);oe(n.$$.fragment,l),l.forEach(w),this.h()},h(){t.disabled=e[1],f(t,"class",r=e[2]+" shadow-lg bg-white rounded-full disabled:opacity-50 "+(e[0]?"text-blue-700":"text-gray-800")),f(t,"title","Enable Dragging")},m(o,l){J(o,t,l),ae(n,t,null),i=!0,s||(a=Ve(t,"click",e[3]),s=!0)},p(o,[l]){(!i||l&2)&&(t.disabled=o[1]),(!i||l&5&&r!==(r=o[2]+" shadow-lg bg-white rounded-full disabled:opacity-50 "+(o[0]?"text-blue-700":"text-gray-800")))&&f(t,"class",r)},i(o){i||(H(n.$$.fragment,o),i=!0)},o(o){X(n.$$.fragment,o),i=!1},d(o){o&&w(t),le(n),s=!1,a()}}}function qa(e,t,n){let{isActive:r=!1}=t,{isLoading:i=!1}=t,{className:s=""}=t;function a(o){Dt.call(this,e,o)}return e.$$set=o=>{"isActive"in o&&n(0,r=o.isActive),"isLoading"in o&&n(1,i=o.isLoading),"className"in o&&n(2,s=o.className)},[r,i,s,a]}class Wa extends he{constructor(t){super(),de(this,t,qa,Ja,pe,{isActive:0,isLoading:1,className:2})}}function Ga(e){let t,n,r;return{c(){t=me("svg"),n=me("path"),r=me("path"),this.h()},l(i){t=_e(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=C(t);n=_e(s,"path",{d:!0,stroke:!0,"stroke-width":!0}),C(n).forEach(w),r=_e(s,"path",{d:!0,stroke:!0,"stroke-width":!0,"stroke-linecap":!0,"stroke-linejoin":!0}),C(r).forEach(w),s.forEach(w),this.h()},h(){f(n,"d","M5.5 10C7.98528 10 10 7.98528 10 5.5C10 3.01472 7.98528 1 5.5 1C3.01472 1 1 3.01472 1 5.5C1 7.98528 3.01472 10 5.5 10Z"),f(n,"stroke","currentColor"),f(n,"stroke-width","0.899979"),f(r,"d","M7.07441 1.28369C5.36599 1.92179 4.14941 3.56879 4.14941 5.50019C4.14941 7.43137 5.36599 9.07837 7.07441 9.71669M8.42441 2.12519L4.14941 5.05019M9.32441 3.25019L4.37441 6.62519M9.77441 4.60019L5.04941 7.97519M9.77441 6.40019L5.94941 9.10019"),f(r,"stroke","currentColor"),f(r,"stroke-width","0.899979"),f(r,"stroke-linecap","round"),f(r,"stroke-linejoin","round"),f(t,"class",e[0]),f(t,"width","40"),f(t,"height","40"),f(t,"viewBox","0 0 11 11"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){J(i,t,s),L(t,n),L(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ye,o:ye,d(i){i&&w(t)}}}function Za(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class Qa extends he{constructor(t){super(),de(this,t,Za,Ga,pe,{classList:0})}}function el(e){let t,n,r,i,s,a;return n=new Qa({}),{c(){t=K("button"),se(n.$$.fragment),this.h()},l(o){t=B(o,"BUTTON",{class:!0,title:!0});var l=C(t);oe(n.$$.fragment,l),l.forEach(w),this.h()},h(){t.disabled=e[1],f(t,"class",r=e[2]+" rounded-full disabled:opacity-50 "+(e[0]?"text-blue-700":"text-gray-800")),f(t,"title","Enable Masking")},m(o,l){J(o,t,l),ae(n,t,null),i=!0,s||(a=Ve(t,"click",e[3]),s=!0)},p(o,[l]){(!i||l&2)&&(t.disabled=o[1]),(!i||l&5&&r!==(r=o[2]+" rounded-full disabled:opacity-50 "+(o[0]?"text-blue-700":"text-gray-800")))&&f(t,"class",r)},i(o){i||(H(n.$$.fragment,o),i=!0)},o(o){X(n.$$.fragment,o),i=!1},d(o){o&&w(t),le(n),s=!1,a()}}}function tl(e,t,n){let{isActive:r=!1}=t,{isLoading:i=!1}=t,{className:s=""}=t;function a(o){Dt.call(this,e,o)}return e.$$set=o=>{"isActive"in o&&n(0,r=o.isActive),"isLoading"in o&&n(1,i=o.isLoading),"className"in o&&n(2,s=o.className)},[r,i,s,a]}class nl extends he{constructor(t){super(),de(this,t,tl,el,pe,{isActive:0,isLoading:1,className:2})}}function rl(e){let t,n,r;return{c(){t=me("svg"),n=me("g"),r=me("path"),this.h()},l(i){t=_e(i,"svg",{class:!0,width:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=C(t);n=_e(s,"g",{opacity:!0});var a=C(n);r=_e(a,"path",{d:!0,fill:!0,stroke:!0,"stroke-width":!0,"stroke-linejoin":!0}),C(r).forEach(w),a.forEach(w),s.forEach(w),this.h()},h(){f(r,"d","M6.33333 2.66667H2.27167L3.46733 1.47133L3 1L1 3L3 5L3.46733 4.52833L2.27267 3.33333H6.33333C6.86377 3.33333 7.37247 3.54405 7.74755 3.91912C8.12262 4.29419 8.33333 4.8029 8.33333 5.33333C8.33333 5.86377 8.12262 6.37247 7.74755 6.74755C7.37247 7.12262 6.86377 7.33333 6.33333 7.33333H3.66667V8H6.33333C7.04058 8 7.71885 7.71905 8.21895 7.21895C8.71905 6.71885 9 6.04058 9 5.33333C9 4.62609 8.71905 3.94781 8.21895 3.44772C7.71885 2.94762 7.04058 2.66667 6.33333 2.66667Z"),f(r,"fill","black"),f(r,"stroke","black"),f(r,"stroke-width","0.5"),f(r,"stroke-linejoin","round"),f(n,"opacity","0.5"),f(t,"class",e[0]),f(t,"width","40"),f(t,"height","29"),f(t,"viewBox","0 0 10 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){J(i,t,s),L(t,n),L(n,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ye,o:ye,d(i){i&&w(t)}}}function il(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class sl extends he{constructor(t){super(),de(this,t,il,rl,pe,{classList:0})}}function ol(e){let t,n,r,i,s,a;return n=new sl({}),{c(){t=K("button"),se(n.$$.fragment),this.h()},l(o){t=B(o,"BUTTON",{class:!0,title:!0});var l=C(t);oe(n.$$.fragment,l),l.forEach(w),this.h()},h(){t.disabled=e[1],f(t,"class",r=e[2]+" bg-white rounded-full disabled:opacity-50 bg-white rounded-full "+(e[0]?"text-blue-700":"text-gray-800")),f(t,"title","Clear Masking")},m(o,l){J(o,t,l),ae(n,t,null),i=!0,s||(a=Ve(t,"click",e[3]),s=!0)},p(o,[l]){(!i||l&2)&&(t.disabled=o[1]),(!i||l&5&&r!==(r=o[2]+" bg-white rounded-full disabled:opacity-50 bg-white rounded-full "+(o[0]?"text-blue-700":"text-gray-800")))&&f(t,"class",r)},i(o){i||(H(n.$$.fragment,o),i=!0)},o(o){X(n.$$.fragment,o),i=!1},d(o){o&&w(t),le(n),s=!1,a()}}}function al(e,t,n){let{isActive:r=!1}=t,{isLoading:i=!1}=t,{className:s=""}=t;function a(o){Dt.call(this,e,o)}return e.$$set=o=>{"isActive"in o&&n(0,r=o.isActive),"isLoading"in o&&n(1,i=o.isLoading),"className"in o&&n(2,s=o.className)},[r,i,s,a]}class ll extends he{constructor(t){super(),de(this,t,al,ol,pe,{isActive:0,isLoading:1,className:2})}}var ul={value:()=>{}};function gn(){for(var e=0,t=arguments.length,n={},r;e=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}})}Zt.prototype=gn.prototype={constructor:Zt,on:function(e,t){var n=this._,r=cl(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s0)for(var n=new Array(i),r=0,i,s;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Sr.hasOwnProperty(t)?{space:Sr[t],local:e}:e}function hl(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zn&&t.documentElement.namespaceURI===zn?t.createElement(e):t.createElementNS(n,e)}}function dl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hi(e){var t=vn(e);return(t.local?dl:hl)(t)}function pl(){}function or(e){return e==null?pl:function(){return this.querySelector(e)}}function ml(e){typeof e!="function"&&(e=or(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=k&&(k=m+1);!($=b[k])&&++k=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function Hl(e){e||(e=Fl);function t(g,h){return g&&h?e(g.__data__,h.__data__):!g-!h}for(var n=this._groups,r=n.length,i=new Array(r),s=0;st?1:e>=t?0:NaN}function Kl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Bl(){return Array.from(this)}function Vl(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?tu:typeof t=="function"?ru:nu)(e,t,n==null?"":n)):bt(this.node(),e)}function bt(e,t){return e.style.getPropertyValue(t)||ji(e).getComputedStyle(e,null).getPropertyValue(t)}function su(e){return function(){delete this[e]}}function ou(e,t){return function(){this[e]=t}}function au(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function lu(e,t){return arguments.length>1?this.each((t==null?su:typeof t=="function"?au:ou)(e,t)):this.node()[e]}function Xi(e){return e.trim().split(/^|\s+/)}function ar(e){return e.classList||new Yi(e)}function Yi(e){this._node=e,this._names=Xi(e.getAttribute("class")||"")}Yi.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 Ji(e,t){for(var n=ar(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Mu(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,s;n()=>e;function Hn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:s,x:a,y:o,dx:l,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Hn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Xu(e){return!e.ctrlKey&&!e.button}function Yu(){return this.parentNode}function Ju(e,t){return t==null?{x:e.x,y:e.y}:t}function qu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Pr(){var e=Xu,t=Yu,n=Ju,r=qu,i={},s=gn("start","drag","end"),a=0,o,l,u,c,g=0;function h(_){_.on("mousedown.drag",v).filter(r).on("touchstart.drag",b).on("touchmove.drag",p,ju).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(_,$){if(!(c||!e.call(this,_,$))){var E=k(this,t.call(this,_,$),_,$,"mouse");!E||(Ne(_.view).on("mousemove.drag",A,Tt).on("mouseup.drag",P,Tt),Zi(_.view),Tn(_),u=!1,o=_.clientX,l=_.clientY,E("start",_))}}function A(_){if(vt(_),!u){var $=_.clientX-o,E=_.clientY-l;u=$*$+E*E>g}i.mouse("drag",_)}function P(_){Ne(_.view).on("mousemove.drag mouseup.drag",null),Qi(_.view,u),vt(_),i.mouse("end",_)}function b(_,$){if(!!e.call(this,_,$)){var E=_.changedTouches,O=t.call(this,_,$),N=E.length,U,V;for(U=0;U{const n=new Image;n.onload=async()=>{const r=n.width,i=n.height,s=document.createElement("canvas");s.width=r,s.height=i,s.getContext("2d").drawImage(n,0,0,r,i);const o=await new Promise(l=>s.toBlob(l,"image/jpeg",.95));t(o)},n.src=e})}async function ec(e,t,n){const r=nc(t),s=`color-palette-${crypto.randomUUID().split("-")[0]}-${r}-${n}.jpeg`,a=new File([e],s,{type:"image/jpeg"}),o=new FormData;o.append("file",a),console.log("uploading image",a);const u=await(await fetch(Zu,{method:"POST",body:o})).json();return console.log("uploaded images",u),u.filename}const tc=512*5-512;function Vt(e,t=32){const n=e%t{n(s)});return hn(()=>{i()}),{subscribe:t,update:r}}function rc(){const e=yn(),t=at(),n=e.subscribe("others",r=>{t.set(r)});return hn(n),t}function ic(){const e=yn(),t=at();async function n(){const{root:r}=await e.getStorage();t.set(r)}return n(),t}function es(e,t){const n=yn(),r=ic(),i=at();let s=()=>{};const a=r.subscribe(o=>{!o||(o.get(e)||o.set(e,new Ea(t)),i.set(o.get(e)),s(),s=n.subscribe(o.get(e),l=>{i.set(l)}))});return hn(a),i}function lr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ts(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Ht(){}var Ct=.7,an=1/Ct,yt="\\s*([+-]?\\d+)\\s*",$t="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sc=/^#([0-9a-f]{3,8})$/,oc=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),ac=new RegExp(`^rgb\\(${je},${je},${je}\\)$`),lc=new RegExp(`^rgba\\(${yt},${yt},${yt},${$t}\\)$`),uc=new RegExp(`^rgba\\(${je},${je},${je},${$t}\\)$`),cc=new RegExp(`^hsl\\(${$t},${je},${je}\\)$`),fc=new RegExp(`^hsla\\(${$t},${je},${je},${$t}\\)$`),Lr={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};lr(Ht,Nt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ar,formatHex:Ar,formatHex8:hc,formatHsl:dc,formatRgb:Tr,toString:Tr});function Ar(){return this.rgb().formatHex()}function hc(){return this.rgb().formatHex8()}function dc(){return ns(this).formatHsl()}function Tr(){return this.rgb().formatRgb()}function Nt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=sc.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Cr(t):n===3?new Se(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jt(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=oc.exec(e))?new Se(t[1],t[2],t[3],1):(t=ac.exec(e))?new Se(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=lc.exec(e))?jt(t[1],t[2],t[3],t[4]):(t=uc.exec(e))?jt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cc.exec(e))?Rr(t[1],t[2]/100,t[3]/100,1):(t=fc.exec(e))?Rr(t[1],t[2]/100,t[3]/100,t[4]):Lr.hasOwnProperty(e)?Cr(Lr[e]):e==="transparent"?new Se(NaN,NaN,NaN,0):null}function Cr(e){return new Se(e>>16&255,e>>8&255,e&255,1)}function jt(e,t,n,r){return r<=0&&(e=t=n=NaN),new Se(e,t,n,r)}function pc(e){return e instanceof Ht||(e=Nt(e)),e?(e=e.rgb(),new Se(e.r,e.g,e.b,e.opacity)):new Se}function Fn(e,t,n,r){return arguments.length===1?pc(e):new Se(e,t,n,r==null?1:r)}function Se(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}lr(Se,Fn,ts(Ht,{brighter(e){return e=e==null?an:Math.pow(an,e),new Se(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ct:Math.pow(Ct,e),new Se(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Se(ht(this.r),ht(this.g),ht(this.b),ln(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:$r,formatHex:$r,formatHex8:mc,formatRgb:Nr,toString:Nr}));function $r(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function mc(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut((isNaN(this.opacity)?1:this.opacity)*255)}`}function Nr(){const e=ln(this.opacity);return`${e===1?"rgb(":"rgba("}${ht(this.r)}, ${ht(this.g)}, ${ht(this.b)}${e===1?")":`, ${e})`}`}function ln(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ht(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ut(e){return e=ht(e),(e<16?"0":"")+e.toString(16)}function Rr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new De(e,t,n,r)}function ns(e){if(e instanceof De)return new De(e.h,e.s,e.l,e.opacity);if(e instanceof Ht||(e=Nt(e)),!e)return new De;if(e instanceof De)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n0&&l<1?0:a,new De(a,o,l,e.opacity)}function _c(e,t,n,r){return arguments.length===1?ns(e):new De(e,t,n,r==null?1:r)}function De(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}lr(De,_c,ts(Ht,{brighter(e){return e=e==null?an:Math.pow(an,e),new De(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ct:Math.pow(Ct,e),new De(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 Se(Cn(e>=240?e-240:e+120,i,r),Cn(e,i,r),Cn(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new De(Mr(this.h),Xt(this.s),Xt(this.l),ln(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=ln(this.opacity);return`${e===1?"hsl(":"hsla("}${Mr(this.h)}, ${Xt(this.s)*100}%, ${Xt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Mr(e){return e=(e||0)%360,e<0?e+360:e}function Xt(e){return Math.max(0,Math.min(1,e||0))}function Cn(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 rs=e=>()=>e;function gc(e,t){return function(n){return e+n*t}}function vc(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 yc(e){return(e=+e)==1?is:function(t,n){return n-t?vc(t,n,e):rs(isNaN(t)?n:t)}}function is(e,t){var n=t-e;return n?gc(e,n):rs(isNaN(e)?t:e)}const Dr=function e(t){var n=yc(t);function r(i,s){var a=n((i=Fn(i)).r,(s=Fn(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=is(i.opacity,s.opacity);return function(c){return i.r=a(c),i.g=o(c),i.b=l(c),i.opacity=u(c),i+""}}return r.gamma=e,r}(1);function it(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Kn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$n=new RegExp(Kn.source,"g");function wc(e){return function(){return e}}function bc(e){return function(t){return e(t)+""}}function kc(e,t){var n=Kn.lastIndex=$n.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Kn.exec(e))&&(i=$n.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:it(r,i)})),n=$n.lastIndex;return n180?c+=360:c-u>180&&(u+=360),h.push({i:g.push(i(g)+"rotate(",null,r)-2,x:it(u,c)})):c&&g.push(i(g)+"rotate("+c+r)}function o(u,c,g,h){u!==c?h.push({i:g.push(i(g)+"skewX(",null,r)-2,x:it(u,c)}):c&&g.push(i(g)+"skewX("+c+r)}function l(u,c,g,h,v,A){if(u!==g||c!==h){var P=v.push(i(v)+"scale(",null,",",null,")");A.push({i:P-4,x:it(u,g)},{i:P-2,x:it(c,h)})}else(g!==1||h!==1)&&v.push(i(v)+"scale("+g+","+h+")")}return function(u,c){var g=[],h=[];return u=e(u),c=e(c),s(u.translateX,u.translateY,c.translateX,c.translateY,g,h),a(u.rotate,c.rotate,g,h),o(u.skewX,c.skewX,g,h),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,g,h),u=c=null,function(v){for(var A=-1,P=h.length,b;++A=0&&e._call.call(void 0,t),e=e._next;--kt}function Hr(){mt=(cn=Rt.now())+bn,kt=Lt=0;try{Cc()}finally{kt=0,Nc(),mt=0}}function $c(){var e=Rt.now(),t=e-cn;t>as&&(bn-=t,cn=e)}function Nc(){for(var e,t=un,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:un=n);At=e,Vn(r)}function Vn(e){if(!kt){Lt&&(Lt=clearTimeout(Lt));var t=e-mt;t>24?(e<1/0&&(Lt=setTimeout(Hr,e-Rt.now()-bn)),Ot&&(Ot=clearInterval(Ot))):(Ot||(cn=Rt.now(),Ot=setInterval($c,as)),kt=1,ls(Hr))}}function Fr(e,t,n){var r=new fn;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Rc=gn("start","end","cancel","interrupt"),Mc=[],cs=0,Kr=1,jn=2,Qt=3,Br=4,Xn=5,en=6;function kn(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Dc(e,n,{name:t,index:r,group:i,on:Rc,tween:Mc,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:cs})}function cr(e,t){var n=Fe(e,t);if(n.state>cs)throw new Error("too late; already scheduled");return n}function Ye(e,t){var n=Fe(e,t);if(n.state>Qt)throw new Error("too late; already running");return n}function Fe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Dc(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=us(s,0,n.time);function s(u){n.state=Kr,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var c,g,h,v;if(n.state!==Kr)return l();for(c in r)if(v=r[c],v.name===n.name){if(v.state===Qt)return Fr(a);v.state===Br?(v.state=en,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[c]):+cjn&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function pf(e,t,n){var r,i,s=df(t)?cr:Ye;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function mf(e,t){var n=this._id;return arguments.length<2?Fe(this.node(),n).on.on(e):this.each(pf(n,e,t))}function _f(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function gf(){return this.on("end.remove",_f(this._id))}function vf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=or(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a()=>e;function Bf(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 Ze(e,t,n){this.k=e,this.x=t,this.y=n}Ze.prototype={constructor:Ze,scale:function(e){return e===1?this:new Ze(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ze(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 Mt=new Ze(1,0,0);Ze.prototype;function Nn(e){e.stopImmediatePropagation()}function St(e){e.preventDefault(),e.stopImmediatePropagation()}function Vf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function jf(){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 Vr(){return this.__zoom||Mt}function Xf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Yf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Jf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function qf(){var e=Vf,t=jf,n=Jf,r=Xf,i=Yf,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Ac,u=gn("start","zoom","end"),c,g,h,v=500,A=150,P=0,b=10;function p(y){y.property("__zoom",Vr).on("wheel.zoom",N,{passive:!1}).on("mousedown.zoom",U).on("dblclick.zoom",V).filter(i).on("touchstart.zoom",Z).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",we).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(y,S,x,z){var D=y.selection?y.selection():y;D.property("__zoom",Vr),y!==D?$(y,S,x,z):D.interrupt().each(function(){E(this,arguments).event(z).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},p.scaleBy=function(y,S,x,z){p.scaleTo(y,function(){var D=this.__zoom.k,j=typeof S=="function"?S.apply(this,arguments):S;return D*j},x,z)},p.scaleTo=function(y,S,x,z){p.transform(y,function(){var D=t.apply(this,arguments),j=this.__zoom,Y=x==null?_(D):typeof x=="function"?x.apply(this,arguments):x,Q=j.invert(Y),ne=typeof S=="function"?S.apply(this,arguments):S;return n(k(m(j,ne),Y,Q),D,a)},x,z)},p.translateBy=function(y,S,x,z){p.transform(y,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof x=="function"?x.apply(this,arguments):x),t.apply(this,arguments),a)},null,z)},p.translateTo=function(y,S,x,z,D){p.transform(y,function(){var j=t.apply(this,arguments),Y=this.__zoom,Q=z==null?_(j):typeof z=="function"?z.apply(this,arguments):z;return n(Mt.translate(Q[0],Q[1]).scale(Y.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof x=="function"?-x.apply(this,arguments):-x),j,a)},z,D)};function m(y,S){return S=Math.max(s[0],Math.min(s[1],S)),S===y.k?y:new Ze(S,y.x,y.y)}function k(y,S,x){var z=S[0]-x[0]*y.k,D=S[1]-x[1]*y.k;return z===y.x&&D===y.y?y:new Ze(y.k,z,D)}function _(y){return[(+y[0][0]+ +y[1][0])/2,(+y[0][1]+ +y[1][1])/2]}function $(y,S,x,z){y.on("start.zoom",function(){E(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(z).end()}).tween("zoom",function(){var D=this,j=arguments,Y=E(D,j).event(z),Q=t.apply(D,j),ne=x==null?_(Q):typeof x=="function"?x.apply(D,j):x,ke=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),te=D.__zoom,Ee=typeof S=="function"?S.apply(D,j):S,Pe=l(te.invert(ne).concat(ke/te.k),Ee.invert(ne).concat(ke/Ee.k));return function(xe){if(xe===1)xe=Ee;else{var Le=Pe(xe),It=ke/Le[2];xe=new Ze(It,ne[0]-Le[0]*It,ne[1]-Le[1]*It)}Y.zoom(null,xe)}})}function E(y,S,x){return!x&&y.__zooming||new O(y,S)}function O(y,S){this.that=y,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(y,S),this.taps=0}O.prototype={event:function(y){return y&&(this.sourceEvent=y),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(y,S){return this.mouse&&y!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&y!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&y!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(y){var S=Ne(this.that).datum();u.call(y,this.that,new Bf(y,{sourceEvent:this.sourceEvent,target:p,type:y,transform:this.that.__zoom,dispatch:u}),S)}};function N(y,...S){if(!e.apply(this,arguments))return;var x=E(this,S).event(y),z=this.__zoom,D=Math.max(s[0],Math.min(s[1],z.k*Math.pow(2,r.apply(this,arguments)))),j=We(y);if(x.wheel)(x.mouse[0][0]!==j[0]||x.mouse[0][1]!==j[1])&&(x.mouse[1]=z.invert(x.mouse[0]=j)),clearTimeout(x.wheel);else{if(z.k===D)return;x.mouse=[j,z.invert(j)],tn(this),x.start()}St(y),x.wheel=setTimeout(Y,A),x.zoom("mouse",n(k(m(z,D),x.mouse[0],x.mouse[1]),x.extent,a));function Y(){x.wheel=null,x.end()}}function U(y,...S){if(h||!e.apply(this,arguments))return;var x=y.currentTarget,z=E(this,S,!0).event(y),D=Ne(y.view).on("mousemove.zoom",ne,!0).on("mouseup.zoom",ke,!0),j=We(y,x),Y=y.clientX,Q=y.clientY;Zi(y.view),Nn(y),z.mouse=[j,this.__zoom.invert(j)],tn(this),z.start();function ne(te){if(St(te),!z.moved){var Ee=te.clientX-Y,Pe=te.clientY-Q;z.moved=Ee*Ee+Pe*Pe>P}z.event(te).zoom("mouse",n(k(z.that.__zoom,z.mouse[0]=We(te,x),z.mouse[1]),z.extent,a))}function ke(te){D.on("mousemove.zoom mouseup.zoom",null),Qi(te.view,z.moved),St(te),z.event(te).end()}}function V(y,...S){if(!!e.apply(this,arguments)){var x=this.__zoom,z=We(y.changedTouches?y.changedTouches[0]:y,this),D=x.invert(z),j=x.k*(y.shiftKey?.5:2),Y=n(k(m(x,j),z,D),t.apply(this,S),a);St(y),o>0?Ne(this).transition().duration(o).call($,Y,z,y):Ne(this).call(p.transform,Y,z,y)}}function Z(y,...S){if(!!e.apply(this,arguments)){var x=y.touches,z=x.length,D=E(this,S,y.changedTouches.length===z).event(y),j,Y,Q,ne;for(Nn(y),Y=0;Y(e.ready="ready",e.loading="loading",e.prompting="prompting",e.processing="processing",e.dragging="dragging",e.masking="masking",e))(ce||{});function jr(e){let t,n,r;return{c(){t=K("div"),n=K("div"),r=ge(e[6]),this.h()},l(i){t=B(i,"DIV",{class:!0});var s=C(t);n=B(s,"DIV",{class:!0});var a=C(n);r=ve(a,e[6]),a.forEach(w),s.forEach(w),this.h()},h(){f(n,"class","font-bold text-xl text-[#387CFF] text-center px-2 line-clamp-4"),f(t,"class","pointer-events-none touch-none")},m(i,s){J(i,t,s),L(t,n),L(n,r)},p(i,s){s&64&&ot(r,i[6])},d(i){i&&w(t)}}}function Xr(e){let t,n,r;return n=new Ui({}),{c(){t=K("div"),se(n.$$.fragment),this.h()},l(i){t=B(i,"DIV",{class:!0});var s=C(t);oe(n.$$.fragment,s),s.forEach(w),this.h()},h(){f(t,"class","absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2")},m(i,s){J(i,t,s),ae(n,t,null),r=!0},i(i){r||(H(n.$$.fragment,i),r=!0)},o(i){X(n.$$.fragment,i),r=!1},d(i){i&&w(t),le(n)}}}function Yr(e){let t,n,r,i,s,a,o,l,u,c,g,h,v,A,P;r=new zi({props:{isLoading:e[4]}}),r.$on("click",e[17]);let b=e[8]!==""&&Jr(e);u=new Wa({props:{className:"p-1",isLoading:e[4],isActive:e[1]}}),u.$on("click",e[11]),h=new nl({props:{isLoading:e[4],className:"p-1",isActive:!e[1]}}),h.$on("click",e[12]);let p=!e[1]&&Wr(e);return{c(){t=K("div"),n=K("div"),se(r.$$.fragment),i=W(),b&&b.c(),a=W(),o=K("div"),l=K("div"),se(u.$$.fragment),c=W(),g=K("div"),se(h.$$.fragment),v=W(),p&&p.c(),this.h()},l(m){t=B(m,"DIV",{class:!0,style:!0});var k=C(t);n=B(k,"DIV",{class:!0});var _=C(n);oe(r.$$.fragment,_),_.forEach(w),i=G(k),b&&b.l(k),k.forEach(w),a=G(m),o=B(m,"DIV",{class:!0,style:!0});var $=C(o);l=B($,"DIV",{class:!0});var E=C(l);oe(u.$$.fragment,E),c=G(E),g=B(E,"DIV",{class:!0});var O=C(g);oe(h.$$.fragment,O),v=G(O),p&&p.l(O),O.forEach(w),E.forEach(w),$.forEach(w),this.h()},h(){f(n,"class","py-3"),f(t,"class","absolute top-full"),f(t,"style",s=`transform: scale(${Math.max(2-e[0].k,1)}); transform-origin: 0 0;`),f(g,"class","flex bg-white rounded-full mt-3 shadow-lg"),f(l,"class","mx-4"),f(o,"class","absolute left-full"),f(o,"style",A=`transform: scale(${Math.max(2-e[0].k,1)}); transform-origin: 0 0;`)},m(m,k){J(m,t,k),L(t,n),ae(r,n,null),L(t,i),b&&b.m(t,null),J(m,a,k),J(m,o,k),L(o,l),ae(u,l,null),L(l,c),L(l,g),ae(h,g,null),L(g,v),p&&p.m(g,null),P=!0},p(m,k){const _={};k&16&&(_.isLoading=m[4]),r.$set(_),m[8]!==""?b?b.p(m,k):(b=Jr(m),b.c(),b.m(t,null)):b&&(b.d(1),b=null),(!P||k&1&&s!==(s=`transform: scale(${Math.max(2-m[0].k,1)}); transform-origin: 0 0;`))&&f(t,"style",s);const $={};k&16&&($.isLoading=m[4]),k&2&&($.isActive=m[1]),u.$set($);const E={};k&16&&(E.isLoading=m[4]),k&2&&(E.isActive=!m[1]),h.$set(E),m[1]?p&&(Te(),X(p,1,1,()=>{p=null}),Ce()):p?(p.p(m,k),k&2&&H(p,1)):(p=Wr(m),p.c(),H(p,1),p.m(g,null)),(!P||k&1&&A!==(A=`transform: scale(${Math.max(2-m[0].k,1)}); transform-origin: 0 0;`))&&f(o,"style",A)},i(m){P||(H(r.$$.fragment,m),H(u.$$.fragment,m),H(h.$$.fragment,m),H(p),P=!0)},o(m){X(r.$$.fragment,m),X(u.$$.fragment,m),X(h.$$.fragment,m),X(p),P=!1},d(m){m&&w(t),le(r),b&&b.d(),m&&w(a),m&&w(o),le(u),le(h),p&&p.d()}}}function Jr(e){let t,n,r,i,s=e[8]==="NFSW"&&qr();return{c(){t=K("div"),s&&s.c(),n=W(),r=K("p"),i=ge(e[8]),this.h()},l(a){t=B(a,"DIV",{class:!0});var o=C(t);s&&s.l(o),n=G(o),r=B(o,"P",{});var l=C(r);i=ve(l,e[8]),l.forEach(w),o.forEach(w),this.h()},h(){f(t,"class","p-3 bg-white rounded-lg font-mono")},m(a,o){J(a,t,o),s&&s.m(t,null),L(t,n),L(t,r),L(r,i)},p(a,o){a[8]==="NFSW"?s||(s=qr(),s.c(),s.m(t,n)):s&&(s.d(1),s=null),o&256&&ot(i,a[8])},d(a){a&&w(t),s&&s.d()}}}function qr(e){let t,n,r,i,s;return{c(){t=K("h2"),n=ge("NSFW Alert"),r=W(),i=K("h3"),s=ge("Possible NSFW result detected, please try again"),this.h()},l(a){t=B(a,"H2",{class:!0});var o=C(t);n=ve(o,"NSFW Alert"),o.forEach(w),r=G(a),i=B(a,"H3",{class:!0});var l=C(i);s=ve(l,"Possible NSFW result detected, please try again"),l.forEach(w),this.h()},h(){f(t,"class","text-red-500 text-2xl font-bold"),f(i,"class","text-red-500 text-lg")},m(a,o){J(a,t,o),L(t,n),J(a,r,o),J(a,i,o),L(i,s)},d(a){a&&w(t),a&&w(r),a&&w(i)}}}function Wr(e){let t,n,r,i;return r=new ll({props:{className:"p-1",isLoading:e[4]}}),r.$on("click",e[13]),{c(){t=K("span"),n=W(),se(r.$$.fragment),this.h()},l(s){t=B(s,"SPAN",{class:!0}),C(t).forEach(w),n=G(s),oe(r.$$.fragment,s),this.h()},h(){f(t,"class","border-gray-800 border-opacity-50 border-r-2 my-2")},m(s,a){J(s,t,a),J(s,n,a),ae(r,s,a),i=!0},p(s,a){const o={};a&16&&(o.isLoading=s[4]),r.$set(o)},i(s){i||(H(r.$$.fragment,s),i=!0)},o(s){X(r.$$.fragment,s),i=!1},d(s){s&&w(t),s&&w(n),le(r,s)}}}function Wf(e){let t,n,r,i,s,a,o,l,u,c,g,h,v,A,P,b=e[6]&&jr(e),p=e[4]&&Xr(),m=!e[3]&&Yr(e);return{c(){t=K("div"),n=K("div"),r=K("div"),i=K("canvas"),a=W(),o=K("div"),b&&b.c(),l=W(),p&&p.c(),u=W(),m&&m.c(),g=W(),h=K("div"),this.h()},l(k){t=B(k,"DIV",{});var _=C(t);n=B(_,"DIV",{class:!0,style:!0});var $=C(n);r=B($,"DIV",{class:!0});var E=C(r);i=B(E,"CANVAS",{class:!0,width:!0,height:!0}),C(i).forEach(w),a=G(E),o=B(E,"DIV",{class:!0});var O=C(o);b&&b.l(O),O.forEach(w),l=G(E),p&&p.l(E),u=G(E),m&&m.l(E),E.forEach(w),$.forEach(w),g=G(_),h=B(_,"DIV",{class:!0,style:!0}),C(h).forEach(w),_.forEach(w),this.h()},h(){f(i,"class",s=e[1]?"":"bg-white"),f(i,"width","512"),f(i,"height","512"),f(o,"class","pointer-events-none touch-none"),f(r,"class","frame svelte-xtgdq4"),f(n,"class","absolute top-0 left-0 pen svelte-xtgdq4"),f(n,"style",c=`transform: translateX(${e[5].x}px) translateY(${e[5].y}px) scale(${e[0].k}); transform-origin: 0 0;`),f(h,"class",v="absolute top-0 left-0 w-[512px] h-[512px] ring-8 hand "+(e[1]?"block":"hidden")+" svelte-xtgdq4"),f(h,"style",A=`transform: translateX(${e[5].x}px) translateY(${e[5].y}px) scale(${e[0].k}); transform-origin: 0 0;`)},m(k,_){J(k,t,_),L(t,n),L(n,r),L(r,i),e[16](i),L(r,a),L(r,o),b&&b.m(o,null),L(r,l),p&&p.m(r,null),L(r,u),m&&m.m(r,null),L(t,g),L(t,h),e[18](h),P=!0},p(k,[_]){(!P||_&2&&s!==(s=k[1]?"":"bg-white"))&&f(i,"class",s),k[6]?b?b.p(k,_):(b=jr(k),b.c(),b.m(o,null)):b&&(b.d(1),b=null),k[4]?p?_&16&&H(p,1):(p=Xr(),p.c(),H(p,1),p.m(r,u)):p&&(Te(),X(p,1,1,()=>{p=null}),Ce()),k[3]?m&&(Te(),X(m,1,1,()=>{m=null}),Ce()):m?(m.p(k,_),_&8&&H(m,1)):(m=Yr(k),m.c(),H(m,1),m.m(r,null)),(!P||_&33&&c!==(c=`transform: translateX(${k[5].x}px) translateY(${k[5].y}px) scale(${k[0].k}); transform-origin: 0 0;`))&&f(n,"style",c),(!P||_&2&&v!==(v="absolute top-0 left-0 w-[512px] h-[512px] ring-8 hand "+(k[1]?"block":"hidden")+" svelte-xtgdq4"))&&f(h,"class",v),(!P||_&33&&A!==(A=`transform: translateX(${k[5].x}px) translateY(${k[5].y}px) scale(${k[0].k}); transform-origin: 0 0;`))&&f(h,"style",A)},i(k){P||(H(p),H(m),P=!0)},o(k){X(p),X(m),P=!1},d(k){k&&w(t),e[16](null),b&&b.d(),p&&p.d(),m&&m.d(),e[18](null)}}}function Gf(e,t,n){let r,i,s,a,o,l,u;Ae(e,Jn,S=>n(7,a=S)),Ae(e,nn,S=>n(22,o=S)),Ae(e,Ie,S=>n(8,u=S));const c=wn();Ae(e,c,S=>n(15,l=S));const g=Qn();let{transform:h}=t,v,A={x:768,y:768},P,b=!0,p=!1,m=0,k=0;function _(S){v.save(),v.clearRect(0,0,512,512),v.globalCompositeOperation="source-over",v.drawImage(o,S.x,S.y,512,512,0,0,512,512),v.restore()}function $(S){v.save(),v.globalCompositeOperation="destination-out",v.beginPath(),v.moveTo(S.lastx,S.lasty),v.lineTo(S.x,S.y),v.lineWidth=50,v.lineCap="round",v.strokeStyle="black",v.stroke(),v.restore()}Et(()=>{v=a.getContext("2d"),Ne(P).call(N()).call(E),Ne(a).call(O()).call(E)});function E(S){function x(D){c.update({cursor:{x:h.invertX(D.clientX),y:h.invertY(D.clientY)}})}function z(){c.update({cursor:null})}return S.on("pointermove",x).on("pointerleave",z)}function O(){let S,x;function z(j){if(i)return;const Y=j.x/h.k,Q=j.y/h.k;S=Y,x=Q}function D(j){if(i)return;const Y=j.x/h.k,Q=j.y/h.k;$({x:Y,y:Q,lastx:S,lasty:x}),S=Y,x=Q}return Pr().on("start",z).on("drag",D)}function N(){function S(D){if(i)return;const j=D.sourceEvent.target.getBoundingClientRect();typeof TouchEvent<"u"&&D.sourceEvent instanceof TouchEvent?(m=D.sourceEvent.targetTouches[0].pageX-j.left,k=D.sourceEvent.targetTouches[0].pageY-j.top):D.sourceEvent instanceof MouseEvent&&(m=D.sourceEvent.pageX-j.left,k=D.sourceEvent.pageY-j.top),n(3,p=!0)}function x(D){if(i)return;const j=Vt(h.invertX(D.x-m)),Y=Vt(h.invertY(D.y-k));n(14,A={x:j,y:Y}),c.update({cursor:{x:h.invertX(D.x),y:h.invertY(D.y)}}),_({x:j,y:Y})}function z(D){if(i)return;n(3,p=!1);const j=Vt(h.invertX(D.x-m)),Y=Vt(h.invertY(D.y-k));_({x:j,y:Y}),c.update({frame:{x:j,y:Y}})}return Pr().on("start",S).on("drag",x).on("end",z)}function U(){n(1,b=!0),c.update({status:ce.dragging})}function V(){n(1,b=!1),_(A),c.update({status:ce.masking})}function Z(){_(A)}function ee(S){dt[S?"unshift":"push"](()=>{a=S,Jn.set(a)})}const we=()=>g("prompt");function y(S){dt[S?"unshift":"push"](()=>{P=S,n(2,P)})}return e.$$set=S=>{"transform"in S&&n(0,h=S.transform)},e.$$.update=()=>{e.$$.dirty&32768&&n(6,r=l==null?void 0:l.currentPrompt),e.$$.dirty&32768&&n(4,i=(l==null?void 0:l.status)===ce.loading||(l==null?void 0:l.status)===ce.prompting||!1),e.$$.dirty&32770&&!b&&l.status===ce.loading&&n(1,b=!0),e.$$.dirty&16385&&n(5,s={x:h.applyX(A.x),y:h.applyY(A.y)})},[h,b,P,p,i,s,r,a,u,c,g,U,V,Z,A,l,ee,we,y]}class Zf extends he{constructor(t){super(),de(this,t,Gf,Wf,pe,{transform:0})}}function Qf(e){let t,n,r,i;const s=e[8].default,a=qn(s,e,e[7],null);return{c(){t=K("div"),n=K("canvas"),r=W(),a&&a.c(),this.h()},l(o){t=B(o,"DIV",{class:!0});var l=C(t);n=B(l,"CANVAS",{width:!0,height:!0,class:!0}),C(n).forEach(w),r=G(l),a&&a.l(l),l.forEach(w),this.h()},h(){f(n,"width",e[4]),f(n,"height",e[3]),f(n,"class","absolute top-0 left-0 bg-white svelte-6dcxg7"),f(t,"class","absolute top-0 left-0 right-0 bottom-0 overflow-hidden z-0 bg-gray-800")},m(o,l){J(o,t,l),L(t,n),e[9](n),L(t,r),a&&a.m(t,null),e[10](t),i=!0},p(o,[l]){a&&a.p&&(!i||l&128)&&Wn(a,s,o,o[7],i?Zn(s,o[7],l,null):Gn(o[7]),null)},i(o){i||(H(a,o),i=!0)},o(o){X(a,o),i=!1},d(o){o&&w(t),e[9](null),a&&a.d(o),e[10](null)}}}function eh(e,t,n){let r,i,s;Ae(e,Yn,O=>n(12,r=O)),Ae(e,nn,O=>n(1,i=O));let{$$slots:a={},$$scope:o}=t;const l=wn(),u=es("promptImgStorage");Ae(e,u,O=>n(6,s=O));const c=512*5,g=512*5;let h,v;const A=new Set;function P(O){return O?Object.values(O).sort((U,V)=>U.date-V.date).filter(({id:U})=>!A.has(U)):[]}let b=[];Et(()=>{const N=(g+400)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight),U=qf().scaleExtent([1/N/2,3]).translateExtent([[-200,-200],[g+200,c+200]]).tapDistance(10).on("zoom",m),V=Ne(i.parentElement).call(U).call(U.transform,Mt).call(U.scaleTo,1/N).on("pointermove",k).on("pointerleave",_);v=i.getContext("2d");function Z(){const ee=(g+400)/(h.clientHeight>h.clientWidth?h.clientWidth:h.clientHeight);V.call(U.transform,Mt),V.call(U.scaleTo,1/ee)}return window.addEventListener("resize",Z),()=>{window.removeEventListener("resize",Z)}});function p(O){Promise.all(O.map(({imgURL:N,position:U,id:V})=>new Promise(Z=>{const ee=new Image;ee.crossOrigin="anonymous",ee.onload=()=>{const we={img:ee,position:U,id:V};v.drawImage(ee,U.x,U.y,ee.width,ee.height),Z(we)},ee.src=`${Gu}/${N}`}))).then(N=>{N.forEach(({img:U,position:V,id:Z})=>{A.add(Z),v.drawImage(U,V.x,V.y,U.width,U.height)})})}function m(O){const N=Oe(Yn,r=O.transform,r);Oe(nn,i.style.transform=`translate(${N.x}px, ${N.y}px) scale(${N.k})`,i)}function k(O){O.preventDefault();const N=r.invertX(O.clientX),U=r.invertY(O.clientY);l.update({cursor:{x:N,y:U}})}function _(){l.update({cursor:null})}function $(O){dt[O?"unshift":"push"](()=>{i=O,nn.set(i)})}function E(O){dt[O?"unshift":"push"](()=>{h=O,n(0,h)})}return e.$$set=O=>{"$$scope"in O&&n(7,o=O.$$scope)},e.$$.update=()=>{e.$$.dirty&64&&n(5,b=P(s==null?void 0:s.toObject())),e.$$.dirty&32&&b&&p(b)},[h,i,u,c,g,b,s,o,a,$,E]}class th extends he{constructor(t){super(),de(this,t,eh,Qf,pe,{})}}function nh(e){let t,n,r;return{c(){t=me("svg"),n=me("rect"),r=me("rect"),this.h()},l(i){t=_e(i,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var s=C(t);n=_e(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,stroke:!0}),C(n).forEach(w),r=_e(s,"rect",{x:!0,y:!0,width:!0,height:!0,rx:!0,fill:!0,stroke:!0}),C(r).forEach(w),s.forEach(w),this.h()},h(){f(n,"x","1"),f(n,"y","1"),f(n,"width","7"),f(n,"height","7"),f(n,"rx","1"),f(n,"stroke","#2F6DCB"),f(r,"x","3.05566"),f(r,"y","3.05566"),f(r,"width","2.88889"),f(r,"height","2.88889"),f(r,"rx","0.5"),f(r,"fill","#2F6DCB"),f(r,"stroke","#2F6DCB"),f(t,"class",e[0]),f(t,"height","15"),f(t,"viewBox","0 0 9 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(i,s){J(i,t,s),L(t,n),L(t,r)},p(i,[s]){s&1&&f(t,"class",i[0])},i:ye,o:ye,d(i){i&&w(t)}}}function rh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class ps extends he{constructor(t){super(),de(this,t,rh,nh,pe,{classList:0})}}function ih(e){let t,n;return{c(){t=me("svg"),n=me("path"),this.h()},l(r){t=_e(r,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var i=C(t);n=_e(i,"path",{d:!0,fill:!0}),C(n).forEach(w),i.forEach(w),this.h()},h(){f(n,"d","M3.5 4.58599C3.74063 4.58599 3.94669 4.4961 4.11819 4.31633C4.2894 4.13687 4.375 3.92102 4.375 3.66879C4.375 3.41656 4.2894 3.20056 4.11819 3.02079C3.94669 2.84132 3.74063 2.75159 3.5 2.75159C3.25937 2.75159 3.05346 2.84132 2.88225 3.02079C2.71075 3.20056 2.625 3.41656 2.625 3.66879C2.625 3.92102 2.71075 4.13687 2.88225 4.31633C3.05346 4.4961 3.25937 4.58599 3.5 4.58599ZM3.5 7.95669C4.38958 7.10064 5.04948 6.32285 5.47969 5.62334C5.9099 4.92413 6.125 4.30318 6.125 3.76051C6.125 2.92739 5.87154 2.24515 5.36462 1.71378C4.858 1.18273 4.23646 0.917197 3.5 0.917197C2.76354 0.917197 2.14185 1.18273 1.63494 1.71378C1.12831 2.24515 0.875 2.92739 0.875 3.76051C0.875 4.30318 1.0901 4.92413 1.52031 5.62334C1.95052 6.32285 2.61042 7.10064 3.5 7.95669ZM3.5 9C3.44167 9 3.38333 8.98853 3.325 8.9656C3.26667 8.94267 3.21562 8.9121 3.17188 8.87389C2.10729 7.8879 1.3125 6.97269 0.7875 6.12825C0.2625 5.28352 0 4.49427 0 3.76051C0 2.61401 0.351896 1.70064 1.05569 1.02038C1.75919 0.340127 2.57396 0 3.5 0C4.42604 0 5.24081 0.340127 5.94431 1.02038C6.6481 1.70064 7 2.61401 7 3.76051C7 4.49427 6.7375 5.28352 6.2125 6.12825C5.6875 6.97269 4.89271 7.8879 3.82812 8.87389C3.78438 8.9121 3.73333 8.94267 3.675 8.9656C3.61667 8.98853 3.55833 9 3.5 9Z"),f(n,"fill","#338D4C"),f(t,"class",e[0]),f(t,"height","15"),f(t,"viewBox","0 0 7 9"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(r,i){J(r,t,i),L(t,n)},p(r,[i]){i&1&&f(t,"class",r[0])},i:ye,o:ye,d(r){r&&w(t)}}}function sh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class oh extends he{constructor(t){super(),de(this,t,sh,ih,pe,{classList:0})}}function ah(e){let t,n,r,i;return{c(){t=me("svg"),n=me("path"),r=me("path"),i=me("path"),this.h()},l(s){t=_e(s,"svg",{class:!0,height:!0,viewBox:!0,fill:!0,xmlns:!0});var a=C(t);n=_e(a,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),C(n).forEach(w),r=_e(a,"path",{d:!0,fill:!0}),C(r).forEach(w),i=_e(a,"path",{"fill-rule":!0,"clip-rule":!0,d:!0,fill:!0}),C(i).forEach(w),a.forEach(w),this.h()},h(){f(n,"fill-rule","evenodd"),f(n,"clip-rule","evenodd"),f(n,"d","M6.41113 3.73486C6.97158 4.11531 7.3643 4.63076 7.3643 5.31801V6.54526H8.59155C8.81654 6.54526 9.00063 6.36118 9.00063 6.13618V5.31801C9.00063 4.42621 7.5402 3.8985 6.41113 3.73486Z"),f(n,"fill","#DBAD37"),f(r,"d","M3.27305 3.27266C4.17677 3.27266 4.90938 2.54005 4.90938 1.63633C4.90938 0.732611 4.17677 0 3.27305 0C2.36933 0 1.63672 0.732611 1.63672 1.63633C1.63672 2.54005 2.36933 3.27266 3.27305 3.27266Z"),f(r,"fill","#DBAD37"),f(i,"fill-rule","evenodd"),f(i,"clip-rule","evenodd"),f(i,"d","M5.72716 3.27266C6.63124 3.27266 7.36349 2.54041 7.36349 1.63633C7.36349 0.732258 6.63124 0 5.72716 0C5.53489 0 5.3549 0.0409082 5.18308 0.0981798C5.53511 0.533533 5.72715 1.07646 5.72715 1.63633C5.72715 2.1962 5.53511 2.73913 5.18308 3.17448C5.3549 3.23176 5.53489 3.27266 5.72716 3.27266ZM3.27266 3.68175C2.18041 3.68175 0 4.22992 0 5.31808V6.13624C0 6.36124 0.184087 6.54533 0.409083 6.54533H6.13625C6.36124 6.54533 6.54533 6.36124 6.54533 6.13624V5.31808C6.54533 4.22992 4.36492 3.68175 3.27266 3.68175Z"),f(i,"fill","#DBAD37"),f(t,"class",e[0]),f(t,"height","15"),f(t,"viewBox","0 0 9 7"),f(t,"fill","none"),f(t,"xmlns","http://www.w3.org/2000/svg")},m(s,a){J(s,t,a),L(t,n),L(t,r),L(t,i)},p(s,[a]){a&1&&f(t,"class",s[0])},i:ye,o:ye,d(s){s&&w(t)}}}function lh(e,t,n){let{classList:r=""}=t;return e.$$set=i=>{"classList"in i&&n(0,r=i.classList)},[r]}class ms extends he{constructor(t){super(),de(this,t,lh,ah,pe,{classList:0})}}function Gr(e,t,n){const r=e.slice();return r[10]=t[n],r[12]=n,r}function Zr(e){let t,n,r,i,s,a,o,l,u,c,g,h,v,A,P,b;i=new ps({}),u=new ms({});let p=e[5],m=[];for(let _=0;_X(m[_],1,1,()=>{m[_]=null});return{c(){t=K("div"),n=K("ul"),r=K("li"),se(i.$$.fragment),s=W(),a=K("span"),o=ge("room"),l=W(),se(u.$$.fragment),c=W(),g=K("span"),h=ge("players"),v=W();for(let _=0;_{E=null}),Ce()),(!k||U&2&&p!==(p="grid-row gap-2 hover:bg-gray-300 "+(e[12]===e[1]?"text-green-600":"")+" svelte-15fj2lr"))&&f(n,"class",p)},i(N){k||(H(E),k=!0)},o(N){X(E),k=!1},d(N){N&&w(t),E&&E.d(),_=!1,$()}}}function uh(e){let t,n,r,i,s,a,o=e[4].label+"",l,u,c,g,h,v=e[4].total+"",A,P,b=e[4].capacity+"",p,m,k,_,$,E,O=!e[3]&&Zr(e);return i=new ps({}),c=new ms({}),{c(){t=K("div"),O&&O.c(),n=W(),r=K("div"),se(i.$$.fragment),s=W(),a=K("span"),l=ge(o),u=W(),se(c.$$.fragment),g=W(),h=K("span"),A=ge(v),P=ge(" / "),p=ge(b),this.h()},l(N){t=B(N,"DIV",{class:!0});var U=C(t);O&&O.l(U),n=G(U),r=B(U,"DIV",{class:!0});var V=C(r);oe(i.$$.fragment,V),s=G(V),a=B(V,"SPAN",{});var Z=C(a);l=ve(Z,o),Z.forEach(w),u=G(V),oe(c.$$.fragment,V),g=G(V),h=B(V,"SPAN",{});var ee=C(h);A=ve(ee,v),P=ve(ee," / "),p=ve(ee,b),ee.forEach(w),V.forEach(w),U.forEach(w),this.h()},h(){f(r,"class",m="grid-row gap-2 relative "+(e[0]?"cursor-wait":"cursor-pointer")+" svelte-15fj2lr"),f(t,"class",k="bg-violet-100 text-violet-900 px-3 py-1 font-mono font-medium tracking-tight relative z-0 "+(e[0]?"opacity-50":"")+" "+(e[3]?"rounded-xl":"rounded-b-xl"))},m(N,U){J(N,t,U),O&&O.m(t,null),L(t,n),L(t,r),ae(i,r,null),L(r,s),L(r,a),L(a,l),L(r,u),ae(c,r,null),L(r,g),L(r,h),L(h,A),L(h,P),L(h,p),e[8](t),_=!0,$||(E=Ve(r,"click",e[7]),$=!0)},p(N,[U]){N[3]?O&&(Te(),X(O,1,1,()=>{O=null}),Ce()):O?(O.p(N,U),U&8&&H(O,1)):(O=Zr(N),O.c(),H(O,1),O.m(t,n)),(!_||U&16)&&o!==(o=N[4].label+"")&&ot(l,o),(!_||U&16)&&v!==(v=N[4].total+"")&&ot(A,v),(!_||U&16)&&b!==(b=N[4].capacity+"")&&ot(p,b),(!_||U&1&&m!==(m="grid-row gap-2 relative "+(N[0]?"cursor-wait":"cursor-pointer")+" svelte-15fj2lr"))&&f(r,"class",m),(!_||U&9&&k!==(k="bg-violet-100 text-violet-900 px-3 py-1 font-mono font-medium tracking-tight relative z-0 "+(N[0]?"opacity-50":"")+" "+(N[3]?"rounded-xl":"rounded-b-xl")))&&f(t,"class",k)},i(N){_||(H(O),H(i.$$.fragment,N),H(c.$$.fragment,N),_=!0)},o(N){X(O),X(i.$$.fragment,N),X(c.$$.fragment,N),_=!1},d(N){N&&w(t),O&&O.d(),le(i),le(c),e[8](null),$=!1,E()}}}function ch(e,t,n){let r,{isLoading:i=!1}=t,s,a=[{label:"room 1",total:11,capacity:20},{label:"room 2",total:11,capacity:20},{label:"room 3",total:11,capacity:20},{label:"room 4",total:11,capacity:20},{label:"room 5",total:11,capacity:20}],o=0,l=!0;function u(v){s.contains(v.target)||n(3,l=!0)}Et(()=>(window.addEventListener("click",u,!0),()=>{window.removeEventListener("click",u,!0)}));const c=v=>n(1,o=v),g=()=>i?null:n(3,l=!l);function h(v){dt[v?"unshift":"push"](()=>{s=v,n(2,s)})}return e.$$set=v=>{"isLoading"in v&&n(0,i=v.isLoading)},e.$$.update=()=>{e.$$.dirty&2&&n(4,r=a[o])},[i,o,s,l,r,a,c,g,h]}class fh extends he{constructor(t){super(),de(this,t,ch,uh,pe,{isLoading:0})}}function hh(e){let t,n,r,i,s;return n=new zi({props:{isLoading:e[0]}}),n.$on("click",e[2]),i=new fh({props:{isLoading:e[0]}}),{c(){t=K("div"),se(n.$$.fragment),r=W(),se(i.$$.fragment),this.h()},l(a){t=B(a,"DIV",{class:!0});var o=C(t);oe(n.$$.fragment,o),r=G(o),oe(i.$$.fragment,o),o.forEach(w),this.h()},h(){f(t,"class","grid grid-cols-1 gap-1 w-max mx-auto")},m(a,o){J(a,t,o),ae(n,t,null),L(t,r),ae(i,t,null),s=!0},p(a,[o]){const l={};o&1&&(l.isLoading=a[0]),n.$set(l);const u={};o&1&&(u.isLoading=a[0]),i.$set(u)},i(a){s||(H(n.$$.fragment,a),H(i.$$.fragment,a),s=!0)},o(a){X(n.$$.fragment,a),X(i.$$.fragment,a),s=!1},d(a){a&&w(t),le(n),le(i)}}}function dh(e,t,n){const r=Qn();let{isLoading:i=!1}=t;const s=o=>{o.key==="Enter"&&r("prompt")};Et(()=>(window.addEventListener("keyup",s),()=>{window.removeEventListener("keyup",s)}));const a=()=>r("prompt");return e.$$set=o=>{"isLoading"in o&&n(0,i=o.isLoading)},[i,r,a]}class ph extends he{constructor(t){super(),de(this,t,dh,hh,pe,{isLoading:0})}}function mh(e){let t,n,r,i,s,a,o,l;return{c(){t=K("form"),n=K("div"),r=K("input"),i=W(),s=K("button"),a=ge("Paint"),this.h()},l(u){t=B(u,"FORM",{class:!0});var c=C(t);n=B(c,"DIV",{class:!0});var g=C(n);r=B(g,"INPUT",{class:!0,placeholder:!0,title:!0,type:!0,name:!0}),i=G(g),s=B(g,"BUTTON",{class:!0,type:!0});var h=C(s);a=ve(h,"Paint"),h.forEach(w),g.forEach(w),c.forEach(w),this.h()},h(){r.value=e[0],f(r,"class","input svelte-1ayu15l"),f(r,"placeholder","Type a prompt..."),f(r,"title","Input prompt to generate image and obtain palette"),f(r,"type","text"),f(r,"name","prompt"),f(s,"class","font-mono border-l-2 pl-2"),f(s,"type","submit"),f(n,"class","flex bg-white rounded-2xl px-2 w-full max-w-md"),f(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(u,c){J(u,t,c),L(t,n),L(n,r),e[7](r),L(n,i),L(n,s),L(s,a),e[8](n),o||(l=[Ve(r,"click",Rs(e[6])),Ve(r,"input",e[4]),Ve(s,"click",Mn(e[3])),Ve(t,"submit",Mn(e[3]))],o=!0)},p(u,[c]){c&1&&r.value!==u[0]&&(r.value=u[0])},i:ye,o:ye,d(u){u&&w(t),e[7](null),e[8](null),o=!1,Ms(l)}}}function _h(e,t,n){const r=Qn();let{initPrompt:i=""}=t,s,a,o;const l=wn(),u=m=>{m.key==="Escape"&&(l.update({status:ce.ready}),r("close"))};Et(()=>(a.focus(),n(0,s=i),window.addEventListener("keyup",u),window.addEventListener("click",A,!0),()=>{window.removeEventListener("keyup",u),window.removeEventListener("click",A,!0)}));let c;function g(m){clearTimeout(c),c=setTimeout(()=>{n(0,s=m),l.update({currentPrompt:s,status:ce.prompting})},100)}function h(){s.trim()!==""&&(r("paint"),r("close"))}function v(m){const k=m.target;g(k.value)}function A(m){o.contains(m.target)||(l.update({status:ce.ready}),r("close"))}function P(m){Dt.call(this,e,m)}function b(m){dt[m?"unshift":"push"](()=>{a=m,n(1,a)})}function p(m){dt[m?"unshift":"push"](()=>{o=m,n(2,o)})}return e.$$set=m=>{"initPrompt"in m&&n(5,i=m.initPrompt)},[s,a,o,h,v,i,P,b,p]}class gh extends he{constructor(t){super(),de(this,t,_h,mh,pe,{initPrompt:5})}}var _s={},gs={},hr={exports:{}},ue=String,vs=function(){return{isColorSupported:!1,reset:ue,bold:ue,dim:ue,italic:ue,underline:ue,inverse:ue,hidden:ue,strikethrough:ue,black:ue,red:ue,green:ue,yellow:ue,blue:ue,magenta:ue,cyan:ue,white:ue,gray:ue,bgBlack:ue,bgRed:ue,bgGreen:ue,bgYellow:ue,bgBlue:ue,bgMagenta:ue,bgCyan:ue,bgWhite:ue}};hr.exports=vs();hr.exports.createColors=vs;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,u){for(var c in u)Object.defineProperty(l,c,{enumerable:!0,get:u[c]})}t(e,{dim:()=>a,default:()=>o});const n=r(hr.exports);function r(l){return l&&l.__esModule?l:{default:l}}let i=new Set;function s(l,u,c){typeof process<"u"&&process.env.JEST_WORKER_ID||c&&i.has(c)||(c&&i.add(c),console.warn(""),u.forEach(g=>console.warn(l,"-",g)))}function a(l){return n.default.dim(l)}const o={info(l,u){s(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[u,l])},warn(l,u){s(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[u,l])},risk(l,u){s(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[u,l])}}})(gs);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:()=>i});const t=n(gs);function n(s){return s&&s.__esModule?s:{default:s}}function r({version:s,from:a,to:o}){t.default.warn(`${a}-color-renamed`,[`As of Tailwind CSS ${s}, \`${a}\` has been renamed to \`${o}\`.`,"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}}})(_s);let Rn=_s;var vh=(Rn.__esModule?Rn:{default:Rn}).default;const qt=Object.values(vh).filter(e=>typeof e=="object").map(e=>e[200]).slice(0,18),Wt=["\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}"];let yh=(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 ti(e,t,n){const r=e.slice();return r[16]=t[n].connectionId,r[17]=t[n].presence,r}function ni(e){var r;let t,n;return t=new gh({props:{initPrompt:(r=e[0])==null?void 0:r.currentPrompt}}),t.$on("paint",e[11]),t.$on("close",e[10]),{c(){se(t.$$.fragment)},l(i){oe(t.$$.fragment,i)},m(i,s){ae(t,i,s),n=!0},p(i,s){var o;const a={};s&1&&(a.initPrompt=(o=i[0])==null?void 0:o.currentPrompt),t.$set(a)},i(i){n||(H(t.$$.fragment,i),n=!0)},o(i){X(t.$$.fragment,i),n=!1},d(i){le(t,i)}}}function ri(e){let t=[],n=new Map,r,i,s=[...e[5]];const a=o=>o[16];for(let o=0;o{a=null}),Ce()),(k=t[17])!=null&&k.cursor?o?(o.p(t,A),A&32&&H(o,1)):(o=si(t),o.c(),H(o,1),o.m(i.parentNode,i)):o&&(Te(),X(o,1,1,()=>{o=null}),Ce())},i(v){s||(H(a),H(o),s=!0)},o(v){X(a),X(o),s=!1},d(v){v&&w(n),a&&a.d(v),v&&w(r),o&&o.d(v),v&&w(i)}}}function wh(e){let t,n,r,i,s,a,o,l,u,c,g,h,v,A,P=e[1]&&ni(e);a=new th({}),u=new Zf({props:{transform:e[4]}}),u.$on("prompt",e[9]);let b=e[5]&&ri(e);return v=new ph({props:{isLoading:e[2]}}),v.$on("prompt",e[9]),{c(){t=K("div"),n=ge(e[3]),r=W(),P&&P.c(),i=W(),s=K("div"),se(a.$$.fragment),o=W(),l=K("main"),se(u.$$.fragment),c=W(),b&&b.c(),g=W(),h=K("div"),se(v.$$.fragment),this.h()},l(p){t=B(p,"DIV",{class:!0});var m=C(t);n=ve(m,e[3]),m.forEach(w),r=G(p),P&&P.l(p),i=G(p),s=B(p,"DIV",{class:!0});var k=C(s);oe(a.$$.fragment,k),o=G(k),l=B(k,"MAIN",{class:!0});var _=C(l);oe(u.$$.fragment,_),c=G(_),b&&b.l(_),_.forEach(w),k.forEach(w),g=G(p),h=B(p,"DIV",{class:!0});var $=C(h);oe(v.$$.fragment,$),$.forEach(w),this.h()},h(){f(t,"class","text touch-none pointer-events-none"),f(l,"class","z-10 relative"),f(s,"class","fixed top-0 left-0 z-0 w-screen h-screen"),f(h,"class","fixed bottom-0 left-0 right-0 z-10 my-2")},m(p,m){J(p,t,m),L(t,n),J(p,r,m),P&&P.m(p,m),J(p,i,m),J(p,s,m),ae(a,s,null),L(s,o),L(s,l),ae(u,l,null),L(l,c),b&&b.m(l,null),J(p,g,m),J(p,h,m),ae(v,h,null),A=!0},p(p,[m]){(!A||m&8)&&ot(n,p[3]),p[1]?P?(P.p(p,m),m&2&&H(P,1)):(P=ni(p),P.c(),H(P,1),P.m(i.parentNode,i)):P&&(Te(),X(P,1,1,()=>{P=null}),Ce());const k={};m&16&&(k.transform=p[4]),u.$set(k),p[5]?b?(b.p(p,m),m&32&&H(b,1)):(b=ri(p),b.c(),H(b,1),b.m(l,null)):b&&(Te(),X(b,1,1,()=>{b=null}),Ce());const _={};m&4&&(_.isLoading=p[2]),v.$set(_)},i(p){A||(H(P),H(a.$$.fragment,p),H(u.$$.fragment,p),H(b),H(v.$$.fragment,p),A=!0)},o(p){X(P),X(a.$$.fragment,p),X(u.$$.fragment,p),X(b),X(v.$$.fragment,p),A=!1},d(p){p&&w(t),p&&w(r),P&&P.d(p),p&&w(i),p&&w(s),le(a),le(u),b&&b.d(),p&&w(g),p&&w(h),le(v)}}}function bh(e){return`${e.x}_${e.y}`}function kh(e,t,n){let r,i,s,a,o,l,u;Ae(e,Ie,k=>n(3,i=k)),Ae(e,Jn,k=>n(13,a=k)),Ae(e,Yn,k=>n(4,l=k));const c=wn();Ae(e,c,k=>n(0,o=k));const g=rc();Ae(e,g,k=>n(5,u=k));const h={cursor:null,frame:null,status:ce.dragging,currentPrompt:""};c.update(h);const v=es("promptImgStorage");Ae(e,v,k=>n(12,s=k));let A=!1;function P(){!r&&!A&&(n(1,A=!0),c.update({status:ce.prompting}))}function b(){n(1,A=!1)}function p(){m(),n(1,A=!1)}async function m(){if(r)return;Oe(Ie,i="Pending",i);const k=o.currentPrompt,_=o.frame;console.log("Generating...",k,_),c.update({status:ce.loading});const $=crypto.randomUUID(),E=a.toDataURL("image/png"),O={fn_index:0,data:[E,k,.75,7.5,35,"patchmatch"],session_hash:$},N=new WebSocket(Wu);N.onclose=U=>{U.wasClean||(Oe(Ie,i="Error",i),c.update({status:ce.ready}))},N.onmessage=async function(U){try{const V=JSON.parse(U.data);switch(Oe(Ie,i="",i),V.msg){case"send_data":Oe(Ie,i="Sending Data",i),N.send(JSON.stringify(O));break;case"queue_full":Oe(Ie,i="Queue full",i),N.close(),c.update({status:ce.ready});return;case"estimation":const{rank:Z,queue_size:ee}=V;Oe(Ie,i=`On queue ${Z}/${ee}`,i);break;case"process_generating":Oe(Ie,i=V.success?"Generating":"Error",i);break;case"process_completed":try{const we=V.output.data[0];if(V.output.data[1])throw new Error("NFSW");const S=bh(_),x=await Qu(we),z=await ec(x,k,S),D={prompt:k,imgURL:z,position:_,date:new Date().getTime(),id:yh()};s.set(S,D),console.log(z),Oe(Ie,i=V.success?"Complete":"Error",i),setTimeout(()=>{Oe(Ie,i="",i)},2e3),c.update({status:ce.ready,currentPrompt:""})}catch(we){const y=we;Oe(Ie,i=y==null?void 0:y.message,i),c.update({status:ce.ready})}N.close();return;case"process_starts":Oe(Ie,i="Processing",i);break}}catch(V){console.error(V),Oe(Ie,i="Error",i)}}}return e.$$.update=()=>{e.$$.dirty&1&&n(2,r=(o==null?void 0:o.status)===ce.loading||!1)},[o,A,r,i,l,u,c,g,v,P,b,p]}class Eh extends he{constructor(t){super(),de(this,t,kh,wh,pe,{})}}function ai(e){let t,n;return t=new Sa({props:{client:e[2],$$slots:{default:[Ih]},$$scope:{ctx:e}}}),{c(){se(t.$$.fragment)},l(r){oe(t.$$.fragment,r)},m(r,i){ae(t,r,i),n=!0},p(r,i){const s={};i&4&&(s.client=r[2]),i&9&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){X(t.$$.fragment,r),n=!1},d(r){le(t,r)}}}function xh(e){let t,n;return t=new Eh({}),{c(){se(t.$$.fragment)},l(r){oe(t.$$.fragment,r)},m(r,i){ae(t,r,i),n=!0},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){X(t.$$.fragment,r),n=!1},d(r){le(t,r)}}}function Ih(e){let t,n;return t=new Aa({props:{id:e[0],$$slots:{default:[xh]},$$scope:{ctx:e}}}),{c(){se(t.$$.fragment)},l(r){oe(t.$$.fragment,r)},m(r,i){ae(t,r,i),n=!0},p(r,i){const s={};i&1&&(s.id=r[0]),i&8&&(s.$$scope={dirty:i,ctx:r}),t.$set(s)},i(r){n||(H(t.$$.fragment,r),n=!0)},o(r){X(t.$$.fragment,r),n=!1},d(r){le(t,r)}}}function Oh(e){let t,n,r=e[1]&&ai(e);return{c(){r&&r.c(),t=st()},l(i){r&&r.l(i),t=st()},m(i,s){r&&r.m(i,s),J(i,t,s),n=!0},p(i,[s]){i[1]?r?(r.p(i,s),s&2&&H(r,1)):(r=ai(i),r.c(),H(r,1),r.m(t.parentNode,t)):r&&(Te(),X(r,1,1,()=>{r=null}),Ce())},i(i){n||(H(r),n=!0)},o(i){X(r),n=!1},d(i){r&&r.d(i),i&&w(t)}}}const Ah=!0;function Sh(e,t,n){let r,i=!1,s;return Et(()=>{document.addEventListener("wheel",a=>a.preventDefault(),{passive:!1}),n(0,r="multiplayer-SD"),n(2,s=xa({publicApiKey:"pk_test_JlUZGH3kQmhmZQiqU2l8eIi5"})),n(1,i=!0)}),[r,i,s]}class Th extends he{constructor(t){super(),de(this,t,Sh,Oh,pe,{})}}export{Th as default,Ah as prerender};