kritzel-stencil 0.1.64 → 0.1.65
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.
- package/dist/cjs/kritzel-active-users_40.cjs.entry.js +10 -13
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +1 -1
- package/dist/collection/components/ui/kritzel-current-user/kritzel-current-user.js +1 -4
- package/dist/collection/components/ui/kritzel-export/kritzel-export.js +1 -1
- package/dist/collection/components/ui/kritzel-login-dialog/kritzel-login-dialog.js +1 -1
- package/dist/collection/components/ui/kritzel-more-menu/kritzel-more-menu.js +1 -1
- package/dist/collection/components/ui/kritzel-settings/kritzel-settings.js +1 -1
- package/dist/collection/components/ui/kritzel-share-dialog/kritzel-share-dialog.js +2 -2
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/constants/version.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-current-user.js +1 -1
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-export.js +1 -1
- package/dist/components/kritzel-login-dialog.js +1 -1
- package/dist/components/kritzel-more-menu.js +1 -1
- package/dist/components/kritzel-settings.js +1 -1
- package/dist/components/kritzel-share-dialog.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/{p-BIR94TZo.js → p-BigXf4HY.js} +1 -1
- package/dist/components/{p-B6bAkfr2.js → p-C3oZEcbe.js} +1 -1
- package/dist/components/{p-C128uVgu.js → p-CAyKy1cc.js} +1 -1
- package/dist/components/{p-B3FMsFu8.js → p-CKy-O_xW.js} +1 -1
- package/dist/components/{p-DTPKVvYU.js → p-D10gvYUs.js} +1 -1
- package/dist/components/p-D4vHTVYS.js +1 -0
- package/dist/components/{p-BUkQ_vI2.js → p-DixJT29r.js} +1 -1
- package/dist/components/{p-CZC3OMJO.js → p-KXf95dmS.js} +1 -1
- package/dist/esm/kritzel-active-users_40.entry.js +10 -13
- package/dist/stencil/{p-0e3f1374.entry.js → p-5719dd66.entry.js} +2 -2
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/constants/version.d.ts +1 -1
- package/dist/types/interfaces/user.interface.d.ts +2 -0
- package/package.json +1 -1
- package/dist/components/p-oiAEG5Cp.js +0 -1
|
@@ -933,10 +933,7 @@ const KritzelCurrentUser = class {
|
|
|
933
933
|
this.closeMenu();
|
|
934
934
|
};
|
|
935
935
|
render() {
|
|
936
|
-
|
|
937
|
-
return index.h(index.Host, { style: { display: 'none' } });
|
|
938
|
-
}
|
|
939
|
-
return (index.h(index.Host, null, index.h("kritzel-avatar", { user: this.user, size: this.avatarSize, onClick: this.toggleMenu }), index.h("kritzel-portal", { anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, index.h("kritzel-menu", { items: this.menuItems, onItemSelect: this.handleMenuItemSelect }))));
|
|
936
|
+
return (index.h(index.Host, { key: 'b2994e92ae664d8258131757344f6231f9b4cfa6' }, index.h("kritzel-avatar", { key: 'ff4ce1ed2d3e3619e1e53d1aed2c21f3ce1a8d0d', user: this.user, size: this.avatarSize, onClick: this.toggleMenu }), index.h("kritzel-portal", { key: '296d3f43875cd9f5fae76506610744256161e104', anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, index.h("kritzel-menu", { key: '8f0d1e9d0097ccf0426f9197853c005fd5ef6b48', items: this.menuItems, onItemSelect: this.handleMenuItemSelect }))));
|
|
940
937
|
}
|
|
941
938
|
};
|
|
942
939
|
KritzelCurrentUser.style = kritzelCurrentUserCss();
|
|
@@ -2255,7 +2252,7 @@ const KritzelEditor = class {
|
|
|
2255
2252
|
}
|
|
2256
2253
|
}
|
|
2257
2254
|
render() {
|
|
2258
|
-
return (index.h(index.Host, { key: '7b7fdb3c439c1240b85091471654162093e7cfbe' }, index.h("div", { key: '7df215c2eba182f1bc062724d098563fb9418f87', class: "top-left-buttons" }, index.h("kritzel-workspace-manager", { key: 'bca670f4992460038ab0dd7fabd564300283680b', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), index.h("kritzel-back-to-content", { key: 'cc0241ccaa912ef6c3aa8f714410293e993380dd', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), index.h("kritzel-engine", { key: '0374d9cd583336ebc21057b94bed77932e2cba1b', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), index.h("kritzel-controls", { key: 'd1e4b9b373019694347226de60b656f7105fb2a4', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), index.h("div", { key: '1bb1bbdb24da5e469bbf3fdfa9244b5320403227', class: "top-right-buttons" }, index.h("kritzel-settings", { key: 'cb4eeb7d2fd93a010995799d09ecd03b1e17f808', ref: el => (this.settingsRef = el), shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), index.h("kritzel-export", { key: '70a02663f888cdb739eedb736c6435a3348d8382', ref: el => (this.exportRef = el), workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), index.h("kritzel-active-users", { key: 'da22e92fbc1147c5ac891eb1df09f0f0274e8ba6', users: this.activeUsers }), index.h("kritzel-current-user", { key: '
|
|
2255
|
+
return (index.h(index.Host, { key: '7b7fdb3c439c1240b85091471654162093e7cfbe' }, index.h("div", { key: '7df215c2eba182f1bc062724d098563fb9418f87', class: "top-left-buttons" }, index.h("kritzel-workspace-manager", { key: 'bca670f4992460038ab0dd7fabd564300283680b', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), index.h("kritzel-back-to-content", { key: 'cc0241ccaa912ef6c3aa8f714410293e993380dd', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), index.h("kritzel-engine", { key: '0374d9cd583336ebc21057b94bed77932e2cba1b', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), index.h("kritzel-controls", { key: 'd1e4b9b373019694347226de60b656f7105fb2a4', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), index.h("div", { key: '1bb1bbdb24da5e469bbf3fdfa9244b5320403227', class: "top-right-buttons" }, index.h("kritzel-settings", { key: 'cb4eeb7d2fd93a010995799d09ecd03b1e17f808', ref: el => (this.settingsRef = el), shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), index.h("kritzel-export", { key: '70a02663f888cdb739eedb736c6435a3348d8382', ref: el => (this.exportRef = el), workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), index.h("kritzel-active-users", { key: 'da22e92fbc1147c5ac891eb1df09f0f0274e8ba6', users: this.activeUsers }), this.loginConfig && this.user && !this.user.isGuest && (index.h("kritzel-current-user", { key: 'eb35978536b353f57e3902168bc39afcd2634404', user: this.user, onItemSelect: event => this.handleCurrentUserItemSelect(event) })), this.loginConfig && (!this.user || this.user.isGuest) && index.h("kritzel-button", { key: '83556b3580f320292c720d3bffb3be9dde1432aa', onButtonClick: () => this.loginDialogRef?.open() }, "Sign in"), index.h("kritzel-more-menu", { key: 'a838c25f4b19e76f81afa2fd30414648073ceb3b', onItemSelect: event => this.handleMoreMenuItemSelect(event) }), index.h("kritzel-share-dialog", { key: 'a14a049714e150062b1fac0cca3d70043a6ab8bf', ref: el => (this.shareDialogRef = el), isPublic: this.currentIsPublic, workspaceId: this.activeWorkspace?.id, onToggleIsPublic: this.handleToggleIsPublic }), this.loginConfig && (index.h("kritzel-login-dialog", { key: '36411a379aa2d9a239a4d8fff6efc6037dfea068', ref: el => (this.loginDialogRef = el), providers: this.loginConfig.providers, dialogTitle: this.loginConfig.title, subtitle: this.loginConfig.subtitle, onProviderLogin: this.handleProviderLogin })))));
|
|
2259
2256
|
}
|
|
2260
2257
|
static get watchers() { return {
|
|
2261
2258
|
"isEngineReady": [{
|
|
@@ -26753,7 +26750,7 @@ const KritzelExport = class {
|
|
|
26753
26750
|
return (index.h("div", { class: "export-tab-content" }, index.h("kritzel-input", { label: "Filename", value: this.exportFilename, placeholder: "Enter filename", suffix: ".json", onValueChange: this.handleFilenameChange })));
|
|
26754
26751
|
}
|
|
26755
26752
|
render() {
|
|
26756
|
-
return (index.h(index.Host, { key: '
|
|
26753
|
+
return (index.h(index.Host, { key: 'ecbb8ef8f31a8742206c0884e171b79c69b3dbb2' }, index.h("kritzel-dialog", { key: '29cfc751195de55e6ae6a47e6d1952ceb2727c97', isOpen: this.isDialogOpen, dialogTitle: "Export", closable: true, onDialogClose: this.closeDialog }, index.h("div", { key: '2565a9a99dc639a4d54e37a2b2ce7925086257ce', class: "export-content" }, index.h("kritzel-pill-tabs", { key: 'a2b9f6f38a70ca416e4de9e06b72ff0a36a2c40b', tabs: this.tabs, value: this.activeTab, onValueChange: this.handleTabChange }), this.activeTab === 'viewport' && this.renderViewportExport(), this.activeTab === 'workspace' && this.renderWorkspaceExport(), index.h("button", { key: '7d9a540c1d85d1362c1411ed71b55166ff19d8d6', class: "export-primary-button", onClick: this.handleExport }, "Export")))));
|
|
26757
26754
|
}
|
|
26758
26755
|
};
|
|
26759
26756
|
KritzelExport.style = kritzelExportCss();
|
|
@@ -27050,7 +27047,7 @@ const KritzelLoginDialog = class {
|
|
|
27050
27047
|
this.dialogClosed.emit();
|
|
27051
27048
|
};
|
|
27052
27049
|
render() {
|
|
27053
|
-
return (index.h(index.Host, { key: '
|
|
27050
|
+
return (index.h(index.Host, { key: '2e4dac186ad527a7b5d4d7846549b5b8eee9540a' }, index.h("kritzel-dialog", { key: '91ba8e589056391f3bd0c2fee188dfcbff91bfd3', dialogTitle: this.dialogTitle, isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, index.h("div", { key: 'f554ab5a524bf753d832042b4a3983ef42221326', class: "login-content" }, this.subtitle && (index.h("p", { key: 'ba41bd1736c8d86c7c804958fa821e1648fb5ed9', class: "login-subtitle" }, this.subtitle)), index.h("div", { key: '39cf113c34881d214e0bfda8fe0949e1af1bf9e9', class: "login-providers" }, this.providers.map(provider => (index.h("button", { key: provider.name, class: {
|
|
27054
27051
|
'provider-button': true,
|
|
27055
27052
|
'is-loading': this.loadingProvider === provider.name,
|
|
27056
27053
|
'is-disabled': this.loadingProvider !== null && this.loadingProvider !== provider.name,
|
|
@@ -27428,7 +27425,7 @@ const KritzelMoreMenu = class {
|
|
|
27428
27425
|
this.closeMenu();
|
|
27429
27426
|
};
|
|
27430
27427
|
render() {
|
|
27431
|
-
return (index.h(index.Host, { key: '
|
|
27428
|
+
return (index.h(index.Host, { key: 'fff6c06a978886d159d9f01cd7d3b70073a7fa53' }, index.h("button", { key: '588562b39541db314b9facc294cc478f9696ac2e', class: "more-menu-button", onClick: this.toggleMenu }, index.h("kritzel-icon", { key: '6b11f2001985e138d8c61205422ba947c2ca81a7', name: this.icon, size: this.iconSize })), index.h("kritzel-portal", { key: 'fd30b4b8664e9155c2c463d7cc54cfbe1575a156', anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, index.h("kritzel-menu", { key: '01f1e7e7a96be9a2249ed48a9ad93fb8e1f009e1', items: this.items, onItemSelect: this.handleMenuItemSelect }))));
|
|
27432
27429
|
}
|
|
27433
27430
|
};
|
|
27434
27431
|
KritzelMoreMenu.style = kritzelMoreMenuCss();
|
|
@@ -27909,7 +27906,7 @@ const KritzelPortal = class {
|
|
|
27909
27906
|
* This file is auto-generated by the version bump scripts.
|
|
27910
27907
|
* Do not modify manually.
|
|
27911
27908
|
*/
|
|
27912
|
-
const KRITZEL_VERSION = '0.1.
|
|
27909
|
+
const KRITZEL_VERSION = '0.1.65';
|
|
27913
27910
|
|
|
27914
27911
|
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)}`;
|
|
27915
27912
|
|
|
@@ -28086,7 +28083,7 @@ const KritzelSettings = class {
|
|
|
28086
28083
|
}
|
|
28087
28084
|
}
|
|
28088
28085
|
render() {
|
|
28089
|
-
return (index.h(index.Host, { key: '
|
|
28086
|
+
return (index.h(index.Host, { key: '05c3098b8af5926b753c028a356fabde832b9ff3' }, index.h("kritzel-dialog", { key: 'c870af6cd4aaa4e489d0cc00d843e51b0b7d77aa', isOpen: this.isDialogOpen, dialogTitle: "Settings", size: "large", onDialogClose: this.closeDialog }, index.h("kritzel-master-detail", { key: '87aeebc15ccb6a93d4db1d52c24c9fca1be6348e', items: SETTINGS_CATEGORIES, selectedItemId: this.selectedCategoryId, onItemSelect: this.handleCategorySelect }, this.renderCategoryContent()))));
|
|
28090
28087
|
}
|
|
28091
28088
|
};
|
|
28092
28089
|
KritzelSettings.style = kritzelSettingsCss();
|
|
@@ -28212,9 +28209,9 @@ const KritzelShareDialog = class {
|
|
|
28212
28209
|
this.dialogClosed.emit();
|
|
28213
28210
|
};
|
|
28214
28211
|
render() {
|
|
28215
|
-
return (index.h(index.Host, { key: '
|
|
28212
|
+
return (index.h(index.Host, { key: '072eab846442e4818542677ec3773a1823af28e6' }, index.h("kritzel-dialog", { key: 'f2f78ef5e2b0275e4ea0a37fcdea495f8a302188', dialogTitle: "Share Workspace", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, index.h("div", { key: '5b02c7a114ab309c435631910f6c15bac58e04dd', class: "share-content" }, index.h("div", { key: '5f56b54595cb9faa8b7187086512f3a5aab22b47', class: "share-section" }, index.h("div", { key: '2f03b8e319e88506dd323ebdc9fe097f3edb828a', class: "share-row" }, index.h("div", { key: '5009bbab7e96eac57df2f6e7415a4bb347d0337c', class: "share-label-group" }, index.h("label", { key: '5dead4f21270bb2a60a1e72b1223cffe2c3891d2', class: "share-label" }, "Link sharing"), index.h("p", { key: '5afa53adc57242b689b6fe68fbbb198956fc0fd6', class: "share-description" }, this.internalIsPublic
|
|
28216
28213
|
? 'Anyone with the link can access this workspace.'
|
|
28217
|
-
: 'Link sharing is disabled. Only you can access this workspace.')), index.h("kritzel-slide-toggle", { key: '
|
|
28214
|
+
: 'Link sharing is disabled. Only you can access this workspace.')), index.h("kritzel-slide-toggle", { key: '7c73afd7c099529f8389d22566fe1ef6fce10fbc', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: "Enable link sharing" }))), this.internalIsPublic && (index.h("div", { key: 'a23829c1b49fdb1edd39b8bd9d2bb4bf89a64c60', class: "share-section" }, index.h("div", { key: '957853fccccf842831b37e4848404c9bdc2c224a', class: "share-url-container" }, index.h("input", { key: '7b57cfd1e8f2fa16ebf753840beb3cbfcb116e33', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), index.h("button", { key: 'f55787708c9e80c3d0bf53b13695773b0c5251fa', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? 'Copied!' : 'Copy link' }, index.h("kritzel-icon", { key: 'd50d6d5849d77d2cdcfe4c9eb1ac05e2b14210b0', name: this.copySuccess ? 'check' : 'copy', size: 18 })))))))));
|
|
28218
28215
|
}
|
|
28219
28216
|
static get watchers() { return {
|
|
28220
28217
|
"isPublic": [{
|
|
@@ -28760,7 +28757,7 @@ const KritzelUtilityPanel = class {
|
|
|
28760
28757
|
this.redo.emit();
|
|
28761
28758
|
}
|
|
28762
28759
|
render() {
|
|
28763
|
-
return (index.h(index.Host, { key: '
|
|
28760
|
+
return (index.h(index.Host, { key: '7f5b5cba79e4e7fa02ab068586cc131530ca31ee' }, index.h("button", { key: '05369f4b3057f031233a6bda2c8b64108b166252', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event) }, index.h("kritzel-icon", { key: '0314795c0a657afa7fc34ba0ff64bc4d56889940', name: "undo" })), index.h("button", { key: 'acecd712262bf4fe599ed043297c0634920f36e3', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event) }, index.h("kritzel-icon", { key: '4ad50519e1f1f98de86573f2b44b36669de0058e', name: "redo" })), index.h("div", { key: 'a0feea0ceb0c212a3103b5ef9a7c580c3c73146d', class: "utility-separator" }), index.h("button", { key: 'b65655ae7000eafdd54a9dc7c5feaf7da794cca7', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit() }, index.h("kritzel-icon", { key: '23d42a377d5c8537b8717fae822a8be07ebcd868', name: "delete" }))));
|
|
28764
28761
|
}
|
|
28765
28762
|
};
|
|
28766
28763
|
KritzelUtilityPanel.style = kritzelUtilityPanelCss();
|
|
@@ -660,7 +660,7 @@ export class KritzelEditor {
|
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
662
|
render() {
|
|
663
|
-
return (h(Host, { key: '7b7fdb3c439c1240b85091471654162093e7cfbe' }, h("div", { key: '7df215c2eba182f1bc062724d098563fb9418f87', class: "top-left-buttons" }, h("kritzel-workspace-manager", { key: 'bca670f4992460038ab0dd7fabd564300283680b', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-back-to-content", { key: 'cc0241ccaa912ef6c3aa8f714410293e993380dd', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), h("kritzel-engine", { key: '0374d9cd583336ebc21057b94bed77932e2cba1b', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), h("kritzel-controls", { key: 'd1e4b9b373019694347226de60b656f7105fb2a4', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), h("div", { key: '1bb1bbdb24da5e469bbf3fdfa9244b5320403227', class: "top-right-buttons" }, h("kritzel-settings", { key: 'cb4eeb7d2fd93a010995799d09ecd03b1e17f808', ref: el => (this.settingsRef = el), shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), h("kritzel-export", { key: '70a02663f888cdb739eedb736c6435a3348d8382', ref: el => (this.exportRef = el), workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), h("kritzel-active-users", { key: 'da22e92fbc1147c5ac891eb1df09f0f0274e8ba6', users: this.activeUsers }), h("kritzel-current-user", { key: '
|
|
663
|
+
return (h(Host, { key: '7b7fdb3c439c1240b85091471654162093e7cfbe' }, h("div", { key: '7df215c2eba182f1bc062724d098563fb9418f87', class: "top-left-buttons" }, h("kritzel-workspace-manager", { key: 'bca670f4992460038ab0dd7fabd564300283680b', workspaces: this.workspaces, activeWorkspace: this.activeWorkspace, onWorkspaceChange: event => (this.activeWorkspace = event.detail), onIsWorkspaceManagerReady: () => (this.isWorkspaceManagerReady = true) }), h("kritzel-back-to-content", { key: 'cc0241ccaa912ef6c3aa8f714410293e993380dd', visible: this.isBackToContentButtonVisible, onBackToContent: () => this.backToContent() })), h("kritzel-engine", { key: '0374d9cd583336ebc21057b94bed77932e2cba1b', ref: el => (this.engineRef = el), workspace: this.activeWorkspace, activeWorkspaceId: this.activeWorkspaceId, editorId: this.editorId, syncConfig: this.syncConfig, user: this.user, scaleMax: this.scaleMax, lockDrawingScale: this.lockDrawingScale, scaleMin: this.scaleMin, viewportBoundaryLeft: this.viewportBoundaryLeft, viewportBoundaryRight: this.viewportBoundaryRight, viewportBoundaryTop: this.viewportBoundaryTop, viewportBoundaryBottom: this.viewportBoundaryBottom, wheelEnabled: this.wheelEnabled, theme: this.currentTheme, globalContextMenuItems: this.globalContextMenuItems, objectContextMenuItems: this.objectContextMenuItems, onIsEngineReady: event => this.onEngineReady(event), onWorkspacesChange: event => this.handleWorkspacesChange(event), onActiveWorkspaceChange: event => this.handleActiveWorkspaceChange(event), onObjectsChange: event => this.handleObjectsChange(event), onObjectsAdded: event => this.handleObjectsAdded(event), onObjectsRemoved: event => this.handleObjectsRemoved(event), onObjectsUpdated: event => this.handleObjectsUpdated(event), onUndoStateChange: event => this.handleUndoStateChange(event), onObjectsInViewportChange: event => this.handleObjectsInViewportChange(event), onViewportChange: event => this.handleViewportChange(event), onAwarenessChange: event => this.handleAwarenessChange(event) }), h("kritzel-controls", { key: 'd1e4b9b373019694347226de60b656f7105fb2a4', class: { 'keyboard-open': this.isVirtualKeyboardOpen }, style: { display: this.isControlsVisible ? 'flex' : 'none' }, ref: el => (this.controlsRef = el), controls: this.controls, isUtilityPanelVisible: this.isUtilityPanelVisible, undoState: this.undoState, theme: this.currentTheme, onIsControlsReady: () => (this.isControlsReady = true) }), h("div", { key: '1bb1bbdb24da5e469bbf3fdfa9244b5320403227', class: "top-right-buttons" }, h("kritzel-settings", { key: 'cb4eeb7d2fd93a010995799d09ecd03b1e17f808', ref: el => (this.settingsRef = el), shortcuts: this.shortcuts, editorId: this.editorId, onSettingsChange: event => this.handleSettingsChange(event) }), h("kritzel-export", { key: '70a02663f888cdb739eedb736c6435a3348d8382', ref: el => (this.exportRef = el), workspaceName: this.activeWorkspace?.name || 'workspace', onExportPng: () => this.engineRef.exportViewportAsPng(), onExportSvg: () => this.engineRef.exportViewportAsSvg(), onExportJson: event => this.engineRef.downloadAsJson(event.detail) }), h("kritzel-active-users", { key: 'da22e92fbc1147c5ac891eb1df09f0f0274e8ba6', users: this.activeUsers }), this.loginConfig && this.user && !this.user.isGuest && (h("kritzel-current-user", { key: 'eb35978536b353f57e3902168bc39afcd2634404', user: this.user, onItemSelect: event => this.handleCurrentUserItemSelect(event) })), this.loginConfig && (!this.user || this.user.isGuest) && h("kritzel-button", { key: '83556b3580f320292c720d3bffb3be9dde1432aa', onButtonClick: () => this.loginDialogRef?.open() }, "Sign in"), h("kritzel-more-menu", { key: 'a838c25f4b19e76f81afa2fd30414648073ceb3b', onItemSelect: event => this.handleMoreMenuItemSelect(event) }), h("kritzel-share-dialog", { key: 'a14a049714e150062b1fac0cca3d70043a6ab8bf', ref: el => (this.shareDialogRef = el), isPublic: this.currentIsPublic, workspaceId: this.activeWorkspace?.id, onToggleIsPublic: this.handleToggleIsPublic }), this.loginConfig && (h("kritzel-login-dialog", { key: '36411a379aa2d9a239a4d8fff6efc6037dfea068', ref: el => (this.loginDialogRef = el), providers: this.loginConfig.providers, dialogTitle: this.loginConfig.title, subtitle: this.loginConfig.subtitle, onProviderLogin: this.handleProviderLogin })))));
|
|
664
664
|
}
|
|
665
665
|
static get is() { return "kritzel-editor"; }
|
|
666
666
|
static get originalStyleUrls() {
|
|
@@ -46,10 +46,7 @@ export class KritzelCurrentUser {
|
|
|
46
46
|
this.closeMenu();
|
|
47
47
|
};
|
|
48
48
|
render() {
|
|
49
|
-
|
|
50
|
-
return h(Host, { style: { display: 'none' } });
|
|
51
|
-
}
|
|
52
|
-
return (h(Host, null, h("kritzel-avatar", { user: this.user, size: this.avatarSize, onClick: this.toggleMenu }), h("kritzel-portal", { anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, h("kritzel-menu", { items: this.menuItems, onItemSelect: this.handleMenuItemSelect }))));
|
|
49
|
+
return (h(Host, { key: 'b2994e92ae664d8258131757344f6231f9b4cfa6' }, h("kritzel-avatar", { key: 'ff4ce1ed2d3e3619e1e53d1aed2c21f3ce1a8d0d', user: this.user, size: this.avatarSize, onClick: this.toggleMenu }), h("kritzel-portal", { key: '296d3f43875cd9f5fae76506610744256161e104', anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, h("kritzel-menu", { key: '8f0d1e9d0097ccf0426f9197853c005fd5ef6b48', items: this.menuItems, onItemSelect: this.handleMenuItemSelect }))));
|
|
53
50
|
}
|
|
54
51
|
static get is() { return "kritzel-current-user"; }
|
|
55
52
|
static get encapsulation() { return "shadow"; }
|
|
@@ -65,7 +65,7 @@ export class KritzelExport {
|
|
|
65
65
|
return (h("div", { class: "export-tab-content" }, h("kritzel-input", { label: "Filename", value: this.exportFilename, placeholder: "Enter filename", suffix: ".json", onValueChange: this.handleFilenameChange })));
|
|
66
66
|
}
|
|
67
67
|
render() {
|
|
68
|
-
return (h(Host, { key: '
|
|
68
|
+
return (h(Host, { key: 'ecbb8ef8f31a8742206c0884e171b79c69b3dbb2' }, h("kritzel-dialog", { key: '29cfc751195de55e6ae6a47e6d1952ceb2727c97', isOpen: this.isDialogOpen, dialogTitle: "Export", closable: true, onDialogClose: this.closeDialog }, h("div", { key: '2565a9a99dc639a4d54e37a2b2ce7925086257ce', class: "export-content" }, h("kritzel-pill-tabs", { key: 'a2b9f6f38a70ca416e4de9e06b72ff0a36a2c40b', tabs: this.tabs, value: this.activeTab, onValueChange: this.handleTabChange }), this.activeTab === 'viewport' && this.renderViewportExport(), this.activeTab === 'workspace' && this.renderWorkspaceExport(), h("button", { key: '7d9a540c1d85d1362c1411ed71b55166ff19d8d6', class: "export-primary-button", onClick: this.handleExport }, "Export")))));
|
|
69
69
|
}
|
|
70
70
|
static get is() { return "kritzel-export"; }
|
|
71
71
|
static get encapsulation() { return "shadow"; }
|
|
@@ -44,7 +44,7 @@ export class KritzelLoginDialog {
|
|
|
44
44
|
this.dialogClosed.emit();
|
|
45
45
|
};
|
|
46
46
|
render() {
|
|
47
|
-
return (h(Host, { key: '
|
|
47
|
+
return (h(Host, { key: '2e4dac186ad527a7b5d4d7846549b5b8eee9540a' }, h("kritzel-dialog", { key: '91ba8e589056391f3bd0c2fee188dfcbff91bfd3', dialogTitle: this.dialogTitle, isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: 'f554ab5a524bf753d832042b4a3983ef42221326', class: "login-content" }, this.subtitle && (h("p", { key: 'ba41bd1736c8d86c7c804958fa821e1648fb5ed9', class: "login-subtitle" }, this.subtitle)), h("div", { key: '39cf113c34881d214e0bfda8fe0949e1af1bf9e9', class: "login-providers" }, this.providers.map(provider => (h("button", { key: provider.name, class: {
|
|
48
48
|
'provider-button': true,
|
|
49
49
|
'is-loading': this.loadingProvider === provider.name,
|
|
50
50
|
'is-disabled': this.loadingProvider !== null && this.loadingProvider !== provider.name,
|
|
@@ -64,7 +64,7 @@ export class KritzelMoreMenu {
|
|
|
64
64
|
this.closeMenu();
|
|
65
65
|
};
|
|
66
66
|
render() {
|
|
67
|
-
return (h(Host, { key: '
|
|
67
|
+
return (h(Host, { key: 'fff6c06a978886d159d9f01cd7d3b70073a7fa53' }, h("button", { key: '588562b39541db314b9facc294cc478f9696ac2e', class: "more-menu-button", onClick: this.toggleMenu }, h("kritzel-icon", { key: '6b11f2001985e138d8c61205422ba947c2ca81a7', name: this.icon, size: this.iconSize })), h("kritzel-portal", { key: 'fd30b4b8664e9155c2c463d7cc54cfbe1575a156', anchor: this.menuAnchor, offsetY: this.offsetY, onClose: this.closeMenu }, h("kritzel-menu", { key: '01f1e7e7a96be9a2249ed48a9ad93fb8e1f009e1', items: this.items, onItemSelect: this.handleMenuItemSelect }))));
|
|
68
68
|
}
|
|
69
69
|
static get is() { return "kritzel-more-menu"; }
|
|
70
70
|
static get encapsulation() { return "shadow"; }
|
|
@@ -169,7 +169,7 @@ export class KritzelSettings {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
render() {
|
|
172
|
-
return (h(Host, { key: '
|
|
172
|
+
return (h(Host, { key: '05c3098b8af5926b753c028a356fabde832b9ff3' }, h("kritzel-dialog", { key: 'c870af6cd4aaa4e489d0cc00d843e51b0b7d77aa', isOpen: this.isDialogOpen, dialogTitle: "Settings", size: "large", onDialogClose: this.closeDialog }, h("kritzel-master-detail", { key: '87aeebc15ccb6a93d4db1d52c24c9fca1be6348e', items: SETTINGS_CATEGORIES, selectedItemId: this.selectedCategoryId, onItemSelect: this.handleCategorySelect }, this.renderCategoryContent()))));
|
|
173
173
|
}
|
|
174
174
|
static get is() { return "kritzel-settings"; }
|
|
175
175
|
static get encapsulation() { return "shadow"; }
|
|
@@ -84,9 +84,9 @@ export class KritzelShareDialog {
|
|
|
84
84
|
this.dialogClosed.emit();
|
|
85
85
|
};
|
|
86
86
|
render() {
|
|
87
|
-
return (h(Host, { key: '
|
|
87
|
+
return (h(Host, { key: '072eab846442e4818542677ec3773a1823af28e6' }, h("kritzel-dialog", { key: 'f2f78ef5e2b0275e4ea0a37fcdea495f8a302188', dialogTitle: "Share Workspace", isOpen: this.isDialogOpen, onDialogClose: this.closeDialog, size: "small" }, h("div", { key: '5b02c7a114ab309c435631910f6c15bac58e04dd', class: "share-content" }, h("div", { key: '5f56b54595cb9faa8b7187086512f3a5aab22b47', class: "share-section" }, h("div", { key: '2f03b8e319e88506dd323ebdc9fe097f3edb828a', class: "share-row" }, h("div", { key: '5009bbab7e96eac57df2f6e7415a4bb347d0337c', class: "share-label-group" }, h("label", { key: '5dead4f21270bb2a60a1e72b1223cffe2c3891d2', class: "share-label" }, "Link sharing"), h("p", { key: '5afa53adc57242b689b6fe68fbbb198956fc0fd6', class: "share-description" }, this.internalIsPublic
|
|
88
88
|
? 'Anyone with the link can access this workspace.'
|
|
89
|
-
: 'Link sharing is disabled. Only you can access this workspace.')), h("kritzel-slide-toggle", { key: '
|
|
89
|
+
: 'Link sharing is disabled. Only you can access this workspace.')), h("kritzel-slide-toggle", { key: '7c73afd7c099529f8389d22566fe1ef6fce10fbc', checked: this.internalIsPublic, onCheckedChange: this.handleToggleChange, label: "Enable link sharing" }))), this.internalIsPublic && (h("div", { key: 'a23829c1b49fdb1edd39b8bd9d2bb4bf89a64c60', class: "share-section" }, h("div", { key: '957853fccccf842831b37e4848404c9bdc2c224a', class: "share-url-container" }, h("input", { key: '7b57cfd1e8f2fa16ebf753840beb3cbfcb116e33', type: "text", class: "share-url-input", value: this.getShareUrl(), readOnly: true, onClick: (e) => e.target.select() }), h("button", { key: 'f55787708c9e80c3d0bf53b13695773b0c5251fa', class: { 'copy-button': true, 'copy-success': this.copySuccess }, onClick: this.handleCopyUrl, title: this.copySuccess ? 'Copied!' : 'Copy link' }, h("kritzel-icon", { key: 'd50d6d5849d77d2cdcfe4c9eb1ac05e2b14210b0', name: this.copySuccess ? 'check' : 'copy', size: 18 })))))))));
|
|
90
90
|
}
|
|
91
91
|
static get is() { return "kritzel-share-dialog"; }
|
|
92
92
|
static get encapsulation() { return "shadow"; }
|
|
@@ -17,7 +17,7 @@ export class KritzelUtilityPanel {
|
|
|
17
17
|
this.redo.emit();
|
|
18
18
|
}
|
|
19
19
|
render() {
|
|
20
|
-
return (h(Host, { key: '
|
|
20
|
+
return (h(Host, { key: '7f5b5cba79e4e7fa02ab068586cc131530ca31ee' }, h("button", { key: '05369f4b3057f031233a6bda2c8b64108b166252', class: "utility-button", "data-testid": "utility-undo", disabled: !this.undoState?.canUndo, onClick: event => this.handleUndo(event) }, h("kritzel-icon", { key: '0314795c0a657afa7fc34ba0ff64bc4d56889940', name: "undo" })), h("button", { key: 'acecd712262bf4fe599ed043297c0634920f36e3', class: "utility-button", "data-testid": "utility-redo", disabled: !this.undoState?.canRedo, onClick: event => this.handleRedo(event) }, h("kritzel-icon", { key: '4ad50519e1f1f98de86573f2b44b36669de0058e', name: "redo" })), h("div", { key: 'a0feea0ceb0c212a3103b5ef9a7c580c3c73146d', class: "utility-separator" }), h("button", { key: 'b65655ae7000eafdd54a9dc7c5feaf7da794cca7', class: "utility-button", "data-testid": "utility-delete", onClick: () => this.delete.emit() }, h("kritzel-icon", { key: '23d42a377d5c8537b8717fae822a8be07ebcd868', name: "delete" }))));
|
|
21
21
|
}
|
|
22
22
|
static get is() { return "kritzel-utility-panel"; }
|
|
23
23
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as s}from"./p-
|
|
1
|
+
import{K as o,d as s}from"./p-CAyKy1cc.js";const c=o,p=s;export{c as KritzelControls,p as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as o,d as
|
|
1
|
+
import{K as o,d as s}from"./p-D4vHTVYS.js";const p=o,r=s;export{p as KritzelCurrentUser,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-pebXO4LU.js";import{K as r,d as a}from"./p-BGQqz2Ds.js";import{S as c,j as h,f as l,g as d,i as u,h as p,k as m,l as g,m as b}from"./p-DQyoGv35.js";import{A as f,e as k,K as y,a as w,d as v,I as z,f as C}from"./p-DQopSiEQ.js";import{D as A}from"./p-B-fsUXTm.js";import{K as j}from"./p-jGOpkGDl.js";import*as S from"yjs";import"y-websocket";import{d as E}from"./p-jx8VOz7S.js";import{d as x}from"./p-CDadAOMw.js";import{d as T}from"./p-BrJTUc6W.js";import{d as O}from"./p-C3eaM9TB.js";import{d as I}from"./p-HvMuj_xj.js";import{d as U}from"./p-DZa4Mv5W.js";import{d as M}from"./p-DbaQI0Ji.js";import{d as D}from"./p-C128uVgu.js";import{d as W}from"./p-oiAEG5Cp.js";import{d as R}from"./p-35nrk8s0.js";import{d as B}from"./p-Dt-J69xt.js";import{d as P}from"./p-CnVzLD5e.js";import{d as V}from"./p-BUkQ_vI2.js";import{d as F}from"./p-CcBM_ClD.js";import{d as L}from"./p-VAkeZOZL.js";import{d as N}from"./p-DW4ADV9w.js";import{d as J}from"./p-x8PzaMuD.js";import{d as q}from"./p-CFhp1W9F.js";import{d as H}from"./p-DTPKVvYU.js";import{d as G}from"./p-DlSSfD-2.js";import{d as K,a as Q}from"./p-D5YGFk3D.js";import{d as Y}from"./p-BIR94TZo.js";import{d as $}from"./p-CSExtYKI.js";import{d as _}from"./p-Ch0UlFwq.js";import{d as X}from"./p-XzgaXbc0.js";import{d as Z}from"./p-84Lrpqfn.js";import{d as tt}from"./p-B6bAkfr2.js";import{d as et}from"./p-JdNoaqqb.js";import{d as st}from"./p-CZC3OMJO.js";import{d as it}from"./p-DaHq4iG1.js";import{d as nt}from"./p-BFUXWQBc.js";import{d as ot}from"./p-CS5_T65h.js";import{d as rt}from"./p-DHyalXeT.js";import{d as at}from"./p-CqLaHE27.js";import{d as ct}from"./p-B3FMsFu8.js";import{d as ht}from"./p-BLI9Rdlk.js";const lt=Math.floor,dt=127,ut=Number.MAX_SAFE_INTEGER,pt="undefined"!=typeof TextEncoder?new TextEncoder:null,mt=pt?t=>pt.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);const bt=(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},ft=(t,e)=>{for(;e>dt;)bt(t,128|dt&e),e=lt(e/128);bt(t,dt&e)},kt=new Uint8Array(3e4),yt=kt.length/3,wt=pt&&pt.encodeInto?(t,e)=>{if(e.length<yt){const s=pt.encodeInto(e,kt).written||0;ft(t,s);for(let e=0;e<s;e++)bt(t,kt[e])}else vt(t,mt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;ft(t,i);for(let e=0;e<i;e++)bt(t,s.codePointAt(e))},vt=(t,e)=>{ft(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)},zt=t=>Error(t),Ct=zt("Unexpected end of array"),At=zt("Integer out of Range"),jt=t=>t.arr[t.pos++],St=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&dt)*s,s*=128,i<128)return e;if(e>ut)throw At}throw Ct},Et=gt?t=>gt.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,St(t)))(t)):t=>{let e=St(t);if(0===e)return"";{let s=String.fromCodePoint(jt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(jt(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 xt;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(xt||(xt={}));const Tt=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Ot;async function It(t){return new Promise((e=>setTimeout(e,t)))}function Ut(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"}(Ot||(Ot={}));const Mt=Math.floor,Dt=128,Wt=127,Rt=Number.MAX_SAFE_INTEGER,Bt=()=>new Set,Pt=Array.from,Vt="undefined"!=typeof TextEncoder?new TextEncoder:null,Ft=Vt?t=>Vt.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 Lt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Lt&&1===Lt.decode(new Uint8Array).length&&(Lt=null);class Nt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Jt=()=>new Nt,qt=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(qt(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},Gt=(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},Kt=(t,e)=>{for(;e>Wt;)Gt(t,Dt|Wt&e),e=Mt(e/128);Gt(t,Wt&e)},Qt=new Uint8Array(3e4),Yt=Qt.length/3,$t=Vt&&Vt.encodeInto?(t,e)=>{if(e.length<Yt){const s=Vt.encodeInto(e,Qt).written||0;Kt(t,s);for(let e=0;e<s;e++)Gt(t,Qt[e])}else _t(t,Ft(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;Kt(t,i);for(let e=0;e<i;e++)Gt(t,s.codePointAt(e))},_t=(t,e)=>{Kt(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)},Xt=t=>Error(t),Zt=Xt("Unexpected end of array"),te=Xt("Integer out of Range");class ee{constructor(t){this.arr=t,this.pos=0}}const se=t=>new ee(t),ie=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,oe(t)),ne=t=>t.arr[t.pos++],oe=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Wt)*s,s*=128,i<Dt)return e;if(e>Rt)throw te}throw Zt},re=Lt?t=>Lt.decode(ie(t)):t=>{let e=oe(t);if(0===e)return"";{let s=String.fromCodePoint(ne(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(ne(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))}},ae=Date.now,ce=()=>new Map;class he{constructor(){this._observers=ce()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Bt).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 Pt((this._observers.get(t)||ce()).values()).forEach((t=>t(...e)))}destroy(){this._observers=ce()}}const le=Object.keys,de=t=>le(t).length,ue=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),pe=(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)||!pe(t.get(s),e.get(s)))return!1;break;case Object:if(de(t)!==de(e))return!1;for(const s in t)if(!ue(t,s)||!pe(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(!pe(t[s],e[s]))return!1;break;default:return!1}return!0};class me extends he{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=ae();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&&ge(this,e,"timeout")}),Mt(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:ae()});const o=[],r=[],a=[],c=[];null===t?c.push(e):null==n?null!=t&&o.push(e):(r.push(e),pe(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 ge=(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:ae()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},be=(t,e,s=t.states)=>{const i=e.length,n=Jt();Kt(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;Kt(n,i),Kt(n,a),$t(n,JSON.stringify(r))}return Ht(n)};class fe{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 ke{constructor(t){this.data=t,this.encoder=Jt(),this.decoder=se(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=re(t);return t.pos=e,s})(this.decoder)}readVarUint(){return oe(this.decoder)}readVarString(){return re(this.decoder)}readVarUint8Array(){return ie(this.decoder)}writeVarUint(t){return Kt(this.encoder,t)}writeVarString(t){return $t(this.encoder,t)}writeVarUint8Array(t){return _t(this.encoder,t)}length(){return qt(this.encoder)}}var ye,we;!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"}(ye||(ye={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(we||(we={}));class ve{constructor(){this.encoder=Jt()}get(t){return t.encoder}toUint8Array(){return Ht(this.encoder)}}class ze extends ve{constructor(){super(...arguments),this.type=ye.CLOSE,this.description="Ask the server to close the connection"}get(t){return $t(this.encoder,t.documentName),Kt(this.encoder,this.type),this.encoder}}class Ce extends fe{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=we.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=we.Connected,this.emit("status",{status:we.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===we.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===we.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(ze,{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===we.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||Ut,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await It(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await It(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 It(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=we.Connecting,this.emit("status",{status:we.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=ae();const s=new ke(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=we.Connected,this.emit("status",{status:we.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===we.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ae()-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)===Ot.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=we.Disconnected,this.emit("status",{status:we.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 Ae=(t,e,s)=>{try{S.applyUpdate(e,ie(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},je=Ae;class Se{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case ye.Sync:this.applySyncMessage(t,e);break;case ye.Awareness:this.applyAwarenessMessage(t);break;case ye.Auth:this.applyAuthMessage(t);break;case ye.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ye.Stateless:t.receiveStateless(re(s.decoder));break;case ye.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&Dt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Wt)*i,i*=128,e<Dt)return n*s;if(s>Rt)throw te}throw Zt})(s.decoder));break;case ye.CLOSE:const n={code:1e3,reason:re(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(ve,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(ye.Sync);const i=((t,e,s,i)=>{const n=oe(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{Kt(t,1),_t(t,S.encodeStateAsUpdate(e,s))})(e,s,ie(t))})(t,e,s);break;case 1:Ae(t,s,i);break;case 2:je(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=se(e),n=ae(),o=[],r=[],a=[],c=[],h=oe(i);for(let e=0;e<h;e++){const e=oe(i);let s=oe(i);const h=JSON.parse(re(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&&(pe(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(St(t)){case xt.Token:e();break;case xt.PermissionDenied:s(Et(t));break;case xt.Authenticated:i(Et(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(ye.Awareness),e.writeVarUint8Array(be(t.awareness,Array.from(t.awareness.getStates().keys())))}}class Ee{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 xe extends ve{constructor(){super(...arguments),this.type=ye.Auth,this.description="Authentication"}get(t){if(void 0===t.token)throw Error("The authentication message requires `token` as an argument.");return $t(this.encoder,t.documentName),Kt(this.encoder,this.type),((t,e)=>{ft(t,xt.Token),wt(t,e)})(this.encoder,t.token),this.encoder}}class Te extends ve{constructor(){super(...arguments),this.type=ye.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 $t(this.encoder,t.documentName),Kt(this.encoder,this.type),e=void 0===t.states?be(t.awareness,t.clients):be(t.awareness,t.clients,t.states),_t(this.encoder,e),this.encoder}}class Oe extends ve{constructor(){super(...arguments),this.type=ye.Stateless,this.description="A stateless message"}get(t){var e;return $t(this.encoder,t.documentName),Kt(this.encoder,this.type),$t(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class Ie extends ve{constructor(){super(...arguments),this.type=ye.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 $t(this.encoder,t.documentName),Kt(this.encoder,this.type),((t,e)=>{Kt(t,0);const s=S.encodeStateVector(e);_t(t,s)})(this.encoder,t.document),this.encoder}}class Ue extends ve{constructor(){super(...arguments),this.type=ye.Sync,this.description="A document update"}get(t){return $t(this.encoder,t.documentName),Kt(this.encoder,this.type),((t,e)=>{Kt(t,2),_t(t,e)})(this.encoder,t.update),this.encoder}}class Me extends Error{constructor(){super(...arguments),this.code=1001}}class De extends fe{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 S.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new me(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:Tt(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Tt(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 Ce(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(Ie,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&ge(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Oe,{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(xe,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(Ue,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Te,{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(Ie,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Te,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new Ee(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new ke(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new ke(t.data)}),new Se(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ge(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&&(ge(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 Me(`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 We={type:"pen",color:A[0],size:16,palettes:{pen:[...A]}},Re={color:A[0],size:8,fontFamily:"Arial",palette:[...A]},Be={color:A[0],size:4,palette:[...A],arrows:{end:{enabled:!0,style:"triangle"}}},Pe={shapeType:c.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:A[0],strokeWidth:4,fontColor:A[0],fontSize:16,fontFamily:"Arial",palette:[...A]},Ve=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=f;scaleMin=k;lockDrawingScale=!0;viewportBoundaryLeft=-1/0;viewportBoundaryRight=1/0;viewportBoundaryTop=-1/0;viewportBoundaryBottom=1/0;wheelEnabled=!0;user;activeUsers;controls=[{name:"selection",type:"tool",isDefault:!0,tool:h,icon:"cursor"},{name:"brush",type:"tool",tool:l,icon:"pen",config:We},{name:"eraser",type:"tool",tool:y,icon:"eraser"},{name:"line",type:"tool",tool:d,icon:"arrow",config:Be},{name:"shape",type:"tool",tool:u,icon:"shape-rectangle",config:Pe,subOptions:[{id:"rectangle",icon:"shape-rectangle",label:"Rectangle",value:c.Rectangle,toolProperty:"shapeType"},{id:"ellipse",icon:"shape-ellipse",label:"Ellipse",value:c.Ellipse,toolProperty:"shapeType"},{id:"triangle",icon:"shape-triangle",label:"Triangle",value:c.Triangle,toolProperty:"shapeType"}]},{name:"text",type:"tool",tool:p,icon:"type",config:Re},{name:"image",type:"tool",tool:w,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:"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(v.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(v.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(v.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(v.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(v.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(v.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;syncConfig={providers:[z]};loginConfig;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){if(this.activeWorkspace){const e=t.find((t=>t.id===this.activeWorkspace.id));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}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 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)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,loginConfig:this.loginConfig})}async onEngineReady(t){this.isEngineReady=!0,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.themeChange.emit(t.detail.theme)}async handleMoreMenuItemSelect(t){const{item:e}=t.detail;if("share"===e.id&&this.shareDialogRef.open(),"settings"===e.id&&this.settingsRef.open(),"export"===e.id){const t=await this.engineRef.getScreenshot("png");this.exportRef.open(t)}"download"===e.id&&await this.engineRef.downloadAsJson(),"import"===e.id&&await this.engineRef.importFromFile()}handleToggleIsPublic=async t=>{const e=t.detail,s=await this.engineRef.getActiveWorkspace();s.isPublic=e,await this.engineRef.updateWorkspace(s),this.isPublicChange.emit({isPublic:e,workspaceId:this.activeWorkspace?.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,this.isPublicChange.emit({isPublic:t,workspaceId:e})}handleCurrentUserItemSelect(t){const{item:e}=t.detail;"logout"===e.id&&this.logout.emit()}handleProviderLogin=t=>{this.login.emit(t.detail)};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)}catch{}}async loadShortcuts(){this.shortcuts=await this.engineRef.getDisplayableShortcuts()}getContentObjects(t){return t.filter((t=>!(t instanceof m||t instanceof g)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){b.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(j.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(){return i(n,{key:"7b7fdb3c439c1240b85091471654162093e7cfbe"},i("div",{key:"7df215c2eba182f1bc062724d098563fb9418f87",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"bca670f4992460038ab0dd7fabd564300283680b",workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"cc0241ccaa912ef6c3aa8f714410293e993380dd",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"0374d9cd583336ebc21057b94bed77932e2cba1b",ref:t=>this.engineRef=t,workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,scaleMin:this.scaleMin,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.currentTheme,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:"d1e4b9b373019694347226de60b656f7105fb2a4",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>this.controlsRef=t,controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState,theme:this.currentTheme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"1bb1bbdb24da5e469bbf3fdfa9244b5320403227",class:"top-right-buttons"},i("kritzel-settings",{key:"cb4eeb7d2fd93a010995799d09ecd03b1e17f808",ref:t=>this.settingsRef=t,shortcuts:this.shortcuts,editorId:this.editorId,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"70a02663f888cdb739eedb736c6435a3348d8382",ref: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:"da22e92fbc1147c5ac891eb1df09f0f0274e8ba6",users:this.activeUsers}),i("kritzel-current-user",{key:"8f488ea8f35933882173acebcc41e6b9894adce3",user:this.user,onItemSelect:t=>this.handleCurrentUserItemSelect(t)}),this.loginConfig&&!this.user&&i("kritzel-button",{key:"6ed067813d0c76eaf5773a288be1d5530ec78c90",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"6793b6af8717b577b312808d7c6fb516ca03ea61",onItemSelect:t=>this.handleMoreMenuItemSelect(t)}),i("kritzel-share-dialog",{key:"2290fbc44d03326a1064c9869ecf1770a9a532a8",ref:t=>this.shareDialogRef=t,isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"204d21e99f5c2d7088c08fbb0e978d1ab8ab0ad8",ref: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-workspace-manager{}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}.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}.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"],user:[16],activeUsers:[16],controls:[16],globalContextMenuItems:[16],objectContextMenuItems:[16],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],syncConfig:[16],loginConfig:[16],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],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}]}]),Fe=Ve,Le=function(){"undefined"!=typeof customElements&&["kritzel-editor","kritzel-active-users","kritzel-avatar","kritzel-back-to-content","kritzel-button","kritzel-color","kritzel-color-palette","kritzel-context-menu","kritzel-controls","kritzel-current-user","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),Ve);break;case"kritzel-active-users":customElements.get(o(t))||E();break;case"kritzel-avatar":customElements.get(o(t))||x();break;case"kritzel-back-to-content":customElements.get(o(t))||T();break;case"kritzel-button":customElements.get(o(t))||O();break;case"kritzel-color":customElements.get(o(t))||I();break;case"kritzel-color-palette":customElements.get(o(t))||U();break;case"kritzel-context-menu":customElements.get(o(t))||M();break;case"kritzel-controls":customElements.get(o(t))||D();break;case"kritzel-current-user":customElements.get(o(t))||W();break;case"kritzel-cursor-trail":customElements.get(o(t))||R();break;case"kritzel-dialog":customElements.get(o(t))||B();break;case"kritzel-dropdown":customElements.get(o(t))||P();break;case"kritzel-engine":customElements.get(o(t))||C();break;case"kritzel-export":customElements.get(o(t))||V();break;case"kritzel-font":customElements.get(o(t))||F();break;case"kritzel-font-family":customElements.get(o(t))||L();break;case"kritzel-font-size":customElements.get(o(t))||N();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||J();break;case"kritzel-line-endings":customElements.get(o(t))||q();break;case"kritzel-login-dialog":customElements.get(o(t))||H();break;case"kritzel-master-detail":customElements.get(o(t))||G();break;case"kritzel-menu":customElements.get(o(t))||Q();break;case"kritzel-menu-item":customElements.get(o(t))||K();break;case"kritzel-more-menu":customElements.get(o(t))||Y();break;case"kritzel-numeric-input":customElements.get(o(t))||$();break;case"kritzel-opacity-slider":customElements.get(o(t))||_();break;case"kritzel-pill-tabs":customElements.get(o(t))||X();break;case"kritzel-portal":customElements.get(o(t))||Z();break;case"kritzel-settings":customElements.get(o(t))||tt();break;case"kritzel-shape-fill":customElements.get(o(t))||et();break;case"kritzel-share-dialog":customElements.get(o(t))||st();break;case"kritzel-slide-toggle":customElements.get(o(t))||it();break;case"kritzel-split-button":customElements.get(o(t))||nt();break;case"kritzel-stroke-size":customElements.get(o(t))||ot();break;case"kritzel-tool-config":customElements.get(o(t))||rt();break;case"kritzel-tooltip":customElements.get(o(t))||at();break;case"kritzel-utility-panel":customElements.get(o(t))||ct();break;case"kritzel-workspace-manager":customElements.get(o(t))||ht()}}))};export{We as D,De as H,Fe as KritzelEditor,Ce as a,Re as b,Be as c,Le as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,c as s,h as i,d as n,t as o}from"./p-pebXO4LU.js";import{K as r,d as a}from"./p-BGQqz2Ds.js";import{S as h,j as c,f as l,g as d,i as u,h as p,k as m,l as g,m as b}from"./p-DQyoGv35.js";import{A as f,e as y,K as k,a as w,d as v,I as z,f as C}from"./p-DQopSiEQ.js";import{D as A}from"./p-B-fsUXTm.js";import{K as j}from"./p-jGOpkGDl.js";import*as S from"yjs";import"y-websocket";import{d as E}from"./p-jx8VOz7S.js";import{d as x}from"./p-CDadAOMw.js";import{d as T}from"./p-BrJTUc6W.js";import{d as O}from"./p-C3eaM9TB.js";import{d as I}from"./p-HvMuj_xj.js";import{d as U}from"./p-DZa4Mv5W.js";import{d as D}from"./p-DbaQI0Ji.js";import{d as M}from"./p-CAyKy1cc.js";import{d as W}from"./p-D4vHTVYS.js";import{d as R}from"./p-35nrk8s0.js";import{d as B}from"./p-Dt-J69xt.js";import{d as P}from"./p-CnVzLD5e.js";import{d as V}from"./p-DixJT29r.js";import{d as F}from"./p-CcBM_ClD.js";import{d as L}from"./p-VAkeZOZL.js";import{d as N}from"./p-DW4ADV9w.js";import{d as H}from"./p-x8PzaMuD.js";import{d as J}from"./p-CFhp1W9F.js";import{d as q}from"./p-D10gvYUs.js";import{d as K}from"./p-DlSSfD-2.js";import{d as G,a as Y}from"./p-D5YGFk3D.js";import{d as Q}from"./p-BigXf4HY.js";import{d as X}from"./p-CSExtYKI.js";import{d as $}from"./p-Ch0UlFwq.js";import{d as _}from"./p-XzgaXbc0.js";import{d as Z}from"./p-84Lrpqfn.js";import{d as tt}from"./p-C3oZEcbe.js";import{d as et}from"./p-JdNoaqqb.js";import{d as st}from"./p-KXf95dmS.js";import{d as it}from"./p-DaHq4iG1.js";import{d as nt}from"./p-BFUXWQBc.js";import{d as ot}from"./p-CS5_T65h.js";import{d as rt}from"./p-DHyalXeT.js";import{d as at}from"./p-CqLaHE27.js";import{d as ht}from"./p-CKy-O_xW.js";import{d as ct}from"./p-BLI9Rdlk.js";const lt=Math.floor,dt=127,ut=Number.MAX_SAFE_INTEGER,pt="undefined"!=typeof TextEncoder?new TextEncoder:null,mt=pt?t=>pt.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);const bt=(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},ft=(t,e)=>{for(;e>dt;)bt(t,128|dt&e),e=lt(e/128);bt(t,dt&e)},yt=new Uint8Array(3e4),kt=yt.length/3,wt=pt&&pt.encodeInto?(t,e)=>{if(e.length<kt){const s=pt.encodeInto(e,yt).written||0;ft(t,s);for(let e=0;e<s;e++)bt(t,yt[e])}else vt(t,mt(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;ft(t,i);for(let e=0;e<i;e++)bt(t,s.codePointAt(e))},vt=(t,e)=>{ft(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)},zt=t=>Error(t),Ct=zt("Unexpected end of array"),At=zt("Integer out of Range"),jt=t=>t.arr[t.pos++],St=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&dt)*s,s*=128,i<128)return e;if(e>ut)throw At}throw Ct},Et=gt?t=>gt.decode((t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,St(t)))(t)):t=>{let e=St(t);if(0===e)return"";{let s=String.fromCodePoint(jt(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(jt(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 xt;!function(t){t[t.Token=0]="Token",t[t.PermissionDenied=1]="PermissionDenied",t[t.Authenticated=2]="Authenticated"}(xt||(xt={}));const Tt=t=>Array.from(t.entries()).map((([t,e])=>({clientId:t,...e})));var Ot;async function It(t){return new Promise((e=>setTimeout(e,t)))}function Ut(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"}(Ot||(Ot={}));const Dt=Math.floor,Mt=128,Wt=127,Rt=Number.MAX_SAFE_INTEGER,Bt=()=>new Set,Pt=Array.from,Vt="undefined"!=typeof TextEncoder?new TextEncoder:null,Ft=Vt?t=>Vt.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 Lt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Lt&&1===Lt.decode(new Uint8Array).length&&(Lt=null);class Nt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Ht=()=>new Nt,Jt=t=>{let e=t.cpos;for(let s=0;s<t.bufs.length;s++)e+=t.bufs[s].length;return e},qt=t=>{const e=new Uint8Array(Jt(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},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},Gt=(t,e)=>{for(;e>Wt;)Kt(t,Mt|Wt&e),e=Dt(e/128);Kt(t,Wt&e)},Yt=new Uint8Array(3e4),Qt=Yt.length/3,Xt=Vt&&Vt.encodeInto?(t,e)=>{if(e.length<Qt){const s=Vt.encodeInto(e,Yt).written||0;Gt(t,s);for(let e=0;e<s;e++)Kt(t,Yt[e])}else $t(t,Ft(e))}:(t,e)=>{const s=unescape(encodeURIComponent(e)),i=s.length;Gt(t,i);for(let e=0;e<i;e++)Kt(t,s.codePointAt(e))},$t=(t,e)=>{Gt(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)},_t=t=>Error(t),Zt=_t("Unexpected end of array"),te=_t("Integer out of Range");class ee{constructor(t){this.arr=t,this.pos=0}}const se=t=>new ee(t),ie=t=>((t,e)=>{const s=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,s})(t,oe(t)),ne=t=>t.arr[t.pos++],oe=t=>{let e=0,s=1;const i=t.arr.length;for(;t.pos<i;){const i=t.arr[t.pos++];if(e+=(i&Wt)*s,s*=128,i<Mt)return e;if(e>Rt)throw te}throw Zt},re=Lt?t=>Lt.decode(ie(t)):t=>{let e=oe(t);if(0===e)return"";{let s=String.fromCodePoint(ne(t));if(--e<100)for(;e--;)s+=String.fromCodePoint(ne(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))}},ae=Date.now,he=()=>new Map;class ce{constructor(){this._observers=he()}on(t,e){((t,e,s)=>{let i=t.get(e);return void 0===i&&t.set(e,i=s()),i})(this._observers,t,Bt).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 Pt((this._observers.get(t)||he()).values()).forEach((t=>t(...e)))}destroy(){this._observers=he()}}const le=Object.keys,de=t=>le(t).length,ue=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),pe=(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)||!pe(t.get(s),e.get(s)))return!1;break;case Object:if(de(t)!==de(e))return!1;for(const s in t)if(!ue(t,s)||!pe(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(!pe(t[s],e[s]))return!1;break;default:return!1}return!0};class me extends ce{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const t=ae();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&&ge(this,e,"timeout")}),Dt(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:ae()});const o=[],r=[],a=[],h=[];null===t?h.push(e):null==n?null!=t&&o.push(e):(r.push(e),pe(n,t)||a.push(e)),(o.length>0||a.length>0||h.length>0)&&this.emit("change",[{added:o,updated:a,removed:h},"local"]),this.emit("update",[{added:o,updated:r,removed:h},"local"])}setLocalStateField(t,e){const s=this.getLocalState();null!==s&&this.setLocalState({...s,[t]:e})}getStates(){return this.states}}const ge=(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:ae()})}i.push(n)}}i.length>0&&(t.emit("change",[{added:[],updated:[],removed:i},s]),t.emit("update",[{added:[],updated:[],removed:i},s]))},be=(t,e,s=t.states)=>{const i=e.length,n=Ht();Gt(n,i);for(let o=0;o<i;o++){const i=e[o],r=s.get(i)||null,a=t.meta.get(i).clock;Gt(n,i),Gt(n,a),Xt(n,JSON.stringify(r))}return qt(n)};class fe{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 ye{constructor(t){this.data=t,this.encoder=Ht(),this.decoder=se(new Uint8Array(this.data))}peekVarString(){return(t=>{const e=t.pos,s=re(t);return t.pos=e,s})(this.decoder)}readVarUint(){return oe(this.decoder)}readVarString(){return re(this.decoder)}readVarUint8Array(){return ie(this.decoder)}writeVarUint(t){return Gt(this.encoder,t)}writeVarString(t){return Xt(this.encoder,t)}writeVarUint8Array(t){return $t(this.encoder,t)}length(){return Jt(this.encoder)}}var ke,we;!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"}(ke||(ke={})),function(t){t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected"}(we||(we={}));class ve{constructor(){this.encoder=Ht()}get(t){return t.encoder}toUint8Array(){return qt(this.encoder)}}class ze extends ve{constructor(){super(...arguments),this.type=ke.CLOSE,this.description="Ask the server to close the connection"}get(t){return Xt(this.encoder,t.documentName),Gt(this.encoder,this.type),this.encoder}}class Ce extends fe{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=we.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=we.Connected,this.emit("status",{status:we.Connected}),this.cancelWebsocketRetry=void 0,this.receivedOnOpenPayload=t}attach(t){this.configuration.providerMap.set(t.configuration.name,t),this.status===we.Disconnected&&this.shouldConnect&&this.connect(),this.receivedOnOpenPayload&&this.status===we.Connected&&t.onOpen(this.receivedOnOpenPayload)}detach(t){this.configuration.providerMap.has(t.configuration.name)&&(t.send(ze,{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===we.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||Ut,o=s.calculateDelay?s.calculateDelay(i,s):s.initialDelay;if(o&&await It(o),i.attemptNum<1&&s.initialJitter){const t=n(i,s);t&&await It(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 It(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=we.Connecting,this.emit("status",{status:we.Connecting}),this.connectionAttempt={resolve:t,reject:e}}))}onMessage(t){var e;this.resolveConnectionAttempt(),this.lastMessageReceived=ae();const s=new ye(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=we.Connected,this.emit("status",{status:we.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===we.Connected&&this.lastMessageReceived&&(this.configuration.messageReconnectTimeout>=ae()-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)===Ot.Open?this.webSocket.send(t):this.messageQueue.push(t)}onClose({event:t}){this.closeTries=0,this.cleanupWebSocket(),this.connectionAttempt&&this.rejectConnectionAttempt(),this.status=we.Disconnected,this.emit("status",{status:we.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 Ae=(t,e,s)=>{try{S.applyUpdate(e,ie(t),s)}catch(t){console.error("Caught error while handling a Yjs update",t)}},je=Ae;class Se{constructor(t){this.message=t}apply(t,e){const{message:s}=this,i=s.readVarUint(),n=s.length();switch(i){case ke.Sync:this.applySyncMessage(t,e);break;case ke.Awareness:this.applyAwarenessMessage(t);break;case ke.Auth:this.applyAuthMessage(t);break;case ke.QueryAwareness:this.applyQueryAwarenessMessage(t);break;case ke.Stateless:t.receiveStateless(re(s.decoder));break;case ke.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&Mt))return n*s;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],s+=(e&Wt)*i,i*=128,e<Mt)return n*s;if(s>Rt)throw te}throw Zt})(s.decoder));break;case ke.CLOSE:const n={code:1e3,reason:re(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(ve,{encoder:s.encoder})}applySyncMessage(t,e){const{message:s}=this;s.writeVarUint(ke.Sync);const i=((t,e,s,i)=>{const n=oe(t);switch(n){case 0:((t,e,s)=>{((t,e,s)=>{Gt(t,1),$t(t,S.encodeStateAsUpdate(e,s))})(e,s,ie(t))})(t,e,s);break;case 1:Ae(t,s,i);break;case 2:je(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=se(e),n=ae(),o=[],r=[],a=[],h=[],c=oe(i);for(let e=0;e<c;e++){const e=oe(i);let s=oe(i);const c=JSON.parse(re(i)),l=t.meta.get(e),d=t.states.get(e),u=void 0===l?0:l.clock;(u<s||u===s&&null===c&&t.states.has(e))&&(null===c?e===t.clientID&&null!=t.getLocalState()?s++:t.states.delete(e):t.states.set(e,c),t.meta.set(e,{clock:s,lastUpdated:n}),void 0===l&&null!==c?o.push(e):void 0!==l&&null===c?h.push(e):null!==c&&(pe(c,d)||a.push(e),r.push(e)))}(o.length>0||a.length>0||h.length>0)&&t.emit("change",[{added:o,updated:a,removed:h},s]),(o.length>0||r.length>0||h.length>0)&&t.emit("update",[{added:o,updated:r,removed:h},s])})(t.awareness,e.readVarUint8Array(),t)}applyAuthMessage(t){const{message:e}=this;((t,e,s,i)=>{switch(St(t)){case xt.Token:e();break;case xt.PermissionDenied:s(Et(t));break;case xt.Authenticated:i(Et(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(ke.Awareness),e.writeVarUint8Array(be(t.awareness,Array.from(t.awareness.getStates().keys())))}}class Ee{constructor(t,e={}){this.message=new t,this.encoder=this.message.get(e)}create(){return qt(this.encoder)}send(t){null==t||t.send(this.create())}}class xe extends ve{constructor(){super(...arguments),this.type=ke.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),Gt(this.encoder,this.type),((t,e)=>{ft(t,xt.Token),wt(t,e)})(this.encoder,t.token),this.encoder}}class Te extends ve{constructor(){super(...arguments),this.type=ke.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),Gt(this.encoder,this.type),e=void 0===t.states?be(t.awareness,t.clients):be(t.awareness,t.clients,t.states),$t(this.encoder,e),this.encoder}}class Oe extends ve{constructor(){super(...arguments),this.type=ke.Stateless,this.description="A stateless message"}get(t){var e;return Xt(this.encoder,t.documentName),Gt(this.encoder,this.type),Xt(this.encoder,null!==(e=t.payload)&&void 0!==e?e:""),this.encoder}}class Ie extends ve{constructor(){super(...arguments),this.type=ke.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),Gt(this.encoder,this.type),((t,e)=>{Gt(t,0);const s=S.encodeStateVector(e);$t(t,s)})(this.encoder,t.document),this.encoder}}class Ue extends ve{constructor(){super(...arguments),this.type=ke.Sync,this.description="A document update"}get(t){return Xt(this.encoder,t.documentName),Gt(this.encoder,this.type),((t,e)=>{Gt(t,2),$t(t,e)})(this.encoder,t.update),this.encoder}}class De extends Error{constructor(){super(...arguments),this.code=1001}}class Me extends fe{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 S.Doc,this.configuration.awareness=void 0!==t.awareness?t.awareness:new me(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:Tt(this.awareness.getStates())})})),null===(s=this.awareness)||void 0===s||s.on("change",(()=>{this.emit("awarenessChange",{states:Tt(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 Ce(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(Ie,{document:this.document,documentName:this.configuration.name})}pageHide(){this.awareness&&ge(this.awareness,[this.document.clientID],"page hide")}registerEventListeners(){"undefined"!=typeof window&&"addEventListener"in window&&window.addEventListener("pagehide",this.boundPageHide)}sendStateless(t){this.send(Oe,{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(xe,{token:null!=t?t:"",documentName:this.configuration.name})}documentUpdateHandler(t,e){e!==this&&(this.incrementUnsyncedChanges(),this.send(Ue,{update:t,documentName:this.configuration.name}))}awarenessUpdateHandler({added:t,updated:e,removed:s},i){const n=t.concat(e).concat(s);this.send(Te,{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(Ie,{document:this.document,documentName:this.configuration.name}),this.awareness&&null!==this.awareness.getLocalState()&&this.send(Te,{awareness:this.awareness,clients:[this.document.clientID],documentName:this.configuration.name})}send(t,e){if(!this._isAttached)return;const s=new Ee(t,e);this.emit("outgoingMessage",{message:s.message}),s.send(this.configuration.websocketProvider)}onMessage(t){const e=new ye(t.data),s=e.readVarString();e.writeVarString(s),this.emit("message",{event:t,message:new ye(t.data)}),new Se(e).apply(this,!0)}onClose(){this.isAuthenticated=!1,this.synced=!1,this.awareness&&ge(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&&(ge(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 De(`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 We={type:"pen",color:A[0],size:16,palettes:{pen:[...A]}},Re={color:A[0],size:8,fontFamily:"Arial",palette:[...A]},Be={color:A[0],size:4,palette:[...A],arrows:{end:{enabled:!0,style:"triangle"}}},Pe={shapeType:h.Rectangle,fillColor:{light:"transparent",dark:"transparent"},strokeColor:A[0],strokeWidth:4,fontColor:A[0],fontSize:16,fontFamily:"Arial",palette:[...A]},Ve=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=f;scaleMin=y;lockDrawingScale=!0;viewportBoundaryLeft=-1/0;viewportBoundaryRight=1/0;viewportBoundaryTop=-1/0;viewportBoundaryBottom=1/0;wheelEnabled=!0;user;activeUsers;controls=[{name:"selection",type:"tool",isDefault:!0,tool:c,icon:"cursor"},{name:"brush",type:"tool",tool:l,icon:"pen",config:We},{name:"eraser",type:"tool",tool:k,icon:"eraser"},{name:"line",type:"tool",tool:d,icon:"arrow",config:Be},{name:"shape",type:"tool",tool:u,icon:"shape-rectangle",config:Pe,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:p,icon:"type",config:Re},{name:"image",type:"tool",tool:w,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:"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(v.StartHorizontal)},{label:"Align Center Horizontally",icon:"align-center-horizontal",action:()=>this.engineRef.alignObjects(v.CenterHorizontal)},{label:"Align Right",icon:"align-end-vertical",action:()=>this.engineRef.alignObjects(v.EndHorizontal)},{label:"Align Top",icon:"align-start-horizontal",action:()=>this.engineRef.alignObjects(v.StartVertical)},{label:"Align Center Vertically",icon:"align-center-vertical",action:()=>this.engineRef.alignObjects(v.CenterVertical)},{label:"Align Bottom",icon:"align-end-horizontal",action:()=>this.engineRef.alignObjects(v.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;syncConfig={providers:[z]};loginConfig;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){if(this.activeWorkspace){const e=t.find((t=>t.id===this.activeWorkspace.id));e&&e!==this.activeWorkspace&&(this.activeWorkspace=e)}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 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)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,loginConfig:this.loginConfig})}async onEngineReady(t){this.isEngineReady=!0,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.themeChange.emit(t.detail.theme)}async handleMoreMenuItemSelect(t){const{item:e}=t.detail;if("share"===e.id&&this.shareDialogRef.open(),"settings"===e.id&&this.settingsRef.open(),"export"===e.id){const t=await this.engineRef.getScreenshot("png");this.exportRef.open(t)}"download"===e.id&&await this.engineRef.downloadAsJson(),"import"===e.id&&await this.engineRef.importFromFile()}handleToggleIsPublic=async t=>{const e=t.detail,s=await this.engineRef.getActiveWorkspace();s.isPublic=e,await this.engineRef.updateWorkspace(s),this.isPublicChange.emit({isPublic:e,workspaceId:this.activeWorkspace?.id})};updateCurrentIsPublic(){const t=this.activeWorkspace?.isPublic??!1,e=this.activeWorkspace?.id;this.currentIsPublic=t,this.isPublicChange.emit({isPublic:t,workspaceId:e})}handleCurrentUserItemSelect(t){const{item:e}=t.detail;"logout"===e.id&&this.logout.emit()}handleProviderLogin=t=>{this.login.emit(t.detail)};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)}catch{}}async loadShortcuts(){this.shortcuts=await this.engineRef.getDisplayableShortcuts()}getContentObjects(t){return t.filter((t=>!(t instanceof m||t instanceof g)))}registerCustomSvgIcons(){for(const[t,e]of Object.entries(this.customSvgIcons))r.register(t,e)}listenForMobileKeyboard(){b.onKeyboardVisibleChanged((t=>{this.isVirtualKeyboardOpen=t}))}setOsSpecificCssVariables(){switch(j.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(){return i(n,{key:"7b7fdb3c439c1240b85091471654162093e7cfbe"},i("div",{key:"7df215c2eba182f1bc062724d098563fb9418f87",class:"top-left-buttons"},i("kritzel-workspace-manager",{key:"bca670f4992460038ab0dd7fabd564300283680b",workspaces:this.workspaces,activeWorkspace:this.activeWorkspace,onWorkspaceChange:t=>this.activeWorkspace=t.detail,onIsWorkspaceManagerReady:()=>this.isWorkspaceManagerReady=!0}),i("kritzel-back-to-content",{key:"cc0241ccaa912ef6c3aa8f714410293e993380dd",visible:this.isBackToContentButtonVisible,onBackToContent:()=>this.backToContent()})),i("kritzel-engine",{key:"0374d9cd583336ebc21057b94bed77932e2cba1b",ref:t=>this.engineRef=t,workspace:this.activeWorkspace,activeWorkspaceId:this.activeWorkspaceId,editorId:this.editorId,syncConfig:this.syncConfig,user:this.user,scaleMax:this.scaleMax,lockDrawingScale:this.lockDrawingScale,scaleMin:this.scaleMin,viewportBoundaryLeft:this.viewportBoundaryLeft,viewportBoundaryRight:this.viewportBoundaryRight,viewportBoundaryTop:this.viewportBoundaryTop,viewportBoundaryBottom:this.viewportBoundaryBottom,wheelEnabled:this.wheelEnabled,theme:this.currentTheme,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:"d1e4b9b373019694347226de60b656f7105fb2a4",class:{"keyboard-open":this.isVirtualKeyboardOpen},style:{display:this.isControlsVisible?"flex":"none"},ref:t=>this.controlsRef=t,controls:this.controls,isUtilityPanelVisible:this.isUtilityPanelVisible,undoState:this.undoState,theme:this.currentTheme,onIsControlsReady:()=>this.isControlsReady=!0}),i("div",{key:"1bb1bbdb24da5e469bbf3fdfa9244b5320403227",class:"top-right-buttons"},i("kritzel-settings",{key:"cb4eeb7d2fd93a010995799d09ecd03b1e17f808",ref:t=>this.settingsRef=t,shortcuts:this.shortcuts,editorId:this.editorId,onSettingsChange:t=>this.handleSettingsChange(t)}),i("kritzel-export",{key:"70a02663f888cdb739eedb736c6435a3348d8382",ref: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:"da22e92fbc1147c5ac891eb1df09f0f0274e8ba6",users:this.activeUsers}),this.loginConfig&&this.user&&!this.user.isGuest&&i("kritzel-current-user",{key:"eb35978536b353f57e3902168bc39afcd2634404",user:this.user,onItemSelect:t=>this.handleCurrentUserItemSelect(t)}),this.loginConfig&&(!this.user||this.user.isGuest)&&i("kritzel-button",{key:"83556b3580f320292c720d3bffb3be9dde1432aa",onButtonClick:()=>this.loginDialogRef?.open()},"Sign in"),i("kritzel-more-menu",{key:"a838c25f4b19e76f81afa2fd30414648073ceb3b",onItemSelect:t=>this.handleMoreMenuItemSelect(t)}),i("kritzel-share-dialog",{key:"a14a049714e150062b1fac0cca3d70043a6ab8bf",ref:t=>this.shareDialogRef=t,isPublic:this.currentIsPublic,workspaceId:this.activeWorkspace?.id,onToggleIsPublic:this.handleToggleIsPublic}),this.loginConfig&&i("kritzel-login-dialog",{key:"36411a379aa2d9a239a4d8fff6efc6037dfea068",ref: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-workspace-manager{}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}.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}.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"],user:[16],activeUsers:[16],controls:[16],globalContextMenuItems:[16],objectContextMenuItems:[16],customSvgIcons:[16],isControlsVisible:[4,"is-controls-visible"],isUtilityPanelVisible:[4,"is-utility-panel-visible"],syncConfig:[16],loginConfig:[16],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],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}]}]),Fe=Ve,Le=function(){"undefined"!=typeof customElements&&["kritzel-editor","kritzel-active-users","kritzel-avatar","kritzel-back-to-content","kritzel-button","kritzel-color","kritzel-color-palette","kritzel-context-menu","kritzel-controls","kritzel-current-user","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),Ve);break;case"kritzel-active-users":customElements.get(o(t))||E();break;case"kritzel-avatar":customElements.get(o(t))||x();break;case"kritzel-back-to-content":customElements.get(o(t))||T();break;case"kritzel-button":customElements.get(o(t))||O();break;case"kritzel-color":customElements.get(o(t))||I();break;case"kritzel-color-palette":customElements.get(o(t))||U();break;case"kritzel-context-menu":customElements.get(o(t))||D();break;case"kritzel-controls":customElements.get(o(t))||M();break;case"kritzel-current-user":customElements.get(o(t))||W();break;case"kritzel-cursor-trail":customElements.get(o(t))||R();break;case"kritzel-dialog":customElements.get(o(t))||B();break;case"kritzel-dropdown":customElements.get(o(t))||P();break;case"kritzel-engine":customElements.get(o(t))||C();break;case"kritzel-export":customElements.get(o(t))||V();break;case"kritzel-font":customElements.get(o(t))||F();break;case"kritzel-font-family":customElements.get(o(t))||L();break;case"kritzel-font-size":customElements.get(o(t))||N();break;case"kritzel-icon":customElements.get(o(t))||a();break;case"kritzel-input":customElements.get(o(t))||H();break;case"kritzel-line-endings":customElements.get(o(t))||J();break;case"kritzel-login-dialog":customElements.get(o(t))||q();break;case"kritzel-master-detail":customElements.get(o(t))||K();break;case"kritzel-menu":customElements.get(o(t))||Y();break;case"kritzel-menu-item":customElements.get(o(t))||G();break;case"kritzel-more-menu":customElements.get(o(t))||Q();break;case"kritzel-numeric-input":customElements.get(o(t))||X();break;case"kritzel-opacity-slider":customElements.get(o(t))||$();break;case"kritzel-pill-tabs":customElements.get(o(t))||_();break;case"kritzel-portal":customElements.get(o(t))||Z();break;case"kritzel-settings":customElements.get(o(t))||tt();break;case"kritzel-shape-fill":customElements.get(o(t))||et();break;case"kritzel-share-dialog":customElements.get(o(t))||st();break;case"kritzel-slide-toggle":customElements.get(o(t))||it();break;case"kritzel-split-button":customElements.get(o(t))||nt();break;case"kritzel-stroke-size":customElements.get(o(t))||ot();break;case"kritzel-tool-config":customElements.get(o(t))||rt();break;case"kritzel-tooltip":customElements.get(o(t))||at();break;case"kritzel-utility-panel":customElements.get(o(t))||ht();break;case"kritzel-workspace-manager":customElements.get(o(t))||ct()}}))};export{We as D,Me as H,Fe as KritzelEditor,Ce as a,Re as b,Be as c,Le as defineCustomElement}
|