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MAAA,CAAO,EAAA,EAAI,MAAM,MAAM,CAAA;AACtD,MAAA,OAAO;AAAA,QACL,OAAO,IAAA,EAAM;AACX,UAAA,MAAA,EAAO;AACP,UAAA,MAAA,GAAS,MAAA,CAAO,UAAA,CAAW,IAAA,CAAK,EAAA,EAAI,MAAM,IAAI,CAAA;AAAA,QAChD,CAAA;AAAA,QACA,OAAA,GAAU;AACR,UAAA,MAAA,EAAO;AAAA,QACT;AAAA,OACF;AAAA,IACF;AAAA,GACF;AACF","file":"svelte.cjs","sourcesContent":["import { createWindowManager } from '../core/manager'\nimport type { ManagerOptions, ManagerState, WindowManager, WindowState } from '../core/types'\nimport { createDesktopBinder, type DesktopBinder } from '../dom/binder'\nimport type { DesktopOptions, WindowAttachOptions } from '../dom/shared'\n\nexport interface ReadableStore {\n subscribe(run: (value: T) => void): () => void\n}\n\nexport interface ActionResult {\n update?(params: WindowActionParams): void\n destroy(): void\n}\n\nexport interface WindowActionParams extends WindowAttachOptions {\n id: string\n}\n\nexport function createManager(options?: ManagerOptions): WindowManager {\n return createWindowManager(options)\n}\n\nexport function wmStore(wm: WindowManager): ReadableStore {\n return {\n subscribe(run) {\n run(wm.getState())\n return wm.subscribe(run)\n },\n }\n}\n\nexport function wmWindowStore(\n wm: WindowManager,\n id: string,\n): ReadableStore {\n return {\n subscribe(run) {\n run(wm.get(id))\n let last = wm.get(id)\n return wm.subscribe(() => {\n const next = wm.get(id)\n if (next !== last) {\n last = next\n run(next)\n }\n })\n },\n }\n}\n\nexport interface SvelteDesktop {\n binder: DesktopBinder\n desktop(node: HTMLElement): ActionResult\n window(node: HTMLElement, params: WindowActionParams): ActionResult\n}\n\nexport function createDesktop(wm: WindowManager, options?: DesktopOptions): SvelteDesktop {\n const binder = createDesktopBinder(wm, options)\n return {\n binder,\n desktop(node) {\n const unbind = binder.bindDesktop(node)\n return { destroy: unbind }\n },\n window(node, params) {\n let unbind = binder.bindWindow(params.id, node, params)\n return {\n update(next) {\n unbind()\n unbind = binder.bindWindow(next.id, node, next)\n },\n destroy() {\n unbind()\n },\n }\n },\n }\n}\n"]}