react-sync-board 1.2.6 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(U,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(U=typeof globalThis<"u"?globalThis:U||self,d(U["React-sync-board"]={},U.React))})(this,function(U,d){"use strict";var
|
|
1
|
+
(function(U,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(U=typeof globalThis<"u"?globalThis:U||self,d(U["React-sync-board"]={},U.React))})(this,function(U,d){"use strict";var is=Object.defineProperty;var as=(U,d,me)=>d in U?is(U,d,{enumerable:!0,configurable:!0,writable:!0,value:me}):U[d]=me;var ur=(U,d,me)=>(as(U,typeof d!="symbol"?d+"":d,me),me);function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var we={},lr={get exports(){return we},set exports(e){we=e}},Ce={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var gt;function fr(){if(gt)return
|
|
9
|
+
*/var gt;function fr(){if(gt)return Ce;gt=1;var e=d,t=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(u,l,m){var f,c={},h=null,S=null;m!==void 0&&(h=""+m),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(S=l.ref);for(f in l)n.call(l,f)&&!s.hasOwnProperty(f)&&(c[f]=l[f]);if(u&&u.defaultProps)for(f in l=u.defaultProps,l)c[f]===void 0&&(c[f]=l[f]);return{$$typeof:t,type:u,key:h,ref:S,props:c,_owner:o.current}}return Ce.Fragment=r,Ce.jsx=a,Ce.jsxs=a,Ce}var xe={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ht;function dr(){return ht||(ht=1,process.env.NODE_ENV!=="production"&&function(){var e=d,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),c=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),
|
|
18
|
-
`+Se+i}}var ut=!1,Ue;{var
|
|
17
|
+
*/var ht;function dr(){return ht||(ht=1,process.env.NODE_ENV!=="production"&&function(){var e=d,t=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),c=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),S=Symbol.for("react.offscreen"),v=Symbol.iterator,E="@@iterator";function T(i){if(i===null||typeof i!="object")return null;var b=v&&i[v]||i[E];return typeof b=="function"?b:null}var y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function C(i){{for(var b=arguments.length,O=new Array(b>1?b-1:0),R=1;R<b;R++)O[R-1]=arguments[R];x("error",i,O)}}function x(i,b,O){{var R=y.ReactDebugCurrentFrame,N=R.getStackAddendum();N!==""&&(b+="%s",O=O.concat([N]));var V=O.map(function(X){return String(X)});V.unshift("Warning: "+b),Function.prototype.apply.call(console[i],console,V)}}var p=!1,_=!1,g=!1,w=!1,I=!1,P;P=Symbol.for("react.module.reference");function D(i){return!!(typeof i=="string"||typeof i=="function"||i===n||i===s||I||i===o||i===m||i===f||w||i===S||p||_||g||typeof i=="object"&&i!==null&&(i.$$typeof===h||i.$$typeof===c||i.$$typeof===a||i.$$typeof===u||i.$$typeof===l||i.$$typeof===P||i.getModuleId!==void 0))}function j(i,b,O){var R=i.displayName;if(R)return R;var N=b.displayName||b.name||"";return N!==""?O+"("+N+")":O}function A(i){return i.displayName||"Context"}function B(i){if(i==null)return null;if(typeof i.tag=="number"&&C("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case n:return"Fragment";case r:return"Portal";case s:return"Profiler";case o:return"StrictMode";case m:return"Suspense";case f:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case u:var b=i;return A(b)+".Consumer";case a:var O=i;return A(O._context)+".Provider";case l:return j(i,i.render,"ForwardRef");case c:var R=i.displayName||null;return R!==null?R:B(i.type)||"Memo";case h:{var N=i,V=N._payload,X=N._init;try{return B(X(V))}catch{return null}}}return null}var W=Object.assign,Q=0,M,$,Y,F,L,K,q;function re(){}re.__reactDisabledLog=!0;function ee(){{if(Q===0){M=console.log,$=console.info,Y=console.warn,F=console.error,L=console.group,K=console.groupCollapsed,q=console.groupEnd;var i={configurable:!0,enumerable:!0,value:re,writable:!0};Object.defineProperties(console,{info:i,log:i,warn:i,error:i,group:i,groupCollapsed:i,groupEnd:i})}Q++}}function se(){{if(Q--,Q===0){var i={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},i,{value:M}),info:W({},i,{value:$}),warn:W({},i,{value:Y}),error:W({},i,{value:F}),group:W({},i,{value:L}),groupCollapsed:W({},i,{value:K}),groupEnd:W({},i,{value:q})})}Q<0&&C("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var le=y.ReactCurrentDispatcher,Se;function _e(i,b,O){{if(Se===void 0)try{throw Error()}catch(N){var R=N.stack.trim().match(/\n( *(at )?)/);Se=R&&R[1]||""}return`
|
|
18
|
+
`+Se+i}}var ut=!1,Ue;{var Lo=typeof WeakMap=="function"?WeakMap:Map;Ue=new Lo}function qt(i,b){if(!i||ut)return"";{var O=Ue.get(i);if(O!==void 0)return O}var R;ut=!0;var N=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var V;V=le.current,le.current=null,ee();try{if(b){var X=function(){throw Error()};if(Object.defineProperty(X.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(X,[])}catch(fe){R=fe}Reflect.construct(i,[],X)}else{try{X.call()}catch(fe){R=fe}i.call(X.prototype)}}else{try{throw Error()}catch(fe){R=fe}i()}}catch(fe){if(fe&&R&&typeof fe.stack=="string"){for(var z=fe.stack.split(`
|
|
19
19
|
`),te=R.stack.split(`
|
|
20
|
-
`),G=
|
|
21
|
-
`+
|
|
20
|
+
`),G=z.length-1,J=te.length-1;G>=1&&J>=0&&z[G]!==te[J];)J--;for(;G>=1&&J>=0;G--,J--)if(z[G]!==te[J]){if(G!==1||J!==1)do if(G--,J--,J<0||z[G]!==te[J]){var ne=`
|
|
21
|
+
`+z[G].replace(" at new "," at ");return i.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",i.displayName)),typeof i=="function"&&Ue.set(i,ne),ne}while(G>=1&&J>=0);break}}}finally{ut=!1,le.current=V,se(),Error.prepareStackTrace=N}var Ee=i?i.displayName||i.name:"",cr=Ee?_e(Ee):"";return typeof i=="function"&&Ue.set(i,cr),cr}function zo(i,b,O){return qt(i,!1)}function Yo(i){var b=i.prototype;return!!(b&&b.isReactComponent)}function We(i,b,O){if(i==null)return"";if(typeof i=="function")return qt(i,Yo(i));if(typeof i=="string")return _e(i);switch(i){case m:return _e("Suspense");case f:return _e("SuspenseList")}if(typeof i=="object")switch(i.$$typeof){case l:return zo(i.render);case c:return We(i.type,b,O);case h:{var R=i,N=R._payload,V=R._init;try{return We(V(N),b,O)}catch{}}}return""}var Ve=Object.prototype.hasOwnProperty,Gt={},Jt=y.ReactDebugCurrentFrame;function Fe(i){if(i){var b=i._owner,O=We(i.type,i._source,b?b.type:null);Jt.setExtraStackFrame(O)}else Jt.setExtraStackFrame(null)}function Bo(i,b,O,R,N){{var V=Function.call.bind(Ve);for(var X in i)if(V(i,X)){var z=void 0;try{if(typeof i[X]!="function"){var te=Error((R||"React class")+": "+O+" type `"+X+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[X]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw te.name="Invariant Violation",te}z=i[X](b,X,R,O,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(G){z=G}z&&!(z instanceof Error)&&(Fe(N),C("%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).",R||"React class",O,X,typeof z),Fe(null)),z instanceof Error&&!(z.message in Gt)&&(Gt[z.message]=!0,Fe(N),C("Failed %s type: %s",O,z.message),Fe(null))}}}var Xo=Array.isArray;function lt(i){return Xo(i)}function No(i){{var b=typeof Symbol=="function"&&Symbol.toStringTag,O=b&&i[Symbol.toStringTag]||i.constructor.name||"Object";return O}}function Uo(i){try{return Zt(i),!1}catch{return!0}}function Zt(i){return""+i}function Qt(i){if(Uo(i))return C("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",No(i)),Zt(i)}var je=y.ReactCurrentOwner,Wo={key:!0,ref:!0,__self:!0,__source:!0},er,tr,ft;ft={};function Vo(i){if(Ve.call(i,"ref")){var b=Object.getOwnPropertyDescriptor(i,"ref").get;if(b&&b.isReactWarning)return!1}return i.ref!==void 0}function Fo(i){if(Ve.call(i,"key")){var b=Object.getOwnPropertyDescriptor(i,"key").get;if(b&&b.isReactWarning)return!1}return i.key!==void 0}function Ko(i,b){if(typeof i.ref=="string"&&je.current&&b&&je.current.stateNode!==b){var O=B(je.current.type);ft[O]||(C('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',B(je.current.type),i.ref),ft[O]=!0)}}function Ho(i,b){{var O=function(){er||(er=!0,C("%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)",b))};O.isReactWarning=!0,Object.defineProperty(i,"key",{get:O,configurable:!0})}}function qo(i,b){{var O=function(){tr||(tr=!0,C("%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)",b))};O.isReactWarning=!0,Object.defineProperty(i,"ref",{get:O,configurable:!0})}}var Go=function(i,b,O,R,N,V,X){var z={$$typeof:t,type:i,key:b,ref:O,props:X,_owner:V};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:R}),Object.defineProperty(z,"_source",{configurable:!1,enumerable:!1,writable:!1,value:N}),Object.freeze&&(Object.freeze(z.props),Object.freeze(z)),z};function Jo(i,b,O,R,N){{var V,X={},z=null,te=null;O!==void 0&&(Qt(O),z=""+O),Fo(b)&&(Qt(b.key),z=""+b.key),Vo(b)&&(te=b.ref,Ko(b,N));for(V in b)Ve.call(b,V)&&!Wo.hasOwnProperty(V)&&(X[V]=b[V]);if(i&&i.defaultProps){var G=i.defaultProps;for(V in G)X[V]===void 0&&(X[V]=G[V])}if(z||te){var J=typeof i=="function"?i.displayName||i.name||"Unknown":i;z&&Ho(X,J),te&&qo(X,J)}return Go(i,z,te,N,R,je.current,X)}}var dt=y.ReactCurrentOwner,rr=y.ReactDebugCurrentFrame;function be(i){if(i){var b=i._owner,O=We(i.type,i._source,b?b.type:null);rr.setExtraStackFrame(O)}else rr.setExtraStackFrame(null)}var mt;mt=!1;function pt(i){return typeof i=="object"&&i!==null&&i.$$typeof===t}function nr(){{if(dt.current){var i=B(dt.current.type);if(i)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+i+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+i+"`."}return""}}function Zo(i){{if(i!==void 0){var b=i.fileName.replace(/^.*[\\\/]/,""),O=i.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+
|
|
25
|
+
Check your code at `+b+":"+O+"."}return""}}var or={};function Qo(i){{var b=nr();if(!b){var O=typeof i=="string"?i:i.displayName||i.name;O&&(b=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+
|
|
27
|
+
Check the top-level render call using <`+O+">.")}return b}}function sr(i,b){{if(!i._store||i._store.validated||i.key!=null)return;i._store.validated=!0;var O=Qo(b);if(or[O])return;or[O]=!0;var R="";i&&i._owner&&i._owner!==dt.current&&(R=" It was passed a child from "+B(i._owner.type)+"."),be(i),C('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',O,R),be(null)}}function ir(i,b){{if(typeof i!="object")return;if(lt(i))for(var O=0;O<i.length;O++){var R=i[O];pt(R)&&sr(R,b)}else if(pt(i))i._store&&(i._store.validated=!0);else if(i){var N=T(i);if(typeof N=="function"&&N!==i.entries)for(var V=N.call(i),X;!(X=V.next()).done;)pt(X.value)&&sr(X.value,b)}}}function es(i){{var b=i.type;if(b==null||typeof b=="string")return;var O;if(typeof b=="function")O=b.propTypes;else if(typeof b=="object"&&(b.$$typeof===l||b.$$typeof===c))O=b.propTypes;else return;if(O){var R=B(b);Bo(O,i.props,"prop",R,i)}else if(b.PropTypes!==void 0&&!mt){mt=!0;var N=B(b);C("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",N||"Unknown")}typeof b.getDefaultProps=="function"&&!b.getDefaultProps.isReactClassApproved&&C("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ts(i){{for(var b=Object.keys(i.props),O=0;O<b.length;O++){var R=b[O];if(R!=="children"&&R!=="key"){be(i),C("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",R),be(null);break}}i.ref!==null&&(be(i),C("Invalid attribute `ref` supplied to `React.Fragment`."),be(null))}}function ar(i,b,O,R,N,V){{var X=D(i);if(!X){var z="";(i===void 0||typeof i=="object"&&i!==null&&Object.keys(i).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 te=Zo(N);te?z+=te:z+=nr();var G;i===null?G="null":lt(i)?G="array":i!==void 0&&i.$$typeof===t?(G="<"+(B(i.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):G=typeof i,C("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",G,z)}var J=Jo(i,b,O,N,V);if(J==null)return J;if(X){var ne=b.children;if(ne!==void 0)if(R)if(lt(ne)){for(var Ee=0;Ee<ne.length;Ee++)ir(ne[Ee],i);Object.freeze&&Object.freeze(ne)}else C("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 ir(ne,i)}return i===n?ts(J):es(J),J}}function rs(i,b,O){return ar(i,b,O,!0)}function ns(i,b,O){return ar(i,b,O,!1)}var os=ns,ss=rs;xe.Fragment=n,xe.jsx=os,xe.jsxs=ss}()),xe}(function(e){process.env.NODE_ENV==="production"?e.exports=fr():e.exports=dr()})(lr);const mr=we.Fragment,k=we.jsx,ae=we.jsxs;let pr=(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 gr{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:o,name:s,params:a})=>{try{const u=await this.registeredRPC[s](a);t.emit(`${this.room}._result.${o}`,{ok:u||null})}catch(u){t.emit(`${this.room}._result.${o}`,{err:`${u.message}`})}})}async _callServerRPC(t,r){const n=pr();return new Promise((o,s)=>{this._socket.once(`${this.room}._result.${n}`,a=>{a.hasOwnProperty("ok")?o(a.ok):s(a.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 o=()=>{if(this.registeredRPC[t]===r)return delete this.registeredRPC[t],this._callServerRPC("unregister",{name:t})};return this.toUnregister.push(o),o}async call(t,r){return await this._callServerRPC("call",{name:t,params:r})}}const hr=({socket:e,room:t,onJoined:r=()=>{},onMaster:n=()=>{},userId:o=null})=>{const s=new gr(e,t,o);return new Promise(a=>{let u=!0;e.on(`${t}.isMaster`,()=>{s._left||n(t)}),e.on(`${t}.roomJoined`,l=>{s._left||(s.userId=l,u=!1,r(s),a(s))}),e.on("connect",()=>{s._left||u||e.emit("joinSuperSocket",{room:t,userId:s.userId})}),e.emit("joinSuperSocket",{room:t,userId:o})})},Ke=d.createContext(),vr=()=>k("div",{style:{position:"absolute",top:"0",bottom:"0",width:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:k("h2",{children:"🌀 Loading..."})}),vt=({socket:e,room:t,channel:r="default",LoadingComponent:n=vr,children:o})=>{const[s,a]=d.useState(!1),[u,l]=d.useState(!1),[m,f]=d.useState(null),c=d.useRef(null),h=d.useRef(!1),S=d.useContext(Ke),v=d.useRef(!1);return d.useEffect(()=>(h.current=!0,()=>{h.current=!1}),[]),d.useEffect(()=>{if(!e)return null;const E=()=>{console.log(`Disconnected from ${r}…`),h.current&&(a(!1),l(!1))};return e.on("disconnect",E),()=>{e.off("disconnect",E)}},[r,e]),d.useEffect(()=>e?(e.connected||e.connect(),console.log(`Try to connect to wire ${t} on channel ${r}`),v.current||(v.current=!0,hr({socket:e,room:t,onMaster:()=>{console.log(`Is now master on channel ${r}…`),h.current&&l(!0)},onJoined:E=>{console.log(`Connected on channel ${r}…`),c.current=E,h.current&&(f(E),a(!0))}})),()=>{var E;(E=c.current)==null||E.leave()}):null,[r,t,e]),!s||!m?k(n,{}):k(Ke.Provider,{value:{...S,[r]:{wire:m,joined:s,isMaster:u,room:t}},children:o})},Ie=(e="default")=>(d.useContext(Ke)||{})[e],yt=e=>{let t;const r=new Set,n=(l,m)=>{const f=typeof l=="function"?l(t):l;if(!Object.is(f,t)){const c=t;t=m??typeof f!="object"?f:Object.assign({},t,f),r.forEach(h=>h(t,c))}},o=()=>t,u={setState:n,getState:o,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,o,u),u},De=e=>e?yt(e):yt;var He={},yr={get exports(){return He},set exports(e){He=e}},qe={},Re={},Sr={get exports(){return Re},set exports(e){Re=e}},Ge={};/**
|
|
28
28
|
* @license React
|
|
29
29
|
* use-sync-external-store-shim.production.min.js
|
|
30
30
|
*
|
|
@@ -32,7 +32,7 @@ Check the top-level render call using <`+I+">.")}return _}}function sr(i,_){{if(
|
|
|
32
32
|
*
|
|
33
33
|
* This source code is licensed under the MIT license found in the
|
|
34
34
|
* LICENSE file in the root directory of this source tree.
|
|
35
|
-
*/var St;function
|
|
35
|
+
*/var St;function _r(){if(St)return Ge;St=1;var e=d;function t(c,h){return c===h&&(c!==0||1/c===1/h)||c!==c&&h!==h}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,o=e.useEffect,s=e.useLayoutEffect,a=e.useDebugValue;function u(c,h){var S=h(),v=n({inst:{value:S,getSnapshot:h}}),E=v[0].inst,T=v[1];return s(function(){E.value=S,E.getSnapshot=h,l(E)&&T({inst:E})},[c,S,h]),o(function(){return l(E)&&T({inst:E}),c(function(){l(E)&&T({inst:E})})},[c]),a(S),S}function l(c){var h=c.getSnapshot;c=c.value;try{var S=h();return!r(c,S)}catch{return!0}}function m(c,h){return h()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:u;return Ge.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Ge}var Je={};/**
|
|
36
36
|
* @license React
|
|
37
37
|
* use-sync-external-store-shim.development.js
|
|
38
38
|
*
|
|
@@ -40,7 +40,7 @@ Check the top-level render call using <`+I+">.")}return _}}function sr(i,_){{if(
|
|
|
40
40
|
*
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
|
-
*/var
|
|
43
|
+
*/var _t;function br(){return _t||(_t=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=d,t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(x){{for(var p=arguments.length,_=new Array(p>1?p-1:0),g=1;g<p;g++)_[g-1]=arguments[g];n("error",x,_)}}function n(x,p,_){{var g=t.ReactDebugCurrentFrame,w=g.getStackAddendum();w!==""&&(p+="%s",_=_.concat([w]));var I=_.map(function(P){return String(P)});I.unshift("Warning: "+p),Function.prototype.apply.call(console[x],console,I)}}function o(x,p){return x===p&&(x!==0||1/x===1/p)||x!==x&&p!==p}var s=typeof Object.is=="function"?Object.is:o,a=e.useState,u=e.useEffect,l=e.useLayoutEffect,m=e.useDebugValue,f=!1,c=!1;function h(x,p,_){f||e.startTransition!==void 0&&(f=!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=p();if(!c){var w=p();s(g,w)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}var I=a({inst:{value:g,getSnapshot:p}}),P=I[0].inst,D=I[1];return l(function(){P.value=g,P.getSnapshot=p,S(P)&&D({inst:P})},[x,g,p]),u(function(){S(P)&&D({inst:P});var j=function(){S(P)&&D({inst:P})};return x(j)},[x]),m(g),g}function S(x){var p=x.getSnapshot,_=x.value;try{var g=p();return!s(_,g)}catch{return!0}}function v(x,p,_){return p()}var E=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",T=!E,y=T?v:h,C=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:y;Je.useSyncExternalStore=C,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Je}var bt;function Et(){return bt||(bt=1,function(e){process.env.NODE_ENV==="production"?e.exports=_r():e.exports=br()}(Sr)),Re}/**
|
|
44
44
|
* @license React
|
|
45
45
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
46
46
|
*
|
|
@@ -48,7 +48,7 @@ Check the top-level render call using <`+I+">.")}return _}}function sr(i,_){{if(
|
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the MIT license found in the
|
|
50
50
|
* LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/var
|
|
51
|
+
*/var wt;function Er(){if(wt)return qe;wt=1;var e=d,t=Et();function r(m,f){return m===f&&(m!==0||1/m===1/f)||m!==m&&f!==f}var n=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,u=e.useMemo,l=e.useDebugValue;return qe.useSyncExternalStoreWithSelector=function(m,f,c,h,S){var v=s(null);if(v.current===null){var E={hasValue:!1,value:null};v.current=E}else E=v.current;v=u(function(){function y(g){if(!C){if(C=!0,x=g,g=h(g),S!==void 0&&E.hasValue){var w=E.value;if(S(w,g))return p=w}return p=g}if(w=p,n(x,g))return w;var I=h(g);return S!==void 0&&S(w,I)?w:(x=g,p=I)}var C=!1,x,p,_=c===void 0?null:c;return[function(){return y(f())},_===null?void 0:function(){return y(_())}]},[f,c,h,S]);var T=o(m,v[0],v[1]);return a(function(){E.hasValue=!0,E.value=T},[T]),l(T),T},qe}var Ze={};/**
|
|
52
52
|
* @license React
|
|
53
53
|
* use-sync-external-store-shim/with-selector.development.js
|
|
54
54
|
*
|
|
@@ -56,13 +56,13 @@ Check the top-level render call using <`+I+">.")}return _}}function sr(i,_){{if(
|
|
|
56
56
|
*
|
|
57
57
|
* This source code is licensed under the MIT license found in the
|
|
58
58
|
* LICENSE file in the root directory of this source tree.
|
|
59
|
-
*/var wt;function Cr(){return wt||(wt=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=d,t=Et();function r(f,c){return f===c&&(f!==0||1/f===1/c)||f!==f&&c!==c}var n=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,u=e.useMemo,l=e.useDebugValue;function m(f,c,h,b,v){var E=s(null),O;E.current===null?(O={hasValue:!1,value:null},E.current=O):O=E.current;var y=u(function(){var C=!1,g,S,T=function(A){if(!C){C=!0,g=A;var N=b(A);if(v!==void 0&&O.hasValue){var W=O.value;if(v(W,N))return S=W,W}return S=N,N}var Z=g,M=S;if(n(Z,A))return M;var $=b(A);return v!==void 0&&v(M,$)?M:(g=A,S=$,$)},P=h===void 0?null:h,D=function(){return T(c())},j=P===null?void 0:function(){return T(P())};return[D,j]},[c,h,b,v]),w=y[0],x=y[1],p=o(f,w,x);return a(function(){O.hasValue=!0,O.value=p},[p]),l(p),p}Ze.useSyncExternalStoreWithSelector=m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ze}(function(e){process.env.NODE_ENV==="production"?e.exports=Er():e.exports=Cr()})(yr);const wr=me(He),{useSyncExternalStoreWithSelector:xr}=wr;function $e(e,t=e.getState,r){const n=xr(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return d.useDebugValue(n),n}const he=(e,t)=>e.classList&&e.classList.contains(t),Oe=(e,t)=>he(e,t)?e:e.parentNode?Oe(e.parentNode,t):!1,Ae=([e,t],[r,n])=>{const o=Math.abs(e-r),s=Math.abs(t-n);return Math.hypot(o,s)},xt=(e,t,r)=>{const n=r*Math.PI/180,o=e*Math.cos(n)-t*Math.sin(n),s=e*Math.sin(n)+t*Math.cos(n);return[o,s]},Qe=([e,t],{scale:r,rotate:n,translateX:o,translateY:s})=>{const a=(e-o)/r,u=(t-s)/r;return xt(a,u,-n)},Le=([e,t],{scale:r,rotate:n,translateX:o,translateY:s})=>{const[a,u]=xt(e,t,n);return[a*r+o,u*r+s]},It=(e,t,r,n)=>{const o=e.x,s=e.y,a=t.x,u=t.y,l=r.x,m=r.y,f=a-o,c=u-s,h=o-l,b=s-m,v=f*f+c*c,E=2*(h*f+b*c),O=h*h+b*b-n*n,y=E*E-4*v*O;if(y<0)return[];const w=(-E+Math.sqrt(y))/(2*v),x=(-E-Math.sqrt(y))/(2*v),p=[];return w>=0&&w<=1&&p.push({x:o+w*f,y:s+w*c}),x>=0&&x<=1&&p.push({x:o+x*f,y:s+x*c}),p},et=(e,t)=>e.x>t.left&&e.x<t.left+t.width&&e.y>t.top&&e.y<t.top+t.height,Ir=(e,t)=>Array.from(e.querySelectorAll(".corner")).every(n=>{const{top:o,left:s}=n.getBoundingClientRect();return et({x:s,y:o},t)}),Or=(e,t)=>{const r=t.getBoundingClientRect();return Ir(e,r)},ze=(e,t)=>{try{const n=e.getElementsByClassName(`item ${t}`)[0];return n||console.error(`Missing item ${t}`),n}catch{console.error(`Error while getting item with id ${t} with wrapper`,e);return}},Te=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},Tr=(e,t=document)=>{const r=e.reduce((n,o)=>{const s=ze(t,o);if(!s)return n||null;const{left:a,right:u,top:l,bottom:m}=s.getBoundingClientRect();let f;return n?f=n:f={left:a,top:l,right:u,bottom:m},f.left=Math.min(a,f.left),f.top=Math.min(l,f.top),f.right=Math.max(u,f.right),f.bottom=Math.max(m,f.bottom),f},null);return r&&(r.width=r.right-r.left,r.height=r.bottom-r.top,r)},Ot=(e,t,r=null)=>(r===null&&(r=new Set),!Array.isArray(t)||t.length===0?[]:t.map(n=>r.has(n)?[]:(r.add(n),[n,...Ot(e,e[n].linkedItems,r)])).flat()),Tt=(e,t,r)=>{const n=new Set(Ot(e,r));return t.filter(o=>n.has(o))},kr=({x:e,y:t,width:r,height:n},{type:o="grid",size:s=1,offset:a={x:0,y:0}})=>{const[u,l]=[e+r/2-a.x,t+n/2-a.y];let m,f,c,h,b,v,E,O,y,w;const x=s/1.1547;switch(o){case"grid":m=Math.round(u/s)*s,f=Math.round(l/s)*s;break;case"hexH":c=2*x,h=3*s,b=Math.round(u/c)*c,E=Math.round(l/h)*h,v=b>u?b-x:b+x,O=E>l?E-1.5*s:E+1.5*s,y=Math.hypot(b-u,E-l),w=Math.hypot(v-u,O-l),y<w?(m=b,f=E):(m=v,f=O);break;case"hexV":c=3*s,h=2*x,b=Math.round(u/c)*c,E=Math.round(l/h)*h,v=b>u?b-1.5*s:b+1.5*s,O=E>l?E-x:E+x,y=Math.hypot(b-u,E-l),w=Math.hypot(v-u,O-l),y<w?(m=b,f=E):(m=v,f=O);break;default:m=e+r/2,f=t+n/2}return{x:m+a.x-r/2,y:f+a.y-n/2}},kt=["#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"],Pt=()=>kt[Math.floor(Math.random()*kt.length)],Pr=!1,tt=({wire:e,storeName:t,noSync:r=[],defaultValue:n},o)=>(s,a,u)=>{s({ready:!1});const l=[];(async()=>{try{const b=await e.call(`${t}_getValue`);Pr&&console.log("init from peer with value",b),s(v=>({...v,...b}))}catch{n!==void 0&&s(n)}l.push(await e.register(`${t}_getValue`,()=>Object.fromEntries(Object.entries(a()).filter(([b,v])=>typeof v!="function"&&!r.includes(b))),{invoke:"first"})),l.push(e.subscribe(`${t}_call`,([b,v])=>{c[b](...v)})),s({ready:!0})})();const f=o(s,a,u),c={...f},h=Object.fromEntries(Object.entries(f).map(([b,v])=>typeof v=="function"&&!b.startsWith("get")&&!r.includes(b)?[b,(...O)=>{const y=v(...O);return e.publish(`${t}_call`,[b,O]),y}]:[b,v]));return h.unsub=()=>{l.forEach(b=>b())},h};function Ye(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,o]of e)if(!Object.is(o,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 Mt=d.createContext(),Mr=(e,t)=>({items:{},getItems:()=>t().items,setItems:r=>e({items:r}),updateItems:(r,n=!1)=>e(o=>n?{items:Object.fromEntries(Object.entries(o.items).map(([a,u])=>r[a]?[a,{...u,...r[a]}]:[a,u]))}:{items:{...o.items,...r}}),moveItems:(r,n)=>e(({items:o})=>{const s={...o};return r.forEach(a=>{const u=o[a];u&&(s[a]={...u,x:(u.x||0)+n.x,y:(u.y||0)+n.y,moving:!0})}),{items:s}})}),jr=(e,t)=>({itemIds:[],setItemIds:r=>e({itemIds:r}),getItemIds:()=>t().itemIds,insert:(r,n)=>e(o=>{const s=[...o.itemIds];return s.splice(r,0,n),{itemIds:s}}),remove:r=>e(n=>{const o=[...n.itemIds];return o.splice(r,1),{itemIds:o}}),updateItemIds:(r,n)=>e(o=>{const s=[...o.itemIds];return s[r]=n,{items:s}}),updateManyItemIds:r=>e(n=>({items:n.itemIds.map((o,s)=>r[s]!==void 0?r[s]:o)}))}),Dr=(e,t)=>({removeItemsById:r=>e(n=>({itemIds:n.itemIds.filter(o=>!r.includes(o)),items:Object.fromEntries(Object.entries(n.items).filter(([o])=>!r.includes(o)))})),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(o=>{let s;const a=r.map(({id:u})=>u);if(n){const u=o.itemIds.findIndex(l=>l===n);s=[...o.itemIds],s.splice(u,0,...a)}else s=[...o.itemIds,...a];return{items:{...o.items,...Object.fromEntries(r.map(u=>[u.id,u]))},itemIds:s}})}),Rr=(e,t)=>({boardConfig:{},getBoardConfig:()=>t().boardConfig,setBoardConfig:r=>e({boardConfig:r}),updateBoardConfig:r=>e(n=>({boardConfig:{...n.boardConfig,...r}}))}),$r=(e,t)=>({session:{},getSessionInfo:()=>t().session,setSessionInfo:r=>e({session:r}),updateSessionInfo:r=>e(n=>({session:{...n.session,...r}}))}),jt=({storeName:e,children:t,defaultValue:r})=>{const{wire:n}=Ie("room"),[o,s]=d.useState(!1),[a]=d.useState(()=>De(tt({wire:n,storeName:e,defaultValue:r},(...u)=>({...Mr(...u),...jr(...u),...Dr(...u),...Rr(...u),...$r(...u)}))));return d.useEffect(()=>{const u=a.subscribe(l=>{l.ready&&(u(),s(!0))})},[a]),o?k(Mt.Provider,{value:a,children:t}):null},oe=(e,t)=>{const r=d.useContext(Mt);return $e(r,e,t||Ye)},Ar=()=>{const[e,t]=oe(n=>[n.itemIds,n.items]);return d.useMemo(()=>e.map(n=>t[n]),[e,t])},Lr=()=>{const[e,t,r]=oe(a=>[a.items,a.itemIds,a.getItemList]),[n,o]=d.useState(r()),[,s]=d.useTransition();return d.useEffect(()=>{const a=r();s(()=>{o(a)})},[e,t,r]),n},Dt=5e4,Rt=d.createContext(),zr=(e,t)=>({config:{itemTemplates:{},actions:{},uid:null,itemExtent:{x:0,y:0,radius:0},boardWrapperRect:{},boardSize:Dt},updateConfiguration:r=>e(n=>({config:{...n.config,...r}})),getConfiguration:()=>t().config}),Yr=(e,t)=>({boardState:{movingItems:!1,selecting:!1,zooming:!1,panning:!1,translateX:0,translateY:0,scale:1,rotate:0},updateBoardState:r=>e(n=>({boardState:{...n.boardState,...r}})),getBoardState:()=>t().boardState}),Br=(e,t)=>({interactions:{},getInteractions:()=>t().interactions,register:(r,n)=>e(o=>{const s=[...o.interactions[r]||[]];return s.push(n),{interactions:{...o.interactions,[r]:s}}}),unregister:(r,n)=>e(o=>{const s=(o.interactions[r]||[]).filter(a=>a!==n);return{interactions:{...o.interactions,[r]:s}}}),callInteractions:(r,n)=>{t().interactions[r]&&t().interactions[r].forEach(o=>{setTimeout(()=>o(n),0)})}}),Nr=(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(o=>!r.includes(o))})),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 o=n.selectionBox;return!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height?{selectionBox:r}:{}})}),$t=({children:e})=>{const[t]=d.useState(()=>De((...r)=>({...zr(...r),...Yr(...r),...Br(...r),...Nr(...r)})));return k(Rt.Provider,{value:t,children:e})},Q=(e,t)=>{const r=d.useContext(Rt);return $e(r,e,t||Ye)},Xr=()=>{const[e]=Q(t=>[t.selection]);return e};function rt(e){const t=d.useRef(e);return t.current=e,d.useMemo(()=>Object.freeze({get current(){return t.current}}),[])}function Ur(e){const t=rt(e);d.useEffect(()=>()=>{t.current()},[])}function nt(e,t,r,n=0){const o=d.useRef(),s=d.useRef(),a=d.useRef(),u=()=>{o.current&&(clearTimeout(o.current),o.current=void 0),s.current&&(clearTimeout(s.current),s.current=void 0)};return Ur(u),d.useMemo(()=>{const l=()=>{if(!a.current)return;const f=a.current;a.current=void 0,e.apply(f.this,f.args),u()},m=function(...f){o.current&&clearTimeout(o.current),a.current={args:f,this:this},o.current=setTimeout(l,r),n>0&&!s.current&&(s.current=setTimeout(l,n))};return Object.defineProperties(m,{length:{value:e.length},name:{value:`${e.name||"anonymous"}__debounced__${r}`}}),m},[r,n,...t])}const Wr=100,Vr=1e3,Fr=.8,Kr=({x:e,y:t,scale:r,rotate:n,itemExtent:o,boardWrapperRect:s,boardSize:a})=>{let[u,l]=[e,t];const m=Qe([s.width/2,s.height/2],{translateX:u,translateY:l,scale:r,rotate:n}),f={x:o.x+a/2,y:o.y+a/2},c={x:a/2,y:a/2},h=Ae(m,[f.x,f.y]),b=Math.min(s.width,s.height),v=o.radius+b/2/r-Wr/r;if(h>v){const y=It({x:m[0],y:m[1]},f,f,v-1/r)[0],[w,x]=Le([-y.x,-y.y],{translateX:s.width/2,translateY:s.height/2,scale:r,rotate:n});u=w,l=x}const E=Ae(m,[c.x,c.y]),O=a/2-Ae([0,0],[s.width,s.height])/r;if(E>O){const y=It({x:m[0],y:m[1]},c,c,O-1/r)[0];if(y){const[w,x]=Le([-y.x,-y.y],{translateX:s.width/2,translateY:s.height/2,scale:r,rotate:n});u=w,l=x}}return[u,l]},ve=()=>{const[e,t,r,n,o]=Q(p=>[p.getBoardState,p.updateBoardState,p.config.itemExtent,p.getConfiguration,p.updateConfiguration]),s=d.useRef([.15,5]),[a]=oe(p=>[p.getItemList]),u=d.useCallback(()=>{const{translateX:p,translateY:C,scale:g,rotate:S}=e();return{translateX:p,translateY:C,scale:g,rotate:S}},[e]),l=d.useCallback((p,C)=>Qe([p,C],e()),[e]),m=d.useCallback((p,C)=>Le([p,C],e()),[e]),f=d.useCallback((p,C)=>{const{scale:g,rotate:S}=e();return Qe([p,C],{translateX:0,translateY:0,rotate:S,scale:g})},[e]),c=d.useCallback(p=>p>s.current[1]?s.current[1]:p<s.current[0]?s.current[0]:p,[]),h=d.useCallback(p=>{const{itemExtent:C,boardWrapperRect:g,boardSize:S}=n(),T=e(),{translateX:P,translateY:D,scale:j,rotate:A}={...T,...p(T)},N=c(j);let[W,Z]=[P,D];(P!==T.translateX||D!==T.translateY)&&([W,Z]=Kr({x:P,y:D,scale:N,rotate:A,itemExtent:C,boardWrapperRect:g,boardSize:S})),t({translateX:W,translateY:Z,scale:N,rotate:A})},[c,e,n,t]),b=d.useCallback(p=>{let C=g=>({...g,...p});typeof p=="function"&&(C=p),h(g=>({...g,...C({translateX:g.translateX,translateY:g.translateY})}))},[h]),v=d.useCallback(({to:p,factor:C})=>{const{boardWrapperRect:g}=n();let S=p;S||(S={x:g.left+g.width/2,y:g.top+g.height/2});const T=e(),P=c(T.scale*C),D=S.x-g.left,j=S.y-g.top,A=D-(D-T.translateX)*P/T.scale,N=j-(j-T.translateY)*P/T.scale;h(W=>({...W,translateX:A,translateY:N,scale:P}))},[c,e,n,h]),E=d.useCallback(({x:p,y:C,radius:g})=>{const{rotate:S}=e(),{boardWrapperRect:T,boardSize:P}=n(),D=T.width/(g*2),j=T.height/(g*2),A=c(Math.min(D,j)*Fr),[N,W]=Le([-P/2-p,-P/2-C],{translateX:T.width/2,translateY:T.height/2,scale:A,rotate:S});h(Z=>({...Z,translateX:N,translateY:W,scale:A}))},[c,e,n,h]),O=d.useCallback(()=>{const{boardWrapperRect:p,boardSize:C}=n(),[g,S]=l(p.width/2,p.height/2);return{x:g-C/2,y:S-C/2}},[l,n]),y=d.useCallback(()=>{const p=a(),{boardWrapper:C,boardSize:g}=n(),S=p.reduce((P,D)=>{const j=ze(C,D.id);return j&&(P.left=Math.min(D.x,P.left),P.top=Math.min(D.y,P.top),P.right=Math.max(D.x+j.offsetWidth,P.right),P.bottom=Math.max(D.y+j.offsetHeight,P.bottom)),P},{left:g/2,top:g/2,right:-g/2,bottom:-g/2}),T={x:(S.right+S.left)/2,y:(S.bottom+S.top)/2};T.radius=Math.max(Ae([T.x,T.y],[S.left,S.top]),Vr),o({itemExtent:T})},[n,a,o]),w=d.useCallback(p=>{let C=()=>p;typeof p=="function"&&(C=p),h(g=>({...g,rotate:C(g.rotate)})),y(),E(r)},[r,h,y,E]),x=nt(()=>y(),[y],200);return{setDim:h,rotateBoard:w,moveBoard:b,getDim:u,zoomTo:v,zoomToCenter:v,zoomToExtent:E,getCenter:O,updateItemExtent:x,vectorFromWrapperToBoard:f,fromWrapperToBoard:l,fromBoardToWrapper:m}},ot=e=>{const[t,r,n]=Q(({register:a,unregister:u,callInteractions:l})=>[a,u,l]),o=d.useCallback(a=>(t(e,a),()=>{r(e,a)}),[e,t,r]),s=d.useCallback(a=>{n(e,a)},[n,e]);return{register:o,call:s}},Be=()=>{const{call:e}=ot("place"),{call:t}=ot("delete"),{getCenter:r,updateItemExtent:n}=ve(),[o,s,a,u]=Q(M=>[M.clear,M.reverse,M.unselect,M.getConfiguration]),{getItems:l,getItemIds:m,setItemIds:f,updateItems:c,moveItems:h,removeItemsById:b,getItemList:v,insertItems:E,setItemList:O}=oe(({getItems:M,getItemIds:$,setItemIds:z,updateItems:F,moveItems:Y,removeItemsById:K,getItemList:q,insertItems:re,setItemList:ee})=>({getItems:M,getItemIds:$,setItemIds:z,updateItems:F,moveItems:Y,removeItemsById:K,getItemList:q,insertItems:re,setItemList:ee})),y=d.useCallback((M,$,z=!1)=>{let F=$;typeof $=="object"&&(F=()=>$);const Y=m().filter(ee=>M.includes(ee)),K=l(),q=Y.map(ee=>{const se=K[ee];return z?[ee,F(se)]:[ee,F({...se})]}).filter(([,ee])=>ee);if(q.length===0)return;const re=Object.fromEntries(q);c(re,z),n()},[m,l,n,c]),w=d.useCallback(M=>{O(M),o(),n()},[o,O,n]),x=d.useCallback((M,$,z=!1)=>{y([M],$,z)},[y]),p=d.useCallback((M,$)=>{h(Tt(l(),m(),M),$),n()},[m,l,h,n]),C=d.useCallback(M=>{const $=m(),z=$.filter(Y=>!M.includes(Y)),F=$.filter(Y=>M.includes(Y));f([...z,...F])},[m,f]),g=d.useCallback((M,{type:$,size:z}={})=>{const{boardWrapper:F}=u();y(M,Y=>{const K=ze(F,Y.id);if(!K)return;const q={type:$||"grid",size:z||1,offset:{x:0,y:0},...Y.grid};return kr({x:Y.x,y:Y.y,width:K.clientWidth,height:K.clientHeight},q)},!0)},[u,y]),S=d.useCallback((M,$)=>{const z=Tt(l(),m(),M);C(z),y(z,{moving:!1},!0),g(z,$),e(M),n()},[y,e,m,l,C,g,n]),T=d.useCallback(M=>{f(M)},[f]),P=d.useCallback(M=>{const $=m(),z=$.filter(Y=>M.includes(Y)),F=$.map(Y=>M.includes(Y)?z.pop():Y);f(F),s()},[m,s,f]),D=d.useCallback((M,$)=>{const z=l(),F=Object.fromEntries($.map((q,re)=>{const ee=z[M[re]];return[q,{x:ee.x,y:ee.y}]}));y(M,q=>F[q.id],!0);const Y=Object.fromEntries(M.map((q,re)=>[q,$[re]])),K=m().map(q=>M.includes(q)?Y[q]:q);f(K)},[l,y,m,f]),j=d.useCallback((M,$)=>{const z=r(),F=M.map((Y,K)=>!Y.x||!Y.y?{...Y,x:z.x+2*K,y:z.y+2*K}:Y);E(F,$),n()},[r,E,n]),A=d.useCallback((M,$)=>{j([M],$)},[j]),N=d.useCallback(M=>{a(M),b(M),t(M)},[a,b,t]),W=d.useCallback(M=>{const $=l();return M.map(z=>$[z])},[l]),Z=d.useCallback(({target:M,clientX:$,clientY:z},{returnLocked:F=!1,passLocked:Y=!1}={})=>{if(["INPUT","TEXTAREA"].includes(M.tagName))return null;const K=Oe(M,"item");if(K){if(he(K,"selected"))return K;if(!Y&&he(K,"locked")&&!he(M,"passthrough"))return F?K:null;if(he(M,"passthrough")){const q=m(),{boardWrapper:re}=u(),ee=q.reduce((se,le)=>{const Se=ze(re,le),be=Se.getBoundingClientRect();return et({x:$,y:z},be)&&se.unshift(Se),se},[]);for(let se=0;se<ee.length;se+=1){const le=ee[se];if(le!==K&&(Y||!he(le,"locked")))return le}return null}}return K},[u,m]);return{putItemsOnTop:C,batchUpdateItems:y,updateItemOrder:T,moveItems:p,placeItems:S,updateItem:x,swapItems:D,reverseItemsOrder:P,setItemList:w,pushItem:A,pushItems:j,removeItems:N,getItemList:v,findElementUnderPointer:Z,getItems:W}};var Hr=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,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(o of t.entries())if(!r.has(o[0]))return!1;for(o of t.entries())if(!e(o[1],r.get(o[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(o of t.entries())if(!r.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(t[o]!==r[o])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(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r};function qr(e,t,r,n=0){d.useEffect(nt(e,t,r,n),t)}const Gr=(e,t)=>{if(e.type in t){const r=t[e.type].defaultActions;return typeof r=="function"?r(e):r}return[]},At=(e,t)=>{const{actions:r=Gr(e,t)}=e;return r.map(n=>typeof n=="string"?{name:n}:n)},Jr=()=>{const[e,t]=oe(c=>[c.items,c.getItems]),[r,n,o]=Q(c=>[c.config.itemTemplates,c.selection,c.getSelection]),[s,a]=d.useState([]),u=d.useRef(!1),[,l]=d.useTransition();d.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const m=d.useCallback(c=>{const h=t();if(c)return[c,c.map(v=>h[v])];const b=o();return[b,b.map(v=>h[v])]},[t,o]),f=d.useCallback(()=>{const[c,h]=m();if(c.length>0){if(!u.current)return;const b=h.reduce((v,E)=>{const O=At(E,r);return v.filter(y=>O.some(w=>Hr(y,w)))},At(h[0],r));l(()=>{a(b)})}else l(()=>{a([])})},[m,r]);return qr(()=>f(),[e,n,f],100),{availableActions:s}},Zr=()=>{const[e]=Q(t=>[t.selectionBox]);return e};let pe=(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 Lt=d.createContext(),st=e=>{localStorage.setItem("user",JSON.stringify(e))},Qr=()=>{if(localStorage.user){const t={name:"Player",color:Pt(),uid:pe(),...JSON.parse(localStorage.user)};return st(t),t}const e={name:"Player",color:Pt(),uid:pe()};return st(e),e},en=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:o})=>o===n)},addUser:n=>t(o=>({users:{...o.users,[n.id]:n}})),updateUser:(n,o)=>t(s=>{if(!s.users[n])return{};const a={...s.users[n],...o,id:n,uid:s.users[n].uid};return a.id===e&&st(a),setTimeout(()=>r().electSpaceMaster(),100),{users:{...s.users,[n]:a}}}),removeUser:n=>t(o=>{const s={...o.users};return delete s[n],setTimeout(()=>r().electSpaceMaster(),100),{users:s}}),updateCurrentUser:n=>r().updateUser(e,n),joinSpace:n=>r().updateUser(e,{space:n,spaceJoinedTimestamp:Date.now()}),electSpaceMaster:()=>{const n=r().getLocalUsers(),o={uid:null,timestamp:Date.now()};Object.values(n).forEach(({spaceJoinedTimestamp:s,id:a})=>{s<o.timestamp&&(o.id=a,o.timestamp=s)}),t({isSpaceMaster:o.id===e})}}),tn=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}})}),zt=({storeName:e,children:t})=>{const{wire:r,isMaster:n}=Ie("room"),[o,s]=d.useState(null),[a,u]=d.useState(!1),l=d.useRef(!1);return d.useEffect(()=>{let m=!0;const f=[];if(!o&&!l.current)return l.current=!0,(()=>{const h=De(tt({wire:r,storeName:e,noSync:["updateCurrentUser","joinSpace","isSpaceMaster","electSpaceMaster"]},(...v)=>({...en(r.userId)(...v),...tn(...v)}))),b=h.subscribe(v=>{v.ready&&(b(),m&&s(h))})})(),()=>{m=!1,l.current=!1,f.forEach(h=>h())}},[o,e,r,r.userId]),d.useEffect(()=>{if(o)return o.getState().addUser({...Qr(),id:r.userId}),u(!0),()=>{o.getState().removeUser(r.userId)}},[n,o,r]),d.useEffect(()=>{if(o){const m=r.subscribe("userLeave",f=>{o.getState().removeUser(f)});return()=>{m()}}},[n,o,r]),d.useEffect(()=>{n&&o&&o.getState().updateCurrentUser({isMaster:n})},[n,o,r]),a?k(Lt.Provider,{value:o,children:t}):null},ye=(e,t)=>{const r=d.useContext(Lt);return $e(r,e,t||Ye)},rn=()=>{const[e,t,r,n,o]=ye(u=>[u.isSpaceMaster,u.getUser(),u.users,u.updateCurrentUser,u.joinSpace]),s=d.useMemo(()=>Object.values(r),[r]),a=d.useMemo(()=>{const{space:u}=t;return s.filter(({space:l})=>l===u)},[t,s]);return{isSpaceMaster:e,currentUser:t,updateCurrentUser:n,users:s,localUsers:a,joinSpace:o}},nn=()=>{const[e,t,r]=oe(o=>[o.boardConfig,o.getBoardConfig,o.setBoardConfig]),n=d.useCallback(o=>{let s=o;typeof o=="object"&&(s=()=>o);const a=t(),u=s(a);r(u)},[t,r]);return[e,n]},on=()=>{const[e]=Q(t=>[t.boardState]);return e},sn=()=>{const[e,t,r,n]=oe(o=>[o.getSessionInfo,o.setSessionInfo,o.updateSessionInfo,o.session]);return{getSessionInfo:e,setSessionInfo:t,sessionInfo:n,updateSessionInfo:r}},Yt=d.createContext(),an=({user:{name:e,uid:t,color:r},content:n})=>({type:"message",user:{name:e,uid:t,color:r},content:n,uid:pe(),timestamp:new Date().toISOString()}),cn=(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 o=an({user:r,content:n});o&&t().addMessage(o)}}),Bt=({storeName:e,children:t,defaultValue:r=[]})=>{const{wire:n}=Ie("room"),[o]=d.useState(()=>De(tt({wire:n,storeName:e,defaultValue:r,noSync:["sendMessage"]},(...s)=>({...cn(...s)}))));return k(Yt.Provider,{value:o,children:t})},un=(e,t)=>{const r=d.useContext(Yt);return $e(r,e,t||Ye)},ln=()=>{},fn=(e=ln)=>{const t=ye(a=>a.getUser()),[r,n,o]=un(a=>[a.messages,a.setMessages,a.sendMessage]);d.useEffect(()=>{r.length&&e()},[r,e]);const s=d.useCallback(a=>{o(t,a)},[t,o]);return{messages:r,setMessages:n,sendMessage:s}},Nt=({children:e,session:t})=>{const r=ye(n=>n.joinSpace);return d.useEffect(()=>(r(t),()=>{r(null)}),[r,t]),e},dn=({socket:e,room:t,session:r,items:n=[],messages:o=[],LoadingComponent:s,...a})=>{const[u]=d.useState(t||pe()),[l]=d.useState(r||pe()),[m]=d.useState(()=>({itemIds:n.map(({id:c})=>c),items:Object.fromEntries(n.map(c=>[c.id,c]))}));return Ie("room")?k(Bt,{storeName:`${l}_messages`,defaultValue:o,children:k($t,{children:k(jt,{storeName:`${l}_item`,defaultValue:m,children:k(Nt,{...a,session:l})})})}):k(vt,{room:u,channel:"room",socket:e,LoadingComponent:s,children:k(zt,{storeName:`${u}_users`,children:k(Bt,{storeName:`${l}_messages`,defaultValue:o,children:k($t,{children:k(jt,{storeName:`${l}_item`,defaultValue:m,children:k(Nt,{...a,session:l})})})})})})},mn=({socket:e,room:t,children:r,LoadingComponent:n})=>{const[o]=d.useState(t||pe());return k(vt,{room:o,channel:"room",socket:e,LoadingComponent:n,children:k(zt,{storeName:`${o}_users`,children:r})})},it=()=>{const e=navigator.userAgent.toLowerCase();return/mac os ?x 10/.test(e)},pn=(()=>{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})(),gn=800,Xt=(e,t)=>{const r=Object.keys(e).map(n=>Number(n)).find(n=>n!==t);return e[r]},Ut=([e,t],[r,n])=>{const o=Math.abs(e-r),s=Math.abs(t-n);return Math.hypot(o,s)},ge=()=>{},hn=e=>t=>{const{event:r}=t;return r.isPropagationStopped()?null:e(t)},vn=e=>async(...t)=>{try{await e(...t)}catch(r){console.error(r)}};class yn{constructor(){ur(this,"lastPromise",Promise.resolve(!0))}add(t,...r){return new Promise((n,o)=>{this.lastPromise=this.lastPromise.then(()=>hn(vn(t))(...r)).then(n).catch(o)})}}const ie=new yn,Ne=({children:e,onDrag:t=ge,onDragStart:r=ge,onDragEnd:n=ge,onPan:o=ge,onTap:s=ge,onLongTap:a=ge,onDoubleTap:u=ge,onZoom:l,mainAction:m="drag"})=>{const f=d.useRef(null),c=d.useRef({moving:!1,pointers:{},mainPointer:void 0}),h=y=>{const{deltaX:w,deltaY:x,clientX:p,clientY:C,deltaMode:g,ctrlKey:S,altKey:T,metaKey:P,target:D}=y;if(!(T||S&&!it()))if(it()&&!S)ie.add(o,{deltaX:-2*w,deltaY:-2*x,button:1,ctrlKey:S,metaKey:P,target:D,event:y});else{if(l===void 0||!x)return;let j=x;switch(g){case 1:j*=pn;break;case 2:j*=gn;break}it()&&(j*=2),ie.add(l,{scale:j,clientX:p,clientY:C,event:y})}},b=y=>{const{target:w,button:x,clientX:p,clientY:C,pointerId:g,altKey:S,ctrlKey:T,metaKey:P,isPrimary:D}=y;if(c.current.pointers[g]={clientX:p,clientY:C},D&&(c.current.mainPointer=void 0),c.current.mainPointer!==void 0){if(c.current.mainPointer!==g)try{const{clientX:j,clientY:A}=Xt(c.current.pointers,g),N=(j+p)/2,W=(A+C)/2,Z=Ut([j,A],[p,C]);Object.assign(c.current,{pressed:!0,moving:!1,gestureStart:!1,startX:p,startY:C,prevX:N,prevY:W,startDistance:Z,prevDistance:Z})}catch(j){console.log("Error while getting other pointer. Ignoring",j),c.current.mainPointer}return}c.current.mainPointer=g,Object.assign(c.current,{pressed:!0,moving:!1,gestureStart:!1,startX:p,startY:C,prevX:p,prevY:C,currentButton:x,pointerDownEvent:y,startDistance:0,prevDistance:0,target:w,timeStart:Date.now(),longTapTimeout:setTimeout(async()=>{c.current.noTap=!0,ie.add(a,{clientX:p,clientY:C,altKey:S,ctrlKey:T,metaKey:P,target:w,event:y})},750)});try{w.setPointerCapture(g)}catch(j){console.log("Fail to capture pointer",j)}},v=y=>{if(c.current.pressed){const{pointerId:w,clientX:x,clientY:p,altKey:C,shiftKey:g,ctrlKey:S,metaKey:T,buttons:P}=y;c.current.pointers[w]={clientX:x,clientY:p},c.current.moving=!0;const D=Object.keys(c.current.pointers).length===2;let j,A,N=0;if(D){const{clientX:$,clientY:z}=Xt(c.current.pointers,w);j=($+x)/2,A=(z+p)/2,N=Ut([$,z],[x,p])}else j=x,A=p;let W=g||C||S||T||P!==1;m!=="drag"&&(W=!W);const Z=!W,M=W;if(Z){c.current.gestureStart||(f.current.style.cursor="move",c.current.gestureStart=!0,clearTimeout(c.current.longTapTimeout),ie.add(r,{deltaX:0,deltaY:0,startX:c.current.startX,startY:c.current.startY,clientX:c.current.startX,clientY:c.current.startY,distanceX:0,distanceY:0,button:c.current.currentButton,altKey:C,shiftKey:g,ctrlKey:S,metaKey:T,target:c.current.target,event:c.current.pointerDownEvent}));const $=j-c.current.prevX,z=A-c.current.prevY,F=j-c.current.startX,Y=A-c.current.startY;ie.add(t,{deltaX:$,deltaY:z,startX:c.current.startX,startY:c.current.startY,clientX:j,clientY:A,distanceX:F,distanceY:Y,button:c.current.currentButton,altKey:C,shiftKey:g,ctrlKey:S,metaKey:T,target:c.current.target,event:y})}if(M){c.current.gestureStart||(f.current.style.cursor="move",c.current.gestureStart=!0,clearTimeout(c.current.longTapTimeout));const $=j-c.current.prevX,z=A-c.current.prevY,{target:F}=c.current;if(ie.add(o,{deltaX:$,deltaY:z,button:c.current.currentButton,altKey:C,shiftKey:g,ctrlKey:S,metaKey:T,target:F,event:y}),N!==c.current.prevDistance&&l){const Y=c.current.prevDistance-N;Math.abs(Y)>0&&(ie.add(l,{scale:Y*3,clientX:j,clientY:A,event:y}),c.current.prevDistance=N)}}c.current.prevX=j,c.current.prevY=A}},E=y=>{const{clientX:w,clientY:x,altKey:p,shiftKey:C,ctrlKey:g,metaKey:S,target:T,pointerId:P}=y;if(c.current.pointers[P]){if(delete c.current.pointers[P],c.current.mainPointer!==P){const{clientX:D,clientY:j}=c.current.pointers[c.current.mainPointer];Object.assign(c.current,{prevX:D,prevY:j,prevDistance:0,startDistance:0});return}for(;Object.keys(c.current.pointers).length>0;){c.current.mainPointer=Number(Object.keys(c.current.pointers)[0]);try{c.current.target.setPointerCapture(c.current.mainPointer);const{clientX:D,clientY:j}=c.current.pointers[c.current.mainPointer];Object.assign(c.current,{prevX:D,prevY:j,prevDistance:0,startDistance:0});return}catch(D){console.log("Fails to set pointer capture",D),c.current.mainPointer=void 0,delete c.current.pointers[Object.keys(c.current.pointers)[0]]}}if(c.current.mainPointer=void 0,c.current.pressed=!1,clearTimeout(c.current.longTapTimeout),c.current.moving)c.current.moving=!1,ie.add(n,{deltaX:w-c.current.prevX,deltaY:x-c.current.prevY,startX:c.current.startX,startY:c.current.startY,clientX:w,clientY:x,distanceX:w-c.current.startX,distanceY:x-c.current.startY,button:c.current.currentButton,altKey:p,shiftKey:C,ctrlKey:g,metaKey:S,event:y}),f.current.style.cursor="auto";else{const D=Date.now();c.current.noTap?c.current.noTap=!1:c.current.timeStart-D<300&&ie.add(s,{clientX:w,clientY:x,altKey:p,shiftKey:C,ctrlKey:g,metaKey:S,target:T,event:y})}}};return k("div",{onWheel:h,onPointerDown:b,onPointerMove:v,onPointerUp:E,onPointerOut:E,onPointerLeave:E,onPointerCancel:E,onDoubleClick:y=>{const{clientX:w,clientY:x,altKey:p,shiftKey:C,ctrlKey:g,metaKey:S,target:T}=y;ie.add(u,{clientX:w,clientY:x,altKey:p,shiftKey:C,ctrlKey:g,metaKey:S,target:T,event:y})},style:{touchAction:"none"},ref:f,children:e})},at=({onResize:e,...t})=>{const[r]=Q(o=>[o.getBoardState]);return k(Ne,{onDrag:({deltaX:o,deltaY:s,event:a})=>{a.stopPropagation();const{scale:u}=r();e({width:o/u,height:s/u})},children:k("div",{...t})})};let Sn={data:""},bn=e=>typeof window=="object"?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||Sn,_n=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,En=/\/\*[^]*?\*\/| +/g,Wt=/\n+/g,de=(e,t)=>{let r="",n="",o="";for(let s in e){let a=e[s];s[0]=="@"?s[1]=="i"?r=s+" "+a+";":n+=s[1]=="f"?de(a,s):s+"{"+de(a,s[1]=="k"?"":t)+"}":typeof a=="object"?n+=de(a,t?t.replace(/([^,])+/g,u=>s.replace(/(^:.*)|([^,])+/g,l=>/&/.test(l)?l.replace(/&/g,u):u?u+" "+l:l)):s):a!=null&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=de.p?de.p(s,a):s+":"+a+";")}return r+(t&&o?t+"{"+o+"}":o)+n},ce={},Vt=e=>{if(typeof e=="object"){let t="";for(let r in e)t+=r+Vt(e[r]);return t}return e},Cn=(e,t,r,n,o)=>{let s=Vt(e),a=ce[s]||(ce[s]=(l=>{let m=0,f=11;for(;m<l.length;)f=101*f+l.charCodeAt(m++)>>>0;return"go"+f})(s));if(!ce[a]){let l=s!==e?e:(m=>{let f,c,h=[{}];for(;f=_n.exec(m.replace(En,""));)f[4]?h.shift():f[3]?(c=f[3].replace(Wt," ").trim(),h.unshift(h[0][c]=h[0][c]||{})):h[0][f[1]]=f[2].replace(Wt," ").trim();return h[0]})(e);ce[a]=de(o?{["@keyframes "+a]:l}:l,r?"":"."+a)}let u=r&&ce.g?ce.g:null;return r&&(ce.g=ce[a]),((l,m,f,c)=>{c?m.data=m.data.replace(c,l):m.data.indexOf(l)===-1&&(m.data=f?l+m.data:m.data+l)})(ce[a],t,n,u),a},wn=(e,t,r)=>e.reduce((n,o,s)=>{let a=t[s];if(a&&a.call){let u=a(r),l=u&&u.props&&u.props.className||/^go/.test(u)&&u;a=l?"."+l:u&&typeof u=="object"?u.props?"":de(u,""):u===!1?"":u}return n+o+(a??"")},"");function H(e){let t=this||{},r=e.call?e(t.p):e;return Cn(r.unshift?r.raw?wn(r,[].slice.call(arguments,1),t.p):r.reduce((n,o)=>Object.assign(n,o&&o.call?o(t.p):o),{}):r,bn(t.target),t.g,t.o,t.k)}H.bind({g:1}),H.bind({k:1});function xn(e,t,r,n){de.p=t}var In=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,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))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(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r};const On=H`
|
|
59
|
+
*/var Ct;function wr(){return Ct||(Ct=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=d,t=Et();function r(f,c){return f===c&&(f!==0||1/f===1/c)||f!==f&&c!==c}var n=typeof Object.is=="function"?Object.is:r,o=t.useSyncExternalStore,s=e.useRef,a=e.useEffect,u=e.useMemo,l=e.useDebugValue;function m(f,c,h,S,v){var E=s(null),T;E.current===null?(T={hasValue:!1,value:null},E.current=T):T=E.current;var y=u(function(){var _=!1,g,w,I=function(A){if(!_){_=!0,g=A;var B=S(A);if(v!==void 0&&T.hasValue){var W=T.value;if(v(W,B))return w=W,W}return w=B,B}var Q=g,M=w;if(n(Q,A))return M;var $=S(A);return v!==void 0&&v(M,$)?M:(g=A,w=$,$)},P=h===void 0?null:h,D=function(){return I(c())},j=P===null?void 0:function(){return I(P())};return[D,j]},[c,h,S,v]),C=y[0],x=y[1],p=o(f,C,x);return a(function(){T.hasValue=!0,T.value=p},[p]),l(p),p}Ze.useSyncExternalStoreWithSelector=m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Ze}(function(e){process.env.NODE_ENV==="production"?e.exports=Er():e.exports=wr()})(yr);const Cr=me(He),{useSyncExternalStoreWithSelector:xr}=Cr;function $e(e,t=e.getState,r){const n=xr(e.subscribe,e.getState,e.getServerState||e.getState,t,r);return d.useDebugValue(n),n}const he=(e,t)=>e.classList&&e.classList.contains(t),Oe=(e,t)=>he(e,t)?e:e.parentNode?Oe(e.parentNode,t):!1,Ae=([e,t],[r,n])=>{const o=Math.abs(e-r),s=Math.abs(t-n);return Math.hypot(o,s)},xt=(e,t,r)=>{const n=r*Math.PI/180,o=e*Math.cos(n)-t*Math.sin(n),s=e*Math.sin(n)+t*Math.cos(n);return[o,s]},Qe=([e,t],{scale:r,rotate:n,translateX:o,translateY:s})=>{const a=(e-o)/r,u=(t-s)/r;return xt(a,u,-n)},Le=([e,t],{scale:r,rotate:n,translateX:o,translateY:s})=>{const[a,u]=xt(e,t,n);return[a*r+o,u*r+s]},It=(e,t,r,n)=>{const o=e.x,s=e.y,a=t.x,u=t.y,l=r.x,m=r.y,f=a-o,c=u-s,h=o-l,S=s-m,v=f*f+c*c,E=2*(h*f+S*c),T=h*h+S*S-n*n,y=E*E-4*v*T;if(y<0)return[];const C=(-E+Math.sqrt(y))/(2*v),x=(-E-Math.sqrt(y))/(2*v),p=[];return C>=0&&C<=1&&p.push({x:o+C*f,y:s+C*c}),x>=0&&x<=1&&p.push({x:o+x*f,y:s+x*c}),p},et=(e,t)=>e.x>t.left&&e.x<t.left+t.width&&e.y>t.top&&e.y<t.top+t.height,Ir=(e,t)=>Array.from(e.querySelectorAll(".corner")).every(n=>{const{top:o,left:s}=n.getBoundingClientRect();return et({x:s,y:o},t)}),Or=(e,t)=>{const r=t.getBoundingClientRect();return Ir(e,r)},ze=(e,t)=>{try{const r=document.getElementById(`${e}__${t}`);return r||console.error(`Missing item ${t}`),r}catch{console.error(`Error while getting item with id ${t} inside wrapper`,e);return}},Te=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},Tr=(e,t)=>{const r=e.reduce((n,o)=>{const s=ze(t,o);if(!s)return n||null;const{left:a,right:u,top:l,bottom:m}=s.getBoundingClientRect();let f;return n?f=n:f={left:a,top:l,right:u,bottom:m},f.left=Math.min(a,f.left),f.top=Math.min(l,f.top),f.right=Math.max(u,f.right),f.bottom=Math.max(m,f.bottom),f},null);return r&&(r.width=r.right-r.left,r.height=r.bottom-r.top,r)},Ot=(e,t,r=null)=>(r===null&&(r=new Set),!Array.isArray(t)||t.length===0?[]:t.map(n=>r.has(n)?[]:(r.add(n),e[n]?[n,...Ot(e,e[n].linkedItems,r)]:[])).flat()),Tt=(e,t,r)=>{const n=new Set(Ot(e,r));return t.filter(o=>n.has(o))},kr=({x:e,y:t,width:r,height:n},{type:o="grid",size:s=1,offset:a={x:0,y:0}})=>{const[u,l]=[e+r/2-a.x,t+n/2-a.y];let m,f,c,h,S,v,E,T,y,C;const x=s/1.1547;switch(o){case"grid":m=Math.round(u/s)*s,f=Math.round(l/s)*s;break;case"hexH":c=2*x,h=3*s,S=Math.round(u/c)*c,E=Math.round(l/h)*h,v=S>u?S-x:S+x,T=E>l?E-1.5*s:E+1.5*s,y=Math.hypot(S-u,E-l),C=Math.hypot(v-u,T-l),y<C?(m=S,f=E):(m=v,f=T);break;case"hexV":c=3*s,h=2*x,S=Math.round(u/c)*c,E=Math.round(l/h)*h,v=S>u?S-1.5*s:S+1.5*s,T=E>l?E-x:E+x,y=Math.hypot(S-u,E-l),C=Math.hypot(v-u,T-l),y<C?(m=S,f=E):(m=v,f=T);break;default:m=e+r/2,f=t+n/2}return{x:m+a.x-r/2,y:f+a.y-n/2}},kt=["#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"],Pt=()=>kt[Math.floor(Math.random()*kt.length)],Pr=!1,tt=({wire:e,storeName:t,noSync:r=[],defaultValue:n},o)=>(s,a,u)=>{s({ready:!1});const l=[];(async()=>{try{const S=await e.call(`${t}_getValue`);Pr&&console.log("init from peer with value",S),s(v=>({...v,...S}))}catch{n!==void 0&&s(n)}l.push(await e.register(`${t}_getValue`,()=>Object.fromEntries(Object.entries(a()).filter(([S,v])=>typeof v!="function"&&!r.includes(S))),{invoke:"first"})),l.push(e.subscribe(`${t}_call`,([S,v])=>{c[S](...v)})),s({ready:!0})})();const f=o(s,a,u),c={...f},h=Object.fromEntries(Object.entries(f).map(([S,v])=>typeof v=="function"&&!S.startsWith("get")&&!r.includes(S)?[S,(...T)=>{const y=v(...T);return e.publish(`${t}_call`,[S,T]),y}]:[S,v]));return h.unsub=()=>{l.forEach(S=>S())},h};function Ye(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,o]of e)if(!Object.is(o,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 Mt=d.createContext(),Mr=(e,t)=>({items:{},getItems:()=>t().items,setItems:r=>e({items:r}),updateItems:(r,n=!1)=>e(o=>n?{items:Object.fromEntries(Object.entries(o.items).map(([a,u])=>r[a]?[a,{...u,...r[a]}]:[a,u]))}:{items:{...o.items,...r}}),moveItems:(r,n)=>e(({items:o})=>{const s={...o};return r.forEach(a=>{const u=o[a];u&&(s[a]={...u,x:(u.x||0)+n.x,y:(u.y||0)+n.y,moving:!0})}),{items:s}})}),jr=(e,t)=>({itemIds:[],setItemIds:r=>e({itemIds:r}),getItemIds:()=>t().itemIds,insert:(r,n)=>e(o=>{const s=[...o.itemIds];return s.splice(r,0,n),{itemIds:s}}),remove:r=>e(n=>{const o=[...n.itemIds];return o.splice(r,1),{itemIds:o}}),updateItemIds:(r,n)=>e(o=>{const s=[...o.itemIds];return s[r]=n,{items:s}}),updateManyItemIds:r=>e(n=>({items:n.itemIds.map((o,s)=>r[s]!==void 0?r[s]:o)}))}),Dr=(e,t)=>({removeItemsById:r=>e(n=>({itemIds:n.itemIds.filter(o=>!r.includes(o)),items:Object.fromEntries(Object.entries(n.items).filter(([o])=>!r.includes(o)))})),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(o=>{let s;const a=r.map(({id:u})=>u);if(n){const u=o.itemIds.findIndex(l=>l===n);s=[...o.itemIds],s.splice(u,0,...a)}else s=[...o.itemIds,...a];return{items:{...o.items,...Object.fromEntries(r.map(u=>[u.id,u]))},itemIds:s}})}),Rr=(e,t)=>({boardConfig:{},getBoardConfig:()=>t().boardConfig,setBoardConfig:r=>e({boardConfig:r}),updateBoardConfig:r=>e(n=>({boardConfig:{...n.boardConfig,...r}}))}),$r=(e,t)=>({session:{},getSessionInfo:()=>t().session,setSessionInfo:r=>e({session:r}),updateSessionInfo:r=>e(n=>({session:{...n.session,...r}}))}),jt=({storeName:e,children:t,defaultValue:r})=>{const{wire:n}=Ie("room"),[o,s]=d.useState(!1),[a]=d.useState(()=>De(tt({wire:n,storeName:e,defaultValue:r},(...u)=>({...Mr(...u),...jr(...u),...Dr(...u),...Rr(...u),...$r(...u)}))));return d.useEffect(()=>{const u=a.subscribe(l=>{l.ready&&(u(),s(!0))})},[a]),o?k(Mt.Provider,{value:a,children:t}):null},oe=(e,t)=>{const r=d.useContext(Mt);return $e(r,e,t||Ye)},Ar=()=>{const[e,t]=oe(n=>[n.itemIds,n.items]);return d.useMemo(()=>e.map(n=>t[n]),[e,t])},Lr=()=>{const[e,t,r]=oe(a=>[a.items,a.itemIds,a.getItemList]),[n,o]=d.useState(r()),[,s]=d.useTransition();return d.useEffect(()=>{const a=r();s(()=>{o(a)})},[e,t,r]),n},Dt=5e4,Rt=d.createContext(),zr=(e,t)=>({config:{itemTemplates:{},actions:{},uid:null,itemExtent:{x:0,y:0,radius:0},boardWrapperRect:{},boardSize:Dt},updateConfiguration:r=>e(n=>({config:{...n.config,...r}})),getConfiguration:()=>t().config}),Yr=(e,t)=>({boardState:{movingItems:!1,selecting:!1,zooming:!1,panning:!1,translateX:0,translateY:0,scale:1,rotate:0},updateBoardState:r=>e(n=>({boardState:{...n.boardState,...r}})),getBoardState:()=>t().boardState}),Br=(e,t)=>({interactions:{},getInteractions:()=>t().interactions,register:(r,n)=>e(o=>{const s=[...o.interactions[r]||[]];return s.push(n),{interactions:{...o.interactions,[r]:s}}}),unregister:(r,n)=>e(o=>{const s=(o.interactions[r]||[]).filter(a=>a!==n);return{interactions:{...o.interactions,[r]:s}}}),callInteractions:(r,n)=>{t().interactions[r]&&t().interactions[r].forEach(o=>{setTimeout(()=>o(n),0)})}}),Xr=(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(o=>!r.includes(o))})),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 o=n.selectionBox;return!o||!r||o.top!==r.top||o.left!==r.left||o.width!==r.width||o.height!==r.height?{selectionBox:r}:{}})}),$t=({children:e})=>{const[t]=d.useState(()=>De((...r)=>({...zr(...r),...Yr(...r),...Br(...r),...Xr(...r)})));return k(Rt.Provider,{value:t,children:e})},Z=(e,t)=>{const r=d.useContext(Rt);return $e(r,e,t||Ye)},Nr=()=>{const[e]=Z(t=>[t.selection]);return e},Ur=()=>{const[e]=Z(t=>[t.getSelection]);return e};function rt(e){const t=d.useRef(e);return t.current=e,d.useMemo(()=>Object.freeze({get current(){return t.current}}),[])}function Wr(e){const t=rt(e);d.useEffect(()=>()=>{t.current()},[])}function nt(e,t,r,n=0){const o=d.useRef(),s=d.useRef(),a=d.useRef(),u=()=>{o.current&&(clearTimeout(o.current),o.current=void 0),s.current&&(clearTimeout(s.current),s.current=void 0)};return Wr(u),d.useMemo(()=>{const l=()=>{if(!a.current)return;const f=a.current;a.current=void 0,e.apply(f.this,f.args),u()},m=function(...f){o.current&&clearTimeout(o.current),a.current={args:f,this:this},o.current=setTimeout(l,r),n>0&&!s.current&&(s.current=setTimeout(l,n))};return Object.defineProperties(m,{length:{value:e.length},name:{value:`${e.name||"anonymous"}__debounced__${r}`}}),m},[r,n,...t])}const Vr=100,Fr=1e3,Kr=.8,Hr=({x:e,y:t,scale:r,rotate:n,itemExtent:o,boardWrapperRect:s,boardSize:a})=>{let[u,l]=[e,t];const m=Qe([s.width/2,s.height/2],{translateX:u,translateY:l,scale:r,rotate:n}),f={x:o.x+a/2,y:o.y+a/2},c={x:a/2,y:a/2},h=Ae(m,[f.x,f.y]),S=Math.min(s.width,s.height),v=o.radius+S/2/r-Vr/r;if(h>v){const y=It({x:m[0],y:m[1]},f,f,v-1/r)[0],[C,x]=Le([-y.x,-y.y],{translateX:s.width/2,translateY:s.height/2,scale:r,rotate:n});u=C,l=x}const E=Ae(m,[c.x,c.y]),T=a/2-Ae([0,0],[s.width,s.height])/r;if(E>T){const y=It({x:m[0],y:m[1]},c,c,T-1/r)[0];if(y){const[C,x]=Le([-y.x,-y.y],{translateX:s.width/2,translateY:s.height/2,scale:r,rotate:n});u=C,l=x}}return[u,l]},ve=()=>{const[e,t,r,n,o]=Z(p=>[p.getBoardState,p.updateBoardState,p.config.itemExtent,p.getConfiguration,p.updateConfiguration]),s=d.useRef([.15,5]),[a]=oe(p=>[p.getItemList]),u=d.useCallback(()=>{const{translateX:p,translateY:_,scale:g,rotate:w}=e();return{translateX:p,translateY:_,scale:g,rotate:w}},[e]),l=d.useCallback((p,_)=>Qe([p,_],e()),[e]),m=d.useCallback((p,_)=>Le([p,_],e()),[e]),f=d.useCallback((p,_)=>{const{scale:g,rotate:w}=e();return Qe([p,_],{translateX:0,translateY:0,rotate:w,scale:g})},[e]),c=d.useCallback(p=>p>s.current[1]?s.current[1]:p<s.current[0]?s.current[0]:p,[]),h=d.useCallback(p=>{const{itemExtent:_,boardWrapperRect:g,boardSize:w}=n(),I=e(),{translateX:P,translateY:D,scale:j,rotate:A}={...I,...p(I)},B=c(j);let[W,Q]=[P,D];(P!==I.translateX||D!==I.translateY)&&([W,Q]=Hr({x:P,y:D,scale:B,rotate:A,itemExtent:_,boardWrapperRect:g,boardSize:w})),t({translateX:W,translateY:Q,scale:B,rotate:A})},[c,e,n,t]),S=d.useCallback(p=>{let _=g=>({...g,...p});typeof p=="function"&&(_=p),h(g=>({...g,..._({translateX:g.translateX,translateY:g.translateY})}))},[h]),v=d.useCallback(({to:p,factor:_})=>{const{boardWrapperRect:g}=n();let w=p;w||(w={x:g.left+g.width/2,y:g.top+g.height/2});const I=e(),P=c(I.scale*_),D=w.x-g.left,j=w.y-g.top,A=D-(D-I.translateX)*P/I.scale,B=j-(j-I.translateY)*P/I.scale;h(W=>({...W,translateX:A,translateY:B,scale:P}))},[c,e,n,h]),E=d.useCallback(({x:p,y:_,radius:g})=>{const{rotate:w}=e(),{boardWrapperRect:I,boardSize:P}=n(),D=I.width/(g*2),j=I.height/(g*2),A=c(Math.min(D,j)*Kr),[B,W]=Le([-P/2-p,-P/2-_],{translateX:I.width/2,translateY:I.height/2,scale:A,rotate:w});h(Q=>({...Q,translateX:B,translateY:W,scale:A}))},[c,e,n,h]),T=d.useCallback(()=>{const{boardWrapperRect:p,boardSize:_}=n(),[g,w]=l(p.width/2,p.height/2);return{x:g-_/2,y:w-_/2}},[l,n]),y=d.useCallback(()=>{const p=a(),{boardSize:_,uid:g}=n(),w=p.reduce((P,D)=>{const j=ze(g,D.id);return j&&(P.left=Math.min(D.x,P.left),P.top=Math.min(D.y,P.top),P.right=Math.max(D.x+j.offsetWidth,P.right),P.bottom=Math.max(D.y+j.offsetHeight,P.bottom)),P},{left:_/2,top:_/2,right:-_/2,bottom:-_/2}),I={x:(w.right+w.left)/2,y:(w.bottom+w.top)/2};I.radius=Math.max(Ae([I.x,I.y],[w.left,w.top]),Fr),o({itemExtent:I})},[n,a,o]),C=d.useCallback(p=>{let _=()=>p;typeof p=="function"&&(_=p),h(g=>({...g,rotate:_(g.rotate)})),y(),E(r)},[r,h,y,E]),x=nt(()=>y(),[y],200);return d.useEffect(()=>{window.debugUpdateExtent=()=>y(),window.debugDisplayExtent=()=>console.log(n().itemExtent)},[n,y]),{setDim:h,rotateBoard:C,moveBoard:S,getDim:u,zoomTo:v,zoomToCenter:v,zoomToExtent:E,getCenter:T,updateItemExtent:x,vectorFromWrapperToBoard:f,fromWrapperToBoard:l,fromBoardToWrapper:m}},ot=e=>{const[t,r,n]=Z(({register:a,unregister:u,callInteractions:l})=>[a,u,l]),o=d.useCallback(a=>(t(e,a),()=>{r(e,a)}),[e,t,r]),s=d.useCallback(a=>{n(e,a)},[n,e]);return{register:o,call:s}},Be=()=>{const{call:e}=ot("place"),{call:t}=ot("delete"),{getCenter:r,updateItemExtent:n}=ve(),[o,s,a,u]=Z(M=>[M.clear,M.reverse,M.unselect,M.getConfiguration]),{getItems:l,getItemIds:m,setItemIds:f,updateItems:c,moveItems:h,removeItemsById:S,getItemList:v,insertItems:E,setItemList:T}=oe(({getItems:M,getItemIds:$,setItemIds:Y,updateItems:F,moveItems:L,removeItemsById:K,getItemList:q,insertItems:re,setItemList:ee})=>({getItems:M,getItemIds:$,setItemIds:Y,updateItems:F,moveItems:L,removeItemsById:K,getItemList:q,insertItems:re,setItemList:ee})),y=d.useCallback((M,$,Y=!1)=>{let F=$;typeof $=="object"&&(F=()=>$);const L=m().filter(ee=>M.includes(ee)),K=l(),q=L.map(ee=>{const se=K[ee];return Y?[ee,F(se)]:[ee,F({...se})]}).filter(([,ee])=>ee);if(q.length===0)return;const re=Object.fromEntries(q);c(re,Y),n()},[m,l,n,c]),C=d.useCallback(M=>{T(M),o(),n()},[o,T,n]),x=d.useCallback((M,$,Y=!1)=>{y([M],$,Y)},[y]),p=d.useCallback((M,$)=>{h(Tt(l(),m(),M),$)},[m,l,h]),_=d.useCallback(M=>{const $=m(),Y=$.filter(L=>!M.includes(L)),F=$.filter(L=>M.includes(L));f([...Y,...F])},[m,f]),g=d.useCallback((M,{type:$,size:Y}={})=>{const{uid:F}=u();y(M,L=>{const K=ze(F,L.id);if(!K)return;const q={type:$||"grid",size:Y||1,offset:{x:0,y:0},...L.grid};return kr({x:L.x,y:L.y,width:K.clientWidth,height:K.clientHeight},q)},!0)},[u,y]),w=d.useCallback((M,$)=>{const Y=Tt(l(),m(),M);_(Y),y(Y,{moving:!1},!0),g(Y,$),e(M),n()},[y,e,m,l,_,g,n]),I=d.useCallback(M=>{f(M)},[f]),P=d.useCallback(M=>{const $=m(),Y=$.filter(L=>M.includes(L)),F=$.map(L=>M.includes(L)?Y.pop():L);f(F),s()},[m,s,f]),D=d.useCallback((M,$)=>{const Y=l(),F=Object.fromEntries($.map((q,re)=>{const ee=Y[M[re]];return[q,{x:ee.x,y:ee.y}]}));y(M,q=>F[q.id],!0);const L=Object.fromEntries(M.map((q,re)=>[q,$[re]])),K=m().map(q=>M.includes(q)?L[q]:q);f(K)},[l,y,m,f]),j=d.useCallback((M,$)=>{const Y=r(),F=M.map((L,K)=>!L.x||!L.y?{...L,x:Y.x+2*K,y:Y.y+2*K}:L);E(F,$),w(M.map(({id:L})=>L))},[r,E,w]),A=d.useCallback((M,$)=>{j([M],$)},[j]),B=d.useCallback(M=>{a(M),S(M),t(M)},[a,S,t]),W=d.useCallback(M=>{const $=l();return M.map(Y=>$[Y])},[l]),Q=d.useCallback(({target:M,clientX:$,clientY:Y},{returnLocked:F=!1,passLocked:L=!1}={})=>{if(["INPUT","TEXTAREA"].includes(M.tagName))return null;const K=Oe(M,"item");if(K){if(he(K,"selected"))return K;if(!L&&he(K,"locked")&&!he(M,"passthrough"))return F?K:null;if(he(M,"passthrough")){const q=m(),{uid:re}=u(),ee=q.reduce((se,le)=>{const Se=ze(re,le),_e=Se.getBoundingClientRect();return et({x:$,y:Y},_e)&&se.unshift(Se),se},[]);for(let se=0;se<ee.length;se+=1){const le=ee[se];if(le!==K&&(L||!he(le,"locked")))return le}return null}}return K},[u,m]);return{putItemsOnTop:_,batchUpdateItems:y,updateItemOrder:I,moveItems:p,placeItems:w,updateItem:x,swapItems:D,reverseItemsOrder:P,setItemList:C,pushItem:A,pushItems:j,removeItems:B,getItemList:v,findElementUnderPointer:Q,getItems:W}};var qr=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,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(o of t.entries())if(!r.has(o[0]))return!1;for(o of t.entries())if(!e(o[1],r.get(o[0])))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(o of t.entries())if(!r.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(r)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(t[o]!==r[o])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(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r};function Gr(e,t,r,n=0){d.useEffect(nt(e,t,r,n),t)}const Jr=(e,t)=>{if(e.type in t){const r=t[e.type].defaultActions;return typeof r=="function"?r(e):r}return[]},At=(e,t)=>{const{actions:r=Jr(e,t)}=e;return r.map(n=>typeof n=="string"?{name:n}:n)},Zr=()=>{const[e,t]=oe(c=>[c.items,c.getItems]),[r,n,o]=Z(c=>[c.config.itemTemplates,c.selection,c.getSelection]),[s,a]=d.useState([]),u=d.useRef(!1),[,l]=d.useTransition();d.useEffect(()=>(u.current=!0,()=>{u.current=!1}),[]);const m=d.useCallback(c=>{const h=t();if(c)return[c,c.map(v=>h[v])];const S=o();return[S,S.map(v=>h[v])]},[t,o]),f=d.useCallback(()=>{const[c,h]=m();if(c.length>0){if(!u.current)return;const S=h.reduce((v,E)=>{const T=At(E,r);return v.filter(y=>T.some(C=>qr(y,C)))},At(h[0],r));l(()=>{a(S)})}else l(()=>{a([])})},[m,r]);return Gr(()=>f(),[e,n,f],100),{availableActions:s}},Qr=()=>{const[e]=Z(t=>[t.selectionBox]);return e};let pe=(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 Lt=d.createContext(),st=e=>{localStorage.setItem("user",JSON.stringify(e))},en=()=>{if(localStorage.user){const t={name:"Player",color:Pt(),uid:pe(),...JSON.parse(localStorage.user)};return st(t),t}const e={name:"Player",color:Pt(),uid:pe()};return st(e),e},tn=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:o})=>o===n)},addUser:n=>t(o=>({users:{...o.users,[n.id]:n}})),updateUser:(n,o)=>t(s=>{if(!s.users[n])return{};const a={...s.users[n],...o,id:n,uid:s.users[n].uid};return a.id===e&&st(a),setTimeout(()=>r().electSpaceMaster(),100),{users:{...s.users,[n]:a}}}),removeUser:n=>t(o=>{const s={...o.users};return delete s[n],setTimeout(()=>r().electSpaceMaster(),100),{users:s}}),updateCurrentUser:n=>r().updateUser(e,n),joinSpace:n=>r().updateUser(e,{space:n,spaceJoinedTimestamp:Date.now()}),electSpaceMaster:()=>{const n=r().getLocalUsers(),o={uid:null,timestamp:Date.now()};Object.values(n).forEach(({spaceJoinedTimestamp:s,id:a})=>{s<o.timestamp&&(o.id=a,o.timestamp=s)}),t({isSpaceMaster:o.id===e})}}),rn=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}})}),zt=({storeName:e,children:t})=>{const{wire:r,isMaster:n}=Ie("room"),[o,s]=d.useState(null),[a,u]=d.useState(!1),l=d.useRef(!1);return d.useEffect(()=>{let m=!0;const f=[];if(!o&&!l.current)return l.current=!0,(()=>{const h=De(tt({wire:r,storeName:e,noSync:["updateCurrentUser","joinSpace","isSpaceMaster","electSpaceMaster"]},(...v)=>({...tn(r.userId)(...v),...rn(...v)}))),S=h.subscribe(v=>{v.ready&&(S(),m&&s(h))})})(),()=>{m=!1,l.current=!1,f.forEach(h=>h())}},[o,e,r,r.userId]),d.useEffect(()=>{if(o)return o.getState().addUser({...en(),id:r.userId}),u(!0),()=>{o.getState().removeUser(r.userId)}},[n,o,r]),d.useEffect(()=>{if(o){const m=r.subscribe("userLeave",f=>{o.getState().removeUser(f)});return()=>{m()}}},[n,o,r]),d.useEffect(()=>{n&&o&&o.getState().updateCurrentUser({isMaster:n})},[n,o,r]),a?k(Lt.Provider,{value:o,children:t}):null},ye=(e,t)=>{const r=d.useContext(Lt);return $e(r,e,t||Ye)},nn=()=>{const[e,t,r,n,o]=ye(u=>[u.isSpaceMaster,u.getUser(),u.users,u.updateCurrentUser,u.joinSpace]),s=d.useMemo(()=>Object.values(r),[r]),a=d.useMemo(()=>{const{space:u}=t;return s.filter(({space:l})=>l===u)},[t,s]);return{isSpaceMaster:e,currentUser:t,updateCurrentUser:n,users:s,localUsers:a,joinSpace:o}},on=()=>{const[e,t,r]=oe(o=>[o.boardConfig,o.getBoardConfig,o.setBoardConfig]),n=d.useCallback(o=>{let s=o;typeof o=="object"&&(s=()=>o);const a=t(),u=s(a);r(u)},[t,r]);return[e,n]},sn=()=>{const[e]=Z(t=>[t.boardState]);return e},an=()=>{const[e,t,r,n]=oe(o=>[o.getSessionInfo,o.setSessionInfo,o.updateSessionInfo,o.session]);return{getSessionInfo:e,setSessionInfo:t,sessionInfo:n,updateSessionInfo:r}},Yt=d.createContext(),cn=({user:{name:e,uid:t,color:r},content:n})=>({type:"message",user:{name:e,uid:t,color:r},content:n,uid:pe(),timestamp:new Date().toISOString()}),un=(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 o=cn({user:r,content:n});o&&t().addMessage(o)}}),Bt=({storeName:e,children:t,defaultValue:r=[]})=>{const{wire:n}=Ie("room"),[o]=d.useState(()=>De(tt({wire:n,storeName:e,defaultValue:r,noSync:["sendMessage"]},(...s)=>({...un(...s)}))));return k(Yt.Provider,{value:o,children:t})},ln=(e,t)=>{const r=d.useContext(Yt);return $e(r,e,t||Ye)},fn=()=>{},dn=(e=fn)=>{const t=ye(a=>a.getUser()),[r,n,o]=ln(a=>[a.messages,a.setMessages,a.sendMessage]);d.useEffect(()=>{r.length&&e()},[r,e]);const s=d.useCallback(a=>{o(t,a)},[t,o]);return{messages:r,setMessages:n,sendMessage:s}},Xt=({children:e,session:t})=>{const r=ye(n=>n.joinSpace);return d.useEffect(()=>(r(t),()=>{r(null)}),[r,t]),e},mn=({socket:e,room:t,session:r,items:n=[],messages:o=[],LoadingComponent:s,...a})=>{const[u]=d.useState(t||pe()),[l]=d.useState(r||pe()),[m]=d.useState(()=>({itemIds:n.map(({id:c})=>c),items:Object.fromEntries(n.map(c=>[c.id,c]))}));return Ie("room")?k(Bt,{storeName:`${l}_messages`,defaultValue:o,children:k($t,{children:k(jt,{storeName:`${l}_item`,defaultValue:m,children:k(Xt,{...a,session:l})})})}):k(vt,{room:u,channel:"room",socket:e,LoadingComponent:s,children:k(zt,{storeName:`${u}_users`,children:k(Bt,{storeName:`${l}_messages`,defaultValue:o,children:k($t,{children:k(jt,{storeName:`${l}_item`,defaultValue:m,children:k(Xt,{...a,session:l})})})})})})},pn=({socket:e,room:t,children:r,LoadingComponent:n})=>{const[o]=d.useState(t||pe());return k(vt,{room:o,channel:"room",socket:e,LoadingComponent:n,children:k(zt,{storeName:`${o}_users`,children:r})})};let gn={data:""},hn=e=>typeof window=="object"?((e?e.querySelector("#_goober"):window._goober)||Object.assign((e||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:e||gn,vn=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,yn=/\/\*[^]*?\*\/| +/g,Nt=/\n+/g,de=(e,t)=>{let r="",n="",o="";for(let s in e){let a=e[s];s[0]=="@"?s[1]=="i"?r=s+" "+a+";":n+=s[1]=="f"?de(a,s):s+"{"+de(a,s[1]=="k"?"":t)+"}":typeof a=="object"?n+=de(a,t?t.replace(/([^,])+/g,u=>s.replace(/(^:.*)|([^,])+/g,l=>/&/.test(l)?l.replace(/&/g,u):u?u+" "+l:l)):s):a!=null&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=de.p?de.p(s,a):s+":"+a+";")}return r+(t&&o?t+"{"+o+"}":o)+n},ce={},Ut=e=>{if(typeof e=="object"){let t="";for(let r in e)t+=r+Ut(e[r]);return t}return e},Sn=(e,t,r,n,o)=>{let s=Ut(e),a=ce[s]||(ce[s]=(l=>{let m=0,f=11;for(;m<l.length;)f=101*f+l.charCodeAt(m++)>>>0;return"go"+f})(s));if(!ce[a]){let l=s!==e?e:(m=>{let f,c,h=[{}];for(;f=vn.exec(m.replace(yn,""));)f[4]?h.shift():f[3]?(c=f[3].replace(Nt," ").trim(),h.unshift(h[0][c]=h[0][c]||{})):h[0][f[1]]=f[2].replace(Nt," ").trim();return h[0]})(e);ce[a]=de(o?{["@keyframes "+a]:l}:l,r?"":"."+a)}let u=r&&ce.g?ce.g:null;return r&&(ce.g=ce[a]),((l,m,f,c)=>{c?m.data=m.data.replace(c,l):m.data.indexOf(l)===-1&&(m.data=f?l+m.data:m.data+l)})(ce[a],t,n,u),a},_n=(e,t,r)=>e.reduce((n,o,s)=>{let a=t[s];if(a&&a.call){let u=a(r),l=u&&u.props&&u.props.className||/^go/.test(u)&&u;a=l?"."+l:u&&typeof u=="object"?u.props?"":de(u,""):u===!1?"":u}return n+o+(a??"")},"");function H(e){let t=this||{},r=e.call?e(t.p):e;return Sn(r.unshift?r.raw?_n(r,[].slice.call(arguments,1),t.p):r.reduce((n,o)=>Object.assign(n,o&&o.call?o(t.p):o),{}):r,hn(t.target),t.g,t.o,t.k)}H.bind({g:1}),H.bind({k:1});function bn(e,t,r,n){de.p=t}var En=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,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))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(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r};const it=()=>{const e=navigator.userAgent.toLowerCase();return/mac os ?x 10/.test(e)},wn=(()=>{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})(),Cn=800,Wt=(e,t)=>{const r=Object.keys(e).map(n=>Number(n)).find(n=>n!==t);return e[r]},Vt=([e,t],[r,n])=>{const o=Math.abs(e-r),s=Math.abs(t-n);return Math.hypot(o,s)},ge=()=>{},xn=e=>t=>{const{event:r}=t;return r.isPropagationStopped()?null:e(t)},In=e=>async(...t)=>{try{await e(...t)}catch(r){console.error(r)}};class On{constructor(){ur(this,"lastPromise",Promise.resolve(!0))}add(t,...r){return new Promise((n,o)=>{this.lastPromise=this.lastPromise.then(()=>xn(In(t))(...r)).then(n).catch(o)})}}const ie=new On,Xe=({children:e,onDrag:t=ge,onDragStart:r=ge,onDragEnd:n=ge,onPan:o=ge,onTap:s=ge,onLongTap:a=ge,onDoubleTap:u=ge,onZoom:l,mainAction:m="drag"})=>{const f=d.useRef(null),c=d.useRef({moving:!1,pointers:{},mainPointer:void 0}),h=y=>{const{deltaX:C,deltaY:x,clientX:p,clientY:_,deltaMode:g,ctrlKey:w,altKey:I,metaKey:P,target:D}=y;if(!(I||w&&!it()))if(it()&&!w)ie.add(o,{deltaX:-2*C,deltaY:-2*x,button:1,ctrlKey:w,metaKey:P,target:D,event:y});else{if(l===void 0||!x)return;let j=x;switch(g){case 1:j*=wn;break;case 2:j*=Cn;break}it()&&(j*=2),ie.add(l,{scale:j,clientX:p,clientY:_,event:y})}},S=y=>{const{target:C,button:x,clientX:p,clientY:_,pointerId:g,altKey:w,ctrlKey:I,metaKey:P,isPrimary:D}=y;if(c.current.pointers[g]={clientX:p,clientY:_},D&&(c.current.mainPointer=void 0),c.current.mainPointer!==void 0){if(c.current.mainPointer!==g)try{const{clientX:j,clientY:A}=Wt(c.current.pointers,g),B=(j+p)/2,W=(A+_)/2,Q=Vt([j,A],[p,_]);Object.assign(c.current,{pressed:!0,moving:!1,gestureStart:!1,startX:p,startY:_,prevX:B,prevY:W,startDistance:Q,prevDistance:Q})}catch(j){console.log("Error while getting other pointer. Ignoring",j),c.current.mainPointer}return}c.current.mainPointer=g,Object.assign(c.current,{pressed:!0,moving:!1,gestureStart:!1,startX:p,startY:_,prevX:p,prevY:_,currentButton:x,pointerDownEvent:y,startDistance:0,prevDistance:0,target:C,timeStart:Date.now(),longTapTimeout:setTimeout(async()=>{c.current.noTap=!0,ie.add(a,{clientX:p,clientY:_,altKey:w,ctrlKey:I,metaKey:P,target:C,event:y})},750)});try{C.setPointerCapture(g)}catch(j){console.log("Fail to capture pointer",j)}},v=y=>{if(c.current.pressed){const{pointerId:C,clientX:x,clientY:p,altKey:_,shiftKey:g,ctrlKey:w,metaKey:I,buttons:P}=y;c.current.pointers[C]={clientX:x,clientY:p},c.current.moving=!0;const D=Object.keys(c.current.pointers).length===2;let j,A,B=0;if(D){const{clientX:$,clientY:Y}=Wt(c.current.pointers,C);j=($+x)/2,A=(Y+p)/2,B=Vt([$,Y],[x,p])}else j=x,A=p;let W=g||_||w||I||P!==1;m!=="drag"&&(W=!W);const Q=!W,M=W;if(Q){c.current.gestureStart||(f.current.style.cursor="move",c.current.gestureStart=!0,clearTimeout(c.current.longTapTimeout),ie.add(r,{deltaX:0,deltaY:0,startX:c.current.startX,startY:c.current.startY,clientX:c.current.startX,clientY:c.current.startY,distanceX:0,distanceY:0,button:c.current.currentButton,altKey:_,shiftKey:g,ctrlKey:w,metaKey:I,target:c.current.target,event:c.current.pointerDownEvent}));const $=j-c.current.prevX,Y=A-c.current.prevY,F=j-c.current.startX,L=A-c.current.startY;ie.add(t,{deltaX:$,deltaY:Y,startX:c.current.startX,startY:c.current.startY,clientX:j,clientY:A,distanceX:F,distanceY:L,button:c.current.currentButton,altKey:_,shiftKey:g,ctrlKey:w,metaKey:I,target:c.current.target,event:y})}if(M){c.current.gestureStart||(f.current.style.cursor="move",c.current.gestureStart=!0,clearTimeout(c.current.longTapTimeout));const $=j-c.current.prevX,Y=A-c.current.prevY,{target:F}=c.current;if(ie.add(o,{deltaX:$,deltaY:Y,button:c.current.currentButton,altKey:_,shiftKey:g,ctrlKey:w,metaKey:I,target:F,event:y}),B!==c.current.prevDistance&&l){const L=c.current.prevDistance-B;Math.abs(L)>0&&(ie.add(l,{scale:L*3,clientX:j,clientY:A,event:y}),c.current.prevDistance=B)}}c.current.prevX=j,c.current.prevY=A}},E=y=>{const{clientX:C,clientY:x,altKey:p,shiftKey:_,ctrlKey:g,metaKey:w,target:I,pointerId:P}=y;if(c.current.pointers[P]){if(delete c.current.pointers[P],c.current.mainPointer!==P){const{clientX:D,clientY:j}=c.current.pointers[c.current.mainPointer];Object.assign(c.current,{prevX:D,prevY:j,prevDistance:0,startDistance:0});return}for(;Object.keys(c.current.pointers).length>0;){c.current.mainPointer=Number(Object.keys(c.current.pointers)[0]);try{c.current.target.setPointerCapture(c.current.mainPointer);const{clientX:D,clientY:j}=c.current.pointers[c.current.mainPointer];Object.assign(c.current,{prevX:D,prevY:j,prevDistance:0,startDistance:0});return}catch(D){console.log("Fails to set pointer capture",D),c.current.mainPointer=void 0,delete c.current.pointers[Object.keys(c.current.pointers)[0]]}}if(c.current.mainPointer=void 0,c.current.pressed=!1,clearTimeout(c.current.longTapTimeout),c.current.moving)c.current.moving=!1,ie.add(n,{deltaX:C-c.current.prevX,deltaY:x-c.current.prevY,startX:c.current.startX,startY:c.current.startY,clientX:C,clientY:x,distanceX:C-c.current.startX,distanceY:x-c.current.startY,button:c.current.currentButton,altKey:p,shiftKey:_,ctrlKey:g,metaKey:w,event:y}),f.current.style.cursor="auto";else{const D=Date.now();c.current.noTap?c.current.noTap=!1:c.current.timeStart-D<300&&ie.add(s,{clientX:C,clientY:x,altKey:p,shiftKey:_,ctrlKey:g,metaKey:w,target:I,event:y})}}};return k("div",{onWheel:h,onPointerDown:S,onPointerMove:v,onPointerUp:E,onPointerOut:E,onPointerLeave:E,onPointerCancel:E,onDoubleClick:y=>{const{clientX:C,clientY:x,altKey:p,shiftKey:_,ctrlKey:g,metaKey:w,target:I}=y;ie.add(u,{clientX:C,clientY:x,altKey:p,shiftKey:_,ctrlKey:g,metaKey:w,target:I,event:y})},style:{touchAction:"none"},ref:f,children:e})},at=({onResize:e,...t})=>{const[r]=Z(o=>[o.getBoardState]);return k(Xe,{onDrag:({deltaX:o,deltaY:s,event:a})=>{a.stopPropagation();const{scale:u}=r();e({width:o/u,height:s/u})},children:k("div",{...t})})},Tn=H`
|
|
60
60
|
display: inline-block;
|
|
61
61
|
transition: transform 150ms;
|
|
62
62
|
user-select: none;
|
|
63
63
|
padding: 2px;
|
|
64
64
|
box-sizing: border-box;
|
|
65
|
-
`,
|
|
65
|
+
`,kn=H`
|
|
66
66
|
border: 2px dashed #db5034;
|
|
67
67
|
padding: 0px;
|
|
68
68
|
cursor: pointer;
|
|
@@ -70,19 +70,19 @@ Check the top-level render call using <`+I+">.")}return _}}function sr(i,_){{if(
|
|
|
70
70
|
position: absolute;
|
|
71
71
|
width: 0px;
|
|
72
72
|
height: 0px;
|
|
73
|
-
`,
|
|
73
|
+
`,Pn=H`
|
|
74
74
|
top: 0;
|
|
75
75
|
left: 0;
|
|
76
|
-
`,
|
|
76
|
+
`,Mn=H`
|
|
77
77
|
top: 0;
|
|
78
78
|
right: 0;
|
|
79
|
-
`,
|
|
79
|
+
`,jn=H`
|
|
80
80
|
bottom: 0;
|
|
81
81
|
left: 0;
|
|
82
|
-
`,
|
|
82
|
+
`,Dn=H`
|
|
83
83
|
bottom: 0;
|
|
84
84
|
right: 0;
|
|
85
|
-
`,
|
|
85
|
+
`,Rn=H`
|
|
86
86
|
top: 50%;
|
|
87
87
|
left: 50%;
|
|
88
88
|
`,ct=H`
|
|
@@ -93,17 +93,17 @@ Check the top-level render call using <`+I+">.")}return _}}function sr(i,_){{if(
|
|
|
93
93
|
border: 2px solid #db5034;
|
|
94
94
|
background-color: #db5034;
|
|
95
95
|
cursor: move;
|
|
96
|
-
|
|
96
|
+
`,$n=H`
|
|
97
97
|
cursor: ew-resize;
|
|
98
98
|
right: -6px;
|
|
99
99
|
top: calc(50% - 5px);
|
|
100
|
-
|
|
100
|
+
`,An=H`
|
|
101
101
|
cursor: ns-resize;
|
|
102
102
|
bottom: -6px;
|
|
103
103
|
left: calc(50% - 5px);
|
|
104
|
-
`,
|
|
104
|
+
`,Ln=H`
|
|
105
105
|
cursor: nwse-resize;
|
|
106
106
|
bottom: -6px;
|
|
107
107
|
right: -6px;
|
|
108
|
-
`,Ln=({onReload:e})=>ae("div",{className:`syncboard-error-item ${H({width:"100px",display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"center",color:"red"})}`,children:["Sorry, this item seems broken.",k("button",{onClick:e,children:"Reload it"})]});class zn extends d.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?k(t,{onReload:this.onReload}):this.props.children}}const Yn=e=>{e.target.className=""},Bn=({width:e,height:t,actualWidth:r,actualHeight:n,prevState:o,keepRatio:s})=>{let{width:a,height:u}=o;if([a,u]=[parseFloat(a),parseFloat(u)],(!a||Number.isNaN(Number(a)))&&(a=r),(!u||Number.isNaN(Number(u)))&&(u=n),s){const l=a/u;return{...o,width:(a+e).toFixed(1),height:(u+t/l).toFixed(1)}}return{...o,width:(a+e).toFixed(1),height:(u+t).toFixed(1)}},Nn={w:!0,h:!0,b:!0},Xn=({setState:e,state:{type:t,rotation:r=0,id:n,locked:o,extraClasses:s,...a}={},animate:u="hvr-pop",isSelected:l,itemMap:m,showResizeHandle:f=!0})=>{var g;const c=d.useRef(null),{component:h=()=>null,resizeDirections:b=Nn,resize:v=Bn}=m[t],E=d.useCallback((S,T=!1)=>e(n,S,T),[e,n]);d.useEffect(()=>{c.current.className=u},[u]);const O=["item",n,On];o&&O.push("locked"),l&&(O.push("selected"),O.push(Tn));const y=O.join(" "),w=({width:S=0,height:T=0,keepRatio:P})=>{E(D=>{const{offsetWidth:j,offsetHeight:A}=c.current;return v({prevState:D,width:S,height:T,actualHeight:A,actualWidth:j,keepRatio:P})})},x=({width:S})=>{w({width:S})},p=({height:S})=>{w({height:S})},C=({width:S})=>{w({height:S,width:S,keepRatio:!0})};return k("div",{style:{transform:`rotate(${r}deg`},"data-id":n,className:y,children:ae("div",{style:{display:"flex"},ref:c,onAnimationEnd:Yn,onKeyDown:S=>S.stopPropagation(),onKeyUp:S=>S.stopPropagation(),children:[k(zn,{itemId:n,state:a,ErrorComponent:((g=m==null?void 0:m.error)==null?void 0:g.component)||Ln,children:k(h,{...a,id:n,setState:E})}),k("div",{className:`corner ${ke} ${kn}`}),k("div",{className:`corner ${ke} ${Pn}`}),k("div",{className:`corner ${ke} ${jn}`}),k("div",{className:`corner ${ke} ${Mn}`}),k("div",{className:`center ${ke} ${Dn}`}),f&&ae(mr,{children:[b.b&&k(at,{className:`${ct} ${An}`,onResize:C}),b.h&&k(at,{className:`${ct} ${$n}`,onResize:p}),b.w&&k(at,{className:`${ct} ${Rn}`,onResize:x})]})]})})},Un=d.memo(Xn,({state:e,setState:t,isSelected:r,showResizeHandle:n},{state:o,setState:s,isSelected:a,showResizeHandle:u})=>r===a&&n===u&&t===s&&In(e,o)),Wn=e=>e,Vn=({state:e={},getCurrentUser:t,className:r,...n})=>{if(!n.itemMap[e.type])return null;const{stateHook:o=Wn}=n.itemMap[e.type],{x:s=0,y:a=0,layer:u=0,moving:l,...m}=o(e,{getCurrentUser:t}),f=(u+4)*10+100+(l?5:0);return k("div",{className:r,style:{transform:`translate(${s}px, ${a}px)`,zIndex:f},children:k(Un,{...n,showResizeHandle:n.isSelected&&n.showResizeHandle,state:m})})},Fn=d.memo(Vn),Kn=()=>{const{updateItem:e}=Be(),[t,r]=oe(m=>[m.itemIds,m.items]),[n,o,s,a]=Q(m=>[m.config.boardSize,m.config.showResizeHandle,m.config.itemTemplates,m.selection]),[u]=ye(m=>[m.getUser]),l=H({position:"absolute",top:`${n/2}px`,left:`${n/2}px`,display:"inline-block",lineHeight:0});return t.map(m=>k(Fn,{state:r[m],setState:e,isSelected:a.includes(m),itemMap:s,boardSize:n,getCurrentUser:u,showResizeHandle:o,className:l},m))};function Hn(e=!1){const t=d.useRef(e),r=d.useCallback(()=>t.current,[]);return d.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),r}function qn(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Gn(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}const Jn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function ue(e,...t){const r=Hn(),n=rt(t[1]),o=d.useMemo(()=>function(...s){r()&&(typeof n.current=="function"?n.current.apply(this,s):typeof n.current.handleEvent=="function"&&n.current.handleEvent.apply(this,s))},[]);d.useEffect(()=>{const s=e&&Jn(e,"current")?e.current:e;if(!s)return;const a=t.slice(2);return qn(s,t[0],o,...a),()=>Gn(s,t[0],o,...a)},[e,t[0]])}const Zn=H({zIndex:210,position:"absolute",backgroundColor:"hsla(0, 40%, 50%, 10%)",border:"2px solid hsl(0, 55%, 40%)"}),Qn=(e,t,r=!1)=>{const n=t.getElementsByClassName("selector");if(!n.length)return[];const o=n[0];return Array.from(t.getElementsByClassName("item")).filter(s=>{const a=Te(s),u=e[a];return!u||!r&&u.locked?!1:Or(s,o)}).map(s=>Te(s))},eo=({children:e,moveFirst:t})=>{const[r,n,o,s,a,u]=Q(g=>[g.getSelection,g.clear,g.setSelection,g.select,g.getConfiguration,g.getBoardState,g.updateBoardState]),{findElementUnderPointer:l}=Be(),[m]=oe(g=>[g.getItems]),[f,c]=d.useState({}),[,h]=d.useTransition(),[b,v]=d.useState(!1),E=d.useRef(null),O=d.useRef({moving:!1});return ue(document,"keydown",g=>{g.key==="l"&&v(!0)}),ue(document,"keyup",g=>{g.key==="l"&&v(!1)}),d.useEffect(()=>(n(),()=>{n()}),[n]),d.useEffect(()=>{if(O.current.moving){const g=m(),{boardWrapper:S}=a(),T=Qn(g,S,b);h(()=>{o(T)})}},[a,m,f,o,b]),k(Ne,{onDragStart:async g=>{await l(g)||(O.current.moving=!0,h(()=>{u({selecting:!0})}),E.current.style.cursor="crosshair")},onDrag:({distanceY:g,distanceX:S,startX:T,startY:P})=>{if(O.current.moving){const{top:D,left:j}=E.current.getBoundingClientRect(),A=T-j,N=P-D;S>0?(O.current.left=A,O.current.width=S):(O.current.left=A+S,O.current.width=-S),g>0?(O.current.top=N,O.current.height=g):(O.current.top=N+g,O.current.height=-g),c({...O.current,moving:!0})}},onDragEnd:()=>{O.current.moving&&(h(()=>{u({selecting:!1})}),O.current.moving=!1,c({moving:!1}),E.current.style.cursor="auto")},onTap:g=>{const{target:S,ctrlKey:T,metaKey:P}=g,D=l(g);if(!D&&Oe(S,"board"))n();else{const j=Te(D);if(!j){n();return}const A=r();D&&!A.includes(j)&&(T||P?s([j]):o([j]))}},onLongTap:({target:g})=>{const S=Oe(g,"item");if(S){const T=Te(S);o([T])}},mainAction:t?"pan":"drag",children:ae("div",{ref:E,children:[f.moving&&k("div",{style:{transform:`translate(${f.left}px, ${f.top}px)`,height:`${f.height}px`,width:`${f.width}px`},className:`selector ${Zn}`}),e]})})},to=({children:e})=>{const{moveItems:t,placeItems:r,findElementUnderPointer:n}=Be(),{vectorFromWrapperToBoard:o}=ve(),[s,a,u,l,m]=Q(y=>[y.select,y.setSelection,y.getSelection,y.getBoardState,y.updateBoardState]),[f]=oe(y=>[y.getBoardConfig]),c=d.useRef({}),h=d.useRef({items:[]}),b=y=>{const{ctrlKey:w,metaKey:x,event:p}=y,C=n(y);if(C){p.stopPropagation();const g=u();h.current.items=g;const S=Te(C);g.includes(S)||(w||x?(h.current.items=[...g,S],s([S])):(h.current.items=[S],a([S]))),Object.assign(c.current,{moving:!0})}},v=({deltaX:y,deltaY:w,event:x})=>{if(c.current.moving){x.stopPropagation();const{movingItems:p}=l(),[C,g]=o(y,w);t(h.current.items,{x:C,y:g},!0),p||m({movingItems:!0})}},E=()=>{if(c.current.moving){const{gridSize:y=1}=f(),w=y||1;c.current={moving:!1},r(h.current.items,{type:"grid",size:w}),m({movingItems:!1})}};return ue(document,"keydown",y=>{if(["INPUT","TEXTAREA"].includes(y.target.tagName))return;const w=u();if(w.length){const{gridSize:x=1}=f();let p=0,C=0;switch(y.key){case"ArrowLeft":p=-10;break;case"ArrowRight":p=10;break;case"ArrowUp":C=-10;break;case"ArrowDown":C=10;break}if(p||C){y.shiftKey&&(p*=5,C*=5),(y.ctrlKey||y.altKey||y.metaKey)&&(p/=10,C/=10);const[g,S]=o(p,C);t(w,{x:g,y:S},!0),r(w,{type:"grid",size:x||1}),y.preventDefault()}}}),k(Ne,{onDragStart:b,onDrag:v,onDragEnd:E,children:e})},ro=e=>{const t=d.useRef({hover:!1,x:0,y:0});return ue(e.current,"mousemove",n=>{const{clientX:o,clientY:s}=n;t.current.x=o,t.current.y=s}),ue(e.current,"mouseenter",()=>{t.current.hover=!0}),ue(e.current,"mouseleave",()=>{t.current.hover=!1}),d.useCallback(()=>t.current,[])},no=[...Array(5).keys()].map(e=>`Digit${e+1}`),oo=()=>{const[e,t]=d.useState({}),[r,n]=Q(o=>[o.getBoardState,o.updateBoardState]);return ue(document,"keydown",o=>{if(!["INPUT","TEXTAREA"].includes(o.target.tagName)&&no.includes(o.code)){const s=o.code,{translateX:a,translateY:u,scale:l}=r();o.altKey||o.metaKey||o.ctrlKey||o.shiftKey?t(m=>({...m,[s]:{translateX:a,translateY:u,scale:l}})):e[s]&&n(e[s]),o.preventDefault()}}),null},so=({children:e,moveFirst:t=!1})=>{const r=d.useRef(null),[n,o,s,a,u]=Q(p=>[{translateX:p.boardState.translateX,translateY:p.boardState.translateY,scale:p.boardState.scale,rotate:p.boardState.rotate},p.config.itemExtent,p.getConfiguration,p.updateBoardState,p.getSelection]),{zoomToCenter:l,zoomToExtent:m,moveBoard:f}=ve(),[c,h]=d.useState(!1),b=d.useRef({}),v=ro(r);oo();const E=d.useCallback(()=>{const{itemExtent:p}=s();m(p)},[s,m]);d.useEffect(()=>{!c&&o.radius&&(E(),h(!0))},[E,c,o]);const O=({clientX:p,clientY:C,scale:g})=>{l({to:{x:p,y:C},factor:1-g/500}),clearTimeout(b.current.zoom),b.current.zoom=setTimeout(()=>{a({zooming:!1})},200),a({zooming:!0})},y=({deltaX:p,deltaY:C})=>{f(({translateX:g,translateY:S})=>({translateX:g+p,translateY:S+C})),clearTimeout(b.current.pan),b.current.pan=setTimeout(()=>{a({panning:!1})},200),a({panning:!0})},w=p=>{if(["INPUT","TEXTAREA"].includes(p.target.tagName))return;let C=0,g=0,S=1;switch(p.key){case"ArrowLeft":C=-10;break;case"ArrowRight":C=10;break;case"ArrowUp":g=-10;break;case"ArrowDown":g=10;break;case"PageUp":S=1.2;break;case"PageDown":S=.8;break}if(C||g||S!==1){const T=u();if(S===1&&T.length)return;p.shiftKey&&(C*=5,g*=5),(p.ctrlKey||p.altKey||p.metaKey)&&(C/=5,g/=5),f(({translateX:P,translateY:D})=>({translateX:P+C,translateY:D+g})),l({factor:S}),p.preventDefault()}p.key===" "&&!p.repeat&&v().hover&&l({factor:3,to:v()})},x=p=>{["INPUT","TEXTAREA"].includes(p.target.tagName)||p.key===" "&&v().hover&&l({factor:1/3,to:v()})};return ue(document,"keydown",w),ue(document,"keyup",x),k(Ne,{onPan:y,onZoom:O,mainAction:t?"pan":"drag",children:k("div",{style:{display:"inline-block",transformOrigin:"top left",transform:`translate(${n.translateX}px, ${n.translateY}px) rotate(${n.rotate}deg) scale(${n.scale})`},className:`board-pane${n.scale<.5?" board-pane__far":""}`,ref:r,children:e})})},io=H({position:"absolute",top:0,left:0,zIndex:210,backgroundColor:"hsla(0, 40%, 50%, 0%)",border:"2px dashed hsl(20, 55%, 40%)",pointerEvents:"none"}),ao=()=>{const[e,t,r,n,o,{translateX:s,translateY:a,scale:u}]=Q(c=>[c.selection,c.getSelection,c.selectionBox,c.setSelectionBox,c.getConfiguration,{translateX:c.boardState.translateX,translateY:c.boardState.translateY,scale:c.boardState.scale}]),[l]=oe(c=>[c.items]),m=d.useCallback(()=>{const c=t(),{boardWrapperRect:h,boardWrapper:b}=o();if(c.length===0){n(null);return}const v=Tr(c,b);if(!v){n(null);return}const{left:E,top:O,width:y,height:w}=v,x={left:E-h.left,top:O-h.top,height:w,width:y};n(x)},[o,t,n]),f=nt(m,[m],300);return d.useEffect(()=>{m(),f()},[e,l,s,a,u,m,f]),!r||e.length<2?null:k("div",{style:{transform:`translate(${r.left}px, ${r.top}px)`,height:`${r.height}px`,width:`${r.width}px`},className:`selection ${io}`})},co=()=>{const[e]=Q(t=>[t.boardState.movingItems]);return e?null:k(ao,{})},uo=typeof window<"u"&&typeof navigator<"u"&&typeof document<"u";let Xe;function lo(){if(!uo)return;if(Xe)return Xe;const e=new Map,t=new ResizeObserver(r=>{r.forEach(n=>{var o;return(o=e.get(n.target))==null?void 0:o.forEach(s=>setTimeout(()=>s(n),0))})});return Xe={observer:t,subscribe:(r,n)=>{let o=e.get(r);o||(o=new Set,e.set(r,o),t.observe(r)),o.add(n)},unsubscribe:(r,n)=>{const o=e.get(r);o&&(o.delete(n),o.size||(e.delete(r),t.unobserve(r)))}},Xe}function fo(e,t,r=!0){const n=r&&lo(),o=rt(t),s=e&&"current"in e?e.current:e;d.useEffect(()=>{const a=e&&"current"in e?e.current:e;if(!n||!a)return;let u=!0;const l=(...m)=>{u&&o.current(...m)};return n.subscribe(a,l),()=>{u=!1,n.unsubscribe(a,l)}},[s,n])}function Ft(e,t,r){return Math.min(Math.max(e,r),t)}class mo extends Error{constructor(t){super(`Failed to parse color: "${t}"`)}}var Pe=mo;function po(e){if(typeof e!="string")throw new Pe(e);if(e.trim().toLowerCase()==="transparent")return[0,0,0,0];let t=e.trim();t=Eo.test(e)?vo(e):e;const r=yo.exec(t);if(r){const a=Array.from(r).slice(1);return[...a.slice(0,3).map(u=>parseInt(Me(u,2),16)),parseInt(Me(a[3]||"f",2),16)/255]}const n=So.exec(t);if(n){const a=Array.from(n).slice(1);return[...a.slice(0,3).map(u=>parseInt(u,16)),parseInt(a[3]||"ff",16)/255]}const o=bo.exec(t);if(o){const a=Array.from(o).slice(1);return[...a.slice(0,3).map(u=>parseInt(u,10)),parseFloat(a[3]||"1")]}const s=_o.exec(t);if(s){const[a,u,l,m]=Array.from(s).slice(1).map(parseFloat);if(Ft(0,100,u)!==u)throw new Pe(e);if(Ft(0,100,l)!==l)throw new Pe(e);return[...Co(a,u,l),Number.isNaN(m)?1:m]}throw new Pe(e)}function go(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0)%2341}const Kt=e=>parseInt(e.replace(/_/g,""),36),ho="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=Kt(t.substring(0,3)),n=Kt(t.substring(3)).toString(16);let o="";for(let s=0;s<6-n.length;s++)o+="0";return e[r]=`${o}${n}`,e},{});function vo(e){const t=e.toLowerCase().trim(),r=ho[go(t)];if(!r)throw new Pe(e);return`#${r}`}const Me=(e,t)=>Array.from(Array(t)).map(()=>e).join(""),yo=new RegExp(`^#${Me("([a-f0-9])",3)}([a-f0-9])?$`,"i"),So=new RegExp(`^#${Me("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),bo=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Me(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),_o=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,Eo=/^[a-z]+$/i,Ht=e=>Math.round(e*255),Co=(e,t,r)=>{let n=r/100;if(t===0)return[n,n,n].map(Ht);const o=(e%360+360)%360/60,s=(1-Math.abs(2*n-1))*(t/100),a=s*(1-Math.abs(o%2-1));let u=0,l=0,m=0;o>=0&&o<1?(u=s,l=a):o>=1&&o<2?(u=a,l=s):o>=2&&o<3?(l=s,m=a):o>=3&&o<4?(l=a,m=s):o>=4&&o<5?(u=a,m=s):o>=5&&o<6&&(u=s,m=a);const f=n-s/2,c=u+f,h=l+f,b=m+f;return[c,h,b].map(Ht)};function wo(e){if(e==="transparent")return 0;function t(s){const a=s/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)}const[r,n,o]=po(e);return .2126*t(r)+.7152*t(n)+.0722*t(o)}function xo(e){return wo(e)>.179}const Io=H({display:"flex",flexDirection:"row",alignItems:"center",zIndex:210,pointerEvents:"none"}),Oo=H({fontWeight:"bold",padding:"0 0.5em",borderRadius:"2px",maxWidth:"5em",overflow:"hidden",textOverflow:"ellipsis",marginLeft:"-0.5em",marginTop:"1.7em",whitespace:"nowrap",pointerEvents:"none"}),To=({color:e="#666",size:t=40,text:r})=>{const n=xo(e)?"#222":"#EEE";return ae("div",{className:Io,children:[ae("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"1064.7701 445.5539 419.8101 717.0565",width:t,height:t,children:[k("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}}),k("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}})]}),k("div",{style:{color:n,backgroundColor:e},className:Oo,children:r})]})},ko=d.memo(To),Po=H({top:0,left:0,zIndex:210,position:"fixed",pointerEvents:"none"}),Mo=({pos:e,...t})=>k("div",{className:Po,style:{transform:`translate(${e.x-6}px, ${e.y-15}px)`},children:k(ko,{...t})}),jo=({children:e})=>{const[t]=Q(v=>[v.getConfiguration,v.boardState.scale]),{fromWrapperToBoard:r,fromBoardToWrapper:n}=ve(),[o,s,a,u]=ye(v=>[v.getUser(),v.getLocalUsers(),v.cursors,v.users]),[l,m]=ye(v=>[v.moveCursor,v.removeCursor]),{boardWrapperRect:f}=t(),c=({clientX:v,clientY:E})=>{const[O,y]=r(v-f.left,E-f.top);l(o.id,{x:O,y})},h=()=>{m(o.id)},b=s.reduce((v,E)=>(E.id!==o.id&&a[E.id]&&(v[E.id]=a[E.id]),v),{});return ae("div",{onPointerMove:c,onPointerLeave:h,children:[e,Object.entries(b).map(([v,E])=>{const[O,y]=n(E.x,E.y),w={x:O+f.left,y:y+f.top};return et(w,f)?k(Mo,{pos:w,text:u[v].name,color:u[v].color},v):null})]})},Do=({children:e})=>e,Ro={overflow:"hidden",position:"absolute",inset:0},$o=({moveFirst:e=!0,style:t,wrapperStyle:r,itemTemplates:n={},boardSize:o=Dt,children:s,showResizeHandle:a=!1,Wrapper:u=Do})=>{const l=d.useRef(null),[m,f]=Q(v=>[v.config.uid,v.updateConfiguration]),{updateItemExtent:c}=ve(),h={userSelect:"none",width:`${o}px`,height:`${o}px`,backgroundColor:"#333",...t};d.useEffect(()=>{const v=E=>{Oe(E.target,"board")&&E.preventDefault()};return document.body.addEventListener("wheel",v,{passive:!1}),()=>{document.body.removeEventListener("wheel",v)}},[]),d.useEffect(()=>{f({boardWrapper:l.current})},[f]),d.useEffect(()=>{m||f({uid:pe()})},[m,f]),d.useEffect(()=>{f({itemTemplates:n,boardSize:o,showResizeHandle:a})},[n,o,a,f]),d.useEffect(()=>{f({boardWrapperRect:l.current.getBoundingClientRect()}),c(),setTimeout(c,2e3)},[f,c]),fo(l,()=>{l.current&&f({boardWrapperRect:l.current.getBoundingClientRect()})});const b=H({...Ro,...r});return ae("div",{ref:l,id:m,className:`sync-board ${b}`,children:[k(jo,{children:k(eo,{moveFirst:e,children:k(so,{moveFirst:e,children:k(to,{moveFirst:e,children:k(u,{children:ae("div",{onContextMenu:v=>{v.preventDefault()},style:h,className:"board",children:[k(Kn,{}),s]})})})})})}),k(co,{})]})};xn(d.createElement),U.Board=$o,U.BoardWrapper=dn,U.RoomWrapper=mn,U.useAvailableActions=Jr,U.useBoardConfig=nn,U.useBoardPosition=ve,U.useBoardState=on,U.useDebouncedItems=Lr,U.useItemActions=Be,U.useItemInteraction=ot,U.useItems=Ar,U.useMessage=fn,U.useSelectedItems=Xr,U.useSelectionBox=Zr,U.useSessionInfo=sn,U.useUsers=rn,U.useWire=Ie,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|
|
108
|
+
`,zn=({onReload:e})=>ae("div",{className:`syncboard-error-item ${H({width:"100px",display:"flex",flexDirection:"column",justifyContent:"center",textAlign:"center",color:"red"})}`,children:["Sorry, this item seems broken.",k("button",{onClick:e,children:"Reload it"})]});class Yn extends d.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?k(t,{onReload:this.onReload}):this.props.children}}const Bn=e=>{e.target.className=""},Xn=({width:e,height:t,actualWidth:r,actualHeight:n,prevState:o,keepRatio:s})=>{let{width:a,height:u}=o;if([a,u]=[parseFloat(a),parseFloat(u)],(!a||Number.isNaN(Number(a)))&&(a=r),(!u||Number.isNaN(Number(u)))&&(u=n),s){const l=a/u;return{...o,width:(a+e).toFixed(1),height:(u+t/l).toFixed(1)}}return{...o,width:(a+e).toFixed(1),height:(u+t).toFixed(1)}},Nn={w:!0,h:!0,b:!0},Un=({setState:e,state:{type:t,rotation:r=0,id:n,locked:o,extraClasses:s,...a}={},animate:u="hvr-pop",isSelected:l,itemMap:m,showResizeHandle:f=!0})=>{var w;const c=d.useRef(null),[h]=Z(I=>[I.config.uid]),{component:S=()=>null,resizeDirections:v=Nn,resize:E=Xn}=m[t],T=d.useCallback((I,P=!1)=>e(n,I,P),[e,n]);d.useEffect(()=>{c.current.className=u},[u]);const y=["item",n,Tn];o&&y.push("locked"),l&&(y.push("selected"),y.push(kn));const C=y.join(" "),x=({width:I=0,height:P=0,keepRatio:D})=>{T(j=>{const{offsetWidth:A,offsetHeight:B}=c.current;return E({prevState:j,width:I,height:P,actualHeight:B,actualWidth:A,keepRatio:D})})},p=({width:I})=>{x({width:I})},_=({height:I})=>{x({height:I})},g=({width:I})=>{x({height:I,width:I,keepRatio:!0})};return k("div",{style:{transform:`rotate(${r}deg`},"data-id":n,id:`${h}__${n}`,className:C,children:ae("div",{style:{display:"flex"},ref:c,onAnimationEnd:Bn,onKeyDown:I=>I.stopPropagation(),onKeyUp:I=>I.stopPropagation(),children:[k(Yn,{itemId:n,state:a,ErrorComponent:((w=m==null?void 0:m.error)==null?void 0:w.component)||zn,children:k(S,{...a,id:n,setState:T})}),k("div",{className:`corner ${ke} ${Pn}`}),k("div",{className:`corner ${ke} ${Mn}`}),k("div",{className:`corner ${ke} ${Dn}`}),k("div",{className:`corner ${ke} ${jn}`}),k("div",{className:`center ${ke} ${Rn}`}),f&&ae(mr,{children:[v.b&&k(at,{className:`${ct} ${Ln}`,onResize:g}),v.h&&k(at,{className:`${ct} ${An}`,onResize:_}),v.w&&k(at,{className:`${ct} ${$n}`,onResize:p})]})]})})},Wn=d.memo(Un,({state:e,setState:t,isSelected:r,showResizeHandle:n},{state:o,setState:s,isSelected:a,showResizeHandle:u})=>r===a&&n===u&&t===s&&En(e,o)),Vn=e=>e,Fn=({state:e={},getCurrentUser:t,className:r,...n})=>{if(!n.itemMap[e.type])return null;const{stateHook:o=Vn}=n.itemMap[e.type],{x:s=0,y:a=0,layer:u=0,moving:l,...m}=o(e,{getCurrentUser:t}),f=(u+4)*10+100+(l?5:0);return k("div",{className:r,style:{transform:`translate(${s}px, ${a}px)`,zIndex:f},children:k(Wn,{...n,showResizeHandle:n.isSelected&&n.showResizeHandle,state:m})})},Kn=d.memo(Fn),Hn=()=>{const{updateItem:e}=Be(),[t,r]=oe(m=>[m.itemIds,m.items]),[n,o,s,a]=Z(m=>[m.config.boardSize,m.config.showResizeHandle,m.config.itemTemplates,m.selection]),[u]=ye(m=>[m.getUser]),l=H({position:"absolute",top:`${n/2}px`,left:`${n/2}px`,display:"inline-block",lineHeight:0});return t.map(m=>k(Kn,{state:r[m],setState:e,isSelected:a.includes(m),itemMap:s,boardSize:n,getCurrentUser:u,showResizeHandle:o,className:l},m))};function qn(e=!1){const t=d.useRef(e),r=d.useCallback(()=>t.current,[]);return d.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),r}function Gn(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function Jn(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}const Zn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);function ue(e,...t){const r=qn(),n=rt(t[1]),o=d.useMemo(()=>function(...s){r()&&(typeof n.current=="function"?n.current.apply(this,s):typeof n.current.handleEvent=="function"&&n.current.handleEvent.apply(this,s))},[]);d.useEffect(()=>{const s=e&&Zn(e,"current")?e.current:e;if(!s)return;const a=t.slice(2);return Gn(s,t[0],o,...a),()=>Jn(s,t[0],o,...a)},[e,t[0]])}const Qn=H({zIndex:210,position:"absolute",backgroundColor:"hsla(0, 40%, 50%, 10%)",border:"2px solid hsl(0, 55%, 40%)"}),eo=(e,t,r=!1)=>{const n=t.getElementsByClassName("selector");if(!n.length)return[];const o=n[0];return Array.from(t.getElementsByClassName("item")).filter(s=>{const a=Te(s),u=e[a];return!u||!r&&u.locked?!1:Or(s,o)}).map(s=>Te(s))},to=({children:e,moveFirst:t})=>{const[r,n,o,s,a,u]=Z(g=>[g.getSelection,g.clear,g.setSelection,g.select,g.getConfiguration,g.getBoardState,g.updateBoardState]),{findElementUnderPointer:l}=Be(),[m]=oe(g=>[g.getItems]),[f,c]=d.useState({}),[,h]=d.useTransition(),[S,v]=d.useState(!1),E=d.useRef(null),T=d.useRef({moving:!1});return ue(document,"keydown",g=>{g.key==="l"&&v(!0)}),ue(document,"keyup",g=>{g.key==="l"&&v(!1)}),d.useEffect(()=>(n(),()=>{n()}),[n]),d.useEffect(()=>{if(T.current.moving){const g=m(),{boardWrapper:w}=a(),I=eo(g,w,S);h(()=>{o(I)})}},[a,m,f,o,S]),k(Xe,{onDragStart:async g=>{await l(g)||(T.current.moving=!0,h(()=>{u({selecting:!0})}),E.current.style.cursor="crosshair")},onDrag:({distanceY:g,distanceX:w,startX:I,startY:P})=>{if(T.current.moving){const{top:D,left:j}=E.current.getBoundingClientRect(),A=I-j,B=P-D;w>0?(T.current.left=A,T.current.width=w):(T.current.left=A+w,T.current.width=-w),g>0?(T.current.top=B,T.current.height=g):(T.current.top=B+g,T.current.height=-g),c({...T.current,moving:!0})}},onDragEnd:()=>{T.current.moving&&(h(()=>{u({selecting:!1})}),T.current.moving=!1,c({moving:!1}),E.current.style.cursor="auto")},onTap:g=>{const{target:w,ctrlKey:I,metaKey:P}=g,D=l(g);if(!D&&Oe(w,"board"))n();else{const j=Te(D);if(!j){n();return}const A=r();D&&!A.includes(j)&&(I||P?s([j]):o([j]))}},onLongTap:({target:g})=>{const w=Oe(g,"item");if(w){const I=Te(w);o([I])}},mainAction:t?"pan":"drag",children:ae("div",{ref:E,children:[f.moving&&k("div",{style:{transform:`translate(${f.left}px, ${f.top}px)`,height:`${f.height}px`,width:`${f.width}px`},className:`selector ${Qn}`}),e]})})},ro=({children:e})=>{const{moveItems:t,placeItems:r,findElementUnderPointer:n}=Be(),{vectorFromWrapperToBoard:o}=ve(),[s,a,u,l,m]=Z(y=>[y.select,y.setSelection,y.getSelection,y.getBoardState,y.updateBoardState]),[f]=oe(y=>[y.getBoardConfig]),c=d.useRef({}),h=d.useRef({items:[]}),S=y=>{const{ctrlKey:C,metaKey:x,event:p}=y,_=n(y);if(_){p.stopPropagation();const g=u();h.current.items=g;const w=Te(_);g.includes(w)||(C||x?(h.current.items=[...g,w],s([w])):(h.current.items=[w],a([w]))),Object.assign(c.current,{moving:!0})}},v=({deltaX:y,deltaY:C,event:x})=>{if(c.current.moving){x.stopPropagation();const{movingItems:p}=l(),[_,g]=o(y,C);t(h.current.items,{x:_,y:g},!0),p||m({movingItems:!0})}},E=()=>{if(c.current.moving){const{gridSize:y=1}=f(),C=y||1;c.current={moving:!1},r(h.current.items,{type:"grid",size:C}),m({movingItems:!1})}};return ue(document,"keydown",y=>{if(["INPUT","TEXTAREA"].includes(y.target.tagName))return;const C=u();if(C.length){const{gridSize:x=1}=f();let p=0,_=0;switch(y.key){case"ArrowLeft":p=-10;break;case"ArrowRight":p=10;break;case"ArrowUp":_=-10;break;case"ArrowDown":_=10;break}if(p||_){y.shiftKey&&(p*=5,_*=5),(y.ctrlKey||y.altKey||y.metaKey)&&(p/=10,_/=10);const[g,w]=o(p,_);t(C,{x:g,y:w},!0),r(C,{type:"grid",size:x||1}),y.preventDefault()}}}),k(Xe,{onDragStart:S,onDrag:v,onDragEnd:E,children:e})},no=e=>{const t=d.useRef({hover:!1,x:0,y:0});return ue(e.current,"mousemove",n=>{const{clientX:o,clientY:s}=n;t.current.x=o,t.current.y=s}),ue(e.current,"mouseenter",()=>{t.current.hover=!0}),ue(e.current,"mouseleave",()=>{t.current.hover=!1}),d.useCallback(()=>t.current,[])},oo=[...Array(5).keys()].map(e=>`Digit${e+1}`),so=()=>{const[e,t]=d.useState({}),[r,n]=Z(o=>[o.getBoardState,o.updateBoardState]);return ue(document,"keydown",o=>{if(!["INPUT","TEXTAREA"].includes(o.target.tagName)&&oo.includes(o.code)){const s=o.code,{translateX:a,translateY:u,scale:l}=r();o.altKey||o.metaKey||o.ctrlKey||o.shiftKey?t(m=>({...m,[s]:{translateX:a,translateY:u,scale:l}})):e[s]&&n(e[s]),o.preventDefault()}}),null},io=({children:e,moveFirst:t=!1})=>{const r=d.useRef(null),[n,o,s,a,u]=Z(p=>[{translateX:p.boardState.translateX,translateY:p.boardState.translateY,scale:p.boardState.scale,rotate:p.boardState.rotate},p.config.itemExtent,p.getConfiguration,p.updateBoardState,p.getSelection]),{zoomToCenter:l,zoomToExtent:m,moveBoard:f}=ve(),[c,h]=d.useState(!1),S=d.useRef({}),v=no(r);so();const E=d.useCallback(()=>{const{itemExtent:p}=s();m(p)},[s,m]);d.useEffect(()=>{!c&&o.radius&&(E(),h(!0))},[E,c,o]);const T=({clientX:p,clientY:_,scale:g})=>{l({to:{x:p,y:_},factor:1-g/500}),clearTimeout(S.current.zoom),S.current.zoom=setTimeout(()=>{a({zooming:!1})},200),a({zooming:!0})},y=({deltaX:p,deltaY:_})=>{f(({translateX:g,translateY:w})=>({translateX:g+p,translateY:w+_})),clearTimeout(S.current.pan),S.current.pan=setTimeout(()=>{a({panning:!1})},200),a({panning:!0})},C=p=>{if(["INPUT","TEXTAREA"].includes(p.target.tagName))return;let _=0,g=0,w=1;switch(p.key){case"ArrowLeft":_=-10;break;case"ArrowRight":_=10;break;case"ArrowUp":g=-10;break;case"ArrowDown":g=10;break;case"PageUp":w=1.2;break;case"PageDown":w=.8;break}if(_||g||w!==1){const I=u();if(w===1&&I.length)return;p.shiftKey&&(_*=5,g*=5),(p.ctrlKey||p.altKey||p.metaKey)&&(_/=5,g/=5),f(({translateX:P,translateY:D})=>({translateX:P+_,translateY:D+g})),l({factor:w}),p.preventDefault()}p.key===" "&&!p.repeat&&v().hover&&l({factor:3,to:v()})},x=p=>{["INPUT","TEXTAREA"].includes(p.target.tagName)||p.key===" "&&v().hover&&l({factor:1/3,to:v()})};return ue(document,"keydown",C),ue(document,"keyup",x),k(Xe,{onPan:y,onZoom:T,mainAction:t?"pan":"drag",children:k("div",{style:{display:"inline-block",transformOrigin:"top left",transform:`translate(${n.translateX}px, ${n.translateY}px) rotate(${n.rotate}deg) scale(${n.scale})`},className:`board-pane${n.scale<.5?" board-pane__far":""}`,ref:r,children:e})})},ao=H({position:"absolute",top:0,left:0,zIndex:210,backgroundColor:"hsla(0, 40%, 50%, 0%)",border:"2px dashed hsl(20, 55%, 40%)",pointerEvents:"none"}),co=()=>{const[e,t,r,n,o,{translateX:s,translateY:a,scale:u}]=Z(c=>[c.selection,c.getSelection,c.selectionBox,c.setSelectionBox,c.getConfiguration,{translateX:c.boardState.translateX,translateY:c.boardState.translateY,scale:c.boardState.scale}]),[l]=oe(c=>[c.items]),m=d.useCallback(()=>{const c=t(),{boardWrapperRect:h,uid:S}=o();if(c.length===0){n(null);return}const v=Tr(c,S);if(!v){n(null);return}const{left:E,top:T,width:y,height:C}=v,x={left:E-h.left,top:T-h.top,height:C,width:y};n(x)},[o,t,n]),f=nt(m,[m],300);return d.useEffect(()=>{m(),f()},[e,l,s,a,u,m,f]),!r||e.length<2?null:k("div",{style:{transform:`translate(${r.left}px, ${r.top}px)`,height:`${r.height}px`,width:`${r.width}px`},className:`selection ${ao}`})},uo=()=>{const[e]=Z(t=>[t.boardState.movingItems]);return e?null:k(co,{})},lo=typeof window<"u"&&typeof navigator<"u"&&typeof document<"u";let Ne;function fo(){if(!lo)return;if(Ne)return Ne;const e=new Map,t=new ResizeObserver(r=>{r.forEach(n=>{var o;return(o=e.get(n.target))==null?void 0:o.forEach(s=>setTimeout(()=>s(n),0))})});return Ne={observer:t,subscribe:(r,n)=>{let o=e.get(r);o||(o=new Set,e.set(r,o),t.observe(r)),o.add(n)},unsubscribe:(r,n)=>{const o=e.get(r);o&&(o.delete(n),o.size||(e.delete(r),t.unobserve(r)))}},Ne}function mo(e,t,r=!0){const n=r&&fo(),o=rt(t),s=e&&"current"in e?e.current:e;d.useEffect(()=>{const a=e&&"current"in e?e.current:e;if(!n||!a)return;let u=!0;const l=(...m)=>{u&&o.current(...m)};return n.subscribe(a,l),()=>{u=!1,n.unsubscribe(a,l)}},[s,n])}function Ft(e,t,r){return Math.min(Math.max(e,r),t)}class po extends Error{constructor(t){super(`Failed to parse color: "${t}"`)}}var Pe=po;function go(e){if(typeof e!="string")throw new Pe(e);if(e.trim().toLowerCase()==="transparent")return[0,0,0,0];let t=e.trim();t=wo.test(e)?yo(e):e;const r=So.exec(t);if(r){const a=Array.from(r).slice(1);return[...a.slice(0,3).map(u=>parseInt(Me(u,2),16)),parseInt(Me(a[3]||"f",2),16)/255]}const n=_o.exec(t);if(n){const a=Array.from(n).slice(1);return[...a.slice(0,3).map(u=>parseInt(u,16)),parseInt(a[3]||"ff",16)/255]}const o=bo.exec(t);if(o){const a=Array.from(o).slice(1);return[...a.slice(0,3).map(u=>parseInt(u,10)),parseFloat(a[3]||"1")]}const s=Eo.exec(t);if(s){const[a,u,l,m]=Array.from(s).slice(1).map(parseFloat);if(Ft(0,100,u)!==u)throw new Pe(e);if(Ft(0,100,l)!==l)throw new Pe(e);return[...Co(a,u,l),Number.isNaN(m)?1:m]}throw new Pe(e)}function ho(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0)%2341}const Kt=e=>parseInt(e.replace(/_/g,""),36),vo="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=Kt(t.substring(0,3)),n=Kt(t.substring(3)).toString(16);let o="";for(let s=0;s<6-n.length;s++)o+="0";return e[r]=`${o}${n}`,e},{});function yo(e){const t=e.toLowerCase().trim(),r=vo[ho(t)];if(!r)throw new Pe(e);return`#${r}`}const Me=(e,t)=>Array.from(Array(t)).map(()=>e).join(""),So=new RegExp(`^#${Me("([a-f0-9])",3)}([a-f0-9])?$`,"i"),_o=new RegExp(`^#${Me("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),bo=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${Me(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),Eo=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,wo=/^[a-z]+$/i,Ht=e=>Math.round(e*255),Co=(e,t,r)=>{let n=r/100;if(t===0)return[n,n,n].map(Ht);const o=(e%360+360)%360/60,s=(1-Math.abs(2*n-1))*(t/100),a=s*(1-Math.abs(o%2-1));let u=0,l=0,m=0;o>=0&&o<1?(u=s,l=a):o>=1&&o<2?(u=a,l=s):o>=2&&o<3?(l=s,m=a):o>=3&&o<4?(l=a,m=s):o>=4&&o<5?(u=a,m=s):o>=5&&o<6&&(u=s,m=a);const f=n-s/2,c=u+f,h=l+f,S=m+f;return[c,h,S].map(Ht)};function xo(e){if(e==="transparent")return 0;function t(s){const a=s/255;return a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)}const[r,n,o]=go(e);return .2126*t(r)+.7152*t(n)+.0722*t(o)}function Io(e){return xo(e)>.179}const Oo=H({display:"flex",flexDirection:"row",alignItems:"center",zIndex:210,pointerEvents:"none"}),To=H({fontWeight:"bold",padding:"0 0.5em",borderRadius:"2px",maxWidth:"5em",overflow:"hidden",textOverflow:"ellipsis",marginLeft:"-0.5em",marginTop:"1.7em",whitespace:"nowrap",pointerEvents:"none"}),ko=({color:e="#666",size:t=40,text:r})=>{const n=Io(e)?"#222":"#EEE";return ae("div",{className:Oo,children:[ae("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"1064.7701 445.5539 419.8101 717.0565",width:t,height:t,children:[k("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}}),k("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}})]}),k("div",{style:{color:n,backgroundColor:e},className:To,children:r})]})},Po=d.memo(ko),Mo=H({top:0,left:0,zIndex:210,position:"fixed",pointerEvents:"none"}),jo=({pos:e,...t})=>k("div",{className:Mo,style:{transform:`translate(${e.x-6}px, ${e.y-15}px)`},children:k(Po,{...t})}),Do=({children:e})=>{const[t]=Z(v=>[v.getConfiguration,v.boardState.scale]),{fromWrapperToBoard:r,fromBoardToWrapper:n}=ve(),[o,s,a,u]=ye(v=>[v.getUser(),v.getLocalUsers(),v.cursors,v.users]),[l,m]=ye(v=>[v.moveCursor,v.removeCursor]),{boardWrapperRect:f}=t(),c=({clientX:v,clientY:E})=>{const[T,y]=r(v-f.left,E-f.top);l(o.id,{x:T,y})},h=()=>{m(o.id)},S=s.reduce((v,E)=>(E.id!==o.id&&a[E.id]&&(v[E.id]=a[E.id]),v),{});return ae("div",{onPointerMove:c,onPointerLeave:h,children:[e,Object.entries(S).map(([v,E])=>{const[T,y]=n(E.x,E.y),C={x:T+f.left,y:y+f.top};return et(C,f)?k(jo,{pos:C,text:u[v].name,color:u[v].color},v):null})]})},Ro=({children:e})=>e,$o={overflow:"hidden",position:"absolute",inset:0},Ao=({moveFirst:e=!0,style:t,wrapperStyle:r,itemTemplates:n={},boardSize:o=Dt,children:s,showResizeHandle:a=!1,Wrapper:u=Ro})=>{const l=d.useRef(null),[m,f]=Z(v=>[v.config.uid,v.updateConfiguration]),{updateItemExtent:c}=ve(),h={userSelect:"none",width:`${o}px`,height:`${o}px`,backgroundColor:"#333",...t};d.useEffect(()=>{const v=E=>{Oe(E.target,"board")&&E.preventDefault()};return document.body.addEventListener("wheel",v,{passive:!1}),()=>{document.body.removeEventListener("wheel",v)}},[]),d.useEffect(()=>{f({boardWrapper:l.current})},[f]),d.useEffect(()=>{m||f({uid:pe()})},[m,f]),d.useEffect(()=>{f({itemTemplates:n,boardSize:o,showResizeHandle:a})},[n,o,a,f]),d.useEffect(()=>{f({boardWrapperRect:l.current.getBoundingClientRect()}),c(),setTimeout(c,2e3)},[f,c]),mo(l,()=>{l.current&&f({boardWrapperRect:l.current.getBoundingClientRect()})});const S=H({...$o,...r});return ae("div",{ref:l,id:m,className:`sync-board ${S}`,children:[k(Do,{children:k(to,{moveFirst:e,children:k(io,{moveFirst:e,children:k(ro,{moveFirst:e,children:k(u,{children:ae("div",{onContextMenu:v=>{v.preventDefault()},style:h,className:"board",children:[k(Hn,{}),s]})})})})})}),k(uo,{})]})};bn(d.createElement),U.Board=Ao,U.BoardWrapper=mn,U.RoomWrapper=pn,U.useAvailableActions=Zr,U.useBoardConfig=on,U.useBoardPosition=ve,U.useBoardState=sn,U.useDebouncedItems=Lr,U.useGetSelectedItems=Ur,U.useItemActions=Be,U.useItemInteraction=ot,U.useItems=Ar,U.useMessage=dn,U.useSelectedItems=Nr,U.useSelectionBox=Qr,U.useSessionInfo=an,U.useUsers=nn,U.useWire=Ie,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|
|
109
109
|
//# sourceMappingURL=react-sync-board.umd.cjs.map
|