react-sync-board 0.7.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,184 @@
1
+ (function(X,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],f):(X=typeof globalThis<"u"?globalThis:X||self,f(X["React-sync-board"]={},X.React))})(this,function(X,f){"use strict";var Vi=Object.defineProperty;var Gi=(X,f,Ce)=>f in X?Vi(X,f,{enumerable:!0,configurable:!0,writable:!0,value:Ce}):X[f]=Ce;var bn=(X,f,Ce)=>(Gi(X,typeof f!="symbol"?f+"":f,Ce),Ce);function Ce(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Ft=Ce(f);function Sn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pe={},Cn={get exports(){return Pe},set exports(e){Pe=e}},je={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Zt;function En(){if(Zt)return je;Zt=1;var e=f,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,p){var d,u={},E=null,S=null;p!==void 0&&(E=""+p),l.key!==void 0&&(E=""+l.key),l.ref!==void 0&&(S=l.ref);for(d in l)n.call(l,d)&&!o.hasOwnProperty(d)&&(u[d]=l[d]);if(a&&a.defaultProps)for(d in l=a.defaultProps,l)u[d]===void 0&&(u[d]=l[d]);return{$$typeof:t,type:a,key:E,ref:S,props:u,_owner:s.current}}return je.Fragment=r,je.jsx=i,je.jsxs=i,je}var De={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Ht;function wn(){return Ht||(Ht=1,process.env.NODE_ENV!=="production"&&function(){var e=f,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),S=Symbol.for("react.offscreen"),b=Symbol.iterator,m="@@iterator";function v(c){if(c===null||typeof c!="object")return null;var _=b&&c[b]||c[m];return typeof _=="function"?_:null}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(c){{for(var _=arguments.length,O=new Array(_>1?_-1:0),L=1;L<_;L++)O[L-1]=arguments[L];y("error",c,O)}}function y(c,_,O){{var L=C.ReactDebugCurrentFrame,W=L.getStackAddendum();W!==""&&(_+="%s",O=O.concat([W]));var G=O.map(function(R){return String(R)});G.unshift("Warning: "+_),Function.prototype.apply.call(console[c],console,G)}}var h=!1,x=!1,g=!1,I=!1,N=!1,M;M=Symbol.for("react.module.reference");function T(c){return!!(typeof c=="string"||typeof c=="function"||c===n||c===o||N||c===s||c===p||c===d||I||c===S||h||x||g||typeof c=="object"&&c!==null&&(c.$$typeof===E||c.$$typeof===u||c.$$typeof===i||c.$$typeof===a||c.$$typeof===l||c.$$typeof===M||c.getModuleId!==void 0))}function P(c,_,O){var L=c.displayName;if(L)return L;var W=_.displayName||_.name||"";return W!==""?O+"("+W+")":O}function $(c){return c.displayName||"Context"}function H(c){if(c==null)return null;if(typeof c.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case n:return"Fragment";case r:return"Portal";case o:return"Profiler";case s:return"StrictMode";case p:return"Suspense";case d:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case a:var _=c;return $(_)+".Consumer";case i:var O=c;return $(O._context)+".Provider";case l:return P(c,c.render,"ForwardRef");case u:var L=c.displayName||null;return L!==null?L:H(c.type)||"Memo";case E:{var W=c,G=W._payload,R=W._init;try{return H(R(G))}catch{return null}}}return null}var K=Object.assign,k=0,j,D,V,Y,F,re,ce;function ue(){}ue.__reactDisabledLog=!0;function le(){{if(k===0){j=console.log,D=console.info,V=console.warn,Y=console.error,F=console.group,re=console.groupCollapsed,ce=console.groupEnd;var c={configurable:!0,enumerable:!0,value:ue,writable:!0};Object.defineProperties(console,{info:c,log:c,warn:c,error:c,group:c,groupCollapsed:c,groupEnd:c})}k++}}function Z(){{if(k--,k===0){var c={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:K({},c,{value:j}),info:K({},c,{value:D}),warn:K({},c,{value:V}),error:K({},c,{value:Y}),group:K({},c,{value:F}),groupCollapsed:K({},c,{value:re}),groupEnd:K({},c,{value:ce})})}k<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=C.ReactCurrentDispatcher,Se;function Te(c,_,O){{if(Se===void 0)try{throw Error()}catch(W){var L=W.stack.trim().match(/\n( *(at )?)/);Se=L&&L[1]||""}return`
18
+ `+Se+c}}var $t=!1,dt;{var Ei=typeof WeakMap=="function"?WeakMap:Map;dt=new Ei}function sn(c,_){if(!c||$t)return"";{var O=dt.get(c);if(O!==void 0)return O}var L;$t=!0;var W=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var G;G=ie.current,ie.current=null,le();try{if(_){var R=function(){throw Error()};if(Object.defineProperty(R.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(R,[])}catch(be){L=be}Reflect.construct(c,[],R)}else{try{R.call()}catch(be){L=be}c.call(R.prototype)}}else{try{throw Error()}catch(be){L=be}c()}}catch(be){if(be&&L&&typeof be.stack=="string"){for(var z=be.stack.split(`
19
+ `),se=L.stack.split(`
20
+ `),q=z.length-1,Q=se.length-1;q>=1&&Q>=0&&z[q]!==se[Q];)Q--;for(;q>=1&&Q>=0;q--,Q--)if(z[q]!==se[Q]){if(q!==1||Q!==1)do if(q--,Q--,Q<0||z[q]!==se[Q]){var fe=`
21
+ `+z[q].replace(" at new "," at ");return c.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",c.displayName)),typeof c=="function"&&dt.set(c,fe),fe}while(q>=1&&Q>=0);break}}}finally{$t=!1,ie.current=G,Z(),Error.prepareStackTrace=W}var Le=c?c.displayName||c.name:"",yn=Le?Te(Le):"";return typeof c=="function"&&dt.set(c,yn),yn}function wi(c,_,O){return sn(c,!1)}function Ii(c){var _=c.prototype;return!!(_&&_.isReactComponent)}function pt(c,_,O){if(c==null)return"";if(typeof c=="function")return sn(c,Ii(c));if(typeof c=="string")return Te(c);switch(c){case p:return Te("Suspense");case d:return Te("SuspenseList")}if(typeof c=="object")switch(c.$$typeof){case l:return wi(c.render);case u:return pt(c.type,_,O);case E:{var L=c,W=L._payload,G=L._init;try{return pt(G(W),_,O)}catch{}}}return""}var mt=Object.prototype.hasOwnProperty,on={},an=C.ReactDebugCurrentFrame;function gt(c){if(c){var _=c._owner,O=pt(c.type,c._source,_?_.type:null);an.setExtraStackFrame(O)}else an.setExtraStackFrame(null)}function _i(c,_,O,L,W){{var G=Function.call.bind(mt);for(var R in c)if(G(c,R)){var z=void 0;try{if(typeof c[R]!="function"){var se=Error((L||"React class")+": "+O+" type `"+R+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof c[R]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw se.name="Invariant Violation",se}z=c[R](_,R,L,O,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(q){z=q}z&&!(z instanceof Error)&&(gt(W),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",L||"React class",O,R,typeof z),gt(null)),z instanceof Error&&!(z.message in on)&&(on[z.message]=!0,gt(W),w("Failed %s type: %s",O,z.message),gt(null))}}}var xi=Array.isArray;function Wt(c){return xi(c)}function Oi(c){{var _=typeof Symbol=="function"&&Symbol.toStringTag,O=_&&c[Symbol.toStringTag]||c.constructor.name||"Object";return O}}function ki(c){try{return cn(c),!1}catch{return!0}}function cn(c){return""+c}function un(c){if(ki(c))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Oi(c)),cn(c)}var Ze=C.ReactCurrentOwner,Ai={key:!0,ref:!0,__self:!0,__source:!0},ln,fn,Ut;Ut={};function Mi(c){if(mt.call(c,"ref")){var _=Object.getOwnPropertyDescriptor(c,"ref").get;if(_&&_.isReactWarning)return!1}return c.ref!==void 0}function Ti(c){if(mt.call(c,"key")){var _=Object.getOwnPropertyDescriptor(c,"key").get;if(_&&_.isReactWarning)return!1}return c.key!==void 0}function Ni(c,_){if(typeof c.ref=="string"&&Ze.current&&_&&Ze.current.stateNode!==_){var O=H(Ze.current.type);Ut[O]||(w('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',H(Ze.current.type),c.ref),Ut[O]=!0)}}function Li(c,_){{var O=function(){ln||(ln=!0,w("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",_))};O.isReactWarning=!0,Object.defineProperty(c,"key",{get:O,configurable:!0})}}function Pi(c,_){{var O=function(){fn||(fn=!0,w("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",_))};O.isReactWarning=!0,Object.defineProperty(c,"ref",{get:O,configurable:!0})}}var ji=function(c,_,O,L,W,G,R){var z={$$typeof:t,type:c,key:_,ref:O,props:R,_owner:G};return z._store={},Object.defineProperty(z._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(z,"_self",{configurable:!1,enumerable:!1,writable:!1,value:L}),Object.defineProperty(z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:W}),Object.freeze&&(Object.freeze(z.props),Object.freeze(z)),z};function Di(c,_,O,L,W){{var G,R={},z=null,se=null;O!==void 0&&(un(O),z=""+O),Ti(_)&&(un(_.key),z=""+_.key),Mi(_)&&(se=_.ref,Ni(_,W));for(G in _)mt.call(_,G)&&!Ai.hasOwnProperty(G)&&(R[G]=_[G]);if(c&&c.defaultProps){var q=c.defaultProps;for(G in q)R[G]===void 0&&(R[G]=q[G])}if(z||se){var Q=typeof c=="function"?c.displayName||c.name||"Unknown":c;z&&Li(R,Q),se&&Pi(R,Q)}return ji(c,z,se,W,L,Ze.current,R)}}var Xt=C.ReactCurrentOwner,dn=C.ReactDebugCurrentFrame;function Ne(c){if(c){var _=c._owner,O=pt(c.type,c._source,_?_.type:null);dn.setExtraStackFrame(O)}else dn.setExtraStackFrame(null)}var Vt;Vt=!1;function Gt(c){return typeof c=="object"&&c!==null&&c.$$typeof===t}function pn(){{if(Xt.current){var c=H(Xt.current.type);if(c)return`
22
+
23
+ Check the render method of \``+c+"`."}return""}}function zi(c){{if(c!==void 0){var _=c.fileName.replace(/^.*[\\\/]/,""),O=c.lineNumber;return`
24
+
25
+ Check your code at `+_+":"+O+"."}return""}}var mn={};function Ri(c){{var _=pn();if(!_){var O=typeof c=="string"?c:c.displayName||c.name;O&&(_=`
26
+
27
+ Check the top-level render call using <`+O+">.")}return _}}function gn(c,_){{if(!c._store||c._store.validated||c.key!=null)return;c._store.validated=!0;var O=Ri(_);if(mn[O])return;mn[O]=!0;var L="";c&&c._owner&&c._owner!==Xt.current&&(L=" It was passed a child from "+H(c._owner.type)+"."),Ne(c),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',O,L),Ne(null)}}function hn(c,_){{if(typeof c!="object")return;if(Wt(c))for(var O=0;O<c.length;O++){var L=c[O];Gt(L)&&gn(L,_)}else if(Gt(c))c._store&&(c._store.validated=!0);else if(c){var W=v(c);if(typeof W=="function"&&W!==c.entries)for(var G=W.call(c),R;!(R=G.next()).done;)Gt(R.value)&&gn(R.value,_)}}}function Yi(c){{var _=c.type;if(_==null||typeof _=="string")return;var O;if(typeof _=="function")O=_.propTypes;else if(typeof _=="object"&&(_.$$typeof===l||_.$$typeof===u))O=_.propTypes;else return;if(O){var L=H(_);_i(O,c.props,"prop",L,c)}else if(_.PropTypes!==void 0&&!Vt){Vt=!0;var W=H(_);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",W||"Unknown")}typeof _.getDefaultProps=="function"&&!_.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Bi(c){{for(var _=Object.keys(c.props),O=0;O<_.length;O++){var L=_[O];if(L!=="children"&&L!=="key"){Ne(c),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",L),Ne(null);break}}c.ref!==null&&(Ne(c),w("Invalid attribute `ref` supplied to `React.Fragment`."),Ne(null))}}function vn(c,_,O,L,W,G){{var R=T(c);if(!R){var z="";(c===void 0||typeof c=="object"&&c!==null&&Object.keys(c).length===0)&&(z+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var se=zi(W);se?z+=se:z+=pn();var q;c===null?q="null":Wt(c)?q="array":c!==void 0&&c.$$typeof===t?(q="<"+(H(c.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):q=typeof c,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",q,z)}var Q=Di(c,_,O,W,G);if(Q==null)return Q;if(R){var fe=_.children;if(fe!==void 0)if(L)if(Wt(fe)){for(var Le=0;Le<fe.length;Le++)hn(fe[Le],c);Object.freeze&&Object.freeze(fe)}else w("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else hn(fe,c)}return c===n?Bi(Q):Yi(Q),Q}}function $i(c,_,O){return vn(c,_,O,!0)}function Wi(c,_,O){return vn(c,_,O,!1)}var Ui=Wi,Xi=$i;De.Fragment=n,De.jsx=Ui,De.jsxs=Xi}()),De}(function(e){process.env.NODE_ENV==="production"?e.exports=En():e.exports=wn()})(Cn);const Kt=Pe.Fragment,A=Pe.jsx,ve=Pe.jsxs;let In=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");class _n{constructor(t,r,n=null){this._socket=t,this.userId=n,this.room=r,this.toUnregister=[()=>{this._socket.off(`${this.room}.isMaster`),this._socket.off(`${this.room}.roomJoined`),this._socket.off(`${this.room}._call`)}],this._left=!1,this.registeredRPC={},this._socket.on(`${this.room}._call`,async({callId:s,name:o,params:i})=>{try{const a=await this.registeredRPC[o](i);t.emit(`${this.room}._result.${s}`,{ok:a||null})}catch(a){t.emit(`${this.room}._result.${s}`,{err:`${a.message}`})}})}async _callServerRPC(t,r){const n=In();return new Promise((s,o)=>{this._socket.once(`${this.room}._result.${n}`,i=>{i.hasOwnProperty("ok")?s(i.ok):o(i.err)}),this._socket.emit(`${this.room}._call`,{callId:n,name:t,params:r})})}leave(){this._left=!0,this.toUnregister.forEach(t=>{t()}),this._socket.emit(`${this.room}.leave`)}publish(t,r,n=!1){this._socket.emit(`${this.room}.publish`,{name:t,params:r,self:n})}subscribe(t,r){this._socket.on(`${this.room}.${t}`,r);const n=()=>{this._socket.off(`${this.room}.${t}`,r)};return this.toUnregister.push(n),n}async register(t,r,{invoke:n="single"}={}){this.registeredRPC[t]=r,await this._callServerRPC("register",{name:t,invoke:n});const s=()=>{if(this.registeredRPC[t]===r)return delete this.registeredRPC[t],this._callServerRPC("unregister",{name:t})};return this.toUnregister.push(s),s}async call(t,r){return await this._callServerRPC("call",{name:t,params:r})}}const xn=({socket:e,room:t,onJoined:r=()=>{},onMaster:n=()=>{},userId:s=null})=>{const o=new _n(e,t,s);return new Promise(i=>{let a=!0;e.on(`${t}.isMaster`,()=>{o._left||n(t)}),e.on(`${t}.roomJoined`,l=>{o._left||(o.userId=l,a=!1,r(o),i(o))}),e.on("connect",()=>{o._left||a||e.emit("joinSuperSocket",{room:t,userId:o.userId})}),e.emit("joinSuperSocket",{room:t,userId:s})})},ht=f.createContext(),On=()=>A("div",{style:{position:"absolute",top:"0",bottom:"0",width:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:A("h2",{children:"🌀 Loading..."})}),qt=({socket:e,room:t,channel:r="default",LoadingComponent:n=On,children:s})=>{const[o,i]=f.useState(!1),[a,l]=f.useState(!1),[p,d]=f.useState(null),u=f.useRef(null),E=f.useRef(!1),S=f.useContext(ht),b=f.useRef(!1);return f.useEffect(()=>(E.current=!0,()=>{E.current=!1}),[]),f.useEffect(()=>{if(!e)return null;const m=()=>{console.log(`Disconnected from ${r}…`),E.current&&(i(!1),l(!1))};return e.on("disconnect",m),()=>{e.off("disconnect",m)}},[r,e]),f.useEffect(()=>e?(e.connected||e.connect(),console.log(`Try to connect to wire ${t} on channel ${r}`),b.current||(b.current=!0,xn({socket:e,room:t,onMaster:()=>{console.log(`Is now master on channel ${r}…`),E.current&&l(!0)},onJoined:m=>{console.log(`Connected on channel ${r}…`),u.current=m,E.current&&(d(m),i(!0))}})),()=>{var m;(m=u.current)==null||m.leave()}):null,[r,t,e]),!o||!p?A(n,{}):A(ht.Provider,{value:{...S,[r]:{wire:p,joined:o,isMaster:a,room:t}},children:s})},ze=(e="default")=>(f.useContext(ht)||{})[e],Jt=e=>{let t;const r=new Set,n=(l,p)=>{const d=typeof l=="function"?l(t):l;if(!Object.is(d,t)){const u=t;t=p??typeof d!="object"?d:Object.assign({},t,d),r.forEach(E=>E(t,u))}},s=()=>t,a={setState:n,getState:s,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production"&&console.warn("[DEPRECATED] The destroy method will be unsupported in the future version. You should use unsubscribe function returned by subscribe. Everything will be garbage collected if store is garbage collected."),r.clear()}};return t=e(n,s,a),a},He=e=>e?Jt(e):Jt;var vt={},kn={get exports(){return vt},set exports(e){vt=e}},yt={},Ke={},An={get exports(){return Ke},set exports(e){Ke=e}},bt={};/**
28
+ * @license React
29
+ * use-sync-external-store-shim.production.min.js
30
+ *
31
+ * Copyright (c) Facebook, Inc. and its affiliates.
32
+ *
33
+ * This source code is licensed under the MIT license found in the
34
+ * LICENSE file in the root directory of this source tree.
35
+ */var Qt;function Mn(){if(Qt)return bt;Qt=1;var e=f;function t(u,E){return u===E&&(u!==0||1/u===1/E)||u!==u&&E!==E}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,s=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function a(u,E){var S=E(),b=n({inst:{value:S,getSnapshot:E}}),m=b[0].inst,v=b[1];return o(function(){m.value=S,m.getSnapshot=E,l(m)&&v({inst:m})},[u,S,E]),s(function(){return l(m)&&v({inst:m}),u(function(){l(m)&&v({inst:m})})},[u]),i(S),S}function l(u){var E=u.getSnapshot;u=u.value;try{var S=E();return!r(u,S)}catch{return!0}}function p(u,E){return E()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:a;return bt.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,bt}var St={};/**
36
+ * @license React
37
+ * use-sync-external-store-shim.development.js
38
+ *
39
+ * Copyright (c) Facebook, Inc. and its affiliates.
40
+ *
41
+ * This source code is licensed under the MIT license found in the
42
+ * LICENSE file in the root directory of this source tree.
43
+ */var er;function Tn(){return er||(er=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=f,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(y){{for(var h=arguments.length,x=new Array(h>1?h-1:0),g=1;g<h;g++)x[g-1]=arguments[g];n("error",y,x)}}function n(y,h,x){{var g=t.ReactDebugCurrentFrame,I=g.getStackAddendum();I!==""&&(h+="%s",x=x.concat([I]));var N=x.map(function(M){return String(M)});N.unshift("Warning: "+h),Function.prototype.apply.call(console[y],console,N)}}function s(y,h){return y===h&&(y!==0||1/y===1/h)||y!==y&&h!==h}var o=typeof Object.is=="function"?Object.is:s,i=e.useState,a=e.useEffect,l=e.useLayoutEffect,p=e.useDebugValue,d=!1,u=!1;function E(y,h,x){d||e.startTransition!==void 0&&(d=!0,r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=h();if(!u){var I=h();o(g,I)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}var N=i({inst:{value:g,getSnapshot:h}}),M=N[0].inst,T=N[1];return l(function(){M.value=g,M.getSnapshot=h,S(M)&&T({inst:M})},[y,g,h]),a(function(){S(M)&&T({inst:M});var P=function(){S(M)&&T({inst:M})};return y(P)},[y]),p(g),g}function S(y){var h=y.getSnapshot,x=y.value;try{var g=h();return!o(x,g)}catch{return!0}}function b(y,h,x){return h()}var m=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",v=!m,C=v?b:E,w=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:C;St.useSyncExternalStore=w,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),St}var tr;function rr(){return tr||(tr=1,function(e){process.env.NODE_ENV==="production"?e.exports=Mn():e.exports=Tn()}(An)),Ke}/**
44
+ * @license React
45
+ * use-sync-external-store-shim/with-selector.production.min.js
46
+ *
47
+ * Copyright (c) Facebook, Inc. and its affiliates.
48
+ *
49
+ * This source code is licensed under the MIT license found in the
50
+ * LICENSE file in the root directory of this source tree.
51
+ */var nr;function Nn(){if(nr)return yt;nr=1;var e=f,t=rr();function r(p,d){return p===d&&(p!==0||1/p===1/d)||p!==p&&d!==d}var n=typeof Object.is=="function"?Object.is:r,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;return yt.useSyncExternalStoreWithSelector=function(p,d,u,E,S){var b=o(null);if(b.current===null){var m={hasValue:!1,value:null};b.current=m}else m=b.current;b=a(function(){function C(g){if(!w){if(w=!0,y=g,g=E(g),S!==void 0&&m.hasValue){var I=m.value;if(S(I,g))return h=I}return h=g}if(I=h,n(y,g))return I;var N=E(g);return S!==void 0&&S(I,N)?I:(y=g,h=N)}var w=!1,y,h,x=u===void 0?null:u;return[function(){return C(d())},x===null?void 0:function(){return C(x())}]},[d,u,E,S]);var v=s(p,b[0],b[1]);return i(function(){m.hasValue=!0,m.value=v},[v]),l(v),v},yt}var Ct={};/**
52
+ * @license React
53
+ * use-sync-external-store-shim/with-selector.development.js
54
+ *
55
+ * Copyright (c) Facebook, Inc. and its affiliates.
56
+ *
57
+ * This source code is licensed under the MIT license found in the
58
+ * LICENSE file in the root directory of this source tree.
59
+ */var sr;function Ln(){return sr||(sr=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=f,t=rr();function r(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var n=typeof Object.is=="function"?Object.is:r,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;function p(d,u,E,S,b){var m=o(null),v;m.current===null?(v={hasValue:!1,value:null},m.current=v):v=m.current;var C=a(function(){var x=!1,g,I,N=function($){if(!x){x=!0,g=$;var H=S($);if(b!==void 0&&v.hasValue){var K=v.value;if(b(K,H))return I=K,K}return I=H,H}var k=g,j=I;if(n(k,$))return j;var D=S($);return b!==void 0&&b(j,D)?j:(g=$,I=D,D)},M=E===void 0?null:E,T=function(){return N(u())},P=M===null?void 0:function(){return N(M())};return[T,P]},[u,E,S,b]),w=C[0],y=C[1],h=s(d,w,y);return i(function(){v.hasValue=!0,v.value=h},[h]),l(h),h}Ct.useSyncExternalStoreWithSelector=p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ct}(function(e){process.env.NODE_ENV==="production"?e.exports=Nn():e.exports=Ln()})(kn);const Pn=Sn(vt),{useSyncExternalStoreWithSelector:jn}=Pn;function qe(e,t=e.getState,r){const n=jn(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return f.useDebugValue(n),n}const or=e=>{({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0}&&"production")!=="production"&&typeof e!="function"&&console.warn('[DEPRECATED] Passing a vanilla store will be unsupported in the future version. Please use `import { useStore } from "zustand"` to use the vanilla store in React.');const t=typeof e=="function"?He(e):e,r=(n,s)=>qe(t,n,s);return Object.assign(r,t),r},ir=e=>e?or(e):or,_e=(e,t)=>e.classList&&e.classList.contains(t),Re=(e,t)=>_e(e,t)?e:e.parentNode?Re(e.parentNode,t):!1,ar=(e,t)=>e.x>t.left&&e.x<t.left+t.width&&e.y>t.top&&e.y<t.top+t.height,Dn=(e,t)=>{const r=t.getBoundingClientRect();return Array.from(e.querySelectorAll(".corner")).every(s=>{const{top:o,left:i}=s.getBoundingClientRect();return ar({x:i,y:o},r)})},Et=(e,t)=>{const n=e.getElementsByClassName(`item ${t}`)[0];return n||console.error(`Missing item ${t}`),n},Ye=e=>{var r,n;const t=(r=e==null?void 0:e.dataset)==null?void 0:r.id;return t||console.error("getIdFromElem call fails",e,JSON.stringify(e==null?void 0:e.dataset),(n=e==null?void 0:e.dataset)==null?void 0:n.id),t},cr=(e,t=document)=>{const r=e.reduce((n,s)=>{const o=Et(t,s);if(!o)return null;const{left:i,right:a,top:l,bottom:p}=o.getBoundingClientRect();let d;return n?d=n:d={left:i,top:l,right:a,bottom:p},d.left=Math.min(i,d.left),d.top=Math.min(l,d.top),d.right=Math.max(a,d.right),d.bottom=Math.max(p,d.bottom),d},null);return r&&(r.width=r.right-r.left,r.height=r.bottom-r.top,r)},zn=({x:e,y:t,width:r,height:n},{type:s="grid",size:o=1,offset:i={x:0,y:0}})=>{const[a,l]=[e+r/2-i.x,t+n/2-i.y];let p,d,u,E,S,b,m,v,C,w;const y=o/1.1547;switch(s){case"grid":p=Math.round(a/o)*o,d=Math.round(l/o)*o;break;case"hexH":u=2*y,E=3*o,S=Math.round(a/u)*u,m=Math.round(l/E)*E,b=S>a?S-y:S+y,v=m>l?m-1.5*o:m+1.5*o,C=Math.hypot(S-a,m-l),w=Math.hypot(b-a,v-l),C<w?(p=S,d=m):(p=b,d=v);break;case"hexV":u=3*o,E=2*y,S=Math.round(a/u)*u,m=Math.round(l/E)*E,b=S>a?S-1.5*o:S+1.5*o,v=m>l?m-y:m+y,C=Math.hypot(S-a,m-l),w=Math.hypot(b-a,v-l),C<w?(p=S,d=m):(p=b,d=v);break;default:p=e+r/2,d=t+n/2}return{x:p+i.x-r/2,y:d+i.y-n/2}},ur=["#037758","#99092a","#067070","#c6650f","#008726","#3d7004","#348402","#057f58","#b58612","#c44c01","#0a7704","#0e910e","#027377","#c99e02","#054160","#157a01","#b10de2","#0d6289","#bc5d03","#ba0cd1","#d39f10","#0c4c7a","#460782","#a51f10","#cecb10","#9b0943","#607f0c","#007a4b","#bf0daa","#af0ad8"],lr=()=>ur[Math.floor(Math.random()*ur.length)],Rn=!1,wt=({wire:e,storeName:t,noSync:r=[],defaultValue:n},s)=>(o,i,a)=>{o({ready:!1});const l=[];(async()=>{try{const S=await e.call(`${t}_getValue`);Rn&&console.log("init from peer with value",S),o(b=>({...b,...S}))}catch{n!==void 0&&o(n)}l.push(await e.register(`${t}_getValue`,()=>Object.fromEntries(Object.entries(i()).filter(([S,b])=>typeof b!="function"&&!r.includes(S))),{invoke:"first"})),l.push(e.subscribe(`${t}_call`,([S,b])=>{u[S](...b)})),o({ready:!0})})();const d=s(o,i,a),u={...d},E=Object.fromEntries(Object.entries(d).map(([S,b])=>typeof b=="function"&&!S.startsWith("get")&&!r.includes(S)?[S,(...v)=>{const C=b(...v);return e.publish(`${t}_call`,[S,v]),C}]:[S,b]));return E.unsub=()=>{l.forEach(S=>S())},E};function Be(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,s]of e)if(!Object.is(s,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0}const fr=f.createContext(),Yn=(e,t)=>({items:{},getItems:()=>t().items,setItems:r=>e({items:r}),updateItems:r=>e(n=>({items:{...n.items,...r}})),moveItems:(r,n)=>e(({items:s})=>{const o={...s};return r.forEach(i=>{const a=s[i];a&&(o[i]={...a,x:(a.x||0)+n.x,y:(a.y||0)+n.y,moving:!0})}),{items:o}})}),Bn=(e,t)=>({itemIds:[],setItemIds:r=>e({itemIds:r}),getItemIds:()=>t().itemIds,insert:(r,n)=>e(s=>{const o=[...s.itemIds];return o.splice(r,0,n),{itemIds:o}}),remove:r=>e(n=>{const s=[...n.itemIds];return s.splice(r,1),{itemIds:s}}),updateItemIds:(r,n)=>e(s=>{const o=[...s.itemIds];return o[r]=n,{items:o}}),updateManyItemIds:r=>e(n=>({items:n.itemIds.map((s,o)=>r[o]!==void 0?r[o]:s)}))}),$n=(e,t)=>({removeItemsById:r=>e(n=>({itemIds:n.itemIds.filter(s=>!r.includes(s)),items:Object.fromEntries(Object.entries(n.items).filter(([s])=>!r.includes(s)))})),getItemList:()=>{const r=t().items;return t().itemIds.map(n=>r[n])},setItemList:r=>e({items:Object.fromEntries(r.map(n=>[n.id,n])),itemIds:r.map(({id:n})=>n)}),insertItems:(r,n)=>e(s=>{let o;const i=r.map(({id:a})=>a);if(n){const a=s.itemIds.findIndex(l=>l===n);o=[...s.itemIds],o.splice(a,0,...i)}else o=[...s.itemIds,...i];return{items:{...s.items,...Object.fromEntries(r.map(a=>[a.id,a]))},itemIds:o}})}),Wn=(e,t)=>({boardConfig:{},getBoardConfig:()=>t().boardConfig,setBoardConfig:r=>e({boardConfig:r}),updateBoardConfig:r=>e(n=>({boardConfig:{...n.boardConfig,...r}}))}),Un=(e,t)=>({session:{},getSessionInfo:()=>t().session,setSessionInfo:r=>e({session:r}),updateSessionInfo:r=>e(n=>({session:{...n.session,...r}}))}),dr=({storeName:e,children:t,defaultValue:r})=>{const{wire:n}=ze("room"),[s]=f.useState(()=>He(wt({wire:n,storeName:e,defaultValue:r},(...o)=>({...Yn(...o),...Bn(...o),...$n(...o),...Wn(...o),...Un(...o)}))));return A(fr.Provider,{value:s,children:t})},de=(e,t)=>{const r=f.useContext(fr);return qe(r,e,t||Be)},Xn=()=>{const[e,t]=de(n=>[n.itemIds,n.items]);return f.useMemo(()=>e.map(n=>t[n]),[e,t])};function pr(e){const t=f.useRef(e);return t.current=e,f.useMemo(()=>Object.freeze({get current(){return t.current}}),[])}function mr(e){const t=pr(e);f.useEffect(()=>()=>{t.current()},[])}function It(e,t,r,n=0){const s=f.useRef(),o=f.useRef(),i=f.useRef(),a=()=>{s.current&&(clearTimeout(s.current),s.current=void 0),o.current&&(clearTimeout(o.current),o.current=void 0)};return mr(a),f.useMemo(()=>{const l=()=>{if(!i.current)return;const d=i.current;i.current=void 0,e.apply(d.this,d.args),a()},p=function(...d){s.current&&clearTimeout(s.current),i.current={args:d,this:this},s.current=setTimeout(l,r),n>0&&!o.current&&(o.current=setTimeout(l,n))};return Object.defineProperties(p,{length:{value:e.length},name:{value:`${e.name||"anonymous"}__debounced__${r}`}}),p},[r,n,...t])}const Vn=typeof window<"u"&&typeof navigator<"u"&&typeof document<"u";function gr(e,t,r,n=!1){const s=f.useRef(),o=f.useRef();return mr(()=>{s.current&&clearTimeout(s.current)}),f.useMemo(()=>{const i=(l,p)=>{o.current=void 0,e.apply(l,p),s.current=setTimeout(()=>{s.current=void 0,!n&&o.current&&(i(o.current.this,o.current.args),o.current=void 0)},r)},a=function(...l){if(s.current){o.current={args:l,this:this};return}i(this,l)};return Object.defineProperties(a,{length:{value:e.length},name:{value:`${e.name||"anonymous"}__throttled__${r}`}}),a},[r,n,...t])}function Gn(e,t,r,n=0){f.useEffect(It(e,t,r,n),t)}function Fn(e,t,r,n=!1){f.useEffect(gr(e,t,r,n),t)}let Je;function Zn(){if(!Vn)return;if(Je)return Je;const e=new Map,t=new ResizeObserver(r=>{r.forEach(n=>{var s;return(s=e.get(n.target))==null?void 0:s.forEach(o=>setTimeout(()=>o(n),0))})});return Je={observer:t,subscribe:(r,n)=>{let s=e.get(r);s||(s=new Set,e.set(r,s),t.observe(r)),s.add(n)},unsubscribe:(r,n)=>{const s=e.get(r);s&&(s.delete(n),s.size||(e.delete(r),t.unobserve(r)))}},Je}function Hn(e,t,r=!0){const n=r&&Zn(),s=pr(t),o=e&&"current"in e?e.current:e;f.useEffect(()=>{const i=e&&"current"in e?e.current:e;if(!n||!i)return;let a=!0;const l=(...p)=>{a&&s.current(...p)};return n.subscribe(i,l),()=>{a=!1,n.unsubscribe(i,l)}},[o,n])}const Kn=()=>{const[e,t,r]=de(o=>[o.items,o.itemIds,o.getItemList]),[n,s]=f.useState(r());return Fn(()=>{const o=r();s(o)},[e,t,r],300),n},qn=ir((e,t)=>({selection:[],setSelection:r=>e(n=>JSON.stringify(n.selection)!==JSON.stringify(r)?{selection:r}:{}),getSelection:()=>t().selection,select:r=>e(n=>({selection:[...n.selection,...r]})),unselect:r=>e(n=>({selection:n.selection.filter(s=>!r.includes(s))})),clear:()=>e(r=>r.selection.length>0?{selection:[]}:{}),reverse:()=>e(r=>{const n=[...r.selection];return n.reverse(),{selection:n}}),selectionBox:null,setSelectionBox:r=>e(n=>{const s=n.selectionBox;return!s||!r||s.top!==r.top||s.left!==r.left||s.width!==r.width||s.height!==r.height?{selectionBox:r}:{}})})),ye=(e,t)=>qn(e,t||Be),Jn=()=>ye(e=>e.selection),hr=5e4,Qn=(e,t)=>({config:{itemTemplates:{},actions:{},uid:null,itemExtent:{},boardWrapperRect:{},boardSize:hr},updateConfiguration:r=>e(n=>({config:{...n.config,...r}})),getConfiguration:()=>t().config}),es=(e,t)=>({boardState:{movingItems:!1,selecting:!1,zooming:!1,panning:!1,translateX:0,translateY:0,scale:1},updateBoardState:r=>e(n=>({boardState:{...n.boardState,...r}})),getBoardState:()=>t().boardState}),ts=(e,t)=>({interactions:{},getInteractions:()=>t().interactions,register:(r,n)=>e(s=>{const o=[...s.interactions[r]||[]];return o.push(n),{interactions:{...s.interaction,[r]:o}}}),unregister:(r,n)=>e(s=>{const o=(s.interactions[r]||[]).filter(i=>i!==n);return{interactions:{...s.interaction,[r]:o}}}),callInteractions:(r,n)=>{t().interactions[r]&&t().interactions[r].forEach(s=>{s(n)})}}),rs=ir((...e)=>({...Qn(...e),...es(...e),...ts(...e)})),ee=(e,t)=>rs(e,t||Be),Qe=100,xe=1e3,ns=.8,vr=({x:e,y:t,scale:r,itemExtent:{right:n,left:s,top:o,bottom:i},boardWrapperRect:a,boardSize:l})=>{const p={left:-n*r+Qe*r,right:a.width-s*r-Qe*r,top:-i*r+Qe*r,bottom:a.height-o*r-Qe*r,maxRight:a.width-l*r,maxLeft:a.height-l*r},d=Math.min(Math.max(e,p.left,p.maxRight),p.right,0),u=Math.min(Math.max(t,p.top,p.maxLeft),p.bottom,0);return[d,u]},et=()=>{const[e,t]=ee(m=>[m.getBoardState,m.updateBoardState]),r=f.useRef([.1,8]),[n,s,o]=ee(m=>[m.config.itemExtent,m.getConfiguration,m.updateConfiguration]),i=de(m=>m.getItemIds),a=f.useCallback(()=>{const{translateX:m,translateY:v,scale:C}=e();return{translateX:m,translateY:v,scale:C}},[e]),l=f.useCallback(m=>{const{itemExtent:v,boardWrapperRect:C,boardSize:w}=s(),y=e(),{translateX:h,translateY:x,scale:g}={...y,...m(y)};let I=g;g!==y.scale&&(I>r.current[1]&&([,I]=r.current),I<r.current[0]&&([I]=r.current));let[N,M]=[h,x];(h!==y.translateX||x!==y.translateY)&&([N,M]=vr({x:h,y:x,scale:I,itemExtent:v,boardWrapperRect:C,boardSize:w})),t({translateX:N,translateY:M,scale:I})},[e,s,t]),p=f.useCallback((m,v)=>{const{itemExtent:C,boardWrapperRect:w,boardSize:y}=s();let h=v;h||(h={x:w.width/2,y:w.height/2});const x=e();let g=x.scale*m;g>r.current[1]&&([,g]=r.current),g<r.current[0]&&([g]=r.current);const I=h.x-w.left,N=h.y-w.top,M=I-(I-x.translateX)*g/x.scale,T=N-(N-x.translateY)*g/x.scale,[P,$]=vr({x:M,y:T,scale:g,itemExtent:C,boardWrapperRect:w,boardSize:y});t({scale:g,translateX:P,translateY:$})},[e,s,t]),d=f.useCallback(({left:m,top:v,width:C,height:w})=>{const{boardWrapperRect:y}=s(),h=y.width/C,x=y.height/w,I=Math.min(h,x)*ns,N=y.width/2-(m+C/2)*I,M=y.height/2-(v+w/2)*I;t({translateX:N,translateY:M,scale:I})},[s,t]),u=f.useCallback(async()=>{const{itemExtent:{width:m,height:v},boardWrapperRect:C}=s(),w=C.width/m,y=C.height/v,h=Math.min(w,y);r.current=[Math.max(h*.5,.05),Math.max(h*10,10)]},[s]),E=f.useCallback(()=>{const{boardWrapperRect:m,boardSize:v}=s(),{translateX:C,translateY:w,scale:y}=e();return{x:(m.width/2-C)/y-v/2,y:(m.height/2-w)/y-v/2}},[e,s]),S=f.useCallback(()=>{const m=i(),{boardWrapperRect:v,boardWrapper:C,boardSize:w}=s(),{scale:y,translateX:h,translateY:x}=e(),{left:g,top:I,width:N,height:M}=cr(m,C)||{left:w/2*y+v.left+h,top:w/2*y+v.top+x,width:0,height:0},T={left:(g-v.left-h)/y,top:(I-v.top-x)/y,width:N/y,height:M/y};if(T.right=T.left+T.width,T.bottom=T.top+T.height,T.width<xe){const P=(xe-T.width)/2;T.left-=P,T.right+=P,T.width=xe}if(T.height<xe){const P=(xe-T.height)/2;T.top-=P,T.bottom+=P,T.height=xe}o({itemExtent:T})},[e,s,i,o]),b=It(S,[],300);return f.useEffect(()=>{n.left&&u()},[u,n]),{setDim:l,getDim:a,zoomTo:p,zoomToCenter:p,zoomToExtent:d,getCenter:E,updateItemExtent:b}},yr=e=>{const[t,r,n]=ee(({register:i,unregister:a,callInteractions:l})=>[i,a,l]),s=f.useCallback(i=>(t(e,i),()=>{r(e,i)}),[e,t,r]),o=f.useCallback(i=>{n(e,i)},[n,e]);return{register:s,call:o}},tt=()=>{const{call:e}=yr("place"),{getCenter:t,updateItemExtent:r}=et(),n=ee(k=>k.getConfiguration),{getItems:s,getItemIds:o,setItemIds:i,updateItems:a,moveItems:l,removeItemsById:p,getItemList:d,insertItems:u,setItemList:E}=de(({getItems:k,getItemIds:j,setItemIds:D,updateItems:V,moveItems:Y,removeItemsById:F,getItemList:re,insertItems:ce,setItemList:ue})=>({getItems:k,getItemIds:j,setItemIds:D,updateItems:V,moveItems:Y,removeItemsById:F,getItemList:re,insertItems:ce,setItemList:ue})),[S,b,m]=ye(k=>[k.clear,k.reverse,k.unselect]),v=f.useCallback((k,j)=>{let D=j;typeof j=="object"&&(D=()=>j);const V=o().filter(re=>k.includes(re)),Y=s(),F=Object.fromEntries(V.map(re=>[re,D({...Y[re]})]));a(F),r()},[o,s,r,a]),C=f.useCallback(k=>{E(k),S(),r()},[S,E,r]),w=f.useCallback((k,j)=>{v([k],j)},[v]),y=f.useCallback((k,j)=>{l(k,j),r()},[l,r]),h=f.useCallback(k=>{const j=o(),D=j.filter(Y=>!k.includes(Y)),V=j.filter(Y=>k.includes(Y));i([...D,...V])},[o,i]),x=f.useCallback((k,{type:j,size:D}={})=>{const{boardWrapper:V}=n(),Y={},F=s();k.forEach(re=>{const ce=F[re],ue=Et(V,re);if(!ue)return;const le={type:j||"grid",size:D||1,offset:{x:0,y:0},...ce.grid},Z=zn({x:ce.x,y:ce.y,width:ue.clientWidth,height:ue.clientHeight},le);Y[re]={...ce,...Z}}),a(Y)},[n,s,a]),g=f.useCallback((k,j)=>{h(k),v(k,D=>{const V={...D};return delete V.moving,V}),x(k,j),e(k),r()},[v,e,h,x,r]),I=f.useCallback(k=>{i(k)},[i]),N=f.useCallback(k=>{const j=o(),D=j.filter(Y=>k.includes(Y)),V=j.map(Y=>k.includes(Y)?D.pop():Y);i(V),b()},[o,b,i]),M=f.useCallback((k,j)=>{const D=s(),V=k.map(Z=>D[Z]),Y=j.map(Z=>D[Z]),F=j.reduce((Z,ie)=>(Z[ie]=V.shift(),Z),{}),re=Y.reduce((Z,ie)=>{const Se=F[ie.id],Te={...ie,x:Se.x,y:Se.y};return Z[ie.id]=Te,Z},{});a(re);const ce=k.reduce((Z,ie)=>(Z[ie]=j.shift(),Z),{}),le=o().map(Z=>k.includes(Z)?ce[Z]:Z);i(le)},[s,a,o,i]),T=f.useCallback((k,j)=>{const D=t(),V=k.map((Y,F)=>!Y.x||!Y.y?{...Y,x:D.x+2*F,y:D.y+2*F}:Y);u(V,j),r()},[t,u,r]),P=f.useCallback((k,j)=>{T([k],j)},[T]),$=f.useCallback(k=>{m(k),p(k)},[m,p]),H=f.useCallback(k=>{const j=s();return k.map(D=>j[D])},[s]),K=f.useCallback(({target:k,clientX:j,clientY:D},{returnLocked:V=!1,passLocked:Y=!1}={})=>{if(["INPUT","TEXTAREA"].includes(k.tagName))return null;const F=Re(k,"item");if(F){if(_e(F,"selected"))return F;if(!Y&&_e(F,"locked")&&!_e(k,"passthrough"))return V?F:null;if(_e(k,"passthrough")){const re=o(),{boardWrapper:ce}=n(),ue=re.reduce((le,Z)=>{const ie=Et(ce,Z),Se=ie.getBoundingClientRect();return ar({x:j,y:D},Se)&&le.unshift(ie),le},[]);for(let le=0;le<ue.length;le+=1){const Z=ue[le];if(Z!==F&&(Y||!_e(Z,"locked")))return Z}return null}}return F},[n,o]);return{putItemsOnTop:h,batchUpdateItems:v,updateItemOrder:I,moveItems:y,placeItems:g,updateItem:w,swapItems:M,reverseItemsOrder:N,setItemList:C,pushItem:P,pushItems:T,removeItems:$,getItemList:d,findElementUnderPointer:K,getItems:H}};var ss=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!e(t[s],r[s]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(s of t.entries())if(!r.has(s[0]))return!1;for(s of t.entries())if(!e(s[1],r.get(s[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(s of t.entries())if(!r.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if(n=t.length,n!=r.length)return!1;for(s=n;s--!==0;)if(t[s]!==r[s])return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r};const os=(e,t)=>{if(e.type in t){const r=t[e.type].defaultActions;return typeof r=="function"?r(e):r}return[]},br=(e,t)=>{const{actions:r=os(e,t)}=e;return r.map(n=>typeof n=="string"?{name:n}:n)},is=()=>{const[e,t]=de(d=>[d.items,d.getItems]),r=ee(d=>d.config.itemTemplates),[n,s]=ye(d=>[d.selection,d.getSelection]),[o,i]=f.useState([]),a=f.useRef(!1);f.useEffect(()=>(a.current=!0,()=>{a.current=!1}),[]);const l=f.useCallback(d=>{const u=t();if(d)return[d,d.map(S=>u[S])];const E=s();return[E,E.map(S=>u[S])]},[t,s]),p=f.useCallback(()=>{const[d,u]=l();if(d.length>0){if(!a.current)return;const E=u.reduce((S,b)=>{const m=br(b,r);return S.filter(v=>m.some(C=>ss(v,C)))},br(u[0],r));i(E)}else i([])},[l,r]);return f.useEffect(()=>{p()},[p,n]),Gn(p,[e,p],300),{availableActions:o}},as=()=>ye(e=>e.selectionBox);let Ee=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");const Sr=f.createContext(),_t=e=>{localStorage.setItem("user",JSON.stringify(e))},cs=()=>{if(localStorage.user){const t={name:"Player",color:lr(),uid:Ee(),...JSON.parse(localStorage.user)};return _t(t),t}const e={name:"Player",color:lr(),uid:Ee()};return _t(e),e},us=e=>(t,r)=>({isSpaceMaster:!1,users:{},getUser:()=>r().users[e],getUsers:()=>r().users,getUserList:()=>Object.values(r().users),getLocalUsers:()=>{if(!r().users[e])return[];const{space:n}=r().users[e];return r().getUserList().filter(({space:s})=>s===n)},addUser:n=>t(s=>({users:{...s.users,[n.id]:n}})),updateUser:(n,s)=>t(o=>{if(!o.users[n])return{};const i={...o.users[n],...s,id:n,uid:o.users[n].uid};return i.id===e&&_t(i),setTimeout(()=>r().electSpaceMaster(),100),{users:{...o.users,[n]:i}}}),removeUser:n=>t(s=>{const o={...s.users};return delete o[n],setTimeout(()=>r().electSpaceMaster(),100),{users:o}}),updateCurrentUser:n=>r().updateUser(e,n),joinSpace:n=>r().updateUser(e,{space:n,spaceJoinedTimestamp:Date.now()}),electSpaceMaster:()=>{const n=r().getLocalUsers(),s={uid:null,timestamp:Date.now()};Object.values(n).forEach(({spaceJoinedTimestamp:o,id:i})=>{o<s.timestamp&&(s.id=i,s.timestamp=o)}),t({isSpaceMaster:s.id===e})}}),ls=e=>({cursors:{},moveCursor:(t,r)=>e(n=>({cursors:{...n.cursors,[t]:r}})),removeCursor:t=>e(r=>{const n={...r.cursors};return delete n[t],{cursors:n}})}),Cr=({storeName:e,children:t})=>{const{wire:r,isMaster:n}=ze("room"),[s,o]=f.useState(null),[i,a]=f.useState(!1),l=f.useRef(!1);return f.useEffect(()=>{let p=!0;const d=[];if(!s&&!l.current)return l.current=!0,(()=>{const E=He(wt({wire:r,storeName:e,noSync:["updateCurrentUser","joinSpace","isSpaceMaster","electSpaceMaster"]},(...b)=>({...us(r.userId)(...b),...ls(...b)}))),S=E.subscribe(b=>{b.ready&&(S(),p&&o(E))})})(),()=>{p=!1,l.current=!1,d.forEach(E=>E())}},[s,e,r,r.userId]),f.useEffect(()=>{if(s)return s.getState().addUser({...cs(),id:r.userId}),a(!0),()=>{s.getState().removeUser(r.userId)}},[n,s,r]),f.useEffect(()=>{if(s){const p=r.subscribe("userLeave",d=>{s.getState().removeUser(d)});return()=>{p()}}},[n,s,r]),f.useEffect(()=>{n&&s&&s.getState().updateCurrentUser({isMaster:n})},[n,s,r]),i?A(Sr.Provider,{value:s,children:t}):null},we=(e,t)=>{const r=f.useContext(Sr);return qe(r,e,t||Be)},fs=()=>{const[e,t,r,n,s]=we(a=>[a.isSpaceMaster,a.getUser(),a.users,a.updateCurrentUser,a.joinSpace]),o=f.useMemo(()=>Object.values(r),[r]),i=f.useMemo(()=>{const{space:a}=t;return o.filter(({space:l})=>l===a)},[t,o]);return{isSpaceMaster:e,currentUser:t,updateCurrentUser:n,users:o,localUsers:i,joinSpace:s}},ds=()=>{const[e,t,r]=de(s=>[s.boardConfig,s.getBoardConfig,s.setBoardConfig]),n=f.useCallback(s=>{let o=s;typeof s=="object"&&(o=()=>s);const i=t(),a=o(i);r(a)},[t,r]);return[e,n]},ps=()=>ee(e=>e.boardState),ms=()=>{const[e,t,r,n]=de(s=>[s.getSessionInfo,s.setSessionInfo,s.updateSessionInfo,s.session]);return{getSessionInfo:e,setSessionInfo:t,sessionInfo:n,updateSessionInfo:r}},Er=f.createContext(),gs=({user:{name:e,uid:t,color:r},content:n})=>({type:"message",user:{name:e,uid:t,color:r},content:n,uid:Ee(),timestamp:new Date().toISOString()}),hs=(e,t)=>({messages:[],setMessages:r=>e({messages:r.map(n=>({...n,timestamp:Date.parse(n.timestamp)}))}),addMessage:r=>e(n=>({messages:[...n.messages,{...r,timestamp:Date.parse(r.timestamp)}]})),sendMessage:(r,n)=>{const s=gs({user:r,content:n});s&&t().addMessage(s)}}),wr=({storeName:e,children:t,defaultValue:r=[]})=>{const{wire:n}=ze("room"),[s]=f.useState(()=>He(wt({wire:n,storeName:e,defaultValue:r,noSync:["sendMessage"]},(...o)=>({...hs(...o)}))));return A(Er.Provider,{value:s,children:t})},vs=(e,t)=>{const r=f.useContext(Er);return qe(r,e,t||Be)},ys=()=>{},bs=(e=ys)=>{const t=we(i=>i.getUser()),[r,n,s]=vs(i=>[i.messages,i.setMessages,i.sendMessage]);f.useEffect(()=>{e()},[r,e]);const o=f.useCallback(i=>{s(t,i)},[t,s]);return{messages:r,setMessages:n,sendMessage:o}};function xt(){return xt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},xt.apply(this,arguments)}function Ir(e){var t=Object.create(null);return function(r){return t[r]===void 0&&(t[r]=e(r)),t[r]}}var Ss=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,Cs=Ir(function(e){return Ss.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91});function Es(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function ws(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var Is=function(){function e(r){var n=this;this._insertTag=function(s){var o;n.tags.length===0?n.insertionPoint?o=n.insertionPoint.nextSibling:n.prepend?o=n.container.firstChild:o=n.before:o=n.tags[n.tags.length-1].nextSibling,n.container.insertBefore(s,o),n.tags.push(s)},this.isSpeedy=r.speedy===void 0?process.env.NODE_ENV==="production":r.speedy,this.tags=[],this.ctr=0,this.nonce=r.nonce,this.key=r.key,this.container=r.container,this.prepend=r.prepend,this.insertionPoint=r.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(n){n.forEach(this._insertTag)},t.insert=function(n){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(ws(this));var s=this.tags[this.tags.length-1];if(process.env.NODE_ENV!=="production"){var o=n.charCodeAt(0)===64&&n.charCodeAt(1)===105;o&&this._alreadyInsertedOrderInsensitiveRule&&console.error(`You're attempting to insert the following rule:
60
+ `+n+"\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules."),this._alreadyInsertedOrderInsensitiveRule=this._alreadyInsertedOrderInsensitiveRule||!o}if(this.isSpeedy){var i=Es(s);try{i.insertRule(n,i.cssRules.length)}catch(a){process.env.NODE_ENV!=="production"&&!/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(n)&&console.error('There was a problem inserting the following rule: "'+n+'"',a)}}else s.appendChild(document.createTextNode(n));this.ctr++},t.flush=function(){this.tags.forEach(function(n){return n.parentNode&&n.parentNode.removeChild(n)}),this.tags=[],this.ctr=0,process.env.NODE_ENV!=="production"&&(this._alreadyInsertedOrderInsensitiveRule=!1)},e}(),ne="-ms-",rt="-moz-",B="-webkit-",Ot="comm",kt="rule",At="decl",_s="@import",_r="@keyframes",xs=Math.abs,nt=String.fromCharCode,Os=Object.assign;function ks(e,t){return te(e,0)^45?(((t<<2^te(e,0))<<2^te(e,1))<<2^te(e,2))<<2^te(e,3):0}function xr(e){return e.trim()}function As(e,t){return(e=t.exec(e))?e[0]:e}function U(e,t,r){return e.replace(t,r)}function Mt(e,t){return e.indexOf(t)}function te(e,t){return e.charCodeAt(t)|0}function $e(e,t,r){return e.slice(t,r)}function me(e){return e.length}function Tt(e){return e.length}function st(e,t){return t.push(e),e}function Ms(e,t){return e.map(t).join("")}var ot=1,Oe=1,Or=0,oe=0,J=0,ke="";function it(e,t,r,n,s,o,i){return{value:e,root:t,parent:r,type:n,props:s,children:o,line:ot,column:Oe,length:i,return:""}}function We(e,t){return Os(it("",null,null,"",null,null,0),e,{length:-e.length},t)}function Ts(){return J}function Ns(){return J=oe>0?te(ke,--oe):0,Oe--,J===10&&(Oe=1,ot--),J}function ae(){return J=oe<Or?te(ke,oe++):0,Oe++,J===10&&(Oe=1,ot++),J}function ge(){return te(ke,oe)}function at(){return oe}function Ue(e,t){return $e(ke,e,t)}function Xe(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function kr(e){return ot=Oe=1,Or=me(ke=e),oe=0,[]}function Ar(e){return ke="",e}function ct(e){return xr(Ue(oe-1,Nt(e===91?e+2:e===40?e+1:e)))}function Ls(e){for(;(J=ge())&&J<33;)ae();return Xe(e)>2||Xe(J)>3?"":" "}function Ps(e,t){for(;--t&&ae()&&!(J<48||J>102||J>57&&J<65||J>70&&J<97););return Ue(e,at()+(t<6&&ge()==32&&ae()==32))}function Nt(e){for(;ae();)switch(J){case e:return oe;case 34:case 39:e!==34&&e!==39&&Nt(J);break;case 40:e===41&&Nt(e);break;case 92:ae();break}return oe}function js(e,t){for(;ae()&&e+J!==47+10;)if(e+J===42+42&&ge()===47)break;return"/*"+Ue(t,oe-1)+"*"+nt(e===47?e:ae())}function Ds(e){for(;!Xe(ge());)ae();return Ue(e,oe)}function zs(e){return Ar(ut("",null,null,null,[""],e=kr(e),0,[0],e))}function ut(e,t,r,n,s,o,i,a,l){for(var p=0,d=0,u=i,E=0,S=0,b=0,m=1,v=1,C=1,w=0,y="",h=s,x=o,g=n,I=y;v;)switch(b=w,w=ae()){case 40:if(b!=108&&te(I,u-1)==58){Mt(I+=U(ct(w),"&","&\f"),"&\f")!=-1&&(C=-1);break}case 34:case 39:case 91:I+=ct(w);break;case 9:case 10:case 13:case 32:I+=Ls(b);break;case 92:I+=Ps(at()-1,7);continue;case 47:switch(ge()){case 42:case 47:st(Rs(js(ae(),at()),t,r),l);break;default:I+="/"}break;case 123*m:a[p++]=me(I)*C;case 125*m:case 59:case 0:switch(w){case 0:case 125:v=0;case 59+d:S>0&&me(I)-u&&st(S>32?Tr(I+";",n,r,u-1):Tr(U(I," ","")+";",n,r,u-2),l);break;case 59:I+=";";default:if(st(g=Mr(I,t,r,p,d,s,a,y,h=[],x=[],u),o),w===123)if(d===0)ut(I,t,g,g,h,o,u,a,x);else switch(E===99&&te(I,3)===110?100:E){case 100:case 109:case 115:ut(e,g,g,n&&st(Mr(e,g,g,0,0,s,a,y,s,h=[],u),x),s,x,u,a,n?h:x);break;default:ut(I,g,g,g,[""],x,0,a,x)}}p=d=S=0,m=C=1,y=I="",u=i;break;case 58:u=1+me(I),S=b;default:if(m<1){if(w==123)--m;else if(w==125&&m++==0&&Ns()==125)continue}switch(I+=nt(w),w*m){case 38:C=d>0?1:(I+="\f",-1);break;case 44:a[p++]=(me(I)-1)*C,C=1;break;case 64:ge()===45&&(I+=ct(ae())),E=ge(),d=u=me(y=I+=Ds(at())),w++;break;case 45:b===45&&me(I)==2&&(m=0)}}return o}function Mr(e,t,r,n,s,o,i,a,l,p,d){for(var u=s-1,E=s===0?o:[""],S=Tt(E),b=0,m=0,v=0;b<n;++b)for(var C=0,w=$e(e,u+1,u=xs(m=i[b])),y=e;C<S;++C)(y=xr(m>0?E[C]+" "+w:U(w,/&\f/g,E[C])))&&(l[v++]=y);return it(e,t,r,s===0?kt:a,l,p,d)}function Rs(e,t,r){return it(e,t,r,Ot,nt(Ts()),$e(e,2,-2),0)}function Tr(e,t,r,n){return it(e,t,r,At,$e(e,0,n),$e(e,n+1,-1),n)}function Ae(e,t){for(var r="",n=Tt(e),s=0;s<n;s++)r+=t(e[s],s,e,t)||"";return r}function Ys(e,t,r,n){switch(e.type){case _s:case At:return e.return=e.return||e.value;case Ot:return"";case _r:return e.return=e.value+"{"+Ae(e.children,n)+"}";case kt:e.value=e.props.join(",")}return me(r=Ae(e.children,n))?e.return=e.value+"{"+r+"}":""}function Bs(e){var t=Tt(e);return function(r,n,s,o){for(var i="",a=0;a<t;a++)i+=e[a](r,n,s,o)||"";return i}}function $s(e){return function(t){t.root||(t=t.return)&&e(t)}}var Ws=function(t,r,n){for(var s=0,o=0;s=o,o=ge(),s===38&&o===12&&(r[n]=1),!Xe(o);)ae();return Ue(t,oe)},Us=function(t,r){var n=-1,s=44;do switch(Xe(s)){case 0:s===38&&ge()===12&&(r[n]=1),t[n]+=Ws(oe-1,r,n);break;case 2:t[n]+=ct(s);break;case 4:if(s===44){t[++n]=ge()===58?"&\f":"",r[n]=t[n].length;break}default:t[n]+=nt(s)}while(s=ae());return t},Xs=function(t,r){return Ar(Us(kr(t),r))},Nr=new WeakMap,Vs=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var r=t.value,n=t.parent,s=t.column===n.column&&t.line===n.line;n.type!=="rule";)if(n=n.parent,!n)return;if(!(t.props.length===1&&r.charCodeAt(0)!==58&&!Nr.get(n))&&!s){Nr.set(t,!0);for(var o=[],i=Xs(r,o),a=n.props,l=0,p=0;l<i.length;l++)for(var d=0;d<a.length;d++,p++)t.props[p]=o[l]?i[l].replace(/&\f/g,a[d]):a[d]+" "+i[l]}}},Gs=function(t){if(t.type==="decl"){var r=t.value;r.charCodeAt(0)===108&&r.charCodeAt(2)===98&&(t.return="",t.value="")}},Fs="emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason",Zs=function(t){return t.type==="comm"&&t.children.indexOf(Fs)>-1},Hs=function(t){return function(r,n,s){if(!(r.type!=="rule"||t.compat)){var o=r.value.match(/(:first|:nth|:nth-last)-child/g);if(o){for(var i=r.parent===s[0],a=i?s[0].children:s,l=a.length-1;l>=0;l--){var p=a[l];if(p.line<r.line)break;if(p.column<r.column){if(Zs(p))return;break}}o.forEach(function(d){console.error('The pseudo class "'+d+'" is potentially unsafe when doing server-side rendering. Try changing it to "'+d.split("-child")[0]+'-of-type".')})}}}},Lr=function(t){return t.type.charCodeAt(1)===105&&t.type.charCodeAt(0)===64},Ks=function(t,r){for(var n=t-1;n>=0;n--)if(!Lr(r[n]))return!0;return!1},Pr=function(t){t.type="",t.value="",t.return="",t.children="",t.props=""},qs=function(t,r,n){Lr(t)&&(t.parent?(console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."),Pr(t)):Ks(r,n)&&(console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."),Pr(t)))};function jr(e,t){switch(ks(e,t)){case 5103:return B+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return B+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return B+e+rt+e+ne+e+e;case 6828:case 4268:return B+e+ne+e+e;case 6165:return B+e+ne+"flex-"+e+e;case 5187:return B+e+U(e,/(\w+).+(:[^]+)/,B+"box-$1$2"+ne+"flex-$1$2")+e;case 5443:return B+e+ne+"flex-item-"+U(e,/flex-|-self/,"")+e;case 4675:return B+e+ne+"flex-line-pack"+U(e,/align-content|flex-|-self/,"")+e;case 5548:return B+e+ne+U(e,"shrink","negative")+e;case 5292:return B+e+ne+U(e,"basis","preferred-size")+e;case 6060:return B+"box-"+U(e,"-grow","")+B+e+ne+U(e,"grow","positive")+e;case 4554:return B+U(e,/([^-])(transform)/g,"$1"+B+"$2")+e;case 6187:return U(U(U(e,/(zoom-|grab)/,B+"$1"),/(image-set)/,B+"$1"),e,"")+e;case 5495:case 3959:return U(e,/(image-set\([^]*)/,B+"$1$`$1");case 4968:return U(U(e,/(.+:)(flex-)?(.*)/,B+"box-pack:$3"+ne+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+B+e+e;case 4095:case 3583:case 4068:case 2532:return U(e,/(.+)-inline(.+)/,B+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(me(e)-1-t>6)switch(te(e,t+1)){case 109:if(te(e,t+4)!==45)break;case 102:return U(e,/(.+:)(.+)-([^]+)/,"$1"+B+"$2-$3$1"+rt+(te(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~Mt(e,"stretch")?jr(U(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(te(e,t+1)!==115)break;case 6444:switch(te(e,me(e)-3-(~Mt(e,"!important")&&10))){case 107:return U(e,":",":"+B)+e;case 101:return U(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+B+(te(e,14)===45?"inline-":"")+"box$3$1"+B+"$2$3$1"+ne+"$2box$3")+e}break;case 5936:switch(te(e,t+11)){case 114:return B+e+ne+U(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return B+e+ne+U(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return B+e+ne+U(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return B+e+ne+e+e}return e}var Js=function(t,r,n,s){if(t.length>-1&&!t.return)switch(t.type){case At:t.return=jr(t.value,t.length);break;case _r:return Ae([We(t,{value:U(t.value,"@","@"+B)})],s);case kt:if(t.length)return Ms(t.props,function(o){switch(As(o,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return Ae([We(t,{props:[U(o,/:(read-\w+)/,":"+rt+"$1")]})],s);case"::placeholder":return Ae([We(t,{props:[U(o,/:(plac\w+)/,":"+B+"input-$1")]}),We(t,{props:[U(o,/:(plac\w+)/,":"+rt+"$1")]}),We(t,{props:[U(o,/:(plac\w+)/,ne+"input-$1")]})],s)}return""})}},Qs=[Js],eo=function(t){var r=t.key;if(process.env.NODE_ENV!=="production"&&!r)throw new Error(`You have to configure \`key\` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.
61
+ If multiple caches share the same key they might "fight" for each other's style elements.`);if(r==="css"){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,function(m){var v=m.getAttribute("data-emotion");v.indexOf(" ")!==-1&&(document.head.appendChild(m),m.setAttribute("data-s",""))})}var s=t.stylisPlugins||Qs;if(process.env.NODE_ENV!=="production"&&/[^a-z-]/.test(r))throw new Error('Emotion key must only contain lower case alphabetical characters and - but "'+r+'" was passed');var o={},i,a=[];i=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),function(m){for(var v=m.getAttribute("data-emotion").split(" "),C=1;C<v.length;C++)o[v[C]]=!0;a.push(m)});var l,p=[Vs,Gs];process.env.NODE_ENV!=="production"&&p.push(Hs({get compat(){return b.compat}}),qs);{var d,u=[Ys,process.env.NODE_ENV!=="production"?function(m){m.root||(m.return?d.insert(m.return):m.value&&m.type!==Ot&&d.insert(m.value+"{}"))}:$s(function(m){d.insert(m)})],E=Bs(p.concat(s,u)),S=function(v){return Ae(zs(v),E)};l=function(v,C,w,y){d=w,process.env.NODE_ENV!=="production"&&C.map!==void 0&&(d={insert:function(x){w.insert(x+C.map)}}),S(v?v+"{"+C.styles+"}":C.styles),y&&(b.inserted[C.name]=!0)}}var b={key:r,sheet:new Is({key:r,container:i,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:o,registered:{},insert:l};return b.sheet.hydrate(a),b},to=!0;function Dr(e,t,r){var n="";return r.split(" ").forEach(function(s){e[s]!==void 0?t.push(e[s]+";"):n+=s+" "}),n}var Lt=function(t,r,n){var s=t.key+"-"+r.name;(n===!1||to===!1)&&t.registered[s]===void 0&&(t.registered[s]=r.styles)},zr=function(t,r,n){Lt(t,r,n);var s=t.key+"-"+r.name;if(t.inserted[r.name]===void 0){var o=r;do t.insert(r===o?"."+s:"",o,t.sheet,!0),o=o.next;while(o!==void 0)}};function ro(e){for(var t=0,r,n=0,s=e.length;s>=4;++n,s-=4)r=e.charCodeAt(n)&255|(e.charCodeAt(++n)&255)<<8|(e.charCodeAt(++n)&255)<<16|(e.charCodeAt(++n)&255)<<24,r=(r&65535)*1540483477+((r>>>16)*59797<<16),r^=r>>>24,t=(r&65535)*1540483477+((r>>>16)*59797<<16)^(t&65535)*1540483477+((t>>>16)*59797<<16);switch(s){case 3:t^=(e.charCodeAt(n+2)&255)<<16;case 2:t^=(e.charCodeAt(n+1)&255)<<8;case 1:t^=e.charCodeAt(n)&255,t=(t&65535)*1540483477+((t>>>16)*59797<<16)}return t^=t>>>13,t=(t&65535)*1540483477+((t>>>16)*59797<<16),((t^t>>>15)>>>0).toString(36)}var no={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Rr=`You have illegal escape sequence in your template literal, most likely inside content's property value.
62
+ Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example "content: '\\00d7';" should become "content: '\\\\00d7';".
63
+ You can read more about this here:
64
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences`,so="You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key).",oo=/[A-Z]|^ms/g,Yr=/_EMO_([^_]+?)_([^]*?)_EMO_/g,Pt=function(t){return t.charCodeAt(1)===45},Br=function(t){return t!=null&&typeof t!="boolean"},jt=Ir(function(e){return Pt(e)?e:e.replace(oo,"-$&").toLowerCase()}),lt=function(t,r){switch(t){case"animation":case"animationName":if(typeof r=="string")return r.replace(Yr,function(n,s,o){return pe={name:s,styles:o,next:pe},s})}return no[t]!==1&&!Pt(t)&&typeof r=="number"&&r!==0?r+"px":r};if(process.env.NODE_ENV!=="production"){var io=/(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/,ao=["normal","none","initial","inherit","unset"],co=lt,uo=/^-ms-/,lo=/-(.)/g,$r={};lt=function(t,r){if(t==="content"&&(typeof r!="string"||ao.indexOf(r)===-1&&!io.test(r)&&(r.charAt(0)!==r.charAt(r.length-1)||r.charAt(0)!=='"'&&r.charAt(0)!=="'")))throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\""+r+"\"'`");var n=co(t,r);return n!==""&&!Pt(t)&&t.indexOf("-")!==-1&&$r[t]===void 0&&($r[t]=!0,console.error("Using kebab-case for css properties in objects is not supported. Did you mean "+t.replace(uo,"ms-").replace(lo,function(s,o){return o.toUpperCase()})+"?")),n}}var Wr="Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform.";function Ve(e,t,r){if(r==null)return"";if(r.__emotion_styles!==void 0){if(process.env.NODE_ENV!=="production"&&r.toString()==="NO_COMPONENT_SELECTOR")throw new Error(Wr);return r}switch(typeof r){case"boolean":return"";case"object":{if(r.anim===1)return pe={name:r.name,styles:r.styles,next:pe},r.name;if(r.styles!==void 0){var n=r.next;if(n!==void 0)for(;n!==void 0;)pe={name:n.name,styles:n.styles,next:pe},n=n.next;var s=r.styles+";";return process.env.NODE_ENV!=="production"&&r.map!==void 0&&(s+=r.map),s}return fo(e,t,r)}case"function":{if(e!==void 0){var o=pe,i=r(e);return pe=o,Ve(e,t,i)}else process.env.NODE_ENV!=="production"&&console.error("Functions that are interpolated in css calls will be stringified.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`");break}case"string":if(process.env.NODE_ENV!=="production"){var a=[],l=r.replace(Yr,function(d,u,E){var S="animation"+a.length;return a.push("const "+S+" = keyframes`"+E.replace(/^@keyframes animation-\w+/,"")+"`"),"${"+S+"}"});a.length&&console.error("`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\nInstead of doing this:\n\n"+[].concat(a,["`"+l+"`"]).join(`
65
+ `)+`
66
+
67
+ You should wrap it with \`css\` like this:
68
+
69
+ `+("css`"+l+"`"))}break}if(t==null)return r;var p=t[r];return p!==void 0?p:r}function fo(e,t,r){var n="";if(Array.isArray(r))for(var s=0;s<r.length;s++)n+=Ve(e,t,r[s])+";";else for(var o in r){var i=r[o];if(typeof i!="object")t!=null&&t[i]!==void 0?n+=o+"{"+t[i]+"}":Br(i)&&(n+=jt(o)+":"+lt(o,i)+";");else{if(o==="NO_COMPONENT_SELECTOR"&&process.env.NODE_ENV!=="production")throw new Error(Wr);if(Array.isArray(i)&&typeof i[0]=="string"&&(t==null||t[i[0]]===void 0))for(var a=0;a<i.length;a++)Br(i[a])&&(n+=jt(o)+":"+lt(o,i[a])+";");else{var l=Ve(e,t,i);switch(o){case"animation":case"animationName":{n+=jt(o)+":"+l+";";break}default:process.env.NODE_ENV!=="production"&&o==="undefined"&&console.error(so),n+=o+"{"+l+"}"}}}}return n}var Ur=/label:\s*([^\s;\n{]+)\s*(;|$)/g,Xr;process.env.NODE_ENV!=="production"&&(Xr=/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g);var pe,Dt=function(t,r,n){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var s=!0,o="";pe=void 0;var i=t[0];i==null||i.raw===void 0?(s=!1,o+=Ve(n,r,i)):(process.env.NODE_ENV!=="production"&&i[0]===void 0&&console.error(Rr),o+=i[0]);for(var a=1;a<t.length;a++)o+=Ve(n,r,t[a]),s&&(process.env.NODE_ENV!=="production"&&i[a]===void 0&&console.error(Rr),o+=i[a]);var l;process.env.NODE_ENV!=="production"&&(o=o.replace(Xr,function(E){return l=E,""})),Ur.lastIndex=0;for(var p="",d;(d=Ur.exec(o))!==null;)p+="-"+d[1];var u=ro(o)+p;return process.env.NODE_ENV!=="production"?{name:u,styles:o,map:l,next:pe,toString:function(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}}:{name:u,styles:o,next:pe}},po=function(t){return t()},mo=Ft["useInsertionEffect"]?Ft["useInsertionEffect"]:!1,Vr=mo||po,go={}.hasOwnProperty,zt=f.createContext(typeof HTMLElement<"u"?eo({key:"css"}):null);process.env.NODE_ENV!=="production"&&(zt.displayName="EmotionCacheContext"),zt.Provider;var Gr=function(t){return f.forwardRef(function(r,n){var s=f.useContext(zt);return t(r,s,n)})},Rt=f.createContext({});process.env.NODE_ENV!=="production"&&(Rt.displayName="EmotionThemeContext");var Fr="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",Zr="__EMOTION_LABEL_PLEASE_DO_NOT_USE__",ho=function(t){var r=t.cache,n=t.serialized,s=t.isStringTag;return Lt(r,n,s),Vr(function(){return zr(r,n,s)}),null},vo=Gr(function(e,t,r){var n=e.css;typeof n=="string"&&t.registered[n]!==void 0&&(n=t.registered[n]);var s=e[Fr],o=[n],i="";typeof e.className=="string"?i=Dr(t.registered,o,e.className):e.className!=null&&(i=e.className+" ");var a=Dt(o,void 0,f.useContext(Rt));if(process.env.NODE_ENV!=="production"&&a.name.indexOf("-")===-1){var l=e[Zr];l&&(a=Dt([a,"label:"+l+";"]))}i+=t.key+"-"+a.name;var p={};for(var d in e)go.call(e,d)&&d!=="css"&&d!==Fr&&(process.env.NODE_ENV==="production"||d!==Zr)&&(p[d]=e[d]);return p.ref=r,p.className=i,f.createElement(f.Fragment,null,f.createElement(ho,{cache:t,serialized:a,isStringTag:typeof s=="string"}),f.createElement(s,p))});process.env.NODE_ENV!=="production"&&(vo.displayName="EmotionCssPropInternal");var yo=Cs,bo=function(t){return t!=="theme"},Hr=function(t){return typeof t=="string"&&t.charCodeAt(0)>96?yo:bo},Kr=function(t,r,n){var s;if(r){var o=r.shouldForwardProp;s=t.__emotion_forwardProp&&o?function(i){return t.__emotion_forwardProp(i)&&o(i)}:o}return typeof s!="function"&&n&&(s=t.__emotion_forwardProp),s},qr=`You have illegal escape sequence in your template literal, most likely inside content's property value.
70
+ Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example "content: '\\00d7';" should become "content: '\\\\00d7';".
71
+ You can read more about this here:
72
+ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences`,So=function(t){var r=t.cache,n=t.serialized,s=t.isStringTag;return Lt(r,n,s),Vr(function(){return zr(r,n,s)}),null},Co=function e(t,r){if(process.env.NODE_ENV!=="production"&&t===void 0)throw new Error(`You are trying to create a styled element with an undefined component.
73
+ You may have forgotten to import it.`);var n=t.__emotion_real===t,s=n&&t.__emotion_base||t,o,i;r!==void 0&&(o=r.label,i=r.target);var a=Kr(t,r,n),l=a||Hr(s),p=!l("as");return function(){var d=arguments,u=n&&t.__emotion_styles!==void 0?t.__emotion_styles.slice(0):[];if(o!==void 0&&u.push("label:"+o+";"),d[0]==null||d[0].raw===void 0)u.push.apply(u,d);else{process.env.NODE_ENV!=="production"&&d[0][0]===void 0&&console.error(qr),u.push(d[0][0]);for(var E=d.length,S=1;S<E;S++)process.env.NODE_ENV!=="production"&&d[0][S]===void 0&&console.error(qr),u.push(d[S],d[0][S])}var b=Gr(function(m,v,C){var w=p&&m.as||s,y="",h=[],x=m;if(m.theme==null){x={};for(var g in m)x[g]=m[g];x.theme=f.useContext(Rt)}typeof m.className=="string"?y=Dr(v.registered,h,m.className):m.className!=null&&(y=m.className+" ");var I=Dt(u.concat(h),v.registered,x);y+=v.key+"-"+I.name,i!==void 0&&(y+=" "+i);var N=p&&a===void 0?Hr(w):l,M={};for(var T in m)p&&T==="as"||N(T)&&(M[T]=m[T]);return M.className=y,M.ref=C,f.createElement(f.Fragment,null,f.createElement(So,{cache:v,serialized:I,isStringTag:typeof w=="string"}),f.createElement(w,M))});return b.displayName=o!==void 0?o:"Styled("+(typeof s=="string"?s:s.displayName||s.name||"Component")+")",b.defaultProps=t.defaultProps,b.__emotion_real=b,b.__emotion_base=s,b.__emotion_styles=u,b.__emotion_forwardProp=a,Object.defineProperty(b,"toString",{value:function(){return i===void 0&&process.env.NODE_ENV!=="production"?"NO_COMPONENT_SELECTOR":"."+i}}),b.withComponent=function(m,v){return e(m,xt({},r,v,{shouldForwardProp:Kr(b,v,!0)})).apply(void 0,u)},b}},Eo=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],Me=Co.bind();Eo.forEach(function(e){Me[e]=Me(e)});const wo=Me.div`
74
+ overflow: hidden;
75
+ position: absolute;
76
+ inset: 0;
77
+ `,Jr=({children:e,session:t,style:r})=>{const n=f.useRef(null),s=we(a=>a.joinSpace),[o,i]=ee(a=>[a.config.uid,a.updateConfiguration]);return f.useEffect(()=>{const a=l=>{Re(l.target,"board")&&l.preventDefault()};return document.body.addEventListener("wheel",a,{passive:!1}),()=>{document.body.removeEventListener("wheel",a)}},[]),f.useEffect(()=>(s(t),()=>{s(null)}),[s,t]),f.useEffect(()=>{o||i({uid:Ee()})},[o,i]),f.useEffect(()=>{i({boardWrapper:n.current})},[i]),Hn(n,()=>{n.current&&i({boardWrapperRect:n.current.getBoundingClientRect()})}),A(wo,{ref:n,id:o,className:"sync-board",style:r,children:e})},Io=({socket:e,room:t,session:r,items:n=[],messages:s=[],LoadingComponent:o,...i})=>{const[a]=f.useState(t||Ee()),[l]=f.useState(r||Ee()),[p]=f.useState(()=>({itemIds:n.map(({id:u})=>u),items:Object.fromEntries(n.map(u=>[u.id,u]))}));return ze("room")?A(wr,{storeName:`${l}_messages`,defaultValue:s,children:A(dr,{storeName:`${l}_item`,defaultValue:p,children:A(Jr,{...i,session:l})})}):A(qt,{room:a,channel:"room",socket:e,LoadingComponent:o,children:A(Cr,{storeName:`${a}_users`,children:A(wr,{storeName:`${l}_messages`,defaultValue:s,children:A(dr,{storeName:`${l}_item`,defaultValue:p,children:A(Jr,{...i,session:l})})})})})},_o=({socket:e,room:t,children:r,LoadingComponent:n})=>{const[s]=f.useState(t||Ee());return A(qt,{room:s,channel:"room",socket:e,LoadingComponent:n,children:A(Cr,{storeName:`${s}_users`,children:r})})},Yt=()=>{const e=navigator.userAgent.toLowerCase();return/mac os ?x 10/.test(e)},xo=(()=>{const e=document.createElement("iframe");e.src="#",document.body.appendChild(e);const t=e.contentWindow.document;t.open(),t.write("<!DOCTYPE html><html><head></head><body><span>a</span></body></html>"),t.close();const r=t.body.firstElementChild.offsetHeight;return document.body.removeChild(e),r})(),Oo=800,Qr=(e,t)=>{const r=Object.keys(e).map(n=>Number(n)).find(n=>n!==t);return e[r]},en=([e,t],[r,n])=>{const s=Math.abs(e-r),o=Math.abs(t-n);return Math.hypot(s,o)},Ie=()=>{},ko=e=>t=>{const{event:r}=t;return r.isPropagationStopped()?null:e(t)},Ao=e=>async(...t)=>{try{await e(...t)}catch(r){console.error(r)}};class Mo{constructor(){bn(this,"lastPromise",Promise.resolve(!0))}add(t,...r){return new Promise((n,s)=>{this.lastPromise=this.lastPromise.then(()=>ko(Ao(t))(...r)).then(n).catch(s)})}}const he=new Mo,ft=({children:e,onDrag:t=Ie,onDragStart:r=Ie,onDragEnd:n=Ie,onPan:s=Ie,onTap:o=Ie,onLongTap:i=Ie,onDoubleTap:a=Ie,onZoom:l,mainAction:p="drag"})=>{const d=f.useRef(null),u=f.useRef({moving:!1,pointers:{},mainPointer:void 0}),E=f.useCallback(C=>{const{deltaX:w,deltaY:y,clientX:h,clientY:x,deltaMode:g,ctrlKey:I,altKey:N,metaKey:M,target:T}=C;if(!(N||I&&!Yt()))if(Yt()&&!I)he.add(s,{deltaX:-2*w,deltaY:-2*y,button:1,ctrlKey:I,metaKey:M,target:T,event:C});else{if(l===void 0||!y)return;let P=y;switch(g){case 1:P*=xo;break;case 2:P*=Oo;break}Yt()&&(P*=2),he.add(l,{scale:P,clientX:h,clientY:x,event:C})}},[s,l]),S=f.useCallback(C=>{const{target:w,button:y,clientX:h,clientY:x,pointerId:g,altKey:I,ctrlKey:N,metaKey:M,isPrimary:T}=C;if(u.current.pointers[g]={clientX:h,clientY:x},T&&(u.current.mainPointer=void 0),u.current.mainPointer!==void 0){if(u.current.mainPointer!==g)try{const{clientX:P,clientY:$}=Qr(u.current.pointers,g),H=(P+h)/2,K=($+x)/2,k=en([P,$],[h,x]);Object.assign(u.current,{pressed:!0,moving:!1,gestureStart:!1,startX:h,startY:x,prevX:H,prevY:K,startDistance:k,prevDistance:k})}catch(P){console.log("Error while getting other pointer. Ignoring",P),u.current.mainPointer}return}u.current.mainPointer=g,Object.assign(u.current,{pressed:!0,moving:!1,gestureStart:!1,startX:h,startY:x,prevX:h,prevY:x,currentButton:y,pointerDownEvent:C,target:w,timeStart:Date.now(),longTapTimeout:setTimeout(async()=>{u.current.noTap=!0,he.add(i,{clientX:h,clientY:x,altKey:I,ctrlKey:N,metaKey:M,target:w,event:C})},750)});try{w.setPointerCapture(g)}catch(P){console.log("Fail to capture pointer",P)}},[i]),b=f.useCallback(C=>{if(u.current.pressed){const{pointerId:w,clientX:y,clientY:h,altKey:x,ctrlKey:g,metaKey:I,buttons:N,pointerType:M}=C;u.current.pointers[w]={clientX:y,clientY:h},u.current.moving=!0;const T=Object.keys(u.current.pointers).length===2;let P,$,H;if(T){const{clientX:D,clientY:V}=Qr(u.current.pointers,w);P=(D+y)/2,$=(V+h)/2,H=en([D,V],[y,h])}else P=y,$=h;let K=x||g||I||N!==1;p!=="drag"&&(K=!K);const k=M!=="touch"?!K:!T,j=M!=="touch"?K:T;if(k){u.current.gestureStart||(d.current.style.cursor="move",u.current.gestureStart=!0,clearTimeout(u.current.longTapTimeout),he.add(r,{deltaX:0,deltaY:0,startX:u.current.startX,startY:u.current.startY,clientX:u.current.startX,clientY:u.current.startY,distanceX:0,distanceY:0,button:u.current.currentButton,altKey:x,ctrlKey:g,metaKey:I,target:u.current.target,event:u.current.pointerDownEvent}));const D=P-u.current.prevX,V=$-u.current.prevY,Y=P-u.current.startX,F=$-u.current.startY;he.add(t,{deltaX:D,deltaY:V,startX:u.current.startX,startY:u.current.startY,clientX:P,clientY:$,distanceX:Y,distanceY:F,button:u.current.currentButton,altKey:x,ctrlKey:g,metaKey:I,target:u.current.target,event:C})}if(j){u.current.gestureStart||(d.current.style.cursor="move",u.current.gestureStart=!0,clearTimeout(u.current.longTapTimeout));const D=P-u.current.prevX,V=$-u.current.prevY,{target:Y}=u.current;if(he.add(s,{deltaX:D,deltaY:V,button:u.current.currentButton,altKey:x,ctrlKey:g,metaKey:I,target:Y,event:C}),H!==u.current.prevDistance&&l){const F=u.current.prevDistance-H;Math.abs(F)>0&&(he.add(l,{scale:F*3,clientX:P,clientY:$,event:C}),u.current.prevDistance=H)}}u.current.prevX=P,u.current.prevY=$}},[p,t,r,s,l]),m=f.useCallback(C=>{const{clientX:w,clientY:y,altKey:h,ctrlKey:x,metaKey:g,target:I,pointerId:N}=C;if(u.current.pointers[N]&&(delete u.current.pointers[N],u.current.mainPointer===N)){for(;Object.keys(u.current.pointers).length>0;){u.current.mainPointer=Number(Object.keys(u.current.pointers)[0]);try{u.current.target.setPointerCapture(u.current.mainPointer);return}catch(M){console.log("Fails to set pointer capture",M),u.current.mainPointer=void 0,delete u.current.pointers[Object.keys(u.current.pointers)[0]]}}if(u.current.mainPointer=void 0,u.current.pressed=!1,clearTimeout(u.current.longTapTimeout),u.current.moving)u.current.moving=!1,he.add(n,{deltaX:w-u.current.prevX,deltaY:y-u.current.prevY,startX:u.current.startX,startY:u.current.startY,clientX:w,clientY:y,distanceX:w-u.current.startX,distanceY:y-u.current.startY,button:u.current.currentButton,altKey:h,ctrlKey:x,metaKey:g,event:C}),d.current.style.cursor="auto";else{const M=Date.now();u.current.noTap?u.current.noTap=!1:u.current.timeStart-M<300&&he.add(o,{clientX:w,clientY:y,altKey:h,ctrlKey:x,metaKey:g,target:I,event:C})}}},[n,o]),v=f.useCallback(C=>{const{clientX:w,clientY:y,altKey:h,ctrlKey:x,metaKey:g,target:I}=C;he.add(a,{clientX:w,clientY:y,altKey:h,ctrlKey:x,metaKey:g,target:I,event:C})},[a]);return A("div",{onWheel:E,onPointerDown:S,onPointerMove:b,onPointerUp:m,onPointerOut:m,onPointerLeave:m,onPointerCancel:m,onDoubleClick:v,style:{touchAction:"none"},ref:d,children:e})},Bt=({onResize:e,...t})=>{const r=ee(s=>s.getBoardState),n=f.useCallback(async({deltaX:s,deltaY:o,event:i})=>{i.stopPropagation();const{scale:a}=r();e({width:s/a,height:o/a})},[r,e]);return A(ft,{onDrag:n,children:A("div",{...t})})},To="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmVyc2lvbj0iMS4xIgogICB4PSIwcHgiCiAgIHk9IjBweCIKICAgdmlld0JveD0iMCAwIDc1LjYwMTMxOCA5NC45IgogICB4bWw6c3BhY2U9InByZXNlcnZlIgogICBpZD0ic3ZnMjYiCiAgIHNvZGlwb2RpOmRvY25hbWU9ImxvY2suc3ZnIgogICB3aWR0aD0iNzUuNjAxMzE4IgogICBoZWlnaHQ9Ijk0LjkwMDAwMiIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC45Mi41ICgyMDYwZWMxZjlmLCAyMDIwLTA0LTA4KSI+PG1ldGFkYXRhCiAgICAgaWQ9Im1ldGFkYXRhMzIiPjxyZGY6UkRGPjxjYzpXb3JrCiAgICAgICAgIHJkZjphYm91dD0iIj48ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD48ZGM6dHlwZQogICAgICAgICAgIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiIC8+PGRjOnRpdGxlPjwvZGM6dGl0bGU+PC9jYzpXb3JrPjwvcmRmOlJERj48L21ldGFkYXRhPjxkZWZzCiAgICAgaWQ9ImRlZnMzMCIgLz48c29kaXBvZGk6bmFtZWR2aWV3CiAgICAgcGFnZWNvbG9yPSIjMDAwMDAwIgogICAgIGJvcmRlcmNvbG9yPSIjNjY2NjY2IgogICAgIGJvcmRlcm9wYWNpdHk9IjEiCiAgICAgb2JqZWN0dG9sZXJhbmNlPSIxMCIKICAgICBncmlkdG9sZXJhbmNlPSIxMCIKICAgICBndWlkZXRvbGVyYW5jZT0iMTAiCiAgICAgaW5rc2NhcGU6cGFnZW9wYWNpdHk9IjAiCiAgICAgaW5rc2NhcGU6cGFnZXNoYWRvdz0iMiIKICAgICBpbmtzY2FwZTp3aW5kb3ctd2lkdGg9IjE4NDgiCiAgICAgaW5rc2NhcGU6d2luZG93LWhlaWdodD0iMTAxNiIKICAgICBpZD0ibmFtZWR2aWV3MjgiCiAgICAgc2hvd2dyaWQ9ImZhbHNlIgogICAgIGZpdC1tYXJnaW4tdG9wPSIwIgogICAgIGZpdC1tYXJnaW4tbGVmdD0iMCIKICAgICBmaXQtbWFyZ2luLXJpZ2h0PSIwIgogICAgIGZpdC1tYXJnaW4tYm90dG9tPSIwIgogICAgIGlua3NjYXBlOnpvb209IjUuMzQwMDcwNCIKICAgICBpbmtzY2FwZTpjeD0iMy4yNjQwMDEzIgogICAgIGlua3NjYXBlOmN5PSI0NS4wNzIxNTIiCiAgICAgaW5rc2NhcGU6d2luZG93LXg9IjE1MTIiCiAgICAgaW5rc2NhcGU6d2luZG93LXk9IjI3IgogICAgIGlua3NjYXBlOndpbmRvdy1tYXhpbWl6ZWQ9IjEiCiAgICAgaW5rc2NhcGU6Y3VycmVudC1sYXllcj0iZzE2IiAvPjxnCiAgICAgaWQ9ImcxNiIKICAgICB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTIuMiwtMi41KSI+PHBhdGgKICAgICAgIGQ9Ik0gNzUuNCwzNi44IEggMzQuMSBWIDI0LjYgYyAwLC04LjggNy4xLC0xNS45IDE1LjksLTE1LjkgOC44LDAgMTUuOSw3LjEgMTUuOSwxNS45IDAsMS43IDEuNCwzLjEgMy4xLDMuMSAxLjcsMCAzLjEsLTEuNCAzLjEsLTMuMSBDIDcyLjEsMTIuNCA2Mi4yLDIuNSA1MCwyLjUgMzcuOCwyLjUgMjcuOSwxMi40IDI3LjksMjQuNiB2IDEyLjIgaCAtMy4zIGMgLTYuOSwwIC0xMi40LDUuNiAtMTIuNCwxMi40IFYgODUgYyAwLDYuOSA1LjYsMTIuNCAxMi40LDEyLjQgaCA1MC44IGMgNi45LDAgMTIuNCwtNS42IDEyLjQsLTEyLjQgViA0OS4yIEMgODcuOSw0Mi4zIDgyLjMsMzYuOCA3NS40LDM2LjggWiBtIDYuMiw0OC4zIGMgMCwzLjQgLTIuOCw2LjIgLTYuMiw2LjIgSCAyNC42IGMgLTMuNCwwIC02LjIsLTIuOCAtNi4yLC02LjIgViA0OS4yIGMgMCwtMy40IDIuOCwtNi4yIDYuMiwtNi4yIGggNTAuOCBjIDMuNCwwIDYuMiwyLjggNi4yLDYuMiB6IgogICAgICAgaWQ9InBhdGgxMiIKICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICBzdHlsZT0iZmlsbDojZmZmZmZmO2ZpbGwtb3BhY2l0eToxIiAvPjxwYXRoCiAgICAgICBkPSJtIDU5LjgsNTcuNiAtMTIuNSwxMi41IC03LC03IGMgLTEuMiwtMS4yIC0zLjIsLTEuMiAtNC40LDAgLTEuMiwxLjIgLTEuMiwzLjIgMCw0LjQgbCA5LjIsOS4yIGMgMC42LDAuNiAxLjQsMC45IDIuMiwwLjkgMC44LDAgMS42LC0wLjMgMi4yLC0wLjkgTCA2NC4yLDYyIGMgMS4yLC0xLjIgMS4yLC0zLjIgMCwtNC40IC0xLjIsLTEuMiAtMy4yLC0xLjIgLTQuNCwwIHoiCiAgICAgICBpZD0icGF0aDE0IgogICAgICAgaW5rc2NhcGU6Y29ubmVjdG9yLWN1cnZhdHVyZT0iMCIKICAgICAgIHN0eWxlPSJmaWxsOiNmZmZmZmY7ZmlsbC1vcGFjaXR5OjEiIC8+PC9nPjwvc3ZnPg==",No=Me.div`
78
+ display: inline-block;
79
+ transition: transform 150ms;
80
+ user-select: none;
81
+ padding: 2px;
82
+ box-sizing: border-box;
83
+ transform: rotate(${({rotation:e})=>e}deg);
84
+
85
+ & .corner {
86
+ position: absolute;
87
+ width: 0px;
88
+ height: 0px;
89
+ }
90
+
91
+ & .top-left {
92
+ top: 0;
93
+ left: 0;
94
+ }
95
+ & .top-right {
96
+ top: 0;
97
+ right: 0;
98
+ }
99
+ & .bottom-left {
100
+ bottom: 0;
101
+ left: 0;
102
+ }
103
+ & .bottom-right {
104
+ bottom: 0;
105
+ right: 0;
106
+ }
107
+
108
+ & .center {
109
+ position: absolute;
110
+ width: 0px;
111
+ height: 0px;
112
+ top: 50%;
113
+ left: 50%;
114
+ }
115
+
116
+ &.selected {
117
+ border: 2px dashed #db5034;
118
+ padding: 0px;
119
+ cursor: pointer;
120
+ }
121
+
122
+ &.locked::after {
123
+ content: "";
124
+ position: absolute;
125
+ width: 24px;
126
+ height: 30px;
127
+ top: 4px;
128
+ right: 4px;
129
+ opacity: 0.1;
130
+ background-image: url("${To}");
131
+ background-size: cover;
132
+ user-select: none;
133
+ }
134
+
135
+ &.locked:hover::after {
136
+ opacity: 0.3;
137
+ }
138
+
139
+ & .resize {
140
+ position: absolute;
141
+
142
+ width: 10px;
143
+ height: 10px;
144
+ border: 2px solid #db5034;
145
+ background-color: #db5034;
146
+ cursor: move;
147
+
148
+ &.resize-width {
149
+ cursor: ew-resize;
150
+ right: -6px;
151
+ top: calc(50% - 5px);
152
+ }
153
+ &.resize-height {
154
+ cursor: ns-resize;
155
+ bottom: -6px;
156
+ left: calc(50% - 5px);
157
+ }
158
+ &.resize-ratio {
159
+ cursor: nwse-resize;
160
+ bottom: -6px;
161
+ right: -6px;
162
+ }
163
+ }
164
+ `,Lo=e=>e,Po=({onReload:e})=>ve("div",{style:{width:"100px",display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"center",color:"red"},className:"syncboard-error-item",children:["Sorry, this item seems broken.",A("button",{onClick:e,children:"Reload it"})]});class jo extends f.Component{constructor(t){super(t),this.state={hasError:!1,itemId:t.itemId},this.onReload=this.onReload.bind(this)}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.error(`Error for item ${this.state.itemId}`,t,this.props.state)}onReload(){this.setState({hasError:!1})}render(){const{ErrorComponent:t}=this.props;return this.state.hasError?A(t,{onReload:this.onReload}):this.props.children}}const Do=e=>{e.target.className=""},zo=({width:e,height:t,actualWidth:r,actualHeight:n,prevState:s,keepRatio:o})=>{let{width:i,height:a}=s;if([i,a]=[parseFloat(i),parseFloat(a)],(!i||Number.isNaN(Number(i)))&&(i=r),(!a||Number.isNaN(Number(a)))&&(a=n),o){const l=i/a;return{...s,width:(i+e).toFixed(1),height:(a+t/l).toFixed(1)}}return{...s,width:(i+e).toFixed(1),height:(a+t).toFixed(1)}},Ro={w:!0,h:!0,b:!0},Yo=({setState:e,state:{type:t,rotation:r=0,id:n,locked:s,layer:o,...i}={},animate:a="hvr-pop",isSelected:l,itemMap:p,showResizeHandle:d=!1})=>{var x;const u=f.useRef(null),{component:E=()=>null,resizeDirections:S=Ro,resize:b=zo}=p[t],m=f.useCallback((g,I=!0)=>e(n,g,I),[e,n]);f.useEffect(()=>{u.current.className=a},[a]);let v=`item ${n}`;s&&(v+=" locked"),l&&(v+=" selected");const C=f.useCallback(({width:g=0,height:I=0,keepRatio:N})=>{m(M=>{const{offsetWidth:T,offsetHeight:P}=u.current;return b({prevState:M,width:g,height:I,actualHeight:P,actualWidth:T,keepRatio:N})})},[b,m]),w=f.useCallback(({width:g})=>{C({width:g})},[C]),y=f.useCallback(({height:g})=>{C({height:g})},[C]),h=f.useCallback(({width:g})=>{C({height:g,width:g,keepRatio:!0})},[C]);return A(No,{rotation:r,locked:s,selected:l,layer:o,"data-id":n,className:v,children:ve("div",{style:{display:"flex"},ref:u,onAnimationEnd:Do,onKeyDown:g=>g.stopPropagation(),onKeyUp:g=>g.stopPropagation(),children:[A(jo,{itemId:n,state:i,setState:m,ErrorComponent:((x=p==null?void 0:p.error)==null?void 0:x.component)||Po,children:A(E,{...i,id:n,setState:m})}),A("div",{className:"corner top-left"}),A("div",{className:"corner top-right"}),A("div",{className:"corner bottom-right"}),A("div",{className:"corner bottom-left"}),A("div",{className:"center"}),l&&d&&ve(Kt,{children:[S.b&&A(Bt,{className:"resize resize-ratio",onResize:h}),S.h&&A(Bt,{className:"resize resize-height",onResize:y}),S.w&&A(Bt,{className:"resize resize-width",onResize:w})]})]})})},Bo=f.memo(Yo,({state:e,setState:t,isSelected:r,showResizeHandle:n},{state:s,setState:o,isSelected:i,showResizeHandle:a})=>r===i&&n===a&&t===o&&JSON.stringify(e)===JSON.stringify(s)),$o=({state:e={},boardSize:t,currentUser:r,...n})=>{if(!n.itemMap[e.type])return null;const{stateHook:s=Lo}=n.itemMap[e.type],{x:o=0,y:i=0,layer:a=0,moving:l,...p}=s(e,{currentUser:r});return A("div",{style:{position:"absolute",top:`${t/2}px`,left:`${t/2}px`,display:"inline-block",transform:`translate(${o}px, ${i}px)`,zIndex:(a+4)*10+100+(l?5:0)},children:A(Bo,{...n,showResizeHandle:n.isSelected&&n.showResizeHandle,state:p})})},Wo=f.memo($o),Uo=()=>{const{updateItem:e}=tt(),[t,r]=de(l=>[l.itemIds,l.items]),n=ye(l=>l.selection),[s,o,i]=ee(l=>[l.config.boardSize,l.config.showResizeHandle,l.config.itemTemplates]),a=we(l=>l.getUser());return t.map(l=>A(Wo,{state:r[l],setState:e,isSelected:n.includes(l),itemMap:i,boardSize:s,currentUser:a,showResizeHandle:o},l))},Xo={zIndex:210,position:"absolute",backgroundColor:"hsla(0, 40%, 50%, 10%)",border:"2px solid hsl(0, 55%, 40%)"},Vo=(e,t)=>{const r=t.getElementsByClassName("selector");if(!r.length)return[];const n=r[0];return Array.from(t.getElementsByClassName("item")).filter(s=>{const o=Ye(s),i=e[o];return!i||i.locked?!1:Dn(s,n)}).map(s=>Ye(s))},Go=({children:e,moveFirst:t})=>{const[r,n,s,o]=ye(g=>[g.getSelection,g.clear,g.setSelection,g.select]),i=ee(g=>g.getConfiguration),[a,l]=ee(g=>[g.getBoardState,g.updateBoardState]),{findElementUnderPointer:p}=tt(),d=de(g=>g.getItems),[u,E]=f.useState({}),S=f.useRef(null),b=f.useRef({moving:!1});f.useEffect(()=>(n(),()=>{n()}),[n]);const m=f.useCallback(()=>{if(b.current.moving){const g=d(),{boardWrapper:I}=i(),N=Vo(g,I);s(N)}},[i,d,s]),v=gr(()=>{m()},[u,m],50),C=f.useCallback(async g=>{await p(g)||(b.current.moving=!0,l({selection:!0}),S.current.style.cursor="crosshair")},[p,l]),w=f.useCallback(({distanceY:g,distanceX:I,startX:N,startY:M})=>{if(b.current.moving){const{top:T,left:P}=S.current.getBoundingClientRect(),{scale:$}=a(),H=(N-P)/$,K=(M-T)/$,k=I/$,j=g/$;k>0?(b.current.left=H,b.current.width=k):(b.current.left=H+k,b.current.width=-k),j>0?(b.current.top=K,b.current.height=j):(b.current.top=K+j,b.current.height=-j),E({...b.current,moving:!0}),v()}},[a,v]),y=f.useCallback(()=>{b.current.moving&&(l({selecting:!1}),b.current.moving=!1,E({moving:!1}),S.current.style.cursor="auto")},[l]),h=f.useCallback(({target:g})=>{const I=Re(g,"item");if(I){const N=Ye(I);s([N])}},[s]),x=f.useCallback(async g=>{const{target:I,ctrlKey:N,metaKey:M}=g,T=await p(g);if(!T&&Re(I,"board"))n();else{const P=Ye(T);if(!P){n();return}const $=r();T&&!$.includes(P)&&(N||M?o([P]):s([P]))}},[n,p,r,o,s]);return A(ft,{onDragStart:C,onDrag:w,onDragEnd:y,onTap:x,onLongTap:h,mainAction:t?"pan":"drag",children:ve("div",{ref:S,children:[u.moving&&A("div",{style:{...Xo,transform:`translate(${u.left}px, ${u.top}px)`,height:`${u.height}px`,width:`${u.width}px`},className:"selector"}),e]})})},Fo=({children:e})=>{const{moveItems:t,placeItems:r,findElementUnderPointer:n}=tt(),[s,o,i]=ye(v=>[v.select,v.setSelection,v.getSelection]),[a,l]=ee(v=>[v.getBoardState,v.updateBoardState]),p=de(v=>v.getBoardConfig),d=f.useRef({}),u=f.useRef({items:[]}),E=f.useCallback(async v=>{const{ctrlKey:C,metaKey:w,event:y}=v,h=await n(v);if(h){y.stopPropagation();const x=i();u.current.items=x;const g=Ye(h);x.includes(g)||(C||w?(u.current.items=[...x,g],s([g])):(u.current.items=[g],o([g]))),Object.assign(d.current,{moving:!0,remainX:0,remainY:0})}},[n,i,s,o]),S=f.useCallback(({deltaX:v,deltaY:C,event:w})=>{if(d.current.moving){w.stopPropagation();const{scale:y}=a(),h=d.current.remainX+v/y,x=d.current.remainY+C/y;t(u.current.items,{x:h,y:x},!0),l({movingItems:!0})}},[a,t,l]),b=f.useCallback(()=>{if(d.current.moving){const{gridSize:v=1}=p(),C=v||1;d.current={moving:!1},r(u.current.items,{type:"grid",size:C}),l({movingItems:!1})}},[p,r,l]),m=f.useCallback(v=>{if(["INPUT","TEXTAREA"].includes(v.target.tagName))return;const C=i();if(C.length){const{gridSize:w=1}=p();let y=0,h=0;switch(v.key){case"ArrowLeft":y=-10;break;case"ArrowRight":y=10;break;case"ArrowUp":h=-10;break;case"ArrowDown":h=10;break}(y||h)&&(v.shiftKey&&(y*=5,h*=5),(v.ctrlKey||v.altKey||v.metaKey)&&(y/=10,h/=10),t(C,{x:y,y:h},!0),r(C,{type:"grid",size:w||1}),v.preventDefault())}},[p,i,t,r]);return f.useEffect(()=>(document.addEventListener("keydown",m),()=>{document.removeEventListener("keydown",m)}),[m]),A(ft,{onDragStart:E,onDrag:S,onDragEnd:b,children:e})};function tn(e,t,r){return Math.min(Math.max(e,r),t)}class Zo extends Error{constructor(t){super(`Failed to parse color: "${t}"`)}}var Ge=Zo;function Ho(e){if(typeof e!="string")throw new Ge(e);if(e.trim().toLowerCase()==="transparent")return[0,0,0,0];let t=e.trim();t=ni.test(e)?Jo(e):e;const r=Qo.exec(t);if(r){const i=Array.from(r).slice(1);return[...i.slice(0,3).map(a=>parseInt(Fe(a,2),16)),parseInt(Fe(i[3]||"f",2),16)/255]}const n=ei.exec(t);if(n){const i=Array.from(n).slice(1);return[...i.slice(0,3).map(a=>parseInt(a,16)),parseInt(i[3]||"ff",16)/255]}const s=ti.exec(t);if(s){const i=Array.from(s).slice(1);return[...i.slice(0,3).map(a=>parseInt(a,10)),parseFloat(i[3]||"1")]}const o=ri.exec(t);if(o){const[i,a,l,p]=Array.from(o).slice(1).map(parseFloat);if(tn(0,100,a)!==a)throw new Ge(e);if(tn(0,100,l)!==l)throw new Ge(e);return[...si(i,a,l),Number.isNaN(p)?1:p]}throw new Ge(e)}function Ko(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0)%2341}const rn=e=>parseInt(e.replace(/_/g,""),36),qo="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((e,t)=>{const r=rn(t.substring(0,3)),n=rn(t.substring(3)).toString(16);let s="";for(let o=0;o<6-n.length;o++)s+="0";return e[r]=`${s}${n}`,e},{});function Jo(e){const t=e.toLowerCase().trim(),r=qo[Ko(t)];if(!r)throw new Ge(e);return`#${r}`}const Fe=(e,t)=>Array.from(Array(t)).map(()=>e).join(""),Qo=new RegExp(`^#${Fe("([a-f0-9])",3)}([a-f0-9])?$`,"i"),ei=new RegExp(`^#${Fe("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),ti=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Fe(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),ri=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,ni=/^[a-z]+$/i,nn=e=>Math.round(e*255),si=(e,t,r)=>{let n=r/100;if(t===0)return[n,n,n].map(nn);const s=(e%360+360)%360/60,o=(1-Math.abs(2*n-1))*(t/100),i=o*(1-Math.abs(s%2-1));let a=0,l=0,p=0;s>=0&&s<1?(a=o,l=i):s>=1&&s<2?(a=i,l=o):s>=2&&s<3?(l=o,p=i):s>=3&&s<4?(l=i,p=o):s>=4&&s<5?(a=i,p=o):s>=5&&s<6&&(a=o,p=i);const d=n-o/2,u=a+d,E=l+d,S=p+d;return[u,E,S].map(nn)};function oi(e){if(e==="transparent")return 0;function t(o){const i=o/255;return i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)}const[r,n,s]=Ho(e);return .2126*t(r)+.7152*t(n)+.0722*t(s)}function ii(e){return oi(e)>.179}const ai=Me.div`
165
+ display: flex;
166
+ flex-direction: row;
167
+ align-items: center;
168
+ z-index: 210;
169
+ pointer-events: none;
170
+ `,ci=Me.div`
171
+ color: ${({textColor:e})=>e};
172
+ font-weight: bold;
173
+ padding: 0 0.5em;
174
+ border-radius: 2px;
175
+ max-width: 5em;
176
+ overflow: hidden;
177
+ text-overflow: ellipsis;
178
+ margin-left: -0.5em;
179
+ margin-top: 1.7em;
180
+ whitespace: nowrap;
181
+ pointer-events: none;
182
+ background-color: ${({color:e})=>e};
183
+ `,ui=({color:e="#666",size:t=40,text:r})=>{const n=ii(e)?"#222":"#EEE";return ve(ai,{children:[ve("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"1064.7701 445.5539 419.8101 717.0565",width:t,height:t,children:[A("path",{d:"m 1197.1015,869.718 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",style:{fill:n}}),A("path",{d:"m 1193.0939,861.12419 -62.2719,-154.49286 133.3276,-9.05842 -257.6915,-253.12748 1.2392,356.98609 88.2465,-79.47087 61.702,152.78366 z",style:{fill:"white",stroke:"#111",strokeWidth:20}})]}),A(ci,{color:e,textColor:n,children:r})]})},li=f.memo(ui),fi=({pos:e,...t})=>A("div",{style:{transform:`translate(${e.x-5}px, ${e.y-3}px)`,top:0,left:0,zIndex:210,position:"fixed",pointerEvents:"none"},children:A(li,{...t})}),di=()=>{const[e,t,r,n]=we(o=>[o.getUser(),o.getLocalUsers(),o.cursors,o.users]),s=t.reduce((o,i)=>(i.id!==e.id&&r[i.id]&&(o[i.id]=r[i.id]),o),{});return A("div",{children:Object.entries(s).map(([o,i])=>A(fi,{pos:i,text:n[o].name,color:n[o].color},o))})},pi=({children:e})=>{const t=we(l=>l.getUser()),[r,n]=we(l=>[l.moveCursor,l.removeCursor]),[s,o]=ee(l=>[l.getConfiguration,l.getBoardState]),i=f.useCallback(({clientX:l,clientY:p})=>{const{scale:d,translateX:u,translateY:E}=o(),{boardWrapperRect:{left:S,top:b}}=s(),m={x:(l-S-u)/d,y:(p-b-E)/d};r(t.id,m)},[o,s,r,t.id]);return ve("div",{onPointerMove:i,onPointerLeave:()=>{n(t.id)},children:[e,A(di,{})]})},mi=e=>{const t=f.useRef({hover:!1,x:0,y:0}),r=f.useCallback(i=>{const{clientX:a,clientY:l}=i;t.current.x=a,t.current.y=l},[]),n=f.useCallback(()=>{t.current.hover=!0},[]),s=f.useCallback(()=>{t.current.hover=!1},[]);return f.useEffect(()=>{const{current:i}=e;return i?(i.addEventListener("mousemove",r),i.addEventListener("mouseenter",n),i.addEventListener("mouseleave",s),()=>{i.removeEventListener("mousemove",r),i.removeEventListener("mouseenter",n),i.addEventListener("mouseleave",s)}):null},[e,e.current,r,n,s]),f.useCallback(()=>t.current,[])},gi=[...Array(5).keys()].map(e=>`Digit${e+1}`),hi=()=>{const[e,t]=f.useState({}),[r,n]=ee(o=>[o.getBoardState,o.updateBoardState]),s=f.useCallback(o=>{if(!["INPUT","TEXTAREA"].includes(o.target.tagName)&&gi.includes(o.code)){const i=o.code,{translateX:a,translateY:l,scale:p}=r();o.altKey||o.metaKey||o.ctrlKey?t(d=>({...d,[i]:{translateX:a,translateY:l,scale:p}})):e[i]&&n(e[i]),o.preventDefault()}},[r,e,n]);return f.useEffect(()=>(document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}),[s]),null},vi=({children:e,moveFirst:t=!1})=>{const r=f.useRef(null),[n,s,o,i]=ee(h=>[{translateX:h.boardState.translateX,translateY:h.boardState.translateY,scale:h.boardState.scale},h.config.itemExtent,h.getConfiguration,h.updateBoardState]),{setDim:a,zoomToCenter:l,zoomToExtent:p}=et(),[d,u]=f.useState(!1),E=f.useRef({}),S=ye(h=>h.getSelection),b=mi(r);hi();const m=f.useCallback(()=>{const{itemExtent:h}=o();p(h)},[o,p]);f.useEffect(()=>{!d&&s.left&&(m(),u(!0))},[m,d,s]);const v=f.useCallback(({clientX:h,clientY:x,scale:g})=>{l(1-g/500,{x:h,y:x}),clearTimeout(E.current.zoom),E.current.zoom=setTimeout(()=>{i({zooming:!1})},200),i({zooming:!0})},[i,l]),C=f.useCallback(async({deltaX:h,deltaY:x})=>{a(g=>({...g,translateX:g.translateX+h,translateY:g.translateY+x})),clearTimeout(E.current.pan),E.current.pan=setTimeout(()=>{i({panning:!1})},200),i({panning:!0})},[a,i]),w=f.useCallback(h=>{if(["INPUT","TEXTAREA"].includes(h.target.tagName))return;let x=0,g=0,I=1;switch(h.key){case"ArrowLeft":x=-10;break;case"ArrowRight":x=10;break;case"ArrowUp":g=-10;break;case"ArrowDown":g=10;break;case"PageUp":I=1.2;break;case"PageDown":I=.8;break}if(x||g||I!==1){const N=S();if(I===1&&N.length)return;h.shiftKey&&(x*=5,g*=5),(h.ctrlKey||h.altKey||h.metaKey)&&(x/=5,g/=5),a(M=>({...M,translateY:M.translateY+g,translateX:M.translateX+x})),l(I),h.preventDefault()}h.key===" "&&!h.repeat&&b().hover&&l(3,b())},[S,a,l,b]),y=f.useCallback(h=>{["INPUT","TEXTAREA"].includes(h.target.tagName)||h.key===" "&&b().hover&&l(1/3,b())},[b,l]);return f.useEffect(()=>(document.addEventListener("keydown",w),document.addEventListener("keyup",y),()=>{document.removeEventListener("keydown",w),document.removeEventListener("keyup",y)}),[w,y]),A(ft,{onPan:C,onZoom:v,mainAction:t?"pan":"drag",children:A("div",{style:{display:"inline-block",transformOrigin:"top left",transform:`translate(${n.translateX}px, ${n.translateY}px) scale(${n.scale})`},className:`board-pane${n.scale<.5?" board-pane__far":""}`,ref:r,children:e})})},yi={position:"absolute",top:0,left:0,zIndex:210,backgroundColor:"hsla(0, 40%, 50%, 0%)",border:"2px dashed hsl(20, 55%, 40%)",pointerEvents:"none"},bi=()=>{const[e,t,r,n]=ye(u=>[u.selection,u.getSelection,u.selectionBox,u.setSelectionBox]),s=ee(u=>u.getConfiguration),{translateX:o,translateY:i,scale:a}=ee(u=>({translateX:u.boardState.translateX,translateY:u.boardState.translateY,scale:u.boardState.scale})),l=de(u=>u.items),p=f.useCallback(()=>{const u=t(),{boardWrapperRect:E,boardWrapper:S}=s();if(u.length===0){n(null);return}const b=cr(u,S);if(!b){n(null);return}const{left:m,top:v,width:C,height:w}=b,y={left:m-E.left,top:v-E.top,height:w,width:C};n(y)},[s,t,n]),d=It(p,[p],300);return f.useEffect(()=>{p(),d()},[e,l,o,i,a,p,d]),!r||e.length<2?null:A("div",{style:{...yi,transform:`translate(${r.left}px, ${r.top}px)`,height:`${r.height}px`,width:`${r.width}px`},className:"selection"})},Si=()=>ee(t=>t.boardState.movingItems)?null:A(bi,{}),Ci=({moveFirst:e=!0,style:t,itemTemplates:r={},boardSize:n=hr,children:s,showResizeHandle:o=!1})=>{const i=ee(p=>p.updateConfiguration),{updateItemExtent:a}=et(),l=f.useMemo(()=>({userSelect:"none",width:`${n}px`,height:`${n}px`,backgroundColor:"#333",...t}),[n,t]);return f.useEffect(()=>{i({itemTemplates:r,boardSize:n,showResizeHandle:o})},[r,n,o,i]),f.useEffect(()=>{a(),setTimeout(a,2e3)},[a]),ve(Kt,{children:[A(vi,{moveFirst:e,children:A(Go,{moveFirst:e,children:A(Fo,{moveFirst:e,children:A(pi,{children:ve("div",{onContextMenu:p=>{p.preventDefault()},style:l,className:"board",children:[A(Uo,{}),s]})})})})}),A(Si,{})]})};X.Board=Ci,X.BoardWrapper=Io,X.RoomWrapper=_o,X.useAvailableActions=is,X.useBoardConfig=ds,X.useBoardPosition=et,X.useBoardState=ps,X.useDebouncedItems=Kn,X.useItemActions=tt,X.useItemInteraction=yr,X.useItems=Xn,X.useMessage=bs,X.useSelectedItems=Jn,X.useSelectionBox=as,X.useSessionInfo=ms,X.useUsers=fs,X.useWire=ze,Object.defineProperty(X,Symbol.toStringTag,{value:"Module"})});
184
+ //# sourceMappingURL=react-sync-board.umd.cjs.map