@reffy/infinite-canvas 0.0.12 → 0.1.0
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/README.md +2 -0
- package/{esm → dist}/API.d.ts +6 -2
- package/dist/API.d.ts.map +1 -0
- package/{lib → dist}/Canvas.d.ts +33 -9
- package/dist/Canvas.d.ts.map +1 -0
- package/{esm → dist}/Component.d.ts +28 -8
- package/dist/Component.d.ts.map +1 -0
- package/dist/bounding/AABB.d.ts.map +1 -0
- package/{lib → dist}/bounding/BoundingBox.d.ts +5 -5
- package/dist/bounding/BoundingBox.d.ts.map +1 -0
- package/{esm → dist}/bounding/Marquee.d.ts +2 -2
- package/dist/bounding/Marquee.d.ts.map +1 -0
- package/{esm → dist}/bounding/MultiBoundingBox.d.ts +3 -3
- package/dist/bounding/MultiBoundingBox.d.ts.map +1 -0
- package/dist/bounding/index.d.ts +6 -0
- package/dist/bounding/index.d.ts.map +1 -0
- package/dist/bounding/type.d.ts.map +1 -0
- package/{esm → dist}/camera/Camera.d.ts +3 -2
- package/dist/camera/Camera.d.ts.map +1 -0
- package/dist/camera/index.d.ts +2 -0
- package/dist/camera/index.d.ts.map +1 -0
- package/dist/contextMenu/ContextMenu.d.ts.map +1 -0
- package/{esm → dist}/contextMenu/Interaction.d.ts +4 -2
- package/dist/contextMenu/Interaction.d.ts.map +1 -0
- package/dist/contextMenu/index.d.ts +3 -0
- package/dist/contextMenu/index.d.ts.map +1 -0
- package/dist/history/history.d.ts.map +1 -0
- package/dist/history/index.d.ts +2 -0
- package/dist/history/index.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.js +14663 -0
- package/dist/index.js.js.map +1 -0
- package/{esm → dist}/loader/Interaction.d.ts +1 -1
- package/dist/loader/Interaction.d.ts.map +1 -0
- package/dist/loader/Loader.d.ts.map +1 -0
- package/dist/loader/index.d.ts +3 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/{lib → dist}/manager/ContextMenu.d.ts +2 -2
- package/dist/manager/ContextMenu.d.ts.map +1 -0
- package/{esm → dist}/manager/FlipCommand.d.ts +3 -3
- package/dist/manager/FlipCommand.d.ts.map +1 -0
- package/{esm → dist}/manager/KeyEvent.d.ts +2 -2
- package/dist/manager/KeyEvent.d.ts.map +1 -0
- package/{esm → dist}/manager/OrderCommand.d.ts +2 -2
- package/dist/manager/OrderCommand.d.ts.map +1 -0
- package/{lib → dist}/manager/PointerEvent.d.ts +7 -7
- package/dist/manager/PointerEvent.d.ts.map +1 -0
- package/{esm → dist}/manager/SceneCommand.d.ts +3 -3
- package/dist/manager/SceneCommand.d.ts.map +1 -0
- package/{esm → dist}/manager/Selection.d.ts +8 -8
- package/dist/manager/Selection.d.ts.map +1 -0
- package/{esm → dist}/manager/TransformCommand.d.ts +2 -2
- package/dist/manager/TransformCommand.d.ts.map +1 -0
- package/dist/manager/index.d.ts +9 -0
- package/dist/manager/index.d.ts.map +1 -0
- package/dist/serializer/index.d.ts +3 -0
- package/dist/serializer/index.d.ts.map +1 -0
- package/dist/serializer/schema.d.ts +26 -0
- package/dist/serializer/schema.d.ts.map +1 -0
- package/{lib → dist}/serializer/serializer.d.ts +6 -4
- package/dist/serializer/serializer.d.ts.map +1 -0
- package/dist/shaders/grid.d.ts.map +1 -0
- package/dist/shaders/img.d.ts.map +1 -0
- package/dist/shaders/index.d.ts +4 -0
- package/dist/shaders/index.d.ts.map +1 -0
- package/dist/shaders/shape.d.ts.map +1 -0
- package/{esm → dist}/shapes/Grid.d.ts +1 -1
- package/dist/shapes/Grid.d.ts.map +1 -0
- package/{esm → dist}/shapes/Img.d.ts +2 -2
- package/dist/shapes/Img.d.ts.map +1 -0
- package/{esm → dist}/shapes/Rect.d.ts +6 -2
- package/dist/shapes/Rect.d.ts.map +1 -0
- package/{lib → dist}/shapes/Renderable.d.ts +6 -3
- package/dist/shapes/Renderable.d.ts.map +1 -0
- package/{esm → dist}/shapes/Shape.d.ts +2 -2
- package/dist/shapes/Shape.d.ts.map +1 -0
- package/{lib → dist}/shapes/Triangle.d.ts +2 -2
- package/dist/shapes/Triangle.d.ts.map +1 -0
- package/dist/shapes/index.d.ts +6 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/state/camera.d.ts.map +1 -0
- package/dist/state/index.d.ts +4 -0
- package/dist/state/index.d.ts.map +1 -0
- package/{esm → dist}/state/pointerEvent.d.ts +3 -3
- package/dist/state/pointerEvent.d.ts.map +1 -0
- package/{esm → dist}/state/renderable.d.ts +1 -1
- package/dist/state/renderable.d.ts.map +1 -0
- package/{esm → dist}/storage/defaultStorage.d.ts +9 -2
- package/dist/storage/defaultStorage.d.ts.map +1 -0
- package/dist/storage/dexie-primary-key.d.ts.map +1 -0
- package/dist/storage/index.d.ts +3 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/{esm → dist}/storage/storage.d.ts +3 -1
- package/dist/storage/storage.d.ts.map +1 -0
- package/{lib → dist}/util/camera/camera.d.ts +1 -1
- package/dist/util/camera/camera.d.ts.map +1 -0
- package/dist/util/camera/index.d.ts +2 -0
- package/dist/util/camera/index.d.ts.map +1 -0
- package/dist/util/checks.d.ts.map +1 -0
- package/{esm → dist}/util/clipboard.d.ts +3 -3
- package/dist/util/clipboard.d.ts.map +1 -0
- package/dist/util/color.d.ts.map +1 -0
- package/dist/util/customEventType.d.ts.map +1 -0
- package/{esm → dist}/util/files.d.ts +2 -3
- package/dist/util/files.d.ts.map +1 -0
- package/dist/util/handles.d.ts.map +1 -0
- package/dist/util/index.d.ts +11 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/performance.d.ts.map +1 -0
- package/dist/util/shaders.d.ts.map +1 -0
- package/dist/util/webgl/index.d.ts +3 -0
- package/dist/util/webgl/index.d.ts.map +1 -0
- package/dist/util/webgl/m3.d.ts.map +1 -0
- package/dist/util/webgl/uniform.d.ts.map +1 -0
- package/package.json +9 -18
- package/dist/assets/index-KcoKIUJZ.js +0 -281
- package/dist/index.html +0 -54
- package/esm/API.d.ts.map +0 -1
- package/esm/API.js +0 -74
- package/esm/API.js.map +0 -1
- package/esm/Canvas.d.ts +0 -69
- package/esm/Canvas.d.ts.map +0 -1
- package/esm/Canvas.js +0 -372
- package/esm/Canvas.js.map +0 -1
- package/esm/Component.d.ts.map +0 -1
- package/esm/Component.js +0 -611
- package/esm/Component.js.map +0 -1
- package/esm/bounding/AABB.d.ts.map +0 -1
- package/esm/bounding/AABB.js +0 -19
- package/esm/bounding/AABB.js.map +0 -1
- package/esm/bounding/BoundingBox.d.ts +0 -53
- package/esm/bounding/BoundingBox.d.ts.map +0 -1
- package/esm/bounding/BoundingBox.js +0 -300
- package/esm/bounding/BoundingBox.js.map +0 -1
- package/esm/bounding/Marquee.d.ts.map +0 -1
- package/esm/bounding/Marquee.js +0 -111
- package/esm/bounding/Marquee.js.map +0 -1
- package/esm/bounding/MultiBoundingBox.d.ts.map +0 -1
- package/esm/bounding/MultiBoundingBox.js +0 -373
- package/esm/bounding/MultiBoundingBox.js.map +0 -1
- package/esm/bounding/index.d.ts +0 -6
- package/esm/bounding/index.d.ts.map +0 -1
- package/esm/bounding/index.js +0 -6
- package/esm/bounding/index.js.map +0 -1
- package/esm/bounding/type.d.ts.map +0 -1
- package/esm/bounding/type.js +0 -6
- package/esm/bounding/type.js.map +0 -1
- package/esm/camera/Camera.d.ts.map +0 -1
- package/esm/camera/Camera.js +0 -71
- package/esm/camera/Camera.js.map +0 -1
- package/esm/camera/index.d.ts +0 -2
- package/esm/camera/index.d.ts.map +0 -1
- package/esm/camera/index.js +0 -2
- package/esm/camera/index.js.map +0 -1
- package/esm/contextMenu/ContextMenu.d.ts.map +0 -1
- package/esm/contextMenu/ContextMenu.js +0 -118
- package/esm/contextMenu/ContextMenu.js.map +0 -1
- package/esm/contextMenu/Interaction.d.ts.map +0 -1
- package/esm/contextMenu/Interaction.js +0 -256
- package/esm/contextMenu/Interaction.js.map +0 -1
- package/esm/contextMenu/index.d.ts +0 -3
- package/esm/contextMenu/index.d.ts.map +0 -1
- package/esm/contextMenu/index.js +0 -3
- package/esm/contextMenu/index.js.map +0 -1
- package/esm/history/history.d.ts.map +0 -1
- package/esm/history/history.js +0 -120
- package/esm/history/history.js.map +0 -1
- package/esm/history/index.d.ts +0 -2
- package/esm/history/index.d.ts.map +0 -1
- package/esm/history/index.js +0 -2
- package/esm/history/index.js.map +0 -1
- package/esm/index.d.ts +0 -5
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -5
- package/esm/index.js.map +0 -1
- package/esm/loader/Interaction.d.ts.map +0 -1
- package/esm/loader/Interaction.js +0 -17
- package/esm/loader/Interaction.js.map +0 -1
- package/esm/loader/Loader.d.ts.map +0 -1
- package/esm/loader/Loader.js +0 -49
- package/esm/loader/Loader.js.map +0 -1
- package/esm/loader/index.d.ts +0 -3
- package/esm/loader/index.d.ts.map +0 -1
- package/esm/loader/index.js +0 -3
- package/esm/loader/index.js.map +0 -1
- package/esm/manager/ContextMenu.d.ts +0 -11
- package/esm/manager/ContextMenu.d.ts.map +0 -1
- package/esm/manager/ContextMenu.js +0 -33
- package/esm/manager/ContextMenu.js.map +0 -1
- package/esm/manager/FlipCommand.d.ts.map +0 -1
- package/esm/manager/FlipCommand.js +0 -35
- package/esm/manager/FlipCommand.js.map +0 -1
- package/esm/manager/KeyEvent.d.ts.map +0 -1
- package/esm/manager/KeyEvent.js +0 -51
- package/esm/manager/KeyEvent.js.map +0 -1
- package/esm/manager/OrderCommand.d.ts.map +0 -1
- package/esm/manager/OrderCommand.js +0 -28
- package/esm/manager/OrderCommand.js.map +0 -1
- package/esm/manager/PointerEvent.d.ts +0 -70
- package/esm/manager/PointerEvent.d.ts.map +0 -1
- package/esm/manager/PointerEvent.js +0 -169
- package/esm/manager/PointerEvent.js.map +0 -1
- package/esm/manager/SceneCommand.d.ts.map +0 -1
- package/esm/manager/SceneCommand.js +0 -85
- package/esm/manager/SceneCommand.js.map +0 -1
- package/esm/manager/Selection.d.ts.map +0 -1
- package/esm/manager/Selection.js +0 -299
- package/esm/manager/Selection.js.map +0 -1
- package/esm/manager/TransformCommand.d.ts.map +0 -1
- package/esm/manager/TransformCommand.js +0 -29
- package/esm/manager/TransformCommand.js.map +0 -1
- package/esm/manager/index.d.ts +0 -9
- package/esm/manager/index.d.ts.map +0 -1
- package/esm/manager/index.js +0 -9
- package/esm/manager/index.js.map +0 -1
- package/esm/serializer/index.d.ts +0 -2
- package/esm/serializer/index.d.ts.map +0 -1
- package/esm/serializer/index.js +0 -2
- package/esm/serializer/index.js.map +0 -1
- package/esm/serializer/serializer.d.ts +0 -54
- package/esm/serializer/serializer.d.ts.map +0 -1
- package/esm/serializer/serializer.js +0 -231
- package/esm/serializer/serializer.js.map +0 -1
- package/esm/shaders/grid.d.ts.map +0 -1
- package/esm/shaders/grid.js +0 -89
- package/esm/shaders/grid.js.map +0 -1
- package/esm/shaders/img.d.ts.map +0 -1
- package/esm/shaders/img.js +0 -39
- package/esm/shaders/img.js.map +0 -1
- package/esm/shaders/index.d.ts +0 -4
- package/esm/shaders/index.d.ts.map +0 -1
- package/esm/shaders/index.js +0 -4
- package/esm/shaders/index.js.map +0 -1
- package/esm/shaders/shape.d.ts.map +0 -1
- package/esm/shaders/shape.js +0 -29
- package/esm/shaders/shape.js.map +0 -1
- package/esm/shapes/Grid.d.ts.map +0 -1
- package/esm/shapes/Grid.js +0 -84
- package/esm/shapes/Grid.js.map +0 -1
- package/esm/shapes/Img.d.ts.map +0 -1
- package/esm/shapes/Img.js +0 -313
- package/esm/shapes/Img.js.map +0 -1
- package/esm/shapes/Rect.d.ts.map +0 -1
- package/esm/shapes/Rect.js +0 -92
- package/esm/shapes/Rect.js.map +0 -1
- package/esm/shapes/Renderable.d.ts +0 -54
- package/esm/shapes/Renderable.d.ts.map +0 -1
- package/esm/shapes/Renderable.js +0 -141
- package/esm/shapes/Renderable.js.map +0 -1
- package/esm/shapes/Shape.d.ts.map +0 -1
- package/esm/shapes/Shape.js +0 -71
- package/esm/shapes/Shape.js.map +0 -1
- package/esm/shapes/Triangle.d.ts +0 -20
- package/esm/shapes/Triangle.d.ts.map +0 -1
- package/esm/shapes/Triangle.js +0 -82
- package/esm/shapes/Triangle.js.map +0 -1
- package/esm/shapes/index.d.ts +0 -6
- package/esm/shapes/index.d.ts.map +0 -1
- package/esm/shapes/index.js +0 -7
- package/esm/shapes/index.js.map +0 -1
- package/esm/state/camera.d.ts.map +0 -1
- package/esm/state/camera.js +0 -88
- package/esm/state/camera.js.map +0 -1
- package/esm/state/index.d.ts +0 -4
- package/esm/state/index.d.ts.map +0 -1
- package/esm/state/index.js +0 -4
- package/esm/state/index.js.map +0 -1
- package/esm/state/pointerEvent.d.ts.map +0 -1
- package/esm/state/pointerEvent.js +0 -49
- package/esm/state/pointerEvent.js.map +0 -1
- package/esm/state/renderable.d.ts.map +0 -1
- package/esm/state/renderable.js +0 -176
- package/esm/state/renderable.js.map +0 -1
- package/esm/storage/defaultStorage.d.ts.map +0 -1
- package/esm/storage/defaultStorage.js +0 -237
- package/esm/storage/defaultStorage.js.map +0 -1
- package/esm/storage/dexie-primary-key.d.ts.map +0 -1
- package/esm/storage/dexie-primary-key.js +0 -81
- package/esm/storage/dexie-primary-key.js.map +0 -1
- package/esm/storage/index.d.ts +0 -3
- package/esm/storage/index.d.ts.map +0 -1
- package/esm/storage/index.js +0 -3
- package/esm/storage/index.js.map +0 -1
- package/esm/storage/storage.d.ts.map +0 -1
- package/esm/storage/storage.js +0 -44
- package/esm/storage/storage.js.map +0 -1
- package/esm/util/camera/camera.d.ts +0 -19
- package/esm/util/camera/camera.d.ts.map +0 -1
- package/esm/util/camera/camera.js +0 -75
- package/esm/util/camera/camera.js.map +0 -1
- package/esm/util/camera/index.d.ts +0 -2
- package/esm/util/camera/index.d.ts.map +0 -1
- package/esm/util/camera/index.js +0 -2
- package/esm/util/camera/index.js.map +0 -1
- package/esm/util/checks.d.ts.map +0 -1
- package/esm/util/checks.js +0 -36
- package/esm/util/checks.js.map +0 -1
- package/esm/util/clipboard.d.ts.map +0 -1
- package/esm/util/clipboard.js +0 -146
- package/esm/util/clipboard.js.map +0 -1
- package/esm/util/color.d.ts.map +0 -1
- package/esm/util/color.js +0 -8
- package/esm/util/color.js.map +0 -1
- package/esm/util/customEventType.d.ts.map +0 -1
- package/esm/util/customEventType.js +0 -35
- package/esm/util/customEventType.js.map +0 -1
- package/esm/util/files.d.ts.map +0 -1
- package/esm/util/files.js +0 -182
- package/esm/util/files.js.map +0 -1
- package/esm/util/handles.d.ts.map +0 -1
- package/esm/util/handles.js +0 -16
- package/esm/util/handles.js.map +0 -1
- package/esm/util/index.d.ts +0 -11
- package/esm/util/index.d.ts.map +0 -1
- package/esm/util/index.js +0 -11
- package/esm/util/index.js.map +0 -1
- package/esm/util/performance.d.ts.map +0 -1
- package/esm/util/performance.js +0 -7
- package/esm/util/performance.js.map +0 -1
- package/esm/util/shaders.d.ts.map +0 -1
- package/esm/util/shaders.js +0 -30
- package/esm/util/shaders.js.map +0 -1
- package/esm/util/webgl/index.d.ts +0 -3
- package/esm/util/webgl/index.d.ts.map +0 -1
- package/esm/util/webgl/index.js +0 -3
- package/esm/util/webgl/index.js.map +0 -1
- package/esm/util/webgl/m3.d.ts.map +0 -1
- package/esm/util/webgl/m3.js +0 -98
- package/esm/util/webgl/m3.js.map +0 -1
- package/esm/util/webgl/uniform.d.ts.map +0 -1
- package/esm/util/webgl/uniform.js +0 -18
- package/esm/util/webgl/uniform.js.map +0 -1
- package/lib/API.d.ts +0 -21
- package/lib/API.d.ts.map +0 -1
- package/lib/API.js +0 -78
- package/lib/API.js.map +0 -1
- package/lib/Canvas.d.ts.map +0 -1
- package/lib/Canvas.js +0 -376
- package/lib/Canvas.js.map +0 -1
- package/lib/Component.d.ts +0 -128
- package/lib/Component.d.ts.map +0 -1
- package/lib/Component.js +0 -617
- package/lib/Component.js.map +0 -1
- package/lib/bounding/AABB.d.ts +0 -10
- package/lib/bounding/AABB.d.ts.map +0 -1
- package/lib/bounding/AABB.js +0 -23
- package/lib/bounding/AABB.js.map +0 -1
- package/lib/bounding/BoundingBox.d.ts.map +0 -1
- package/lib/bounding/BoundingBox.js +0 -304
- package/lib/bounding/BoundingBox.js.map +0 -1
- package/lib/bounding/Marquee.d.ts +0 -28
- package/lib/bounding/Marquee.d.ts.map +0 -1
- package/lib/bounding/Marquee.js +0 -115
- package/lib/bounding/Marquee.js.map +0 -1
- package/lib/bounding/MultiBoundingBox.d.ts +0 -33
- package/lib/bounding/MultiBoundingBox.d.ts.map +0 -1
- package/lib/bounding/MultiBoundingBox.js +0 -377
- package/lib/bounding/MultiBoundingBox.js.map +0 -1
- package/lib/bounding/index.d.ts +0 -6
- package/lib/bounding/index.d.ts.map +0 -1
- package/lib/bounding/index.js +0 -22
- package/lib/bounding/index.js.map +0 -1
- package/lib/bounding/type.d.ts +0 -13
- package/lib/bounding/type.d.ts.map +0 -1
- package/lib/bounding/type.js +0 -9
- package/lib/bounding/type.js.map +0 -1
- package/lib/camera/Camera.d.ts +0 -29
- package/lib/camera/Camera.d.ts.map +0 -1
- package/lib/camera/Camera.js +0 -75
- package/lib/camera/Camera.js.map +0 -1
- package/lib/camera/index.d.ts +0 -2
- package/lib/camera/index.d.ts.map +0 -1
- package/lib/camera/index.js +0 -18
- package/lib/camera/index.js.map +0 -1
- package/lib/contextMenu/ContextMenu.d.ts +0 -57
- package/lib/contextMenu/ContextMenu.d.ts.map +0 -1
- package/lib/contextMenu/ContextMenu.js +0 -124
- package/lib/contextMenu/ContextMenu.js.map +0 -1
- package/lib/contextMenu/Interaction.d.ts +0 -22
- package/lib/contextMenu/Interaction.d.ts.map +0 -1
- package/lib/contextMenu/Interaction.js +0 -265
- package/lib/contextMenu/Interaction.js.map +0 -1
- package/lib/contextMenu/index.d.ts +0 -3
- package/lib/contextMenu/index.d.ts.map +0 -1
- package/lib/contextMenu/index.js +0 -19
- package/lib/contextMenu/index.js.map +0 -1
- package/lib/history/history.d.ts +0 -29
- package/lib/history/history.d.ts.map +0 -1
- package/lib/history/history.js +0 -127
- package/lib/history/history.js.map +0 -1
- package/lib/history/index.d.ts +0 -2
- package/lib/history/index.d.ts.map +0 -1
- package/lib/history/index.js +0 -18
- package/lib/history/index.js.map +0 -1
- package/lib/index.d.ts +0 -5
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -21
- package/lib/index.js.map +0 -1
- package/lib/loader/Interaction.d.ts +0 -4
- package/lib/loader/Interaction.d.ts.map +0 -1
- package/lib/loader/Interaction.js +0 -21
- package/lib/loader/Interaction.js.map +0 -1
- package/lib/loader/Loader.d.ts +0 -19
- package/lib/loader/Loader.d.ts.map +0 -1
- package/lib/loader/Loader.js +0 -53
- package/lib/loader/Loader.js.map +0 -1
- package/lib/loader/index.d.ts +0 -3
- package/lib/loader/index.d.ts.map +0 -1
- package/lib/loader/index.js +0 -19
- package/lib/loader/index.js.map +0 -1
- package/lib/manager/ContextMenu.d.ts.map +0 -1
- package/lib/manager/ContextMenu.js +0 -37
- package/lib/manager/ContextMenu.js.map +0 -1
- package/lib/manager/FlipCommand.d.ts +0 -18
- package/lib/manager/FlipCommand.d.ts.map +0 -1
- package/lib/manager/FlipCommand.js +0 -39
- package/lib/manager/FlipCommand.js.map +0 -1
- package/lib/manager/KeyEvent.d.ts +0 -16
- package/lib/manager/KeyEvent.d.ts.map +0 -1
- package/lib/manager/KeyEvent.js +0 -55
- package/lib/manager/KeyEvent.js.map +0 -1
- package/lib/manager/OrderCommand.d.ts +0 -17
- package/lib/manager/OrderCommand.d.ts.map +0 -1
- package/lib/manager/OrderCommand.js +0 -32
- package/lib/manager/OrderCommand.js.map +0 -1
- package/lib/manager/PointerEvent.d.ts.map +0 -1
- package/lib/manager/PointerEvent.js +0 -173
- package/lib/manager/PointerEvent.js.map +0 -1
- package/lib/manager/SceneCommand.d.ts +0 -18
- package/lib/manager/SceneCommand.d.ts.map +0 -1
- package/lib/manager/SceneCommand.js +0 -91
- package/lib/manager/SceneCommand.js.map +0 -1
- package/lib/manager/Selection.d.ts +0 -62
- package/lib/manager/Selection.d.ts.map +0 -1
- package/lib/manager/Selection.js +0 -303
- package/lib/manager/Selection.js.map +0 -1
- package/lib/manager/TransformCommand.d.ts +0 -20
- package/lib/manager/TransformCommand.d.ts.map +0 -1
- package/lib/manager/TransformCommand.js +0 -33
- package/lib/manager/TransformCommand.js.map +0 -1
- package/lib/manager/index.d.ts +0 -9
- package/lib/manager/index.d.ts.map +0 -1
- package/lib/manager/index.js +0 -25
- package/lib/manager/index.js.map +0 -1
- package/lib/serializer/index.d.ts +0 -2
- package/lib/serializer/index.d.ts.map +0 -1
- package/lib/serializer/index.js +0 -18
- package/lib/serializer/index.js.map +0 -1
- package/lib/serializer/serializer.d.ts.map +0 -1
- package/lib/serializer/serializer.js +0 -236
- package/lib/serializer/serializer.js.map +0 -1
- package/lib/shaders/grid.d.ts +0 -3
- package/lib/shaders/grid.d.ts.map +0 -1
- package/lib/shaders/grid.js +0 -92
- package/lib/shaders/grid.js.map +0 -1
- package/lib/shaders/img.d.ts +0 -4
- package/lib/shaders/img.d.ts.map +0 -1
- package/lib/shaders/img.js +0 -43
- package/lib/shaders/img.js.map +0 -1
- package/lib/shaders/index.d.ts +0 -4
- package/lib/shaders/index.d.ts.map +0 -1
- package/lib/shaders/index.js +0 -20
- package/lib/shaders/index.js.map +0 -1
- package/lib/shaders/shape.d.ts +0 -4
- package/lib/shaders/shape.d.ts.map +0 -1
- package/lib/shaders/shape.js +0 -33
- package/lib/shaders/shape.js.map +0 -1
- package/lib/shapes/Grid.d.ts +0 -21
- package/lib/shapes/Grid.d.ts.map +0 -1
- package/lib/shapes/Grid.js +0 -88
- package/lib/shapes/Grid.js.map +0 -1
- package/lib/shapes/Img.d.ts +0 -47
- package/lib/shapes/Img.d.ts.map +0 -1
- package/lib/shapes/Img.js +0 -317
- package/lib/shapes/Img.js.map +0 -1
- package/lib/shapes/Rect.d.ts +0 -34
- package/lib/shapes/Rect.d.ts.map +0 -1
- package/lib/shapes/Rect.js +0 -96
- package/lib/shapes/Rect.js.map +0 -1
- package/lib/shapes/Renderable.d.ts.map +0 -1
- package/lib/shapes/Renderable.js +0 -146
- package/lib/shapes/Renderable.js.map +0 -1
- package/lib/shapes/Shape.d.ts +0 -27
- package/lib/shapes/Shape.d.ts.map +0 -1
- package/lib/shapes/Shape.js +0 -75
- package/lib/shapes/Shape.js.map +0 -1
- package/lib/shapes/Triangle.d.ts.map +0 -1
- package/lib/shapes/Triangle.js +0 -86
- package/lib/shapes/Triangle.js.map +0 -1
- package/lib/shapes/index.d.ts +0 -6
- package/lib/shapes/index.d.ts.map +0 -1
- package/lib/shapes/index.js +0 -23
- package/lib/shapes/index.js.map +0 -1
- package/lib/state/camera.d.ts +0 -36
- package/lib/state/camera.d.ts.map +0 -1
- package/lib/state/camera.js +0 -92
- package/lib/state/camera.js.map +0 -1
- package/lib/state/index.d.ts +0 -4
- package/lib/state/index.d.ts.map +0 -1
- package/lib/state/index.js +0 -20
- package/lib/state/index.js.map +0 -1
- package/lib/state/pointerEvent.d.ts +0 -23
- package/lib/state/pointerEvent.d.ts.map +0 -1
- package/lib/state/pointerEvent.js +0 -53
- package/lib/state/pointerEvent.js.map +0 -1
- package/lib/state/renderable.d.ts +0 -36
- package/lib/state/renderable.d.ts.map +0 -1
- package/lib/state/renderable.js +0 -180
- package/lib/state/renderable.js.map +0 -1
- package/lib/storage/defaultStorage.d.ts +0 -34
- package/lib/storage/defaultStorage.d.ts.map +0 -1
- package/lib/storage/defaultStorage.js +0 -246
- package/lib/storage/defaultStorage.js.map +0 -1
- package/lib/storage/dexie-primary-key.d.ts +0 -2
- package/lib/storage/dexie-primary-key.d.ts.map +0 -1
- package/lib/storage/dexie-primary-key.js +0 -86
- package/lib/storage/dexie-primary-key.js.map +0 -1
- package/lib/storage/index.d.ts +0 -3
- package/lib/storage/index.d.ts.map +0 -1
- package/lib/storage/index.js +0 -19
- package/lib/storage/index.js.map +0 -1
- package/lib/storage/storage.d.ts +0 -36
- package/lib/storage/storage.d.ts.map +0 -1
- package/lib/storage/storage.js +0 -50
- package/lib/storage/storage.js.map +0 -1
- package/lib/util/camera/camera.d.ts.map +0 -1
- package/lib/util/camera/camera.js +0 -87
- package/lib/util/camera/camera.js.map +0 -1
- package/lib/util/camera/index.d.ts +0 -2
- package/lib/util/camera/index.d.ts.map +0 -1
- package/lib/util/camera/index.js +0 -18
- package/lib/util/camera/index.js.map +0 -1
- package/lib/util/checks.d.ts +0 -11
- package/lib/util/checks.d.ts.map +0 -1
- package/lib/util/checks.js +0 -49
- package/lib/util/checks.js.map +0 -1
- package/lib/util/clipboard.d.ts +0 -7
- package/lib/util/clipboard.d.ts.map +0 -1
- package/lib/util/clipboard.js +0 -152
- package/lib/util/clipboard.js.map +0 -1
- package/lib/util/color.d.ts +0 -4
- package/lib/util/color.d.ts.map +0 -1
- package/lib/util/color.js +0 -11
- package/lib/util/color.js.map +0 -1
- package/lib/util/customEventType.d.ts +0 -35
- package/lib/util/customEventType.d.ts.map +0 -1
- package/lib/util/customEventType.js +0 -38
- package/lib/util/customEventType.js.map +0 -1
- package/lib/util/files.d.ts +0 -19
- package/lib/util/files.d.ts.map +0 -1
- package/lib/util/files.js +0 -193
- package/lib/util/files.js.map +0 -1
- package/lib/util/handles.d.ts +0 -10
- package/lib/util/handles.d.ts.map +0 -1
- package/lib/util/handles.js +0 -20
- package/lib/util/handles.js.map +0 -1
- package/lib/util/index.d.ts +0 -11
- package/lib/util/index.d.ts.map +0 -1
- package/lib/util/index.js +0 -27
- package/lib/util/index.js.map +0 -1
- package/lib/util/performance.d.ts +0 -2
- package/lib/util/performance.d.ts.map +0 -1
- package/lib/util/performance.js +0 -10
- package/lib/util/performance.js.map +0 -1
- package/lib/util/shaders.d.ts +0 -2
- package/lib/util/shaders.d.ts.map +0 -1
- package/lib/util/shaders.js +0 -33
- package/lib/util/shaders.js.map +0 -1
- package/lib/util/webgl/index.d.ts +0 -3
- package/lib/util/webgl/index.d.ts.map +0 -1
- package/lib/util/webgl/index.js +0 -19
- package/lib/util/webgl/index.js.map +0 -1
- package/lib/util/webgl/m3.d.ts +0 -11
- package/lib/util/webgl/m3.d.ts.map +0 -1
- package/lib/util/webgl/m3.js +0 -101
- package/lib/util/webgl/m3.js.map +0 -1
- package/lib/util/webgl/uniform.d.ts +0 -5
- package/lib/util/webgl/uniform.d.ts.map +0 -1
- package/lib/util/webgl/uniform.js +0 -21
- package/lib/util/webgl/uniform.js.map +0 -1
- /package/{esm → dist}/bounding/AABB.d.ts +0 -0
- /package/{esm → dist}/bounding/type.d.ts +0 -0
- /package/{esm → dist}/contextMenu/ContextMenu.d.ts +0 -0
- /package/{esm → dist}/history/history.d.ts +0 -0
- /package/{esm → dist}/loader/Loader.d.ts +0 -0
- /package/{esm → dist}/shaders/grid.d.ts +0 -0
- /package/{esm → dist}/shaders/img.d.ts +0 -0
- /package/{esm → dist}/shaders/shape.d.ts +0 -0
- /package/{esm → dist}/state/camera.d.ts +0 -0
- /package/{esm → dist}/storage/dexie-primary-key.d.ts +0 -0
- /package/{esm → dist}/util/checks.d.ts +0 -0
- /package/{esm → dist}/util/color.d.ts +0 -0
- /package/{esm → dist}/util/customEventType.d.ts +0 -0
- /package/{esm → dist}/util/handles.d.ts +0 -0
- /package/{esm → dist}/util/performance.d.ts +0 -0
- /package/{esm → dist}/util/shaders.d.ts +0 -0
- /package/{esm → dist}/util/webgl/m3.d.ts +0 -0
- /package/{esm → dist}/util/webgl/uniform.d.ts +0 -0
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
var wa=n=>{throw TypeError(n)};var xa=(n,t,e)=>t.has(n)||wa("Cannot "+e);var F=(n,t,e)=>(xa(n,t,"read from private field"),e?e.call(n):t.get(n)),$t=(n,t,e)=>t.has(n)?wa("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),Pt=(n,t,e,r)=>(xa(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const l of u.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function e(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(o){if(o.ep)return;o.ep=!0;const u=e(o);fetch(o.href,u)}})();const Or=["TOP","BOTTOM","LEFT","RIGHT"],wi=["TOPLEFT","TOPRIGHT","BOTTOMLEFT","BOTTOMRIGHT"],Sa={TOPLEFT:"TOPRIGHT",TOPRIGHT:"TOPLEFT",BOTTOMLEFT:"BOTTOMRIGHT",BOTTOMRIGHT:"BOTTOMLEFT"};function Oa(n){return Sa[n]?Sa[n]:n}const vu=8,wo=2,bt={identity:function(){return[1,0,0,0,1,0,0,0,1]},translation:function(n,t){return[1,0,0,0,1,0,n,t,1]},rotation:function(n){var t=Math.cos(n),e=Math.sin(n);return[t,-e,0,e,t,0,0,0,1]},scaling:function(n,t){return[n,0,0,0,t,0,0,0,1]},multiply:function(n,t){var e=n[0],r=n[1],o=n[2],u=n[3],l=n[4],f=n[5],p=n[6],m=n[7],_=n[8],S=t[0],R=t[1],I=t[2],j=t[3],V=t[4],W=t[5],tt=t[6],ot=t[7],Q=t[8];return[S*e+R*u+I*p,S*r+R*l+I*m,S*o+R*f+I*_,j*e+V*u+W*p,j*r+V*l+W*m,j*o+V*f+W*_,tt*e+ot*u+Q*p,tt*r+ot*l+Q*m,tt*o+ot*f+Q*_]},inverse(n){const t=[9],e=n[0],r=n[1],o=n[2],u=n[3],l=n[4],f=n[5],p=n[6],m=n[7],_=n[8],S=_*l-f*m,R=-_*u+f*p,I=m*u-l*p,V=1/(e*S+r*R+o*I);return t[0]=S*V,t[1]=(-_*r+o*m)*V,t[2]=(f*r-o*l)*V,t[3]=R*V,t[4]=(_*e-o*p)*V,t[5]=(-f*e+o*u)*V,t[6]=I*V,t[7]=(-m*e+r*p)*V,t[8]=(l*e-r*u)*V,t},projection(n,t){const e=[9];return e[0]=2/n,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/t,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},transformPoint(n,t){var e=t[0],r=t[1],o=e*n[2]+r*n[5]+n[8];return[(e*n[0]+r*n[3]+n[6])/o,(e*n[1]+r*n[4]+n[7])/o]}};function Gs(n,t,e){const r=Aa(n,n.VERTEX_SHADER,t),o=Aa(n,n.FRAGMENT_SHADER,e),u=n.createProgram();if(n.attachShader(u,r),n.attachShader(u,o),n.linkProgram(u),!n.getProgramParameter(u,n.LINK_STATUS))throw n.deleteProgram(u),n.deleteShader(r),n.deleteShader(o),new Error("Program was not created or the link to shaders was not successful.");return n.detachShader(u,r),n.detachShader(u,o),u}function Aa(n,t,e){const r=n.createShader(t);if(n.shaderSource(r,e),n.compileShader(r),n.getShaderParameter(r,n.COMPILE_STATUS))return r;throw n.deleteShader(r),new Error("Shader was not created.")}function tl(n,t,e,r,o,u){const l=o.getBoundingClientRect(),f=window.devicePixelRatio||1,p=(n-l.left)*f,m=(t-l.top)*f,_=p/e*2-1,S=m/r*-2+1,R=bt.projection(e,r),I=bt.multiply(R,u),j=bt.inverse(I),[V,W]=bt.transformPoint(j,[_,S]);return[V,W]}function an(n,t,e){const{gl:r,canvas:o}=e;return tl(n,t,r.canvas.width,r.canvas.height,o,e.worldMatrix)}function Jt(n,t,e){const r=t??0,o=e??0;return[n[0]*r+n[3]*o+n[6],n[1]*r+n[4]*o+n[7]]}function el(n){return Math.hypot(n[0],n[1])}function nl(n){return Math.hypot(n[3],n[4])}function hn(n){return[el(n),nl(n)]}function Ea(n){return n/Math.abs(n)}function xi(n){return[Ea(n[0]),Ea(n[4])]}const ki=(n,t)=>Math.abs(n)<t?0:Math.sign(n),Ii=(n,t,e)=>{const r=n*t;return ki(n,e)!==ki(r,e)};async function rl(n){return new Promise((t,e)=>{let r=new FileReader;r.onload=o=>{t(o.target.result)},r.onerror=e,r.readAsDataURL(n)})}const il=["image/webp","image/png","image/jpeg","image/jpg","image/svg+xml","image/avif","image/gif","image/apng"];function sl(n){return il.includes(n)}async function xo(n){const e=new TextEncoder().encode(n),r=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(r)).map(u=>u.toString(16).padStart(2,"0")).join("")}function ol(n){const t=/^data:([^;]+);base64,/.exec(n);return t?t[1]:void 0}async function al(n,t){const e=[];if(n.length>0)for(let r=0;r<n.length;r++){const o=n[r];if(sl(o.type))try{const u=await rl(o);typeof u=="string"?e.push(await t(u)):console.error("Image not added")}catch{console.error("Failed to copy image.")}}return e}function ul(n,t){const e=JSON.stringify(t,null,2),r=new Blob([e],{type:"application/json"}),o=URL.createObjectURL(r),u=document.createElement("a");u.href=o,u.download=n,document.body.appendChild(u),u.click(),u.remove(),URL.revokeObjectURL(o)}async function cl(n){const t=await n.text();return JSON.parse(t)}function mu(n,t=1){return new Promise((e,r)=>{const o=new Image;o.onload=()=>{const u=document.createElement("canvas");u.width=o.width,u.height=o.height;const l=u.getContext("2d");l.clearRect(0,0,u.width,u.height),l.drawImage(o,0,0);const f=u.toDataURL("image/png",t);e(f)},o.onerror=r,o.src=n})}const Nn=[.33,.6,.95,1],mi=[.33,.6,.95,.6],ll=[.33,.6,.95,.4];function Di(n,t,e="Add Child"){return{label:e,do(){for(const r of t)n.appendChild(r)},undo(){for(const r of t)n.removeChild(r)}}}function hl(n,t,e="Remove Child"){let r=-1;return{label:e,do(){r=n.children.indexOf(t),r>=0&&n.children.splice(r,1)},undo(){if(r<0){n.children.push(t);return}n.children.splice(r,0,t)}}}function fl(n,t,e="Remove Children"){let r=[];return{label:e,do(){const o=new Set(t);r=[],n.children.forEach((u,l)=>{o.has(u)&&r.push({child:u,idx:l})}),r.slice().sort((u,l)=>l.idx-u.idx).forEach(({child:u})=>{n.removeChild(u)})},undo(){r.slice().sort((o,u)=>o.idx-u.idx).forEach(({child:o,idx:u})=>{n.children.includes(o)||(n.children.splice(Math.min(u,n.children.length),0,o),o.addParent(n))}),n.markOrderDirty()}}}const dl=["image/","text/plain"],pl=()=>"clipboard"in navigator&&"writeText"in navigator.clipboard;async function gu(n,t){const e={type:"infinite_canvas",elements:n.map(u=>({src:u.src,x:u.x,y:u.y,sx:u.sx,sy:u.sy}))},r=JSON.stringify(e),o=new ClipboardItem({"text/plain":new Blob([r],{type:"text/plain"})});if(pl())try{await navigator.clipboard.write([o]);return}catch(u){console.error(u)}if(!vl(r))throw new Error("Error copying to clipboard.")}function vl(n){n||(n=" ");const t=document.documentElement.getAttribute("dir")==="rtl",e=document.createElement("textarea");e.style.border="0",e.style.padding="0",e.style.margin="0",e.style.position="absolute",e.style[t?"right":"left"]="-9999px";const r=window.pageYOffset||document.documentElement.scrollTop;e.style.top=`${r}px`,e.style.fontSize="12pt",e.setAttribute("readonly",""),e.value=n,document.body.appendChild(e);let o=!1;try{e.select(),e.setSelectionRange(0,e.value.length),o=document.execCommand("copy")}catch(u){console.error(u)}return e.remove(),o}async function yu(n,t,e,r,o=!0){const u=await navigator.clipboard.read(),l=u[0].types,[f,p]=o?[n,t]:an(n,t,e);for(const m of l){if(!dl.find(I=>I.endsWith("/")?m.startsWith(I):m===I))continue;const S=await u[0].getType(m);try{if(m==="text/plain"){const I=JSON.parse(await S.text());if(I.elements.length===0)return;let j=1/0,V=1/0;for(const tt of I.elements)tt.x<j&&(j=tt.x),tt.y<V&&(V=tt.y);const W=await Promise.all(I.elements.map(tt=>e.addImageToCanvas(tt.src,f+tt.x-j,p+tt.y-V,tt.sx,tt.sy)));r.push(Di(e,W));return}}catch(I){console.error("Failed to parse clipboard data",I);continue}let R;if(m.startsWith("image/svg"))try{const I=await S.text();R=await mu(`data:image/svg+xml;base64,${btoa(I)}`)}catch(I){console.error("SVG conversion failed",I);continue}else try{R=await new Promise((I,j)=>{const V=new FileReader;V.onloadend=()=>I(V.result),V.onerror=j,V.readAsDataURL(S)})}catch(I){console.error("Image read failed",I);continue}try{const I=await e.addImageToCanvas(R,f,p);r.push(Di(e,[I]));return}catch(I){console.error("Failed to add image to canvas",I);continue}}}const Oe={Open:"opencontextmenu",Close:"closecontextmenu"},Ae={Save:"save",Change:"statechange"},In={start:"startloading",done:"completeloading"},Dn={Save:"save",SaveCompleted:"savecompleted",SaveFailed:"savefailed"},ml=`
|
|
2
|
-
attribute vec2 a_position;
|
|
3
|
-
|
|
4
|
-
uniform vec2 u_resolution;
|
|
5
|
-
uniform mat3 u_matrix;
|
|
6
|
-
uniform float u_z;
|
|
7
|
-
|
|
8
|
-
// all shaders have a main function
|
|
9
|
-
void main() {
|
|
10
|
-
vec2 position = (u_matrix * vec3(a_position, 1)).xy;
|
|
11
|
-
|
|
12
|
-
vec2 zeroToOne = position / u_resolution;
|
|
13
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
14
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
15
|
-
float z = mix(1.0, -1.0, u_z);
|
|
16
|
-
|
|
17
|
-
gl_Position = vec4(clipSpace * vec2(1, -1), z, 1);
|
|
18
|
-
}
|
|
19
|
-
`,gl=`
|
|
20
|
-
precision mediump float;
|
|
21
|
-
uniform vec4 u_color;
|
|
22
|
-
|
|
23
|
-
void main() {
|
|
24
|
-
gl_FragColor = u_color;
|
|
25
|
-
}
|
|
26
|
-
`,yl=`
|
|
27
|
-
#extension GL_OES_standard_derivatives : enable
|
|
28
|
-
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
29
|
-
precision highp float;
|
|
30
|
-
precision highp int;
|
|
31
|
-
#else
|
|
32
|
-
precision mediump float;
|
|
33
|
-
precision mediump int;
|
|
34
|
-
#endif
|
|
35
|
-
|
|
36
|
-
uniform mat3 u_ViewProjectionInvMatrix;
|
|
37
|
-
uniform float u_ZoomScale;
|
|
38
|
-
uniform float u_CheckboardStyle;
|
|
39
|
-
uniform float u_z;
|
|
40
|
-
|
|
41
|
-
attribute vec2 a_Position;
|
|
42
|
-
|
|
43
|
-
varying vec2 v_Position;
|
|
44
|
-
|
|
45
|
-
vec2 project_clipspace_to_world(vec2 p) {
|
|
46
|
-
return (u_ViewProjectionInvMatrix * vec3(p, 1.0)).xy;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
void main() {
|
|
50
|
-
v_Position = project_clipspace_to_world(a_Position);
|
|
51
|
-
float z = mix(1.0, -1.0, u_z);
|
|
52
|
-
gl_Position = vec4(a_Position, z, 1.0);
|
|
53
|
-
}
|
|
54
|
-
`,_l=`
|
|
55
|
-
#extension GL_OES_standard_derivatives : enable
|
|
56
|
-
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
57
|
-
precision highp float;
|
|
58
|
-
precision highp int;
|
|
59
|
-
#else
|
|
60
|
-
precision mediump float;
|
|
61
|
-
precision mediump int;
|
|
62
|
-
#endif
|
|
63
|
-
|
|
64
|
-
uniform mat3 u_ViewProjectionInvMatrix;
|
|
65
|
-
uniform float u_ZoomScale;
|
|
66
|
-
uniform float u_CheckboardStyle;
|
|
67
|
-
|
|
68
|
-
varying vec2 v_Position;
|
|
69
|
-
|
|
70
|
-
const vec4 GRID_COLOR = vec4(0.87, 0.87, 0.87, 1.0);
|
|
71
|
-
const vec4 PAGE_COLOR = vec4(0.986, 0.986, 0.986, 1.0);
|
|
72
|
-
const int CHECKERBOARD_STYLE_NONE = 0;
|
|
73
|
-
const int CHECKERBOARD_STYLE_GRID = 1;
|
|
74
|
-
const int CHECKERBOARD_STYLE_DOTS = 2;
|
|
75
|
-
const float BASE_GRID_PIXEL_SIZE = 100.0;
|
|
76
|
-
|
|
77
|
-
vec2 scale_grid_size(float zoom) {
|
|
78
|
-
if (zoom < 0.125) return vec2(BASE_GRID_PIXEL_SIZE * 125.0, 0.125);
|
|
79
|
-
else if (zoom < 0.25) return vec2(BASE_GRID_PIXEL_SIZE * 25.0, 0.25);
|
|
80
|
-
else if (zoom < 0.5) return vec2(BASE_GRID_PIXEL_SIZE * 5.0, 0.5);
|
|
81
|
-
return vec2(BASE_GRID_PIXEL_SIZE, 4.0);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
vec4 render_grid_checkerboard(vec2 coord) {
|
|
85
|
-
float alpha = 0.0;
|
|
86
|
-
|
|
87
|
-
vec2 size = scale_grid_size(u_ZoomScale);
|
|
88
|
-
float gridSize1 = size.x;
|
|
89
|
-
float gridSize2 = gridSize1 / 10.0;
|
|
90
|
-
float zoomStep = size.y;
|
|
91
|
-
int checkboardStyle = int(floor(u_CheckboardStyle + 0.5));
|
|
92
|
-
|
|
93
|
-
if (checkboardStyle == CHECKERBOARD_STYLE_GRID) {
|
|
94
|
-
vec2 grid1 = abs(fract(coord / gridSize1 - 0.5) - 0.5) / fwidth(coord) * gridSize1 / 2.0;
|
|
95
|
-
vec2 grid2 = abs(fract(coord / gridSize2 - 0.5) - 0.5) / fwidth(coord) * gridSize2;
|
|
96
|
-
float v1 = 1.0 - min(min(grid1.x, grid1.y), 1.0);
|
|
97
|
-
float v2 = 1.0 - min(min(grid2.x, grid2.y), 1.0);
|
|
98
|
-
|
|
99
|
-
if (v1 > 0.0) {
|
|
100
|
-
alpha = v1;
|
|
101
|
-
} else {
|
|
102
|
-
alpha = v2 * clamp(u_ZoomScale / zoomStep, 0.0, 1.0);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return mix(PAGE_COLOR, GRID_COLOR, alpha);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
void main() {
|
|
110
|
-
gl_FragColor = render_grid_checkerboard(v_Position);
|
|
111
|
-
}
|
|
112
|
-
`,bl=`
|
|
113
|
-
attribute vec2 a_position;
|
|
114
|
-
attribute vec2 a_texCoord;
|
|
115
|
-
|
|
116
|
-
uniform vec2 u_resolution;
|
|
117
|
-
uniform mat3 u_matrix;
|
|
118
|
-
uniform float u_z;
|
|
119
|
-
|
|
120
|
-
varying vec2 v_texCoord;
|
|
121
|
-
|
|
122
|
-
void main() {
|
|
123
|
-
vec2 position = (u_matrix * vec3(a_position, 1)).xy;
|
|
124
|
-
vec2 zeroToOne = position / u_resolution;
|
|
125
|
-
vec2 zeroToTwo = zeroToOne * 2.0;
|
|
126
|
-
vec2 clipSpace = zeroToTwo - 1.0;
|
|
127
|
-
float z = mix(1.0, -1.0, u_z);
|
|
128
|
-
|
|
129
|
-
gl_Position = vec4(clipSpace * vec2(1, -1), z, 1);
|
|
130
|
-
|
|
131
|
-
v_texCoord = a_texCoord;
|
|
132
|
-
}
|
|
133
|
-
`,wl=`
|
|
134
|
-
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
135
|
-
precision highp float;
|
|
136
|
-
#else
|
|
137
|
-
precision mediump float;
|
|
138
|
-
#endif
|
|
139
|
-
|
|
140
|
-
uniform sampler2D u_image;
|
|
141
|
-
|
|
142
|
-
varying vec2 v_texCoord;
|
|
143
|
-
|
|
144
|
-
void main() {
|
|
145
|
-
gl_FragColor = texture2D(u_image, v_texCoord);
|
|
146
|
-
}
|
|
147
|
-
`;var Zt=(n=>(n[n.ACTIVE=0]="ACTIVE",n[n.PASSIVE=1]="PASSIVE",n))(Zt||{});class Ca{constructor(t,e){this.sides=new Map,this.corners=new Map,this.borderSize=0,this.boxSize=0,this.mode=Zt.ACTIVE,this.target=t,this.setDimension(),this.mode=e??Zt.ACTIVE,this.borderSize=wo,this.boxSize=vu/2,this.addSides(),this.mode===Zt.ACTIVE&&this.addCorners()}setDimension(){const t=this.target.getEdge();this.width=t.maxX-t.minX,this.height=t.maxY-t.minY}getSidesInScreenSpace(t,e){const[r,o]=e?hn(e):[1,1],{width:u,height:l,borderSize:f}=this,[p,m]=Jt(e),[_,S]=xi(e);return{TOP:{x:_>0?p:p-u*r,y:m,width:u*r,height:f},BOTTOM:{x:_>0?p:p-u*r,y:m+l*o*S,width:u*r,height:f},LEFT:{x:p,y:S>0?m:m-l*o,width:f,height:l*o},RIGHT:{x:p+u*r*_,y:S>0?m:m-l*o,width:f,height:l*o}}[t]}getCornersInScreenSpace(t,e){const[r,o]=e?hn(e):[1,1],{width:u,height:l,boxSize:f}=this,[p,m]=Jt(e),[_,S]=xi(e);return{TOPLEFT:{x:p-f,y:m-f,width:f*2,height:f*2},TOPRIGHT:{x:p-f+u*r*_,y:m-f,width:f*2,height:f*2},BOTTOMLEFT:{x:p-f,y:m-f+l*o*S,width:f*2,height:f*2},BOTTOMRIGHT:{x:p-f+u*r*_,y:m-f+l*o*S,width:f*2,height:f*2}}[t]}setPassive(){this.mode=Zt.PASSIVE,this.removeCorners()}setActive(){this.mode=Zt.ACTIVE,this.addCorners()}getPositions(){return this.target.getPositions()}hitTest(t,e,r){if(this.mode===Zt.PASSIVE)return;const[o,u]=hn(this.target.worldMatrix),[l,f]=xi(this.target.worldMatrix),[p,m]=Jt(r,t,e),_=4;for(const Q of wi){const et=this.getCornersInScreenSpace(Q,this.target.worldMatrix);if(p>=et.x-_&&p<=et.x+et.width+_&&m>=et.y-_&&m<=et.y+et.height+_)return Q}for(const Q of Or){const et=this.getSidesInScreenSpace(Q,this.target.worldMatrix);if(p>=et.x-_&&p<=et.x+et.width+_&&m>=et.y-_&&m<=et.y+et.height+_)return Q}const[S,R]=Jt(this.target.worldMatrix),I=this.width*o*l,j=this.height*u*f,V=Math.min(S,S+I),W=Math.max(S,S+I),tt=Math.min(R,R+j),ot=Math.max(R,R+j);if(p>=V&&p<=W&&m>=tt&&m<=ot)return"CENTER"}update(){this.updateSides(),this.updateCorners()}render(t,e){this.update();for(const[r,o]of this.sides.entries())o.render(t,e);for(const[r,o]of this.corners.entries())o.render(t,e)}destroy(){for(const[t,e]of this.sides.entries())e.destroy();for(const[t,e]of this.corners.entries())e.destroy()}move(t,e){this.target.updateTranslation(t,e)}resize(t,e,r){if(this.target instanceof We){const o=Math.abs(this.width),u=Math.abs(this.height),l=o/u,f=this.target.sx,p=this.target.sy,m=1e-6,_=Math.abs(o*f)<m?m*ki(o*f||1,m):o*f,S=Math.abs(u*p)<m?m*ki(u*p||1,m):u*p,R=t/_,I=e/S,j=m,V=r==="LEFT"||r==="BOTTOMLEFT"||r==="TOPLEFT"?1-R:r==="RIGHT"||r==="BOTTOMRIGHT"||r==="TOPRIGHT"?1+R:r==="TOP"?1-I:1+I;if(Ii(f,V,j)||Ii(p,V,j))return;const W=o*f*V,tt=u*p*V;if(Math.abs(W)<j||Math.abs(tt)<j)return;if(this.target.updateScale(V,V),r==="LEFT"){const ot=u*p,Q=u*this.target.sy;this.target.updateTranslation(t,(ot-Q)/2)}else if(r==="RIGHT"){const ot=u*p,Q=u*this.target.sy;this.target.updateTranslation(0,(ot-Q)/2)}else if(r==="TOP"){const ot=o*f,Q=o*this.target.sx;this.target.updateTranslation((ot-Q)/2,e)}else if(r==="BOTTOM"){const ot=o*f,Q=o*this.target.sx;this.target.updateTranslation((ot-Q)/2,0)}else r==="BOTTOMLEFT"?this.target.updateTranslation(t,0):r==="TOPLEFT"?this.target.updateTranslation(t,t/l*Math.sign(this.target.sx)):r==="TOPRIGHT"&&this.target.updateTranslation(0,-t/l*Math.sign(this.target.sx))}}reset(){this.target.setScale(1,1)}flip(t){const{x:e,y:r,sx:o,sy:u}=this.target;return t==="vertical"?this.target.flipVertical(this.height):this.target.flipHorizontal(this.width),{ref:this.target,start:{x:e,y:r,sx:o,sy:u},end:{x:this.target.x,y:this.target.y,sx:this.target.sx,sy:this.target.sy}}}addCorners(){for(const t of wi){const e=new We(this.getCornersInScreenSpace(t,this.target.worldMatrix));e.color=this.mode===Zt.ACTIVE?Nn:mi,this.corners.set(t,e)}}removeCorners(){this.corners.clear()}updateCorners(){for(const t of wi){const e=this.getCornersInScreenSpace(t,this.target.worldMatrix),r=this.corners.get(t);r&&(r.setTranslation(e.x,e.y),r.width=e.width,r.height=e.height,r.color=this.mode===Zt.ACTIVE?Nn:mi)}}addSides(){for(const t of Or){const e=new We(this.getSidesInScreenSpace(t,this.target.worldMatrix));e.color=this.mode===Zt.ACTIVE?Nn:mi,this.sides.set(t,e)}}updateSides(){for(const t of Or){const e=this.getSidesInScreenSpace(t,this.target.worldMatrix),r=this.sides.get(t);r&&(r.setTranslation(e.x,e.y),r.width=e.width,r.height=e.height,r.color=this.mode===Zt.ACTIVE?Nn:mi)}}}const Hs=[...wi,...Or];class xl{constructor(t){this.targets=[],this.handles=new Map,this.borderSize=0,this.boxSize=0,this.scale=[1,1],t&&t.forEach(e=>this.add(e)),this.addHandles()}add(t){this.targets.includes(t)||this.targets.push(t)}remove(t){const e=this.targets.indexOf(t);e!=-1&&this.targets.splice(e,1)}render(t,e){this.update();for(const[r,o]of this.handles.entries())o.render(t,e)}update(){this.borderSize=wo,this.boxSize=vu/2,this.recalculateBounds(),this.updateHandles()}destroy(){for(const[t,e]of this.handles.entries())e.destroy()}move(t,e){for(const r of this.targets)r.updateTranslation(t,e)}resize(t,e,r,o){const u=this.width,l=this.height,f=r.includes("TOP"),p=r.includes("BOTTOM"),m=r.includes("LEFT"),_=r.includes("RIGHT"),S=m?this.x+u:_?this.x:this.x+u/2,R=f?this.y+l:p?this.y:this.y+l/2,I=1e-6,j=Math.abs(u)<I?u<0?-I:I:u,V=Math.abs(l)<I?l<0?-I:I:l,[W,tt]=hn(o),ot=t*W/j,Q=e*tt/V,et=r.includes("LEFT")?1-ot:r.includes("RIGHT")?1+ot:r==="TOP"?1-Q:1+Q;if(Ii(this.scale[0],et,I)||Ii(this.scale[1],et,I))return;const At=u*et,Et=l*et;if(!(Math.abs(At)<I||Math.abs(Et)<I))for(const yt of this.targets){const Fr=yt.x,as=yt.y,[er,nr]=Jt(o,Fr,as),Ge=S+(er-S)*et,ve=R+(nr-R)*et,us=Ge-er,rr=ve-nr,ir=Math.abs(W)<I?W<0?-I:I:W,cs=Math.abs(tt)<I?tt<0?-I:I:tt,me=us/ir,Re=rr/cs;yt.updateScale(et,et),yt.updateTranslation(me,Re)}}flip(t,e,r){hn(t);const o=[],[u,l]=r(this.x,this.y);for(const f of this.targets){const p={ref:f,start:{x:f.x,y:f.y,sx:f.sx,sy:f.sy}};if(e==="vertical"){const m=f.height*f.sy;f.setTranslation(f.x,-f.y-m),f.flipVertical(f.height)}else{const m=f.width*f.sx;f.setTranslation(-f.x-m,f.y),f.flipHorizontal(f.width)}p.end={x:f.x,y:f.y,sx:f.sx,sy:f.sy},o.push(p)}return o}align(t){if(this.targets.length<=1)return;const e=[],r=[t==="top"?1:t==="bottom"?-1:0,t==="left"?1:t==="right"?-1:0];let o=r[0]!==0?1/0*r[0]:1/0*r[1];for(const[u,l]of this.targets.entries()){const f=l.getBoundingBox();o=t==="top"||t==="left"?Math.min(t==="top"?f.minY:f.minX,o):Math.max(t==="bottom"?f.maxY:f.maxX,o)}for(const u of this.targets){const l={ref:u,start:{x:u.x,y:u.y,sx:u.sx,sy:u.sy}},f=u.getBoundingBox();u.updateTranslation(t==="top"||t==="bottom"?0:o-(t==="left"?f.minX:f.maxX),t==="top"||t==="bottom"?o-(t==="top"?f.minY:f.maxY):0),l.end={x:u.x,y:u.y,sx:u.sx,sy:u.sy},e.push(l)}return e}normalize(t,e){const r=[],o=this.targets[0],u=t==="height"?e==="first"?o.height*o.sy:this.targets.reduce((l,f)=>l+Math.abs(f.height*f.sy),0)/this.targets.length:t==="width"?e==="first"?o.width*o.sx:this.targets.reduce((l,f)=>l+Math.abs(f.width*f.sx),0)/this.targets.length:t==="scale"?e==="first"?o.sx:this.targets.reduce((l,f)=>l+Math.abs(f.sx),0)/this.targets.length:e==="first"?o.width*o.height*o.sx*o.sy:this.targets.reduce((l,f)=>l+Math.abs(f.sx*f.width*f.height*f.sy),0)/this.targets.length;for(const l of this.targets){const f={ref:l,start:{x:l.x,y:l.y,sx:l.sx,sy:l.sy}},p=[(l.x+l.width*l.sx)/2,(l.y+l.height*l.sy)/2];if(t==="height"){const _=l.height*l.sy,S=Math.abs(u/_);l.updateScale(S,S)}else if(t==="width"){const _=l.width*l.sx,S=Math.abs(u/_);l.updateScale(S,S)}else if(t==="scale"){const _=Math.sign(l.sx),S=Math.sign(l.sy);l.setScale(u*_,u*S)}else if(t==="size"){const _=l.width*l.height*l.sx*l.sy,S=Math.sqrt(Math.abs(u/_));l.updateScale(S,S)}const m=[(l.x+l.width*l.sx)/2,(l.y+l.height*l.sy)/2];l.updateTranslation(p[0]-m[0],p[1]-m[1]),f.end={x:l.x,y:l.y,sx:l.sx,sy:l.sy},r.push(f)}return r}getPositions(){return[this.x,this.y,this.x+this.width,this.y,this.x+this.width,this.y+this.height,this.x,this.y+this.height]}hitTest(t,e,r){const[o,u]=Jt(r,t,e),l=4;for(const S of Hs){const R=this.getHandleConfig(S);if(o>=R.x-l&&o<=R.x+R.width+l&&u>=R.y-l&&u<=R.y+R.height+l)return S}const f=Math.min(this.x,this.x+this.width),p=Math.max(this.x,this.x+this.width),m=Math.min(this.y,this.y+this.height),_=Math.max(this.y,this.y+this.height);if(o>=f&&o<=p&&u>=m&&u<=_)return"CENTER"}getBounds(){const t=Array.from(this.targets);let e=1/0,r=1/0,o=-1/0,u=-1/0;for(const l of t){const[f,p]=Jt(l.worldMatrix),[m,_]=Jt(l.worldMatrix,l.width,l.height);e=Math.min(e,l.sx<0?m:f),r=Math.min(r,l.sy<0?_:p),o=Math.max(o,l.sx<0?f:m),u=Math.max(u,l.sy<0?p:_)}return{minX:e,minY:r,maxX:o,maxY:u}}recalculateBounds(){const{minX:t,minY:e,maxX:r,maxY:o}=this.getBounds();this.x=this.scale[0]<0?r:t,this.y=this.scale[1]<0?o:e,this.width=this.scale[0]*(r-t),this.height=this.scale[1]*(o-e)}addHandles(){for(const t of Hs){const e=this.getHandleConfig(t),r=new We(e);r.color=Nn,this.handles.set(t,r)}}updateHandles(){for(const t of Hs){const e=this.handles.get(t),r=this.getHandleConfig(t);e&&(e.setTranslation(r.x,r.y),e.width=r.width,e.height=r.height)}}getHandleConfig(t){let{x:e,y:r,width:o,height:u,borderSize:l,boxSize:f}=this;return{TOP:{x:e,y:r,width:o,height:l},BOTTOM:{x:e,y:r+u,width:o,height:l},LEFT:{x:e,y:r,width:l,height:u},RIGHT:{x:e+o,y:r,width:l,height:u},TOPLEFT:{x:e-f,y:r-f,width:f*2,height:f*2},TOPRIGHT:{x:e-f+o,y:r-f,width:f*2,height:f*2},BOTTOMLEFT:{x:e-f,y:r-f+u,width:f*2,height:f*2},BOTTOMRIGHT:{x:e-f+o,y:r-f+u,width:f*2,height:f*2}}[t]}}class dn{constructor(t,e,r,o){this.minX=t,this.minY=e,this.maxX=r,this.maxY=o}getArea(){return(this.maxY-this.minY)*(this.maxX-this.minX)}static isColliding(t,e){return t.minX<=e.maxX&&t.maxX>=e.minX&&t.minY<=e.maxY&&t.maxY>=e.minY}}const Ta=["CENTER",...Or];class Sl{constructor(t,e,r){this.width=0,this.height=0,this.rects=new Map,this.borderSize=0;const[o,u]=Jt(r,t,e);this.x=o,this.y=u,this.addRects()}getRectConfig(t){let{x:e,y:r,width:o,height:u,borderSize:l}=this;return{TOP:{x:e,y:r,width:o<0?o:o+l,height:l},BOTTOM:{x:e,y:r+u,width:o<0?o:o+l,height:l},LEFT:{x:u<0&&o<0?e-l:e,y:r,width:l,height:u<0&&o<0?u:u+l},RIGHT:{x:e+o,y:r,width:l,height:u<0?u:u+l},CENTER:{x:e,y:r,width:o,height:u}}[t]}render(t,e){this.update();for(const[r,o]of this.rects.entries())o.render(t,e)}update(){this.borderSize=wo,this.updateRects()}destroy(){for(const[t,e]of this.rects.entries())e.destroy()}getBoundingBox(t){const[e,r]=t(this.x,this.y),[o,u]=t(this.x+this.width,this.y+this.height),l=Math.min(e,o),f=Math.max(e,o),p=Math.min(r,u),m=Math.max(r,u);return new dn(l,p,f,m)}resize(t,e,r){const[o,u]=hn(r);this.width+=t*o,this.height+=e*u}addRects(){for(const t of Ta){const e=this.getRectConfig(t),r=new We(e);r.color=Nn,this.rects.set(t,r)}}updateRects(){for(const t of Ta){const e=this.rects.get(t),r=this.getRectConfig(t);e&&(e.setTranslation(r.x,r.y),e.width=r.width,e.height=r.height,t==="CENTER"&&(e.color=ll))}}}function ht(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r<t;r++)e[r-1]=arguments[r];throw new Error(typeof n=="number"?"[MobX] minified error nr: "+n+(e.length?" "+e.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+n)}var Ol={};function So(){return typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:Ol}var _u=Object.assign,Bi=Object.getOwnPropertyDescriptor,fe=Object.defineProperty,Gi=Object.prototype,io=[];Object.freeze(io);var Oo={};Object.freeze(Oo);var Al=typeof Proxy<"u",El=Object.toString();function bu(){Al||ht("Proxy not available")}function wu(n){var t=!1;return function(){if(!t)return t=!0,n.apply(this,arguments)}}var Un=function(){};function ne(n){return typeof n=="function"}function pn(n){var t=typeof n;switch(t){case"string":case"symbol":case"number":return!0}return!1}function Hi(n){return n!==null&&typeof n=="object"}function Ve(n){if(!Hi(n))return!1;var t=Object.getPrototypeOf(n);if(t==null)return!0;var e=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e.toString()===El}function xu(n){var t=n?.constructor;return t?t.name==="GeneratorFunction"||t.displayName==="GeneratorFunction":!1}function Xi(n,t,e){fe(n,t,{enumerable:!1,writable:!0,configurable:!0,value:e})}function Su(n,t,e){fe(n,t,{enumerable:!1,writable:!1,configurable:!0,value:e})}function _n(n,t){var e="isMobX"+n;return t.prototype[e]=!0,function(r){return Hi(r)&&r[e]===!0}}function Qn(n){return n!=null&&Object.prototype.toString.call(n)==="[object Map]"}function Cl(n){var t=Object.getPrototypeOf(n),e=Object.getPrototypeOf(t),r=Object.getPrototypeOf(e);return r===null}function Ee(n){return n!=null&&Object.prototype.toString.call(n)==="[object Set]"}var Ou=typeof Object.getOwnPropertySymbols<"u";function Tl(n){var t=Object.keys(n);if(!Ou)return t;var e=Object.getOwnPropertySymbols(n);return e.length?[].concat(t,e.filter(function(r){return Gi.propertyIsEnumerable.call(n,r)})):t}var Yi=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Ou?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames;function Au(n){return n===null?null:typeof n=="object"?""+n:n}function Te(n,t){return Gi.hasOwnProperty.call(n,t)}var Ml=Object.getOwnPropertyDescriptors||function(t){var e={};return Yi(t).forEach(function(r){e[r]=Bi(t,r)}),e};function zt(n,t){return!!(n&t)}function Kt(n,t,e){return e?n|=t:n&=~t,n}function Ma(n,t){(t==null||t>n.length)&&(t=n.length);for(var e=0,r=Array(t);e<t;e++)r[e]=n[e];return r}function Pl(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,kl(r.key),r)}}function Jn(n,t,e){return t&&Pl(n.prototype,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function Fn(n,t){var e=typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(e)return(e=e.call(n)).next.bind(e);if(Array.isArray(n)||(e=Il(n))||t){e&&(n=e);var r=0;return function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
148
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vn(){return vn=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)({}).hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},vn.apply(null,arguments)}function Eu(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,so(n,t)}function so(n,t){return so=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},so(n,t)}function Rl(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var r=e.call(n,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function kl(n){var t=Rl(n,"string");return typeof t=="symbol"?t:t+""}function Il(n,t){if(n){if(typeof n=="string")return Ma(n,t);var e={}.toString.call(n).slice(8,-1);return e==="Object"&&n.constructor&&(e=n.constructor.name),e==="Map"||e==="Set"?Array.from(n):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ma(n,t):void 0}}var he=Symbol("mobx-stored-annotations");function de(n){function t(e,r){if(Lr(r))return n.decorate_20223_(e,r);Br(e,r,n)}return Object.assign(t,n)}function Br(n,t,e){Te(n,he)||Xi(n,he,vn({},n[he])),Ul(e)||(n[he][t]=e)}function Dl(n){return Te(n,he)||Xi(n,he,vn({},n[he])),n[he]}function Lr(n){return typeof n=="object"&&typeof n.kind=="string"}var J=Symbol("mobx administration"),qe=(function(){function n(e){e===void 0&&(e="Atom"),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=lt.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=n.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(r){return r()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(r){return r()})},t.reportObserved=function(){return Fu(this)},t.reportChanged=function(){Ht(),zu(this),Xt()},t.toString=function(){return this.name_},Jn(n,[{key:"isBeingObserved",get:function(){return zt(this.flags_,n.isBeingObservedMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isBeingObservedMask_,r)}},{key:"isPendingUnobservation",get:function(){return zt(this.flags_,n.isPendingUnobservationMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isPendingUnobservationMask_,r)}},{key:"diffValue",get:function(){return zt(this.flags_,n.diffValueMask_)?1:0},set:function(r){this.flags_=Kt(this.flags_,n.diffValueMask_,r===1)}}])})();qe.isBeingObservedMask_=1;qe.isPendingUnobservationMask_=2;qe.diffValueMask_=4;var Ao=_n("Atom",qe);function Cu(n,t,e){t===void 0&&(t=Un),e===void 0&&(e=Un);var r=new qe(n);return t!==Un&&Vh(r,t),e!==Un&&Hu(r,e),r}function Bl(n,t){return oc(n,t)}function Ll(n,t){return Object.is?Object.is(n,t):n===t?n!==0||1/n===1/t:n!==n&&t!==t}var qn={structural:Bl,default:Ll};function mn(n,t,e){return Zu(n)?n:Array.isArray(n)?dt.array(n,{name:e}):Ve(n)?dt.object(n,void 0,{name:e}):Qn(n)?dt.map(n,{name:e}):Ee(n)?dt.set(n,{name:e}):typeof n=="function"&&!Gn(n)&&!Rr(n)?xu(n)?Hn(n):Pr(e,n):n}function jl(n,t,e){if(n==null||rs(n)||ns(n)||wn(n)||le(n))return n;if(Array.isArray(n))return dt.array(n,{name:e,deep:!1});if(Ve(n))return dt.object(n,void 0,{name:e,deep:!1});if(Qn(n))return dt.map(n,{name:e,deep:!1});if(Ee(n))return dt.set(n,{name:e,deep:!1})}function Zi(n){return n}function $l(n,t){return oc(n,t)?t:n}var Nl="override";function Ul(n){return n.annotationType_===Nl}function jr(n,t){return{annotationType_:n,options_:t,make_:Fl,extend_:zl,decorate_20223_:Kl}}function Fl(n,t,e,r){var o;if((o=this.options_)!=null&&o.bound)return this.extend_(n,t,e,!1)===null?0:1;if(r===n.target_)return this.extend_(n,t,e,!1)===null?0:2;if(Gn(e.value))return 1;var u=Tu(n,this,t,e,!1);return fe(r,t,u),2}function zl(n,t,e,r){var o=Tu(n,this,t,e);return n.defineProperty_(t,o,r)}function Kl(n,t){var e=t.kind,r=t.name,o=t.addInitializer,u=this,l=function(m){var _,S,R,I;return gn((_=(S=u.options_)==null?void 0:S.name)!=null?_:r.toString(),m,(R=(I=u.options_)==null?void 0:I.autoAction)!=null?R:!1)};if(e=="field")return function(p){var m,_=p;return Gn(_)||(_=l(_)),(m=u.options_)!=null&&m.bound&&(_=_.bind(this),_.isMobxAction=!0),_};if(e=="method"){var f;return Gn(n)||(n=l(n)),(f=this.options_)!=null&&f.bound&&o(function(){var p=this,m=p[r].bind(p);m.isMobxAction=!0,p[r]=m}),n}ht("Cannot apply '"+u.annotationType_+"' to '"+String(r)+"' (kind: "+e+"):"+(`
|
|
149
|
-
'`+u.annotationType_+"' can only be used on properties with a function value."))}function Wl(n,t,e,r){t.annotationType_,r.value}function Tu(n,t,e,r,o){var u,l,f,p,m,_,S;o===void 0&&(o=H.safeDescriptors),Wl(n,t,e,r);var R=r.value;if((u=t.options_)!=null&&u.bound){var I;R=R.bind((I=n.proxy_)!=null?I:n.target_)}return{value:gn((l=(f=t.options_)==null?void 0:f.name)!=null?l:e.toString(),R,(p=(m=t.options_)==null?void 0:m.autoAction)!=null?p:!1,(_=t.options_)!=null&&_.bound?(S=n.proxy_)!=null?S:n.target_:void 0),configurable:o?n.isPlainObject_:!0,enumerable:!1,writable:!o}}function Mu(n,t){return{annotationType_:n,options_:t,make_:Vl,extend_:ql,decorate_20223_:Gl}}function Vl(n,t,e,r){var o;if(r===n.target_)return this.extend_(n,t,e,!1)===null?0:2;if((o=this.options_)!=null&&o.bound&&(!Te(n.target_,t)||!Rr(n.target_[t]))&&this.extend_(n,t,e,!1)===null)return 0;if(Rr(e.value))return 1;var u=Pu(n,this,t,e,!1,!1);return fe(r,t,u),2}function ql(n,t,e,r){var o,u=Pu(n,this,t,e,(o=this.options_)==null?void 0:o.bound);return n.defineProperty_(t,u,r)}function Gl(n,t){var e,r=t.name,o=t.addInitializer;return Rr(n)||(n=Hn(n)),(e=this.options_)!=null&&e.bound&&o(function(){var u=this,l=u[r].bind(u);l.isMobXFlow=!0,u[r]=l}),n}function Hl(n,t,e,r){t.annotationType_,r.value}function Pu(n,t,e,r,o,u){u===void 0&&(u=H.safeDescriptors),Hl(n,t,e,r);var l=r.value;if(Rr(l)||(l=Hn(l)),o){var f;l=l.bind((f=n.proxy_)!=null?f:n.target_),l.isMobXFlow=!0}return{value:l,configurable:u?n.isPlainObject_:!0,enumerable:!1,writable:!u}}function Eo(n,t){return{annotationType_:n,options_:t,make_:Xl,extend_:Yl,decorate_20223_:Zl}}function Xl(n,t,e){return this.extend_(n,t,e,!1)===null?0:1}function Yl(n,t,e,r){return Ql(n,this,t,e),n.defineComputedProperty_(t,vn({},this.options_,{get:e.get,set:e.set}),r)}function Zl(n,t){var e=this,r=t.name,o=t.addInitializer;return o(function(){var u=tr(this)[J],l=vn({},e.options_,{get:n,context:this});l.name||(l.name="ObservableObject."+r.toString()),u.values_.set(r,new re(l))}),function(){return this[J].getObservablePropValue_(r)}}function Ql(n,t,e,r){t.annotationType_,r.get}function Qi(n,t){return{annotationType_:n,options_:t,make_:Jl,extend_:th,decorate_20223_:eh}}function Jl(n,t,e){return this.extend_(n,t,e,!1)===null?0:1}function th(n,t,e,r){var o,u;return nh(n,this),n.defineObservableProperty_(t,e.value,(o=(u=this.options_)==null?void 0:u.enhancer)!=null?o:mn,r)}function eh(n,t){var e=this,r=t.kind,o=t.name,u=new WeakSet;function l(f,p){var m,_,S=tr(f)[J],R=new fn(p,(m=(_=e.options_)==null?void 0:_.enhancer)!=null?m:mn,"ObservableObject."+o.toString(),!1);S.values_.set(o,R),u.add(f)}if(r=="accessor")return{get:function(){return u.has(this)||l(this,n.get.call(this)),this[J].getObservablePropValue_(o)},set:function(p){return u.has(this)||l(this,p),this[J].setObservablePropValue_(o,p)},init:function(p){return u.has(this)||l(this,p),p}}}function nh(n,t,e,r){t.annotationType_}var rh="true",ih=Ru();function Ru(n){return{annotationType_:rh,options_:n,make_:sh,extend_:oh,decorate_20223_:ah}}function sh(n,t,e,r){var o,u;if(e.get)return ce.make_(n,t,e,r);if(e.set){var l=Gn(e.set)?e.set:gn(t.toString(),e.set);return r===n.target_?n.defineProperty_(t,{configurable:H.safeDescriptors?n.isPlainObject_:!0,set:l})===null?0:2:(fe(r,t,{configurable:!0,set:l}),2)}if(r!==n.target_&&typeof e.value=="function"){var f;if(xu(e.value)){var p,m=(p=this.options_)!=null&&p.autoBind?Hn.bound:Hn;return m.make_(n,t,e,r)}var _=(f=this.options_)!=null&&f.autoBind?Pr.bound:Pr;return _.make_(n,t,e,r)}var S=((o=this.options_)==null?void 0:o.deep)===!1?dt.ref:dt;if(typeof e.value=="function"&&(u=this.options_)!=null&&u.autoBind){var R;e.value=e.value.bind((R=n.proxy_)!=null?R:n.target_)}return S.make_(n,t,e,r)}function oh(n,t,e,r){var o,u;if(e.get)return ce.extend_(n,t,e,r);if(e.set)return n.defineProperty_(t,{configurable:H.safeDescriptors?n.isPlainObject_:!0,set:gn(t.toString(),e.set)},r);if(typeof e.value=="function"&&(o=this.options_)!=null&&o.autoBind){var l;e.value=e.value.bind((l=n.proxy_)!=null?l:n.target_)}var f=((u=this.options_)==null?void 0:u.deep)===!1?dt.ref:dt;return f.extend_(n,t,e,r)}function ah(n,t){ht("'"+this.annotationType_+"' cannot be used as a decorator")}var uh="observable",ch="observable.ref",lh="observable.shallow",hh="observable.struct",ku={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(ku);function gi(n){return n||ku}var oo=Qi(uh),fh=Qi(ch,{enhancer:Zi}),dh=Qi(lh,{enhancer:jl}),ph=Qi(hh,{enhancer:$l}),Iu=de(oo);function yi(n){return n.deep===!0?mn:n.deep===!1?Zi:mh(n.defaultDecorator)}function vh(n){var t;return n?(t=n.defaultDecorator)!=null?t:Ru(n):void 0}function mh(n){var t,e;return n&&(t=(e=n.options_)==null?void 0:e.enhancer)!=null?t:mn}function Du(n,t,e){if(Lr(t))return oo.decorate_20223_(n,t);if(pn(t)){Br(n,t,oo);return}return Zu(n)?n:Ve(n)?dt.object(n,t,e):Array.isArray(n)?dt.array(n,t):Qn(n)?dt.map(n,t):Ee(n)?dt.set(n,t):typeof n=="object"&&n!==null?n:dt.box(n,t)}_u(Du,Iu);var gh={box:function(t,e){var r=gi(e);return new fn(t,yi(r),r.name,!0,r.equals)},array:function(t,e){var r=gi(e);return(H.useProxies===!1||r.proxy===!1?hf:tf)(t,yi(r),r.name)},map:function(t,e){var r=gi(e);return new tc(t,yi(r),r.name)},set:function(t,e){var r=gi(e);return new ec(t,yi(r),r.name)},object:function(t,e,r){return xn(function(){return qh(H.useProxies===!1||r?.proxy===!1?tr({},r):Zh({},r),t,e)})},ref:de(fh),shallow:de(dh),deep:Iu,struct:de(ph)},dt=_u(Du,gh),Bu="computed",yh="computed.struct",ao=Eo(Bu),_h=Eo(yh,{equals:qn.structural}),ce=function(t,e){if(Lr(e))return ao.decorate_20223_(t,e);if(pn(e))return Br(t,e,ao);if(Ve(t))return de(Eo(Bu,t));var r=Ve(e)?e:{};return r.get=t,r.name||(r.name=t.name||""),new re(r)};Object.assign(ce,ao);ce.struct=de(_h);var Pa,Ra,Li=0,bh=1,wh=(Pa=(Ra=Bi(function(){},"name"))==null?void 0:Ra.configurable)!=null?Pa:!1,ka={value:"action",configurable:!0,writable:!1,enumerable:!1};function gn(n,t,e,r){e===void 0&&(e=!1);function o(){return xh(n,e,t,r||this,arguments)}return o.isMobxAction=!0,o.toString=function(){return t.toString()},wh&&(ka.value=n,fe(o,"name",ka)),o}function xh(n,t,e,r,o){var u=Sh(n,t);try{return e.apply(r,o)}catch(l){throw u.error_=l,l}finally{Oh(u)}}function Sh(n,t,e,r){var o=!1,u=0,l=H.trackingDerivation,f=!t||!l;Ht();var p=H.allowStateChanges;f&&(bn(),p=Ji(!0));var m=Co(!0),_={runAsAction_:f,prevDerivation_:l,prevAllowStateChanges_:p,prevAllowStateReads_:m,notifySpy_:o,startTime_:u,actionId_:bh++,parentActionId_:Li};return Li=_.actionId_,_}function Oh(n){Li!==n.actionId_&&ht(30),Li=n.parentActionId_,n.error_!==void 0&&(H.suppressReactionErrors=!0),ts(n.prevAllowStateChanges_),Ar(n.prevAllowStateReads_),Xt(),n.runAsAction_&&Me(n.prevDerivation_),H.suppressReactionErrors=!1}function Ah(n,t){var e=Ji(n);try{return t()}finally{ts(e)}}function Ji(n){var t=H.allowStateChanges;return H.allowStateChanges=n,t}function ts(n){H.allowStateChanges=n}var fn=(function(n){function t(r,o,u,l,f){var p;return u===void 0&&(u="ObservableValue"),f===void 0&&(f=qn.default),p=n.call(this,u)||this,p.enhancer=void 0,p.name_=void 0,p.equals=void 0,p.hasUnreportedChange_=!1,p.interceptors_=void 0,p.changeListeners_=void 0,p.value_=void 0,p.dehancer=void 0,p.enhancer=o,p.name_=u,p.equals=f,p.value_=o(r,void 0,u),p}Eu(t,n);var e=t.prototype;return e.dehanceValue=function(o){return this.dehancer!==void 0?this.dehancer(o):o},e.set=function(o){this.value_,o=this.prepareNewValue_(o),o!==H.UNCHANGED&&this.setNewValue_(o)},e.prepareNewValue_=function(o){if(qt(this)){var u=Gt(this,{object:this,type:pe,newValue:o});if(!u)return H.UNCHANGED;o=u.newValue}return o=this.enhancer(o,this.value_,this.name_),this.equals(this.value_,o)?H.UNCHANGED:o},e.setNewValue_=function(o){var u=this.value_;this.value_=o,this.reportChanged(),te(this)&&ee(this,{type:pe,object:this,newValue:o,oldValue:u})},e.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},e.intercept_=function(o){return $r(this,o)},e.observe_=function(o,u){return u&&o({observableKind:"value",debugObjectName:this.name_,object:this,type:pe,newValue:this.value_,oldValue:void 0}),Nr(this,o)},e.raw=function(){return this.value_},e.toJSON=function(){return this.get()},e.toString=function(){return this.name_+"["+this.value_+"]"},e.valueOf=function(){return Au(this.get())},e[Symbol.toPrimitive]=function(){return this.valueOf()},t})(qe),re=(function(){function n(e){this.dependenciesState_=lt.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=lt.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new $i(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=ji.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||ht(31),this.derivation=e.get,this.name_=e.name||"ComputedValue",e.set&&(this.setter_=gn("ComputedValue-setter",e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?qn.structural:qn.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=n.prototype;return t.onBecomeStale_=function(){Mh(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(r){return r()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(r){return r()})},t.get=function(){if(this.isComputing&&ht(32,this.name_,this.derivation),H.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)uo(this)&&(this.warnAboutUntrackedRead_(),Ht(),this.value_=this.computeValue_(!1),Xt());else if(Fu(this),uo(this)){var r=H.trackingContext;this.keepAlive_&&!r&&(H.trackingContext=this),this.trackAndCompute()&&Th(this),H.trackingContext=r}var o=this.value_;if(Si(o))throw o.cause;return o},t.set=function(r){if(this.setter_){this.isRunningSetter&&ht(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,r)}finally{this.isRunningSetter=!1}}else ht(34,this.name_)},t.trackAndCompute=function(){var r=this.value_,o=this.dependenciesState_===lt.NOT_TRACKING_,u=this.computeValue_(!0),l=o||Si(r)||Si(u)||!this.equals_(r,u);return l&&(this.value_=u),l},t.computeValue_=function(r){this.isComputing=!0;var o=Ji(!1),u;if(r)u=Lu(this,this.derivation,this.scope_);else if(H.disableErrorBoundaries===!0)u=this.derivation.call(this.scope_);else try{u=this.derivation.call(this.scope_)}catch(l){u=new $i(l)}return ts(o),this.isComputing=!1,u},t.suspend_=function(){this.keepAlive_||(co(this),this.value_=void 0)},t.observe_=function(r,o){var u=this,l=!0,f=void 0;return Nh(function(){var p=u.get();if(!l||o){var m=bn();r({observableKind:"computed",debugObjectName:u.name_,type:pe,object:u,newValue:p,oldValue:f}),Me(m)}l=!1,f=p})},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return Au(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},Jn(n,[{key:"isComputing",get:function(){return zt(this.flags_,n.isComputingMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isComputingMask_,r)}},{key:"isRunningSetter",get:function(){return zt(this.flags_,n.isRunningSetterMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isRunningSetterMask_,r)}},{key:"isBeingObserved",get:function(){return zt(this.flags_,n.isBeingObservedMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isBeingObservedMask_,r)}},{key:"isPendingUnobservation",get:function(){return zt(this.flags_,n.isPendingUnobservationMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isPendingUnobservationMask_,r)}},{key:"diffValue",get:function(){return zt(this.flags_,n.diffValueMask_)?1:0},set:function(r){this.flags_=Kt(this.flags_,n.diffValueMask_,r===1)}}])})();re.isComputingMask_=1;re.isRunningSetterMask_=2;re.isBeingObservedMask_=4;re.isPendingUnobservationMask_=8;re.diffValueMask_=16;var es=_n("ComputedValue",re),lt;(function(n){n[n.NOT_TRACKING_=-1]="NOT_TRACKING_",n[n.UP_TO_DATE_=0]="UP_TO_DATE_",n[n.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",n[n.STALE_=2]="STALE_"})(lt||(lt={}));var ji;(function(n){n[n.NONE=0]="NONE",n[n.LOG=1]="LOG",n[n.BREAK=2]="BREAK"})(ji||(ji={}));var $i=function(t){this.cause=void 0,this.cause=t};function Si(n){return n instanceof $i}function uo(n){switch(n.dependenciesState_){case lt.UP_TO_DATE_:return!1;case lt.NOT_TRACKING_:case lt.STALE_:return!0;case lt.POSSIBLY_STALE_:{for(var t=Co(!0),e=bn(),r=n.observing_,o=r.length,u=0;u<o;u++){var l=r[u];if(es(l)){if(H.disableErrorBoundaries)l.get();else try{l.get()}catch{return Me(e),Ar(t),!0}if(n.dependenciesState_===lt.STALE_)return Me(e),Ar(t),!0}}return $u(n),Me(e),Ar(t),!1}}}function Lu(n,t,e){var r=Co(!0);$u(n),n.newObserving_=new Array(n.runId_===0?100:n.observing_.length),n.unboundDepsCount_=0,n.runId_=++H.runId;var o=H.trackingDerivation;H.trackingDerivation=n,H.inBatch++;var u;if(H.disableErrorBoundaries===!0)u=t.call(e);else try{u=t.call(e)}catch(l){u=new $i(l)}return H.inBatch--,H.trackingDerivation=o,Eh(n),Ar(r),u}function Eh(n){for(var t=n.observing_,e=n.observing_=n.newObserving_,r=lt.UP_TO_DATE_,o=0,u=n.unboundDepsCount_,l=0;l<u;l++){var f=e[l];f.diffValue===0&&(f.diffValue=1,o!==l&&(e[o]=f),o++),f.dependenciesState_>r&&(r=f.dependenciesState_)}for(e.length=o,n.newObserving_=null,u=t.length;u--;){var p=t[u];p.diffValue===0&&Nu(p,n),p.diffValue=0}for(;o--;){var m=e[o];m.diffValue===1&&(m.diffValue=0,Ch(m,n))}r!==lt.UP_TO_DATE_&&(n.dependenciesState_=r,n.onBecomeStale_())}function co(n){var t=n.observing_;n.observing_=[];for(var e=t.length;e--;)Nu(t[e],n);n.dependenciesState_=lt.NOT_TRACKING_}function ju(n){var t=bn();try{return n()}finally{Me(t)}}function bn(){var n=H.trackingDerivation;return H.trackingDerivation=null,n}function Me(n){H.trackingDerivation=n}function Co(n){var t=H.allowStateReads;return H.allowStateReads=n,t}function Ar(n){H.allowStateReads=n}function $u(n){if(n.dependenciesState_!==lt.UP_TO_DATE_){n.dependenciesState_=lt.UP_TO_DATE_;for(var t=n.observing_,e=t.length;e--;)t[e].lowestObserverState_=lt.UP_TO_DATE_}}var Xs=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},Ys=!0,H=(function(){var n=So();return n.__mobxInstanceCount>0&&!n.__mobxGlobals&&(Ys=!1),n.__mobxGlobals&&n.__mobxGlobals.version!==new Xs().version&&(Ys=!1),Ys?n.__mobxGlobals?(n.__mobxInstanceCount+=1,n.__mobxGlobals.UNCHANGED||(n.__mobxGlobals.UNCHANGED={}),n.__mobxGlobals):(n.__mobxInstanceCount=1,n.__mobxGlobals=new Xs):(setTimeout(function(){ht(35)},1),new Xs)})();function Ch(n,t){n.observers_.add(t),n.lowestObserverState_>t.dependenciesState_&&(n.lowestObserverState_=t.dependenciesState_)}function Nu(n,t){n.observers_.delete(t),n.observers_.size===0&&Uu(n)}function Uu(n){n.isPendingUnobservation===!1&&(n.isPendingUnobservation=!0,H.pendingUnobservations.push(n))}function Ht(){H.inBatch++}function Xt(){if(--H.inBatch===0){Ku();for(var n=H.pendingUnobservations,t=0;t<n.length;t++){var e=n[t];e.isPendingUnobservation=!1,e.observers_.size===0&&(e.isBeingObserved&&(e.isBeingObserved=!1,e.onBUO()),e instanceof re&&e.suspend_())}H.pendingUnobservations=[]}}function Fu(n){var t=H.trackingDerivation;return t!==null?(t.runId_!==n.lastAccessedBy_&&(n.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=n,!n.isBeingObserved&&H.trackingContext&&(n.isBeingObserved=!0,n.onBO())),n.isBeingObserved):(n.observers_.size===0&&H.inBatch>0&&Uu(n),!1)}function zu(n){n.lowestObserverState_!==lt.STALE_&&(n.lowestObserverState_=lt.STALE_,n.observers_.forEach(function(t){t.dependenciesState_===lt.UP_TO_DATE_&&t.onBecomeStale_(),t.dependenciesState_=lt.STALE_}))}function Th(n){n.lowestObserverState_!==lt.STALE_&&(n.lowestObserverState_=lt.STALE_,n.observers_.forEach(function(t){t.dependenciesState_===lt.POSSIBLY_STALE_?t.dependenciesState_=lt.STALE_:t.dependenciesState_===lt.UP_TO_DATE_&&(n.lowestObserverState_=lt.UP_TO_DATE_)}))}function Mh(n){n.lowestObserverState_===lt.UP_TO_DATE_&&(n.lowestObserverState_=lt.POSSIBLY_STALE_,n.observers_.forEach(function(t){t.dependenciesState_===lt.UP_TO_DATE_&&(t.dependenciesState_=lt.POSSIBLY_STALE_,t.onBecomeStale_())}))}var Pe=(function(){function n(e,r,o,u){e===void 0&&(e="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=lt.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=ji.NONE,this.name_=e,this.onInvalidate_=r,this.errorHandler_=o,this.requiresObservable_=u}var t=n.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled||(this.isScheduled=!0,H.pendingReactions.push(this),Ku())},t.runReaction_=function(){if(!this.isDisposed){Ht(),this.isScheduled=!1;var r=H.trackingContext;if(H.trackingContext=this,uo(this)){this.isTrackPending=!0;try{this.onInvalidate_()}catch(o){this.reportExceptionInDerivation_(o)}}H.trackingContext=r,Xt()}},t.track=function(r){if(!this.isDisposed){Ht(),this.isRunning=!0;var o=H.trackingContext;H.trackingContext=this;var u=Lu(this,r,void 0);H.trackingContext=o,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&co(this),Si(u)&&this.reportExceptionInDerivation_(u.cause),Xt()}},t.reportExceptionInDerivation_=function(r){var o=this;if(this.errorHandler_){this.errorHandler_(r,this);return}if(H.disableErrorBoundaries)throw r;var u="[mobx] uncaught error in '"+this+"'";H.suppressReactionErrors||console.error(u,r),H.globalReactionErrorHandlers.forEach(function(l){return l(r,o)})},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(Ht(),co(this),Xt()))},t.getDisposer_=function(r){var o=this,u=function l(){o.dispose(),r==null||r.removeEventListener==null||r.removeEventListener("abort",l)};return r==null||r.addEventListener==null||r.addEventListener("abort",u),u[J]=this,"dispose"in Symbol&&typeof Symbol.dispose=="symbol"&&(u[Symbol.dispose]=u),u},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(r){},Jn(n,[{key:"isDisposed",get:function(){return zt(this.flags_,n.isDisposedMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isDisposedMask_,r)}},{key:"isScheduled",get:function(){return zt(this.flags_,n.isScheduledMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isScheduledMask_,r)}},{key:"isTrackPending",get:function(){return zt(this.flags_,n.isTrackPendingMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isTrackPendingMask_,r)}},{key:"isRunning",get:function(){return zt(this.flags_,n.isRunningMask_)},set:function(r){this.flags_=Kt(this.flags_,n.isRunningMask_,r)}},{key:"diffValue",get:function(){return zt(this.flags_,n.diffValueMask_)?1:0},set:function(r){this.flags_=Kt(this.flags_,n.diffValueMask_,r===1)}}])})();Pe.isDisposedMask_=1;Pe.isScheduledMask_=2;Pe.isTrackPendingMask_=4;Pe.isRunningMask_=8;Pe.diffValueMask_=16;var Ph=100,Rh=function(t){return t()};function Ku(){H.inBatch>0||H.isRunningReactions||Rh(kh)}function kh(){H.isRunningReactions=!0;for(var n=H.pendingReactions,t=0;n.length>0;){++t===Ph&&(console.error("[mobx] cycle in reaction: "+n[0]),n.splice(0));for(var e=n.splice(0),r=0,o=e.length;r<o;r++)e[r].runReaction_()}H.isRunningReactions=!1}var Ni=_n("Reaction",Pe);function Er(){return!1}function Ih(n){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}}var Wu="action",Dh="action.bound",Vu="autoAction",Bh="autoAction.bound",Lh="<unnamed action>",lo=jr(Wu),jh=jr(Dh,{bound:!0}),ho=jr(Vu,{autoAction:!0}),$h=jr(Bh,{autoAction:!0,bound:!0});function qu(n){var t=function(r,o){if(ne(r))return gn(r.name||Lh,r,n);if(ne(o))return gn(r,o,n);if(Lr(o))return(n?ho:lo).decorate_20223_(r,o);if(pn(o))return Br(r,o,n?ho:lo);if(pn(r))return de(jr(n?Vu:Wu,{name:r,autoAction:n}))};return t}var ft=qu(!1);Object.assign(ft,lo);var Pr=qu(!0);Object.assign(Pr,ho);ft.bound=de(jh);Pr.bound=de($h);function Gn(n){return ne(n)&&n.isMobxAction===!0}function Nh(n,t){var e,r,o,u;t===void 0&&(t=Oo);var l=(e=(r=t)==null?void 0:r.name)!=null?e:"Autorun",f=!t.scheduler&&!t.delay,p;if(f)p=new Pe(l,function(){this.track(S)},t.onError,t.requiresObservable);else{var m=Gu(t),_=!1;p=new Pe(l,function(){_||(_=!0,m(function(){_=!1,p.isDisposed||p.track(S)}))},t.onError,t.requiresObservable)}function S(){n(p)}return(o=t)!=null&&(o=o.signal)!=null&&o.aborted||p.schedule_(),p.getDisposer_((u=t)==null?void 0:u.signal)}var Uh=function(t){return t()};function Gu(n){return n.scheduler?n.scheduler:n.delay?function(t){return setTimeout(t,n.delay)}:Uh}function Fh(n,t,e){var r,o,u;e===void 0&&(e=Oo);var l=(r=e.name)!=null?r:"Reaction",f=ft(l,e.onError?zh(e.onError,t):t),p=!e.scheduler&&!e.delay,m=Gu(e),_=!0,S=!1,R,I=e.compareStructural?qn.structural:e.equals||qn.default,j=new Pe(l,function(){_||p?V():S||(S=!0,m(V))},e.onError,e.requiresObservable);function V(){if(S=!1,!j.isDisposed){var W=!1,tt=R;j.track(function(){var ot=Ah(!1,function(){return n(j)});W=_||!I(R,ot),R=ot}),(_&&e.fireImmediately||!_&&W)&&f(R,tt,j),_=!1}}return(o=e)!=null&&(o=o.signal)!=null&&o.aborted||j.schedule_(),j.getDisposer_((u=e)==null?void 0:u.signal)}function zh(n,t){return function(){try{return t.apply(this,arguments)}catch(e){n.call(this,e)}}}var Kh="onBO",Wh="onBUO";function Vh(n,t,e){return Xu(Kh,n,t,e)}function Hu(n,t,e){return Xu(Wh,n,t,e)}function Xu(n,t,e,r){var o=fo(t),u=ne(r)?r:e,l=n+"L";return o[l]?o[l].add(u):o[l]=new Set([u]),function(){var f=o[l];f&&(f.delete(u),f.size===0&&delete o[l])}}function qh(n,t,e,r){var o=Ml(t);return xn(function(){var u=tr(n,r)[J];Yi(o).forEach(function(l){u.extend_(l,o[l],e&&l in e?e[l]:!0)})}),n}var Gh=0;function Yu(){this.message="FLOW_CANCELLED"}Yu.prototype=Object.create(Error.prototype);var Zs=Mu("flow"),Hh=Mu("flow.bound",{bound:!0}),Hn=Object.assign(function(t,e){if(Lr(e))return Zs.decorate_20223_(t,e);if(pn(e))return Br(t,e,Zs);var r=t,o=r.name||"<unnamed flow>",u=function(){var f=this,p=arguments,m=++Gh,_=ft(o+" - runid: "+m+" - init",r).apply(f,p),S,R=void 0,I=new Promise(function(j,V){var W=0;S=V;function tt(et){R=void 0;var At;try{At=ft(o+" - runid: "+m+" - yield "+W++,_.next).call(_,et)}catch(Et){return V(Et)}Q(At)}function ot(et){R=void 0;var At;try{At=ft(o+" - runid: "+m+" - yield "+W++,_.throw).call(_,et)}catch(Et){return V(Et)}Q(At)}function Q(et){if(ne(et?.then)){et.then(Q,V);return}return et.done?j(et.value):(R=Promise.resolve(et.value),R.then(tt,ot))}tt(void 0)});return I.cancel=ft(o+" - runid: "+m+" - cancel",function(){try{R&&Ia(R);var j=_.return(void 0),V=Promise.resolve(j.value);V.then(Un,Un),Ia(V),S(new Yu)}catch(W){S(W)}}),I};return u.isMobXFlow=!0,u},Zs);Hn.bound=de(Hh);function Ia(n){ne(n.cancel)&&n.cancel()}function Rr(n){return n?.isMobXFlow===!0}function Xh(n,t){return n?rs(n)||!!n[J]||Ao(n)||Ni(n)||es(n):!1}function Zu(n){return Xh(n)}function Ce(n,t){t===void 0&&(t=void 0),Ht();try{return n.apply(t)}finally{Xt()}}function Bn(n){return n[J]}var Yh={has:function(t,e){return Bn(t).has_(e)},get:function(t,e){return Bn(t).get_(e)},set:function(t,e,r){var o;return pn(e)?(o=Bn(t).set_(e,r,!0))!=null?o:!0:!1},deleteProperty:function(t,e){var r;return pn(e)?(r=Bn(t).delete_(e,!0))!=null?r:!0:!1},defineProperty:function(t,e,r){var o;return(o=Bn(t).defineProperty_(e,r))!=null?o:!0},ownKeys:function(t){return Bn(t).ownKeys_()},preventExtensions:function(t){ht(13)}};function Zh(n,t){var e,r;return bu(),n=tr(n,t),(r=(e=n[J]).proxy_)!=null?r:e.proxy_=new Proxy(n,Yh)}function qt(n){return n.interceptors_!==void 0&&n.interceptors_.length>0}function $r(n,t){var e=n.interceptors_||(n.interceptors_=[]);return e.push(t),wu(function(){var r=e.indexOf(t);r!==-1&&e.splice(r,1)})}function Gt(n,t){var e=bn();try{for(var r=[].concat(n.interceptors_||[]),o=0,u=r.length;o<u&&(t=r[o](t),t&&!t.type&&ht(14),!!t);o++);return t}finally{Me(e)}}function te(n){return n.changeListeners_!==void 0&&n.changeListeners_.length>0}function Nr(n,t){var e=n.changeListeners_||(n.changeListeners_=[]);return e.push(t),wu(function(){var r=e.indexOf(t);r!==-1&&e.splice(r,1)})}function ee(n,t){var e=bn(),r=n.changeListeners_;if(r){r=r.slice();for(var o=0,u=r.length;o<u;o++)r[o](t);Me(e)}}function Qu(n,t,e){return xn(function(){var r,o=tr(n,e)[J];(r=t)!=null||(t=Dl(n)),Yi(t).forEach(function(u){return o.make_(u,t[u])})}),n}var Da="splice",pe="update",Qh=1e4,Jh={get:function(t,e){var r=t[J];return e===J?r:e==="length"?r.getArrayLength_():typeof e=="string"&&!isNaN(e)?r.get_(parseInt(e)):Te(Ui,e)?Ui[e]:t[e]},set:function(t,e,r){var o=t[J];return e==="length"&&o.setArrayLength_(r),typeof e=="symbol"||isNaN(e)?t[e]=r:o.set_(parseInt(e),r),!0},preventExtensions:function(){ht(15)}},To=(function(){function n(e,r,o,u){e===void 0&&(e="ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=o,this.legacyMode_=u,this.atom_=new qe(e),this.enhancer_=function(l,f){return r(l,f,"ObservableArray[..]")}}var t=n.prototype;return t.dehanceValue_=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.dehanceValues_=function(r){return this.dehancer!==void 0&&r.length>0?r.map(this.dehancer):r},t.intercept_=function(r){return $r(this,r)},t.observe_=function(r,o){return o===void 0&&(o=!1),o&&r({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Nr(this,r)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(r){(typeof r!="number"||isNaN(r)||r<0)&&ht("Out of range: "+r);var o=this.values_.length;if(r!==o)if(r>o){for(var u=new Array(r-o),l=0;l<r-o;l++)u[l]=void 0;this.spliceWithArray_(o,0,u)}else this.spliceWithArray_(r,o-r)},t.updateArrayLength_=function(r,o){r!==this.lastKnownLength_&&ht(16),this.lastKnownLength_+=o,this.legacyMode_&&o>0&&sc(r+o+1)},t.spliceWithArray_=function(r,o,u){var l=this;this.atom_;var f=this.values_.length;if(r===void 0?r=0:r>f?r=f:r<0&&(r=Math.max(0,f+r)),arguments.length===1?o=f-r:o==null?o=0:o=Math.max(0,Math.min(o,f-r)),u===void 0&&(u=io),qt(this)){var p=Gt(this,{object:this.proxy_,type:Da,index:r,removedCount:o,added:u});if(!p)return io;o=p.removedCount,u=p.added}if(u=u.length===0?u:u.map(function(S){return l.enhancer_(S,void 0)}),this.legacyMode_){var m=u.length-o;this.updateArrayLength_(f,m)}var _=this.spliceItemsIntoValues_(r,o,u);return(o!==0||u.length!==0)&&this.notifyArraySplice_(r,u,_),this.dehanceValues_(_)},t.spliceItemsIntoValues_=function(r,o,u){if(u.length<Qh){var l;return(l=this.values_).splice.apply(l,[r,o].concat(u))}else{var f=this.values_.slice(r,r+o),p=this.values_.slice(r+o);this.values_.length+=u.length-o;for(var m=0;m<u.length;m++)this.values_[r+m]=u[m];for(var _=0;_<p.length;_++)this.values_[r+u.length+_]=p[_];return f}},t.notifyArrayChildUpdate_=function(r,o,u){var l=!this.owned_&&Er(),f=te(this),p=f||l?{observableKind:"array",object:this.proxy_,type:pe,debugObjectName:this.atom_.name_,index:r,newValue:o,oldValue:u}:null;this.atom_.reportChanged(),f&&ee(this,p)},t.notifyArraySplice_=function(r,o,u){var l=!this.owned_&&Er(),f=te(this),p=f||l?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:Da,index:r,removed:u,added:o,removedCount:u.length,addedCount:o.length}:null;this.atom_.reportChanged(),f&&ee(this,p)},t.get_=function(r){if(this.legacyMode_&&r>=this.values_.length){console.warn("[mobx] Out of bounds read: "+r);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[r])},t.set_=function(r,o){var u=this.values_;if(this.legacyMode_&&r>u.length&&ht(17,r,u.length),r<u.length){this.atom_;var l=u[r];if(qt(this)){var f=Gt(this,{type:pe,object:this.proxy_,index:r,newValue:o});if(!f)return;o=f.newValue}o=this.enhancer_(o,l);var p=o!==l;p&&(u[r]=o,this.notifyArrayChildUpdate_(r,o,l))}else{for(var m=new Array(r+1-u.length),_=0;_<m.length-1;_++)m[_]=void 0;m[m.length-1]=o,this.spliceWithArray_(u.length,0,m)}},n})();function tf(n,t,e,r){return e===void 0&&(e="ObservableArray"),r===void 0&&(r=!1),bu(),xn(function(){var o=new To(e,t,r,!1);Su(o.values_,J,o);var u=new Proxy(o.values_,Jh);return o.proxy_=u,n&&n.length&&o.spliceWithArray_(0,0,n),u})}var Ui={clear:function(){return this.splice(0)},replace:function(t){var e=this[J];return e.spliceWithArray_(0,e.values_.length,t)},toJSON:function(){return this.slice()},splice:function(t,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),u=2;u<r;u++)o[u-2]=arguments[u];var l=this[J];switch(arguments.length){case 0:return[];case 1:return l.spliceWithArray_(t);case 2:return l.spliceWithArray_(t,e)}return l.spliceWithArray_(t,e,o)},spliceWithArray:function(t,e,r){return this[J].spliceWithArray_(t,e,r)},push:function(){for(var t=this[J],e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return t.spliceWithArray_(t.values_.length,0,r),t.values_.length},pop:function(){return this.splice(Math.max(this[J].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var t=this[J],e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return t.spliceWithArray_(0,0,r),t.values_.length},reverse:function(){return H.trackingDerivation&&ht(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){H.trackingDerivation&&ht(37,"sort");var t=this.slice();return t.sort.apply(t,arguments),this.replace(t),this},remove:function(t){var e=this[J],r=e.dehanceValues_(e.values_).indexOf(t);return r>-1?(this.splice(r,1),!0):!1}};mt("at",Wt);mt("concat",Wt);mt("flat",Wt);mt("includes",Wt);mt("indexOf",Wt);mt("join",Wt);mt("lastIndexOf",Wt);mt("slice",Wt);mt("toString",Wt);mt("toLocaleString",Wt);mt("toSorted",Wt);mt("toSpliced",Wt);mt("with",Wt);mt("every",ie);mt("filter",ie);mt("find",ie);mt("findIndex",ie);mt("findLast",ie);mt("findLastIndex",ie);mt("flatMap",ie);mt("forEach",ie);mt("map",ie);mt("some",ie);mt("toReversed",ie);mt("reduce",Ju);mt("reduceRight",Ju);function mt(n,t){typeof Array.prototype[n]=="function"&&(Ui[n]=t(n))}function Wt(n){return function(){var t=this[J];t.atom_.reportObserved();var e=t.dehanceValues_(t.values_);return e[n].apply(e,arguments)}}function ie(n){return function(t,e){var r=this,o=this[J];o.atom_.reportObserved();var u=o.dehanceValues_(o.values_);return u[n](function(l,f){return t.call(e,l,f,r)})}}function Ju(n){return function(){var t=this,e=this[J];e.atom_.reportObserved();var r=e.dehanceValues_(e.values_),o=arguments[0];return arguments[0]=function(u,l,f){return o(u,l,f,t)},r[n].apply(r,arguments)}}var ef=_n("ObservableArrayAdministration",To);function ns(n){return Hi(n)&&ef(n[J])}var nf={},Ke="add",Fi="delete",tc=(function(){function n(e,r,o){var u=this;r===void 0&&(r=mn),o===void 0&&(o="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[J]=nf,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=r,this.name_=o,ne(Map)||ht(18),xn(function(){u.keysAtom_=Cu("ObservableMap.keys()"),u.data_=new Map,u.hasMap_=new Map,e&&u.merge(e)})}var t=n.prototype;return t.has_=function(r){return this.data_.has(r)},t.has=function(r){var o=this;if(!H.trackingDerivation)return this.has_(r);var u=this.hasMap_.get(r);if(!u){var l=u=new fn(this.has_(r),Zi,"ObservableMap.key?",!1);this.hasMap_.set(r,l),Hu(l,function(){return o.hasMap_.delete(r)})}return u.get()},t.set=function(r,o){var u=this.has_(r);if(qt(this)){var l=Gt(this,{type:u?pe:Ke,object:this,newValue:o,name:r});if(!l)return this;o=l.newValue}return u?this.updateValue_(r,o):this.addValue_(r,o),this},t.delete=function(r){var o=this;if(this.keysAtom_,qt(this)){var u=Gt(this,{type:Fi,object:this,name:r});if(!u)return!1}if(this.has_(r)){var l=Er(),f=te(this),p=f||l?{observableKind:"map",debugObjectName:this.name_,type:Fi,object:this,oldValue:this.data_.get(r).value_,name:r}:null;return Ce(function(){var m;o.keysAtom_.reportChanged(),(m=o.hasMap_.get(r))==null||m.setNewValue_(!1);var _=o.data_.get(r);_.setNewValue_(void 0),o.data_.delete(r)}),f&&ee(this,p),!0}return!1},t.updateValue_=function(r,o){var u=this.data_.get(r);if(o=u.prepareNewValue_(o),o!==H.UNCHANGED){var l=Er(),f=te(this),p=f||l?{observableKind:"map",debugObjectName:this.name_,type:pe,object:this,oldValue:u.value_,name:r,newValue:o}:null;u.setNewValue_(o),f&&ee(this,p)}},t.addValue_=function(r,o){var u=this;this.keysAtom_,Ce(function(){var m,_=new fn(o,u.enhancer_,"ObservableMap.key",!1);u.data_.set(r,_),o=_.value_,(m=u.hasMap_.get(r))==null||m.setNewValue_(!0),u.keysAtom_.reportChanged()});var l=Er(),f=te(this),p=f||l?{observableKind:"map",debugObjectName:this.name_,type:Ke,object:this,name:r,newValue:o}:null;f&&ee(this,p)},t.get=function(r){return this.has(r)?this.dehanceValue_(this.data_.get(r).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var r=this,o=this.keys();return Ba({next:function(){var l=o.next(),f=l.done,p=l.value;return{done:f,value:f?void 0:r.get(p)}}})},t.entries=function(){var r=this,o=this.keys();return Ba({next:function(){var l=o.next(),f=l.done,p=l.value;return{done:f,value:f?void 0:[p,r.get(p)]}}})},t[Symbol.iterator]=function(){return this.entries()},t.forEach=function(r,o){for(var u=Fn(this),l;!(l=u()).done;){var f=l.value,p=f[0],m=f[1];r.call(o,m,p,this)}},t.merge=function(r){var o=this;return wn(r)&&(r=new Map(r)),Ce(function(){Ve(r)?Tl(r).forEach(function(u){return o.set(u,r[u])}):Array.isArray(r)?r.forEach(function(u){var l=u[0],f=u[1];return o.set(l,f)}):Qn(r)?(Cl(r)||ht(19,r),r.forEach(function(u,l){return o.set(l,u)})):r!=null&&ht(20,r)}),this},t.clear=function(){var r=this;Ce(function(){ju(function(){for(var o=Fn(r.keys()),u;!(u=o()).done;){var l=u.value;r.delete(l)}})})},t.replace=function(r){var o=this;return Ce(function(){for(var u=rf(r),l=new Map,f=!1,p=Fn(o.data_.keys()),m;!(m=p()).done;){var _=m.value;if(!u.has(_)){var S=o.delete(_);if(S)f=!0;else{var R=o.data_.get(_);l.set(_,R)}}}for(var I=Fn(u.entries()),j;!(j=I()).done;){var V=j.value,W=V[0],tt=V[1],ot=o.data_.has(W);if(o.set(W,tt),o.data_.has(W)){var Q=o.data_.get(W);l.set(W,Q),ot||(f=!0)}}if(!f)if(o.data_.size!==l.size)o.keysAtom_.reportChanged();else for(var et=o.data_.keys(),At=l.keys(),Et=et.next(),yt=At.next();!Et.done;){if(Et.value!==yt.value){o.keysAtom_.reportChanged();break}Et=et.next(),yt=At.next()}o.data_=l}),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(r,o){return Nr(this,r)},t.intercept_=function(r){return $r(this,r)},Jn(n,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Map"}}])})(),wn=_n("ObservableMap",tc);function Ba(n){return n[Symbol.toStringTag]="MapIterator",Po(n)}function rf(n){if(Qn(n)||wn(n))return n;if(Array.isArray(n))return new Map(n);if(Ve(n)){var t=new Map;for(var e in n)t.set(e,n[e]);return t}else return ht(21,n)}var sf={},ec=(function(){function n(e,r,o){var u=this;r===void 0&&(r=mn),o===void 0&&(o="ObservableSet"),this.name_=void 0,this[J]=sf,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=o,ne(Set)||ht(22),this.enhancer_=function(l,f){return r(l,f,o)},xn(function(){u.atom_=Cu(u.name_),e&&u.replace(e)})}var t=n.prototype;return t.dehanceValue_=function(r){return this.dehancer!==void 0?this.dehancer(r):r},t.clear=function(){var r=this;Ce(function(){ju(function(){for(var o=Fn(r.data_.values()),u;!(u=o()).done;){var l=u.value;r.delete(l)}})})},t.forEach=function(r,o){for(var u=Fn(this),l;!(l=u()).done;){var f=l.value;r.call(o,f,f,this)}},t.add=function(r){var o=this;if(this.atom_,qt(this)){var u=Gt(this,{type:Ke,object:this,newValue:r});if(!u)return this;r=u.newValue}if(!this.has(r)){Ce(function(){o.data_.add(o.enhancer_(r,void 0)),o.atom_.reportChanged()});var l=!1,f=te(this),p=f||l?{observableKind:"set",debugObjectName:this.name_,type:Ke,object:this,newValue:r}:null;f&&ee(this,p)}return this},t.delete=function(r){var o=this;if(qt(this)){var u=Gt(this,{type:Fi,object:this,oldValue:r});if(!u)return!1}if(this.has(r)){var l=!1,f=te(this),p=f||l?{observableKind:"set",debugObjectName:this.name_,type:Fi,object:this,oldValue:r}:null;return Ce(function(){o.atom_.reportChanged(),o.data_.delete(r)}),f&&ee(this,p),!0}return!1},t.has=function(r){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(r))},t.entries=function(){var r=this.values();return La({next:function(){var u=r.next(),l=u.value,f=u.done;return f?{value:void 0,done:f}:{value:[l,l],done:f}}})},t.keys=function(){return this.values()},t.values=function(){this.atom_.reportObserved();var r=this,o=this.data_.values();return La({next:function(){var l=o.next(),f=l.value,p=l.done;return p?{value:void 0,done:p}:{value:r.dehanceValue_(f),done:p}}})},t.intersection=function(r){if(Ee(r)&&!le(r))return r.intersection(this);var o=new Set(this);return o.intersection(r)},t.union=function(r){if(Ee(r)&&!le(r))return r.union(this);var o=new Set(this);return o.union(r)},t.difference=function(r){return new Set(this).difference(r)},t.symmetricDifference=function(r){if(Ee(r)&&!le(r))return r.symmetricDifference(this);var o=new Set(this);return o.symmetricDifference(r)},t.isSubsetOf=function(r){return new Set(this).isSubsetOf(r)},t.isSupersetOf=function(r){return new Set(this).isSupersetOf(r)},t.isDisjointFrom=function(r){if(Ee(r)&&!le(r))return r.isDisjointFrom(this);var o=new Set(this);return o.isDisjointFrom(r)},t.replace=function(r){var o=this;return le(r)&&(r=new Set(r)),Ce(function(){Array.isArray(r)?(o.clear(),r.forEach(function(u){return o.add(u)})):Ee(r)?(o.clear(),r.forEach(function(u){return o.add(u)})):r!=null&&ht("Cannot initialize set from "+r)}),this},t.observe_=function(r,o){return Nr(this,r)},t.intercept_=function(r){return $r(this,r)},t.toJSON=function(){return Array.from(this)},t.toString=function(){return"[object ObservableSet]"},t[Symbol.iterator]=function(){return this.values()},Jn(n,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return"Set"}}])})(),le=_n("ObservableSet",ec);function La(n){return n[Symbol.toStringTag]="SetIterator",Po(n)}var ja=Object.create(null),$a="remove",nc=(function(){function n(e,r,o,u){r===void 0&&(r=new Map),u===void 0&&(u=ih),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=e,this.values_=r,this.name_=o,this.defaultAnnotation_=u,this.keysAtom_=new qe("ObservableObject.keys"),this.isPlainObject_=Ve(this.target_)}var t=n.prototype;return t.getObservablePropValue_=function(r){return this.values_.get(r).get()},t.setObservablePropValue_=function(r,o){var u=this.values_.get(r);if(u instanceof re)return u.set(o),!0;if(qt(this)){var l=Gt(this,{type:pe,object:this.proxy_||this.target_,name:r,newValue:o});if(!l)return null;o=l.newValue}if(o=u.prepareNewValue_(o),o!==H.UNCHANGED){var f=te(this),p=!1,m=f||p?{type:pe,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:u.value_,name:r,newValue:o}:null;u.setNewValue_(o),f&&ee(this,m)}return!0},t.get_=function(r){return H.trackingDerivation&&!Te(this.target_,r)&&this.has_(r),this.target_[r]},t.set_=function(r,o,u){return u===void 0&&(u=!1),Te(this.target_,r)?this.values_.has(r)?this.setObservablePropValue_(r,o):u?Reflect.set(this.target_,r,o):(this.target_[r]=o,!0):this.extend_(r,{value:o,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,u)},t.has_=function(r){if(!H.trackingDerivation)return r in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var o=this.pendingKeys_.get(r);return o||(o=new fn(r in this.target_,Zi,"ObservableObject.key?",!1),this.pendingKeys_.set(r,o)),o.get()},t.make_=function(r,o){if(o===!0&&(o=this.defaultAnnotation_),o!==!1){if(!(r in this.target_)){var u;if((u=this.target_[he])!=null&&u[r])return;ht(1,o.annotationType_,this.name_+"."+r.toString())}for(var l=this.target_;l&&l!==Gi;){var f=Bi(l,r);if(f){var p=o.make_(this,r,f,l);if(p===0)return;if(p===1)break}l=Object.getPrototypeOf(l)}Ua(this,o,r)}},t.extend_=function(r,o,u,l){if(l===void 0&&(l=!1),u===!0&&(u=this.defaultAnnotation_),u===!1)return this.defineProperty_(r,o,l);var f=u.extend_(this,r,o,l);return f&&Ua(this,u,r),f},t.defineProperty_=function(r,o,u){u===void 0&&(u=!1),this.keysAtom_;try{Ht();var l=this.delete_(r);if(!l)return l;if(qt(this)){var f=Gt(this,{object:this.proxy_||this.target_,name:r,type:Ke,newValue:o.value});if(!f)return null;var p=f.newValue;o.value!==p&&(o=vn({},o,{value:p}))}if(u){if(!Reflect.defineProperty(this.target_,r,o))return!1}else fe(this.target_,r,o);this.notifyPropertyAddition_(r,o.value)}finally{Xt()}return!0},t.defineObservableProperty_=function(r,o,u,l){l===void 0&&(l=!1),this.keysAtom_;try{Ht();var f=this.delete_(r);if(!f)return f;if(qt(this)){var p=Gt(this,{object:this.proxy_||this.target_,name:r,type:Ke,newValue:o});if(!p)return null;o=p.newValue}var m=Na(r),_={configurable:H.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:m.get,set:m.set};if(l){if(!Reflect.defineProperty(this.target_,r,_))return!1}else fe(this.target_,r,_);var S=new fn(o,u,"ObservableObject.key",!1);this.values_.set(r,S),this.notifyPropertyAddition_(r,S.value_)}finally{Xt()}return!0},t.defineComputedProperty_=function(r,o,u){u===void 0&&(u=!1),this.keysAtom_;try{Ht();var l=this.delete_(r);if(!l)return l;if(qt(this)){var f=Gt(this,{object:this.proxy_||this.target_,name:r,type:Ke,newValue:void 0});if(!f)return null}o.name||(o.name="ObservableObject.key"),o.context=this.proxy_||this.target_;var p=Na(r),m={configurable:H.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:p.get,set:p.set};if(u){if(!Reflect.defineProperty(this.target_,r,m))return!1}else fe(this.target_,r,m);this.values_.set(r,new re(o)),this.notifyPropertyAddition_(r,void 0)}finally{Xt()}return!0},t.delete_=function(r,o){if(o===void 0&&(o=!1),this.keysAtom_,!Te(this.target_,r))return!0;if(qt(this)){var u=Gt(this,{object:this.proxy_||this.target_,name:r,type:$a});if(!u)return null}try{var l;Ht();var f=te(this),p=!1,m=this.values_.get(r),_=void 0;if(!m&&(f||p)){var S;_=(S=Bi(this.target_,r))==null?void 0:S.value}if(o){if(!Reflect.deleteProperty(this.target_,r))return!1}else delete this.target_[r];if(m&&(this.values_.delete(r),m instanceof fn&&(_=m.value_),zu(m)),this.keysAtom_.reportChanged(),(l=this.pendingKeys_)==null||(l=l.get(r))==null||l.set(r in this.target_),f||p){var R={type:$a,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:_,name:r};f&&ee(this,R)}}finally{Xt()}return!0},t.observe_=function(r,o){return Nr(this,r)},t.intercept_=function(r){return $r(this,r)},t.notifyPropertyAddition_=function(r,o){var u,l=te(this),f=!1;if(l||f){var p=l||f?{type:Ke,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:r,newValue:o}:null;l&&ee(this,p)}(u=this.pendingKeys_)==null||(u=u.get(r))==null||u.set(!0),this.keysAtom_.reportChanged()},t.ownKeys_=function(){return this.keysAtom_.reportObserved(),Yi(this.target_)},t.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},n})();function tr(n,t){var e;if(Te(n,J))return n;var r=(e=t?.name)!=null?e:"ObservableObject",o=new nc(n,new Map,String(r),vh(t));return Xi(n,J,o),n}var of=_n("ObservableObjectAdministration",nc);function Na(n){return ja[n]||(ja[n]={get:function(){return this[J].getObservablePropValue_(n)},set:function(e){return this[J].setObservablePropValue_(n,e)}})}function rs(n){return Hi(n)?of(n[J]):!1}function Ua(n,t,e){var r;(r=n.target_[he])==null||delete r[e]}var af=ic(0),uf=(function(){var n=!1,t={};return Object.defineProperty(t,"0",{set:function(){n=!0}}),Object.create(t)[0]=1,n===!1})(),Qs=0,rc=function(){};function cf(n,t){Object.setPrototypeOf?Object.setPrototypeOf(n.prototype,t):n.prototype.__proto__!==void 0?n.prototype.__proto__=t:n.prototype=t}cf(rc,Array.prototype);var Mo=(function(n){function t(r,o,u,l){var f;return u===void 0&&(u="ObservableArray"),l===void 0&&(l=!1),f=n.call(this)||this,xn(function(){var p=new To(u,o,l,!0);p.proxy_=f,Su(f,J,p),r&&r.length&&f.spliceWithArray(0,0,r),uf&&Object.defineProperty(f,"0",af)}),f}Eu(t,n);var e=t.prototype;return e.concat=function(){this[J].atom_.reportObserved();for(var o=arguments.length,u=new Array(o),l=0;l<o;l++)u[l]=arguments[l];return Array.prototype.concat.apply(this.slice(),u.map(function(f){return ns(f)?f.slice():f}))},e[Symbol.iterator]=function(){var r=this,o=0;return Po({next:function(){return o<r.length?{value:r[o++],done:!1}:{done:!0,value:void 0}}})},Jn(t,[{key:"length",get:function(){return this[J].getArrayLength_()},set:function(o){this[J].setArrayLength_(o)}},{key:Symbol.toStringTag,get:function(){return"Array"}}])})(rc);Object.entries(Ui).forEach(function(n){var t=n[0],e=n[1];t!=="concat"&&Xi(Mo.prototype,t,e)});function ic(n){return{enumerable:!1,configurable:!0,get:function(){return this[J].get_(n)},set:function(e){this[J].set_(n,e)}}}function lf(n){fe(Mo.prototype,""+n,ic(n))}function sc(n){if(n>Qs){for(var t=Qs;t<n+100;t++)lf(t);Qs=n}}sc(1e3);function hf(n,t,e){return new Mo(n,t,e)}function fo(n,t){if(typeof n=="object"&&n!==null){if(ns(n))return t!==void 0&&ht(23),n[J].atom_;if(le(n))return n.atom_;if(wn(n)){if(t===void 0)return n.keysAtom_;var e=n.data_.get(t)||n.hasMap_.get(t);return e||ht(25,t,po(n)),e}if(rs(n)){if(!t)return ht(26);var r=n[J].values_.get(t);return r||ht(27,t,po(n)),r}if(Ao(n)||es(n)||Ni(n))return n}else if(ne(n)&&Ni(n[J]))return n[J];ht(28)}function ff(n,t){if(n||ht(29),Ao(n)||es(n)||Ni(n)||wn(n)||le(n))return n;if(n[J])return n[J];ht(24,n)}function po(n,t){var e;if(t!==void 0)e=fo(n,t);else{if(Gn(n))return n.name;rs(n)||wn(n)||le(n)?e=ff(n):e=fo(n)}return e.name_}function xn(n){var t=bn(),e=Ji(!0);Ht();try{return n()}finally{Xt(),ts(e),Me(t)}}var Fa=Gi.toString;function oc(n,t,e){return e===void 0&&(e=-1),vo(n,t,e)}function vo(n,t,e,r,o){if(n===t)return n!==0||1/n===1/t;if(n==null||t==null)return!1;if(n!==n)return t!==t;var u=typeof n;if(u!=="function"&&u!=="object"&&typeof t!="object")return!1;var l=Fa.call(n);if(l!==Fa.call(t))return!1;switch(l){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!=+n?+t!=+t:+n==0?1/+n===1/t:+n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object Symbol]":return typeof Symbol<"u"&&Symbol.valueOf.call(n)===Symbol.valueOf.call(t);case"[object Map]":case"[object Set]":e>=0&&e++;break}n=za(n),t=za(t);var f=l==="[object Array]";if(!f){if(typeof n!="object"||typeof t!="object")return!1;var p=n.constructor,m=t.constructor;if(p!==m&&!(ne(p)&&p instanceof p&&ne(m)&&m instanceof m)&&"constructor"in n&&"constructor"in t)return!1}if(e===0)return!1;e<0&&(e=-1),r=r||[],o=o||[];for(var _=r.length;_--;)if(r[_]===n)return o[_]===t;if(r.push(n),o.push(t),f){if(_=n.length,_!==t.length)return!1;for(;_--;)if(!vo(n[_],t[_],e-1,r,o))return!1}else{var S=Object.keys(n),R=S.length;if(Object.keys(t).length!==R)return!1;for(var I=0;I<R;I++){var j=S[I];if(!(Te(t,j)&&vo(n[j],t[j],e-1,r,o)))return!1}}return r.pop(),o.pop(),!0}function za(n){return ns(n)?n.slice():Qn(n)||wn(n)||Ee(n)||le(n)?Array.from(n.entries()):n}var Ka,df=((Ka=So().Iterator)==null?void 0:Ka.prototype)||{};function Po(n){return n[Symbol.iterator]=pf,Object.assign(Object.create(df),n)}function pf(){return this}["Symbol","Map","Set"].forEach(function(n){var t=So();typeof t[n]>"u"&&ht("MobX requires global '"+n+"' to be available or polyfilled")});typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:Ih,extras:{getDebugName:po},$mobx:J});class vf{constructor(t={}){const{x:e=0,y:r=0,width:o=0,height:u=0,rotation:l=0,zoom:f=1}=t;this.x=e,this.y=r,this.width=o,this.height=u,this.rotation=l,this.zoom=f,Qu(this,{x:dt,y:dt,width:dt,height:dt,rotation:dt,zoom:dt,setX:ft,setY:ft,setPosition:ft,incrementPosition:ft,setWidth:ft,setHeight:ft,setSize:ft,setZoom:ft,setRotation:ft,stateVector:ce})}setX(t){this.x=t}setY(t){this.y=t}setPosition(t,e){this.x=t,this.y=e}incrementPosition(t,e){this.x+=t,this.y+=e}setWidth(t){this.width=t}setHeight(t){this.height=t}setSize(t,e){this.width=t,this.height=e}setZoom(t){this.zoom=t}setRotation(t){this.rotation=t}get dimension(){return[this.width,this.height]}get position(){return[this.x,this.y]}get stateVector(){return[this.x,this.y,this.width,this.height,this.rotation,this.zoom]}get translationMatrix(){return bt.translation(this.x,this.y)}get rotationMatrix(){return bt.rotation(this.rotation)}get scaleMatrix(){return bt.scaling(this.zoom,this.zoom)}get cameraMatrix(){const t=bt.multiply(this.translationMatrix,this.rotationMatrix);return bt.multiply(t,this.scaleMatrix)}get canvasMatrix(){return bt.inverse(this.cameraMatrix)}}function Wa(n,t){n.setTranslation(t.x,t.y),n.setScale(t.sx,t.sy)}function Va(n,t,e){return{label:"Flip",do(){for(const r of n)Wa(r.ref,r.end);e&&(e.scale[t==="horizontal"?0:1]*=-1)},undo(){for(const r of n)Wa(r.ref,r.start);e&&(e.scale[t==="horizontal"?0:1]*=-1)}}}function qa(n,t){n.setTranslation(t.x,t.y),n.setScale(t.sx,t.sy)}function mo(n,t="Transform"){return{label:t,do(){for(const e of n)qa(e.ref,e.end)},undo(){for(const e of n)qa(e.ref,e.start)}}}class mf{#r;#n=new Set;#e=new Set;#t;#i;#o;get multiBoundingBox(){return this.#t}get boundingBoxes(){return this.#e}#a=!0;#s;#u;get selected(){return Array.from(this.#n)}set selected(t){this.#n.clear(),t.forEach(e=>{this.#n.add(e),this.#e.add(new Ca(e))})}get marqueeBox(){return this.#i}set marqueeBox(t){this.#i=new Sl(t.x,t.y,this.getWorldMatrix())}constructor(t,e,r,o,u,l,f,p){this.#s=r,this.#u=o,this.#r=t,this.#o=e,this.getWorldMatrix=u,this.getCanvasChildren=l,this.getWorldCoords=f,this.getMarqueeCoords=p;const m=Object.getPrototypeOf(this);for(const _ of Object.getOwnPropertyNames(m)){const S=this[_];typeof S=="function"&&_!=="constructor"&&(this[_]=S.bind(this))}}add(t){t.forEach(e=>{this.#n.has(e)||(this.#n.add(e),this.#e.add(new Ca(e)))}),this.#e.size>1&&(this.#e.forEach(e=>e.setPassive()),this.#t||(this.#t=new xl([])),this.selected.forEach(e=>this.#t.add(e)))}remove(t){t.forEach(e=>{if(!this.#n.has(e))return;this.#n.delete(e);const r=Array.from(this.#e.values()).find(o=>o.target===e);r?this.#e.delete(r):console.error("No matching bounding box found"),this.#t&&this.#t.remove(e)}),this.#e.size<=1&&(this.#e.forEach(e=>e.setActive()),this.#t=null)}deleteSelected(t){const e=[...this.#n];this.remove(e);for(const r of e)r.destroy();this.#r.push(fl(t,e))}hitTest(t,e){if(this.#t){const r=this.#t.hitTest(t,e,this.getWorldMatrix());if(r)return r}for(const r of this.#e.values()){const o=r.hitTest(t,e,this.getWorldMatrix());if(o)return o}return null}isMultiBoundingBoxHit(t,e){return this.#t&&this.#t.hitTest(t,e,this.getWorldMatrix())}isBoundingBoxHit(t,e){return this.#e.size===1&&Array.from(this.#e)[0].hitTest(t,e,this.getWorldMatrix())}hitTestAdjustedCorner(t,e){if(this.#t){const r=this.#t.hitTest(t,e,this.getWorldMatrix());if(r)return this.#t.scale[0]*this.#t.scale[1]<0?Oa(r):r}for(const r of this.#e.values()){const o=r.hitTest(t,e,this.getWorldMatrix());if(o)return r.target.sx*r.target.sy<0?Oa(o):o}}update(){this.#e.forEach(t=>t.update()),this.#t&&this.#t.update()}render(t){if(!this.#i&&!this.#t&&this.#e.size===0)return;this.#s.useProgram(t);const e=this.#s.getUniformLocation(t,"u_z");e&&this.#s.uniform1f(e,1),this.#a&&this.#e.forEach(r=>r.render(this.#s,t)),this.#t&&this.#t.render(this.#s,t),this.#i&&this.#i.render(this.#s,t)}isRectSelected(t){return this.#n.has(t)}clear(){this.#n.clear(),this.#e.clear(),this.#t=null}clearMarquee(){this.#i&&(this.#i=null)}move(t,e){if(this.#t)this.#t.move(t,e);else for(const r of this.#e)r.move(t,e);this.#o.emit(Ae.Change)}resize(t,e,r){this.multiBoundingBox&&this.multiBoundingBox.resize(t,e,r,this.getWorldMatrix());for(const o of this.boundingBoxes)this.multiBoundingBox?o.update():o.resize(t,e,r);this.#o.emit(Ae.Change)}flip(t){if(this.multiBoundingBox){const e=this.multiBoundingBox.flip(this.getWorldMatrix(),t,this.getWorldCoords);this.#r.push(Va(e,t,this.multiBoundingBox))}else{const e=[];for(const r of this.boundingBoxes)e.push(r.flip(t));this.#r.push(Va(e,t))}this.#o.emit(Ae.Change)}alignSelection(t){if(!this.multiBoundingBox)return;const e=this.multiBoundingBox.align(t);this.#r.push(mo(e)),this.#o.emit(Ae.Change)}normalize(t,e="first"){if(!this.multiBoundingBox)return;const r=this.multiBoundingBox.normalize(t,e);this.#r.push(mo(r)),this.#o.emit(Ae.Change)}onPointerMove(t,e,r,o,u,l,f,p){if(l())f(t,e);else if(u&&u!=="CENTER")this.resize(r,o,u);else if(this.marqueeBox){this.marqueeBox.resize(r,o,p());const m=this.getCanvasChildren(),_=this.marqueeBox.getBoundingBox(this.getMarqueeCoords);for(const S of m){const R=S.getBoundingBox();dn.isColliding(R,_)&&!this.#n.has(S)?this.add([S]):!dn.isColliding(R,_)&&this.#n.has(S)&&this.remove([S])}}else this.move(r,o)}onSelectionPointerDown(t,e,r,o){e?(t||this.clear(),this.add([e])):(this.clear(),this.marqueeBox?this.clearMarquee():this.marqueeBox={x:r,y:o})}}var br=(n=>(n[n.SELECT=0]="SELECT",n[n.PAN=1]="PAN",n))(br||{});const gf={TOP:"ns-resize",BOTTOM:"ns-resize",LEFT:"ew-resize",RIGHT:"ew-resize",TOPLEFT:"nwse-resize",BOTTOMRIGHT:"nwse-resize",TOPRIGHT:"nesw-resize",BOTTOMLEFT:"nesw-resize",CENTER:"grab"};class yf{constructor(t){for(const e in t)e in t&&t[e]!==void 0&&(this[e]=t[e]);this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMoveWhileDown=this.onPointerMoveWhileDown.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.addOnPointerMove(),this.addOnWheel(t.onWheel),this.addOnPointerDown(),window.addEventListener("copy",async e=>{e.preventDefault(),!this.isContextMenuActive()&&await gu(this.getSelected())}),window.addEventListener("paste",async e=>{e.preventDefault(),!this.isContextMenuActive()&&await t.paste(this.state.lastPointerPos.x,this.state.lastPointerPos.y)})}changeMode(){this.state.toggleMode()}addOnPointerDown(){this.assignEventListener("pointerdown",this.onPointerDown)}addOnPointerMove(){this.assignEventListener("pointermove",t=>{[this.state.lastPointerPos.x,this.state.lastPointerPos.y]=this.getWorldCoords(t.clientX,t.clientY);let e=this.hitTestAdjustedCorner(this.state.lastPointerPos.x,this.state.lastPointerPos.y);this.setCursorStyle(gf[e]||"default")})}addOnWheel(t){this.assignEventListener("wheel",e=>{this.isContextMenuActive()||t(e)},{passive:!1})}onPointerDown(t){t.stopPropagation(),t.preventDefault(),this.eventHub.emit(Oe.Close);const[e,r]=this.getWorldCoords(t.clientX,t.clientY);this.state.initialize(e,r),this.currentTransform=void 0,this.state.mode===1?this.handlePanPointerDown():this.state.mode===0&&this.handleSelectPointerDown(t,e,r),document.addEventListener("pointermove",this.onPointerMoveWhileDown),document.addEventListener("pointerup",this.onPointerUp)}handlePanPointerDown(){this.setCanvasGlobalClick(!0),this.clearSelection()}handleSelectPointerDown(t,e,r){this.setCanvasGlobalClick(!1);const o=this.checkCollidingChild(e,r),u=this.checkIfSelectionHit(e,r);if(t.button===2)u||this.clearSelection(),o&&!this.isSelection(o)&&this.addSelection([o]);else{u?this.state.resizingDirection=u:this.onSelectionPointerDown(t.shiftKey,o,e,r);const l=this.getSelected();l.length&&(this.currentTransform={targets:l.map(f=>({ref:f,start:{x:f.x,y:f.y,sx:f.sx,sy:f.sy}}))})}}onPointerMoveWhileDown(t){if(t.buttons===2)return;const[e,r]=this.getWorldCoords(t.clientX,t.clientY),o=e-this.state.lastWorldX,u=r-this.state.lastWorldY;this.selectionPointerMove(this.state.startWorldX-e,this.state.startWorldY-r,o,u,this.state.resizingDirection),this.state.updateLastWorldCoord(e,r),this.setCursorStyle("grabbing")}onPointerUp(){if(document.removeEventListener("pointermove",this.onPointerMoveWhileDown),document.removeEventListener("pointerup",this.onPointerUp),this.setCanvasGlobalClick(!0),this.setCursorStyle("default"),this.currentTransform){const t=this.currentTransform.targets.map(e=>({ref:e.ref,start:e.start,end:{x:e.ref.x,y:e.ref.y,sx:e.ref.sx,sy:e.ref.sy}})).filter(e=>e.start.x!==e.end.x||e.start.y!==e.end.y||e.start.sx!==e.end.sx||e.start.sy!==e.end.sy);t.length&&this.history.push(mo(t))}this.currentTransform=void 0,this.state.resizingDirection=null,this.closeMarquee(),this.eventHub.emit("save")}checkCollidingChild(t,e){const r=this.getChildren();for(let o=r.length-1;o>=0;o--){const u=r[o];if(u instanceof Xn&&u.hitTest&&u.hitTest(t,e))return u}return null}}class _f{constructor(t,e,r,o){this.history=t,this.deleteSelected=r,this.save=()=>e.emit(Ae.Save),this.assignEventListener=o,this.onKeyPressed=this.onKeyPressed.bind(this),this.addOnKeyPressed()}addOnKeyPressed(){document.addEventListener("keydown",this.onKeyPressed)}onKeyPressed(t){if(this.isCtrlZ(t)){t.preventDefault(),this.history.undo();return}if(this.isCtrlY(t)){t.preventDefault(),this.history.redo();return}if(this.isDelete(t)){this.deleteSelected();return}if(this.isSave(t)){t.preventDefault(),this.save();return}}isCtrlZ(t){return t.key.toLowerCase()==="z"&&(t.ctrlKey||t.metaKey)&&!t.shiftKey}isCtrlY(t){return t.key.toLowerCase()==="y"&&(t.ctrlKey||t.metaKey)&&!t.shiftKey}isDelete(t){return t.key==="Delete"}isSave(t){return t.key.toLowerCase()==="s"&&t.ctrlKey}}class bf{#r=!1;get isActive(){return this.#r}constructor(t,e,r,o,u){this.customContextMenu=l=>{l.preventDefault(),l.stopPropagation();const[f,p]=o(l.clientX,l.clientY);e(f,p)?t.emit(Oe.Open,l.clientX,l.clientY,"multi"):r(f,p)?t.emit(Oe.Open,l.clientX,l.clientY):t.emit(Oe.Open,l.clientX,l.clientY,"canvas")},t.on(Oe.Open,()=>{this.#r=!0}),t.on(Oe.Close,()=>{this.#r=!1}),u("contextmenu",this.customContextMenu)}}function Ga(n,t){n.renderOrder=t.renderOrder}function wf(n,t="Order"){return{label:t,do(){for(const e of n)Ga(e.ref,e.end)},undo(){for(const e of n)Ga(e.ref,e.start)}}}class xf{constructor(t=br.SELECT){this.lastPointerPos={x:0,y:0},this.startWorldX=0,this.startWorldY=0,this.lastWorldX=0,this.lastWorldY=0,this.resizingDirection=null,this.mode=t}get isResizing(){return this.resizingDirection!==null}get dragDXFromStart(){return this.lastWorldX-this.startWorldX}get dragDYFromStart(){return this.lastWorldY-this.startWorldY}setMode(t){this.mode=t}toggleMode(){this.mode=this.mode===br.PAN?br.SELECT:br.PAN}setResizingDirection(t){this.resizingDirection=t}clearResizingDirection(){this.resizingDirection=null}initialize(t,e){this.startWorldX=t,this.startWorldY=e,this.lastWorldX=t,this.lastWorldY=e,this.resizingDirection=null}updateLastWorldCoord(t,e){this.lastWorldX=t,this.lastWorldY=e}}class Sf{constructor(){this.translation=[0,0],this.angleRadians=0,this.scale=[1,1],this.localMatrix=bt.identity(),this.worldMatrix=bt.identity(),this.children=[],this.parent=null,this.renderDirtyFlag=!0,Qu(this,{translation:dt.struct,angleRadians:dt,scale:dt.struct,localMatrix:dt.ref,worldMatrix:dt.ref,children:dt.shallow,parent:dt.ref,renderDirtyFlag:dt,x:ce,y:ce,scaleX:ce,scaleY:ce,dirty:ce,setTranslation:ft,setScale:ft,flipVertical:ft,setAngle:ft,getChild:ft,appendChild:ft,appendChildren:ft,removeChild:ft,clearChildren:ft,setParent:ft,markDirty:ft,clearDirty:ft,updateLocalMatrix:ft,updateWorldMatrix:ft,setWorldMatrix:ft}),this.updateLocalMatrix(),this.updateWorldMatrix()}get x(){return this.translation[0]}get y(){return this.translation[1]}get scaleX(){return this.scale[0]}get scaleY(){return this.scale[1]}get dirty(){return this.renderDirtyFlag}setTranslation(t,e){this.translation[0]=t,this.translation[1]=e,this.markDirty()}updateTranslation(t,e){this.translation[0]+=t,this.translation[1]+=e,this.markDirty()}setScale(t,e){t===this.scale[0]&&e===this.scale[1]||(this.scale[0]=t,this.scale[1]=e,this.markDirty())}updateScale(t,e){this.scale[0]*=t,this.scale[1]*=e,this.markDirty()}flipVertical(t){this.translation[1]+=this.scale[1]*t,this.scale[1]*=-1,this.markDirty()}flipHorizontal(t){this.translation[0]+=this.scale[0]*t,this.scale[0]*=-1,this.markDirty()}setAngle(t){const r=(360-t)*Math.PI/180;r!==this.angleRadians&&(this.angleRadians=r,this.markDirty())}getChild(t){return this.children[t]}appendChild(t){this.children.includes(t)||(this.children.push(t),this.markDirty())}appendChildren(t){for(const e of t){if(this.children.includes(e))return;this.children.push(e)}this.markDirty()}removeChild(t){const e=this.children.indexOf(t);if(e<0)return;const r=this.children.splice(e,1);return t.state.setParent(null),this.markDirty(),r[0]}clearChildren(){if(this.children){for(const t of this.children)t.destroy();this.children=[],this.markDirty()}}setParent(t){this.parent!==t&&(this.parent=t,this.markDirty())}markDirty(){this.renderDirtyFlag||(this.renderDirtyFlag=!0,this.updateLocalMatrix())}clearDirty(){this.renderDirtyFlag&&(this.renderDirtyFlag=!1,this.updateLocalMatrix())}updateLocalMatrix(){const t=bt.translation(this.translation[0],this.translation[1]),e=bt.rotation(this.angleRadians),r=bt.scaling(this.scale[0],this.scale[1]);this.localMatrix=bt.multiply(bt.multiply(t,e),r)}updateWorldMatrix(t){this.worldMatrix=t?bt.multiply(t,this.localMatrix):this.localMatrix.slice();const e=this.worldMatrix;this.children.forEach(r=>{r.updateWorldMatrix(e)})}setWorldMatrix(t){this.worldMatrix=t}}class ac{get x(){return this.state.x}get y(){return this.state.y}get sx(){return this.state.scaleX}get sy(){return this.state.scaleY}get dirty(){return this.state.dirty}get localMatrix(){return this.state.localMatrix}get worldMatrix(){return this.state.worldMatrix}get children(){return this.state.children}get parent(){return this.state.parent}get angleRadians(){return this.state.angleRadians}updateTranslation(t,e){this.state.updateTranslation(t,e)}setTranslation(t,e){this.state.setTranslation(t,e)}updateScale(t,e){this.state.updateScale(t,e)}setScale(t,e){this.state.setScale(t,e)}setAngle(t){return this.state.setAngle(t)}flipVertical(t){this.state.flipVertical(t)}flipHorizontal(t){this.state.flipHorizontal(t)}markDirty(){this.state.markDirty()}clearDirty(){this.state.clearDirty()}updateLocalMatrix(){this.state.updateLocalMatrix()}setWorldMatrix(t){this.state.setWorldMatrix(t)}addChild(t){this.state.appendChild(t)}addParent(t){return this.state.setParent(t)}clearChildren(){return this.state.clearChildren()}constructor(){this.state=new Sf,this.setWorldMatrix=this.setWorldMatrix.bind(this),this.updateWorldMatrix=this.updateWorldMatrix.bind(this)}appendChild(t){return t.setParent(this),!t._emitter&&this._emitter&&(t._emitter=this._emitter),t}setParent(t){if(this.parent){const e=this.parent.children.indexOf(this);e>=0&&this.parent.children.splice(e,1)}t&&t.addChild(this),this.addParent(t)}updateWorldMatrix(t){this.updateLocalMatrix(),this.state.updateWorldMatrix(t)}addEventListener(t,e,r){const o=typeof e=="function"?e:e.handleEvent.bind(e);this._emitter.on(t,o)}removeEventListener(t,e,r){}dispatchEvent(t){return this._emitter.emit(t.type,t),!t.defaultPrevented}}class uc extends ac{constructor(){super(...arguments),this.initialized=!1}updateVertexData(t){const e=this.getPositions();(!this.vertexArray||this.vertexArray.length!==e.length)&&(this.vertexArray=new Float32Array(e.length)),this.vertexArray.set(e),t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW)}setUpVertexData(t,e){this.positionBuffer||(this.positionBuffer=t.createBuffer()),this.attributeLocation=t.getAttribLocation(e,"a_position")}setUpUniforms(t,e){this.resolutionLocation=t.getUniformLocation(e,"u_resolution"),this.matrixLocation=t.getUniformLocation(e,"u_matrix")}updateUniforms(t){t.uniform2f(this.resolutionLocation,t.canvas.width,t.canvas.height),t.uniformMatrix3fv(this.matrixLocation,!1,this.worldMatrix)}}const Vi=class Vi extends uc{constructor(t,e,r=1,o=1){super(),this._seq=Vi._seqCounter++,this.culled=!1,this._renderOrder=0,this.color=[1,0,.5,1],this.setTranslation(t,e),this.setScale(r,o)}get renderOrder(){return this._renderOrder}set renderOrder(t){this._renderOrder!==t&&(this._renderOrder=t,this.markDirty())}get seq(){return this._seq}getZ(){const e=this.renderOrder*1e-4+.5;return Math.max(0,Math.min(1,e))}render(t,e){this.updateWorldMatrix(this.parent?this.parent.worldMatrix:void 0),t.useProgram(e),this.dirty&&!this.culled&&(this.initialized||(this.setUpVertexData(t,e),this.setUpUniforms(t,e),this.initialized=!0),this.updateVertexData(t),this.clearDirty()),this.updateUniforms(t);const r=t.getUniformLocation(e,"u_color");r&&t.uniform4fv(r,this.color),this.culled||this.draw(t)}draw(t){t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer);const e=2,r=t.FLOAT;t.vertexAttribPointer(this.attributeLocation,e,r,!1,0,0),t.enableVertexAttribArray(this.attributeLocation),t.drawArrays(t.TRIANGLES,0,this.getVertexCount()),t.bindBuffer(t.ARRAY_BUFFER,null),t.disableVertexAttribArray(this.attributeLocation)}destroy(){this.positionBuffer&&(this.positionBuffer=void 0),this.initialized=!1}};Vi._seqCounter=0;let Xn=Vi;class We extends Xn{constructor(t){super(t.x,t.y,t.sx,t.sy),this._width=t.width??100,this._height=t.height??100}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this.markDirty())}get height(){return this._height}set height(t){this._height!==t&&(this._height=t,this.markDirty())}getVertexCount(){return 6}getPositions(){const r=this.width,o=this.height;return[0,0,0,o,r,0,r,0,0,o,r,o]}getBoundingBox(){const t=this.state.translation[0],e=t+this.width*this.state.scaleX,r=this.state.translation[1],o=r+this.height*this.state.scaleY,u=Math.min(t,e),l=Math.max(t,e),f=Math.min(r,o),p=Math.max(r,o);return this.AABB=new dn(u,f,l,p),this.AABB}getEdge(){const t=this.x,e=this.y;return{minX:Math.min(t,t+this.width),maxX:Math.max(t,t+this.width),minY:Math.min(e,e+this.height),maxY:Math.max(e,e+this.height)}}hitTest(t,e){const[r,o]=hn(this.worldMatrix),[u,l]=xi(this.worldMatrix),[f,p]=Jt(this.parent.worldMatrix,t,e),[m,_]=Jt(this.worldMatrix),S=this.width*r*u,R=this.height*o*l,I=Math.min(m,m+S),j=Math.max(m,m+S),V=Math.min(_,_+R),W=Math.max(_,_+R);return f>=I&&f<=j&&p>=V&&p<=W}}class Cr extends We{constructor(t){super(t),this.texCoordArray=new Float32Array([0,0,0,1,1,0,1,0,0,1,1,1]),this.useLowRes=!1,this.lowResNeedsRefresh=!0,this._src=t.src,this.loadImage(t.src,t.width,t.height)}get src(){return this._src}set src(t){this._src!==t&&(this._src=t,this.updateImageTexture(t),this.markDirty())}get fileId(){return this._fileId}set fileId(t){this._fileId=t}determineIfLowRes(t,e,r=.1){const o=t.getArea();return this.getBoundingBox().getArea()/o<r/e}async setUseLowRes(t,e){this.useLowRes===t&&!this.lowResNeedsRefresh||(this.useLowRes=t,(t&&e||this.lowResNeedsRefresh)&&await this.ensureLowResUploaded(e),this.markDirty(),this.lowResNeedsRefresh=!1)}loadImage(t,e,r){this.culled||this.updateImageTexture(t,e,r)}updateImageTexture(t,e,r){this._image=new Image,this._image.crossOrigin="anonymous",this._image.onload=async()=>{this.width=e??this._image.naturalWidth,this.height=r??this._image.naturalHeight;try{if(this.bitmap){try{this.bitmap.close()}catch{}this.bitmap=void 0}typeof createImageBitmap=="function"&&(this.bitmap=await createImageBitmap(this._image))}catch(o){console.warn("createImageBitmap failed, falling back to HTMLImageElement",o),this.bitmap=void 0}if(this.gl&&this.program)try{this.texture&&this.gl&&(this.gl.deleteTexture(this.texture),this.texture=void 0),this.initialiseTexture(),this.initialized=!0,this.markDirty()}catch(o){console.error("Failed to initialise texture on image load",o)}this.lowResNeedsRefresh=!0},this._image.onerror=o=>{console.error("Failed to load image:",t,o)},this._image.src=t}async ensureLowResUploaded(t){if(!(this.lowResTexture&&!this.lowResNeedsRefresh)&&!(!this._image||!this._image.complete))try{const r=this._image.naturalWidth,o=this._image.naturalHeight,u=Math.min(1,256/Math.max(1,Math.max(r,o))),l=Math.max(1,Math.round(r*u)),f=Math.max(1,Math.round(o*u));let p;typeof OffscreenCanvas<"u"?p=new OffscreenCanvas(l,f):(p=document.createElement("canvas"),p.width=l,p.height=f);const m=p.getContext("2d");m.clearRect(0,0,l,f);const _=Math.min(l/r,f/o),S=Math.round(r*_),R=Math.round(o*_),I=Math.round((l-S)/2),j=Math.round((f-R)/2);m.drawImage(this._image,0,0,r,o,I,j,S,R),this.lowResBitmap=await createImageBitmap(p),this.setLowResTextureFromBitmap(t,this.lowResBitmap)}catch(e){console.error("Failed to create/upload low-res image",e)}}setLowResTextureFromBitmap(t,e){if(this.lowResTexture){try{t.deleteTexture(this.lowResTexture)}catch{}this.lowResTexture=void 0}this.lowResTexture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.lowResTexture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.bindTexture(t.TEXTURE_2D,null),this.markDirty()}initialiseTexture(){!this.gl||!this.program||!this._image||!this._image.complete||this._image.naturalWidth===0||(this.setUpVertexData(this.gl,this.program),this.setUpTexData(this.gl,this.program),this.setTexture(this.gl),super.setUpUniforms(this.gl,this.program),this.samplerLocation=this.gl.getUniformLocation(this.program,"u_image"),this.samplerLocation&&this.gl.uniform1i(this.samplerLocation,0))}setUpTexData(t,e){this.texcoordBuffer||(this.texcoordBuffer=t.createBuffer()),this.texcoordLocation=t.getAttribLocation(e,"a_texCoord")}setTexture(t){if(this.texture){try{try{t.deleteTexture(this.texture)}catch{}}catch{}this.texture=void 0}this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR);const e=this.bitmap??this._image;e&&t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.bindTexture(t.TEXTURE_2D,null)}updateVertexData(t){super.updateVertexData(t),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),t.bufferData(t.ARRAY_BUFFER,this.texCoordArray,t.STATIC_DRAW)}getVertexCount(){return 6}render(t,e){if(this.dirty&&!this.culled){if(this.updateWorldMatrix(this.parent?this.parent.worldMatrix:void 0),!this.initialized)if(this.gl=t,this.program=e,this.initialiseTexture(),this._image.complete&&this._image.naturalWidth>0)this.initialized=!0;else return;this.updateVertexData(t),this.clearDirty()}super.updateUniforms(t),this.culled||this.draw(t)}draw(t){t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer);const e=2,r=t.FLOAT,o=!1,u=0,l=0;t.vertexAttribPointer(this.attributeLocation,e,r,o,u,l),t.enableVertexAttribArray(this.attributeLocation),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),t.vertexAttribPointer(this.texcoordLocation,e,r,o,u,l),t.enableVertexAttribArray(this.texcoordLocation),t.activeTexture(t.TEXTURE0);try{const f=this.useLowRes&&this.lowResTexture?this.lowResTexture:this.texture;t.bindTexture(t.TEXTURE_2D,f),t.drawArrays(t.TRIANGLES,0,this.getVertexCount()),t.bindBuffer(t.ARRAY_BUFFER,null),t.disableVertexAttribArray(this.attributeLocation),t.disableVertexAttribArray(this.texcoordLocation)}catch(f){console.error(f)}}destroy(){if(this.texcoordBuffer){try{this.gl.deleteBuffer(this.texcoordBuffer)}catch{}this.texcoordBuffer=void 0}if(this.texture){try{this.gl.deleteTexture(this.texture)}catch{}this.texture=void 0}if(this.lowResTexture){try{this.gl.deleteTexture(this.lowResTexture)}catch{}this.lowResTexture=void 0}if(this.bitmap){try{this.bitmap.close()}catch{}this.bitmap=void 0}if(this.lowResBitmap){try{this.lowResBitmap.close()}catch{}this.lowResBitmap=void 0}this.texcoordLocation=void 0,this.samplerLocation=void 0;try{super.destroy()}catch{}}}var Oi=(n=>(n[n.NONE=0]="NONE",n[n.GRID=1]="GRID",n))(Oi||{});class cc extends uc{constructor(){super(...arguments),this.buffer=null,this.vertexCount=0,this.gridType=1,this.zoom=1}getPositions(){return new Float32Array([-1,-1,3,-1,-1,3])}changeGridType(t){this.gridType=t}render(t,e){if(this.buffer)t.bindBuffer(t.ARRAY_BUFFER,this.buffer);else{if(this.buffer=t.createBuffer(),!this.buffer)throw new Error("Failed to create grid buffer");const m=this.getPositions();this.vertexCount=m.length/2,t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,m,t.STATIC_DRAW)}this.initialized||(this.setUpVertexData(t,e),this.setUpUniforms(t,e),this.initialized=!0);const r=t.drawingBufferWidth,o=t.drawingBufferHeight,u=bt.inverse(bt.projection(r,o)),l=bt.inverse(this.worldMatrix),f=bt.multiply(l,u);this.viewProjectionInvLocation&&t.uniformMatrix3fv(this.viewProjectionInvLocation,!1,new Float32Array(f)),this.zoomScaleLocation&&t.uniform1f(this.zoomScaleLocation,this.zoom),this.checkboardStyleLocation&&t.uniform1f(this.checkboardStyleLocation,this.gridType);const p=t.getAttribLocation(e,"a_Position");if(p===-1)throw new Error("Attribute a_Position not found in grid program");t.vertexAttribPointer(p,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(p),t.drawArrays(t.TRIANGLES,0,this.vertexCount),t.bindBuffer(t.ARRAY_BUFFER,null),t.disableVertexAttribArray(p)}destroy(){this.buffer&&(this.buffer=null)}hitTest(t,e){return!1}setUpUniforms(t,e){const r=new Float32Array([1,0,0,0,1,0,0,0,1]);this.viewProjectionInvLocation=t.getUniformLocation(e,"u_ViewProjectionInvMatrix"),this.zoomScaleLocation=t.getUniformLocation(e,"u_ZoomScale"),this.checkboardStyleLocation=t.getUniformLocation(e,"u_CheckboardStyle"),t.uniformMatrix3fv(this.viewProjectionInvLocation,!1,r),t.uniform1f(this.zoomScaleLocation,this.zoom),t.uniform1f(this.checkboardStyleLocation,1)}}const Of=.02,Af=20;class Ef{constructor(t,e,r,o){this.viewportX=0,this.viewportY=0,this.state=t,this.updateCameraPos=this.updateCameraPos.bind(this),this.updateZoom=this.updateZoom.bind(this),this.onWheel=this.onWheel.bind(this),this.worldToCamera=this.worldToCamera.bind(this),this.getWorldCoords=o,this.setWorldMatrix=e,this.updateWorldMatrix=r,this.updateReaction=Fh(()=>this.state.stateVector,()=>this.updateViewMatrix()),this.updateViewMatrix()}updateViewMatrix(){this.setWorldMatrix(this.state.canvasMatrix),this.updateWorldMatrix()}setViewPortDimension(t,e){this.state.width!==t&&this.state.setWidth(t),this.state.height!==e&&this.state.setHeight(e)}getBoundingBox(){const[t,e]=this.getWorldCoords(this.viewportX,this.viewportY),[r,o]=this.getWorldCoords(this.state.width+this.viewportX,this.state.height+this.viewportY);return new dn(t,e,r,o)}onWheel(t){t.preventDefault();const r=Math.exp(-t.deltaY*.003);this.updateZoom(t.clientX,t.clientY,r)}updateCameraPos(t,e){this.state.incrementPosition(t,e)}updateZoom(t,e,r){const[o,u]=this.getWorldCoords(t,e);this.state.setZoom(Math.min(Af,Math.max(Of,this.state.zoom*r)));const[l,f]=this.getWorldCoords(t,e);this.state.incrementPosition(o-l,u-f)}worldToCamera(t,e){const r=this.state.cameraMatrix,o=r[0]*t+r[1]*e+r[2],u=r[3]*t+r[4]*e+r[5];return[o,u]}dispose(){this.updateReaction&&(this.updateReaction(),this.updateReaction=void 0)}}const Ha="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBmaWxsPSIjYjNiM2IzIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjUgNmEyLjI1IDIuMjUgMCAwIDEgMi4yNS0yLjI1aDE2LjVBMi4yNSAyLjI1IDAgMCAxIDIyLjUgNnYxMmEyLjI1IDIuMjUgMCAwIDEtMi4yNSAyLjI1SDMuNzVBMi4yNSAyLjI1IDAgMCAxIDEuNSAxOHpNMyAxNi4wNlYxOGMwIC40MTQuMzM2Ljc1Ljc1Ljc1aDE2LjVBLjc1Ljc1IDAgMCAwIDIxIDE4di0xLjk0bC0yLjY5LTIuNjg5YTEuNSAxLjUgMCAwIDAtMi4xMiAwbC0uODguODc5bC45Ny45N2EuNzUuNzUgMCAxIDEtMS4wNiAxLjA2bC01LjE2LTUuMTU5YTEuNSAxLjUgMCAwIDAtMi4xMiAwem0xMC4xMjUtNy44MWExLjEyNSAxLjEyNSAwIDEgMSAyLjI1IDBhMS4xMjUgMS4xMjUgMCAwIDEtMi4yNSAwIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=",Ln=240;function Xa(n){return{x:n.x??0,y:n.y??0,sx:n.sx??1,sy:n.sy??1}}function Js(n){return n.children.map(lc)}function lc(n){return n instanceof Cr?{type:"Img",id:n.seq,renderOrder:n.renderOrder,transform:Xa(n),width:n.width,height:n.height,fileId:n.fileId,children:n.children?.length?Js(n):void 0}:n instanceof We?{type:"Rect",id:n.seq,renderOrder:n.renderOrder,transform:Xa(n),width:n.width,height:n.height,color:n.color,children:n.children?.length?Js(n):void 0}:n instanceof cc?{type:"Grid",style:n.gridType}:{type:"Renderable",children:n.children?.length?Js(n):void 0}}function go(n,t){const{gl:e}=n;return{version:1,canvas:{width:e.canvas.width,height:e.canvas.height,dpr:window.devicePixelRatio||1},camera:{x:n.camera.state.x,y:n.camera.state.y,zoom:n.camera.state.zoom},root:lc(n),files:t}}async function yo(n,t,e,r){t.children.length=0,n.camera&&(t.camera.state.setZoom(n.camera.zoom),t.camera.state.setX(n.camera.x),t.camera.state.setY(n.camera.y));async function o(u,l){let f;switch(u.type){case"Rect":f=new We({x:u.transform.x,y:u.transform.y,width:u.width,height:u.height}),f.setScale(u.transform.sx,u.transform.sy),t.appendChild(f);break;case"Img":let p;try{p=n.files&&Array.isArray(n.files)?n.files.find(I=>I.id===u.fileId)?.dataURL??Ha:Ha,r&&r(p);const m=u.width,_=u.height,S=await Tf(p,m*u.transform.sx,_*u.transform.sy);if(f=new Cr({x:u.transform.x,y:u.transform.y,src:S,width:m,height:_}),n.files&&Array.isArray(n.files)){const R=n.files.find(I=>I.id===u.fileId);f.src=R.dataURL}else e(u.fileId).then(R=>{f.src=R.dataURL}).catch(R=>console.error("Image not loaded",R));f.fileId=u.fileId??await xo(p),f.setScale(u.transform.sx,u.transform.sy),t.appendChild(f),typeof u.renderOrder=="number"&&(f.renderOrder=u.renderOrder)}catch{console.error(`Failed to match image to restore with source: ${p}`)}finally{break}case"Grid":l instanceof zi&&(l.grid.gridType=u.style);break}if(u.children)for(const p of u.children)await o(p,f)}return await o(n.root,t),t}async function Cf(n){const t=new Image;return t.crossOrigin="anonymous",new Promise((e,r)=>{t.onload=()=>e(t),t.onerror=o=>r(o),t.src=n})}async function Tf(n,t,e,r="#d6d6d6ff"){let o=null,u;n instanceof Blob?(o=URL.createObjectURL(n),u=o):u=n;try{let l=null;try{l=await Cf(u)}catch{}const f=t&&t>0?t:l?.naturalWidth??Ln,p=e&&e>0?e:l?.naturalHeight??Ln,m=document.createElement("canvas");m.width=f,m.height=p;const _=m.getContext("2d");if(_.fillStyle=r,_.fillRect(0,0,f,p),l){const S=Math.min(f/l.naturalWidth,p/l.naturalHeight),R=l.naturalHeight*S,I=l.naturalWidth*S;let j=Ln,V=Ln;(Ln>R||Ln>I)&&(j=I,V=R);const W=Math.round((f-j)/2),tt=Math.round((p-V)/2);_.drawImage(l,0,0,l.naturalWidth,l.naturalHeight,W,tt,j,V)}return m.toDataURL("image/png")}finally{o&&URL.revokeObjectURL(o)}}var ue,we,cn,zn,ut,xe,Kn,ln,Se,ze,kt,Wn,qi,Vn;const Ot=class Ot extends ac{constructor(e,r,o,u,l,f){super();$t(this,ue);$t(this,we);$t(this,cn);$t(this,zn);$t(this,ut);$t(this,xe);$t(this,Kn);$t(this,ln);$t(this,Se);$t(this,ze);$t(this,kt);$t(this,Wn);$t(this,qi);$t(this,Vn);Pt(this,ze,!0),this.orderDirty=!0,this.renderList=[],Pt(this,ue,e),Pt(this,we,o),Pt(this,cn,r),Pt(this,Se,new cc),Pt(this,ut,e.getContext("webgl",{alpha:!0,premultipliedAlpha:!1})),F(this,ut).enable(F(this,ut).BLEND),F(this,ut).blendFunc(F(this,ut).SRC_ALPHA,F(this,ut).ONE_MINUS_SRC_ALPHA),F(this,ut).getExtension("OES_standard_derivatives"),F(this,ut).enable(F(this,ut).DEPTH_TEST),F(this,ut).depthFunc(F(this,ut).LEQUAL),Pt(this,xe,Gs(F(this,ut),ml,gl)),Pt(this,Kn,Gs(F(this,ut),bl,wl)),Pt(this,ln,Gs(F(this,ut),yl,_l)),this.writeToStorage=u,this.saveImgFileToStorage=l,this.getContainerDimension=f,this.engine=this.engine.bind(this),this.getBoundingClientRect=this.getBoundingClientRect.bind(this),this.appendChild=this.appendChild.bind(this),this.addImageToCanvas=this.addImageToCanvas.bind(this),this.setShapeZOrder=this.setShapeZOrder.bind(this),this.toggleGrid=this.toggleGrid.bind(this),this.changeMode=this.changeMode.bind(this),this.getSelected=this.getSelected.bind(this),this.updateZoomByFixedAmount=this.updateZoomByFixedAmount.bind(this),this.assignEventListener=this.assignEventListener.bind(this),this.getWorldsCoordsFromCanvas=(R,I)=>an(R,I,this);const p=(R,I)=>an(R+this.camera.viewportX,I+this.camera.viewportY,this);this.exportState=this.exportState.bind(this),this.importState=this.importState.bind(this),this.clearChildren=this.clearChildren.bind(this),Pt(this,kt,new mf(r,o,this.gl,F(this,xe),()=>this.worldMatrix,()=>this.children,this.getWorldsCoordsFromCanvas,p));const m=new vf({});Pt(this,zn,new Ef(m,this.setWorldMatrix,this.updateWorldMatrix,this.getWorldsCoordsFromCanvas)),Pt(this,qi,new _f(r,o,()=>this.selectionManager.deleteSelected(this),this.assignEventListener)),Pt(this,Vn,new bf(o,this.selectionManager.isMultiBoundingBoxHit,this.selectionManager.isBoundingBoxHit,this.getWorldsCoordsFromCanvas,this.assignEventListener));const _=new xf,S={history:r,eventHub:o,state:_,isContextMenuActive:()=>F(this,Vn).isActive,getSelected:()=>F(this,kt).selected,getChildren:()=>this.children,getWorldMatrix:()=>this.worldMatrix,getCanvasGlobalClick:()=>this.isGlobalClick,setCanvasGlobalClick:R=>this.isGlobalClick=R,getWorldCoords:this.getWorldsCoordsFromCanvas,updateCameraPos:this.camera.updateCameraPos,onWheel:this.camera.onWheel,setCursorStyle:R=>e.style.cursor=R,paste:(R,I)=>yu(R,I,this,r),assignEventListener:this.assignEventListener,closeMarquee:F(this,kt).clearMarquee,selectionPointerMove:(R,I,j,V,W)=>F(this,kt).onPointerMove(R,I,j,V,W,()=>this.isGlobalClick,this.camera.updateCameraPos,()=>this.worldMatrix),onSelectionPointerDown:this.selectionManager.onSelectionPointerDown,checkIfSelectionHit:this.selectionManager.hitTest,addSelection:this.selectionManager.add,clearSelection:this.selectionManager.clear,isSelection:this.selectionManager.isRectSelected,hitTestAdjustedCorner:this.selectionManager.hitTestAdjustedCorner};Pt(this,Wn,new yf(S)),F(this,we).on("save",this.writeToStorage)}markOrderDirty(){this.orderDirty=!0}get gl(){return F(this,ut)}get grid(){return F(this,Se)}get history(){return F(this,cn)}get eventHub(){return F(this,we)}get pointerEventManager(){return F(this,Wn)}get selectionManager(){return F(this,kt)}get contextMenuManager(){return F(this,Vn)}get canvas(){return F(this,ue)}get camera(){return F(this,zn)}get isGlobalClick(){return F(this,ze)}set isGlobalClick(e){Pt(this,ze,e)}get basicShapeProgram(){return F(this,xe)}engine(){return this}get totalNumberOfChildren(){return this.children.length}get numberOfChildrenRendered(){return this.renderList.length}appendChild(e){if(super.appendChild(e),e instanceof Xn){const r=this.children.map(u=>u.renderOrder),o=r.length?Math.max(...r):0;e.renderOrder=o+1}return this.markOrderDirty(),e}removeChild(e){this.state.removeChild(e),F(this,kt)&&F(this,kt).remove([e]),e.destroy(),this.markOrderDirty()}getChild(e){return this.state.getChild(e)}updateWorldMatrix(){F(this,Se).updateWorldMatrix(this.worldMatrix),this.children.forEach(e=>{e.updateWorldMatrix(this.worldMatrix)}),F(this,kt).update()}render(){F(this,ut).clearColor(0,0,0,0),F(this,ut).clear(F(this,ut).COLOR_BUFFER_BIT|F(this,ut).DEPTH_BUFFER_BIT),F(this,ut).viewport(0,0,F(this,ut).canvas.width,F(this,ut).canvas.height);const e=this.canvas.parentElement.getBoundingClientRect();this.camera.setViewPortDimension(e.width,e.height),F(this,ut).useProgram(F(this,ln));const r=F(this,ut).getUniformLocation(F(this,ln),"u_z");F(this,ut).uniform1f(r,0),F(this,Se).render(F(this,ut),F(this,ln));const o=this.camera.getBoundingBox();this.renderList=[];for(const _ of this.children)dn.isColliding(o,_.getBoundingBox())?(this.renderList.push(_),_.culled=!1):_.culled=!0;const[u,l]=an(0,0,this),[f,p]=an(window.screen.width,window.screen.height,this),m=new dn(u,l,f,p);this.renderList.forEach(_=>{if(_ instanceof Cr){const S=_.determineIfLowRes(m,this.camera.state.zoom);_.setUseLowRes(S,this.gl)}});for(const _ of this.renderList){let S;_ instanceof Cr?S=F(this,Kn):_ instanceof Xn&&(S=F(this,xe)),F(this,ut).useProgram(S);const R=F(this,ut).getUniformLocation(S,"u_z");F(this,ut).uniform1f(R,_.getZ()),_.render(F(this,ut),S)}F(this,kt).render(F(this,xe))}destroy(){F(this,ut).deleteProgram(F(this,xe)),F(this,ut).deleteProgram(F(this,Kn)),this.children.forEach(e=>{"destroy"in e&&e.destroy()}),this.clearChildren()}getDOM(){return F(this,ue)}assignEventListener(e,r,o){F(this,ue).addEventListener(e,r,o)}hitTest(e,r){return Pt(this,ze,!0),F(this,ze)}async addImageToCanvas(e,r,o,u=1,l=1,f=!1){const p=new Cr({x:r,y:o,src:e,sx:u,sy:l});if(this.saveImgFileToStorage(e).then(m=>p.fileId=m),f){const m=new Image;m.src=e.startsWith("data:image/png")?e:await mu(e),m.onload=()=>{const _=m.naturalWidth||m.width||0,S=m.naturalHeight||m.height||0;(_||S)&&p.updateTranslation(-_/2,-S/2),p.src=m.src,this.appendChild(p)}}return F(this,we).emit("save"),F(this,we).emit(Ae.Change),p}exportState(){return go(this)}async importState(e,r){return await yo(e,this,r)}clearChildren(){this.selectionManager.clear(),this.state.clearChildren(),F(this,cn).clear()}toggleGrid(){F(this,Se).changeGridType(F(this,Se).gridType===Oi.GRID?Oi.NONE:Oi.GRID)}getSelected(){return F(this,kt).selected}setShapeZOrder(e=!0){if(F(this,kt).multiBoundingBox||F(this,kt).boundingBoxes.size!=1)return;const r=Array.from(F(this,kt).boundingBoxes)[0].target,o={ref:r,start:{renderOrder:r.renderOrder}},u=this.children.map(p=>p.renderOrder);if(u.length===0)throw new Error("Order unexpected missing.");const l=Math.max(...u),f=Math.min(...u);r.renderOrder=e?l+1:f-1,o.end={renderOrder:r.renderOrder},this.markOrderDirty(),F(this,cn).push(wf([o])),F(this,we).emit(Ae.Change)}changeMode(){F(this,Wn).changeMode(),F(this,kt).clear()}updateZoomByFixedAmount(e=1){F(this,zn).updateZoom(F(this,ue).width/2,F(this,ue).height/2,Math.exp(.5*.3*e))}getBoundingClientRect(){return F(this,ue).getBoundingClientRect()}wrapWebGLContext(e){const r=e.createTexture.bind(e);e.createTexture=()=>(Ot.webglStats.texturesCreated++,console.log(`Textures created: ${Ot.webglStats.texturesCreated}`),r());const o=e.deleteTexture.bind(e);e.deleteTexture=f=>(f&&(Ot.webglStats.texturesDeleted++,console.log(`Textures deleted: ${Ot.webglStats.texturesDeleted}`)),o(f));const u=e.createShader.bind(e);e.createShader=f=>(Ot.webglStats.shadersCreated++,console.log(`Shaders created: ${Ot.webglStats.shadersCreated}`),u(f));const l=e.deleteShader.bind(e);return e.deleteShader=f=>(f&&(Ot.webglStats.shadersDeleted++,console.log(`Shaders deleted: ${Ot.webglStats.shadersDeleted}`)),l(f)),e}static getWebGLStats(){return{...Ot.webglStats,buffersLeaked:Ot.webglStats.buffersCreated-Ot.webglStats.buffersDeleted,programsLeaked:Ot.webglStats.programsCreated-Ot.webglStats.programsDeleted,texturesLeaked:Ot.webglStats.texturesCreated-Ot.webglStats.texturesDeleted,shadersLeaked:Ot.webglStats.shadersCreated-Ot.webglStats.shadersDeleted}}};ue=new WeakMap,we=new WeakMap,cn=new WeakMap,zn=new WeakMap,ut=new WeakMap,xe=new WeakMap,Kn=new WeakMap,ln=new WeakMap,Se=new WeakMap,ze=new WeakMap,kt=new WeakMap,Wn=new WeakMap,qi=new WeakMap,Vn=new WeakMap,Ot.webglStats={buffersCreated:0,buffersDeleted:0,programsCreated:0,programsDeleted:0,texturesCreated:0,texturesDeleted:0,shadersCreated:0,shadersDeleted:0};let zi=Ot;const Ya=25;class Mf{constructor(){this._undoStack=[],this._redoStack=[],this._openGroup=null}get undoStack(){return this._undoStack}begin(t){if(this._openGroup)throw new Error("History group already open");this._openGroup=[],this._openLabel=t}push(t){if(this._openGroup)this._openGroup.push(t);else{for(;this._undoStack.length>=Ya;)this._undoStack.shift();this._undoStack.push([t]),t.do(),this._redoStack.length=0}}commit(){if(!this._openGroup)return;const t=this._openGroup;this._openGroup=null;for(const e of t)e.do();for(;this._undoStack.length>=Ya;)this._undoStack.shift();this._undoStack.push(t),this._redoStack.length=0,this._openLabel=void 0}cancel(){this._openGroup=null,this._openLabel=void 0}canUndo(){return this._undoStack.length>0}canRedo(){return this._redoStack.length>0}undo(){const t=this._undoStack.pop();if(t){for(let e=t.length-1;e>=0;e--)t[e].undo();this._redoStack.push(t)}}redo(){const t=this._redoStack.pop();if(t){for(const e of t)e.do();this._undoStack.push(t)}}clear(){this._undoStack.length=0,this._redoStack.length=0,this._openGroup=null,this._openLabel=void 0}}const Ai=globalThis,Ro=Ai.ShadowRoot&&(Ai.ShadyCSS===void 0||Ai.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ko=Symbol(),Za=new WeakMap;let hc=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==ko)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(Ro&&t===void 0){const r=e!==void 0&&e.length===1;r&&(t=Za.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Za.set(e,t))}return t}toString(){return this.cssText}};const Pf=n=>new hc(typeof n=="string"?n:n+"",void 0,ko),Rf=(n,...t)=>{const e=n.length===1?n[0]:t.reduce(((r,o,u)=>r+(l=>{if(l._$cssResult$===!0)return l.cssText;if(typeof l=="number")return l;throw Error("Value passed to 'css' function must be a 'css' function result: "+l+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+n[u+1]),n[0]);return new hc(e,n,ko)},kf=(n,t)=>{if(Ro)n.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const e of t){const r=document.createElement("style"),o=Ai.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=e.cssText,n.appendChild(r)}},Qa=Ro?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const r of t.cssRules)e+=r.cssText;return Pf(e)})(n):n;const{is:If,defineProperty:Df,getOwnPropertyDescriptor:Bf,getOwnPropertyNames:Lf,getOwnPropertySymbols:jf,getPrototypeOf:$f}=Object,is=globalThis,Ja=is.trustedTypes,Nf=Ja?Ja.emptyScript:"",Uf=is.reactiveElementPolyfillSupport,Tr=(n,t)=>n,_o={toAttribute(n,t){switch(t){case Boolean:n=n?Nf:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},fc=(n,t)=>!If(n,t),tu={attribute:!0,type:String,converter:_o,reflect:!1,useDefault:!1,hasChanged:fc};Symbol.metadata??=Symbol("metadata"),is.litPropertyMetadata??=new WeakMap;class jn extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=tu){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const r=Symbol(),o=this.getPropertyDescriptor(t,r,e);o!==void 0&&Df(this.prototype,t,o)}}static getPropertyDescriptor(t,e,r){const{get:o,set:u}=Bf(this.prototype,t)??{get(){return this[e]},set(l){this[e]=l}};return{get:o,set(l){const f=o?.call(this);u?.call(this,l),this.requestUpdate(t,f,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??tu}static _$Ei(){if(this.hasOwnProperty(Tr("elementProperties")))return;const t=$f(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Tr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Tr("properties"))){const e=this.properties,r=[...Lf(e),...jf(e)];for(const o of r)this.createProperty(o,e[o])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[r,o]of e)this.elementProperties.set(r,o)}this._$Eh=new Map;for(const[e,r]of this.elementProperties){const o=this._$Eu(e,r);o!==void 0&&this._$Eh.set(o,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const o of r)e.unshift(Qa(o))}else t!==void 0&&e.push(Qa(t));return e}static _$Eu(t,e){const r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return kf(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){const r=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,r);if(o!==void 0&&r.reflect===!0){const u=(r.converter?.toAttribute!==void 0?r.converter:_o).toAttribute(e,r.type);this._$Em=t,u==null?this.removeAttribute(o):this.setAttribute(o,u),this._$Em=null}}_$AK(t,e){const r=this.constructor,o=r._$Eh.get(t);if(o!==void 0&&this._$Em!==o){const u=r.getPropertyOptions(o),l=typeof u.converter=="function"?{fromAttribute:u.converter}:u.converter?.fromAttribute!==void 0?u.converter:_o;this._$Em=o;const f=l.fromAttribute(e,u.type);this[o]=f??this._$Ej?.get(o)??f,this._$Em=null}}requestUpdate(t,e,r){if(t!==void 0){const o=this.constructor,u=this[t];if(r??=o.getPropertyOptions(t),!((r.hasChanged??fc)(u,e)||r.useDefault&&r.reflect&&u===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:o,wrapped:u},l){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,l??e??this[t]),u!==!0||l!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),o===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[o,u]of this._$Ep)this[o]=u;this._$Ep=void 0}const r=this.constructor.elementProperties;if(r.size>0)for(const[o,u]of r){const{wrapped:l}=u,f=this[o];l!==!0||this._$AL.has(o)||f===void 0||this.C(o,void 0,u,f)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((r=>r.hostUpdate?.())),this.update(e)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}}jn.elementStyles=[],jn.shadowRootOptions={mode:"open"},jn[Tr("elementProperties")]=new Map,jn[Tr("finalized")]=new Map,Uf?.({ReactiveElement:jn}),(is.reactiveElementVersions??=[]).push("2.1.1");const Io=globalThis,Ki=Io.trustedTypes,eu=Ki?Ki.createPolicy("lit-html",{createHTML:n=>n}):void 0,dc="$lit$",Fe=`lit$${Math.random().toFixed(9).slice(2)}$`,pc="?"+Fe,Ff=`<${pc}>`,yn=document,kr=()=>yn.createComment(""),Ir=n=>n===null||typeof n!="object"&&typeof n!="function",Do=Array.isArray,zf=n=>Do(n)||typeof n?.[Symbol.iterator]=="function",to=`[
|
|
150
|
-
\f\r]`,_r=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nu=/-->/g,ru=/>/g,on=RegExp(`>|${to}(?:([^\\s"'>=/]+)(${to}*=${to}*(?:[^
|
|
151
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),iu=/'/g,su=/"/g,vc=/^(?:script|style|textarea|title)$/i,Yn=Symbol.for("lit-noChange"),Mt=Symbol.for("lit-nothing"),ou=new WeakMap,un=yn.createTreeWalker(yn,129);function mc(n,t){if(!Do(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return eu!==void 0?eu.createHTML(t):t}const Kf=(n,t)=>{const e=n.length-1,r=[];let o,u=t===2?"<svg>":t===3?"<math>":"",l=_r;for(let f=0;f<e;f++){const p=n[f];let m,_,S=-1,R=0;for(;R<p.length&&(l.lastIndex=R,_=l.exec(p),_!==null);)R=l.lastIndex,l===_r?_[1]==="!--"?l=nu:_[1]!==void 0?l=ru:_[2]!==void 0?(vc.test(_[2])&&(o=RegExp("</"+_[2],"g")),l=on):_[3]!==void 0&&(l=on):l===on?_[0]===">"?(l=o??_r,S=-1):_[1]===void 0?S=-2:(S=l.lastIndex-_[2].length,m=_[1],l=_[3]===void 0?on:_[3]==='"'?su:iu):l===su||l===iu?l=on:l===nu||l===ru?l=_r:(l=on,o=void 0);const I=l===on&&n[f+1].startsWith("/>")?" ":"";u+=l===_r?p+Ff:S>=0?(r.push(m),p.slice(0,S)+dc+p.slice(S)+Fe+I):p+Fe+(S===-2?f:I)}return[mc(n,u+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]};class Dr{constructor({strings:t,_$litType$:e},r){let o;this.parts=[];let u=0,l=0;const f=t.length-1,p=this.parts,[m,_]=Kf(t,e);if(this.el=Dr.createElement(m,r),un.currentNode=this.el.content,e===2||e===3){const S=this.el.content.firstChild;S.replaceWith(...S.childNodes)}for(;(o=un.nextNode())!==null&&p.length<f;){if(o.nodeType===1){if(o.hasAttributes())for(const S of o.getAttributeNames())if(S.endsWith(dc)){const R=_[l++],I=o.getAttribute(S).split(Fe),j=/([.?@])?(.*)/.exec(R);p.push({type:1,index:u,name:j[2],strings:I,ctor:j[1]==="."?Vf:j[1]==="?"?qf:j[1]==="@"?Gf:ss}),o.removeAttribute(S)}else S.startsWith(Fe)&&(p.push({type:6,index:u}),o.removeAttribute(S));if(vc.test(o.tagName)){const S=o.textContent.split(Fe),R=S.length-1;if(R>0){o.textContent=Ki?Ki.emptyScript:"";for(let I=0;I<R;I++)o.append(S[I],kr()),un.nextNode(),p.push({type:2,index:++u});o.append(S[R],kr())}}}else if(o.nodeType===8)if(o.data===pc)p.push({type:2,index:u});else{let S=-1;for(;(S=o.data.indexOf(Fe,S+1))!==-1;)p.push({type:7,index:u}),S+=Fe.length-1}u++}}static createElement(t,e){const r=yn.createElement("template");return r.innerHTML=t,r}}function Zn(n,t,e=n,r){if(t===Yn)return t;let o=r!==void 0?e._$Co?.[r]:e._$Cl;const u=Ir(t)?void 0:t._$litDirective$;return o?.constructor!==u&&(o?._$AO?.(!1),u===void 0?o=void 0:(o=new u(n),o._$AT(n,e,r)),r!==void 0?(e._$Co??=[])[r]=o:e._$Cl=o),o!==void 0&&(t=Zn(n,o._$AS(n,t.values),o,r)),t}class Wf{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,o=(t?.creationScope??yn).importNode(e,!0);un.currentNode=o;let u=un.nextNode(),l=0,f=0,p=r[0];for(;p!==void 0;){if(l===p.index){let m;p.type===2?m=new Ur(u,u.nextSibling,this,t):p.type===1?m=new p.ctor(u,p.name,p.strings,this,t):p.type===6&&(m=new Hf(u,this,t)),this._$AV.push(m),p=r[++f]}l!==p?.index&&(u=un.nextNode(),l++)}return un.currentNode=yn,o}p(t){let e=0;for(const r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class Ur{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,o){this.type=2,this._$AH=Mt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Zn(this,t,e),Ir(t)?t===Mt||t==null||t===""?(this._$AH!==Mt&&this._$AR(),this._$AH=Mt):t!==this._$AH&&t!==Yn&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):zf(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Mt&&Ir(this._$AH)?this._$AA.nextSibling.data=t:this.T(yn.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:r}=t,o=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=Dr.createElement(mc(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(e);else{const u=new Wf(o,this),l=u.u(this.options);u.p(e),this.T(l),this._$AH=u}}_$AC(t){let e=ou.get(t.strings);return e===void 0&&ou.set(t.strings,e=new Dr(t)),e}k(t){Do(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,o=0;for(const u of t)o===e.length?e.push(r=new Ur(this.O(kr()),this.O(kr()),this,this.options)):r=e[o],r._$AI(u),o++;o<e.length&&(this._$AR(r&&r._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const r=t.nextSibling;t.remove(),t=r}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}}class ss{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,o,u){this.type=1,this._$AH=Mt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=u,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=Mt}_$AI(t,e=this,r,o){const u=this.strings;let l=!1;if(u===void 0)t=Zn(this,t,e,0),l=!Ir(t)||t!==this._$AH&&t!==Yn,l&&(this._$AH=t);else{const f=t;let p,m;for(t=u[0],p=0;p<u.length-1;p++)m=Zn(this,f[r+p],e,p),m===Yn&&(m=this._$AH[p]),l||=!Ir(m)||m!==this._$AH[p],m===Mt?t=Mt:t!==Mt&&(t+=(m??"")+u[p+1]),this._$AH[p]=m}l&&!o&&this.j(t)}j(t){t===Mt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Vf extends ss{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Mt?void 0:t}}class qf extends ss{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Mt)}}class Gf extends ss{constructor(t,e,r,o,u){super(t,e,r,o,u),this.type=5}_$AI(t,e=this){if((t=Zn(this,t,e,0)??Mt)===Yn)return;const r=this._$AH,o=t===Mt&&r!==Mt||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,u=t!==Mt&&(r===Mt||o);o&&this.element.removeEventListener(this.name,this,r),u&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class Hf{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Zn(this,t)}}const Xf=Io.litHtmlPolyfillSupport;Xf?.(Dr,Ur),(Io.litHtmlVersions??=[]).push("3.3.1");const Yf=(n,t,e)=>{const r=e?.renderBefore??t;let o=r._$litPart$;if(o===void 0){const u=e?.renderBefore??null;r._$litPart$=o=new Ur(t.insertBefore(kr(),u),u,void 0,e??{})}return o._$AI(n),o};const Bo=globalThis;class Mr extends jn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Yf(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Yn}}Mr._$litElement$=!0,Mr.finalized=!0,Bo.litElementHydrateSupport?.({LitElement:Mr});const Zf=Bo.litElementPolyfillSupport;Zf?.({LitElement:Mr});(Bo.litElementVersions??=[]).push("4.2.1");const Qf=n=>(t,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(n,t)})):customElements.define(n,t)};class gc{constructor(t,e){this.options=[],this.rootNode=e,this._el=document.createElement("div"),this._el.classList.add("context-menu"),t.options.forEach((r,o)=>{this.createOptionGroup(r),o!==t.options.length-1&&this.addDivider()}),this._el.addEventListener("contextmenu",r=>{r.preventDefault()})}get el(){return this._el}attachToParent(t){t.appendChild(this.el)}createOptionGroup(t){const e=new Jf(t,this.rootNode);this.options.push(e),this.el.appendChild(e.el)}addDivider(){const t=document.createElement("hr");t.classList.add("context-menu-divider"),this.el.appendChild(t)}}class Jf{constructor(t,e){this.childOptions=[],this.rootNode=e,this._el=document.createElement("div"),this.createOptionElement=this.createOptionElement.bind(this),t.childOptions.forEach(r=>this.createOptionElement(r))}get el(){return this._el}attachToParent(t){t.appendChild(this.el)}createOptionElement(t){t.parent=this;const e=new td(t,this.rootNode);this.childOptions.push(e)}}class td{get el(){return this._el}constructor(t,e){this.displayText=t.text,this.rootNode=e,this.parent=t.parent,this._el=document.createElement("button"),this._el.textContent=t.text,this._el.classList.add("context-menu-option"),this.parent.el.appendChild(this._el),"onClick"in t&&this._el.addEventListener("click",t.onClick),this._el.addEventListener("pointerenter",r=>ed(r,t,this._el,this.rootNode)),this._el.addEventListener("contextmenu",r=>{r.preventDefault()})}}function ed(n,t,e,r){if(!r)return;const o=r.querySelector(".sub-context-menu");if(o&&o.remove(),t.subMenu){const u=new gc(t.subMenu,this);r.appendChild(u.el),u.el.id=`${t.text}-context-menu`,u.el.classList.add("sub-context-menu");const l=r.getBoundingClientRect(),f=e.getBoundingClientRect(),p=u.el.getBoundingClientRect(),m=l.right-l.left,_=l.bottom-l.top,S=f.right+p.width;f.top+p.height>_?u._el.style.top=`${f.bottom-p.height}px`:u._el.style.top=`${f.top}px`,S>m?u._el.style.left=`${f.left-p.width}px`:u._el.style.left=`${f.right}px`}}const _i=5;function os(n){const t=this;return function(...e){const r=n.apply(t,e);return t.clearContextMenu(),r}}function nd(n,t,e="single"){const r=new gc(e==="single"?this.singleImageMenuOptions:e==="multi"?this.multiImageMenuOptions:this.canvasImageMenuOptions,this.rootDiv);if(!this.rootDiv){console.error("Can't add to parent div");return}r.attachToParent(this.rootDiv);const o=this.getBoundingClientRect(),u=n-o.left,l=t-o.top,f=o.right-o.left,p=o.bottom-o.top,m=r.el.getBoundingClientRect(),_=[u+m.width>f?1:0,l+m.height>p?1:0],S=m.height*_[1],R=m.width*_[0];if(S>p){const I=p-2*_i;r._el.style.height=`${I}px`,r._el.style.top=`${_i}px`}else r._el.style.top=`${l-S}px`;R>f?(r._el.style.width=`${f-2*_i}px`,r._el.style.left=`${_i}px`):r._el.style.left=`${u-R}px`}function rd(){const n=this.renderRoot.querySelector(".context-menu");n&&(n.remove(),this.eventHub.emit(Oe.Close))}function id(){return this.renderRoot.querySelector(".context-menu")!==null}function sd(){const n=os.bind(this);return{options:[{childOptions:[{text:"Cut",onClick:async()=>{await this.copyImage.bind(this)(),n(this.deleteSelectedImages.bind(this))()}},{text:"Copy",onClick:n(this.copyImage.bind(this))},{text:"Paste",onClick:t=>n(this.pasteImage.bind(this))(t)},{text:"Delete",onClick:n(this.deleteSelectedImages.bind(this))}]},{childOptions:[{text:"Flip Horizontal",onClick:n(this.flipHorizontal.bind(this))},{text:"Flip Vertical",onClick:n(this.flipVertical.bind(this))}]}]}}function od(n){const t=os.bind(this);return{options:[...n??[],{childOptions:[{text:"Send to Front",onClick:()=>t(this.sendShapeToNewZOrder.bind(this))(!0)},{text:"Send to Back",onClick:()=>t(this.sendShapeToNewZOrder.bind(this))(!1)}]}]}}function ad(n){const t=os.bind(this);return{options:[...n??[],{childOptions:[{text:"Align",onHover:()=>{},subMenu:{options:[{childOptions:[{text:"Align Left",onClick:()=>t(this.align.bind(this))("left")},{text:"Align Right",onClick:()=>t(this.align.bind(this))("right")},{text:"Align Top",onClick:()=>t(this.align.bind(this))("top")},{text:"Align Bottom",onClick:()=>t(this.align.bind(this))("bottom")}]}]}},{text:"Normalize by First",onHover:()=>{},subMenu:{options:[{childOptions:[{text:"Height",onClick:()=>t(this.normalizeSelection.bind(this))("height","first")},{text:"Width",onClick:()=>t(this.normalizeSelection.bind(this))("width","first")},{text:"Size",onClick:()=>t(this.normalizeSelection.bind(this))("size","first")},{text:"Scale",onClick:()=>t(this.normalizeSelection.bind(this))("scale","first")}]}]}},{text:"Normalize by Average",onHover:()=>{},subMenu:{options:[{childOptions:[{text:"Height",onClick:()=>t(this.normalizeSelection.bind(this))("height","average")},{text:"Width",onClick:()=>t(this.normalizeSelection.bind(this))("width","average")},{text:"Size",onClick:()=>t(this.normalizeSelection.bind(this))("size","average")},{text:"Scale",onClick:()=>t(this.normalizeSelection.bind(this))("scale","average")}]}]}}]}]}}function ud(n){const t=os.bind(this);return{options:[...n??[],{childOptions:[{text:"Change mode",onClick:()=>t(this.togglePointerMode.bind(this))()},{text:"Toggle Grid",onClick:()=>t(this.toggleGrid.bind(this))()}]},{childOptions:[{text:"Save",onClick:()=>t(this.saveToCanvasStorage.bind(this))()},{text:"Paste",onClick:e=>t(this.pasteImage.bind(this))(e)}]}]}}class Lo{_touch(){this._lastRetrieved=Date.now()}get id(){return this._touch(),this._id}get dataURL(){return this._touch(),this._dataURL}get mimetype(){return this._touch(),this._mimetype}get created(){return this._touch(),this._created}get lastRetrieved(){return this._lastRetrieved}constructor(t){this._dataURL=t,this._mimetype=ol(t),this._created=Date.now(),this._lastRetrieved=Date.now()}static async create(t){const e=new Lo(t);return e._id=await xo(t),e}}class cd{}class ld{}var hd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ei={exports:{}},fd=Ei.exports,au;function dd(){return au||(au=1,(function(n,t){(function(e,r){n.exports=r()})(fd,function(){var e=function(i,s){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,c){a.__proto__=c}||function(a,c){for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(a[h]=c[h])})(i,s)},r=function(){return(r=Object.assign||function(i){for(var s,a=1,c=arguments.length;a<c;a++)for(var h in s=arguments[a])Object.prototype.hasOwnProperty.call(s,h)&&(i[h]=s[h]);return i}).apply(this,arguments)};function o(i,s,a){for(var c,h=0,d=s.length;h<d;h++)!c&&h in s||((c=c||Array.prototype.slice.call(s,0,h))[h]=s[h]);return i.concat(c||Array.prototype.slice.call(s))}var u=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:hd,l=Object.keys,f=Array.isArray;function p(i,s){return typeof s!="object"||l(s).forEach(function(a){i[a]=s[a]}),i}typeof Promise>"u"||u.Promise||(u.Promise=Promise);var m=Object.getPrototypeOf,_={}.hasOwnProperty;function S(i,s){return _.call(i,s)}function R(i,s){typeof s=="function"&&(s=s(m(i))),(typeof Reflect>"u"?l:Reflect.ownKeys)(s).forEach(function(a){j(i,a,s[a])})}var I=Object.defineProperty;function j(i,s,a,c){I(i,s,p(a&&S(a,"get")&&typeof a.get=="function"?{get:a.get,set:a.set,configurable:!0}:{value:a,configurable:!0,writable:!0},c))}function V(i){return{from:function(s){return i.prototype=Object.create(s.prototype),j(i.prototype,"constructor",i),{extend:R.bind(null,i.prototype)}}}}var W=Object.getOwnPropertyDescriptor,tt=[].slice;function ot(i,s,a){return tt.call(i,s,a)}function Q(i,s){return s(i)}function et(i){if(!i)throw new Error("Assertion Failed")}function At(i){u.setImmediate?setImmediate(i):setTimeout(i,0)}function Et(i,s){if(typeof s=="string"&&S(i,s))return i[s];if(!s)return i;if(typeof s!="string"){for(var a=[],c=0,h=s.length;c<h;++c){var d=Et(i,s[c]);a.push(d)}return a}var v=s.indexOf(".");if(v!==-1){var g=i[s.substr(0,v)];return g==null?void 0:Et(g,s.substr(v+1))}}function yt(i,s,a){if(i&&s!==void 0&&!("isFrozen"in Object&&Object.isFrozen(i)))if(typeof s!="string"&&"length"in s){et(typeof a!="string"&&"length"in a);for(var c=0,h=s.length;c<h;++c)yt(i,s[c],a[c])}else{var d,v,g=s.indexOf(".");g!==-1?(d=s.substr(0,g),(v=s.substr(g+1))===""?a===void 0?f(i)&&!isNaN(parseInt(d))?i.splice(d,1):delete i[d]:i[d]=a:yt(g=!(g=i[d])||!S(i,d)?i[d]={}:g,v,a)):a===void 0?f(i)&&!isNaN(parseInt(s))?i.splice(s,1):delete i[s]:i[s]=a}}function Fr(i){var s,a={};for(s in i)S(i,s)&&(a[s]=i[s]);return a}var as=[].concat;function er(i){return as.apply([],i)}var Xe="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(er([8,16,32,64].map(function(i){return["Int","Uint","Float"].map(function(s){return s+i+"Array"})}))).filter(function(i){return u[i]}),nr=new Set(Xe.map(function(i){return u[i]})),Ge=null;function ve(i){return Ge=new WeakMap,i=(function s(a){if(!a||typeof a!="object")return a;var c=Ge.get(a);if(c)return c;if(f(a)){c=[],Ge.set(a,c);for(var h=0,d=a.length;h<d;++h)c.push(s(a[h]))}else if(nr.has(a.constructor))c=a;else{var v,g=m(a);for(v in c=g===Object.prototype?{}:Object.create(g),Ge.set(a,c),a)S(a,v)&&(c[v]=s(a[v]))}return c})(i),Ge=null,i}var us={}.toString;function rr(i){return us.call(i).slice(8,-1)}var ir=typeof Symbol<"u"?Symbol.iterator:"@@iterator",cs=typeof ir=="symbol"?function(i){var s;return i!=null&&(s=i[ir])&&s.apply(i)}:function(){return null};function me(i,s){return s=i.indexOf(s),0<=s&&i.splice(s,1),0<=s}var Re={};function ge(i){var s,a,c,h;if(arguments.length===1){if(f(i))return i.slice();if(this===Re&&typeof i=="string")return[i];if(h=cs(i)){for(a=[];!(c=h.next()).done;)a.push(c.value);return a}if(i==null)return[i];if(typeof(s=i.length)!="number")return[i];for(a=new Array(s);s--;)a[s]=i[s];return a}for(s=arguments.length,a=new Array(s);s--;)a[s]=arguments[s];return a}var ls=typeof Symbol<"u"?function(i){return i[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},ar=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Vt=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ar),xc={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Sn(i,s){this.name=i,this.message=s}function $o(i,s){return i+". Errors: "+Object.keys(s).map(function(a){return s[a].toString()}).filter(function(a,c,h){return h.indexOf(a)===c}).join(`
|
|
152
|
-
`)}function zr(i,s,a,c){this.failures=s,this.failedKeys=c,this.successCount=a,this.message=$o(i,s)}function On(i,s){this.name="BulkError",this.failures=Object.keys(s).map(function(a){return s[a]}),this.failuresByPos=s,this.message=$o(i,this.failures)}V(Sn).from(Error).extend({toString:function(){return this.name+": "+this.message}}),V(zr).from(Sn),V(On).from(Sn);var hs=Vt.reduce(function(i,s){return i[s]=s+"Error",i},{}),Sc=Sn,Z=Vt.reduce(function(i,s){var a=s+"Error";function c(h,d){this.name=a,h?typeof h=="string"?(this.message="".concat(h).concat(d?`
|
|
153
|
-
`+d:""),this.inner=d||null):typeof h=="object"&&(this.message="".concat(h.name," ").concat(h.message),this.inner=h):(this.message=xc[s]||a,this.inner=null)}return V(c).from(Sc),i[s]=c,i},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var No=ar.reduce(function(i,s){return i[s+"Error"]=Z[s],i},{}),Kr=Vt.reduce(function(i,s){return["Syntax","Type","Range"].indexOf(s)===-1&&(i[s+"Error"]=Z[s]),i},{});function pt(){}function sr(i){return i}function Oc(i,s){return i==null||i===sr?s:function(a){return s(i(a))}}function He(i,s){return function(){i.apply(this,arguments),s.apply(this,arguments)}}function Ac(i,s){return i===pt?s:function(){var a=i.apply(this,arguments);a!==void 0&&(arguments[0]=a);var c=this.onsuccess,h=this.onerror;this.onsuccess=null,this.onerror=null;var d=s.apply(this,arguments);return c&&(this.onsuccess=this.onsuccess?He(c,this.onsuccess):c),h&&(this.onerror=this.onerror?He(h,this.onerror):h),d!==void 0?d:a}}function Ec(i,s){return i===pt?s:function(){i.apply(this,arguments);var a=this.onsuccess,c=this.onerror;this.onsuccess=this.onerror=null,s.apply(this,arguments),a&&(this.onsuccess=this.onsuccess?He(a,this.onsuccess):a),c&&(this.onerror=this.onerror?He(c,this.onerror):c)}}function Cc(i,s){return i===pt?s:function(a){var c=i.apply(this,arguments);p(a,c);var h=this.onsuccess,d=this.onerror;return this.onsuccess=null,this.onerror=null,a=s.apply(this,arguments),h&&(this.onsuccess=this.onsuccess?He(h,this.onsuccess):h),d&&(this.onerror=this.onerror?He(d,this.onerror):d),c===void 0?a===void 0?void 0:a:p(c,a)}}function Tc(i,s){return i===pt?s:function(){return s.apply(this,arguments)!==!1&&i.apply(this,arguments)}}function fs(i,s){return i===pt?s:function(){var a=i.apply(this,arguments);if(a&&typeof a.then=="function"){for(var c=this,h=arguments.length,d=new Array(h);h--;)d[h]=arguments[h];return a.then(function(){return s.apply(c,d)})}return s.apply(this,arguments)}}Kr.ModifyError=zr,Kr.DexieError=Sn,Kr.BulkError=On;var se=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Uo(i){se=i}var or={},Fo=100,Xe=typeof Promise>"u"?[]:(function(){var i=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[i,m(i),i];var s=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[s,m(s),i]})(),ar=Xe[0],Vt=Xe[1],Xe=Xe[2],Vt=Vt&&Vt.then,Ye=ar&&ar.constructor,ds=!!Xe,ur=function(i,s){cr.push([i,s]),Wr&&(queueMicrotask(Pc),Wr=!1)},ps=!0,Wr=!0,Ze=[],Vr=[],vs=sr,ke={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:pt,pgp:!1,env:{},finalize:pt},X=ke,cr=[],Qe=0,qr=[];function q(i){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var s=this._PSD=X;if(typeof i!="function"){if(i!==or)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&gs(this,this._value))}this._state=null,this._value=null,++s.ref,(function a(c,h){try{h(function(d){if(c._state===null){if(d===c)throw new TypeError("A promise cannot be resolved with itself.");var v=c._lib&&An();d&&typeof d.then=="function"?a(c,function(g,b){d instanceof q?d._then(g,b):d.then(g,b)}):(c._state=!0,c._value=d,Ko(c)),v&&En()}},gs.bind(null,c))}catch(d){gs(c,d)}})(this,i)}var ms={get:function(){var i=X,s=Yr;function a(c,h){var d=this,v=!i.global&&(i!==X||s!==Yr),g=v&&!De(),b=new q(function(w,E){ys(d,new zo(Vo(c,i,v,g),Vo(h,i,v,g),w,E,i))});return this._consoleTask&&(b._consoleTask=this._consoleTask),b}return a.prototype=or,a},set:function(i){j(this,"then",i&&i.prototype===or?ms:{get:function(){return i},set:ms.set})}};function zo(i,s,a,c,h){this.onFulfilled=typeof i=="function"?i:null,this.onRejected=typeof s=="function"?s:null,this.resolve=a,this.reject=c,this.psd=h}function gs(i,s){var a,c;Vr.push(s),i._state===null&&(a=i._lib&&An(),s=vs(s),i._state=!1,i._value=s,c=i,Ze.some(function(h){return h._value===c._value})||Ze.push(c),Ko(i),a&&En())}function Ko(i){var s=i._listeners;i._listeners=[];for(var a=0,c=s.length;a<c;++a)ys(i,s[a]);var h=i._PSD;--h.ref||h.finalize(),Qe===0&&(++Qe,ur(function(){--Qe==0&&_s()},[]))}function ys(i,s){if(i._state!==null){var a=i._state?s.onFulfilled:s.onRejected;if(a===null)return(i._state?s.resolve:s.reject)(i._value);++s.psd.ref,++Qe,ur(Mc,[a,i,s])}else i._listeners.push(s)}function Mc(i,s,a){try{var c,h=s._value;!s._state&&Vr.length&&(Vr=[]),c=se&&s._consoleTask?s._consoleTask.run(function(){return i(h)}):i(h),s._state||Vr.indexOf(h)!==-1||(function(d){for(var v=Ze.length;v;)if(Ze[--v]._value===d._value)return Ze.splice(v,1)})(s),a.resolve(c)}catch(d){a.reject(d)}finally{--Qe==0&&_s(),--a.psd.ref||a.psd.finalize()}}function Pc(){Je(ke,function(){An()&&En()})}function An(){var i=ps;return Wr=ps=!1,i}function En(){var i,s,a;do for(;0<cr.length;)for(i=cr,cr=[],a=i.length,s=0;s<a;++s){var c=i[s];c[0].apply(null,c[1])}while(0<cr.length);Wr=ps=!0}function _s(){var i=Ze;Ze=[],i.forEach(function(c){c._PSD.onunhandled.call(null,c._value,c)});for(var s=qr.slice(0),a=s.length;a;)s[--a]()}function Gr(i){return new q(or,!1,i)}function gt(i,s){var a=X;return function(){var c=An(),h=X;try{return Be(a,!0),i.apply(this,arguments)}catch(d){s&&s(d)}finally{Be(h,!1),c&&En()}}}R(q.prototype,{then:ms,_then:function(i,s){ys(this,new zo(null,null,i,s,X))},catch:function(i){if(arguments.length===1)return this.then(null,i);var s=i,a=arguments[1];return typeof s=="function"?this.then(null,function(c){return(c instanceof s?a:Gr)(c)}):this.then(null,function(c){return(c&&c.name===s?a:Gr)(c)})},finally:function(i){return this.then(function(s){return q.resolve(i()).then(function(){return s})},function(s){return q.resolve(i()).then(function(){return Gr(s)})})},timeout:function(i,s){var a=this;return i<1/0?new q(function(c,h){var d=setTimeout(function(){return h(new Z.Timeout(s))},i);a.then(c,h).finally(clearTimeout.bind(null,d))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&j(q.prototype,Symbol.toStringTag,"Dexie.Promise"),ke.env=Wo(),R(q,{all:function(){var i=ge.apply(null,arguments).map(Zr);return new q(function(s,a){i.length===0&&s([]);var c=i.length;i.forEach(function(h,d){return q.resolve(h).then(function(v){i[d]=v,--c||s(i)},a)})})},resolve:function(i){return i instanceof q?i:i&&typeof i.then=="function"?new q(function(s,a){i.then(s,a)}):new q(or,!0,i)},reject:Gr,race:function(){var i=ge.apply(null,arguments).map(Zr);return new q(function(s,a){i.map(function(c){return q.resolve(c).then(s,a)})})},PSD:{get:function(){return X},set:function(i){return X=i}},totalEchoes:{get:function(){return Yr}},newPSD:Ie,usePSD:Je,scheduler:{get:function(){return ur},set:function(i){ur=i}},rejectionMapper:{get:function(){return vs},set:function(i){vs=i}},follow:function(i,s){return new q(function(a,c){return Ie(function(h,d){var v=X;v.unhandleds=[],v.onunhandled=d,v.finalize=He(function(){var g,b=this;g=function(){b.unhandleds.length===0?h():d(b.unhandleds[0])},qr.push(function w(){g(),qr.splice(qr.indexOf(w),1)}),++Qe,ur(function(){--Qe==0&&_s()},[])},v.finalize),i()},s,a,c)})}}),Ye&&(Ye.allSettled&&j(q,"allSettled",function(){var i=ge.apply(null,arguments).map(Zr);return new q(function(s){i.length===0&&s([]);var a=i.length,c=new Array(a);i.forEach(function(h,d){return q.resolve(h).then(function(v){return c[d]={status:"fulfilled",value:v}},function(v){return c[d]={status:"rejected",reason:v}}).then(function(){return--a||s(c)})})})}),Ye.any&&typeof AggregateError<"u"&&j(q,"any",function(){var i=ge.apply(null,arguments).map(Zr);return new q(function(s,a){i.length===0&&a(new AggregateError([]));var c=i.length,h=new Array(c);i.forEach(function(d,v){return q.resolve(d).then(function(g){return s(g)},function(g){h[v]=g,--c||a(new AggregateError(h))})})})}),Ye.withResolvers&&(q.withResolvers=Ye.withResolvers));var Ct={awaits:0,echoes:0,id:0},Rc=0,Hr=[],Xr=0,Yr=0,kc=0;function Ie(i,s,a,c){var h=X,d=Object.create(h);return d.parent=h,d.ref=0,d.global=!1,d.id=++kc,ke.env,d.env=ds?{Promise:q,PromiseProp:{value:q,configurable:!0,writable:!0},all:q.all,race:q.race,allSettled:q.allSettled,any:q.any,resolve:q.resolve,reject:q.reject}:{},s&&p(d,s),++h.ref,d.finalize=function(){--this.parent.ref||this.parent.finalize()},c=Je(d,i,a,c),d.ref===0&&d.finalize(),c}function Cn(){return Ct.id||(Ct.id=++Rc),++Ct.awaits,Ct.echoes+=Fo,Ct.id}function De(){return!!Ct.awaits&&(--Ct.awaits==0&&(Ct.id=0),Ct.echoes=Ct.awaits*Fo,!0)}function Zr(i){return Ct.echoes&&i&&i.constructor===Ye?(Cn(),i.then(function(s){return De(),s},function(s){return De(),wt(s)})):i}function Ic(){var i=Hr[Hr.length-1];Hr.pop(),Be(i,!1)}function Be(i,s){var a,c=X;(s?!Ct.echoes||Xr++&&i===X:!Xr||--Xr&&i===X)||queueMicrotask(s?(function(h){++Yr,Ct.echoes&&--Ct.echoes!=0||(Ct.echoes=Ct.awaits=Ct.id=0),Hr.push(X),Be(h,!0)}).bind(null,i):Ic),i!==X&&(X=i,c===ke&&(ke.env=Wo()),ds&&(a=ke.env.Promise,s=i.env,(c.global||i.global)&&(Object.defineProperty(u,"Promise",s.PromiseProp),a.all=s.all,a.race=s.race,a.resolve=s.resolve,a.reject=s.reject,s.allSettled&&(a.allSettled=s.allSettled),s.any&&(a.any=s.any))))}function Wo(){var i=u.Promise;return ds?{Promise:i,PromiseProp:Object.getOwnPropertyDescriptor(u,"Promise"),all:i.all,race:i.race,allSettled:i.allSettled,any:i.any,resolve:i.resolve,reject:i.reject}:{}}function Je(i,s,a,c,h){var d=X;try{return Be(i,!0),s(a,c,h)}finally{Be(d,!1)}}function Vo(i,s,a,c){return typeof i!="function"?i:function(){var h=X;a&&Cn(),Be(s,!0);try{return i.apply(this,arguments)}finally{Be(h,!1),c&&queueMicrotask(De)}}}function bs(i){Promise===Ye&&Ct.echoes===0?Xr===0?i():enqueueNativeMicroTask(i):setTimeout(i,0)}(""+Vt).indexOf("[native code]")===-1&&(Cn=De=pt);var wt=q.reject,tn="",ye="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",qo="String expected.",Tn=[],Qr="__dbnames",ws="readonly",xs="readwrite";function en(i,s){return i?s?function(){return i.apply(this,arguments)&&s.apply(this,arguments)}:i:s}var Go={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Jr(i){return typeof i!="string"||/\./.test(i)?function(s){return s}:function(s){return s[i]===void 0&&i in s&&delete(s=ve(s))[i],s}}function Ho(){throw Z.Type("Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.")}function at(i,s){try{var a=Xo(i),c=Xo(s);if(a!==c)return a==="Array"?1:c==="Array"?-1:a==="binary"?1:c==="binary"?-1:a==="string"?1:c==="string"?-1:a==="Date"?1:c!=="Date"?NaN:-1;switch(a){case"number":case"Date":case"string":return s<i?1:i<s?-1:0;case"binary":return(function(h,d){for(var v=h.length,g=d.length,b=v<g?v:g,w=0;w<b;++w)if(h[w]!==d[w])return h[w]<d[w]?-1:1;return v===g?0:v<g?-1:1})(Yo(i),Yo(s));case"Array":return(function(h,d){for(var v=h.length,g=d.length,b=v<g?v:g,w=0;w<b;++w){var E=at(h[w],d[w]);if(E!==0)return E}return v===g?0:v<g?-1:1})(i,s)}}catch{}return NaN}function Xo(i){var s=typeof i;return s!="object"?s:ArrayBuffer.isView(i)?"binary":(i=rr(i),i==="ArrayBuffer"?"binary":i)}function Yo(i){return i instanceof Uint8Array?i:ArrayBuffer.isView(i)?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i)}function ti(i,s,a){var c=i.schema.yProps;return c?(s&&0<a.numFailures&&(s=s.filter(function(h,d){return!a.failures[d]})),Promise.all(c.map(function(h){return h=h.updatesTable,s?i.db.table(h).where("k").anyOf(s).delete():i.db.table(h).clear()})).then(function(){return a})):a}var lr=(Zo.prototype.execute=function(i){var s=this["@@propmod"];if(s.add!==void 0){var a=s.add;if(f(a))return o(o([],f(i)?i:[],!0),a).sort();if(typeof a=="number")return(Number(i)||0)+a;if(typeof a=="bigint")try{return BigInt(i)+a}catch{return BigInt(0)+a}throw new TypeError("Invalid term ".concat(a))}if(s.remove!==void 0){var c=s.remove;if(f(c))return f(i)?i.filter(function(h){return!c.includes(h)}).sort():[];if(typeof c=="number")return Number(i)-c;if(typeof c=="bigint")try{return BigInt(i)-c}catch{return BigInt(0)-c}throw new TypeError("Invalid subtrahend ".concat(c))}return a=(a=s.replacePrefix)===null||a===void 0?void 0:a[0],a&&typeof i=="string"&&i.startsWith(a)?s.replacePrefix[1]+i.substring(a.length):i},Zo);function Zo(i){this["@@propmod"]=i}function Qo(i,s){for(var a=l(s),c=a.length,h=!1,d=0;d<c;++d){var v=a[d],g=s[v],b=Et(i,v);g instanceof lr?(yt(i,v,g.execute(b)),h=!0):b!==g&&(yt(i,v,g),h=!0)}return h}var Jo=(vt.prototype._trans=function(i,s,a){var c=this._tx||X.trans,h=this.name,d=se&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(i==="readonly"?"read":"write"," ").concat(this.name));function v(w,E,y){if(!y.schema[h])throw new Z.NotFound("Table "+h+" not part of transaction");return s(y.idbtrans,y)}var g=An();try{var b=c&&c.db._novip===this.db._novip?c===X.trans?c._promise(i,v,a):Ie(function(){return c._promise(i,v,a)},{trans:c,transless:X.transless||X}):(function w(E,y,T,x){if(E.idbdb&&(E._state.openComplete||X.letThrough||E._vip)){var O=E._createTransaction(y,T,E._dbSchema);try{O.create(),E._state.PR1398_maxLoop=3}catch(A){return A.name===hs.InvalidState&&E.isOpen()&&0<--E._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),E.close({disableAutoOpen:!1}),E.open().then(function(){return w(E,y,T,x)})):wt(A)}return O._promise(y,function(A,C){return Ie(function(){return X.trans=O,x(A,C,O)})}).then(function(A){if(y==="readwrite")try{O.idbtrans.commit()}catch{}return y==="readonly"?A:O._completion.then(function(){return A})})}if(E._state.openComplete)return wt(new Z.DatabaseClosed(E._state.dbOpenError));if(!E._state.isBeingOpened){if(!E._state.autoOpen)return wt(new Z.DatabaseClosed);E.open().catch(pt)}return E._state.dbReadyPromise.then(function(){return w(E,y,T,x)})})(this.db,i,[this.name],v);return d&&(b._consoleTask=d,b=b.catch(function(w){return console.trace(w),wt(w)})),b}finally{g&&En()}},vt.prototype.get=function(i,s){var a=this;return i&&i.constructor===Object?this.where(i).first(s):i==null?wt(new Z.Type("Invalid argument to Table.get()")):this._trans("readonly",function(c){return a.core.get({trans:c,key:i}).then(function(h){return a.hook.reading.fire(h)})}).then(s)},vt.prototype.where=function(i){if(typeof i=="string")return new this.db.WhereClause(this,i);if(f(i))return new this.db.WhereClause(this,"[".concat(i.join("+"),"]"));var s=l(i);if(s.length===1)return this.where(s[0]).equals(i[s[0]]);var a=this.schema.indexes.concat(this.schema.primKey).filter(function(g){if(g.compound&&s.every(function(w){return 0<=g.keyPath.indexOf(w)})){for(var b=0;b<s.length;++b)if(s.indexOf(g.keyPath[b])===-1)return!1;return!0}return!1}).sort(function(g,b){return g.keyPath.length-b.keyPath.length})[0];if(a&&this.db._maxKey!==tn){var d=a.keyPath.slice(0,s.length);return this.where(d).equals(d.map(function(b){return i[b]}))}!a&&se&&console.warn("The query ".concat(JSON.stringify(i)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(s.join("+"),"]"));var c=this.schema.idxByName;function h(g,b){return at(g,b)===0}var v=s.reduce(function(y,b){var w=y[0],E=y[1],y=c[b],T=i[b];return[w||y,w||!y?en(E,y&&y.multi?function(x){return x=Et(x,b),f(x)&&x.some(function(O){return h(T,O)})}:function(x){return h(T,Et(x,b))}):E]},[null,null]),d=v[0],v=v[1];return d?this.where(d.name).equals(i[d.keyPath]).filter(v):a?this.filter(v):this.where(s).equals("")},vt.prototype.filter=function(i){return this.toCollection().and(i)},vt.prototype.count=function(i){return this.toCollection().count(i)},vt.prototype.offset=function(i){return this.toCollection().offset(i)},vt.prototype.limit=function(i){return this.toCollection().limit(i)},vt.prototype.each=function(i){return this.toCollection().each(i)},vt.prototype.toArray=function(i){return this.toCollection().toArray(i)},vt.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},vt.prototype.orderBy=function(i){return new this.db.Collection(new this.db.WhereClause(this,f(i)?"[".concat(i.join("+"),"]"):i))},vt.prototype.reverse=function(){return this.toCollection().reverse()},vt.prototype.mapToClass=function(i){var s,a=this.db,c=this.name;function h(){return s!==null&&s.apply(this,arguments)||this}(this.schema.mappedClass=i).prototype instanceof Ho&&((function(b,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function E(){this.constructor=b}e(b,w),b.prototype=w===null?Object.create(w):(E.prototype=w.prototype,new E)})(h,s=i),Object.defineProperty(h.prototype,"db",{get:function(){return a},enumerable:!1,configurable:!0}),h.prototype.table=function(){return c},i=h);for(var d=new Set,v=i.prototype;v;v=m(v))Object.getOwnPropertyNames(v).forEach(function(b){return d.add(b)});function g(b){if(!b)return b;var w,E=Object.create(i.prototype);for(w in b)if(!d.has(w))try{E[w]=b[w]}catch{}return E}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=g,this.hook("reading",g),i},vt.prototype.defineClass=function(){return this.mapToClass(function(i){p(this,i)})},vt.prototype.add=function(i,s){var a=this,c=this.schema.primKey,h=c.auto,d=c.keyPath,v=i;return d&&h&&(v=Jr(d)(i)),this._trans("readwrite",function(g){return a.core.mutate({trans:g,type:"add",keys:s!=null?[s]:null,values:[v]})}).then(function(g){return g.numFailures?q.reject(g.failures[0]):g.lastResult}).then(function(g){if(d)try{yt(i,d,g)}catch{}return g})},vt.prototype.upsert=function(i,s){var a=this,c=this.schema.primKey.keyPath;return this._trans("readwrite",function(h){return a.core.get({trans:h,key:i}).then(function(d){var v=d??{};return Qo(v,s),c&&yt(v,c,i),a.core.mutate({trans:h,type:"put",values:[v],keys:[i],upsert:!0,updates:{keys:[i],changeSpecs:[s]}}).then(function(g){return g.numFailures?q.reject(g.failures[0]):!!d})})})},vt.prototype.update=function(i,s){return typeof i!="object"||f(i)?this.where(":id").equals(i).modify(s):(i=Et(i,this.schema.primKey.keyPath),i===void 0?wt(new Z.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(i).modify(s))},vt.prototype.put=function(i,s){var a=this,c=this.schema.primKey,h=c.auto,d=c.keyPath,v=i;return d&&h&&(v=Jr(d)(i)),this._trans("readwrite",function(g){return a.core.mutate({trans:g,type:"put",values:[v],keys:s!=null?[s]:null})}).then(function(g){return g.numFailures?q.reject(g.failures[0]):g.lastResult}).then(function(g){if(d)try{yt(i,d,g)}catch{}return g})},vt.prototype.delete=function(i){var s=this;return this._trans("readwrite",function(a){return s.core.mutate({trans:a,type:"delete",keys:[i]}).then(function(c){return ti(s,[i],c)}).then(function(c){return c.numFailures?q.reject(c.failures[0]):void 0})})},vt.prototype.clear=function(){var i=this;return this._trans("readwrite",function(s){return i.core.mutate({trans:s,type:"deleteRange",range:Go}).then(function(a){return ti(i,null,a)})}).then(function(s){return s.numFailures?q.reject(s.failures[0]):void 0})},vt.prototype.bulkGet=function(i){var s=this;return this._trans("readonly",function(a){return s.core.getMany({keys:i,trans:a}).then(function(c){return c.map(function(h){return s.hook.reading.fire(h)})})})},vt.prototype.bulkAdd=function(i,s,a){var c=this,h=Array.isArray(s)?s:void 0,d=(a=a||(h?void 0:s))?a.allKeys:void 0;return this._trans("readwrite",function(v){var w=c.schema.primKey,g=w.auto,w=w.keyPath;if(w&&h)throw new Z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(h&&h.length!==i.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var b=i.length,w=w&&g?i.map(Jr(w)):i;return c.core.mutate({trans:v,type:"add",keys:h,values:w,wantResults:d}).then(function(O){var y=O.numFailures,T=O.results,x=O.lastResult,O=O.failures;if(y===0)return d?T:x;throw new On("".concat(c.name,".bulkAdd(): ").concat(y," of ").concat(b," operations failed"),O)})})},vt.prototype.bulkPut=function(i,s,a){var c=this,h=Array.isArray(s)?s:void 0,d=(a=a||(h?void 0:s))?a.allKeys:void 0;return this._trans("readwrite",function(v){var w=c.schema.primKey,g=w.auto,w=w.keyPath;if(w&&h)throw new Z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(h&&h.length!==i.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var b=i.length,w=w&&g?i.map(Jr(w)):i;return c.core.mutate({trans:v,type:"put",keys:h,values:w,wantResults:d}).then(function(O){var y=O.numFailures,T=O.results,x=O.lastResult,O=O.failures;if(y===0)return d?T:x;throw new On("".concat(c.name,".bulkPut(): ").concat(y," of ").concat(b," operations failed"),O)})})},vt.prototype.bulkUpdate=function(i){var s=this,a=this.core,c=i.map(function(v){return v.key}),h=i.map(function(v){return v.changes}),d=[];return this._trans("readwrite",function(v){return a.getMany({trans:v,keys:c,cache:"clone"}).then(function(g){var b=[],w=[];i.forEach(function(y,T){var x=y.key,O=y.changes,A=g[T];if(A){for(var C=0,M=Object.keys(O);C<M.length;C++){var P=M[C],k=O[P];if(P===s.schema.primKey.keyPath){if(at(k,x)!==0)throw new Z.Constraint("Cannot update primary key in bulkUpdate()")}else yt(A,P,k)}d.push(T),b.push(x),w.push(A)}});var E=b.length;return a.mutate({trans:v,type:"put",keys:b,values:w,updates:{keys:c,changeSpecs:h}}).then(function(y){var T=y.numFailures,x=y.failures;if(T===0)return E;for(var O=0,A=Object.keys(x);O<A.length;O++){var C,M=A[O],P=d[Number(M)];P!=null&&(C=x[M],delete x[M],x[P]=C)}throw new On("".concat(s.name,".bulkUpdate(): ").concat(T," of ").concat(E," operations failed"),x)})})})},vt.prototype.bulkDelete=function(i){var s=this,a=i.length;return this._trans("readwrite",function(c){return s.core.mutate({trans:c,type:"delete",keys:i}).then(function(h){return ti(s,i,h)})}).then(function(v){var h=v.numFailures,d=v.lastResult,v=v.failures;if(h===0)return d;throw new On("".concat(s.name,".bulkDelete(): ").concat(h," of ").concat(a," operations failed"),v)})},vt);function vt(){}function hr(i){function s(v,g){if(g){for(var b=arguments.length,w=new Array(b-1);--b;)w[b-1]=arguments[b];return a[v].subscribe.apply(null,w),i}if(typeof v=="string")return a[v]}var a={};s.addEventType=d;for(var c=1,h=arguments.length;c<h;++c)d(arguments[c]);return s;function d(v,g,b){if(typeof v!="object"){var w;g=g||Tc;var E={subscribers:[],fire:b=b||pt,subscribe:function(y){E.subscribers.indexOf(y)===-1&&(E.subscribers.push(y),E.fire=g(E.fire,y))},unsubscribe:function(y){E.subscribers=E.subscribers.filter(function(T){return T!==y}),E.fire=E.subscribers.reduce(g,b)}};return a[v]=s[v]=E}l(w=v).forEach(function(y){var T=w[y];if(f(T))d(y,w[y][0],w[y][1]);else{if(T!=="asap")throw new Z.InvalidArgument("Invalid event config");var x=d(y,sr,function(){for(var O=arguments.length,A=new Array(O);O--;)A[O]=arguments[O];x.subscribers.forEach(function(C){At(function(){C.apply(null,A)})})})}})}}function fr(i,s){return V(s).from({prototype:i}),s}function Mn(i,s){return!(i.filter||i.algorithm||i.or)&&(s?i.justLimit:!i.replayFilter)}function Ss(i,s){i.filter=en(i.filter,s)}function Os(i,s,a){var c=i.replayFilter;i.replayFilter=c?function(){return en(c(),s())}:s,i.justLimit=a&&!c}function ei(i,s){if(i.isPrimKey)return s.primaryKey;var a=s.getIndexByKeyPath(i.index);if(!a)throw new Z.Schema("KeyPath "+i.index+" on object store "+s.name+" is not indexed");return a}function ta(i,s,a){var c=ei(i,s.schema);return s.openCursor({trans:a,values:!i.keysOnly,reverse:i.dir==="prev",unique:!!i.unique,query:{index:c,range:i.range}})}function ni(i,s,a,c){var h=i.replayFilter?en(i.filter,i.replayFilter()):i.filter;if(i.or){var d={},v=function(g,b,w){var E,y;h&&!h(b,w,function(T){return b.stop(T)},function(T){return b.fail(T)})||((y=""+(E=b.primaryKey))=="[object ArrayBuffer]"&&(y=""+new Uint8Array(E)),S(d,y)||(d[y]=!0,s(g,b,w)))};return Promise.all([i.or._iterate(v,a),ea(ta(i,c,a),i.algorithm,v,!i.keysOnly&&i.valueMapper)])}return ea(ta(i,c,a),en(i.algorithm,h),s,!i.keysOnly&&i.valueMapper)}function ea(i,s,a,c){var h=gt(c?function(d,v,g){return a(c(d),v,g)}:a);return i.then(function(d){if(d)return d.start(function(){var v=function(){return d.continue()};s&&!s(d,function(g){return v=g},function(g){d.stop(g),v=pt},function(g){d.fail(g),v=pt})||h(d.value,d,function(g){return v=g}),v()})})}var Dc=(ct.prototype._read=function(i,s){var a=this._ctx;return a.error?a.table._trans(null,wt.bind(null,a.error)):a.table._trans("readonly",i).then(s)},ct.prototype._write=function(i){var s=this._ctx;return s.error?s.table._trans(null,wt.bind(null,s.error)):s.table._trans("readwrite",i,"locked")},ct.prototype._addAlgorithm=function(i){var s=this._ctx;s.algorithm=en(s.algorithm,i)},ct.prototype._iterate=function(i,s){return ni(this._ctx,i,s,this._ctx.table.core)},ct.prototype.clone=function(i){var s=Object.create(this.constructor.prototype),a=Object.create(this._ctx);return i&&p(a,i),s._ctx=a,s},ct.prototype.raw=function(){return this._ctx.valueMapper=null,this},ct.prototype.each=function(i){var s=this._ctx;return this._read(function(a){return ni(s,i,a,s.table.core)})},ct.prototype.count=function(i){var s=this;return this._read(function(a){var c=s._ctx,h=c.table.core;if(Mn(c,!0))return h.count({trans:a,query:{index:ei(c,h.schema),range:c.range}}).then(function(v){return Math.min(v,c.limit)});var d=0;return ni(c,function(){return++d,!1},a,h).then(function(){return d})}).then(i)},ct.prototype.sortBy=function(i,s){var a=i.split(".").reverse(),c=a[0],h=a.length-1;function d(b,w){return w?d(b[a[w]],w-1):b[c]}var v=this._ctx.dir==="next"?1:-1;function g(b,w){return at(d(b,h),d(w,h))*v}return this.toArray(function(b){return b.sort(g)}).then(s)},ct.prototype.toArray=function(i){var s=this;return this._read(function(a){var c=s._ctx;if(c.dir==="next"&&Mn(c,!0)&&0<c.limit){var h=c.valueMapper,d=ei(c,c.table.core.schema);return c.table.core.query({trans:a,limit:c.limit,values:!0,query:{index:d,range:c.range}}).then(function(g){return g=g.result,h?g.map(h):g})}var v=[];return ni(c,function(g){return v.push(g)},a,c.table.core).then(function(){return v})},i)},ct.prototype.offset=function(i){var s=this._ctx;return i<=0||(s.offset+=i,Mn(s)?Os(s,function(){var a=i;return function(c,h){return a===0||(a===1?--a:h(function(){c.advance(a),a=0}),!1)}}):Os(s,function(){var a=i;return function(){return--a<0}})),this},ct.prototype.limit=function(i){return this._ctx.limit=Math.min(this._ctx.limit,i),Os(this._ctx,function(){var s=i;return function(a,c,h){return--s<=0&&c(h),0<=s}},!0),this},ct.prototype.until=function(i,s){return Ss(this._ctx,function(a,c,h){return!i(a.value)||(c(h),s)}),this},ct.prototype.first=function(i){return this.limit(1).toArray(function(s){return s[0]}).then(i)},ct.prototype.last=function(i){return this.reverse().first(i)},ct.prototype.filter=function(i){var s;return Ss(this._ctx,function(a){return i(a.value)}),(s=this._ctx).isMatch=en(s.isMatch,i),this},ct.prototype.and=function(i){return this.filter(i)},ct.prototype.or=function(i){return new this.db.WhereClause(this._ctx.table,i,this)},ct.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},ct.prototype.desc=function(){return this.reverse()},ct.prototype.eachKey=function(i){var s=this._ctx;return s.keysOnly=!s.isMatch,this.each(function(a,c){i(c.key,c)})},ct.prototype.eachUniqueKey=function(i){return this._ctx.unique="unique",this.eachKey(i)},ct.prototype.eachPrimaryKey=function(i){var s=this._ctx;return s.keysOnly=!s.isMatch,this.each(function(a,c){i(c.primaryKey,c)})},ct.prototype.keys=function(i){var s=this._ctx;s.keysOnly=!s.isMatch;var a=[];return this.each(function(c,h){a.push(h.key)}).then(function(){return a}).then(i)},ct.prototype.primaryKeys=function(i){var s=this._ctx;if(s.dir==="next"&&Mn(s,!0)&&0<s.limit)return this._read(function(c){var h=ei(s,s.table.core.schema);return s.table.core.query({trans:c,values:!1,limit:s.limit,query:{index:h,range:s.range}})}).then(function(c){return c.result}).then(i);s.keysOnly=!s.isMatch;var a=[];return this.each(function(c,h){a.push(h.primaryKey)}).then(function(){return a}).then(i)},ct.prototype.uniqueKeys=function(i){return this._ctx.unique="unique",this.keys(i)},ct.prototype.firstKey=function(i){return this.limit(1).keys(function(s){return s[0]}).then(i)},ct.prototype.lastKey=function(i){return this.reverse().firstKey(i)},ct.prototype.distinct=function(){var i=this._ctx,i=i.index&&i.table.schema.idxByName[i.index];if(!i||!i.multi)return this;var s={};return Ss(this._ctx,function(h){var c=h.primaryKey.toString(),h=S(s,c);return s[c]=!0,!h}),this},ct.prototype.modify=function(i){var s=this,a=this._ctx;return this._write(function(c){var h=typeof i=="function"?i:function(A){return Qo(A,i)},d=a.table.core,w=d.schema.primaryKey,v=w.outbound,g=w.extractKey,b=200,w=s.db._options.modifyChunkSize;w&&(b=typeof w=="object"?w[d.name]||w["*"]||200:w);function E(A,P){var M=P.failures,P=P.numFailures;T+=A-P;for(var k=0,D=l(M);k<D.length;k++){var $=D[k];y.push(M[$])}}var y=[],T=0,x=[],O=i===na;return s.clone().primaryKeys().then(function(A){function C(P){var k=Math.min(b,A.length-P),D=A.slice(P,P+k);return(O?Promise.resolve([]):d.getMany({trans:c,keys:D,cache:"immutable"})).then(function($){var z=[],L=[],N=v?[]:null,K=O?D:[];if(!O)for(var U=0;U<k;++U){var G=$[U],rt={value:ve(G),primKey:A[P+U]};h.call(rt,rt.value,rt)!==!1&&(rt.value==null?K.push(A[P+U]):v||at(g(G),g(rt.value))===0?(L.push(rt.value),v&&N.push(A[P+U])):(K.push(A[P+U]),z.push(rt.value)))}return Promise.resolve(0<z.length&&d.mutate({trans:c,type:"add",values:z}).then(function(it){for(var st in it.failures)K.splice(parseInt(st),1);E(z.length,it)})).then(function(){return(0<L.length||M&&typeof i=="object")&&d.mutate({trans:c,type:"put",keys:N,values:L,criteria:M,changeSpec:typeof i!="function"&&i,isAdditionalChunk:0<P}).then(function(it){return E(L.length,it)})}).then(function(){return(0<K.length||M&&O)&&d.mutate({trans:c,type:"delete",keys:K,criteria:M,isAdditionalChunk:0<P}).then(function(it){return ti(a.table,K,it)}).then(function(it){return E(K.length,it)})}).then(function(){return A.length>P+k&&C(P+b)})})}var M=Mn(a)&&a.limit===1/0&&(typeof i!="function"||O)&&{index:a.index,range:a.range};return C(0).then(function(){if(0<y.length)throw new zr("Error modifying one or more objects",y,T,x);return A.length})})})},ct.prototype.delete=function(){var i=this._ctx,s=i.range;return!Mn(i)||i.table.schema.yProps||!i.isPrimKey&&s.type!==3?this.modify(na):this._write(function(a){var c=i.table.core.schema.primaryKey,h=s;return i.table.core.count({trans:a,query:{index:c,range:h}}).then(function(d){return i.table.core.mutate({trans:a,type:"deleteRange",range:h}).then(function(b){var g=b.failures,b=b.numFailures;if(b)throw new zr("Could not delete some values",Object.keys(g).map(function(w){return g[w]}),d-b);return d-b})})})},ct);function ct(){}var na=function(i,s){return s.value=null};function Bc(i,s){return i<s?-1:i===s?0:1}function Lc(i,s){return s<i?-1:i===s?0:1}function Ut(i,s,a){return i=i instanceof ia?new i.Collection(i):i,i._ctx.error=new(a||TypeError)(s),i}function Pn(i){return new i.Collection(i,function(){return ra("")}).limit(0)}function ri(i,s,a,c){var h,d,v,g,b,w,E,y=a.length;if(!a.every(function(O){return typeof O=="string"}))return Ut(i,qo);function T(O){h=O==="next"?function(C){return C.toUpperCase()}:function(C){return C.toLowerCase()},d=O==="next"?function(C){return C.toLowerCase()}:function(C){return C.toUpperCase()},v=O==="next"?Bc:Lc;var A=a.map(function(C){return{lower:d(C),upper:h(C)}}).sort(function(C,M){return v(C.lower,M.lower)});g=A.map(function(C){return C.upper}),b=A.map(function(C){return C.lower}),E=(w=O)==="next"?"":c}T("next"),i=new i.Collection(i,function(){return Le(g[0],b[y-1]+c)}),i._ondirectionchange=function(O){T(O)};var x=0;return i._addAlgorithm(function(O,A,C){var M=O.key;if(typeof M!="string")return!1;var P=d(M);if(s(P,b,x))return!0;for(var k=null,D=x;D<y;++D){var $=(function(z,L,N,K,U,G){for(var rt=Math.min(z.length,K.length),it=-1,st=0;st<rt;++st){var Ft=L[st];if(Ft!==K[st])return U(z[st],N[st])<0?z.substr(0,st)+N[st]+N.substr(st+1):U(z[st],K[st])<0?z.substr(0,st)+K[st]+N.substr(st+1):0<=it?z.substr(0,it)+L[it]+N.substr(it+1):null;U(z[st],Ft)<0&&(it=st)}return rt<K.length&&G==="next"?z+N.substr(z.length):rt<z.length&&G==="prev"?z.substr(0,N.length):it<0?null:z.substr(0,it)+K[it]+N.substr(it+1)})(M,P,g[D],b[D],v,w);$===null&&k===null?x=D+1:(k===null||0<v(k,$))&&(k=$)}return A(k!==null?function(){O.continue(k+E)}:C),!1}),i}function Le(i,s,a,c){return{type:2,lower:i,upper:s,lowerOpen:a,upperOpen:c}}function ra(i){return{type:1,lower:i,upper:i}}var ia=(Object.defineProperty(Tt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Tt.prototype.between=function(i,s,a,c){a=a!==!1,c=c===!0;try{return 0<this._cmp(i,s)||this._cmp(i,s)===0&&(a||c)&&(!a||!c)?Pn(this):new this.Collection(this,function(){return Le(i,s,!a,!c)})}catch{return Ut(this,ye)}},Tt.prototype.equals=function(i){return i==null?Ut(this,ye):new this.Collection(this,function(){return ra(i)})},Tt.prototype.above=function(i){return i==null?Ut(this,ye):new this.Collection(this,function(){return Le(i,void 0,!0)})},Tt.prototype.aboveOrEqual=function(i){return i==null?Ut(this,ye):new this.Collection(this,function(){return Le(i,void 0,!1)})},Tt.prototype.below=function(i){return i==null?Ut(this,ye):new this.Collection(this,function(){return Le(void 0,i,!1,!0)})},Tt.prototype.belowOrEqual=function(i){return i==null?Ut(this,ye):new this.Collection(this,function(){return Le(void 0,i)})},Tt.prototype.startsWith=function(i){return typeof i!="string"?Ut(this,qo):this.between(i,i+tn,!0,!0)},Tt.prototype.startsWithIgnoreCase=function(i){return i===""?this.startsWith(i):ri(this,function(s,a){return s.indexOf(a[0])===0},[i],tn)},Tt.prototype.equalsIgnoreCase=function(i){return ri(this,function(s,a){return s===a[0]},[i],"")},Tt.prototype.anyOfIgnoreCase=function(){var i=ge.apply(Re,arguments);return i.length===0?Pn(this):ri(this,function(s,a){return a.indexOf(s)!==-1},i,"")},Tt.prototype.startsWithAnyOfIgnoreCase=function(){var i=ge.apply(Re,arguments);return i.length===0?Pn(this):ri(this,function(s,a){return a.some(function(c){return s.indexOf(c)===0})},i,tn)},Tt.prototype.anyOf=function(){var i=this,s=ge.apply(Re,arguments),a=this._cmp;try{s.sort(a)}catch{return Ut(this,ye)}if(s.length===0)return Pn(this);var c=new this.Collection(this,function(){return Le(s[0],s[s.length-1])});c._ondirectionchange=function(d){a=d==="next"?i._ascending:i._descending,s.sort(a)};var h=0;return c._addAlgorithm(function(d,v,g){for(var b=d.key;0<a(b,s[h]);)if(++h===s.length)return v(g),!1;return a(b,s[h])===0||(v(function(){d.continue(s[h])}),!1)}),c},Tt.prototype.notEqual=function(i){return this.inAnyRange([[-1/0,i],[i,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Tt.prototype.noneOf=function(){var i=ge.apply(Re,arguments);if(i.length===0)return new this.Collection(this);try{i.sort(this._ascending)}catch{return Ut(this,ye)}var s=i.reduce(function(a,c){return a?a.concat([[a[a.length-1][1],c]]):[[-1/0,c]]},null);return s.push([i[i.length-1],this.db._maxKey]),this.inAnyRange(s,{includeLowers:!1,includeUppers:!1})},Tt.prototype.inAnyRange=function(M,s){var a=this,c=this._cmp,h=this._ascending,d=this._descending,v=this._min,g=this._max;if(M.length===0)return Pn(this);if(!M.every(function(P){return P[0]!==void 0&&P[1]!==void 0&&h(P[0],P[1])<=0}))return Ut(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Z.InvalidArgument);var b=!s||s.includeLowers!==!1,w=s&&s.includeUppers===!0,E,y=h;function T(P,k){return y(P[0],k[0])}try{(E=M.reduce(function(P,k){for(var D=0,$=P.length;D<$;++D){var z=P[D];if(c(k[0],z[1])<0&&0<c(k[1],z[0])){z[0]=v(z[0],k[0]),z[1]=g(z[1],k[1]);break}}return D===$&&P.push(k),P},[])).sort(T)}catch{return Ut(this,ye)}var x=0,O=w?function(P){return 0<h(P,E[x][1])}:function(P){return 0<=h(P,E[x][1])},A=b?function(P){return 0<d(P,E[x][0])}:function(P){return 0<=d(P,E[x][0])},C=O,M=new this.Collection(this,function(){return Le(E[0][0],E[E.length-1][1],!b,!w)});return M._ondirectionchange=function(P){y=P==="next"?(C=O,h):(C=A,d),E.sort(T)},M._addAlgorithm(function(P,k,D){for(var $,z=P.key;C(z);)if(++x===E.length)return k(D),!1;return!O($=z)&&!A($)||(a._cmp(z,E[x][1])===0||a._cmp(z,E[x][0])===0||k(function(){y===h?P.continue(E[x][0]):P.continue(E[x][1])}),!1)}),M},Tt.prototype.startsWithAnyOf=function(){var i=ge.apply(Re,arguments);return i.every(function(s){return typeof s=="string"})?i.length===0?Pn(this):this.inAnyRange(i.map(function(s){return[s,s+tn]})):Ut(this,"startsWithAnyOf() only works with strings")},Tt);function Tt(){}function oe(i){return gt(function(s){return dr(s),i(s.target.error),!1})}function dr(i){i.stopPropagation&&i.stopPropagation(),i.preventDefault&&i.preventDefault()}var pr="storagemutated",As="x-storagemutated-1",je=hr(null,pr),jc=(ae.prototype._lock=function(){return et(!X.global),++this._reculock,this._reculock!==1||X.global||(X.lockOwnerFor=this),this},ae.prototype._unlock=function(){if(et(!X.global),--this._reculock==0)for(X.global||(X.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var i=this._blockedFuncs.shift();try{Je(i[1],i[0])}catch{}}return this},ae.prototype._locked=function(){return this._reculock&&X.lockOwnerFor!==this},ae.prototype.create=function(i){var s=this;if(!this.mode)return this;var a=this.db.idbdb,c=this.db._state.dbOpenError;if(et(!this.idbtrans),!i&&!a)switch(c&&c.name){case"DatabaseClosedError":throw new Z.DatabaseClosed(c);case"MissingAPIError":throw new Z.MissingAPI(c.message,c);default:throw new Z.OpenFailed(c)}if(!this.active)throw new Z.TransactionInactive;return et(this._completion._state===null),(i=this.idbtrans=i||(this.db.core||a).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=gt(function(h){dr(h),s._reject(i.error)}),i.onabort=gt(function(h){dr(h),s.active&&s._reject(new Z.Abort(i.error)),s.active=!1,s.on("abort").fire(h)}),i.oncomplete=gt(function(){s.active=!1,s._resolve(),"mutatedParts"in i&&je.storagemutated.fire(i.mutatedParts)}),this},ae.prototype._promise=function(i,s,a){var c=this;if(i==="readwrite"&&this.mode!=="readwrite")return wt(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return wt(new Z.TransactionInactive);if(this._locked())return new q(function(d,v){c._blockedFuncs.push([function(){c._promise(i,s,a).then(d,v)},X])});if(a)return Ie(function(){var d=new q(function(v,g){c._lock();var b=s(v,g,c);b&&b.then&&b.then(v,g)});return d.finally(function(){return c._unlock()}),d._lib=!0,d});var h=new q(function(d,v){var g=s(d,v,c);g&&g.then&&g.then(d,v)});return h._lib=!0,h},ae.prototype._root=function(){return this.parent?this.parent._root():this},ae.prototype.waitFor=function(i){var s,a=this._root(),c=q.resolve(i);a._waitingFor?a._waitingFor=a._waitingFor.then(function(){return c}):(a._waitingFor=c,a._waitingQueue=[],s=a.idbtrans.objectStore(a.storeNames[0]),(function d(){for(++a._spinCount;a._waitingQueue.length;)a._waitingQueue.shift()();a._waitingFor&&(s.get(-1/0).onsuccess=d)})());var h=a._waitingFor;return new q(function(d,v){c.then(function(g){return a._waitingQueue.push(gt(d.bind(null,g)))},function(g){return a._waitingQueue.push(gt(v.bind(null,g)))}).finally(function(){a._waitingFor===h&&(a._waitingFor=null)})})},ae.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Z.Abort))},ae.prototype.table=function(i){var s=this._memoizedTables||(this._memoizedTables={});if(S(s,i))return s[i];var a=this.schema[i];if(!a)throw new Z.NotFound("Table "+i+" not part of transaction");return a=new this.db.Table(i,a,this),a.core=this.db.core.table(i),s[i]=a},ae);function ae(){}function Es(i,s,a,c,h,d,v,g){return{name:i,keyPath:s,unique:a,multi:c,auto:h,compound:d,src:(a&&!v?"&":"")+(c?"*":"")+(h?"++":"")+sa(s),type:g}}function sa(i){return typeof i=="string"?i:i?"["+[].join.call(i,"+")+"]":""}function Cs(i,s,a){return{name:i,primKey:s,indexes:a,mappedClass:null,idxByName:(c=function(h){return[h.name,h]},a.reduce(function(h,d,v){return v=c(d,v),v&&(h[v[0]]=v[1]),h},{}))};var c}var vr=function(i){try{return i.only([[]]),vr=function(){return[[]]},[[]]}catch{return vr=function(){return tn},tn}};function Ts(i){return i==null?function(){}:typeof i=="string"?(s=i).split(".").length===1?function(a){return a[s]}:function(a){return Et(a,s)}:function(a){return Et(a,i)};var s}function oa(i){return[].slice.call(i)}var $c=0;function mr(i){return i==null?":id":typeof i=="string"?i:"[".concat(i.join("+"),"]")}function Nc(i,s,b){function c(C){if(C.type===3)return null;if(C.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var x=C.lower,O=C.upper,A=C.lowerOpen,C=C.upperOpen;return x===void 0?O===void 0?null:s.upperBound(O,!!C):O===void 0?s.lowerBound(x,!!A):s.bound(x,O,!!A,!!C)}function h(T){var x,O=T.name;return{name:O,schema:T,mutate:function(A){var C=A.trans,M=A.type,P=A.keys,k=A.values,D=A.range;return new Promise(function($,z){$=gt($);var L=C.objectStore(O),N=L.keyPath==null,K=M==="put"||M==="add";if(!K&&M!=="delete"&&M!=="deleteRange")throw new Error("Invalid operation type: "+M);var U,G=(P||k||{length:1}).length;if(P&&k&&P.length!==k.length)throw new Error("Given keys array must have same length as given values array.");if(G===0)return $({numFailures:0,failures:{},results:[],lastResult:void 0});function rt(jt){++Ft,dr(jt)}var it=[],st=[],Ft=0;if(M==="deleteRange"){if(D.type===4)return $({numFailures:Ft,failures:st,results:[],lastResult:void 0});D.type===3?it.push(U=L.clear()):it.push(U=L.delete(c(D)))}else{var N=K?N?[k,P]:[k,null]:[P,null],nt=N[0],Dt=N[1];if(K)for(var Bt=0;Bt<G;++Bt)it.push(U=Dt&&Dt[Bt]!==void 0?L[M](nt[Bt],Dt[Bt]):L[M](nt[Bt])),U.onerror=rt;else for(Bt=0;Bt<G;++Bt)it.push(U=L[M](nt[Bt])),U.onerror=rt}function vi(jt){jt=jt.target.result,it.forEach(function(sn,qs){return sn.error!=null&&(st[qs]=sn.error)}),$({numFailures:Ft,failures:st,results:M==="delete"?P:it.map(function(sn){return sn.result}),lastResult:jt})}U.onerror=function(jt){rt(jt),vi(jt)},U.onsuccess=vi})},getMany:function(A){var C=A.trans,M=A.keys;return new Promise(function(P,k){P=gt(P);for(var D,$=C.objectStore(O),z=M.length,L=new Array(z),N=0,K=0,U=function(it){it=it.target,L[it._pos]=it.result,++K===N&&P(L)},G=oe(k),rt=0;rt<z;++rt)M[rt]!=null&&((D=$.get(M[rt]))._pos=rt,D.onsuccess=U,D.onerror=G,++N);N===0&&P(L)})},get:function(A){var C=A.trans,M=A.key;return new Promise(function(P,k){P=gt(P);var D=C.objectStore(O).get(M);D.onsuccess=function($){return P($.target.result)},D.onerror=oe(k)})},query:(x=w,function(A){return new Promise(function(C,M){C=gt(C);var P,k,D,N=A.trans,$=A.values,z=A.limit,U=A.query,L=z===1/0?void 0:z,K=U.index,U=U.range,N=N.objectStore(O),K=K.isPrimaryKey?N:N.index(K.name),U=c(U);if(z===0)return C({result:[]});x?((L=$?K.getAll(U,L):K.getAllKeys(U,L)).onsuccess=function(G){return C({result:G.target.result})},L.onerror=oe(M)):(P=0,k=!$&&"openKeyCursor"in K?K.openKeyCursor(U):K.openCursor(U),D=[],k.onsuccess=function(G){var rt=k.result;return rt?(D.push($?rt.value:rt.primaryKey),++P===z?C({result:D}):void rt.continue()):C({result:D})},k.onerror=oe(M))})}),openCursor:function(A){var C=A.trans,M=A.values,P=A.query,k=A.reverse,D=A.unique;return new Promise(function($,z){$=gt($);var K=P.index,L=P.range,N=C.objectStore(O),N=K.isPrimaryKey?N:N.index(K.name),K=k?D?"prevunique":"prev":D?"nextunique":"next",U=!M&&"openKeyCursor"in N?N.openKeyCursor(c(L),K):N.openCursor(c(L),K);U.onerror=oe(z),U.onsuccess=gt(function(G){var rt,it,st,Ft,nt=U.result;nt?(nt.___id=++$c,nt.done=!1,rt=nt.continue.bind(nt),it=(it=nt.continuePrimaryKey)&&it.bind(nt),st=nt.advance.bind(nt),Ft=function(){throw new Error("Cursor not stopped")},nt.trans=C,nt.stop=nt.continue=nt.continuePrimaryKey=nt.advance=function(){throw new Error("Cursor not started")},nt.fail=gt(z),nt.next=function(){var Dt=this,Bt=1;return this.start(function(){return Bt--?Dt.continue():Dt.stop()}).then(function(){return Dt})},nt.start=function(Dt){function Bt(){if(U.result)try{Dt()}catch(jt){nt.fail(jt)}else nt.done=!0,nt.start=function(){throw new Error("Cursor behind last entry")},nt.stop()}var vi=new Promise(function(jt,sn){jt=gt(jt),U.onerror=oe(sn),nt.fail=sn,nt.stop=function(qs){nt.stop=nt.continue=nt.continuePrimaryKey=nt.advance=Ft,jt(qs)}});return U.onsuccess=gt(function(jt){U.onsuccess=Bt,Bt()}),nt.continue=rt,nt.continuePrimaryKey=it,nt.advance=st,Bt(),vi},$(nt)):$(null)},z)})},count:function(A){var C=A.query,M=A.trans,P=C.index,k=C.range;return new Promise(function(D,$){var z=M.objectStore(O),L=P.isPrimaryKey?z:z.index(P.name),z=c(k),L=z?L.count(z):L.count();L.onsuccess=gt(function(N){return D(N.target.result)}),L.onerror=oe($)})}}}var d,v,g,E=(v=b,g=oa((d=i).objectStoreNames),{schema:{name:d.name,tables:g.map(function(T){return v.objectStore(T)}).map(function(T){var x=T.keyPath,C=T.autoIncrement,O=f(x),A={},C={name:T.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:x==null,compound:O,keyPath:x,autoIncrement:C,unique:!0,extractKey:Ts(x)},indexes:oa(T.indexNames).map(function(M){return T.index(M)}).map(function(D){var P=D.name,k=D.unique,$=D.multiEntry,D=D.keyPath,$={name:P,compound:f(D),keyPath:D,unique:k,multiEntry:$,extractKey:Ts(D)};return A[mr(D)]=$}),getIndexByKeyPath:function(M){return A[mr(M)]}};return A[":id"]=C.primaryKey,x!=null&&(A[mr(x)]=C.primaryKey),C})},hasGetAll:0<g.length&&"getAll"in v.objectStore(g[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),b=E.schema,w=E.hasGetAll,E=b.tables.map(h),y={};return E.forEach(function(T){return y[T.name]=T}),{stack:"dbcore",transaction:i.transaction.bind(i),table:function(T){if(!y[T])throw new Error("Table '".concat(T,"' not found"));return y[T]},MIN_KEY:-1/0,MAX_KEY:vr(s),schema:b}}function Uc(i,s,a,c){var h=a.IDBKeyRange;return a.indexedDB,{dbcore:(c=Nc(s,h,c),i.dbcore.reduce(function(d,v){return v=v.create,r(r({},d),v(d))},c))}}function ii(i,c){var a=c.db,c=Uc(i._middlewares,a,i._deps,c);i.core=c.dbcore,i.tables.forEach(function(h){var d=h.name;i.core.schema.tables.some(function(v){return v.name===d})&&(h.core=i.core.table(d),i[d]instanceof i.Table&&(i[d].core=h.core))})}function si(i,s,a,c){a.forEach(function(h){var d=c[h];s.forEach(function(v){var g=(function b(w,E){return W(w,E)||(w=m(w))&&b(w,E)})(v,h);(!g||"value"in g&&g.value===void 0)&&(v===i.Transaction.prototype||v instanceof i.Transaction?j(v,h,{get:function(){return this.table(h)},set:function(b){I(this,h,{value:b,writable:!0,configurable:!0,enumerable:!0})}}):v[h]=new i.Table(h,d))})})}function Ms(i,s){s.forEach(function(a){for(var c in a)a[c]instanceof i.Table&&delete a[c]})}function Fc(i,s){return i._cfg.version-s._cfg.version}function zc(i,s,a,c){var h=i._dbSchema;a.objectStoreNames.contains("$meta")&&!h.$meta&&(h.$meta=Cs("$meta",ua("")[0],[]),i._storeNames.push("$meta"));var d=i._createTransaction("readwrite",i._storeNames,h);d.create(a),d._completion.catch(c);var v=d._reject.bind(d),g=X.transless||X;Ie(function(){return X.trans=d,X.transless=g,s!==0?(ii(i,a),w=s,((b=d).storeNames.includes("$meta")?b.table("$meta").get("version").then(function(E){return E??w}):q.resolve(w)).then(function(E){return T=E,x=d,O=a,A=[],E=(y=i)._versions,C=y._dbSchema=ai(0,y.idbdb,O),(E=E.filter(function(M){return M._cfg.version>=T})).length!==0?(E.forEach(function(M){A.push(function(){var P=C,k=M._cfg.dbschema;ui(y,P,O),ui(y,k,O),C=y._dbSchema=k;var D=Ps(P,k);D.add.forEach(function(K){Rs(O,K[0],K[1].primKey,K[1].indexes)}),D.change.forEach(function(K){if(K.recreate)throw new Z.Upgrade("Not yet support for changing primary key");var U=O.objectStore(K.name);K.add.forEach(function(G){return oi(U,G)}),K.change.forEach(function(G){U.deleteIndex(G.name),oi(U,G)}),K.del.forEach(function(G){return U.deleteIndex(G)})});var $=M._cfg.contentUpgrade;if($&&M._cfg.version>T){ii(y,O),x._memoizedTables={};var z=Fr(k);D.del.forEach(function(K){z[K]=P[K]}),Ms(y,[y.Transaction.prototype]),si(y,[y.Transaction.prototype],l(z),z),x.schema=z;var L,N=ls($);return N&&Cn(),D=q.follow(function(){var K;(L=$(x))&&N&&(K=De.bind(null,null),L.then(K,K))}),L&&typeof L.then=="function"?q.resolve(L):D.then(function(){return L})}}),A.push(function(P){var k,D,$=M._cfg.dbschema;k=$,D=P,[].slice.call(D.db.objectStoreNames).forEach(function(z){return k[z]==null&&D.db.deleteObjectStore(z)}),Ms(y,[y.Transaction.prototype]),si(y,[y.Transaction.prototype],y._storeNames,y._dbSchema),x.schema=y._dbSchema}),A.push(function(P){y.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(y.idbdb.version/10)===M._cfg.version?(y.idbdb.deleteObjectStore("$meta"),delete y._dbSchema.$meta,y._storeNames=y._storeNames.filter(function(k){return k!=="$meta"})):P.objectStore("$meta").put(M._cfg.version,"version"))})}),(function M(){return A.length?q.resolve(A.shift()(x.idbtrans)).then(M):q.resolve()})().then(function(){aa(C,O)})):q.resolve();var y,T,x,O,A,C}).catch(v)):(l(h).forEach(function(E){Rs(a,E,h[E].primKey,h[E].indexes)}),ii(i,a),void q.follow(function(){return i.on.populate.fire(d)}).catch(v));var b,w})}function Kc(i,s){aa(i._dbSchema,s),s.db.version%10!=0||s.objectStoreNames.contains("$meta")||s.db.createObjectStore("$meta").add(Math.ceil(s.db.version/10-1),"version");var a=ai(0,i.idbdb,s);ui(i,i._dbSchema,s);for(var c=0,h=Ps(a,i._dbSchema).change;c<h.length;c++){var d=(function(v){if(v.change.length||v.recreate)return console.warn("Unable to patch indexes of table ".concat(v.name," because it has changes on the type of index or primary key.")),{value:void 0};var g=s.objectStore(v.name);v.add.forEach(function(b){se&&console.debug("Dexie upgrade patch: Creating missing index ".concat(v.name,".").concat(b.src)),oi(g,b)})})(h[c]);if(typeof d=="object")return d.value}}function Ps(i,s){var a,c={del:[],add:[],change:[]};for(a in i)s[a]||c.del.push(a);for(a in s){var h=i[a],d=s[a];if(h){var v={name:a,def:d,recreate:!1,del:[],add:[],change:[]};if(""+(h.primKey.keyPath||"")!=""+(d.primKey.keyPath||"")||h.primKey.auto!==d.primKey.auto)v.recreate=!0,c.change.push(v);else{var g=h.idxByName,b=d.idxByName,w=void 0;for(w in g)b[w]||v.del.push(w);for(w in b){var E=g[w],y=b[w];E?E.src!==y.src&&v.change.push(y):v.add.push(y)}(0<v.del.length||0<v.add.length||0<v.change.length)&&c.change.push(v)}}else c.add.push([a,d])}return c}function Rs(i,s,a,c){var h=i.db.createObjectStore(s,a.keyPath?{keyPath:a.keyPath,autoIncrement:a.auto}:{autoIncrement:a.auto});return c.forEach(function(d){return oi(h,d)}),h}function aa(i,s){l(i).forEach(function(a){s.db.objectStoreNames.contains(a)||(se&&console.debug("Dexie: Creating missing table",a),Rs(s,a,i[a].primKey,i[a].indexes))})}function oi(i,s){i.createIndex(s.name,s.keyPath,{unique:s.unique,multiEntry:s.multi})}function ai(i,s,a){var c={};return ot(s.objectStoreNames,0).forEach(function(h){for(var d=a.objectStore(h),v=Es(sa(w=d.keyPath),w||"",!0,!1,!!d.autoIncrement,w&&typeof w!="string",!0),g=[],b=0;b<d.indexNames.length;++b){var E=d.index(d.indexNames[b]),w=E.keyPath,E=Es(E.name,w,!!E.unique,!!E.multiEntry,!1,w&&typeof w!="string",!1);g.push(E)}c[h]=Cs(h,v,g)}),c}function ui(i,s,a){for(var c=a.db.objectStoreNames,h=0;h<c.length;++h){var d=c[h],v=a.objectStore(d);i._hasGetAll="getAll"in v;for(var g=0;g<v.indexNames.length;++g){var b=v.indexNames[g],w=v.index(b).keyPath,E=typeof w=="string"?w:"["+ot(w).join("+")+"]";!s[d]||(w=s[d].idxByName[E])&&(w.name=b,delete s[d].idxByName[E],s[d].idxByName[b]=w)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&u.WorkerGlobalScope&&u instanceof u.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(i._hasGetAll=!1)}function ua(i){return i.split(",").map(function(s,a){var d=s.split(":"),c=(h=d[1])===null||h===void 0?void 0:h.trim(),h=(s=d[0].trim()).replace(/([&*]|\+\+)/g,""),d=/^\[/.test(h)?h.match(/^\[(.*)\]$/)[1].split("+"):h;return Es(h,d||null,/\&/.test(s),/\*/.test(s),/\+\+/.test(s),f(d),a===0,c)})}var Wc=(Rn.prototype._createTableSchema=Cs,Rn.prototype._parseIndexSyntax=ua,Rn.prototype._parseStoresSpec=function(i,s){var a=this;l(i).forEach(function(c){if(i[c]!==null){var h=a._parseIndexSyntax(i[c]),d=h.shift();if(!d)throw new Z.Schema("Invalid schema for table "+c+": "+i[c]);if(d.unique=!0,d.multi)throw new Z.Schema("Primary key cannot be multiEntry*");h.forEach(function(v){if(v.auto)throw new Z.Schema("Only primary key can be marked as autoIncrement (++)");if(!v.keyPath)throw new Z.Schema("Index must have a name and cannot be an empty string")}),h=a._createTableSchema(c,d,h),s[c]=h}})},Rn.prototype.stores=function(a){var s=this.db;this._cfg.storesSource=this._cfg.storesSource?p(this._cfg.storesSource,a):a;var a=s._versions,c={},h={};return a.forEach(function(d){p(c,d._cfg.storesSource),h=d._cfg.dbschema={},d._parseStoresSpec(c,h)}),s._dbSchema=h,Ms(s,[s._allTables,s,s.Transaction.prototype]),si(s,[s._allTables,s,s.Transaction.prototype,this._cfg.tables],l(h),h),s._storeNames=l(h),this},Rn.prototype.upgrade=function(i){return this._cfg.contentUpgrade=fs(this._cfg.contentUpgrade||pt,i),this},Rn);function Rn(){}function ks(i,s){var a=i._dbNamesDB;return a||(a=i._dbNamesDB=new _e(Qr,{addons:[],indexedDB:i,IDBKeyRange:s})).version(1).stores({dbnames:"name"}),a.table("dbnames")}function Is(i){return i&&typeof i.databases=="function"}function Ds(i){return Ie(function(){return X.letThrough=!0,i()})}function Bs(i){return!("from"in i)}var It=function(i,s){if(!this){var a=new It;return i&&"d"in i&&p(a,i),a}p(this,arguments.length?{d:1,from:i,to:1<arguments.length?s:i}:{d:0})};function gr(i,s,a){var c=at(s,a);if(!isNaN(c)){if(0<c)throw RangeError();if(Bs(i))return p(i,{from:s,to:a,d:1});var h=i.l,c=i.r;if(at(a,i.from)<0)return h?gr(h,s,a):i.l={from:s,to:a,d:1,l:null,r:null},la(i);if(0<at(s,i.to))return c?gr(c,s,a):i.r={from:s,to:a,d:1,l:null,r:null},la(i);at(s,i.from)<0&&(i.from=s,i.l=null,i.d=c?c.d+1:1),0<at(a,i.to)&&(i.to=a,i.r=null,i.d=i.l?i.l.d+1:1),a=!i.r,h&&!i.l&&yr(i,h),c&&a&&yr(i,c)}}function yr(i,s){Bs(s)||(function a(c,b){var d=b.from,v=b.to,g=b.l,b=b.r;gr(c,d,v),g&&a(c,g),b&&a(c,b)})(i,s)}function ca(i,s){var a=ci(s),c=a.next();if(c.done)return!1;for(var h=c.value,d=ci(i),v=d.next(h.from),g=v.value;!c.done&&!v.done;){if(at(g.from,h.to)<=0&&0<=at(g.to,h.from))return!0;at(h.from,g.from)<0?h=(c=a.next(g.from)).value:g=(v=d.next(h.from)).value}return!1}function ci(i){var s=Bs(i)?null:{s:0,n:i};return{next:function(a){for(var c=0<arguments.length;s;)switch(s.s){case 0:if(s.s=1,c)for(;s.n.l&&at(a,s.n.from)<0;)s={up:s,n:s.n.l,s:1};else for(;s.n.l;)s={up:s,n:s.n.l,s:1};case 1:if(s.s=2,!c||at(a,s.n.to)<=0)return{value:s.n,done:!1};case 2:if(s.n.r){s.s=3,s={up:s,n:s.n.r,s:0};continue}case 3:s=s.up}return{done:!0}}}}function la(i){var s,a,c=(((s=i.r)===null||s===void 0?void 0:s.d)||0)-(((a=i.l)===null||a===void 0?void 0:a.d)||0),h=1<c?"r":c<-1?"l":"";h&&(s=h=="r"?"l":"r",a=r({},i),c=i[h],i.from=c.from,i.to=c.to,i[h]=c[h],a[h]=c[s],(i[s]=a).d=ha(a)),i.d=ha(i)}function ha(a){var s=a.r,a=a.l;return(s?a?Math.max(s.d,a.d):s.d:a?a.d:0)+1}function li(i,s){return l(s).forEach(function(a){i[a]?yr(i[a],s[a]):i[a]=(function c(h){var d,v,g={};for(d in h)S(h,d)&&(v=h[d],g[d]=!v||typeof v!="object"||nr.has(v.constructor)?v:c(v));return g})(s[a])}),i}function Ls(i,s){return i.all||s.all||Object.keys(i).some(function(a){return s[a]&&ca(s[a],i[a])})}R(It.prototype,((Vt={add:function(i){return yr(this,i),this},addKey:function(i){return gr(this,i,i),this},addKeys:function(i){var s=this;return i.forEach(function(a){return gr(s,a,a)}),this},hasKey:function(i){var s=ci(this).next(i).value;return s&&at(s.from,i)<=0&&0<=at(s.to,i)}})[ir]=function(){return ci(this)},Vt));var nn={},js={},$s=!1;function hi(i){li(js,i),$s||($s=!0,setTimeout(function(){$s=!1,Ns(js,!(js={}))},0))}function Ns(i,s){s===void 0&&(s=!1);var a=new Set;if(i.all)for(var c=0,h=Object.values(nn);c<h.length;c++)fa(v=h[c],i,a,s);else for(var d in i){var v,g=/^idb\:\/\/(.*)\/(.*)\//.exec(d);g&&(d=g[1],g=g[2],(v=nn["idb://".concat(d,"/").concat(g)])&&fa(v,i,a,s))}a.forEach(function(b){return b()})}function fa(i,s,a,c){for(var h=[],d=0,v=Object.entries(i.queries.query);d<v.length;d++){for(var g=v[d],b=g[0],w=[],E=0,y=g[1];E<y.length;E++){var T=y[E];Ls(s,T.obsSet)?T.subscribers.forEach(function(C){return a.add(C)}):c&&w.push(T)}c&&h.push([b,w])}if(c)for(var x=0,O=h;x<O.length;x++){var A=O[x],b=A[0],w=A[1];i.queries.query[b]=w}}function Vc(i){var s=i._state,a=i._deps.indexedDB;if(s.isBeingOpened||i.idbdb)return s.dbReadyPromise.then(function(){return s.dbOpenError?wt(s.dbOpenError):i});s.isBeingOpened=!0,s.dbOpenError=null,s.openComplete=!1;var c=s.openCanceller,h=Math.round(10*i.verno),d=!1;function v(){if(s.openCanceller!==c)throw new Z.DatabaseClosed("db.open() was cancelled")}function g(){return new q(function(T,x){if(v(),!a)throw new Z.MissingAPI;var O=i.name,A=s.autoSchema||!h?a.open(O):a.open(O,h);if(!A)throw new Z.MissingAPI;A.onerror=oe(x),A.onblocked=gt(i._fireOnBlocked),A.onupgradeneeded=gt(function(C){var M;E=A.transaction,s.autoSchema&&!i._options.allowEmptyDB?(A.onerror=dr,E.abort(),A.result.close(),(M=a.deleteDatabase(O)).onsuccess=M.onerror=gt(function(){x(new Z.NoSuchDatabase("Database ".concat(O," doesnt exist")))})):(E.onerror=oe(x),C=C.oldVersion>Math.pow(2,62)?0:C.oldVersion,y=C<1,i.idbdb=A.result,d&&Kc(i,E),zc(i,C/10,E,x))},x),A.onsuccess=gt(function(){E=null;var C,M,P,k,D,$=i.idbdb=A.result,z=ot($.objectStoreNames);if(0<z.length)try{var L=$.transaction((k=z).length===1?k[0]:k,"readonly");if(s.autoSchema)M=$,P=L,(C=i).verno=M.version/10,P=C._dbSchema=ai(0,M,P),C._storeNames=ot(M.objectStoreNames,0),si(C,[C._allTables],l(P),P);else if(ui(i,i._dbSchema,L),((D=Ps(ai(0,(D=i).idbdb,L),D._dbSchema)).add.length||D.change.some(function(N){return N.add.length||N.change.length}))&&!d)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),$.close(),h=$.version+1,d=!0,T(g());ii(i,L)}catch{}Tn.push(i),$.onversionchange=gt(function(N){s.vcFired=!0,i.on("versionchange").fire(N)}),$.onclose=gt(function(){i.close({disableAutoOpen:!1})}),y&&(D=i._deps,L=O,$=D.indexedDB,D=D.IDBKeyRange,Is($)||L===Qr||ks($,D).put({name:L}).catch(pt)),T()},x)}).catch(function(T){switch(T?.name){case"UnknownError":if(0<s.PR1398_maxLoop)return s.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),g();break;case"VersionError":if(0<h)return h=0,g()}return q.reject(T)})}var b,w=s.dbReadyResolve,E=null,y=!1;return q.race([c,(typeof navigator>"u"?q.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(T){function x(){return indexedDB.databases().finally(T)}b=setInterval(x,100),x()}).finally(function(){return clearInterval(b)}):Promise.resolve()).then(g)]).then(function(){return v(),s.onReadyBeingFired=[],q.resolve(Ds(function(){return i.on.ready.fire(i.vip)})).then(function T(){if(0<s.onReadyBeingFired.length){var x=s.onReadyBeingFired.reduce(fs,pt);return s.onReadyBeingFired=[],q.resolve(Ds(function(){return x(i.vip)})).then(T)}})}).finally(function(){s.openCanceller===c&&(s.onReadyBeingFired=null,s.isBeingOpened=!1)}).catch(function(T){s.dbOpenError=T;try{E&&E.abort()}catch{}return c===s.openCanceller&&i._close(),wt(T)}).finally(function(){s.openComplete=!0,w()}).then(function(){var T;return y&&(T={},i.tables.forEach(function(x){x.schema.indexes.forEach(function(O){O.name&&(T["idb://".concat(i.name,"/").concat(x.name,"/").concat(O.name)]=new It(-1/0,[[[]]]))}),T["idb://".concat(i.name,"/").concat(x.name,"/")]=T["idb://".concat(i.name,"/").concat(x.name,"/:dels")]=new It(-1/0,[[[]]])}),je(pr).fire(T),Ns(T,!0)),i})}function Us(i){function s(d){return i.next(d)}var a=h(s),c=h(function(d){return i.throw(d)});function h(d){return function(b){var g=d(b),b=g.value;return g.done?b:b&&typeof b.then=="function"?b.then(a,c):f(b)?Promise.all(b).then(a,c):a(b)}}return h(s)()}function fi(i,s,a){for(var c=f(i)?i.slice():[i],h=0;h<a;++h)c.push(s);return c}var qc={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(i){return r(r({},i),{table:function(s){var a=i.table(s),c=a.schema,h={},d=[];function v(y,T,x){var O=mr(y),A=h[O]=h[O]||[],C=y==null?0:typeof y=="string"?1:y.length,M=0<T,M=r(r({},x),{name:M?"".concat(O,"(virtual-from:").concat(x.name,")"):x.name,lowLevelIndex:x,isVirtual:M,keyTail:T,keyLength:C,extractKey:Ts(y),unique:!M&&x.unique});return A.push(M),M.isPrimaryKey||d.push(M),1<C&&v(C===2?y[0]:y.slice(0,C-1),T+1,x),A.sort(function(P,k){return P.keyTail-k.keyTail}),M}s=v(c.primaryKey.keyPath,0,c.primaryKey),h[":id"]=[s];for(var g=0,b=c.indexes;g<b.length;g++){var w=b[g];v(w.keyPath,0,w)}function E(y){var T,x=y.query.index;return x.isVirtual?r(r({},y),{query:{index:x.lowLevelIndex,range:(T=y.query.range,x=x.keyTail,{type:T.type===1?2:T.type,lower:fi(T.lower,T.lowerOpen?i.MAX_KEY:i.MIN_KEY,x),lowerOpen:!0,upper:fi(T.upper,T.upperOpen?i.MIN_KEY:i.MAX_KEY,x),upperOpen:!0})}}):y}return r(r({},a),{schema:r(r({},c),{primaryKey:s,indexes:d,getIndexByKeyPath:function(y){return(y=h[mr(y)])&&y[0]}}),count:function(y){return a.count(E(y))},query:function(y){return a.query(E(y))},openCursor:function(y){var T=y.query.index,x=T.keyTail,O=T.isVirtual,A=T.keyLength;return O?a.openCursor(E(y)).then(function(M){return M&&C(M)}):a.openCursor(y);function C(M){return Object.create(M,{continue:{value:function(P){P!=null?M.continue(fi(P,y.reverse?i.MAX_KEY:i.MIN_KEY,x)):y.unique?M.continue(M.key.slice(0,A).concat(y.reverse?i.MIN_KEY:i.MAX_KEY,x)):M.continue()}},continuePrimaryKey:{value:function(P,k){M.continuePrimaryKey(fi(P,i.MAX_KEY,x),k)}},primaryKey:{get:function(){return M.primaryKey}},key:{get:function(){var P=M.key;return A===1?P[0]:P.slice(0,A)}},value:{get:function(){return M.value}}})}}})}})}};function Fs(i,s,a,c){return a=a||{},c=c||"",l(i).forEach(function(h){var d,v,g;S(s,h)?(d=i[h],v=s[h],typeof d=="object"&&typeof v=="object"&&d&&v?(g=rr(d))!==rr(v)?a[c+h]=s[h]:g==="Object"?Fs(d,v,a,c+h+"."):d!==v&&(a[c+h]=s[h]):d!==v&&(a[c+h]=s[h])):a[c+h]=void 0}),l(s).forEach(function(h){S(i,h)||(a[c+h]=s[h])}),a}function zs(i,s){return s.type==="delete"?s.keys:s.keys||s.values.map(i.extractKey)}var Gc={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(i){return r(r({},i),{table:function(s){var a=i.table(s),c=a.schema.primaryKey;return r(r({},a),{mutate:function(h){var d=X.trans,v=d.table(s).hook,g=v.deleting,b=v.creating,w=v.updating;switch(h.type){case"add":if(b.fire===pt)break;return d._promise("readwrite",function(){return E(h)},!0);case"put":if(b.fire===pt&&w.fire===pt)break;return d._promise("readwrite",function(){return E(h)},!0);case"delete":if(g.fire===pt)break;return d._promise("readwrite",function(){return E(h)},!0);case"deleteRange":if(g.fire===pt)break;return d._promise("readwrite",function(){return(function y(T,x,O){return a.query({trans:T,values:!1,query:{index:c,range:x},limit:O}).then(function(A){var C=A.result;return E({type:"delete",keys:C,trans:T}).then(function(M){return 0<M.numFailures?Promise.reject(M.failures[0]):C.length<O?{failures:[],numFailures:0,lastResult:void 0}:y(T,r(r({},x),{lower:C[C.length-1],lowerOpen:!0}),O)})})})(h.trans,h.range,1e4)},!0)}return a.mutate(h);function E(y){var T,x,O,A=X.trans,C=y.keys||zs(c,y);if(!C)throw new Error("Keys missing");return(y=y.type==="add"||y.type==="put"?r(r({},y),{keys:C}):r({},y)).type!=="delete"&&(y.values=o([],y.values)),y.keys&&(y.keys=o([],y.keys)),T=a,O=C,((x=y).type==="add"?Promise.resolve([]):T.getMany({trans:x.trans,keys:O,cache:"immutable"})).then(function(M){var P=C.map(function(k,D){var $,z,L,N=M[D],K={onerror:null,onsuccess:null};return y.type==="delete"?g.fire.call(K,k,N,A):y.type==="add"||N===void 0?($=b.fire.call(K,k,y.values[D],A),k==null&&$!=null&&(y.keys[D]=k=$,c.outbound||yt(y.values[D],c.keyPath,k))):($=Fs(N,y.values[D]),(z=w.fire.call(K,$,k,N,A))&&(L=y.values[D],Object.keys(z).forEach(function(U){S(L,U)?L[U]=z[U]:yt(L,U,z[U])}))),K});return a.mutate(y).then(function(k){for(var D=k.failures,$=k.results,z=k.numFailures,k=k.lastResult,L=0;L<C.length;++L){var N=($||C)[L],K=P[L];N==null?K.onerror&&K.onerror(D[L]):K.onsuccess&&K.onsuccess(y.type==="put"&&M[L]?y.values[L]:N)}return{failures:D,results:$,numFailures:z,lastResult:k}}).catch(function(k){return P.forEach(function(D){return D.onerror&&D.onerror(k)}),Promise.reject(k)})})}}})}})}};function da(i,s,a){try{if(!s||s.keys.length<i.length)return null;for(var c=[],h=0,d=0;h<s.keys.length&&d<i.length;++h)at(s.keys[h],i[d])===0&&(c.push(a?ve(s.values[h]):s.values[h]),++d);return c.length===i.length?c:null}catch{return null}}var Hc={stack:"dbcore",level:-1,create:function(i){return{table:function(s){var a=i.table(s);return r(r({},a),{getMany:function(c){if(!c.cache)return a.getMany(c);var h=da(c.keys,c.trans._cache,c.cache==="clone");return h?q.resolve(h):a.getMany(c).then(function(d){return c.trans._cache={keys:c.keys,values:c.cache==="clone"?ve(d):d},d})},mutate:function(c){return c.type!=="add"&&(c.trans._cache=null),a.mutate(c)}})}}}};function pa(i,s){return i.trans.mode==="readonly"&&!!i.subscr&&!i.trans.explicit&&i.trans.db._options.cache!=="disabled"&&!s.schema.primaryKey.outbound}function va(i,s){switch(i){case"query":return s.values&&!s.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Xc={stack:"dbcore",level:0,name:"Observability",create:function(i){var s=i.schema.name,a=new It(i.MIN_KEY,i.MAX_KEY);return r(r({},i),{transaction:function(c,h,d){if(X.subscr&&h!=="readonly")throw new Z.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(X.querier));return i.transaction(c,h,d)},table:function(c){var h=i.table(c),d=h.schema,v=d.primaryKey,y=d.indexes,g=v.extractKey,b=v.outbound,w=v.autoIncrement&&y.filter(function(x){return x.compound&&x.keyPath.includes(v.keyPath)}),E=r(r({},h),{mutate:function(x){function O(U){return U="idb://".concat(s,"/").concat(c,"/").concat(U),k[U]||(k[U]=new It)}var A,C,M,P=x.trans,k=x.mutatedParts||(x.mutatedParts={}),D=O(""),$=O(":dels"),z=x.type,K=x.type==="deleteRange"?[x.range]:x.type==="delete"?[x.keys]:x.values.length<50?[zs(v,x).filter(function(U){return U}),x.values]:[],L=K[0],N=K[1],K=x.trans._cache;return f(L)?(D.addKeys(L),(K=z==="delete"||L.length===N.length?da(L,K):null)||$.addKeys(L),(K||N)&&(A=O,C=K,M=N,d.indexes.forEach(function(U){var G=A(U.name||"");function rt(st){return st!=null?U.extractKey(st):null}function it(st){return U.multiEntry&&f(st)?st.forEach(function(Ft){return G.addKey(Ft)}):G.addKey(st)}(C||M).forEach(function(st,Dt){var nt=C&&rt(C[Dt]),Dt=M&&rt(M[Dt]);at(nt,Dt)!==0&&(nt!=null&&it(nt),Dt!=null&&it(Dt))})}))):L?(N={from:(N=L.lower)!==null&&N!==void 0?N:i.MIN_KEY,to:(N=L.upper)!==null&&N!==void 0?N:i.MAX_KEY},$.add(N),D.add(N)):(D.add(a),$.add(a),d.indexes.forEach(function(U){return O(U.name).add(a)})),h.mutate(x).then(function(U){return!L||x.type!=="add"&&x.type!=="put"||(D.addKeys(U.results),w&&w.forEach(function(G){for(var rt=x.values.map(function(nt){return G.extractKey(nt)}),it=G.keyPath.findIndex(function(nt){return nt===v.keyPath}),st=0,Ft=U.results.length;st<Ft;++st)rt[st][it]=U.results[st];O(G.name).addKeys(rt)})),P.mutatedParts=li(P.mutatedParts||{},k),U})}}),y=function(O){var A=O.query,O=A.index,A=A.range;return[O,new It((O=A.lower)!==null&&O!==void 0?O:i.MIN_KEY,(A=A.upper)!==null&&A!==void 0?A:i.MAX_KEY)]},T={get:function(x){return[v,new It(x.key)]},getMany:function(x){return[v,new It().addKeys(x.keys)]},count:y,query:y,openCursor:y};return l(T).forEach(function(x){E[x]=function(O){var A=X.subscr,C=!!A,M=pa(X,h)&&va(x,O)?O.obsSet={}:A;if(C){var P=function(N){return N="idb://".concat(s,"/").concat(c,"/").concat(N),M[N]||(M[N]=new It)},k=P(""),D=P(":dels"),A=T[x](O),C=A[0],A=A[1];if((x==="query"&&C.isPrimaryKey&&!O.values?D:P(C.name||"")).add(A),!C.isPrimaryKey){if(x!=="count"){var $=x==="query"&&b&&O.values&&h.query(r(r({},O),{values:!1}));return h[x].apply(this,arguments).then(function(N){if(x==="query"){if(b&&O.values)return $.then(function(rt){return rt=rt.result,k.addKeys(rt),N});var K=O.values?N.result.map(g):N.result;(O.values?k:D).addKeys(K)}else if(x==="openCursor"){var U=N,G=O.values;return U&&Object.create(U,{key:{get:function(){return D.addKey(U.primaryKey),U.key}},primaryKey:{get:function(){var rt=U.primaryKey;return D.addKey(rt),rt}},value:{get:function(){return G&&k.addKey(U.primaryKey),U.value}}})}return N})}D.add(a)}}return h[x].apply(this,arguments)}}),E}})}};function ma(i,s,a){if(a.numFailures===0)return s;if(s.type==="deleteRange")return null;var c=s.keys?s.keys.length:"values"in s&&s.values?s.values.length:1;return a.numFailures===c?null:(s=r({},s),f(s.keys)&&(s.keys=s.keys.filter(function(h,d){return!(d in a.failures)})),"values"in s&&f(s.values)&&(s.values=s.values.filter(function(h,d){return!(d in a.failures)})),s)}function Ks(i,s){return a=i,((c=s).lower===void 0||(c.lowerOpen?0<at(a,c.lower):0<=at(a,c.lower)))&&(i=i,(s=s).upper===void 0||(s.upperOpen?at(i,s.upper)<0:at(i,s.upper)<=0));var a,c}function ga(i,s,T,c,h,d){if(!T||T.length===0)return i;var v=s.query.index,g=v.multiEntry,b=s.query.range,w=c.schema.primaryKey.extractKey,E=v.extractKey,y=(v.lowLevelIndex||v).extractKey,T=T.reduce(function(x,O){var A=x,C=[];if(O.type==="add"||O.type==="put")for(var M=new It,P=O.values.length-1;0<=P;--P){var k,D=O.values[P],$=w(D);M.hasKey($)||(k=E(D),(g&&f(k)?k.some(function(U){return Ks(U,b)}):Ks(k,b))&&(M.addKey($),C.push(D)))}switch(O.type){case"add":var z=new It().addKeys(s.values?x.map(function(G){return w(G)}):x),A=x.concat(s.values?C.filter(function(G){return G=w(G),!z.hasKey(G)&&(z.addKey(G),!0)}):C.map(function(G){return w(G)}).filter(function(G){return!z.hasKey(G)&&(z.addKey(G),!0)}));break;case"put":var L=new It().addKeys(O.values.map(function(G){return w(G)}));A=x.filter(function(G){return!L.hasKey(s.values?w(G):G)}).concat(s.values?C:C.map(function(G){return w(G)}));break;case"delete":var N=new It().addKeys(O.keys);A=x.filter(function(G){return!N.hasKey(s.values?w(G):G)});break;case"deleteRange":var K=O.range;A=x.filter(function(G){return!Ks(w(G),K)})}return A},i);return T===i?i:(T.sort(function(x,O){return at(y(x),y(O))||at(w(x),w(O))}),s.limit&&s.limit<1/0&&(T.length>s.limit?T.length=s.limit:i.length===s.limit&&T.length<s.limit&&(h.dirty=!0)),d?Object.freeze(T):T)}function ya(i,s){return at(i.lower,s.lower)===0&&at(i.upper,s.upper)===0&&!!i.lowerOpen==!!s.lowerOpen&&!!i.upperOpen==!!s.upperOpen}function Yc(i,s){return(function(a,c,h,d){if(a===void 0)return c!==void 0?-1:0;if(c===void 0)return 1;if((c=at(a,c))===0){if(h&&d)return 0;if(h)return 1;if(d)return-1}return c})(i.lower,s.lower,i.lowerOpen,s.lowerOpen)<=0&&0<=(function(a,c,h,d){if(a===void 0)return c!==void 0?1:0;if(c===void 0)return-1;if((c=at(a,c))===0){if(h&&d)return 0;if(h)return-1;if(d)return 1}return c})(i.upper,s.upper,i.upperOpen,s.upperOpen)}function Zc(i,s,a,c){i.subscribers.add(a),c.addEventListener("abort",function(){var h,d;i.subscribers.delete(a),i.subscribers.size===0&&(h=i,d=s,setTimeout(function(){h.subscribers.size===0&&me(d,h)},3e3))})}var Qc={stack:"dbcore",level:0,name:"Cache",create:function(i){var s=i.schema.name;return r(r({},i),{transaction:function(a,c,h){var d,v,g=i.transaction(a,c,h);return c==="readwrite"&&(v=(d=new AbortController).signal,h=function(b){return function(){if(d.abort(),c==="readwrite"){for(var w=new Set,E=0,y=a;E<y.length;E++){var T=y[E],x=nn["idb://".concat(s,"/").concat(T)];if(x){var O=i.table(T),A=x.optimisticOps.filter(function(G){return G.trans===g});if(g._explicit&&b&&g.mutatedParts)for(var C=0,M=Object.values(x.queries.query);C<M.length;C++)for(var P=0,k=(z=M[C]).slice();P<k.length;P++)Ls((L=k[P]).obsSet,g.mutatedParts)&&(me(z,L),L.subscribers.forEach(function(G){return w.add(G)}));else if(0<A.length){x.optimisticOps=x.optimisticOps.filter(function(G){return G.trans!==g});for(var D=0,$=Object.values(x.queries.query);D<$.length;D++)for(var z,L,N,K=0,U=(z=$[D]).slice();K<U.length;K++)(L=U[K]).res!=null&&g.mutatedParts&&(b&&!L.dirty?(N=Object.isFrozen(L.res),N=ga(L.res,L.req,A,O,L,N),L.dirty?(me(z,L),L.subscribers.forEach(function(G){return w.add(G)})):N!==L.res&&(L.res=N,L.promise=q.resolve({result:N}))):(L.dirty&&me(z,L),L.subscribers.forEach(function(G){return w.add(G)})))}}}w.forEach(function(G){return G()})}}},g.addEventListener("abort",h(!1),{signal:v}),g.addEventListener("error",h(!1),{signal:v}),g.addEventListener("complete",h(!0),{signal:v})),g},table:function(a){var c=i.table(a),h=c.schema.primaryKey;return r(r({},c),{mutate:function(d){var v=X.trans;if(h.outbound||v.db._options.cache==="disabled"||v.explicit||v.idbtrans.mode!=="readwrite")return c.mutate(d);var g=nn["idb://".concat(s,"/").concat(a)];return g?(v=c.mutate(d),d.type!=="add"&&d.type!=="put"||!(50<=d.values.length||zs(h,d).some(function(b){return b==null}))?(g.optimisticOps.push(d),d.mutatedParts&&hi(d.mutatedParts),v.then(function(b){0<b.numFailures&&(me(g.optimisticOps,d),(b=ma(0,d,b))&&g.optimisticOps.push(b),d.mutatedParts&&hi(d.mutatedParts))}),v.catch(function(){me(g.optimisticOps,d),d.mutatedParts&&hi(d.mutatedParts)})):v.then(function(b){var w=ma(0,r(r({},d),{values:d.values.map(function(E,y){var T;return b.failures[y]?E:(E=(T=h.keyPath)!==null&&T!==void 0&&T.includes(".")?ve(E):r({},E),yt(E,h.keyPath,b.results[y]),E)})}),b);g.optimisticOps.push(w),queueMicrotask(function(){return d.mutatedParts&&hi(d.mutatedParts)})}),v):c.mutate(d)},query:function(d){if(!pa(X,c)||!va("query",d))return c.query(d);var v=((w=X.trans)===null||w===void 0?void 0:w.db._options.cache)==="immutable",y=X,g=y.requery,b=y.signal,w=(function(O,A,C,M){var P=nn["idb://".concat(O,"/").concat(A)];if(!P)return[];if(!(A=P.queries[C]))return[null,!1,P,null];var k=A[(M.query?M.query.index.name:null)||""];if(!k)return[null,!1,P,null];switch(C){case"query":var D=k.find(function($){return $.req.limit===M.limit&&$.req.values===M.values&&ya($.req.query.range,M.query.range)});return D?[D,!0,P,k]:[k.find(function($){return("limit"in $.req?$.req.limit:1/0)>=M.limit&&(!M.values||$.req.values)&&Yc($.req.query.range,M.query.range)}),!1,P,k];case"count":return D=k.find(function($){return ya($.req.query.range,M.query.range)}),[D,!!D,P,k]}})(s,a,"query",d),E=w[0],y=w[1],T=w[2],x=w[3];return E&&y?E.obsSet=d.obsSet:(y=c.query(d).then(function(O){var A=O.result;if(E&&(E.res=A),v){for(var C=0,M=A.length;C<M;++C)Object.freeze(A[C]);Object.freeze(A)}else O.result=ve(A);return O}).catch(function(O){return x&&E&&me(x,E),Promise.reject(O)}),E={obsSet:d.obsSet,promise:y,subscribers:new Set,type:"query",req:d,dirty:!1},x?x.push(E):(x=[E],(T=T||(nn["idb://".concat(s,"/").concat(a)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[d.query.index.name||""]=x)),Zc(E,x,g,b),E.promise.then(function(O){return{result:ga(O.result,d,T?.optimisticOps,c,E,v)}})}})}})}};function di(i,s){return new Proxy(i,{get:function(a,c,h){return c==="db"?s:Reflect.get(a,c,h)}})}var _e=(xt.prototype.version=function(i){if(isNaN(i)||i<.1)throw new Z.Type("Given version is not a positive number");if(i=Math.round(10*i)/10,this.idbdb||this._state.isBeingOpened)throw new Z.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,i);var s=this._versions,a=s.filter(function(c){return c._cfg.version===i})[0];return a||(a=new this.Version(i),s.push(a),s.sort(Fc),a.stores({}),this._state.autoSchema=!1,a)},xt.prototype._whenReady=function(i){var s=this;return this.idbdb&&(this._state.openComplete||X.letThrough||this._vip)?i():new q(function(a,c){if(s._state.openComplete)return c(new Z.DatabaseClosed(s._state.dbOpenError));if(!s._state.isBeingOpened){if(!s._state.autoOpen)return void c(new Z.DatabaseClosed);s.open().catch(pt)}s._state.dbReadyPromise.then(a,c)}).then(i)},xt.prototype.use=function(i){var s=i.stack,a=i.create,c=i.level,h=i.name;return h&&this.unuse({stack:s,name:h}),i=this._middlewares[s]||(this._middlewares[s]=[]),i.push({stack:s,create:a,level:c??10,name:h}),i.sort(function(d,v){return d.level-v.level}),this},xt.prototype.unuse=function(i){var s=i.stack,a=i.name,c=i.create;return s&&this._middlewares[s]&&(this._middlewares[s]=this._middlewares[s].filter(function(h){return c?h.create!==c:!!a&&h.name!==a})),this},xt.prototype.open=function(){var i=this;return Je(ke,function(){return Vc(i)})},xt.prototype._close=function(){this.on.close.fire(new CustomEvent("close"));var i=this._state,s=Tn.indexOf(this);if(0<=s&&Tn.splice(s,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}i.isBeingOpened||(i.dbReadyPromise=new q(function(a){i.dbReadyResolve=a}),i.openCanceller=new q(function(a,c){i.cancelOpen=c}))},xt.prototype.close=function(a){var s=(a===void 0?{disableAutoOpen:!0}:a).disableAutoOpen,a=this._state;s?(a.isBeingOpened&&a.cancelOpen(new Z.DatabaseClosed),this._close(),a.autoOpen=!1,a.dbOpenError=new Z.DatabaseClosed):(this._close(),a.autoOpen=this._options.autoOpen||a.isBeingOpened,a.openComplete=!1,a.dbOpenError=null)},xt.prototype.delete=function(i){var s=this;i===void 0&&(i={disableAutoOpen:!0});var a=0<arguments.length&&typeof arguments[0]!="object",c=this._state;return new q(function(h,d){function v(){s.close(i);var g=s._deps.indexedDB.deleteDatabase(s.name);g.onsuccess=gt(function(){var b,w,E;b=s._deps,w=s.name,E=b.indexedDB,b=b.IDBKeyRange,Is(E)||w===Qr||ks(E,b).delete(w).catch(pt),h()}),g.onerror=oe(d),g.onblocked=s._fireOnBlocked}if(a)throw new Z.InvalidArgument("Invalid closeOptions argument to db.delete()");c.isBeingOpened?c.dbReadyPromise.then(v):v()})},xt.prototype.backendDB=function(){return this.idbdb},xt.prototype.isOpen=function(){return this.idbdb!==null},xt.prototype.hasBeenClosed=function(){var i=this._state.dbOpenError;return i&&i.name==="DatabaseClosed"},xt.prototype.hasFailed=function(){return this._state.dbOpenError!==null},xt.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(xt.prototype,"tables",{get:function(){var i=this;return l(this._allTables).map(function(s){return i._allTables[s]})},enumerable:!1,configurable:!0}),xt.prototype.transaction=function(){var i=(function(s,a,c){var h=arguments.length;if(h<2)throw new Z.InvalidArgument("Too few arguments");for(var d=new Array(h-1);--h;)d[h-1]=arguments[h];return c=d.pop(),[s,er(d),c]}).apply(this,arguments);return this._transaction.apply(this,i)},xt.prototype._transaction=function(i,s,a){var c=this,h=X.trans;h&&h.db===this&&i.indexOf("!")===-1||(h=null);var d,v,g=i.indexOf("?")!==-1;i=i.replace("!","").replace("?","");try{if(v=s.map(function(w){if(w=w instanceof c.Table?w.name:w,typeof w!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return w}),i=="r"||i===ws)d=ws;else{if(i!="rw"&&i!=xs)throw new Z.InvalidArgument("Invalid transaction mode: "+i);d=xs}if(h){if(h.mode===ws&&d===xs){if(!g)throw new Z.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");h=null}h&&v.forEach(function(w){if(h&&h.storeNames.indexOf(w)===-1){if(!g)throw new Z.SubTransaction("Table "+w+" not included in parent transaction.");h=null}}),g&&h&&!h.active&&(h=null)}}catch(w){return h?h._promise(null,function(E,y){y(w)}):wt(w)}var b=(function w(E,y,T,x,O){return q.resolve().then(function(){var A=X.transless||X,C=E._createTransaction(y,T,E._dbSchema,x);if(C.explicit=!0,A={trans:C,transless:A},x)C.idbtrans=x.idbtrans;else try{C.create(),C.idbtrans._explicit=!0,E._state.PR1398_maxLoop=3}catch(k){return k.name===hs.InvalidState&&E.isOpen()&&0<--E._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),E.close({disableAutoOpen:!1}),E.open().then(function(){return w(E,y,T,null,O)})):wt(k)}var M,P=ls(O);return P&&Cn(),A=q.follow(function(){var k;(M=O.call(C,C))&&(P?(k=De.bind(null,null),M.then(k,k)):typeof M.next=="function"&&typeof M.throw=="function"&&(M=Us(M)))},A),(M&&typeof M.then=="function"?q.resolve(M).then(function(k){return C.active?k:wt(new Z.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):A.then(function(){return M})).then(function(k){return x&&C._resolve(),C._completion.then(function(){return k})}).catch(function(k){return C._reject(k),wt(k)})})}).bind(null,this,d,v,h,a);return h?h._promise(d,b,"lock"):X.trans?Je(X.transless,function(){return c._whenReady(b)}):this._whenReady(b)},xt.prototype.table=function(i){if(!S(this._allTables,i))throw new Z.InvalidTable("Table ".concat(i," does not exist"));return this._allTables[i]},xt);function xt(i,s){var a=this;this._middlewares={},this.verno=0;var c=xt.dependencies;this._options=s=r({addons:xt.addons,autoOpen:!0,indexedDB:c.indexedDB,IDBKeyRange:c.IDBKeyRange,cache:"cloned"},s),this._deps={indexedDB:s.indexedDB,IDBKeyRange:s.IDBKeyRange},c=s.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var h,d,v,g,b,w={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:pt,dbReadyPromise:null,cancelOpen:pt,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:s.autoOpen};w.dbReadyPromise=new q(function(y){w.dbReadyResolve=y}),w.openCanceller=new q(function(y,T){w.cancelOpen=T}),this._state=w,this.name=i,this.on=hr(this,"populate","blocked","versionchange","close",{ready:[fs,pt]}),this.once=function(y,T){var x=function(){for(var O=[],A=0;A<arguments.length;A++)O[A]=arguments[A];a.on(y).unsubscribe(x),T.apply(a,O)};return a.on(y,x)},this.on.ready.subscribe=Q(this.on.ready.subscribe,function(y){return function(T,x){xt.vip(function(){var O,A=a._state;A.openComplete?(A.dbOpenError||q.resolve().then(T),x&&y(T)):A.onReadyBeingFired?(A.onReadyBeingFired.push(T),x&&y(T)):(y(T),O=a,x||y(function C(){O.on.ready.unsubscribe(T),O.on.ready.unsubscribe(C)}))})}}),this.Collection=(h=this,fr(Dc.prototype,function(M,C){this.db=h;var x=Go,O=null;if(C)try{x=C()}catch(P){O=P}var A=M._ctx,C=A.table,M=C.hook.reading.fire;this._ctx={table:C,index:A.index,isPrimKey:!A.index||C.schema.primKey.keyPath&&A.index===C.schema.primKey.name,range:x,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:O,or:A.or,valueMapper:M!==sr?M:null}})),this.Table=(d=this,fr(Jo.prototype,function(y,T,x){this.db=d,this._tx=x,this.name=y,this.schema=T,this.hook=d._allTables[y]?d._allTables[y].hook:hr(null,{creating:[Ac,pt],reading:[Oc,sr],updating:[Cc,pt],deleting:[Ec,pt]})})),this.Transaction=(v=this,fr(jc.prototype,function(y,T,x,O,A){var C=this;y!=="readonly"&&T.forEach(function(M){M=(M=x[M])===null||M===void 0?void 0:M.yProps,M&&(T=T.concat(M.map(function(P){return P.updatesTable})))}),this.db=v,this.mode=y,this.storeNames=T,this.schema=x,this.chromeTransactionDurability=O,this.idbtrans=null,this.on=hr(this,"complete","error","abort"),this.parent=A||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new q(function(M,P){C._resolve=M,C._reject=P}),this._completion.then(function(){C.active=!1,C.on.complete.fire()},function(M){var P=C.active;return C.active=!1,C.on.error.fire(M),C.parent?C.parent._reject(M):P&&C.idbtrans&&C.idbtrans.abort(),wt(M)})})),this.Version=(g=this,fr(Wc.prototype,function(y){this.db=g,this._cfg={version:y,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(b=this,fr(ia.prototype,function(y,T,x){if(this.db=b,this._ctx={table:y,index:T===":id"?null:T,or:x},this._cmp=this._ascending=at,this._descending=function(O,A){return at(A,O)},this._max=function(O,A){return 0<at(O,A)?O:A},this._min=function(O,A){return at(O,A)<0?O:A},this._IDBKeyRange=b._deps.IDBKeyRange,!this._IDBKeyRange)throw new Z.MissingAPI})),this.on("versionchange",function(y){0<y.newVersion?console.warn("Another connection wants to upgrade database '".concat(a.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(a.name,"'. Closing db now to resume the delete request.")),a.close({disableAutoOpen:!1})}),this.on("blocked",function(y){!y.newVersion||y.newVersion<y.oldVersion?console.warn("Dexie.delete('".concat(a.name,"') was blocked")):console.warn("Upgrade '".concat(a.name,"' blocked by other connection holding version ").concat(y.oldVersion/10))}),this._maxKey=vr(s.IDBKeyRange),this._createTransaction=function(y,T,x,O){return new a.Transaction(y,T,x,a._options.chromeTransactionDurability,O)},this._fireOnBlocked=function(y){a.on("blocked").fire(y),Tn.filter(function(T){return T.name===a.name&&T!==a&&!T._state.vcFired}).map(function(T){return T.on("versionchange").fire(y)})},this.use(Hc),this.use(Qc),this.use(Xc),this.use(qc),this.use(Gc);var E=new Proxy(this,{get:function(y,T,x){if(T==="_vip")return!0;if(T==="table")return function(A){return di(a.table(A),E)};var O=Reflect.get(y,T,x);return O instanceof Jo?di(O,E):T==="tables"?O.map(function(A){return di(A,E)}):T==="_createTransaction"?function(){return di(O.apply(this,arguments),E)}:O}});this.vip=E,c.forEach(function(y){return y(a)})}var pi,Vt=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",Jc=(Ws.prototype.subscribe=function(i,s,a){return this._subscribe(i&&typeof i!="function"?i:{next:i,error:s,complete:a})},Ws.prototype[Vt]=function(){return this},Ws);function Ws(i){this._subscribe=i}try{pi={indexedDB:u.indexedDB||u.mozIndexedDB||u.webkitIndexedDB||u.msIndexedDB,IDBKeyRange:u.IDBKeyRange||u.webkitIDBKeyRange}}catch{pi={indexedDB:null,IDBKeyRange:null}}function _a(i){var s,a=!1,c=new Jc(function(h){var d=ls(i),v,g=!1,b={},w={},E={get closed(){return g},unsubscribe:function(){g||(g=!0,v&&v.abort(),y&&je.storagemutated.unsubscribe(x))}};h.start&&h.start(E);var y=!1,T=function(){return bs(O)},x=function(A){li(b,A),Ls(w,b)&&T()},O=function(){var A,C,M;!g&&pi.indexedDB&&(b={},A={},v&&v.abort(),v=new AbortController,M=(function(P){var k=An();try{d&&Cn();var D=Ie(i,P);return D=d?D.finally(De):D}finally{k&&En()}})(C={subscr:A,signal:v.signal,requery:T,querier:i,trans:null}),Promise.resolve(M).then(function(P){a=!0,s=P,g||C.signal.aborted||(b={},(function(k){for(var D in k)if(S(k,D))return;return 1})(w=A)||y||(je(pr,x),y=!0),bs(function(){return!g&&h.next&&h.next(P)}))},function(P){a=!1,["DatabaseClosedError","AbortError"].includes(P?.name)||g||bs(function(){g||h.error&&h.error(P)})}))};return setTimeout(T,0),E});return c.hasValue=function(){return a},c.getValue=function(){return s},c}var rn=_e;function Vs(i){var s=$e;try{$e=!0,je.storagemutated.fire(i),Ns(i,!0)}finally{$e=s}}R(rn,r(r({},Kr),{delete:function(i){return new rn(i,{addons:[]}).delete()},exists:function(i){return new rn(i,{addons:[]}).open().then(function(s){return s.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(i){try{return s=rn.dependencies,a=s.indexedDB,s=s.IDBKeyRange,(Is(a)?Promise.resolve(a.databases()).then(function(c){return c.map(function(h){return h.name}).filter(function(h){return h!==Qr})}):ks(a,s).toCollection().primaryKeys()).then(i)}catch{return wt(new Z.MissingAPI)}var s,a},defineClass:function(){return function(i){p(this,i)}},ignoreTransaction:function(i){return X.trans?Je(X.transless,i):i()},vip:Ds,async:function(i){return function(){try{var s=Us(i.apply(this,arguments));return s&&typeof s.then=="function"?s:q.resolve(s)}catch(a){return wt(a)}}},spawn:function(i,s,a){try{var c=Us(i.apply(a,s||[]));return c&&typeof c.then=="function"?c:q.resolve(c)}catch(h){return wt(h)}},currentTransaction:{get:function(){return X.trans||null}},waitFor:function(i,s){return s=q.resolve(typeof i=="function"?rn.ignoreTransaction(i):i).timeout(s||6e4),X.trans?X.trans.waitFor(s):s},Promise:q,debug:{get:function(){return se},set:function(i){Uo(i)}},derive:V,extend:p,props:R,override:Q,Events:hr,on:je,liveQuery:_a,extendObservabilitySet:li,getByKeyPath:Et,setByKeyPath:yt,delByKeyPath:function(i,s){typeof s=="string"?yt(i,s,void 0):"length"in s&&[].map.call(s,function(a){yt(i,a,void 0)})},shallowClone:Fr,deepClone:ve,getObjectDiff:Fs,cmp:at,asap:At,minKey:-1/0,addons:[],connections:Tn,errnames:hs,dependencies:pi,cache:nn,semVer:"4.2.1",version:"4.2.1".split(".").map(function(i){return parseInt(i)}).reduce(function(i,s,a){return i+s/Math.pow(10,2*a)})})),rn.maxKey=vr(rn.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(je(pr,function(i){$e||(i=new CustomEvent(As,{detail:i}),$e=!0,dispatchEvent(i),$e=!1)}),addEventListener(As,function(i){i=i.detail,$e||Vs(i)}));var kn,$e=!1,ba=function(){};return typeof BroadcastChannel<"u"&&((ba=function(){(kn=new BroadcastChannel(As)).onmessage=function(i){return i.data&&Vs(i.data)}})(),typeof kn.unref=="function"&&kn.unref(),je(pr,function(i){$e||kn.postMessage(i)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(i){if(!_e.disableBfCache&&i.persisted){se&&console.debug("Dexie: handling persisted pagehide"),kn?.close();for(var s=0,a=Tn;s<a.length;s++)a[s].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(i){!_e.disableBfCache&&i.persisted&&(se&&console.debug("Dexie: handling persisted pageshow"),ba(),Vs({all:new It(-1/0,[[]])}))})),q.rejectionMapper=function(i,s){return!i||i instanceof Sn||i instanceof TypeError||i instanceof SyntaxError||!i.name||!No[i.name]?i:(s=new No[i.name](s||i.message,i),"stack"in i&&j(s,"stack",{get:function(){return this.inner.stack}}),s)},Uo(se),r(_e,Object.freeze({__proto__:null,Dexie:_e,liveQuery:_a,Entity:Ho,cmp:at,PropModification:lr,replacePrefix:function(i,s){return new lr({replacePrefix:[i,s]})},add:function(i){return new lr({add:i})},remove:function(i){return new lr({remove:i})},default:_e,RangeSet:It,mergeRanges:yr,rangesOverlap:ca}),{default:_e}),_e})})(Ei)),Ei.exports}var pd=dd();const bo=yc(pd),uu=Symbol.for("Dexie"),Yt=globalThis[uu]||(globalThis[uu]=bo);if(bo.semVer!==Yt.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${bo.semVer} and ${Yt.semVer}`);const{liveQuery:$d,mergeRanges:Nd,rangesOverlap:Ud,RangeSet:Fd,cmp:zd,Entity:Kd,PropModification:Wd,replacePrefix:Vd,add:qd,remove:Gd,DexieYProvider:Hd}=Yt,Rt=[];for(let n=0;n<256;++n)Rt.push((n+256).toString(16).slice(1));function vd(n,t=0){return(Rt[n[t+0]]+Rt[n[t+1]]+Rt[n[t+2]]+Rt[n[t+3]]+"-"+Rt[n[t+4]]+Rt[n[t+5]]+"-"+Rt[n[t+6]]+Rt[n[t+7]]+"-"+Rt[n[t+8]]+Rt[n[t+9]]+"-"+Rt[n[t+10]]+Rt[n[t+11]]+Rt[n[t+12]]+Rt[n[t+13]]+Rt[n[t+14]]+Rt[n[t+15]]).toLowerCase()}let eo;const md=new Uint8Array(16);function gd(){if(!eo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");eo=crypto.getRandomValues.bind(crypto)}return eo(md)}const yd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),cu={randomUUID:yd};function _d(n,t,e){n=n||{};const r=n.random??n.rng?.()??gd();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,vd(r)}function bd(n,t,e){return cu.randomUUID&&!n?cu.randomUUID():_d(n)}function _c(n){n.Version.prototype._parseStoresSpec=Yt.override(n.Version.prototype._parseStoresSpec,wd),n.open=Yt.override(n.open,Sd(n))}function wd(n){return function(t,e){n.call(this,t,e),Object.keys(e).forEach(function(r){let o=e[r];o.primKey.name.indexOf("$$")===0&&(o.primKey.uuid=!0,o.primKey.name=o.primKey.name.substr(2),o.primKey.keyPath=o.primKey.keyPath.substr(2))})}}function xd(n){return function(e,r){let o;return e===void 0&&n.schema.primKey.uuid&&(e=o=bd(),n.schema.primKey.keyPath&&Yt.setByKeyPath(r,n.schema.primKey.keyPath,e)),o}}function Sd(n){return function(e){return function(){return Object.keys(n._allTables).forEach(r=>{let o=n._allTables[r];o.hook("creating").subscribe(xd(o))}),e.apply(this,arguments)}}}Yt.UUIDPrimaryKey=_c;Yt.addons.push(_c);Yt.UUIDPrimaryKey;const Od={files:"$$id, mimetype, created, lastRetrieved"},lu={MAX_IMAGE_ENTRIES:1e3};class bi extends cd{constructor(){super(),this.dbQueue=new fu,this.cache=new Map,this.CACHE_LIMIT=500,this.dbQueue=new fu,this.dbPromise=this.initDb()}async initDb(){return Ne(async()=>{let t=new Yt("InfiniteCanvas");return Yt.UUIDPrimaryKey(t),t.version(1).stores(Od),await t.open(),t})}async getIndexDb(){return this.dbPromise}async write(t){const e=await Lo.create(t),r=Cd(e.dataURL);return this.dbQueue.add(()=>Ne(async()=>{const o=await this.getIndexDb();return await o.transaction("rw",o.files,async()=>(await Ed(o),await o.files.add({id:e.id,blob:r,dataURL:e.dataURL,mimetype:e.mimetype,created:e.created,lastRetrieved:e.lastRetrieved}))).catch(u=>{throw console.error("Failed to save image blob to local DB:",u),u})}))}async readAll(){return Ne(async()=>await(await this.getIndexDb()).files.toArray())}async readPage(t,e){return Ne(async()=>await(await this.getIndexDb()).files.offset(t).limit(e).toArray())}async read(t){return Ne(async()=>{const e=await this.getIndexDb();if(this.cache.has(t))return this.cache.get(t);const r=await e.files.get(t);if(!r)return null;if(this.dbQueue.add(async()=>{try{await e.files.update(t,{lastRetrieved:Date.now()})}catch(o){console.error("Failed to update lastRetrieved",o)}}).catch(()=>{}),this.cache.set(t,r),this.cache.size>this.CACHE_LIMIT){const o=this.cache.keys().next().value;this.cache.delete(o)}return r})}async delete(t){return this.dbQueue.add(()=>Ne(async()=>{const e=await this.getIndexDb();return await e.transaction("rw",e.files,async()=>{const r=await e.files.where("id").equals(t).first();return await e.files.delete(r.id),r}).catch(r=>{throw console.error("Failed to save image blob to local DB:",r),r})}))}async update(t){return this.dbQueue.add(()=>Ne(async()=>{const e=await this.getIndexDb();return await e.transaction("rw",e.files,async()=>{await e.files.update(t.id,{dataURL:t.dataURL,mimetype:t.mimetype,lastRetrieved:Date.now()})}),await e.files.where("id").equals(t.id).first()}))}async checkIfImageStored(t){return Ne(async()=>{const r=await(await this.getIndexDb()).files.where("id").equals(t).first();return r?r.id:null})}}class no extends ld{constructor(t){super(),this.key="infinite_canvas",this.key=t}async write(t){return new Promise((e,r)=>{try{localStorage.setItem(this.key,JSON.stringify(t)),e()}catch(o){r(o)}})}async read(){return new Promise((t,e)=>{try{t(localStorage.getItem(this.key))}catch(r){e(r)}})}async delete(){return new Promise((t,e)=>{try{localStorage.removeItem(this.key),t()}catch(r){e(r)}})}async update(t){return this.write(t)}}class hu extends Error{constructor(t){super(t),this.name="QuotaExceededError"}}class Ad extends Error{constructor(t){super(t),this.name="DatabaseLimitError"}}class fu{constructor(){this.queue=Promise.resolve()}async add(t){const e=this.queue.then(()=>t());return this.queue=e.catch(()=>{}),e}}const Ne=async n=>{try{return await n()}catch(t){throw t instanceof DOMException&&t.name==="QuotaExceededError"?new hu("Storage quota exceeded. Please free up space."):t instanceof Yt.QuotaExceededError?new hu("Database quota exceeded. Please free up space."):t}};async function Ed(n){if(await n.files.count()>=lu.MAX_IMAGE_ENTRIES)throw new Ad(`Cannot save image: limit of ${lu.MAX_IMAGE_ENTRIES} reached`)}function Cd(n){const t=n.split(","),e=t[0],r=t[1],o=e.match(/:(.*?);/),u=o?o[1]:"application/octet-stream",l=atob(r),f=l.length,p=new Uint8Array(f);for(let m=0;m<f;m++)p[m]=l.charCodeAt(m);return new Blob([p],{type:u})}var ro={exports:{}},du;function Td(){return du||(du=1,(function(n){var t=Object.prototype.hasOwnProperty,e="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(e=!1));function o(p,m,_){this.fn=p,this.context=m,this.once=_||!1}function u(p,m,_,S,R){if(typeof _!="function")throw new TypeError("The listener must be a function");var I=new o(_,S||p,R),j=e?e+m:m;return p._events[j]?p._events[j].fn?p._events[j]=[p._events[j],I]:p._events[j].push(I):(p._events[j]=I,p._eventsCount++),p}function l(p,m){--p._eventsCount===0?p._events=new r:delete p._events[m]}function f(){this._events=new r,this._eventsCount=0}f.prototype.eventNames=function(){var m=[],_,S;if(this._eventsCount===0)return m;for(S in _=this._events)t.call(_,S)&&m.push(e?S.slice(1):S);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(_)):m},f.prototype.listeners=function(m){var _=e?e+m:m,S=this._events[_];if(!S)return[];if(S.fn)return[S.fn];for(var R=0,I=S.length,j=new Array(I);R<I;R++)j[R]=S[R].fn;return j},f.prototype.listenerCount=function(m){var _=e?e+m:m,S=this._events[_];return S?S.fn?1:S.length:0},f.prototype.emit=function(m,_,S,R,I,j){var V=e?e+m:m;if(!this._events[V])return!1;var W=this._events[V],tt=arguments.length,ot,Q;if(W.fn){switch(W.once&&this.removeListener(m,W.fn,void 0,!0),tt){case 1:return W.fn.call(W.context),!0;case 2:return W.fn.call(W.context,_),!0;case 3:return W.fn.call(W.context,_,S),!0;case 4:return W.fn.call(W.context,_,S,R),!0;case 5:return W.fn.call(W.context,_,S,R,I),!0;case 6:return W.fn.call(W.context,_,S,R,I,j),!0}for(Q=1,ot=new Array(tt-1);Q<tt;Q++)ot[Q-1]=arguments[Q];W.fn.apply(W.context,ot)}else{var et=W.length,At;for(Q=0;Q<et;Q++)switch(W[Q].once&&this.removeListener(m,W[Q].fn,void 0,!0),tt){case 1:W[Q].fn.call(W[Q].context);break;case 2:W[Q].fn.call(W[Q].context,_);break;case 3:W[Q].fn.call(W[Q].context,_,S);break;case 4:W[Q].fn.call(W[Q].context,_,S,R);break;default:if(!ot)for(At=1,ot=new Array(tt-1);At<tt;At++)ot[At-1]=arguments[At];W[Q].fn.apply(W[Q].context,ot)}}return!0},f.prototype.on=function(m,_,S){return u(this,m,_,S,!1)},f.prototype.once=function(m,_,S){return u(this,m,_,S,!0)},f.prototype.removeListener=function(m,_,S,R){var I=e?e+m:m;if(!this._events[I])return this;if(!_)return l(this,I),this;var j=this._events[I];if(j.fn)j.fn===_&&(!R||j.once)&&(!S||j.context===S)&&l(this,I);else{for(var V=0,W=[],tt=j.length;V<tt;V++)(j[V].fn!==_||R&&!j[V].once||S&&j[V].context!==S)&&W.push(j[V]);W.length?this._events[I]=W.length===1?W[0]:W:l(this,I)}return this},f.prototype.removeAllListeners=function(m){var _;return m?(_=e?e+m:m,this._events[_]&&l(this,_)):(this._events=new r,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=e,f.EventEmitter=f,n.exports=f})(ro)),ro.exports}var Md=Td();const Pd=yc(Md);class Rd{get el(){return this._el}constructor(t){this.type=t.type,this.message=t.message,this._el=document.createElement("div"),this._el.classList.add("canvas-loader"),this.render()}render(){if(this._el.innerHTML="",this.type==="spinner"){const t=document.createElement("div");if(t.classList.add("canvas-loader-spinner"),this._el.appendChild(t),this.message){const e=document.createElement("div");e.classList.add("canvas-loader-message"),e.textContent=this.message,this._el.appendChild(e)}}else if(this.type==="message"){const t=document.createElement("div");t.classList.add("canvas-loader-message"),t.textContent=this.message??"",this._el.appendChild(t)}}setMessage(t){this.message=t,this.render()}setProgress(t){this.progress=t,this.render()}attachToParent(t){t.appendChild(this.el)}remove(){this._el.parentNode&&this._el.parentNode.removeChild(this._el)}}function kd(n,t){const e=new Rd({type:n,message:t});e.attachToParent(this.renderRoot);const r=this.getBoundingClientRect();return e.el.style.width=`${r.right}px`,e.el.style.height=`${r.bottom}px`,e._el.style.top=`${-r.bottom}px`,e}function Id(){const n=this.renderRoot.querySelector(".canvas-loader");n&&n.remove()}var Dd=Object.getOwnPropertyDescriptor,bc=n=>{throw TypeError(n)},Bd=(n,t,e,r)=>{for(var o=r>1?void 0:r?Dd(t,e):t,u=n.length-1,l;u>=0;u--)(l=n[u])&&(o=l(o)||o);return o},wc=(n,t,e)=>t.has(n)||bc("Cannot "+e),B=(n,t,e)=>(wc(n,t,"read from private field"),e?e.call(n):t.get(n)),Nt=(n,t,e)=>t.has(n)?bc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),_t=(n,t,e,r)=>(wc(n,t,"write to private field"),t.set(n,e),e),Y,St,Ci,Ue,Lt,Qt,wr,Ti,xr,Sr,be,$n,Mi,Pi,Ri;let Wi=class extends Mr{constructor(){super(...arguments),this.name="Reffy",this.displayMode="fullscreen",Nt(this,Y),Nt(this,St),Nt(this,Ci),Nt(this,Ue),Nt(this,Lt),Nt(this,Qt),Nt(this,wr,3e5),Nt(this,Ti),Nt(this,xr),Nt(this,Sr),Nt(this,be),Nt(this,$n),Nt(this,Mi),Nt(this,Pi),Nt(this,Ri),this.handleGlobalPointerDown=n=>{!this.contains(n.target)&&!this.renderRoot.contains(n.target)&&this.clearContextMenu()}}get singleImageMenuOptions(){return B(this,Mi)}get multiImageMenuOptions(){return B(this,Pi)}get canvasImageMenuOptions(){return B(this,Ri)}get canvas(){return B(this,Y)}get onCanvasChange(){return B(this,$n)}set onCanvasChange(n){_t(this,$n,n)}get eventHub(){return B(this,St)}get rootDiv(){return B(this,be)}connectedCallback(){super.connectedCallback(),this.handleGlobalPointerDown=this.handleGlobalPointerDown.bind(this),document.addEventListener("pointerdown",this.handleGlobalPointerDown,!0)}disconnectedCallback(){document.removeEventListener("pointerdown",this.handleGlobalPointerDown,!0),window.removeEventListener("resize",B(this,Sr)),B(this,Ci)?.disconnect(),_t(this,Ci,void 0),B(this,Y).destroy(),super.disconnectedCallback()}firstUpdated(n){try{this.initCanvas()}catch(t){throw console.error(t),t}}updated(n){if(!(n.has("width")||n.has("height")||n.has("displayMode")))return;const e=B(this,be),r=this.renderRoot.querySelector("canvas");e&&r&&this.resizeCanvas(e,r)}async initCanvas(){await this.warmUpStorage(),_t(this,Ue,new Mf),_t(this,St,new Pd);const n=document.createElement("div");n.style.overflow="hidden",this.renderRoot.appendChild(n),_t(this,be,n);const t=document.createElement("canvas");this.assignFileStorage=this.assignFileStorage.bind(this),this.getImageFileMetadata=this.getImageFileMetadata.bind(this),this.getAllImageFileMetdata=this.getAllImageFileMetdata.bind(this),this.saveImageFileMetadata=this.saveImageFileMetadata.bind(this),this.restoreStateFromCanvasStorage=this.restoreStateFromCanvasStorage.bind(this),this.assignCanvasStorage=this.assignCanvasStorage.bind(this),this.saveToCanvasStorage=this.saveToCanvasStorage.bind(this),this.debounceSaveToCanvasStorage=this.debounceSaveToCanvasStorage.bind(this),this.importCanvas=this.importCanvas.bind(this),this.exportCanvas=this.exportCanvas.bind(this),this.addContextMenu=nd.bind(this),this.clearContextMenu=rd.bind(this),this.isContextMenuActive=id.bind(this),this.getContainerSize=this.getContainerSize.bind(this),n.contains(t)||n.appendChild(t),this.registerSignal(),_t(this,Y,new zi(t,B(this,Ue),B(this,St),this.debounceSaveToCanvasStorage,this.saveImageFileMetadata,this.getContainerSize));try{await this.restoreStateFromCanvasStorage()}catch{console.error("Failed to restore canvas")}this.resizeCanvas(n,t),_t(this,Sr,()=>this.resizeCanvas(n,t)),window.addEventListener("resize",B(this,Sr));const e=sd.bind(this)();_t(this,Mi,od.bind(this)(e.options)),_t(this,Ri,ud.bind(this)()),_t(this,Pi,ad.bind(this)(e.options)),this.dispatchEvent(new Event("load"));const r=async()=>{B(this,Y).render(),requestAnimationFrame(r)};r()}normalizeCssSize(n){if(!n)return n;const t=String(n).trim();return/^\d+$/.test(t)?`${t}px`:t}resizeCanvas(n,t){n.style.width=this.displayMode==="fullscreen"?"100vw":this.normalizeCssSize(this.width),n.style.height=this.displayMode==="fullscreen"?"100vh":this.normalizeCssSize(this.height),n.style.overflow="hidden";const e=window.devicePixelRatio||1;let r=window.screen.width,o=window.screen.height;const u=n.getBoundingClientRect(),l=Math.round(r*e),f=Math.round(o*e);(t.width!==l||t.height!==f)&&(t.width=l,t.height=f),t.style.width=`${r}px`,t.style.height=`${o}px`,this.canvas.camera.viewportX=u.x,this.canvas.camera.viewportY=u.y,this.canvas.camera.state.setHeight(u.height),this.canvas.camera.state.setWidth(u.width)}registerSignal(){B(this,St).on(In.start,kd.bind(this),"spinner"),B(this,St).on(In.done,Id.bind(this)),B(this,St).on(Oe.Open,this.addContextMenu),B(this,St).on(Oe.Close,this.clearContextMenu),B(this,St).on(Ae.Change,()=>{B(this,$n)&&B(this,$n).call(this)}),B(this,St).on(Dn.Save,this.saveToCanvasStorage),B(this,St).on(Dn.SaveCompleted,()=>{}),B(this,St).on(Dn.SaveFailed,()=>console.error("Failed to Save!"))}async warmUpStorage(){B(this,Lt)||_t(this,Lt,new bi);try{await B(this,Lt).readAll()}catch(n){console.error("Storage warm-up failed",n)}}getContainerSize(){if(!B(this,be))return;const n=B(this,be).getBoundingClientRect();return[n.width,n.height]}assignCanvasStorage(n,t=B(this,wr)){_t(this,Qt,n),_t(this,wr,t),B(this,xr)&&clearInterval(B(this,xr)),_t(this,xr,setInterval(this.saveToCanvasStorage,B(this,wr)))}assignFileStorage(n){_t(this,Lt,n)}async saveImageFileMetadata(n){B(this,Lt)||_t(this,Lt,new bi);try{const t=await xo(n);return await B(this,Lt).checkIfImageStored(t)?t:await B(this,Lt).write(n)}catch(t){console.error(t)}}async getImageFileMetadata(n){B(this,Lt)||_t(this,Lt,new bi);try{return await B(this,Lt).read(n)}catch(t){console.error(t)}}async getAllImageFileMetdata(){B(this,Lt)||_t(this,Lt,new bi);try{return await B(this,Lt).readAll()}catch(n){console.error(n)}}debounceSaveToCanvasStorage(n=1e3){B(this,Qt)||_t(this,Qt,new no(this.name)),clearTimeout(B(this,Ti)),_t(this,Ti,setTimeout(this.saveToCanvasStorage,n))}async saveToCanvasStorage(){B(this,Qt)||_t(this,Qt,new no(this.name)),B(this,Qt).write(go(B(this,Y))).then(()=>B(this,St).emit(Dn.SaveCompleted)).catch(()=>B(this,St).emit(Dn.SaveFailed))}async restoreStateFromCanvasStorage(){B(this,Qt)||_t(this,Qt,new no(this.name));const n=await B(this,Qt).read(),t=JSON.parse(n);t&&await yo(t,B(this,Y),this.getImageFileMetadata)}togglePointerMode(){B(this,Y)&&B(this,Y).changeMode()}toggleGrid(){B(this,Y)&&B(this,Y).toggleGrid()}zoomIn(){B(this,Y)&&B(this,Y).updateZoomByFixedAmount(-1)}zoomOut(){B(this,Y)&&B(this,Y).updateZoomByFixedAmount()}async addImages(n){if(!B(this,Y))return;const t=B(this,be).getBoundingClientRect(),e=t.left+t.width/2,r=t.top+t.height/2,[o,u]=an(e,r,B(this,Y)),l=await al(n,f=>B(this,Y).addImageToCanvas(f,o,u,1,1,!0));B(this,Ue).push(Di(B(this,Y),l))}async removeImage(n){if(!B(this,Y))return;const t=B(this,Y).getChild(n);B(this,Y).removeChild(t),B(this,Ue).push(hl(B(this,Y),t))}async addImageFromUrl(n){if(!B(this,Y))return;const t=B(this,be).getBoundingClientRect(),e=t.left+t.width/2,r=t.top+t.height/2,[o,u]=an(e,r,B(this,Y)),l=await B(this,Y).addImageToCanvas(n,o,u,1,1,!0);B(this,Ue).push(Di(B(this,Y),[l]))}async copyImage(){B(this,Y)&&await gu(B(this,Y).getSelected())}async pasteImage(n){B(this,Y)&&await yu(n.clientX,n.clientY,B(this,Y),B(this,Ue),!1)}flipVertical(){B(this,Y)&&B(this,Y).selectionManager.flip("vertical")}flipHorizontal(){B(this,Y)&&B(this,Y).selectionManager.flip("horizontal")}align(n){B(this,Y)&&B(this,Y).selectionManager.alignSelection(n)}normalizeSelection(n,t){B(this,Y)&&B(this,Y).selectionManager.normalize(n,t)}sendShapeToNewZOrder(n){B(this,Y)&&B(this,Y).setShapeZOrder(n)}deleteSelectedImages(){B(this,Y)&&B(this,Y).selectionManager.deleteSelected(B(this,Y))}async exportCanvas(n="infinite-canvas.json"){if(!B(this,Y))return;B(this,St).emit(In.start,"spinner");const t=await this.getAllImageFileMetdata(),e=go(B(this,Y),t);ul(n,e),B(this,St).emit(In.done)}async importCanvas(n){if(B(this,St).emit(In.start,"spinner"),!B(this,Y)||!n||n.length!==1)return;const t=n[0];if(!t.type||!t.type.includes("json")&&!t.name.toLowerCase().endsWith(".json"))return;const e=await cl(t);await yo(e,B(this,Y),this.getImageFileMetadata,this.saveImageFileMetadata),B(this,St).emit(Dn.Save),B(this,St).emit(In.done)}clearCanvas(){B(this,Y)&&B(this,Y).clearChildren()}getTotalNumberOfChildren(){if(B(this,Y))return B(this,Y).totalNumberOfChildren}getNumberOfChildrenRendered(){if(B(this,Y))return B(this,Y).numberOfChildrenRendered}};Y=new WeakMap;St=new WeakMap;Ci=new WeakMap;Ue=new WeakMap;Lt=new WeakMap;Qt=new WeakMap;wr=new WeakMap;Ti=new WeakMap;xr=new WeakMap;Sr=new WeakMap;be=new WeakMap;$n=new WeakMap;Mi=new WeakMap;Pi=new WeakMap;Ri=new WeakMap;Wi.properties={name:{type:String,reflect:!0},width:{type:String,reflect:!0},height:{type:String,reflect:!0},displayMode:{type:String,reflect:!0}};Wi.styles=Rf`
|
|
154
|
-
:host {
|
|
155
|
-
position: relative;
|
|
156
|
-
overflow: hidden;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.context-menu {
|
|
160
|
-
position: absolute;
|
|
161
|
-
background: white;
|
|
162
|
-
min-width: 180px;
|
|
163
|
-
background: var(--menu-bg, #fff);
|
|
164
|
-
border-radius: 6px;
|
|
165
|
-
border: 1px solid var(--menu-border, #9f9f9fff);
|
|
166
|
-
box-sizing: border-box;
|
|
167
|
-
padding: 6px 0;
|
|
168
|
-
display: flex;
|
|
169
|
-
gap: 2px;
|
|
170
|
-
flex-direction: column;
|
|
171
|
-
font-family: system-ui, sans-serif;
|
|
172
|
-
animation: fadeInMenu 0.13s cubic-bezier(0.4, 0, 0.2, 1);
|
|
173
|
-
overflow: scroll;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@keyframes fadeInMenu {
|
|
177
|
-
from {
|
|
178
|
-
opacity: 0;
|
|
179
|
-
transform: translateY(8px);
|
|
180
|
-
}
|
|
181
|
-
to {
|
|
182
|
-
opacity: 1;
|
|
183
|
-
transform: none;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.context-menu button {
|
|
188
|
-
all: unset;
|
|
189
|
-
display: flex;
|
|
190
|
-
align-items: center;
|
|
191
|
-
box-sizing: border-box;
|
|
192
|
-
width: 100%;
|
|
193
|
-
padding: 8px 18px;
|
|
194
|
-
font-size: 15px;
|
|
195
|
-
color: var(--menu-fg, #222);
|
|
196
|
-
background: none;
|
|
197
|
-
cursor: pointer;
|
|
198
|
-
transition:
|
|
199
|
-
background 0.1s,
|
|
200
|
-
color 0.1s;
|
|
201
|
-
user-select: none;
|
|
202
|
-
outline: none;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
.context-menu button:hover,
|
|
206
|
-
.context-menu button:focus-visible {
|
|
207
|
-
background: var(--menu-hover, #c7d5eaff);
|
|
208
|
-
color: var(--menu-accent, #155290ff);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.context-menu button:active {
|
|
212
|
-
background: var(--menu-active, #e3eaf3);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.context-menu button[disabled] {
|
|
216
|
-
color: #aaa;
|
|
217
|
-
cursor: not-allowed;
|
|
218
|
-
background: none;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.context-menu-divider {
|
|
222
|
-
height: 1px;
|
|
223
|
-
background: var(--menu-divider, #c7d5eaff);
|
|
224
|
-
margin: 6px 12px;
|
|
225
|
-
border: none;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
canvas {
|
|
229
|
-
width: 100%;
|
|
230
|
-
height: 100%;
|
|
231
|
-
outline: none;
|
|
232
|
-
padding: 0;
|
|
233
|
-
margin: 0;
|
|
234
|
-
touch-action: none;
|
|
235
|
-
display: block;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.canvas-loader {
|
|
239
|
-
position: absolute;
|
|
240
|
-
top: 0;
|
|
241
|
-
left: 0;
|
|
242
|
-
display: flex;
|
|
243
|
-
flex-direction: column;
|
|
244
|
-
align-items: center;
|
|
245
|
-
justify-content: center;
|
|
246
|
-
background: rgba(255, 255, 255, 0.7);
|
|
247
|
-
z-index: 1000;
|
|
248
|
-
pointer-events: all;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.canvas-loader-spinner {
|
|
252
|
-
width: 48px;
|
|
253
|
-
height: 48px;
|
|
254
|
-
border: 6px solid #e0e0e0;
|
|
255
|
-
border-top: 6px solid #1976d2;
|
|
256
|
-
border-radius: 50%;
|
|
257
|
-
animation: canvas-loader-spin 1s linear infinite;
|
|
258
|
-
margin-bottom: 16px;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
@keyframes canvas-loader-spin {
|
|
262
|
-
0% {
|
|
263
|
-
transform: rotate(0deg);
|
|
264
|
-
}
|
|
265
|
-
100% {
|
|
266
|
-
transform: rotate(360deg);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.canvas-loader-message {
|
|
271
|
-
font-size: 1.1rem;
|
|
272
|
-
color: #333;
|
|
273
|
-
background: rgba(255, 255, 255, 0.9);
|
|
274
|
-
padding: 8px 16px;
|
|
275
|
-
border-radius: 4px;
|
|
276
|
-
margin-top: 8px;
|
|
277
|
-
text-align: center;
|
|
278
|
-
max-width: 80%;
|
|
279
|
-
word-break: break-word;
|
|
280
|
-
}
|
|
281
|
-
`;Wi=Bd([Qf("infinite-canvas")],Wi);class jo{constructor(t){if(!t)throw new Error("InfiniteCanvasElement is required");this.el=t,this.assignCanvasStorage=this.assignCanvasStorage.bind(this),this.zoomIn=this.zoomIn.bind(this),this.zoomOut=this.zoomOut.bind(this),this.toggleMode=this.toggleMode.bind(this),this.addImageFromLocal=this.addImageFromLocal.bind(this),this.exportCanvas=this.exportCanvas.bind(this),this.importCanvas=this.importCanvas.bind(this),this.clearCanvas=this.clearCanvas.bind(this)}static async forElement(t){let e;if(typeof t=="string"?(await customElements.whenDefined("infinite-canvas"),e=document.querySelector(t)):e=t,!e)throw new Error("infinite-canvas element not found");return e.canvas||await new Promise(r=>e.addEventListener("load",()=>r(),{once:!0})),new jo(e)}assignCanvasStorage(t,e=3e3){return this.el.assignCanvasStorage(t,e),this}async zoomIn(){console.log("zooming"),this.el.zoomIn()}async zoomOut(){this.el.zoomOut()}async toggleMode(){this.el.togglePointerMode()}async addImageFromLocal(t){if(!(!t||t.length===0)){for(let e=0;e<t.length;e++){const r=t[e];if(!r||!r.type||!r.type.startsWith("image/"))throw new Error("Only specific image files are supported. Please select image files only.")}await this.el.addImages(t)}}async exportCanvas(t){this.el.exportCanvas(t)}async importCanvas(t){!t||t.length!==1||await this.el.importCanvas(t)}async clearCanvas(){this.el.clearCanvas()}}const pu=document.querySelector("#canvas");jo.forElement(pu).then(n=>{const t={"mode-button":n.toggleMode.bind(n),"zoom-in-button":n.zoomIn.bind(n),"zoom-out-button":n.zoomOut.bind(n),"export-canvas-button":n.exportCanvas.bind(n),"clear-canvas-button":n.clearCanvas.bind(n)};for(const[l,f]of Object.entries(t)){const p=document.getElementById(l);p.onclick=()=>f()}const e=document.getElementById("add-image-input"),r=document.getElementById("add-image-btn");r.onclick=()=>e.click(),e.onchange=async()=>{!e.files||e.files.length===0||(await n.addImageFromLocal(e.files),e.value="")};const o=document.getElementById("import-canvas-input"),u=document.getElementById("import-canvas-button");u.onclick=()=>o.click(),o.onchange=async()=>{!o.files||o.files.length===0||o.files.length>1||(await n.importCanvas(o.files),e.value="")},pu.onCanvasChange=()=>console.log("data changed")});
|