kritzel-stencil 0.2.5 → 0.2.6

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.
@@ -27516,6 +27516,10 @@ const KritzelEngine = class {
27516
27516
  overflow: 'visible',
27517
27517
  } }))), workspace_migrations.KritzelClassHelper.isInstanceOf(object, 'KritzelShape') && (() => {
27518
27518
  const effectiveOpacity = (object.markedForRemoval ? 0.5 : 1) * object.opacity;
27519
+ const fillResolved = workspace_migrations.KritzelColorHelper.resolveThemeColor(object.fillColor, currentTheme);
27520
+ const strokeResolved = workspace_migrations.KritzelColorHelper.resolveThemeColor(object.strokeColor, currentTheme);
27521
+ const isFilled = !!fillResolved && fillResolved !== 'transparent';
27522
+ const strokeMatchesFill = isFilled && strokeResolved === fillResolved;
27519
27523
  return (index.h("div", { ref: el => el && object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
27520
27524
  position: 'absolute',
27521
27525
  left: '0',
@@ -27534,7 +27538,7 @@ const KritzelEngine = class {
27534
27538
  height: '100%',
27535
27539
  overflow: 'visible',
27536
27540
  pointerEvents: 'none',
27537
- }, viewBox: object.viewBox, preserveAspectRatio: "none" }, index.h("path", { d: object.getSvgPath(), fill: workspace_migrations.KritzelColorHelper.applyOpacity(object.fillColor, effectiveOpacity, currentTheme), stroke: workspace_migrations.KritzelColorHelper.applyOpacity(object.strokeColor, effectiveOpacity, currentTheme), "stroke-width": object.strokeWidth })), index.h("div", { ref: el => el && object.mountTextEditor(el), style: {
27541
+ }, viewBox: object.viewBox, preserveAspectRatio: "none" }, index.h("path", { d: object.getSvgPath(), fill: workspace_migrations.KritzelColorHelper.applyOpacity(object.fillColor, effectiveOpacity, currentTheme), stroke: strokeMatchesFill ? 'none' : workspace_migrations.KritzelColorHelper.applyOpacity(object.strokeColor, effectiveOpacity, currentTheme), "stroke-width": strokeMatchesFill ? 0 : object.strokeWidth })), index.h("div", { ref: el => el && object.mountTextEditor(el), style: {
27538
27542
  position: 'absolute',
27539
27543
  top: '0',
27540
27544
  left: '0',
@@ -29095,7 +29099,7 @@ const KritzelPortal = class {
29095
29099
  * This file is auto-generated by the version bump scripts.
29096
29100
  * Do not modify manually.
29097
29101
  */
29098
- const KRITZEL_VERSION = '0.2.5';
29102
+ const KRITZEL_VERSION = '0.2.6';
29099
29103
 
29100
29104
  const kritzelSettingsCss = () => `:host{display:contents}kritzel-dialog{--kritzel-dialog-body-padding:0;--kritzel-dialog-width-large:800px;--kritzel-dialog-height-large:500px}.footer-button{padding:8px 16px;border-radius:6px;cursor:pointer;font-size:14px}.cancel-button{border:1px solid #ebebeb;background:#fff;color:inherit}.cancel-button:hover{background:#f5f5f5}.settings-content{padding:0}.settings-content h3{margin:0 0 16px 0;font-size:18px;font-weight:600;color:var(--kritzel-settings-content-heading-color, #333333)}.settings-content p{margin:0;font-size:14px;color:var(--kritzel-settings-content-text-color, #666666);line-height:1.5}.settings-group{display:flex;flex-direction:column;gap:24px}.settings-item{display:flex;flex-direction:column;gap:8px}.settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.settings-label{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.settings-description{font-size:12px;color:var(--kritzel-settings-description-color, #888888);margin:0;line-height:1.4}.shortcuts-list{display:flex;flex-direction:column;gap:24px}.shortcuts-category{display:flex;flex-direction:column;gap:8px}.shortcuts-category-title{font-size:14px;font-weight:600;color:var(--kritzel-settings-label-color, #333333);margin:0 0 4px 0}.shortcuts-group{display:flex;flex-direction:column;gap:4px}.shortcut-item{display:flex;justify-content:space-between;align-items:center;padding:6px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-item-bg, rgba(0, 0, 0, 0.02))}.shortcut-label{font-size:14px;color:var(--kritzel-settings-content-text-color, #666666)}.shortcut-key{font-family:monospace;font-size:12px;padding:2px 8px;border-radius:4px;background:var(--kritzel-settings-shortcut-key-bg, #f0f0f0);color:var(--kritzel-settings-shortcut-key-color, #333333);border:1px solid var(--kritzel-settings-shortcut-key-border, #ddd)}`;
29101
29105
 
@@ -1697,6 +1697,10 @@ export class KritzelEngine {
1697
1697
  overflow: 'visible',
1698
1698
  } }))), KritzelClassHelper.isInstanceOf(object, 'KritzelShape') && (() => {
1699
1699
  const effectiveOpacity = (object.markedForRemoval ? 0.5 : 1) * object.opacity;
1700
+ const fillResolved = KritzelColorHelper.resolveThemeColor(object.fillColor, currentTheme);
1701
+ const strokeResolved = KritzelColorHelper.resolveThemeColor(object.strokeColor, currentTheme);
1702
+ const isFilled = !!fillResolved && fillResolved !== 'transparent';
1703
+ const strokeMatchesFill = isFilled && strokeResolved === fillResolved;
1700
1704
  return (h("div", { ref: el => el && object.mount(el), onPointerDown: e => object.handlePointerDown(e), onPointerMove: e => object.handlePointerMove(e), onPointerUp: e => object.handlePointerUp(e), style: {
1701
1705
  position: 'absolute',
1702
1706
  left: '0',
@@ -1715,7 +1719,7 @@ export class KritzelEngine {
1715
1719
  height: '100%',
1716
1720
  overflow: 'visible',
1717
1721
  pointerEvents: 'none',
1718
- }, viewBox: object.viewBox, preserveAspectRatio: "none" }, h("path", { d: object.getSvgPath(), fill: KritzelColorHelper.applyOpacity(object.fillColor, effectiveOpacity, currentTheme), stroke: KritzelColorHelper.applyOpacity(object.strokeColor, effectiveOpacity, currentTheme), "stroke-width": object.strokeWidth })), h("div", { ref: el => el && object.mountTextEditor(el), style: {
1722
+ }, viewBox: object.viewBox, preserveAspectRatio: "none" }, h("path", { d: object.getSvgPath(), fill: KritzelColorHelper.applyOpacity(object.fillColor, effectiveOpacity, currentTheme), stroke: strokeMatchesFill ? 'none' : KritzelColorHelper.applyOpacity(object.strokeColor, effectiveOpacity, currentTheme), "stroke-width": strokeMatchesFill ? 0 : object.strokeWidth })), h("div", { ref: el => el && object.mountTextEditor(el), style: {
1719
1723
  position: 'absolute',
1720
1724
  top: '0',
1721
1725
  left: '0',
@@ -3,4 +3,4 @@
3
3
  * This file is auto-generated by the version bump scripts.
4
4
  * Do not modify manually.
5
5
  */
6
- export const KRITZEL_VERSION = '0.2.5';
6
+ export const KRITZEL_VERSION = '0.2.6';
@@ -1 +1 @@
1
- export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-BWj1eE2b.js";export{A as AssetNotFoundError,I as IndexedDBAssetProvider,i as KritzelAssetResolver,d as KritzelBrushTool,b as KritzelGroup,a as KritzelImage,e as KritzelLineTool,h as KritzelSelectionTool,c as KritzelShape,g as KritzelShapeTool,K as KritzelText,f as KritzelTextTool,S as ShapeType}from"./p-DwZAEb-2.js";export{a as KritzelLine,K as KritzelPath}from"./p-BhMchyAR.js";export{A as APP_STATE_MIGRATIONS,I as IndexedDBSyncProvider,d as KritzelAlignment,c as KritzelAnchorManager,b as KritzelCursorHelper,K as KritzelEraserTool,a as KritzelImageTool,W as WORKSPACE_MIGRATIONS,r as runMigrations}from"./p-eez_2Ccc.js";import*as t from"yjs";import{WebsocketProvider as o}from"y-websocket";import{H as n,a as m}from"./kritzel-editor.js";export{d as DEFAULT_ASSET_STORAGE_CONFIG,D as DEFAULT_BRUSH_CONFIG,c as DEFAULT_LINE_TOOL_CONFIG,b as DEFAULT_TEXT_CONFIG,KritzelEditor,defineCustomElement as defineCustomElementKritzelEditor}from"./kritzel-editor.js";export{K as KritzelWorkspace,W as WORKSPACE_EXPORT_VERSION}from"./p-DhMlShij.js";export{K as KritzelThemeManager,d as darkTheme,l as lightTheme}from"./p-D_Tdq4Z0.js";export{C as CURRENT_APP_STATE_SCHEMA_VERSION,a as CURRENT_WORKSPACE_SCHEMA_VERSION}from"./p-CW-VyJgK.js";export{KritzelActiveUsers,defineCustomElement as defineCustomElementKritzelActiveUsers}from"./kritzel-active-users.js";export{KritzelAvatar,defineCustomElement as defineCustomElementKritzelAvatar}from"./kritzel-avatar.js";export{KritzelAwarenessCursors,defineCustomElement as defineCustomElementKritzelAwarenessCursors}from"./kritzel-awareness-cursors.js";export{KritzelBackToContent,defineCustomElement as defineCustomElementKritzelBackToContent}from"./kritzel-back-to-content.js";export{KritzelBrushStyle,defineCustomElement as defineCustomElementKritzelBrushStyle}from"./kritzel-brush-style.js";export{KritzelButton,defineCustomElement as defineCustomElementKritzelButton}from"./kritzel-button.js";export{KritzelColor,defineCustomElement as defineCustomElementKritzelColor}from"./kritzel-color.js";export{KritzelColorPalette,defineCustomElement as defineCustomElementKritzelColorPalette}from"./kritzel-color-palette.js";export{KritzelContextMenu,defineCustomElement as defineCustomElementKritzelContextMenu}from"./kritzel-context-menu.js";export{KritzelControls,defineCustomElement as defineCustomElementKritzelControls}from"./kritzel-controls.js";export{KritzelCurrentUser,defineCustomElement as defineCustomElementKritzelCurrentUser}from"./kritzel-current-user.js";export{KritzelCurrentUserDialog,defineCustomElement as defineCustomElementKritzelCurrentUserDialog}from"./kritzel-current-user-dialog.js";export{KritzelCursorTrail,defineCustomElement as defineCustomElementKritzelCursorTrail}from"./kritzel-cursor-trail.js";export{KritzelDialog,defineCustomElement as defineCustomElementKritzelDialog}from"./kritzel-dialog.js";export{KritzelDropdown,defineCustomElement as defineCustomElementKritzelDropdown}from"./kritzel-dropdown.js";export{KritzelEngine,defineCustomElement as defineCustomElementKritzelEngine}from"./kritzel-engine.js";export{KritzelExport,defineCustomElement as defineCustomElementKritzelExport}from"./kritzel-export.js";export{KritzelFont,defineCustomElement as defineCustomElementKritzelFont}from"./kritzel-font.js";export{KritzelFontFamily,defineCustomElement as defineCustomElementKritzelFontFamily}from"./kritzel-font-family.js";export{KritzelFontSize,defineCustomElement as defineCustomElementKritzelFontSize}from"./kritzel-font-size.js";export{KritzelIcon,defineCustomElement as defineCustomElementKritzelIcon}from"./kritzel-icon.js";export{KritzelInput,defineCustomElement as defineCustomElementKritzelInput}from"./kritzel-input.js";export{KritzelLineEndings,defineCustomElement as defineCustomElementKritzelLineEndings}from"./kritzel-line-endings.js";export{KritzelLoginDialog,defineCustomElement as defineCustomElementKritzelLoginDialog}from"./kritzel-login-dialog.js";export{KritzelMasterDetail,defineCustomElement as defineCustomElementKritzelMasterDetail}from"./kritzel-master-detail.js";export{KritzelMenu,defineCustomElement as defineCustomElementKritzelMenu}from"./kritzel-menu.js";export{KritzelMenuItem,defineCustomElement as defineCustomElementKritzelMenuItem}from"./kritzel-menu-item.js";export{KritzelMoreMenu,defineCustomElement as defineCustomElementKritzelMoreMenu}from"./kritzel-more-menu.js";export{KritzelNumericInput,defineCustomElement as defineCustomElementKritzelNumericInput}from"./kritzel-numeric-input.js";export{KritzelOpacitySlider,defineCustomElement as defineCustomElementKritzelOpacitySlider}from"./kritzel-opacity-slider.js";export{KritzelPillTabs,defineCustomElement as defineCustomElementKritzelPillTabs}from"./kritzel-pill-tabs.js";export{KritzelPortal,defineCustomElement as defineCustomElementKritzelPortal}from"./kritzel-portal.js";export{KritzelSettings,defineCustomElement as defineCustomElementKritzelSettings}from"./kritzel-settings.js";export{KritzelShapeFill,defineCustomElement as defineCustomElementKritzelShapeFill}from"./kritzel-shape-fill.js";export{KritzelShareDialog,defineCustomElement as defineCustomElementKritzelShareDialog}from"./kritzel-share-dialog.js";export{KritzelSlideToggle,defineCustomElement as defineCustomElementKritzelSlideToggle}from"./kritzel-slide-toggle.js";export{KritzelSplitButton,defineCustomElement as defineCustomElementKritzelSplitButton}from"./kritzel-split-button.js";export{KritzelStrokeSize,defineCustomElement as defineCustomElementKritzelStrokeSize}from"./kritzel-stroke-size.js";export{KritzelToolConfig,defineCustomElement as defineCustomElementKritzelToolConfig}from"./kritzel-tool-config.js";export{KritzelTooltip,defineCustomElement as defineCustomElementKritzelTooltip}from"./kritzel-tooltip.js";export{KritzelUtilityPanel,defineCustomElement as defineCustomElementKritzelUtilityPanel}from"./kritzel-utility-panel.js";export{KritzelWorkspaceManager,defineCustomElement as defineCustomElementKritzelWorkspaceManager}from"./kritzel-workspace-manager.js";const u=Math.floor,z=127,p=Number.MAX_SAFE_INTEGER;class E{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const y=()=>new E,w=e=>{const t=new Uint8Array((e=>{let t=e.cpos;for(let s=0;s<e.bufs.length;s++)t+=e.bufs[s].length;return t})(e));let s=0;for(let i=0;i<e.bufs.length;i++){const o=e.bufs[i];t.set(o,s),s+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),s),t},k=(e,t)=>{const s=e.cbuf.length;e.cpos===s&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*s),e.cpos=0),e.cbuf[e.cpos++]=t},x=(e,t)=>{for(;t>z;)k(e,128|z&t),t=u(t/128);k(e,z&t)},T=(e,t)=>{x(e,t.byteLength),((e,t)=>{const s=e.cbuf.length,i=e.cpos,o=((e,t)=>e<t?e:t)(s-i,t.length),n=t.length-o;e.cbuf.set(t.subarray(0,o),i),e.cpos+=o,n>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(((e,t)=>e>t?e:t)(2*s,n)),e.cbuf.set(t.subarray(o)),e.cpos=n)})(e,t)},j=e=>Error(e),P=j("Unexpected end of array"),v=j("Integer out of Range");class U{constructor(e){this.arr=e,this.pos=0}}const M=e=>((e,t)=>{const s=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,s})(e,_(e)),_=e=>{let t=0,s=1;const i=e.arr.length;for(;e.pos<i;){const i=e.arr[e.pos++];if(t+=(i&z)*s,s*=128,i<128)return t;if(t>p)throw v}throw P};class F{type="local";doc;channel;_synced=!1;constructor(e,t,s){this.doc=t,this.channel=new BroadcastChannel(e),this.channel.onmessage=e=>{this.handleMessage(e.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),s?.quiet||console.info("BroadcastChannel Provider initialized: "+e)}handleDocUpdate=(e,t)=>{if(t!==this){const t=y();x(t,0),T(t,e),this.channel.postMessage(w(t))}};handleMessage(e){const s=(e=>new U(e))(new Uint8Array(e));switch(_(s)){case 0:const e=M(s);t.applyUpdate(this.doc,e,this);break;case 1:this.broadcastSync();break;case 2:const i=M(s),o=t.encodeStateAsUpdate(this.doc,i);if(o.length>0){const e=y();x(e,0),T(e,o),this.channel.postMessage(w(e))}}}broadcastSync(){const e=y();x(e,2),T(e,t.encodeStateVector(this.doc)),this.channel.postMessage(w(e))}async connect(){if(!this._synced)return new Promise((e=>{const t=()=>{this._synced?e():setTimeout(t,50)};t()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}class ${type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(e,t,s){const i=s?.url||"ws://localhost:1234",n=s?.roomName||e;this.provider=new o(i,n,t,{params:s?.params,protocols:s?.protocols,WebSocketPolyfill:s?.WebSocketPolyfill,awareness:s?.awareness,maxBackoffTime:s?.maxBackoffTime,disableBc:!0}),this._quiet=s?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${i}/${n}`)}static with(e){return{create:(t,s,i)=>{const o=i?{...e,...i}:e;return new $(t,s,o)}}}setupEventListeners(){this.provider.on("status",(({status:e})=>{"connected"===e?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===e&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(e=>{e&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((e,t)=>{const s=setTimeout((()=>{t(Error("WebSocket connection timeout"))}),1e4),i=({status:t})=>{"connected"===t&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,e())};this.provider.on("status",i),this.provider.wsconnected&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,e())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class O{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(e,t,s){const i=s?.name||e,o=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const r=s?.websocketProvider||O.sharedWebSocketProvider,l={};void 0!==s?.delay&&(l.delay=s.delay),void 0!==s?.factor&&(l.factor=s.factor),void 0!==s?.maxAttempts&&(l.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(l.minDelay=s.minDelay),void 0!==s?.maxDelay&&(l.maxDelay=s.maxDelay);const a=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info("Hocuspocus connected: "+i),s?.onConnect&&s.onConnect())},c=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info("Hocuspocus disconnected: "+i),s?.onDisconnect&&s.onDisconnect())},m=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info("Hocuspocus synced: "+i),s?.onSynced&&s.onSynced())},d=e=>{this.isDestroyed||("connecting"===e.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(e))};if(r){this.usesSharedSocket=!0;const e={websocketProvider:r,name:i,document:t,token:s?.token||null,onStatus:d,onConnect:a,onDisconnect:c,onSynced:m,...l};void 0!==s?.forceSyncInterval&&(e.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(e.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new n(e),this.provider.attach(),s?.quiet||console.info("Hocuspocus Provider initialized (multiplexed): "+i)}else{this.usesSharedSocket=!1;const e={url:o,name:i,document:t,token:s?.token||null,autoConnect:!1,onStatus:d,onConnect:a,onDisconnect:c,onSynced:m,...l};void 0!==s?.forceSyncInterval&&(e.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(e.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(e.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new n(e),s?.quiet||console.info(`Hocuspocus Provider initialized: ${o}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(e){if(O.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),O.sharedWebSocketProvider;const t={url:e.url};return e.WebSocketPolyfill&&(t.WebSocketPolyfill=e.WebSocketPolyfill),e.onConnect&&(t.onConnect=e.onConnect),e.onDisconnect&&(t.onDisconnect=e.onDisconnect),e.onStatus&&(t.onStatus=e.onStatus),O.sharedWebSocketProvider=new m(t),console.info("Shared Hocuspocus WebSocket created: "+e.url),O.sharedWebSocketProvider}static destroySharedWebSocket(){O.sharedWebSocketProvider&&(O.sharedWebSocketProvider.destroy(),O.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return O.sharedWebSocketProvider}static with(e){return{create:(t,s,i)=>{const o=i?{...e,...i}:e;return new O(t,s,o)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((e,t)=>{this.pendingConnectReject=t,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,t(Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||e()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void e();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}class R{type="remote";name="HttpAssetProvider";_options;constructor(e){this._options=e}static with(e){return{create:()=>new R(e)}}async init(){this._options.quiet||console.info("HttpAssetProvider initialized")}destroy(){}canResolve(e){return!0}async put(e,t){const s=t.id??this.generateUuid(),i={...t,id:s},o=await(this._options.headers?.())??{},n=await this._options.uploadUrl(i),r=this._options.upload??this.defaultUpload;return{id:(await r(n,e,i,o)).id??s,kind:t.kind??"file",mimeType:t.mimeType,size:e.size,createdAt:Date.now(),width:t.width,height:t.height,durationMs:t.durationMs,originalFilename:t.originalFilename}}async resolve(e){return this._options.resolveUrl(e)}async fetch(e){const t=await this._options.resolveUrl(e),s=await(this._options.headers?.())??{},i=await fetch(t,{headers:s});if(!i.ok)throw Error(`[HttpAssetProvider] Failed to fetch asset ${e}: ${i.status} ${i.statusText}`);return i.blob()}async delete(e){if(!this._options.deleteUrl)return;const t=await this._options.deleteUrl(e),s=await(this._options.headers?.())??{},i=await fetch(t,{method:"DELETE",headers:s});if(!i.ok)throw Error(`[HttpAssetProvider] Failed to delete asset ${e}: ${i.status} ${i.statusText}`);this._options.quiet||console.info("HttpAssetProvider: deleted asset "+e)}defaultUpload=async(e,t,s,i)=>{const o=new FormData;o.append("metadata",JSON.stringify(s)),o.append("file",t,s.originalFilename||`${s.id}.${this.extensionFromMime(s.mimeType)}`);const n=await fetch(e,{method:"POST",headers:i,body:o});if(!n.ok)throw Error(`[HttpAssetProvider] Upload failed: ${n.status} ${n.statusText}`);return(n.headers.get("content-type")||"").includes("application/json")?await n.json():{}};extensionFromMime(e){const t=e.indexOf("/");return t>=0?e.slice(t+1):"bin"}generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}class H{type="remote";name="PresignedAssetProvider";_options;constructor(e){this._options=e}static with(e){return{create:()=>new H(e)}}async init(){this._options.quiet||console.info("PresignedAssetProvider initialized")}destroy(){}canResolve(e){return!0}async put(e,t){const s=await this._options.getUploadDescriptor(t),i=s.method??"PUT",o={...s.headers??{}};let n;if(o["Content-Type"]||o["content-type"]||(o["Content-Type"]=t.mimeType),"POST"===i&&s.fields){const t=new FormData;for(const[e,i]of Object.entries(s.fields))t.append(e,i);t.append("file",e),n=t,delete o["Content-Type"],delete o["content-type"]}else n=e;const r=await fetch(s.url,{method:i,headers:o,body:n});if(!r.ok)throw Error(`[PresignedAssetProvider] Upload failed: ${r.status} ${r.statusText}`);return{id:s.id,kind:t.kind??"file",mimeType:t.mimeType,size:e.size,createdAt:Date.now(),width:t.width,height:t.height,durationMs:t.durationMs,originalFilename:t.originalFilename}}async resolve(e){return this._options.getDownloadUrl(e)}async fetch(e){const t=await this._options.getDownloadUrl(e),s=await fetch(t);if(!s.ok)throw Error(`[PresignedAssetProvider] Failed to fetch asset ${e}: ${s.status} ${s.statusText}`);return s.blob()}async delete(e){this._options.deleteAsset&&(await this._options.deleteAsset(e),this._options.quiet||console.info("PresignedAssetProvider: deleted asset "+e))}}export{F as BroadcastSyncProvider,O as HocuspocusSyncProvider,R as HttpAssetProvider,H as PresignedAssetProvider,$ as WebSocketSyncProvider}
1
+ export{g as getAssetPath,r as render,s as setAssetPath,a as setNonce,b as setPlatformOptions}from"./p-BWj1eE2b.js";export{A as AssetNotFoundError,I as IndexedDBAssetProvider,i as KritzelAssetResolver,d as KritzelBrushTool,b as KritzelGroup,a as KritzelImage,e as KritzelLineTool,h as KritzelSelectionTool,c as KritzelShape,g as KritzelShapeTool,K as KritzelText,f as KritzelTextTool,S as ShapeType}from"./p-DwZAEb-2.js";export{a as KritzelLine,K as KritzelPath}from"./p-BhMchyAR.js";export{A as APP_STATE_MIGRATIONS,I as IndexedDBSyncProvider,d as KritzelAlignment,c as KritzelAnchorManager,b as KritzelCursorHelper,K as KritzelEraserTool,a as KritzelImageTool,W as WORKSPACE_MIGRATIONS,r as runMigrations}from"./p-B7jb9G4E.js";import*as t from"yjs";import{WebsocketProvider as o}from"y-websocket";import{H as n,a as m}from"./kritzel-editor.js";export{d as DEFAULT_ASSET_STORAGE_CONFIG,D as DEFAULT_BRUSH_CONFIG,c as DEFAULT_LINE_TOOL_CONFIG,b as DEFAULT_TEXT_CONFIG,KritzelEditor,defineCustomElement as defineCustomElementKritzelEditor}from"./kritzel-editor.js";export{K as KritzelWorkspace,W as WORKSPACE_EXPORT_VERSION}from"./p-DhMlShij.js";export{K as KritzelThemeManager,d as darkTheme,l as lightTheme}from"./p-D_Tdq4Z0.js";export{C as CURRENT_APP_STATE_SCHEMA_VERSION,a as CURRENT_WORKSPACE_SCHEMA_VERSION}from"./p-CW-VyJgK.js";export{KritzelActiveUsers,defineCustomElement as defineCustomElementKritzelActiveUsers}from"./kritzel-active-users.js";export{KritzelAvatar,defineCustomElement as defineCustomElementKritzelAvatar}from"./kritzel-avatar.js";export{KritzelAwarenessCursors,defineCustomElement as defineCustomElementKritzelAwarenessCursors}from"./kritzel-awareness-cursors.js";export{KritzelBackToContent,defineCustomElement as defineCustomElementKritzelBackToContent}from"./kritzel-back-to-content.js";export{KritzelBrushStyle,defineCustomElement as defineCustomElementKritzelBrushStyle}from"./kritzel-brush-style.js";export{KritzelButton,defineCustomElement as defineCustomElementKritzelButton}from"./kritzel-button.js";export{KritzelColor,defineCustomElement as defineCustomElementKritzelColor}from"./kritzel-color.js";export{KritzelColorPalette,defineCustomElement as defineCustomElementKritzelColorPalette}from"./kritzel-color-palette.js";export{KritzelContextMenu,defineCustomElement as defineCustomElementKritzelContextMenu}from"./kritzel-context-menu.js";export{KritzelControls,defineCustomElement as defineCustomElementKritzelControls}from"./kritzel-controls.js";export{KritzelCurrentUser,defineCustomElement as defineCustomElementKritzelCurrentUser}from"./kritzel-current-user.js";export{KritzelCurrentUserDialog,defineCustomElement as defineCustomElementKritzelCurrentUserDialog}from"./kritzel-current-user-dialog.js";export{KritzelCursorTrail,defineCustomElement as defineCustomElementKritzelCursorTrail}from"./kritzel-cursor-trail.js";export{KritzelDialog,defineCustomElement as defineCustomElementKritzelDialog}from"./kritzel-dialog.js";export{KritzelDropdown,defineCustomElement as defineCustomElementKritzelDropdown}from"./kritzel-dropdown.js";export{KritzelEngine,defineCustomElement as defineCustomElementKritzelEngine}from"./kritzel-engine.js";export{KritzelExport,defineCustomElement as defineCustomElementKritzelExport}from"./kritzel-export.js";export{KritzelFont,defineCustomElement as defineCustomElementKritzelFont}from"./kritzel-font.js";export{KritzelFontFamily,defineCustomElement as defineCustomElementKritzelFontFamily}from"./kritzel-font-family.js";export{KritzelFontSize,defineCustomElement as defineCustomElementKritzelFontSize}from"./kritzel-font-size.js";export{KritzelIcon,defineCustomElement as defineCustomElementKritzelIcon}from"./kritzel-icon.js";export{KritzelInput,defineCustomElement as defineCustomElementKritzelInput}from"./kritzel-input.js";export{KritzelLineEndings,defineCustomElement as defineCustomElementKritzelLineEndings}from"./kritzel-line-endings.js";export{KritzelLoginDialog,defineCustomElement as defineCustomElementKritzelLoginDialog}from"./kritzel-login-dialog.js";export{KritzelMasterDetail,defineCustomElement as defineCustomElementKritzelMasterDetail}from"./kritzel-master-detail.js";export{KritzelMenu,defineCustomElement as defineCustomElementKritzelMenu}from"./kritzel-menu.js";export{KritzelMenuItem,defineCustomElement as defineCustomElementKritzelMenuItem}from"./kritzel-menu-item.js";export{KritzelMoreMenu,defineCustomElement as defineCustomElementKritzelMoreMenu}from"./kritzel-more-menu.js";export{KritzelNumericInput,defineCustomElement as defineCustomElementKritzelNumericInput}from"./kritzel-numeric-input.js";export{KritzelOpacitySlider,defineCustomElement as defineCustomElementKritzelOpacitySlider}from"./kritzel-opacity-slider.js";export{KritzelPillTabs,defineCustomElement as defineCustomElementKritzelPillTabs}from"./kritzel-pill-tabs.js";export{KritzelPortal,defineCustomElement as defineCustomElementKritzelPortal}from"./kritzel-portal.js";export{KritzelSettings,defineCustomElement as defineCustomElementKritzelSettings}from"./kritzel-settings.js";export{KritzelShapeFill,defineCustomElement as defineCustomElementKritzelShapeFill}from"./kritzel-shape-fill.js";export{KritzelShareDialog,defineCustomElement as defineCustomElementKritzelShareDialog}from"./kritzel-share-dialog.js";export{KritzelSlideToggle,defineCustomElement as defineCustomElementKritzelSlideToggle}from"./kritzel-slide-toggle.js";export{KritzelSplitButton,defineCustomElement as defineCustomElementKritzelSplitButton}from"./kritzel-split-button.js";export{KritzelStrokeSize,defineCustomElement as defineCustomElementKritzelStrokeSize}from"./kritzel-stroke-size.js";export{KritzelToolConfig,defineCustomElement as defineCustomElementKritzelToolConfig}from"./kritzel-tool-config.js";export{KritzelTooltip,defineCustomElement as defineCustomElementKritzelTooltip}from"./kritzel-tooltip.js";export{KritzelUtilityPanel,defineCustomElement as defineCustomElementKritzelUtilityPanel}from"./kritzel-utility-panel.js";export{KritzelWorkspaceManager,defineCustomElement as defineCustomElementKritzelWorkspaceManager}from"./kritzel-workspace-manager.js";const u=Math.floor,z=127,p=Number.MAX_SAFE_INTEGER;class E{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const y=()=>new E,w=e=>{const t=new Uint8Array((e=>{let t=e.cpos;for(let s=0;s<e.bufs.length;s++)t+=e.bufs[s].length;return t})(e));let s=0;for(let i=0;i<e.bufs.length;i++){const o=e.bufs[i];t.set(o,s),s+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),s),t},k=(e,t)=>{const s=e.cbuf.length;e.cpos===s&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*s),e.cpos=0),e.cbuf[e.cpos++]=t},x=(e,t)=>{for(;t>z;)k(e,128|z&t),t=u(t/128);k(e,z&t)},T=(e,t)=>{x(e,t.byteLength),((e,t)=>{const s=e.cbuf.length,i=e.cpos,o=((e,t)=>e<t?e:t)(s-i,t.length),n=t.length-o;e.cbuf.set(t.subarray(0,o),i),e.cpos+=o,n>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(((e,t)=>e>t?e:t)(2*s,n)),e.cbuf.set(t.subarray(o)),e.cpos=n)})(e,t)},j=e=>Error(e),P=j("Unexpected end of array"),v=j("Integer out of Range");class U{constructor(e){this.arr=e,this.pos=0}}const M=e=>((e,t)=>{const s=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,s})(e,_(e)),_=e=>{let t=0,s=1;const i=e.arr.length;for(;e.pos<i;){const i=e.arr[e.pos++];if(t+=(i&z)*s,s*=128,i<128)return t;if(t>p)throw v}throw P};class F{type="local";doc;channel;_synced=!1;constructor(e,t,s){this.doc=t,this.channel=new BroadcastChannel(e),this.channel.onmessage=e=>{this.handleMessage(e.data)},this.doc.on("update",this.handleDocUpdate),this.broadcastSync(),setTimeout((()=>{this._synced=!0}),100),s?.quiet||console.info("BroadcastChannel Provider initialized: "+e)}handleDocUpdate=(e,t)=>{if(t!==this){const t=y();x(t,0),T(t,e),this.channel.postMessage(w(t))}};handleMessage(e){const s=(e=>new U(e))(new Uint8Array(e));switch(_(s)){case 0:const e=M(s);t.applyUpdate(this.doc,e,this);break;case 1:this.broadcastSync();break;case 2:const i=M(s),o=t.encodeStateAsUpdate(this.doc,i);if(o.length>0){const e=y();x(e,0),T(e,o),this.channel.postMessage(w(e))}}}broadcastSync(){const e=y();x(e,2),T(e,t.encodeStateVector(this.doc)),this.channel.postMessage(w(e))}async connect(){if(!this._synced)return new Promise((e=>{const t=()=>{this._synced?e():setTimeout(t,50)};t()}))}disconnect(){}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.doc.off("update",this.handleDocUpdate),this.channel.close()}}class ${type="network";provider;isConnected=!1;_quiet=!1;get awareness(){return this.provider.awareness}constructor(e,t,s){const i=s?.url||"ws://localhost:1234",n=s?.roomName||e;this.provider=new o(i,n,t,{params:s?.params,protocols:s?.protocols,WebSocketPolyfill:s?.WebSocketPolyfill,awareness:s?.awareness,maxBackoffTime:s?.maxBackoffTime,disableBc:!0}),this._quiet=s?.quiet??!1,this.setupEventListeners(),this._quiet||console.info(`WebSocket Provider initialized: ${i}/${n}`)}static with(e){return{create:(t,s,i)=>{const o=i?{...e,...i}:e;return new $(t,s,o)}}}setupEventListeners(){this.provider.on("status",(({status:e})=>{"connected"===e?(this.isConnected=!0,this._quiet||console.info("WebSocket connected")):"disconnected"===e&&(this.isConnected=!1,this._quiet||console.info("WebSocket disconnected"))})),this.provider.on("sync",(e=>{e&&!this._quiet&&console.info("WebSocket synced")}))}async connect(){if(!this.isConnected)return new Promise(((e,t)=>{const s=setTimeout((()=>{t(Error("WebSocket connection timeout"))}),1e4),i=({status:t})=>{"connected"===t&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,e())};this.provider.on("status",i),this.provider.wsconnected&&(clearTimeout(s),this.provider.off("status",i),this.isConnected=!0,e())}))}disconnect(){this.provider&&this.provider.disconnect(),this.isConnected=!1}async reconnect(){return this.disconnect(),this.connect()}destroy(){this.provider&&this.provider.destroy(),this.isConnected=!1}}class O{type="network";provider;isConnected=!1;isSynced=!1;usesSharedSocket=!1;isDestroyed=!1;connectTimeout=null;pendingConnectReject=null;connectionTimeoutMs;_connectionStatus="disconnected";visibilityHandler=null;onlineHandler=null;get awareness(){return this.provider.awareness}get connectionStatus(){return this._connectionStatus}static sharedWebSocketProvider=null;constructor(e,t,s){const i=s?.name||e,o=s?.url||"ws://localhost:1234";this.connectionTimeoutMs=s?.connectionTimeout??1e4;const r=s?.websocketProvider||O.sharedWebSocketProvider,l={};void 0!==s?.delay&&(l.delay=s.delay),void 0!==s?.factor&&(l.factor=s.factor),void 0!==s?.maxAttempts&&(l.maxAttempts=s.maxAttempts),void 0!==s?.minDelay&&(l.minDelay=s.minDelay),void 0!==s?.maxDelay&&(l.maxDelay=s.maxDelay);const a=()=>{this.isDestroyed||(this.isConnected=!0,this._connectionStatus="connected",s?.quiet||console.info("Hocuspocus connected: "+i),s?.onConnect&&s.onConnect())},c=()=>{this.isDestroyed||(this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected",s?.quiet||console.info("Hocuspocus disconnected: "+i),s?.onDisconnect&&s.onDisconnect())},m=()=>{this.isDestroyed||(this.isSynced=!0,this._connectionStatus="synced",s?.quiet||console.info("Hocuspocus synced: "+i),s?.onSynced&&s.onSynced())},d=e=>{this.isDestroyed||("connecting"===e.status&&(this._connectionStatus="connecting"),s?.onStatus&&s.onStatus(e))};if(r){this.usesSharedSocket=!0;const e={websocketProvider:r,name:i,document:t,token:s?.token||null,onStatus:d,onConnect:a,onDisconnect:c,onSynced:m,...l};void 0!==s?.forceSyncInterval&&(e.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(e.onAuthenticationFailed=s.onAuthenticationFailed),this.provider=new n(e),this.provider.attach(),s?.quiet||console.info("Hocuspocus Provider initialized (multiplexed): "+i)}else{this.usesSharedSocket=!1;const e={url:o,name:i,document:t,token:s?.token||null,autoConnect:!1,onStatus:d,onConnect:a,onDisconnect:c,onSynced:m,...l};void 0!==s?.forceSyncInterval&&(e.forceSyncInterval=s.forceSyncInterval),s?.onAuthenticationFailed&&(e.onAuthenticationFailed=s.onAuthenticationFailed),s?.WebSocketPolyfill&&(e.WebSocketPolyfill=s.WebSocketPolyfill),this.provider=new n(e),s?.quiet||console.info(`Hocuspocus Provider initialized: ${o}/${i}`)}this.setupBrowserEventListeners()}setupBrowserEventListeners(){"undefined"!=typeof document&&(this.visibilityHandler=()=>{"visible"!==document.visibilityState||this.isConnected||this.isDestroyed||this.provider.connect()},document.addEventListener("visibilitychange",this.visibilityHandler)),"undefined"!=typeof window&&(this.onlineHandler=()=>{this.isConnected||this.isDestroyed||this.provider.connect()},window.addEventListener("online",this.onlineHandler))}removeBrowserEventListeners(){this.visibilityHandler&&"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null),this.onlineHandler&&"undefined"!=typeof window&&(window.removeEventListener("online",this.onlineHandler),this.onlineHandler=null)}static createSharedWebSocket(e){if(O.sharedWebSocketProvider)return console.warn("Shared WebSocket already exists. Returning existing instance."),O.sharedWebSocketProvider;const t={url:e.url};return e.WebSocketPolyfill&&(t.WebSocketPolyfill=e.WebSocketPolyfill),e.onConnect&&(t.onConnect=e.onConnect),e.onDisconnect&&(t.onDisconnect=e.onDisconnect),e.onStatus&&(t.onStatus=e.onStatus),O.sharedWebSocketProvider=new m(t),console.info("Shared Hocuspocus WebSocket created: "+e.url),O.sharedWebSocketProvider}static destroySharedWebSocket(){O.sharedWebSocketProvider&&(O.sharedWebSocketProvider.destroy(),O.sharedWebSocketProvider=null,console.info("Shared Hocuspocus WebSocket destroyed"))}static getSharedWebSocket(){return O.sharedWebSocketProvider}static with(e){return{create:(t,s,i)=>{const o=i?{...e,...i}:e;return new O(t,s,o)}}}async connect(){if(!this.isSynced&&!this.isDestroyed)return this._connectionStatus="connecting",new Promise(((e,t)=>{this.pendingConnectReject=t,this.connectTimeout=setTimeout((()=>{this.pendingConnectReject=null,this.connectTimeout=null,t(Error("Hocuspocus connection timeout"))}),this.connectionTimeoutMs);const s=()=>{this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),this.isDestroyed||e()};if(this.provider.on("synced",s),this.provider.isSynced)return this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject=null,this.provider.off("synced",s),void e();this.isConnected||this.usesSharedSocket||this.provider.connect()}))}async reconnect(){return this.disconnect(),this.connect()}disconnect(){this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.provider&&(this.usesSharedSocket?this.provider.detach():this.provider.disconnect()),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}destroy(){this.isDestroyed=!0,this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=null),this.pendingConnectReject&&(this.pendingConnectReject=null),this.removeBrowserEventListeners(),this.provider&&this.provider.destroy(),this.isConnected=!1,this.isSynced=!1,this._connectionStatus="disconnected"}}class R{type="remote";name="HttpAssetProvider";_options;constructor(e){this._options=e}static with(e){return{create:()=>new R(e)}}async init(){this._options.quiet||console.info("HttpAssetProvider initialized")}destroy(){}canResolve(e){return!0}async put(e,t){const s=t.id??this.generateUuid(),i={...t,id:s},o=await(this._options.headers?.())??{},n=await this._options.uploadUrl(i),r=this._options.upload??this.defaultUpload;return{id:(await r(n,e,i,o)).id??s,kind:t.kind??"file",mimeType:t.mimeType,size:e.size,createdAt:Date.now(),width:t.width,height:t.height,durationMs:t.durationMs,originalFilename:t.originalFilename}}async resolve(e){return this._options.resolveUrl(e)}async fetch(e){const t=await this._options.resolveUrl(e),s=await(this._options.headers?.())??{},i=await fetch(t,{headers:s});if(!i.ok)throw Error(`[HttpAssetProvider] Failed to fetch asset ${e}: ${i.status} ${i.statusText}`);return i.blob()}async delete(e){if(!this._options.deleteUrl)return;const t=await this._options.deleteUrl(e),s=await(this._options.headers?.())??{},i=await fetch(t,{method:"DELETE",headers:s});if(!i.ok)throw Error(`[HttpAssetProvider] Failed to delete asset ${e}: ${i.status} ${i.statusText}`);this._options.quiet||console.info("HttpAssetProvider: deleted asset "+e)}defaultUpload=async(e,t,s,i)=>{const o=new FormData;o.append("metadata",JSON.stringify(s)),o.append("file",t,s.originalFilename||`${s.id}.${this.extensionFromMime(s.mimeType)}`);const n=await fetch(e,{method:"POST",headers:i,body:o});if(!n.ok)throw Error(`[HttpAssetProvider] Upload failed: ${n.status} ${n.statusText}`);return(n.headers.get("content-type")||"").includes("application/json")?await n.json():{}};extensionFromMime(e){const t=e.indexOf("/");return t>=0?e.slice(t+1):"bin"}generateUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}class B{type="remote";name="PresignedAssetProvider";_options;constructor(e){this._options=e}static with(e){return{create:()=>new B(e)}}async init(){this._options.quiet||console.info("PresignedAssetProvider initialized")}destroy(){}canResolve(e){return!0}async put(e,t){const s=await this._options.getUploadDescriptor(t),i=s.method??"PUT",o={...s.headers??{}};let n;if(o["Content-Type"]||o["content-type"]||(o["Content-Type"]=t.mimeType),"POST"===i&&s.fields){const t=new FormData;for(const[e,i]of Object.entries(s.fields))t.append(e,i);t.append("file",e),n=t,delete o["Content-Type"],delete o["content-type"]}else n=e;const r=await fetch(s.url,{method:i,headers:o,body:n});if(!r.ok)throw Error(`[PresignedAssetProvider] Upload failed: ${r.status} ${r.statusText}`);return{id:s.id,kind:t.kind??"file",mimeType:t.mimeType,size:e.size,createdAt:Date.now(),width:t.width,height:t.height,durationMs:t.durationMs,originalFilename:t.originalFilename}}async resolve(e){return this._options.getDownloadUrl(e)}async fetch(e){const t=await this._options.getDownloadUrl(e),s=await fetch(t);if(!s.ok)throw Error(`[PresignedAssetProvider] Failed to fetch asset ${e}: ${s.status} ${s.statusText}`);return s.blob()}async delete(e){this._options.deleteAsset&&(await this._options.deleteAsset(e),this._options.quiet||console.info("PresignedAssetProvider: deleted asset "+e))}}export{F as BroadcastSyncProvider,O as HocuspocusSyncProvider,R as HttpAssetProvider,B as PresignedAssetProvider,$ as WebSocketSyncProvider}
@@ -1 +1 @@
1
- import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-BWj1eE2b.js";import{K as r,d as a}from"./p-A7Ult9iv.js";import{I as c,S as h,h as l,d,e as u,g as p,f as m,j as g,k as b,l as f}from"./p-DwZAEb-2.js";import{e as y,f as k,K as w,a as v,d as z,D as C,g as j}from"./p-eez_2Ccc.js";import{D as A}from"./p-D_Tdq4Z0.js";import{K as S}from"./p-jGOpkGDl.js";import"./p-BhMchyAR.js";import*as E from"yjs";import"y-indexeddb";import"y-websocket";import{d as x}from"./p-CaKSDRid.js";import{d as T}from"./p-Cz2gQKbL.js";import{d as O}from"./p-DORo_go4.js";import{d as I}from"./p-BoRQF_Zc.js";import{d as U}from"./p-C_OSXZqJ.js";import{d as M}from"./p-DDm8Gefw.js";import{d as D}from"./p-DeqXAEjq.js";import{d as R}from"./p-BvgGpgKP.js";import{d as W}from"./p-BcWZP5At.js";import{d as B}from"./p-DYHF_MSN.js";import{d as P}from"./p-BDOSy6zd.js";import{d as V}from"./p-DXO_ppUK.js";import{d as L}from"./p-0F9_lw6l.js";import{d as F}from"./p-CBTqCoUx.js";import{d as N}from"./p-BmYsz1bP.js";import{d as K}from"./p-C4vg_-vg.js";import{d as J}from"./p-qBqQhAmh.js";import{d as G}from"./p-DDBaFNFi.js";import{d as q}from"./p-BVEYAGm1.js";import{d as _}from"./p-D6KNaj_Y.js";import{d as H}from"./p-ZpItdhxS.js";import{d as Y}from"./p-Czaea0WP.js";import{d as Q,a as Z}from"./p-DQ1fRE9J.js";import{d as $}from"./p-xHh03blG.js";import{d as X}from"./p-B5a3arJg.js";import{d as tt}from"./p-DemKKw9U.js";import{d as et}from"./p-DVEfOb8T.js";import{d as st}from"./p-BLjdzUzs.js";import{d as it}from"./p-KAwmnjZJ.js";import{d as nt}from"./p-DEd2L0e3.js";import{d as ot}from"./p-R60vdaIY.js";import{d as rt}from"./p-CTj2UdbS.js";import{d as at}from"./p-CRsnBR8O.js";import{d as ct}from"./p-BK9c3UTv.js";import{d as ht}from"./p-BeOG6L2d.js";import{d as lt}from"./p-0cs6zQLB.js";import{d as dt}from"./p-BAjrJjMX.js";import{d as ut}from"./p-BpRNLd4z.js";const pt=Math.floor,mt=127,gt=Number.MAX_SAFE_INTEGER,bt="undefined"!=typeof TextEncoder?new TextEncoder:null,ft=bt?t=>bt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let yt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});yt&&1===yt.decode(new Uint8Array).length&&(yt=null);const kt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},wt=(t,e)=>{for(;e>mt;)kt(t,128|mt&e),e=pt(e/128);kt(t,mt&e)},vt=new Uint8Array(3e4),zt=vt.length/3,Ct=bt&&bt.encodeInto?(t,e)=>{if(e.length<zt){const s=bt.encodeInto(e,vt).written||0;wt(t,s);for(let e=0;e<s;e++)kt(t,vt[e])}else jt(t,ft(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;wt(t,i);for(let e=0;e<i;e++)kt(t,s.codePointAt(e))},jt=(t,e)=>{wt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},At=t=>Error(t),St=At("Unexpected end of array"),Et=At("Integer out of Range"),xt=t=>t.arr[t.pos++],Tt=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&mt)*s,s*=128,i<128)return e;if(e>gt)throw Et}throw St},Ot=yt?t=>yt.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Tt(t)))(t)):t=>{let e=Tt(t);if(0===e)return"";{let s=String.fromCodePoint(xt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(xt(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}};var It;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(It||(It={}));const Ut=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Mt;async function Dt(t){return new Promise((e=>setTimeout(e,t)))}function Rt(t,e){let s=e.delay;if(0===s)return 0;if(e.factor&&(s*=Math.pow(e.factor,t.attemptNum-1),0!==e.maxDelay&&(s=Math.min(s,e.maxDelay))),e.jitter){const t=Math.ceil(e.minDelay),i=Math.floor(s);s=Math.floor(Math.random()*(i-t+1))+t}return Math.round(s)}!function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"}(Mt||(Mt={}));const Wt=Math.floor,Bt=128,Pt=127,Vt=Number.MAX_SAFE_INTEGER,Lt=()=>new Set,Ft=Array.from,Nt="undefined"!=typeof TextEncoder?new TextEncoder:null,Kt=Nt?t=>Nt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let Jt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Jt&&1===Jt.decode(new Uint8Array).length&&(Jt=null);class Gt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const qt=()=>new Gt,_t=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},Ht=t=>{const e=new Uint8Array(_t(t));let s=0;for(let i=0;i<t.bufs.length;i++){const n=t.bufs[i];e.set(n,s),s+=n.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),s),e},Yt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},Qt=(t,e)=>{for(;e>Pt;)Yt(t,Bt|Pt&e),e=Wt(e/128);Yt(t,Pt&e)},Zt=new Uint8Array(3e4),$t=Zt.length/3,Xt=Nt&&Nt.encodeInto?(t,e)=>{if(e.length<$t){const s=Nt.encodeInto(e,Zt).written||0;Qt(t,s);for(let e=0;e<s;e++)Yt(t,Zt[e])}else te(t,Kt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;Qt(t,i);for(let e=0;e<i;e++)Yt(t,s.codePointAt(e))},te=(t,e)=>{Qt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},ee=t=>Error(t),se=ee("Unexpected end of array"),ie=ee("Integer out of Range");class ne{constructor(t){this.arr=t,this.pos=0}}const oe=t=>new ne(t),re=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,ce(t)),ae=t=>t.arr[t.pos++],ce=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Pt)*s,s*=128,i<Bt)return e;if(e>Vt)throw ie}throw se},he=Jt?t=>Jt.decode(re(t)):t=>{let e=ce(t);if(0===e)return"";{let s=String.fromCodePoint(ae(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(ae(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}},le=Date.now,de=()=>new Map;class ue{constructor(){this._observers=de()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Lt).add(e)}once(t,e){const s=(...i)=>{this.off(t,s),e(...i)};this.on(t,s)}off(t,e){const s=this._observers.get(t);void 0!==s&&(s.delete(e),0===s.size&&this._observers.delete(t))}emit(t,e){return Ft((this._observers.get(t)||de()).values()).forEach((t=>t(...e)))}destroy(){this._observers=de()}}const pe=Object.keys,me=t=>pe(t).length,ge=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),be=(t,e)=>{if(null==t||null==e)return((t,e)=>t===e)(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;break;case Set:if(t.size!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;break;case Map:if(t.size!==e.size)return!1;for(const s of t.keys())if(!e.has(s)||!be(t.get(s),e.get(s)))return!1;break;case Object:if(me(t)!==me(e))return!1;for(const s in t)if(!ge(t,s)||!be(t[s],e[s]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!be(t[s],e[s]))return!1;break;default:return!1}return!0};class fe extends ue{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=le();null!==this.getLocalState()&&15e3<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const e=[];this.meta.forEach(((s,i)=>{i!==this.clientID&&3e4<=t-s.lastUpdated&&this.states.has(i)&&e.push(i)})),e.length>0&&ye(this,e,"timeout")}),Wt(3e3)),t.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const e=this.clientID,s=this.meta.get(e),i=void 0===s?0:s.clock+1,n=this.states.get(e);null===t?this.states.delete(e):this.states.set(e,t),this.meta.set(e,{clock:i,lastUpdated:le()});const o=[],r=[],a=[],c=[];null===t?c.push(e):null==n?null!=t&&o.push(e):(r.push(e),be(n,t)||a.push(e)),(o.length>0||a.length>0||c.length>0)&&this.emit("change",[{added:o,updated:a,removed:c},"local"]),this.emit("update",[{added:o,updated:r,removed:c},"local"])}setLocalStateField(t,e){const s=this.getLocalState();null!==s&&this.setLocalState({...s,[t]:e})}getStates(){return this.states}}const ye=(t,e,s)=>{const i=[];for(let s=0;s<e.length;s++){const n=e[s];if(t.states.has(n)){if(t.states.delete(n),n===t.clientID){const e=t.meta.get(n);t.meta.set(n,{clock:e.clock+1,lastUpdated:le()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},ke=(t,e,s=t.states)=>{const i=e.length,n=qt();Qt(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;Qt(n,i),Qt(n,a),Xt(n,JSON.stringify(r))}return Ht(n)};class we{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const s=this.callbacks[t];return s&&s.forEach((t=>t.apply(this,e))),this}off(t,e){const s=this.callbacks[t];return s&&(e?this.callbacks[t]=s.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}class ve{constructor(t){this.data=t,this.encoder=qt(),this.decoder=oe(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=he(t);return t.pos=e,s})(this.decoder)}readVarUint(){return ce(this.decoder)}readVarString(){return he(this.decoder)}readVarUint8Array(){return re(this.decoder)}writeVarUint(t){return Qt(this.encoder,t)}writeVarString(t){return Xt(this.encoder,t)}writeVarUint8Array(t){return te(this.encoder,t)}length(){return _t(this.encoder)}}var ze,Ce;!function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"}(ze||(ze={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(Ce||(Ce={}));class je{constructor(){this.encoder=qt()}get(t){return t.encoder}toUint8Array(){return Ht(this.encoder)}}class Ae extends je{constructor(){super(...arguments),this.type=ze.CLOSE,this.description="Ask the server to close the connection"}get(t){return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),this.encoder}}class Se extends we{constructor(t){super(),this.messageQueue=[],this.configuration={url:"",autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=Ce.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(t),this.configuration.WebSocketPolyfill=t.WebSocketPolyfill?t.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(t){this.status=Ce.Connected,this.emit("status",{status:Ce.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===Ce.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===Ce.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(Ae,{documentName:t.configuration.name}),this.configuration.providerMap.delete(t.configuration.name))}setConfiguration(t={}){this.configuration={...this.configuration,...t},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===Ce.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const{retryPromise:t,cancelFunc:e}=(()=>{let t=!1;return{retryPromise:async function(t,e){const s=function(t){return t||(t={}),{delay:void 0===t.delay?200:t.delay,initialDelay:void 0===t.initialDelay?0:t.initialDelay,minDelay:void 0===t.minDelay?0:t.minDelay,maxDelay:void 0===t.maxDelay?0:t.maxDelay,factor:void 0===t.factor?0:t.factor,maxAttempts:void 0===t.maxAttempts?3:t.maxAttempts,timeout:void 0===t.timeout?0:t.timeout,jitter:!0===t.jitter,initialJitter:!0===t.initialJitter,handleError:void 0===t.handleError?null:t.handleError,handleTimeout:void 0===t.handleTimeout?null:t.handleTimeout,beforeAttempt:void 0===t.beforeAttempt?null:t.beforeAttempt,calculateDelay:void 0===t.calculateDelay?null:t.calculateDelay}}(e);for(const t of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const e=s[t];if(!Number.isInteger(e)||e<0)throw Error(`Value for ${t} must be an integer greater than or equal to 0`)}if(s.factor.constructor!==Number||s.factor<0)throw Error("Value for factor must be a number greater than or equal to 0");if(s.delay<s.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${s.delay}, minDelay: ${s.minDelay}`);const i={attemptNum:0,attemptsRemaining:s.maxAttempts?s.maxAttempts:-1,aborted:!1,abort(){i.aborted=!0}},n=s.calculateDelay||Rt,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await Dt(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await Dt(t)}return async function e(){if(s.beforeAttempt&&s.beforeAttempt(i,s),i.aborted){const t=Error("Attempt aborted");throw t.code="ATTEMPT_ABORTED",t}const o=async t=>{if(s.handleError&&await s.handleError(t,i,s),i.aborted||0===i.attemptsRemaining)throw t;i.attemptNum++;const o=n(i,s);return o&&await Dt(o),e()};return i.attemptsRemaining>0&&i.attemptsRemaining--,s.timeout?new Promise(((e,n)=>{const r=setTimeout((()=>{if(s.handleTimeout)try{e(s.handleTimeout(i,s))}catch(t){n(t)}else{const t=Error(`Retry timeout (attemptNum: ${i.attemptNum}, timeout: ${s.timeout})`);t.code="ATTEMPT_TIMEOUT",n(t)}}),s.timeout);t(i,s).then((t=>{clearTimeout(r),e(t)})).catch((t=>{clearTimeout(r),o(t).then(e).catch(n)}))})):t(i,s).catch(o)}()}(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:e=>{this.shouldConnect&&!t||e.abort()}}).catch((t=>{if(t&&"ATTEMPT_ABORTED"!==t.code)throw t})),cancelFunc:()=>{t=!0}}})();return this.cancelWebsocketRetry=e,t}attachWebSocketListeners(t,e){const{identifier:s}=t;this.webSocketHandlers[s]={message:t=>this.emit("message",t),close:t=>this.emit("close",{event:t}),open:t=>this.emit("open",t),error:t=>{e(t)}};const i=this.webSocketHandlers[t.identifier];Object.keys(i).forEach((e=>{t.addEventListener(e,i[e])}))}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:t}=this.webSocket,e=this.webSocketHandlers[t];Object.keys(e).forEach((s=>{var i;null===(i=this.webSocket)||void 0===i||i.removeEventListener(s,e[s]),delete this.webSocketHandlers[t]})),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise(((t,e)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const s=new this.configuration.WebSocketPolyfill(this.url);s.binaryType="arraybuffer",s.identifier=this.identifier,this.attachWebSocketListeners(s,e),this.webSocket=s,this.status=Ce.Connecting,this.emit("status",{status:Ce.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=le();const s=new ve(t.data).peekVarString();null===(e=this.configuration.providerMap.get(s))||void 0===e||e.onMessage(t)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Ce.Connected,this.emit("status",{status:Ce.Connected}),this.emit("connect"),this.messageQueue.forEach((t=>this.send(t))),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var t;null===(t=this.connectionAttempt)||void 0===t||t.reject(),this.connectionAttempt=null}checkConnection(){var t;this.status===Ce.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=le()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(null===(t=this.webSocket)||void 0===t||t.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let t=this.configuration.url;for(;"/"===t[t.length-1];)t=t.slice(0,t.length-1);return t}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,null!==this.webSocket)try{this.webSocket.close(),this.messageQueue=[]}catch(t){console.error(t)}}send(t){var e;(null===(e=this.webSocket)||void 0===e?void 0:e.readyState)===Mt.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=Ce.Disconnected,this.emit("status",{status:Ce.Disconnected}),this.emit("disconnect",{event:t}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout((()=>{this.connect()}),this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const Ee=(t,e,s)=>{try{E.applyUpdate(e,re(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},xe=Ee;class Te{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case ze.Sync:this.applySyncMessage(t,e);break;case ze.Awareness:this.applyAwarenessMessage(t);break;case ze.Auth:this.applyAuthMessage(t);break;case ze.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ze.Stateless:t.receiveStateless(he(s.decoder));break;case ze.SyncStatus:this.applySyncStatusMessage(t,1===(t=>{let e=t.arr[t.pos++],s=63&e,i=64;const n=(64&e)>0?-1:1;if(!(e&Bt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Pt)*i,i*=128,e<Bt)return n*s;if(s>Vt)throw ie}throw se})(s.decoder));break;case ze.CLOSE:const n={code:1e3,reason:he(s.decoder),target:t.configuration.websocketProvider.webSocket,type:"close"};t.onClose(),t.configuration.onClose({event:n}),t.forwardClose({event:n});break;default:throw Error("Can’t apply message of unknown type: "+i)}s.length()>n+1&&t.send(je,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(ze.Sync);const i=((t,e,s,i)=>{const n=ce(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{Qt(t,1),te(t,E.encodeStateAsUpdate(e,s))})(e,s,re(t))})(t,e,s);break;case 1:Ee(t,s,i);break;case 2:xe(t,s,i);break;default:throw Error("Unknown message type")}return n})(s.decoder,s.encoder,t.document,t);e&&1===i&&(t.synced=!0)}applySyncStatusMessage(t,e){e&&t.decrementUnsyncedChanges()}applyAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;((t,e,s)=>{const i=oe(e),n=le(),o=[],r=[],a=[],c=[],h=ce(i);for(let e=0;e<h;e++){const e=ce(i);let s=ce(i);const h=JSON.parse(he(i)),l=t.meta.get(e),d=t.states.get(e),u=void 0===l?0:l.clock;(u<s||u===s&&null===h&&t.states.has(e))&&(null===h?e===t.clientID&&null!=t.getLocalState()?s++:t.states.delete(e):t.states.set(e,h),t.meta.set(e,{clock:s,lastUpdated:n}),void 0===l&&null!==h?o.push(e):void 0!==l&&null===h?c.push(e):null!==h&&(be(h,d)||a.push(e),r.push(e)))}(o.length>0||a.length>0||c.length>0)&&t.emit("change",[{added:o,updated:a,removed:c},s]),(o.length>0||r.length>0||c.length>0)&&t.emit("update",[{added:o,updated:r,removed:c},s])})(t.awareness,e.readVarUint8Array(),t)}applyAuthMessage(t){const{message:e}=this;((t,e,s,i)=>{switch(Tt(t)){case It.Token:e();break;case It.PermissionDenied:s(Ot(t));break;case It.Authenticated:i(Ot(t))}})(e.decoder,t.sendToken.bind(t),t.permissionDeniedHandler.bind(t),t.authenticatedHandler.bind(t))}applyQueryAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;e.writeVarUint(ze.Awareness),e.writeVarUint8Array(ke(t.awareness,Array.from(t.awareness.getStates().keys())))}}class Oe{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return Ht(this.encoder)}send(t){null==t||t.send(this.create())}}class Ie extends je{constructor(){super(...arguments),this.type=ze.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{wt(t,It.Token),Ct(t,e)})(this.encoder,t.token),this.encoder}}class Ue extends je{constructor(){super(...arguments),this.type=ze.Awareness,this.description="Awareness states update"}get(t){if(void 0===t.awareness)throw Error("The awareness message requires awareness as an argument");if(void 0===t.clients)throw Error("The awareness message requires clients as an argument");let e;return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),e=void 0===t.states?ke(t.awareness,t.clients):ke(t.awareness,t.clients,t.states),te(this.encoder,e),this.encoder}}class Me extends je{constructor(){super(...arguments),this.type=ze.Stateless,this.description="A stateless message"}get(t){var e;return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),Xt(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class De extends je{constructor(){super(...arguments),this.type=ze.Sync,this.description="First sync step"}get(t){if(void 0===t.document)throw Error("The sync step one message requires document as an argument");return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{Qt(t,0);const s=E.encodeStateVector(e);te(t,s)})(this.encoder,t.document),this.encoder}}class Re extends je{constructor(){super(...arguments),this.type=ze.Sync,this.description="A document update"}get(t){return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{Qt(t,2),te(t,e)})(this.encoder,t.update),this.encoder}}class We extends Error{constructor(){super(...arguments),this.code=1001}}class Be extends we{constructor(t){var e,s,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=t=>this.emit("status",t),this.forwardClose=t=>this.emit("close",t),this.forwardDisconnect=t=>this.emit("disconnect",t),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(t),this.configuration.document=t.document?t.document:new E.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new fe(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),null===(e=this.awareness)||void 0===e||e.on("update",(()=>{this.emit("awarenessUpdate",{states:Ut(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Ut(this.awareness.getStates())})})),this.document.on("update",this.boundDocumentUpdateHandler),null===(i=this.awareness)||void 0===i||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&"number"==typeof this.configuration.forceSyncInterval&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(t={}){t.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new Se(t)),this.configuration={...this.configuration,...t}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),0===this.unsyncedChanges&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(De,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&ye(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Me,{documentName:this.configuration.name,payload:t})}async sendToken(){let t;try{t=await this.getToken()}catch(t){return void this.permissionDeniedHandler("Failed to get token during sendToken(): "+t)}this.send(Ie,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(Re,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Ue,{awareness:this.awareness,clients:n,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(t){this.isSynced!==t&&(this.isSynced=t,t&&this.emit("synced",{state:t}))}receiveStateless(t){this.emit("stateless",{payload:t})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(t){this.isAuthenticated=!1,this.emit("open",{event:t}),await this.sendToken(),this.startSync()}async getToken(){return"function"==typeof this.configuration.token?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(De,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Ue,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new Oe(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new ve(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new ve(t.data)}),new Te(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ye(this.awareness,Array.from(this.awareness.getStates().keys()).filter((t=>t!==this.document.clientID)),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(ye(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),"undefined"!=typeof window&&"removeEventListener"in window&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(t){this.emit("authenticationFailed",{reason:t}),this.isAuthenticated=!1}authenticatedHandler(t){this.isAuthenticated=!0,this.authorizedScope=t,this.emit("authenticated",{scope:t})}setAwarenessField(t,e){if(!this.awareness)throw new We(`Cannot set awareness field "${t}" to ${JSON.stringify(e)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(t,e)}}const Pe={type:"pen",color:A[0],size:16,palettes:{pen:[...A]}},Ve={color:A[0],size:8,fontFamily:"Arial",palette:[...A]},Le={color:A[0],size:4,palette:[...A],arrows:{end:{enabled:!0,style:"triangle"}}},Fe={providers:[c]},Ne={shapeType:h.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:A[0],strokeWidth:4,fontColor:A[0],fontSize:16,fontFamily:"Arial",palette:[...A]},Ke=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.isReady=s(this,"isReady"),this.activeWorkspaceChange=s(this,"activeWorkspaceChange"),this.objectsChange=s(this,"objectsChange"),this.objectsAdded=s(this,"objectsAdded"),this.objectsRemoved=s(this,"objectsRemoved"),this.objectsUpdated=s(this,"objectsUpdated"),this.undoStateChange=s(this,"undoStateChange"),this.themeChange=s(this,"themeChange"),this.viewportChange=s(this,"viewportChange"),this.logout=s(this,"logout"),this.login=s(this,"login"),this.isPublicChange=s(this,"isPublicChange"),this.awarenessChange=s(this,"awarenessChange")}get host(){return this}scaleMax=y;scaleMin=k;lockDrawingScale=!0;viewportBoundaryLeft=-1/0;viewportBoundaryRight=1/0;viewportBoundaryTop=-1/0;viewportBoundaryBottom=1/0;wheelEnabled=!0;debugInfo={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0};user;activeUsers;controls=[{name:"selection",type:"tool",isDefault:!0,tool:l,icon:"cursor"},{name:"brush",type:"tool",tool:d,icon:"pen",config:Pe},{name:"eraser",type:"tool",tool:w,icon:"eraser"},{name:"line",type:"tool",tool:u,icon:"arrow",config:Le},{name:"shape",type:"tool",tool:p,icon:"shape-rectangle",config:Ne,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:h.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:h.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:h.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:m,icon:"type",config:Ve},{name:"image",type:"tool",tool:v,icon:"image"},{name:"config",type:"config"}];globalContextMenuItems=[{label:"Paste",icon:"paste",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Select All",icon:"select-all",disabled:async()=>0===(await this.engineRef.getObjectsInViewport()).length,action:()=>this.selectAllObjectsInViewport()}];objectContextMenuItems=[{label:"Copy",icon:"copy",group:"clipboard",action:()=>this.engineRef.copy()},{label:"Cut",icon:"cut",group:"clipboard",action:()=>this.engineRef.cut()},{label:"Paste",icon:"paste",group:"clipboard",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Order",icon:"ordering",group:"other",children:[{label:"Bring to Front",icon:"bring-to-front",action:()=>this.engineRef.bringToFront()},{label:"Send to Back",icon:"send-to-back",action:()=>this.engineRef.sendToBack()},{label:"Move Up",icon:"arrow-up-from-dot",action:()=>this.engineRef.bringForward()},{label:"Move Down",icon:"arrow-down-from-dot",action:()=>this.engineRef.sendBackward()}]},{label:"Align",icon:"align",group:"other",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,children:[{label:"Align Left",icon:"align-start-vertical",action:()=>this.engineRef.alignObjects(z.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(z.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(z.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(z.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(z.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(z.EndVertical)}]},{label:"Group",icon:"group",group:"other",children:[{label:"Group",icon:"group",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,action:()=>this.engineRef.group()},{label:"Ungroup",icon:"ungroup",disabled:async()=>!(await this.engineRef.getSelectedObjects()).some((t=>"KritzelGroup"===t.__class__)),action:()=>this.engineRef.ungroup()}]},{label:"Export",icon:"download",group:"export",children:[{label:"Export as SVG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsSvg()},{label:"Export as PNG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsPng()}]},{label:"Delete",icon:"delete",group:"edit",action:()=>this.engineRef.delete()}];customSvgIcons={};isControlsVisible=!0;isUtilityPanelVisible=!0;isWorkspaceManagerVisible=!0;isMoreMenuVisible=!0;syncConfig=C;assetStorageConfig=Fe;cursorTarget;loginConfig={providers:[{label:"Sign in with Google",icon:"google",name:"Google"}]};isLoading=!1;editorId;activeWorkspaceId;isReady;activeWorkspaceChange;objectsChange;objectsAdded;objectsRemoved;objectsUpdated;undoStateChange;themeChange;viewportChange;logout;login;isPublicChange;awarenessChange;isEngineReady=!1;isControlsReady=!1;isWorkspaceManagerReady=!1;workspaces=[];activeWorkspace;isVirtualKeyboardOpen=!1;undoState=null;isBackToContentButtonVisible=!1;currentTheme="light";shortcuts=[];currentIsPublic=!1;onIsEngineReady(t){t&&this.isControlsReady&&this.checkIsReady()}onIsControlsReady(t){t&&this.isEngineReady&&this.checkIsReady()}onWorkspacesChange(t){const e=this.activeWorkspace;if(e){const s=t.find((t=>t.id===e.id));s&&s!==e&&(this.activeWorkspace=s)}if(this.activeWorkspaceId){const e=t.find((t=>t.id===this.activeWorkspaceId));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}}onActiveWorkspaceChange(){this.updateCurrentIsPublic()}onActiveWorkspaceIdChange(t){if(!t)return;if(0===this.workspaces.length)return;const e=this.workspaces.find((e=>e.id===t));e?e!==this.activeWorkspace&&(this.activeWorkspace=e):console.warn("[KritzelEditor] No workspace found with ID: "+t)}onCurrentThemeChange(){setTimeout((()=>this.setOsSpecificCssVariables()),0)}onTouchStart(t){t.cancelable&&t.preventDefault()}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async getSelectedObjects(){return this.engineRef.getSelectedObjects()}async selectObjects(t){return this.engineRef.selectObjects(t)}async selectAllObjectsInViewport(){return this.engineRef.selectAllObjectsInViewport()}async clearSelection(){this.engineRef.clearSelection()}async centerObjectInViewport(t){return this.engineRef.centerObjectInViewport(t)}async backToContent(){return this.engineRef.backToContent()}async centerAllObjects(t=!0){return this.engineRef.centerAllObjects(t)}async setViewport(t,e,s){return this.engineRef.setViewport(t,e,s)}async panTo(t,e){return this.engineRef.panTo(t,e)}async zoomTo(t,e,s){return this.engineRef.zoomTo(t,e,s)}async getViewport(){return this.engineRef.getViewport()}async screenToWorld(t,e){return this.engineRef.screenToWorld(t,e)}async worldToScreen(t,e){return this.engineRef.worldToScreen(t,e)}async createWorkspace(t){return this.engineRef.createWorkspace(t)}async updateWorkspace(t){return this.engineRef.updateWorkspace(t)}async deleteWorkspace(t){return this.engineRef.deleteWorkspace(t)}async getWorkspaces(){return this.engineRef.getWorkspaces()}async getActiveWorkspace(){return this.engineRef.getActiveWorkspace()}async loadSharedWorkspace(t){return this.engineRef.loadSharedWorkspace(t)}async reinitSync(){return this.engineRef.reinitSync()}async registerTool(t,e,s){return this.engineRef.registerTool(t,e,s)}async changeActiveTool(t){return this.engineRef.changeActiveTool(t)}async disable(){return this.engineRef.disable()}async enable(){return this.engineRef.enable()}async copy(){return this.engineRef.copy()}async cut(){return this.engineRef.cut()}async paste(t,e){return this.engineRef.paste(t,e)}async delete(){return this.engineRef.delete()}async bringForward(t){return this.engineRef.bringForward(t)}async sendBackward(t){return this.engineRef.sendBackward(t)}async bringToFront(t){return this.engineRef.bringToFront(t)}async sendToBack(t){return this.engineRef.sendToBack(t)}async alignObjects(t){return this.engineRef.alignObjects(t)}async group(){return this.engineRef.group()}async ungroup(){return this.engineRef.ungroup()}async undo(){return this.engineRef.undo()}async redo(){return this.engineRef.redo()}async getScreenshot(t="png"){return this.engineRef.getScreenshot(t)}async exportViewportAsPng(){return this.engineRef.exportViewportAsPng()}async exportViewportAsSvg(){return this.engineRef.exportViewportAsSvg()}async downloadAsJson(t){return this.engineRef.downloadAsJson(t)}async importFromFile(){return this.engineRef.importFromFile()}async loadObjectsFromJson(t){return this.engineRef.loadObjectsFromJson(t)}async getObjectsTotalCount(){return this.engineRef.getObjectsTotalCount()}async getAllObjects(){return this.engineRef.getAllObjects()}async findObjects(t){return this.engineRef.findObjects(t)}async getCopiedObjects(){return this.engineRef.getCopiedObjects()}async getObjectsInViewport(){return this.engineRef.getObjectsInViewport()}async hideContextMenu(){return this.engineRef.hideContextMenu()}async triggerSelectionChange(){return this.engineRef.triggerSelectionChange()}async getDisplayableShortcuts(){return this.engineRef.getDisplayableShortcuts()}engineRef;controlsRef;settingsRef;exportRef;splitButtonRef;shareDialogRef;loginDialogRef;componentWillLoad(){this.loadSettingsFromStorage()}componentDidLoad(){this.registerCustomSvgIcons(),this.listenForMobileKeyboard(),this.setOsSpecificCssVariables()}async checkIsReady(){if(await customElements.whenDefined("kritzel-editor"),await customElements.whenDefined("kritzel-workspace-manager"),await customElements.whenDefined("kritzel-controls"),await customElements.whenDefined("kritzel-engine"),!(this.isEngineReady&&this.isControlsReady&&this.isWorkspaceManagerReady&&this.activeWorkspace))return;const{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n}=this.activeWorkspace;this.isReady.emit({host:this.host,activeWorkspace:{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n},syncConfig:this.syncConfig,assetStorageConfig:this.assetStorageConfig,loginConfig:this.loginConfig})}async onEngineReady(t){this.isEngineReady=!0,t.detail.activeWorkspace&&(this.activeWorkspace=t.detail.activeWorkspace,this.workspaces=t.detail.workspaces,this.currentIsPublic=await this.engineRef.getIsPublic(),this.loadShortcuts())}handleWorkspacesChange(t){this.workspaces=t.detail}handleActiveWorkspaceChange(t){if(t.stopPropagation(),this.activeWorkspace=t.detail,!this.isEngineReady)return;const{id:e,name:s,isPublic:i,createdAt:n,updatedAt:o}=this.activeWorkspace;this.activeWorkspaceChange.emit({id:e,name:s,isPublic:i,createdAt:n,updatedAt:o})}handleObjectsChange(t){this.objectsChange.emit(t.detail)}handleObjectsAdded(t){this.objectsAdded.emit(t.detail)}handleObjectsRemoved(t){this.objectsRemoved.emit(t.detail)}handleObjectsUpdated(t){this.objectsUpdated.emit(t.detail)}handleUndoStateChange(t){this.undoStateChange.emit(t.detail),this.undoState=t.detail}async handleObjectsInViewportChange(t){const e=this.getContentObjects(t.detail).length>0,s=this.getContentObjects(await this.engineRef.getAllObjects()).length>0;this.isBackToContentButtonVisible=!e&&s}handleViewportChange(t){this.viewportChange.emit(t.detail)}handleAwarenessChange(t){this.awarenessChange.emit(t.detail)}handleSettingsChange(t){this.scaleMin=t.detail.scaleMin,this.scaleMax=t.detail.scaleMax,this.lockDrawingScale=t.detail.lockDrawingScale,this.currentTheme=t.detail.theme,this.viewportBoundaryLeft=t.detail.viewportBoundaryLeft??-1/0,this.viewportBoundaryRight=t.detail.viewportBoundaryRight??1/0,this.viewportBoundaryTop=t.detail.viewportBoundaryTop??-1/0,this.viewportBoundaryBottom=t.detail.viewportBoundaryBottom??1/0,this.debugInfo=t.detail.debugInfo,this.themeChange.emit(t.detail.theme)}get moreMenuItems(){return[{id:"share",label:"Share",icon:"share",action:()=>{this.isLoggedIn||!this.loginConfig?this.shareDialogRef.open():this.openLoginDialog()}},{id:"export",label:"Export",icon:"upload",action:async()=>{const t=await this.engineRef.getScreenshot("png");this.exportRef.open(t??void 0)}},{id:"import",label:"Import",icon:"download",action:()=>this.engineRef.importFromFile()},{id:"settings",label:"Settings",icon:"settings",action:()=>this.settingsRef.open()},{id:"logout",label:"Logout",icon:"log-out",color:"#ff3b30",isVisible:this.isLoggedIn,action:()=>this.logout.emit()}]}handleToggleIsPublic=async t=>{const e=t.detail,s=await this.engineRef.getActiveWorkspace();s.isPublic=e,await this.engineRef.updateWorkspace(s),this.activeWorkspace=s.clone(),this.isPublicChange.emit({isPublic:e,workspaceId:s.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,e&&this.isPublicChange.emit({isPublic:t,workspaceId:e})}handleProviderLogin=t=>{this.login.emit(t.detail)};get isLoggedIn(){return!!this.user&&!this.user.isGuest}async openLoginDialog(){this.loginDialogRef?.open()}async setLoginLoading(t){this.loginDialogRef?.setLoading(t)}getSettingsStorageKey(){return this.editorId?"kritzel-settings-"+this.editorId:"kritzel-settings"}loadSettingsFromStorage(){const t=localStorage.getItem(this.getSettingsStorageKey());if(t)try{const e=JSON.parse(t);"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"light"!==e.theme&&"dark"!==e.theme||(this.currentTheme=e.theme),"number"==typeof e.viewportBoundaryLeft&&(this.viewportBoundaryLeft=e.viewportBoundaryLeft),"number"==typeof e.viewportBoundaryRight&&(this.viewportBoundaryRight=e.viewportBoundaryRight),"number"==typeof e.viewportBoundaryTop&&(this.viewportBoundaryTop=e.viewportBoundaryTop),"number"==typeof e.viewportBoundaryBottom&&(this.viewportBoundaryBottom=e.viewportBoundaryBottom),e.debugInfo&&(this.debugInfo={...this.debugInfo,...e.debugInfo})}catch{}}async loadShortcuts(){this.shortcuts=await this.engineRef.getDisplayableShortcuts()}getContentObjects(t){return t.filter((t=>!(t instanceof g||t instanceof b)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){f.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(S.detectOS()){case"iOS":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;case"Android":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","24px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;default:this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px")}}render(){const t=this.isLoggedIn,e=t,s=!!this.loginConfig&&!t;return i(n,{key:"6e832b0036dbc0d36aa70b297cf73cceafbaa846"},i("div",{key:"48e99e354326781792798fdcc2b07a1b5bbc8cca",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"980bf87558891a8b20030be4b6d0c32ee568ca4d",visible:this.isWorkspaceManagerVisible,workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"59636e148d71c54e51f17095dfec2754d63f1692",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"11f17eef609d3d3ece1ead3cf51524e690f4a2eb",ref:t=>{t&&(this.engineRef=t)},workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,assetStorageConfig:this.assetStorageConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,scaleMin:this.scaleMin,cursorTarget:this.cursorTarget,isLoading:this.isLoading,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.currentTheme,debugInfo:this.debugInfo,globalContextMenuItems:this.globalContextMenuItems,objectContextMenuItems:this.objectContextMenuItems,onIsEngineReady:t=>this.onEngineReady(t),onWorkspacesChange:t=>this.handleWorkspacesChange(t),onActiveWorkspaceChange:t=>this.handleActiveWorkspaceChange(t),onObjectsChange:t=>this.handleObjectsChange(t),onObjectsAdded:t=>this.handleObjectsAdded(t),onObjectsRemoved:t=>this.handleObjectsRemoved(t),onObjectsUpdated:t=>this.handleObjectsUpdated(t),onUndoStateChange:t=>this.handleUndoStateChange(t),onObjectsInViewportChange:t=>this.handleObjectsInViewportChange(t),onViewportChange:t=>this.handleViewportChange(t),onAwarenessChange:t=>this.handleAwarenessChange(t)}),i("kritzel-controls",{key:"b9852a78ed062ca7026b8d0da44263fb0a64d8cc",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>{t&&(this.controlsRef=t)},controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState??void 0,theme:this.currentTheme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"f3e33d794033eb5fdbde8c4553c744da61eefc51",class:"top-right-buttons"},i("kritzel-settings",{key:"466ac8a5d110feb46472c3207f4a73e9ce37e148",ref:t=>{t&&(this.settingsRef=t)},shortcuts:this.shortcuts,editorId:this.editorId,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"c6e0eca3baca940f9160ca02989d5c27410ccc59",ref:t=>{t&&(this.exportRef=t)},workspaceName:this.activeWorkspace?.name||"workspace",onExportPng:()=>this.engineRef.exportViewportAsPng(),onExportSvg:()=>this.engineRef.exportViewportAsSvg(),onExportJson:t=>this.engineRef.downloadAsJson(t.detail)}),i("kritzel-active-users",{key:"b66a7736b9ac0942873e5bdc1677228cd53d57d6",users:this.activeUsers}),e&&i("kritzel-current-user",{key:"4ab0b49bd43f428fb1ade5d5d9836d846355d92f",user:this.user}),s&&i("kritzel-button",{key:"04d6d43b60ad1bd3272dfb1e09aa3efb9602c42e",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"7ca482736a2253d95dffc369de1db1d14d207c35",items:this.moreMenuItems,visible:this.isMoreMenuVisible}),i("kritzel-share-dialog",{key:"c5ae3f2e981d980fd35380424036acdc29b0fe53",ref:t=>{t&&(this.shareDialogRef=t)},isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"f72b412715d0ffd9a8038ade192d894623fc98fc",ref:t=>{t&&(this.loginDialogRef=t)},providers:this.loginConfig.providers,dialogTitle:this.loginConfig.title,subtitle:this.loginConfig.subtitle,onProviderLogin:this.handleProviderLogin})))}static get watchers(){return{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}}static get style(){return"kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}.top-left-buttons{position:absolute;top:var(--kritzel-editor-top-left-buttons-top, 14px);left:var(--kritzel-editor-top-left-buttons-left, 14px);display:flex;align-items:flex-start;gap:8px;z-index:10000}.top-right-buttons{position:absolute;top:var(--kritzel-editor-top-right-buttons-top, 14px);right:var(--kritzel-editor-top-right-buttons-right, 14px);display:flex;align-items:center;gap:8px;z-index:10000}.top-right-button{display:flex;align-items:center;justify-content:center;width:50px;height:50px;padding:0;border:var(--kritzel-split-button-border, 1px solid #ebebeb);border-radius:var(--kritzel-split-button-border-radius, 12px);background-color:var(--kritzel-split-button-background-color, #ffffff);cursor:var(--kritzel-global-pointer-cursor, pointer);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));transition:background-color 150ms ease;-webkit-tap-highlight-color:transparent}.top-right-button:hover{background-color:#f5f5f5}.top-right-button:active{background-color:#ebebeb}"}},[512,"kritzel-editor",{scaleMax:[1026,"scale-max"],scaleMin:[1026,"scale-min"],lockDrawingScale:[1028,"lock-drawing-scale"],viewportBoundaryLeft:[1026,"viewport-boundary-left"],viewportBoundaryRight:[1026,"viewport-boundary-right"],viewportBoundaryTop:[1026,"viewport-boundary-top"],viewportBoundaryBottom:[1026,"viewport-boundary-bottom"],wheelEnabled:[1028,"wheel-enabled"],debugInfo:[1040],user:[16],activeUsers:[16],controls:[16],globalContextMenuItems:[16],objectContextMenuItems:[16],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],isWorkspaceManagerVisible:[4,"is-workspace-manager-visible"],isMoreMenuVisible:[4,"is-more-menu-visible"],syncConfig:[16],assetStorageConfig:[16],cursorTarget:[16],loginConfig:[16],isLoading:[4,"is-loading"],editorId:[1,"editor-id"],activeWorkspaceId:[1,"active-workspace-id"],isEngineReady:[32],isControlsReady:[32],isWorkspaceManagerReady:[32],workspaces:[32],activeWorkspace:[32],isVirtualKeyboardOpen:[32],undoState:[32],isBackToContentButtonVisible:[32],currentTheme:[32],shortcuts:[32],currentIsPublic:[32],getObjectById:[64],addObject:[64],updateObject:[64],removeObject:[64],getSelectedObjects:[64],selectObjects:[64],selectAllObjectsInViewport:[64],clearSelection:[64],centerObjectInViewport:[64],backToContent:[64],centerAllObjects:[64],setViewport:[64],panTo:[64],zoomTo:[64],getViewport:[64],screenToWorld:[64],worldToScreen:[64],createWorkspace:[64],updateWorkspace:[64],deleteWorkspace:[64],getWorkspaces:[64],getActiveWorkspace:[64],loadSharedWorkspace:[64],reinitSync:[64],registerTool:[64],changeActiveTool:[64],disable:[64],enable:[64],copy:[64],cut:[64],paste:[64],delete:[64],bringForward:[64],sendBackward:[64],bringToFront:[64],sendToBack:[64],alignObjects:[64],group:[64],ungroup:[64],undo:[64],redo:[64],getScreenshot:[64],exportViewportAsPng:[64],exportViewportAsSvg:[64],downloadAsJson:[64],importFromFile:[64],loadObjectsFromJson:[64],getObjectsTotalCount:[64],getAllObjects:[64],findObjects:[64],getCopiedObjects:[64],getObjectsInViewport:[64],hideContextMenu:[64],triggerSelectionChange:[64],getDisplayableShortcuts:[64],openLoginDialog:[64],setLoginLoading:[64]},[[0,"dblclick","onTouchStart"]],{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}]),Je=Ke,Ge=function(){"undefined"!=typeof customElements&&["kritzel-editor","kritzel-active-users","kritzel-avatar","kritzel-awareness-cursors","kritzel-back-to-content","kritzel-button","kritzel-color","kritzel-color-palette","kritzel-context-menu","kritzel-controls","kritzel-current-user","kritzel-current-user-dialog","kritzel-cursor-trail","kritzel-dialog","kritzel-dropdown","kritzel-engine","kritzel-export","kritzel-font","kritzel-font-family","kritzel-font-size","kritzel-icon","kritzel-input","kritzel-line-endings","kritzel-login-dialog","kritzel-master-detail","kritzel-menu","kritzel-menu-item","kritzel-more-menu","kritzel-numeric-input","kritzel-opacity-slider","kritzel-pill-tabs","kritzel-portal","kritzel-settings","kritzel-shape-fill","kritzel-share-dialog","kritzel-slide-toggle","kritzel-split-button","kritzel-stroke-size","kritzel-tool-config","kritzel-tooltip","kritzel-utility-panel","kritzel-workspace-manager"].forEach((t=>{switch(t){case"kritzel-editor":customElements.get(o(t))||customElements.define(o(t),Ke);break;case"kritzel-active-users":customElements.get(o(t))||x();break;case"kritzel-avatar":customElements.get(o(t))||T();break;case"kritzel-awareness-cursors":customElements.get(o(t))||O();break;case"kritzel-back-to-content":customElements.get(o(t))||I();break;case"kritzel-button":customElements.get(o(t))||U();break;case"kritzel-color":customElements.get(o(t))||M();break;case"kritzel-color-palette":customElements.get(o(t))||D();break;case"kritzel-context-menu":customElements.get(o(t))||R();break;case"kritzel-controls":customElements.get(o(t))||W();break;case"kritzel-current-user":customElements.get(o(t))||B();break;case"kritzel-current-user-dialog":customElements.get(o(t))||P();break;case"kritzel-cursor-trail":customElements.get(o(t))||V();break;case"kritzel-dialog":customElements.get(o(t))||L();break;case"kritzel-dropdown":customElements.get(o(t))||F();break;case"kritzel-engine":customElements.get(o(t))||j();break;case"kritzel-export":customElements.get(o(t))||N();break;case"kritzel-font":customElements.get(o(t))||K();break;case"kritzel-font-family":customElements.get(o(t))||J();break;case"kritzel-font-size":customElements.get(o(t))||G();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||q();break;case"kritzel-line-endings":customElements.get(o(t))||_();break;case"kritzel-login-dialog":customElements.get(o(t))||H();break;case"kritzel-master-detail":customElements.get(o(t))||Y();break;case"kritzel-menu":customElements.get(o(t))||Z();break;case"kritzel-menu-item":customElements.get(o(t))||Q();break;case"kritzel-more-menu":customElements.get(o(t))||$();break;case"kritzel-numeric-input":customElements.get(o(t))||X();break;case"kritzel-opacity-slider":customElements.get(o(t))||tt();break;case"kritzel-pill-tabs":customElements.get(o(t))||et();break;case"kritzel-portal":customElements.get(o(t))||st();break;case"kritzel-settings":customElements.get(o(t))||it();break;case"kritzel-shape-fill":customElements.get(o(t))||nt();break;case"kritzel-share-dialog":customElements.get(o(t))||ot();break;case"kritzel-slide-toggle":customElements.get(o(t))||rt();break;case"kritzel-split-button":customElements.get(o(t))||at();break;case"kritzel-stroke-size":customElements.get(o(t))||ct();break;case"kritzel-tool-config":customElements.get(o(t))||ht();break;case"kritzel-tooltip":customElements.get(o(t))||lt();break;case"kritzel-utility-panel":customElements.get(o(t))||dt();break;case"kritzel-workspace-manager":customElements.get(o(t))||ut()}}))};export{Pe as D,Be as H,Je as KritzelEditor,Se as a,Ve as b,Le as c,Fe as d,Ge as defineCustomElement}
1
+ import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-BWj1eE2b.js";import{K as r,d as a}from"./p-A7Ult9iv.js";import{I as c,S as h,h as l,d,e as u,g as p,f as m,j as g,k as b,l as f}from"./p-DwZAEb-2.js";import{e as y,f as k,K as w,a as v,d as z,D as C,g as j}from"./p-B7jb9G4E.js";import{D as A}from"./p-D_Tdq4Z0.js";import{K as S}from"./p-jGOpkGDl.js";import"./p-BhMchyAR.js";import*as E from"yjs";import"y-indexeddb";import"y-websocket";import{d as x}from"./p-CaKSDRid.js";import{d as T}from"./p-Cz2gQKbL.js";import{d as O}from"./p-DORo_go4.js";import{d as I}from"./p-BoRQF_Zc.js";import{d as U}from"./p-C_OSXZqJ.js";import{d as M}from"./p-DDm8Gefw.js";import{d as D}from"./p-DeqXAEjq.js";import{d as R}from"./p-BvgGpgKP.js";import{d as B}from"./p-BcWZP5At.js";import{d as W}from"./p-DYHF_MSN.js";import{d as P}from"./p-BDOSy6zd.js";import{d as V}from"./p-DXO_ppUK.js";import{d as L}from"./p-0F9_lw6l.js";import{d as F}from"./p-CBTqCoUx.js";import{d as N}from"./p-BmYsz1bP.js";import{d as K}from"./p-C4vg_-vg.js";import{d as G}from"./p-qBqQhAmh.js";import{d as J}from"./p-DDBaFNFi.js";import{d as q}from"./p-BVEYAGm1.js";import{d as H}from"./p-D6KNaj_Y.js";import{d as _}from"./p-ZpItdhxS.js";import{d as Y}from"./p-Czaea0WP.js";import{d as Q,a as $}from"./p-DQ1fRE9J.js";import{d as Z}from"./p-xHh03blG.js";import{d as X}from"./p-B5a3arJg.js";import{d as tt}from"./p-DemKKw9U.js";import{d as et}from"./p-DVEfOb8T.js";import{d as st}from"./p-BLjdzUzs.js";import{d as it}from"./p-CgVHVzNt.js";import{d as nt}from"./p-DEd2L0e3.js";import{d as ot}from"./p-R60vdaIY.js";import{d as rt}from"./p-CTj2UdbS.js";import{d as at}from"./p-CRsnBR8O.js";import{d as ct}from"./p-BK9c3UTv.js";import{d as ht}from"./p-BeOG6L2d.js";import{d as lt}from"./p-0cs6zQLB.js";import{d as dt}from"./p-BAjrJjMX.js";import{d as ut}from"./p-BpRNLd4z.js";const pt=Math.floor,mt=127,gt=Number.MAX_SAFE_INTEGER,bt="undefined"!=typeof TextEncoder?new TextEncoder:null,ft=bt?t=>bt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let yt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});yt&&1===yt.decode(new Uint8Array).length&&(yt=null);const kt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},wt=(t,e)=>{for(;e>mt;)kt(t,128|mt&e),e=pt(e/128);kt(t,mt&e)},vt=new Uint8Array(3e4),zt=vt.length/3,Ct=bt&&bt.encodeInto?(t,e)=>{if(e.length<zt){const s=bt.encodeInto(e,vt).written||0;wt(t,s);for(let e=0;e<s;e++)kt(t,vt[e])}else jt(t,ft(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;wt(t,i);for(let e=0;e<i;e++)kt(t,s.codePointAt(e))},jt=(t,e)=>{wt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},At=t=>Error(t),St=At("Unexpected end of array"),Et=At("Integer out of Range"),xt=t=>t.arr[t.pos++],Tt=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&mt)*s,s*=128,i<128)return e;if(e>gt)throw Et}throw St},Ot=yt?t=>yt.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,Tt(t)))(t)):t=>{let e=Tt(t);if(0===e)return"";{let s=String.fromCodePoint(xt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(xt(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}};var It;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(It||(It={}));const Ut=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Mt;async function Dt(t){return new Promise((e=>setTimeout(e,t)))}function Rt(t,e){let s=e.delay;if(0===s)return 0;if(e.factor&&(s*=Math.pow(e.factor,t.attemptNum-1),0!==e.maxDelay&&(s=Math.min(s,e.maxDelay))),e.jitter){const t=Math.ceil(e.minDelay),i=Math.floor(s);s=Math.floor(Math.random()*(i-t+1))+t}return Math.round(s)}!function(t){t[t.Connecting=0]="Connecting",t[t.Open=1]="Open",t[t.Closing=2]="Closing",t[t.Closed=3]="Closed"}(Mt||(Mt={}));const Bt=Math.floor,Wt=128,Pt=127,Vt=Number.MAX_SAFE_INTEGER,Lt=()=>new Set,Ft=Array.from,Nt="undefined"!=typeof TextEncoder?new TextEncoder:null,Kt=Nt?t=>Nt.encode(t):t=>{const e=unescape(encodeURIComponent(t)),s=e.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=e.codePointAt(t);return i};let Gt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Gt&&1===Gt.decode(new Uint8Array).length&&(Gt=null);class Jt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const qt=()=>new Jt,Ht=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},_t=t=>{const e=new Uint8Array(Ht(t));let s=0;for(let i=0;i<t.bufs.length;i++){const n=t.bufs[i];e.set(n,s),s+=n.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),s),e},Yt=(t,e)=>{const s=t.cbuf.length;t.cpos===s&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*s),t.cpos=0),t.cbuf[t.cpos++]=e},Qt=(t,e)=>{for(;e>Pt;)Yt(t,Wt|Pt&e),e=Bt(e/128);Yt(t,Pt&e)},$t=new Uint8Array(3e4),Zt=$t.length/3,Xt=Nt&&Nt.encodeInto?(t,e)=>{if(e.length<Zt){const s=Nt.encodeInto(e,$t).written||0;Qt(t,s);for(let e=0;e<s;e++)Yt(t,$t[e])}else te(t,Kt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;Qt(t,i);for(let e=0;e<i;e++)Yt(t,s.codePointAt(e))},te=(t,e)=>{Qt(t,e.byteLength),((t,e)=>{const s=t.cbuf.length,i=t.cpos,n=((t,e)=>t<e?t:e)(s-i,e.length),o=e.length-n;t.cbuf.set(e.subarray(0,n),i),t.cpos+=n,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(((t,e)=>t>e?t:e)(2*s,o)),t.cbuf.set(e.subarray(n)),t.cpos=o)})(t,e)},ee=t=>Error(t),se=ee("Unexpected end of array"),ie=ee("Integer out of Range");class ne{constructor(t){this.arr=t,this.pos=0}}const oe=t=>new ne(t),re=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,ce(t)),ae=t=>t.arr[t.pos++],ce=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Pt)*s,s*=128,i<Wt)return e;if(e>Vt)throw ie}throw se},he=Gt?t=>Gt.decode(re(t)):t=>{let e=ce(t);if(0===e)return"";{let s=String.fromCodePoint(ae(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(ae(t));else for(;e>0;){const i=e<1e4?e:1e4,n=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,s+=String.fromCodePoint.apply(null,n),e-=i}return decodeURIComponent(escape(s))}},le=Date.now,de=()=>new Map;class ue{constructor(){this._observers=de()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Lt).add(e)}once(t,e){const s=(...i)=>{this.off(t,s),e(...i)};this.on(t,s)}off(t,e){const s=this._observers.get(t);void 0!==s&&(s.delete(e),0===s.size&&this._observers.delete(t))}emit(t,e){return Ft((this._observers.get(t)||de()).values()).forEach((t=>t(...e)))}destroy(){this._observers=de()}}const pe=Object.keys,me=t=>pe(t).length,ge=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),be=(t,e)=>{if(null==t||null==e)return((t,e)=>t===e)(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;break;case Set:if(t.size!==e.size)return!1;for(const s of t)if(!e.has(s))return!1;break;case Map:if(t.size!==e.size)return!1;for(const s of t.keys())if(!e.has(s)||!be(t.get(s),e.get(s)))return!1;break;case Object:if(me(t)!==me(e))return!1;for(const s in t)if(!ge(t,s)||!be(t[s],e[s]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!be(t[s],e[s]))return!1;break;default:return!1}return!0};class fe extends ue{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=le();null!==this.getLocalState()&&15e3<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const e=[];this.meta.forEach(((s,i)=>{i!==this.clientID&&3e4<=t-s.lastUpdated&&this.states.has(i)&&e.push(i)})),e.length>0&&ye(this,e,"timeout")}),Bt(3e3)),t.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){const e=this.clientID,s=this.meta.get(e),i=void 0===s?0:s.clock+1,n=this.states.get(e);null===t?this.states.delete(e):this.states.set(e,t),this.meta.set(e,{clock:i,lastUpdated:le()});const o=[],r=[],a=[],c=[];null===t?c.push(e):null==n?null!=t&&o.push(e):(r.push(e),be(n,t)||a.push(e)),(o.length>0||a.length>0||c.length>0)&&this.emit("change",[{added:o,updated:a,removed:c},"local"]),this.emit("update",[{added:o,updated:r,removed:c},"local"])}setLocalStateField(t,e){const s=this.getLocalState();null!==s&&this.setLocalState({...s,[t]:e})}getStates(){return this.states}}const ye=(t,e,s)=>{const i=[];for(let s=0;s<e.length;s++){const n=e[s];if(t.states.has(n)){if(t.states.delete(n),n===t.clientID){const e=t.meta.get(n);t.meta.set(n,{clock:e.clock+1,lastUpdated:le()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},ke=(t,e,s=t.states)=>{const i=e.length,n=qt();Qt(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;Qt(n,i),Qt(n,a),Xt(n,JSON.stringify(r))}return _t(n)};class we{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const s=this.callbacks[t];return s&&s.forEach((t=>t.apply(this,e))),this}off(t,e){const s=this.callbacks[t];return s&&(e?this.callbacks[t]=s.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}class ve{constructor(t){this.data=t,this.encoder=qt(),this.decoder=oe(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=he(t);return t.pos=e,s})(this.decoder)}readVarUint(){return ce(this.decoder)}readVarString(){return he(this.decoder)}readVarUint8Array(){return re(this.decoder)}writeVarUint(t){return Qt(this.encoder,t)}writeVarString(t){return Xt(this.encoder,t)}writeVarUint8Array(t){return te(this.encoder,t)}length(){return Ht(this.encoder)}}var ze,Ce;!function(t){t[t.Sync=0]="Sync",t[t.Awareness=1]="Awareness",t[t.Auth=2]="Auth",t[t.QueryAwareness=3]="QueryAwareness",t[t.Stateless=5]="Stateless",t[t.CLOSE=7]="CLOSE",t[t.SyncStatus=8]="SyncStatus"}(ze||(ze={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(Ce||(Ce={}));class je{constructor(){this.encoder=qt()}get(t){return t.encoder}toUint8Array(){return _t(this.encoder)}}class Ae extends je{constructor(){super(...arguments),this.type=ze.CLOSE,this.description="Ask the server to close the connection"}get(t){return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),this.encoder}}class Se extends we{constructor(t){super(),this.messageQueue=[],this.configuration={url:"",autoConnect:!0,preserveTrailingSlash:!1,document:void 0,WebSocketPolyfill:void 0,messageReconnectTimeout:3e4,delay:1e3,initialDelay:0,factor:2,maxAttempts:0,minDelay:1e3,maxDelay:3e4,jitter:!0,timeout:0,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,handleTimeout:null,providerMap:new Map},this.webSocket=null,this.webSocketHandlers={},this.shouldConnect=!0,this.status=Ce.Disconnected,this.lastMessageReceived=0,this.identifier=0,this.intervals={connectionChecker:null},this.connectionAttempt=null,this.receivedOnOpenPayload=void 0,this.closeTries=0,this.setConfiguration(t),this.configuration.WebSocketPolyfill=t.WebSocketPolyfill?t.WebSocketPolyfill:WebSocket,this.on("open",this.configuration.onOpen),this.on("open",this.onOpen.bind(this)),this.on("connect",this.configuration.onConnect),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("status",this.configuration.onStatus),this.on("disconnect",this.configuration.onDisconnect),this.on("close",this.configuration.onClose),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("close",this.onClose.bind(this)),this.on("message",this.onMessage.bind(this)),this.intervals.connectionChecker=setInterval(this.checkConnection.bind(this),this.configuration.messageReconnectTimeout/10),this.shouldConnect&&this.connect()}async onOpen(t){this.status=Ce.Connected,this.emit("status",{status:Ce.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===Ce.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===Ce.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(Ae,{documentName:t.configuration.name}),this.configuration.providerMap.delete(t.configuration.name))}setConfiguration(t={}){this.configuration={...this.configuration,...t},this.configuration.autoConnect||(this.shouldConnect=!1)}async connect(){if(this.status===Ce.Connected)return;this.cancelWebsocketRetry&&(this.cancelWebsocketRetry(),this.cancelWebsocketRetry=void 0),this.receivedOnOpenPayload=void 0,this.shouldConnect=!0;const{retryPromise:t,cancelFunc:e}=(()=>{let t=!1;return{retryPromise:async function(t,e){const s=function(t){return t||(t={}),{delay:void 0===t.delay?200:t.delay,initialDelay:void 0===t.initialDelay?0:t.initialDelay,minDelay:void 0===t.minDelay?0:t.minDelay,maxDelay:void 0===t.maxDelay?0:t.maxDelay,factor:void 0===t.factor?0:t.factor,maxAttempts:void 0===t.maxAttempts?3:t.maxAttempts,timeout:void 0===t.timeout?0:t.timeout,jitter:!0===t.jitter,initialJitter:!0===t.initialJitter,handleError:void 0===t.handleError?null:t.handleError,handleTimeout:void 0===t.handleTimeout?null:t.handleTimeout,beforeAttempt:void 0===t.beforeAttempt?null:t.beforeAttempt,calculateDelay:void 0===t.calculateDelay?null:t.calculateDelay}}(e);for(const t of["delay","initialDelay","minDelay","maxDelay","maxAttempts","timeout"]){const e=s[t];if(!Number.isInteger(e)||e<0)throw Error(`Value for ${t} must be an integer greater than or equal to 0`)}if(s.factor.constructor!==Number||s.factor<0)throw Error("Value for factor must be a number greater than or equal to 0");if(s.delay<s.minDelay)throw Error(`delay cannot be less than minDelay (delay: ${s.delay}, minDelay: ${s.minDelay}`);const i={attemptNum:0,attemptsRemaining:s.maxAttempts?s.maxAttempts:-1,aborted:!1,abort(){i.aborted=!0}},n=s.calculateDelay||Rt,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await Dt(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await Dt(t)}return async function e(){if(s.beforeAttempt&&s.beforeAttempt(i,s),i.aborted){const t=Error("Attempt aborted");throw t.code="ATTEMPT_ABORTED",t}const o=async t=>{if(s.handleError&&await s.handleError(t,i,s),i.aborted||0===i.attemptsRemaining)throw t;i.attemptNum++;const o=n(i,s);return o&&await Dt(o),e()};return i.attemptsRemaining>0&&i.attemptsRemaining--,s.timeout?new Promise(((e,n)=>{const r=setTimeout((()=>{if(s.handleTimeout)try{e(s.handleTimeout(i,s))}catch(t){n(t)}else{const t=Error(`Retry timeout (attemptNum: ${i.attemptNum}, timeout: ${s.timeout})`);t.code="ATTEMPT_TIMEOUT",n(t)}}),s.timeout);t(i,s).then((t=>{clearTimeout(r),e(t)})).catch((t=>{clearTimeout(r),o(t).then(e).catch(n)}))})):t(i,s).catch(o)}()}(this.createWebSocketConnection.bind(this),{delay:this.configuration.delay,initialDelay:this.configuration.initialDelay,factor:this.configuration.factor,maxAttempts:this.configuration.maxAttempts,minDelay:this.configuration.minDelay,maxDelay:this.configuration.maxDelay,jitter:this.configuration.jitter,timeout:this.configuration.timeout,handleTimeout:this.configuration.handleTimeout,beforeAttempt:e=>{this.shouldConnect&&!t||e.abort()}}).catch((t=>{if(t&&"ATTEMPT_ABORTED"!==t.code)throw t})),cancelFunc:()=>{t=!0}}})();return this.cancelWebsocketRetry=e,t}attachWebSocketListeners(t,e){const{identifier:s}=t;this.webSocketHandlers[s]={message:t=>this.emit("message",t),close:t=>this.emit("close",{event:t}),open:t=>this.emit("open",t),error:t=>{e(t)}};const i=this.webSocketHandlers[t.identifier];Object.keys(i).forEach((e=>{t.addEventListener(e,i[e])}))}cleanupWebSocket(){if(!this.webSocket)return;const{identifier:t}=this.webSocket,e=this.webSocketHandlers[t];Object.keys(e).forEach((s=>{var i;null===(i=this.webSocket)||void 0===i||i.removeEventListener(s,e[s]),delete this.webSocketHandlers[t]})),this.webSocket.close(),this.webSocket=null}createWebSocketConnection(){return new Promise(((t,e)=>{this.webSocket&&(this.messageQueue=[],this.cleanupWebSocket()),this.lastMessageReceived=0,this.identifier+=1;const s=new this.configuration.WebSocketPolyfill(this.url);s.binaryType="arraybuffer",s.identifier=this.identifier,this.attachWebSocketListeners(s,e),this.webSocket=s,this.status=Ce.Connecting,this.emit("status",{status:Ce.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=le();const s=new ve(t.data).peekVarString();null===(e=this.configuration.providerMap.get(s))||void 0===e||e.onMessage(t)}resolveConnectionAttempt(){this.connectionAttempt&&(this.connectionAttempt.resolve(),this.connectionAttempt=null,this.status=Ce.Connected,this.emit("status",{status:Ce.Connected}),this.emit("connect"),this.messageQueue.forEach((t=>this.send(t))),this.messageQueue=[])}stopConnectionAttempt(){this.connectionAttempt=null}rejectConnectionAttempt(){var t;null===(t=this.connectionAttempt)||void 0===t||t.reject(),this.connectionAttempt=null}checkConnection(){var t;this.status===Ce.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=le()-this.lastMessageReceived||(this.closeTries+=1,this.closeTries>2?(this.onClose({event:{code:4408,reason:"forced"}}),this.closeTries=0):(null===(t=this.webSocket)||void 0===t||t.close(),this.messageQueue=[])))}get serverUrl(){if(this.configuration.preserveTrailingSlash)return this.configuration.url;let t=this.configuration.url;for(;"/"===t[t.length-1];)t=t.slice(0,t.length-1);return t}get url(){return this.serverUrl}disconnect(){if(this.shouldConnect=!1,null!==this.webSocket)try{this.webSocket.close(),this.messageQueue=[]}catch(t){console.error(t)}}send(t){var e;(null===(e=this.webSocket)||void 0===e?void 0:e.readyState)===Mt.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=Ce.Disconnected,this.emit("status",{status:Ce.Disconnected}),this.emit("disconnect",{event:t}),!this.cancelWebsocketRetry&&this.shouldConnect&&setTimeout((()=>{this.connect()}),this.configuration.delay)}destroy(){this.emit("destroy"),clearInterval(this.intervals.connectionChecker),this.stopConnectionAttempt(),this.disconnect(),this.removeAllListeners(),this.cleanupWebSocket()}}const Ee=(t,e,s)=>{try{E.applyUpdate(e,re(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},xe=Ee;class Te{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case ze.Sync:this.applySyncMessage(t,e);break;case ze.Awareness:this.applyAwarenessMessage(t);break;case ze.Auth:this.applyAuthMessage(t);break;case ze.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ze.Stateless:t.receiveStateless(he(s.decoder));break;case ze.SyncStatus:this.applySyncStatusMessage(t,1===(t=>{let e=t.arr[t.pos++],s=63&e,i=64;const n=(64&e)>0?-1:1;if(!(e&Wt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Pt)*i,i*=128,e<Wt)return n*s;if(s>Vt)throw ie}throw se})(s.decoder));break;case ze.CLOSE:const n={code:1e3,reason:he(s.decoder),target:t.configuration.websocketProvider.webSocket,type:"close"};t.onClose(),t.configuration.onClose({event:n}),t.forwardClose({event:n});break;default:throw Error("Can’t apply message of unknown type: "+i)}s.length()>n+1&&t.send(je,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(ze.Sync);const i=((t,e,s,i)=>{const n=ce(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{Qt(t,1),te(t,E.encodeStateAsUpdate(e,s))})(e,s,re(t))})(t,e,s);break;case 1:Ee(t,s,i);break;case 2:xe(t,s,i);break;default:throw Error("Unknown message type")}return n})(s.decoder,s.encoder,t.document,t);e&&1===i&&(t.synced=!0)}applySyncStatusMessage(t,e){e&&t.decrementUnsyncedChanges()}applyAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;((t,e,s)=>{const i=oe(e),n=le(),o=[],r=[],a=[],c=[],h=ce(i);for(let e=0;e<h;e++){const e=ce(i);let s=ce(i);const h=JSON.parse(he(i)),l=t.meta.get(e),d=t.states.get(e),u=void 0===l?0:l.clock;(u<s||u===s&&null===h&&t.states.has(e))&&(null===h?e===t.clientID&&null!=t.getLocalState()?s++:t.states.delete(e):t.states.set(e,h),t.meta.set(e,{clock:s,lastUpdated:n}),void 0===l&&null!==h?o.push(e):void 0!==l&&null===h?c.push(e):null!==h&&(be(h,d)||a.push(e),r.push(e)))}(o.length>0||a.length>0||c.length>0)&&t.emit("change",[{added:o,updated:a,removed:c},s]),(o.length>0||r.length>0||c.length>0)&&t.emit("update",[{added:o,updated:r,removed:c},s])})(t.awareness,e.readVarUint8Array(),t)}applyAuthMessage(t){const{message:e}=this;((t,e,s,i)=>{switch(Tt(t)){case It.Token:e();break;case It.PermissionDenied:s(Ot(t));break;case It.Authenticated:i(Ot(t))}})(e.decoder,t.sendToken.bind(t),t.permissionDeniedHandler.bind(t),t.authenticatedHandler.bind(t))}applyQueryAwarenessMessage(t){if(!t.awareness)return;const{message:e}=this;e.writeVarUint(ze.Awareness),e.writeVarUint8Array(ke(t.awareness,Array.from(t.awareness.getStates().keys())))}}class Oe{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return _t(this.encoder)}send(t){null==t||t.send(this.create())}}class Ie extends je{constructor(){super(...arguments),this.type=ze.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{wt(t,It.Token),Ct(t,e)})(this.encoder,t.token),this.encoder}}class Ue extends je{constructor(){super(...arguments),this.type=ze.Awareness,this.description="Awareness states update"}get(t){if(void 0===t.awareness)throw Error("The awareness message requires awareness as an argument");if(void 0===t.clients)throw Error("The awareness message requires clients as an argument");let e;return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),e=void 0===t.states?ke(t.awareness,t.clients):ke(t.awareness,t.clients,t.states),te(this.encoder,e),this.encoder}}class Me extends je{constructor(){super(...arguments),this.type=ze.Stateless,this.description="A stateless message"}get(t){var e;return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),Xt(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class De extends je{constructor(){super(...arguments),this.type=ze.Sync,this.description="First sync step"}get(t){if(void 0===t.document)throw Error("The sync step one message requires document as an argument");return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{Qt(t,0);const s=E.encodeStateVector(e);te(t,s)})(this.encoder,t.document),this.encoder}}class Re extends je{constructor(){super(...arguments),this.type=ze.Sync,this.description="A document update"}get(t){return Xt(this.encoder,t.documentName),Qt(this.encoder,this.type),((t,e)=>{Qt(t,2),te(t,e)})(this.encoder,t.update),this.encoder}}class Be extends Error{constructor(){super(...arguments),this.code=1001}}class We extends we{constructor(t){var e,s,i;super(),this.configuration={name:"",document:void 0,awareness:void 0,token:null,forceSyncInterval:!1,onAuthenticated:()=>null,onAuthenticationFailed:()=>null,onOpen:()=>null,onConnect:()=>null,onMessage:()=>null,onOutgoingMessage:()=>null,onSynced:()=>null,onStatus:()=>null,onDisconnect:()=>null,onClose:()=>null,onDestroy:()=>null,onAwarenessUpdate:()=>null,onAwarenessChange:()=>null,onStateless:()=>null,onUnsyncedChanges:()=>null},this.isSynced=!1,this.unsyncedChanges=0,this.isAuthenticated=!1,this.authorizedScope=void 0,this.manageSocket=!1,this._isAttached=!1,this.intervals={forceSync:null},this.boundDocumentUpdateHandler=this.documentUpdateHandler.bind(this),this.boundAwarenessUpdateHandler=this.awarenessUpdateHandler.bind(this),this.boundPageHide=this.pageHide.bind(this),this.boundOnOpen=this.onOpen.bind(this),this.boundOnClose=this.onClose.bind(this),this.forwardConnect=()=>this.emit("connect"),this.forwardStatus=t=>this.emit("status",t),this.forwardClose=t=>this.emit("close",t),this.forwardDisconnect=t=>this.emit("disconnect",t),this.forwardDestroy=()=>this.emit("destroy"),this.setConfiguration(t),this.configuration.document=t.document?t.document:new E.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new fe(this.document),this.on("open",this.configuration.onOpen),this.on("message",this.configuration.onMessage),this.on("outgoingMessage",this.configuration.onOutgoingMessage),this.on("synced",this.configuration.onSynced),this.on("destroy",this.configuration.onDestroy),this.on("awarenessUpdate",this.configuration.onAwarenessUpdate),this.on("awarenessChange",this.configuration.onAwarenessChange),this.on("stateless",this.configuration.onStateless),this.on("unsyncedChanges",this.configuration.onUnsyncedChanges),this.on("authenticated",this.configuration.onAuthenticated),this.on("authenticationFailed",this.configuration.onAuthenticationFailed),null===(e=this.awareness)||void 0===e||e.on("update",(()=>{this.emit("awarenessUpdate",{states:Ut(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Ut(this.awareness.getStates())})})),this.document.on("update",this.boundDocumentUpdateHandler),null===(i=this.awareness)||void 0===i||i.on("update",this.boundAwarenessUpdateHandler),this.registerEventListeners(),this.configuration.forceSyncInterval&&"number"==typeof this.configuration.forceSyncInterval&&(this.intervals.forceSync=setInterval(this.forceSync.bind(this),this.configuration.forceSyncInterval)),this.manageSocket&&this.attach()}setConfiguration(t={}){t.websocketProvider||(this.manageSocket=!0,this.configuration.websocketProvider=new Se(t)),this.configuration={...this.configuration,...t}}get document(){return this.configuration.document}get isAttached(){return this._isAttached}get awareness(){return this.configuration.awareness}get hasUnsyncedChanges(){return this.unsyncedChanges>0}resetUnsyncedChanges(){this.unsyncedChanges=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}incrementUnsyncedChanges(){this.unsyncedChanges+=1,this.emit("unsyncedChanges",{number:this.unsyncedChanges})}decrementUnsyncedChanges(){this.unsyncedChanges>0&&(this.unsyncedChanges-=1),0===this.unsyncedChanges&&(this.synced=!0),this.emit("unsyncedChanges",{number:this.unsyncedChanges})}forceSync(){this.resetUnsyncedChanges(),this.send(De,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&ye(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Me,{documentName:this.configuration.name,payload:t})}async sendToken(){let t;try{t=await this.getToken()}catch(t){return void this.permissionDeniedHandler("Failed to get token during sendToken(): "+t)}this.send(Ie,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(Re,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Ue,{awareness:this.awareness,clients:n,documentName:this.configuration.name})}get synced(){return this.isSynced}set synced(t){this.isSynced!==t&&(this.isSynced=t,t&&this.emit("synced",{state:t}))}receiveStateless(t){this.emit("stateless",{payload:t})}async connect(){if(this.manageSocket)return this.configuration.websocketProvider.connect();console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}disconnect(){if(this.manageSocket)return this.configuration.websocketProvider.disconnect();console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.")}async onOpen(t){this.isAuthenticated=!1,this.emit("open",{event:t}),await this.sendToken(),this.startSync()}async getToken(){return"function"==typeof this.configuration.token?await this.configuration.token():this.configuration.token}startSync(){this.resetUnsyncedChanges(),this.send(De,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Ue,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new Oe(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new ve(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new ve(t.data)}),new Te(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ye(this.awareness,Array.from(this.awareness.getStates().keys()).filter((t=>t!==this.document.clientID)),this)}destroy(){this.emit("destroy"),this.intervals.forceSync&&clearInterval(this.intervals.forceSync),this.awareness&&(ye(this.awareness,[this.document.clientID],"provider destroy"),this.awareness.off("update",this.boundAwarenessUpdateHandler),this.awareness.destroy()),this.document.off("update",this.boundDocumentUpdateHandler),this.removeAllListeners(),this.detach(),this.manageSocket&&this.configuration.websocketProvider.destroy(),"undefined"!=typeof window&&"removeEventListener"in window&&window.removeEventListener("pagehide",this.boundPageHide)}detach(){this.configuration.websocketProvider.off("connect",this.configuration.onConnect),this.configuration.websocketProvider.off("connect",this.forwardConnect),this.configuration.websocketProvider.off("status",this.forwardStatus),this.configuration.websocketProvider.off("status",this.configuration.onStatus),this.configuration.websocketProvider.off("open",this.boundOnOpen),this.configuration.websocketProvider.off("close",this.boundOnClose),this.configuration.websocketProvider.off("close",this.configuration.onClose),this.configuration.websocketProvider.off("close",this.forwardClose),this.configuration.websocketProvider.off("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.off("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.off("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.off("destroy",this.forwardDestroy),this.configuration.websocketProvider.detach(this),this._isAttached=!1}attach(){this._isAttached||(this.configuration.websocketProvider.on("connect",this.configuration.onConnect),this.configuration.websocketProvider.on("connect",this.forwardConnect),this.configuration.websocketProvider.on("status",this.configuration.onStatus),this.configuration.websocketProvider.on("status",this.forwardStatus),this.configuration.websocketProvider.on("open",this.boundOnOpen),this.configuration.websocketProvider.on("close",this.boundOnClose),this.configuration.websocketProvider.on("close",this.configuration.onClose),this.configuration.websocketProvider.on("close",this.forwardClose),this.configuration.websocketProvider.on("disconnect",this.configuration.onDisconnect),this.configuration.websocketProvider.on("disconnect",this.forwardDisconnect),this.configuration.websocketProvider.on("destroy",this.configuration.onDestroy),this.configuration.websocketProvider.on("destroy",this.forwardDestroy),this.configuration.websocketProvider.attach(this),this._isAttached=!0)}permissionDeniedHandler(t){this.emit("authenticationFailed",{reason:t}),this.isAuthenticated=!1}authenticatedHandler(t){this.isAuthenticated=!0,this.authorizedScope=t,this.emit("authenticated",{scope:t})}setAwarenessField(t,e){if(!this.awareness)throw new Be(`Cannot set awareness field "${t}" to ${JSON.stringify(e)}. You have disabled Awareness for this provider by explicitly passing awareness: null in the provider configuration.`);this.awareness.setLocalStateField(t,e)}}const Pe={type:"pen",color:A[0],size:16,palettes:{pen:[...A]}},Ve={color:A[0],size:8,fontFamily:"Arial",palette:[...A]},Le={color:A[0],size:4,palette:[...A],arrows:{end:{enabled:!0,style:"triangle"}}},Fe={providers:[c]},Ne={shapeType:h.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:A[0],strokeWidth:4,fontColor:A[0],fontSize:16,fontFamily:"Arial",palette:[...A]},Ke=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.isReady=s(this,"isReady"),this.activeWorkspaceChange=s(this,"activeWorkspaceChange"),this.objectsChange=s(this,"objectsChange"),this.objectsAdded=s(this,"objectsAdded"),this.objectsRemoved=s(this,"objectsRemoved"),this.objectsUpdated=s(this,"objectsUpdated"),this.undoStateChange=s(this,"undoStateChange"),this.themeChange=s(this,"themeChange"),this.viewportChange=s(this,"viewportChange"),this.logout=s(this,"logout"),this.login=s(this,"login"),this.isPublicChange=s(this,"isPublicChange"),this.awarenessChange=s(this,"awarenessChange")}get host(){return this}scaleMax=y;scaleMin=k;lockDrawingScale=!0;viewportBoundaryLeft=-1/0;viewportBoundaryRight=1/0;viewportBoundaryTop=-1/0;viewportBoundaryBottom=1/0;wheelEnabled=!0;debugInfo={showViewportInfo:!1,showObjectInfo:!1,showSyncProviderInfo:!0,showMigrationInfo:!0};user;activeUsers;controls=[{name:"selection",type:"tool",isDefault:!0,tool:l,icon:"cursor"},{name:"brush",type:"tool",tool:d,icon:"pen",config:Pe},{name:"eraser",type:"tool",tool:w,icon:"eraser"},{name:"line",type:"tool",tool:u,icon:"arrow",config:Le},{name:"shape",type:"tool",tool:p,icon:"shape-rectangle",config:Ne,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:h.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:h.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:h.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:m,icon:"type",config:Ve},{name:"image",type:"tool",tool:v,icon:"image"},{name:"config",type:"config"}];globalContextMenuItems=[{label:"Paste",icon:"paste",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Select All",icon:"select-all",disabled:async()=>0===(await this.engineRef.getObjectsInViewport()).length,action:()=>this.selectAllObjectsInViewport()}];objectContextMenuItems=[{label:"Copy",icon:"copy",group:"clipboard",action:()=>this.engineRef.copy()},{label:"Cut",icon:"cut",group:"clipboard",action:()=>this.engineRef.cut()},{label:"Paste",icon:"paste",group:"clipboard",disabled:async()=>0===(await this.engineRef.getCopiedObjects()).length,action:t=>this.engineRef.paste(t.x,t.y)},{label:"Order",icon:"ordering",group:"other",children:[{label:"Bring to Front",icon:"bring-to-front",action:()=>this.engineRef.bringToFront()},{label:"Send to Back",icon:"send-to-back",action:()=>this.engineRef.sendToBack()},{label:"Move Up",icon:"arrow-up-from-dot",action:()=>this.engineRef.bringForward()},{label:"Move Down",icon:"arrow-down-from-dot",action:()=>this.engineRef.sendBackward()}]},{label:"Align",icon:"align",group:"other",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,children:[{label:"Align Left",icon:"align-start-vertical",action:()=>this.engineRef.alignObjects(z.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(z.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(z.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(z.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(z.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(z.EndVertical)}]},{label:"Group",icon:"group",group:"other",children:[{label:"Group",icon:"group",disabled:async()=>(await this.engineRef.getSelectedObjects()).length<2,action:()=>this.engineRef.group()},{label:"Ungroup",icon:"ungroup",disabled:async()=>!(await this.engineRef.getSelectedObjects()).some((t=>"KritzelGroup"===t.__class__)),action:()=>this.engineRef.ungroup()}]},{label:"Export",icon:"download",group:"export",children:[{label:"Export as SVG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsSvg()},{label:"Export as PNG",icon:"download",action:()=>this.engineRef.exportSelectedObjectsAsPng()}]},{label:"Delete",icon:"delete",group:"edit",action:()=>this.engineRef.delete()}];customSvgIcons={};isControlsVisible=!0;isUtilityPanelVisible=!0;isWorkspaceManagerVisible=!0;isMoreMenuVisible=!0;syncConfig=C;assetStorageConfig=Fe;cursorTarget;loginConfig={providers:[{label:"Sign in with Google",icon:"google",name:"Google"}]};isLoading=!1;editorId;activeWorkspaceId;isReady;activeWorkspaceChange;objectsChange;objectsAdded;objectsRemoved;objectsUpdated;undoStateChange;themeChange;viewportChange;logout;login;isPublicChange;awarenessChange;isEngineReady=!1;isControlsReady=!1;isWorkspaceManagerReady=!1;workspaces=[];activeWorkspace;isVirtualKeyboardOpen=!1;undoState=null;isBackToContentButtonVisible=!1;currentTheme="light";shortcuts=[];currentIsPublic=!1;onIsEngineReady(t){t&&this.isControlsReady&&this.checkIsReady()}onIsControlsReady(t){t&&this.isEngineReady&&this.checkIsReady()}onWorkspacesChange(t){const e=this.activeWorkspace;if(e){const s=t.find((t=>t.id===e.id));s&&s!==e&&(this.activeWorkspace=s)}if(this.activeWorkspaceId){const e=t.find((t=>t.id===this.activeWorkspaceId));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}}onActiveWorkspaceChange(){this.updateCurrentIsPublic()}onActiveWorkspaceIdChange(t){if(!t)return;if(0===this.workspaces.length)return;const e=this.workspaces.find((e=>e.id===t));e?e!==this.activeWorkspace&&(this.activeWorkspace=e):console.warn("[KritzelEditor] No workspace found with ID: "+t)}onCurrentThemeChange(){setTimeout((()=>this.setOsSpecificCssVariables()),0)}onTouchStart(t){t.cancelable&&t.preventDefault()}async getObjectById(t){return this.engineRef.getObjectById(t)}async addObject(t){return this.engineRef.addObject(t)}async updateObject(t,e){return this.engineRef.updateObject(t,e)}async removeObject(t){return this.engineRef.removeObject(t)}async getSelectedObjects(){return this.engineRef.getSelectedObjects()}async selectObjects(t){return this.engineRef.selectObjects(t)}async selectAllObjectsInViewport(){return this.engineRef.selectAllObjectsInViewport()}async clearSelection(){this.engineRef.clearSelection()}async centerObjectInViewport(t){return this.engineRef.centerObjectInViewport(t)}async backToContent(){return this.engineRef.backToContent()}async centerAllObjects(t=!0){return this.engineRef.centerAllObjects(t)}async setViewport(t,e,s){return this.engineRef.setViewport(t,e,s)}async panTo(t,e){return this.engineRef.panTo(t,e)}async zoomTo(t,e,s){return this.engineRef.zoomTo(t,e,s)}async getViewport(){return this.engineRef.getViewport()}async screenToWorld(t,e){return this.engineRef.screenToWorld(t,e)}async worldToScreen(t,e){return this.engineRef.worldToScreen(t,e)}async createWorkspace(t){return this.engineRef.createWorkspace(t)}async updateWorkspace(t){return this.engineRef.updateWorkspace(t)}async deleteWorkspace(t){return this.engineRef.deleteWorkspace(t)}async getWorkspaces(){return this.engineRef.getWorkspaces()}async getActiveWorkspace(){return this.engineRef.getActiveWorkspace()}async loadSharedWorkspace(t){return this.engineRef.loadSharedWorkspace(t)}async reinitSync(){return this.engineRef.reinitSync()}async registerTool(t,e,s){return this.engineRef.registerTool(t,e,s)}async changeActiveTool(t){return this.engineRef.changeActiveTool(t)}async disable(){return this.engineRef.disable()}async enable(){return this.engineRef.enable()}async copy(){return this.engineRef.copy()}async cut(){return this.engineRef.cut()}async paste(t,e){return this.engineRef.paste(t,e)}async delete(){return this.engineRef.delete()}async bringForward(t){return this.engineRef.bringForward(t)}async sendBackward(t){return this.engineRef.sendBackward(t)}async bringToFront(t){return this.engineRef.bringToFront(t)}async sendToBack(t){return this.engineRef.sendToBack(t)}async alignObjects(t){return this.engineRef.alignObjects(t)}async group(){return this.engineRef.group()}async ungroup(){return this.engineRef.ungroup()}async undo(){return this.engineRef.undo()}async redo(){return this.engineRef.redo()}async getScreenshot(t="png"){return this.engineRef.getScreenshot(t)}async exportViewportAsPng(){return this.engineRef.exportViewportAsPng()}async exportViewportAsSvg(){return this.engineRef.exportViewportAsSvg()}async downloadAsJson(t){return this.engineRef.downloadAsJson(t)}async importFromFile(){return this.engineRef.importFromFile()}async loadObjectsFromJson(t){return this.engineRef.loadObjectsFromJson(t)}async getObjectsTotalCount(){return this.engineRef.getObjectsTotalCount()}async getAllObjects(){return this.engineRef.getAllObjects()}async findObjects(t){return this.engineRef.findObjects(t)}async getCopiedObjects(){return this.engineRef.getCopiedObjects()}async getObjectsInViewport(){return this.engineRef.getObjectsInViewport()}async hideContextMenu(){return this.engineRef.hideContextMenu()}async triggerSelectionChange(){return this.engineRef.triggerSelectionChange()}async getDisplayableShortcuts(){return this.engineRef.getDisplayableShortcuts()}engineRef;controlsRef;settingsRef;exportRef;splitButtonRef;shareDialogRef;loginDialogRef;componentWillLoad(){this.loadSettingsFromStorage()}componentDidLoad(){this.registerCustomSvgIcons(),this.listenForMobileKeyboard(),this.setOsSpecificCssVariables()}async checkIsReady(){if(await customElements.whenDefined("kritzel-editor"),await customElements.whenDefined("kritzel-workspace-manager"),await customElements.whenDefined("kritzel-controls"),await customElements.whenDefined("kritzel-engine"),!(this.isEngineReady&&this.isControlsReady&&this.isWorkspaceManagerReady&&this.activeWorkspace))return;const{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n}=this.activeWorkspace;this.isReady.emit({host:this.host,activeWorkspace:{id:t,name:e,isPublic:s,createdAt:i,updatedAt:n},syncConfig:this.syncConfig,assetStorageConfig:this.assetStorageConfig,loginConfig:this.loginConfig})}async onEngineReady(t){this.isEngineReady=!0,t.detail.activeWorkspace&&(this.activeWorkspace=t.detail.activeWorkspace,this.workspaces=t.detail.workspaces,this.currentIsPublic=await this.engineRef.getIsPublic(),this.loadShortcuts())}handleWorkspacesChange(t){this.workspaces=t.detail}handleActiveWorkspaceChange(t){if(t.stopPropagation(),this.activeWorkspace=t.detail,!this.isEngineReady)return;const{id:e,name:s,isPublic:i,createdAt:n,updatedAt:o}=this.activeWorkspace;this.activeWorkspaceChange.emit({id:e,name:s,isPublic:i,createdAt:n,updatedAt:o})}handleObjectsChange(t){this.objectsChange.emit(t.detail)}handleObjectsAdded(t){this.objectsAdded.emit(t.detail)}handleObjectsRemoved(t){this.objectsRemoved.emit(t.detail)}handleObjectsUpdated(t){this.objectsUpdated.emit(t.detail)}handleUndoStateChange(t){this.undoStateChange.emit(t.detail),this.undoState=t.detail}async handleObjectsInViewportChange(t){const e=this.getContentObjects(t.detail).length>0,s=this.getContentObjects(await this.engineRef.getAllObjects()).length>0;this.isBackToContentButtonVisible=!e&&s}handleViewportChange(t){this.viewportChange.emit(t.detail)}handleAwarenessChange(t){this.awarenessChange.emit(t.detail)}handleSettingsChange(t){this.scaleMin=t.detail.scaleMin,this.scaleMax=t.detail.scaleMax,this.lockDrawingScale=t.detail.lockDrawingScale,this.currentTheme=t.detail.theme,this.viewportBoundaryLeft=t.detail.viewportBoundaryLeft??-1/0,this.viewportBoundaryRight=t.detail.viewportBoundaryRight??1/0,this.viewportBoundaryTop=t.detail.viewportBoundaryTop??-1/0,this.viewportBoundaryBottom=t.detail.viewportBoundaryBottom??1/0,this.debugInfo=t.detail.debugInfo,this.themeChange.emit(t.detail.theme)}get moreMenuItems(){return[{id:"share",label:"Share",icon:"share",action:()=>{this.isLoggedIn||!this.loginConfig?this.shareDialogRef.open():this.openLoginDialog()}},{id:"export",label:"Export",icon:"upload",action:async()=>{const t=await this.engineRef.getScreenshot("png");this.exportRef.open(t??void 0)}},{id:"import",label:"Import",icon:"download",action:()=>this.engineRef.importFromFile()},{id:"settings",label:"Settings",icon:"settings",action:()=>this.settingsRef.open()},{id:"logout",label:"Logout",icon:"log-out",color:"#ff3b30",isVisible:this.isLoggedIn,action:()=>this.logout.emit()}]}handleToggleIsPublic=async t=>{const e=t.detail,s=await this.engineRef.getActiveWorkspace();s.isPublic=e,await this.engineRef.updateWorkspace(s),this.activeWorkspace=s.clone(),this.isPublicChange.emit({isPublic:e,workspaceId:s.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,e&&this.isPublicChange.emit({isPublic:t,workspaceId:e})}handleProviderLogin=t=>{this.login.emit(t.detail)};get isLoggedIn(){return!!this.user&&!this.user.isGuest}async openLoginDialog(){this.loginDialogRef?.open()}async setLoginLoading(t){this.loginDialogRef?.setLoading(t)}getSettingsStorageKey(){return this.editorId?"kritzel-settings-"+this.editorId:"kritzel-settings"}loadSettingsFromStorage(){const t=localStorage.getItem(this.getSettingsStorageKey());if(t)try{const e=JSON.parse(t);"number"==typeof e.scaleMin&&(this.scaleMin=e.scaleMin),"number"==typeof e.scaleMax&&(this.scaleMax=e.scaleMax),"boolean"==typeof e.lockDrawingScale&&(this.lockDrawingScale=e.lockDrawingScale),"light"!==e.theme&&"dark"!==e.theme||(this.currentTheme=e.theme),"number"==typeof e.viewportBoundaryLeft&&(this.viewportBoundaryLeft=e.viewportBoundaryLeft),"number"==typeof e.viewportBoundaryRight&&(this.viewportBoundaryRight=e.viewportBoundaryRight),"number"==typeof e.viewportBoundaryTop&&(this.viewportBoundaryTop=e.viewportBoundaryTop),"number"==typeof e.viewportBoundaryBottom&&(this.viewportBoundaryBottom=e.viewportBoundaryBottom),e.debugInfo&&(this.debugInfo={...this.debugInfo,...e.debugInfo})}catch{}}async loadShortcuts(){this.shortcuts=await this.engineRef.getDisplayableShortcuts()}getContentObjects(t){return t.filter((t=>!(t instanceof g||t instanceof b)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){f.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(S.detectOS()){case"iOS":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;case"Android":this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","24px"),this.host.style.setProperty("--kritzel-editor-controls-transition","cubic-bezier(0.25, 0.1, 0.25, 1.0)"),this.host.style.setProperty("--kritzel-editor-controls-transform","translateY(200%)"),this.host.style.setProperty("--kritzel-editor-controls-transition-duration","0.25s");break;default:this.host.style.setProperty("--kritzel-editor-top-left-buttons-top","14px"),this.host.style.setProperty("--kritzel-editor-top-left-buttons-left","14px"),this.host.style.setProperty("--kritzel-editor-controls-bottom","14px")}}render(){const t=this.isLoggedIn,e=t,s=!!this.loginConfig&&!t;return i(n,{key:"6e832b0036dbc0d36aa70b297cf73cceafbaa846"},i("div",{key:"48e99e354326781792798fdcc2b07a1b5bbc8cca",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"980bf87558891a8b20030be4b6d0c32ee568ca4d",visible:this.isWorkspaceManagerVisible,workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"59636e148d71c54e51f17095dfec2754d63f1692",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"11f17eef609d3d3ece1ead3cf51524e690f4a2eb",ref:t=>{t&&(this.engineRef=t)},workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,assetStorageConfig:this.assetStorageConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,scaleMin:this.scaleMin,cursorTarget:this.cursorTarget,isLoading:this.isLoading,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.currentTheme,debugInfo:this.debugInfo,globalContextMenuItems:this.globalContextMenuItems,objectContextMenuItems:this.objectContextMenuItems,onIsEngineReady:t=>this.onEngineReady(t),onWorkspacesChange:t=>this.handleWorkspacesChange(t),onActiveWorkspaceChange:t=>this.handleActiveWorkspaceChange(t),onObjectsChange:t=>this.handleObjectsChange(t),onObjectsAdded:t=>this.handleObjectsAdded(t),onObjectsRemoved:t=>this.handleObjectsRemoved(t),onObjectsUpdated:t=>this.handleObjectsUpdated(t),onUndoStateChange:t=>this.handleUndoStateChange(t),onObjectsInViewportChange:t=>this.handleObjectsInViewportChange(t),onViewportChange:t=>this.handleViewportChange(t),onAwarenessChange:t=>this.handleAwarenessChange(t)}),i("kritzel-controls",{key:"b9852a78ed062ca7026b8d0da44263fb0a64d8cc",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>{t&&(this.controlsRef=t)},controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState??void 0,theme:this.currentTheme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"f3e33d794033eb5fdbde8c4553c744da61eefc51",class:"top-right-buttons"},i("kritzel-settings",{key:"466ac8a5d110feb46472c3207f4a73e9ce37e148",ref:t=>{t&&(this.settingsRef=t)},shortcuts:this.shortcuts,editorId:this.editorId,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"c6e0eca3baca940f9160ca02989d5c27410ccc59",ref:t=>{t&&(this.exportRef=t)},workspaceName:this.activeWorkspace?.name||"workspace",onExportPng:()=>this.engineRef.exportViewportAsPng(),onExportSvg:()=>this.engineRef.exportViewportAsSvg(),onExportJson:t=>this.engineRef.downloadAsJson(t.detail)}),i("kritzel-active-users",{key:"b66a7736b9ac0942873e5bdc1677228cd53d57d6",users:this.activeUsers}),e&&i("kritzel-current-user",{key:"4ab0b49bd43f428fb1ade5d5d9836d846355d92f",user:this.user}),s&&i("kritzel-button",{key:"04d6d43b60ad1bd3272dfb1e09aa3efb9602c42e",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"7ca482736a2253d95dffc369de1db1d14d207c35",items:this.moreMenuItems,visible:this.isMoreMenuVisible}),i("kritzel-share-dialog",{key:"c5ae3f2e981d980fd35380424036acdc29b0fe53",ref:t=>{t&&(this.shareDialogRef=t)},isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"f72b412715d0ffd9a8038ade192d894623fc98fc",ref:t=>{t&&(this.loginDialogRef=t)},providers:this.loginConfig.providers,dialogTitle:this.loginConfig.title,subtitle:this.loginConfig.subtitle,onProviderLogin:this.handleProviderLogin})))}static get watchers(){return{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}}static get style(){return"kritzel-editor{display:flex;margin:0;position:relative;overflow:hidden;width:100%;height:100%;align-items:center;justify-content:center;touch-action:manipulation;user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}kritzel-controls{position:absolute;bottom:var(--kritzel-editor-controls-bottom, 14px);transition:transform var(--kritzel-editor-controls-transition-duration, 0.1s) var(--kritzel-editor-controls-transition, ease-in-out)}kritzel-controls.keyboard-open{transform:var(--kritzel-editor-controls-transform, translateY(300%))}.top-left-buttons{position:absolute;top:var(--kritzel-editor-top-left-buttons-top, 14px);left:var(--kritzel-editor-top-left-buttons-left, 14px);display:flex;align-items:flex-start;gap:8px;z-index:10000}.top-right-buttons{position:absolute;top:var(--kritzel-editor-top-right-buttons-top, 14px);right:var(--kritzel-editor-top-right-buttons-right, 14px);display:flex;align-items:center;gap:8px;z-index:10000}.top-right-button{display:flex;align-items:center;justify-content:center;width:50px;height:50px;padding:0;border:var(--kritzel-split-button-border, 1px solid #ebebeb);border-radius:var(--kritzel-split-button-border-radius, 12px);background-color:var(--kritzel-split-button-background-color, #ffffff);cursor:var(--kritzel-global-pointer-cursor, pointer);box-shadow:var(--kritzel-split-button-box-shadow, 0 0 3px rgba(0, 0, 0, 0.08));transition:background-color 150ms ease;-webkit-tap-highlight-color:transparent}.top-right-button:hover{background-color:#f5f5f5}.top-right-button:active{background-color:#ebebeb}"}},[512,"kritzel-editor",{scaleMax:[1026,"scale-max"],scaleMin:[1026,"scale-min"],lockDrawingScale:[1028,"lock-drawing-scale"],viewportBoundaryLeft:[1026,"viewport-boundary-left"],viewportBoundaryRight:[1026,"viewport-boundary-right"],viewportBoundaryTop:[1026,"viewport-boundary-top"],viewportBoundaryBottom:[1026,"viewport-boundary-bottom"],wheelEnabled:[1028,"wheel-enabled"],debugInfo:[1040],user:[16],activeUsers:[16],controls:[16],globalContextMenuItems:[16],objectContextMenuItems:[16],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],isWorkspaceManagerVisible:[4,"is-workspace-manager-visible"],isMoreMenuVisible:[4,"is-more-menu-visible"],syncConfig:[16],assetStorageConfig:[16],cursorTarget:[16],loginConfig:[16],isLoading:[4,"is-loading"],editorId:[1,"editor-id"],activeWorkspaceId:[1,"active-workspace-id"],isEngineReady:[32],isControlsReady:[32],isWorkspaceManagerReady:[32],workspaces:[32],activeWorkspace:[32],isVirtualKeyboardOpen:[32],undoState:[32],isBackToContentButtonVisible:[32],currentTheme:[32],shortcuts:[32],currentIsPublic:[32],getObjectById:[64],addObject:[64],updateObject:[64],removeObject:[64],getSelectedObjects:[64],selectObjects:[64],selectAllObjectsInViewport:[64],clearSelection:[64],centerObjectInViewport:[64],backToContent:[64],centerAllObjects:[64],setViewport:[64],panTo:[64],zoomTo:[64],getViewport:[64],screenToWorld:[64],worldToScreen:[64],createWorkspace:[64],updateWorkspace:[64],deleteWorkspace:[64],getWorkspaces:[64],getActiveWorkspace:[64],loadSharedWorkspace:[64],reinitSync:[64],registerTool:[64],changeActiveTool:[64],disable:[64],enable:[64],copy:[64],cut:[64],paste:[64],delete:[64],bringForward:[64],sendBackward:[64],bringToFront:[64],sendToBack:[64],alignObjects:[64],group:[64],ungroup:[64],undo:[64],redo:[64],getScreenshot:[64],exportViewportAsPng:[64],exportViewportAsSvg:[64],downloadAsJson:[64],importFromFile:[64],loadObjectsFromJson:[64],getObjectsTotalCount:[64],getAllObjects:[64],findObjects:[64],getCopiedObjects:[64],getObjectsInViewport:[64],hideContextMenu:[64],triggerSelectionChange:[64],getDisplayableShortcuts:[64],openLoginDialog:[64],setLoginLoading:[64]},[[0,"dblclick","onTouchStart"]],{isEngineReady:[{onIsEngineReady:0}],isControlsReady:[{onIsControlsReady:0}],workspaces:[{onWorkspacesChange:0}],activeWorkspace:[{onActiveWorkspaceChange:0}],activeWorkspaceId:[{onActiveWorkspaceIdChange:0}],currentTheme:[{onCurrentThemeChange:0}]}]),Ge=Ke,Je=function(){"undefined"!=typeof customElements&&["kritzel-editor","kritzel-active-users","kritzel-avatar","kritzel-awareness-cursors","kritzel-back-to-content","kritzel-button","kritzel-color","kritzel-color-palette","kritzel-context-menu","kritzel-controls","kritzel-current-user","kritzel-current-user-dialog","kritzel-cursor-trail","kritzel-dialog","kritzel-dropdown","kritzel-engine","kritzel-export","kritzel-font","kritzel-font-family","kritzel-font-size","kritzel-icon","kritzel-input","kritzel-line-endings","kritzel-login-dialog","kritzel-master-detail","kritzel-menu","kritzel-menu-item","kritzel-more-menu","kritzel-numeric-input","kritzel-opacity-slider","kritzel-pill-tabs","kritzel-portal","kritzel-settings","kritzel-shape-fill","kritzel-share-dialog","kritzel-slide-toggle","kritzel-split-button","kritzel-stroke-size","kritzel-tool-config","kritzel-tooltip","kritzel-utility-panel","kritzel-workspace-manager"].forEach((t=>{switch(t){case"kritzel-editor":customElements.get(o(t))||customElements.define(o(t),Ke);break;case"kritzel-active-users":customElements.get(o(t))||x();break;case"kritzel-avatar":customElements.get(o(t))||T();break;case"kritzel-awareness-cursors":customElements.get(o(t))||O();break;case"kritzel-back-to-content":customElements.get(o(t))||I();break;case"kritzel-button":customElements.get(o(t))||U();break;case"kritzel-color":customElements.get(o(t))||M();break;case"kritzel-color-palette":customElements.get(o(t))||D();break;case"kritzel-context-menu":customElements.get(o(t))||R();break;case"kritzel-controls":customElements.get(o(t))||B();break;case"kritzel-current-user":customElements.get(o(t))||W();break;case"kritzel-current-user-dialog":customElements.get(o(t))||P();break;case"kritzel-cursor-trail":customElements.get(o(t))||V();break;case"kritzel-dialog":customElements.get(o(t))||L();break;case"kritzel-dropdown":customElements.get(o(t))||F();break;case"kritzel-engine":customElements.get(o(t))||j();break;case"kritzel-export":customElements.get(o(t))||N();break;case"kritzel-font":customElements.get(o(t))||K();break;case"kritzel-font-family":customElements.get(o(t))||G();break;case"kritzel-font-size":customElements.get(o(t))||J();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||q();break;case"kritzel-line-endings":customElements.get(o(t))||H();break;case"kritzel-login-dialog":customElements.get(o(t))||_();break;case"kritzel-master-detail":customElements.get(o(t))||Y();break;case"kritzel-menu":customElements.get(o(t))||$();break;case"kritzel-menu-item":customElements.get(o(t))||Q();break;case"kritzel-more-menu":customElements.get(o(t))||Z();break;case"kritzel-numeric-input":customElements.get(o(t))||X();break;case"kritzel-opacity-slider":customElements.get(o(t))||tt();break;case"kritzel-pill-tabs":customElements.get(o(t))||et();break;case"kritzel-portal":customElements.get(o(t))||st();break;case"kritzel-settings":customElements.get(o(t))||it();break;case"kritzel-shape-fill":customElements.get(o(t))||nt();break;case"kritzel-share-dialog":customElements.get(o(t))||ot();break;case"kritzel-slide-toggle":customElements.get(o(t))||rt();break;case"kritzel-split-button":customElements.get(o(t))||at();break;case"kritzel-stroke-size":customElements.get(o(t))||ct();break;case"kritzel-tool-config":customElements.get(o(t))||ht();break;case"kritzel-tooltip":customElements.get(o(t))||lt();break;case"kritzel-utility-panel":customElements.get(o(t))||dt();break;case"kritzel-workspace-manager":customElements.get(o(t))||ut()}}))};export{Pe as D,We as H,Ge as KritzelEditor,Se as a,Ve as b,Le as c,Fe as d,Je as defineCustomElement}
@@ -1 +1 @@
1
- import{h as o,g as s}from"./p-eez_2Ccc.js";const c=o,e=s;export{c as KritzelEngine,e as defineCustomElement}
1
+ import{h as o,g as s}from"./p-B7jb9G4E.js";const p=o,r=s;export{p as KritzelEngine,r as defineCustomElement}
@@ -1 +1 @@
1
- import{K as o,d as s}from"./p-KAwmnjZJ.js";const m=o,p=s;export{m as KritzelSettings,p as defineCustomElement}
1
+ import{K as o,d as s}from"./p-CgVHVzNt.js";const t=o,p=s;export{t as KritzelSettings,p as defineCustomElement}