tauri-notice-window 1.0.18 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,25 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import type { MessageType } from '../types/message';
3
3
  /**
4
- * Props for NoticeLayout component
4
+ * Context provided to all children of NoticeLayout.
5
+ * windowReady is false during the measurement phase (before auto-sizing),
6
+ * and true once the window has been sized and is visible.
7
+ *
8
+ * Consumers should remove viewport-filling constraints (e.g. h-screen, flex-1)
9
+ * when windowReady is false so content can render at its natural height for measurement.
5
10
  */
11
+ interface NoticeWindowContextType {
12
+ windowReady: boolean;
13
+ }
14
+ /**
15
+ * Hook for notice window pages to know whether the window has been sized and is visible.
16
+ * Use this to conditionally apply h-screen / flex-1 only after the window is ready.
17
+ *
18
+ * @example
19
+ * const { windowReady } = useNoticeWindowContext()
20
+ * <div className={`flex flex-col ${windowReady ? 'h-screen' : ''}`}>
21
+ */
22
+ export declare const useNoticeWindowContext: () => NoticeWindowContextType;
6
23
  interface NoticeLayoutProps {
7
24
  children: (message: MessageType) => ReactNode;
8
25
  onLoad?: (message: MessageType) => void;
@@ -10,8 +27,16 @@ interface NoticeLayoutProps {
10
27
  }
11
28
  /**
12
29
  * Layout component for notice windows.
13
- * Loads the message from database/URL and provides it to children.
14
- * When autoSize is enabled, measures rendered content then resizes the window to fit.
30
+ * Loads the message from database/URL and provides it to children via render prop.
31
+ *
32
+ * When autoSize is enabled (default: true):
33
+ * - Window is created hidden (visible: false)
34
+ * - windowReady starts as false — children should NOT use h-screen/flex-1 during this phase
35
+ * - After content renders at natural height, the container is measured
36
+ * - Window is resized to fit, repositioned, then shown
37
+ * - windowReady becomes true — children should apply h-screen/flex-1 to fill the window
38
+ *
39
+ * Use useNoticeWindowContext() in child components to read windowReady.
15
40
  */
16
41
  export declare const NoticeLayout: ({ children, onLoad, onClose }: NoticeLayoutProps) => import("react/jsx-runtime").JSX.Element;
17
42
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"NoticeLayout.d.ts","sourceRoot":"","sources":["../../src/components/NoticeLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AA2CnD;;GAEG;AACH,UAAU,iBAAiB;IACzB,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAA;IAC7C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;IACvC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;CACzC;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,+BAA+B,iBAAiB,4CA6L5E,CAAA"}
1
+ {"version":3,"file":"NoticeLayout.d.ts","sourceRoot":"","sources":["../../src/components/NoticeLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC9F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAOnD;;;;;;;GAOG;AACH,UAAU,uBAAuB;IAC/B,WAAW,EAAE,OAAO,CAAA;CACrB;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,QAAO,uBAA0D,CAAA;AAkCpG,UAAU,iBAAiB;IACzB,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAA;IAC7C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;IACvC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;CACzC;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,+BAA+B,iBAAiB,4CA0N5E,CAAA"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ve=require("zustand"),Se=require("zustand-sync"),We=require("dexie"),d=require("react"),T=require("react/jsx-runtime"),ue="tauri-notice-config",ee={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300,notFoundUrl:"/404",defaultDecorations:!0,loadTimeout:4e3,autoSize:!0,maxWidth:600,maxHeight:800,autoSizeTimeout:3e3},ce=()=>{try{const t=localStorage.getItem(ue);if(t)return{...ee,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return ee},ze=t=>{try{localStorage.setItem(ue,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},Ne=t=>{const i={...ce(),...t};ze(i)},L=()=>ce();class Ae extends We{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let I=null;const G=()=>{if(!I){const t=L();I=new Ae(t.databaseName)}return I},p=()=>I||G(),Me=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await p().messages.put(e)},De=async t=>!!await p().messages.get(t),xe=async t=>{const e=await p().messages.get(t);return e?.isShown===!0||e?.queueStatus==="shown"},de=async()=>await p().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),Oe=async(t,e)=>{await p().messages.update(t,{queueStatus:e})},Pe=async t=>{await p().messages.update(t,{queueStatus:"shown",isShown:!0})},Ie=async t=>{await p().messages.update(t,{queueStatus:"hidden"})},V=async t=>await p().messages.get(t),ke=async t=>{await p().messages.delete(t)},Ce=async()=>{await p().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},Le=async t=>{const e=t.map(i=>p().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},Te=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await xe(i.id)){console.log(`Message ${i.id} was already shown, skipping`);return}if(await De(i.id)||await Me(i),!n.queue.some(g=>g.id===i.id)){const g=[...n.queue,i];t({queue:g}),await e().persistQueue()}!n.isProcessing&&!n.currentMessage&&await e().showNext()},dequeue:()=>{const i=e();if(i.queue.length===0)return null;const[n,...a]=i.queue;return t({queue:a}),n},showNext:async()=>{if(e().isProcessing)return;const n=e().dequeue();if(!n){t({isProcessing:!1,currentMessage:null});return}if(!await V(n.id)){console.log(`Message ${n.id} was deleted, skipping to next`),await e().showNext();return}t({currentMessage:n,isProcessing:!0}),await Oe(n.id,"showing"),await e().persistQueue()},clearCurrent:()=>{t({currentMessage:null,isProcessing:!1}),e().queue.length>0&&e().showNext()},setCurrentMessage:i=>{t({currentMessage:i})},setIsProcessing:i=>{t({isProcessing:i})},setQueue:i=>{t({queue:i})},initializeFromDatabase:async()=>{if(e().initialized)return;t({initialized:!0});const n=await de();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,o)=>({id:a.id,position:o}));await Le(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await Ce()},removeFromQueue:async i=>{const n=e(),a=n.queue.filter(o=>o.id!==i);t({queue:a}),await e().persistQueue(),n.currentMessage?.id===i&&e().clearCurrent()},deleteMessage:async i=>{await ke(i),await e().removeFromQueue(i)},hideMessage:async i=>{await Ie(i),await e().removeFromQueue(i)},markMessageAsShown:async i=>{await Pe(i)},addActiveWindow:i=>{const n=e(),a=String(i);n.activeWindowIds.includes(a)||t({activeWindowIds:[...n.activeWindowIds,a]})},removeActiveWindow:i=>{const n=e(),a=String(i);t({activeWindowIds:n.activeWindowIds.filter(o=>o!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),c=ve.create()(Se.syncTabs(Te,{name:"tauri-notice-queue"})),P={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},Re=()=>{const t=c(i=>i.enqueue);return{showNotice:d.useCallback(async i=>{await t(i)},[t])}};function Ee(t,e,i,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function qe(t,e,i,n,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}var R;const b="__TAURI_TO_IPC_KEY__";function Fe(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}class Be{get rid(){return Ee(this,R,"f")}constructor(e){R.set(this,void 0),qe(this,R,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}R=new WeakMap;class J{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new W(this.width*e,this.height*e)}[b](){return{width:this.width,height:this.height}}toJSON(){return this[b]()}}class W{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new J(this.width/e,this.height/e)}[b](){return{width:this.width,height:this.height}}toJSON(){return this[b]()}}class S{constructor(e){this.size=e}toLogical(e){return this.size instanceof J?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof W?this.size:this.size.toPhysical(e)}[b](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[b]()}}class Z{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new w(this.x*e,this.y*e)}[b](){return{x:this.x,y:this.y}}toJSON(){return this[b]()}}class w{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new Z(this.x/e,this.y/e)}[b](){return{x:this.x,y:this.y}}toJSON(){return this[b]()}}class A{constructor(e){this.position=e}toLogical(e){return this.position instanceof Z?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof w?this.position:this.position.toPhysical(e)}[b](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[b]()}}const te=Object.freeze(Object.defineProperty({__proto__:null,LogicalPosition:Z,LogicalSize:J,PhysicalPosition:w,PhysicalSize:W,Position:A,Size:S},Symbol.toStringTag,{value:"Module"}));var u;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(u||(u={}));async function we(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function q(t,e,i){var n;const a=typeof i?.target=="string"?{kind:"AnyLabel",label:i.target}:(n=i?.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:a,handler:Fe(e)}).then(o=>async()=>we(t,o))}async function Y(t,e,i){return q(t,n=>{we(t,n.id),e(n)},i)}async function he(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ge(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class k extends Be{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:E(e),width:i,height:n}).then(a=>new k(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:E(e)}).then(i=>new k(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new k(i))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}function E(t){return t==null?null:typeof t=="string"?t:t instanceof k?t.rid:t}var j;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(j||(j={}));class He{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var ie;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(ie||(ie={}));function ye(){return new F(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function U(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new F(e,{skip:!0})))}const Q=["tauri://created","tauri://error"];class F{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:window|create",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await U()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return ye()}static async getAll(){return U()}static async getFocusedWindow(){for(const e of await U())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:q(e,i,{target:{kind:"Window",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Y(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(Q.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return he(e,i)}async emitTo(e,i,n){if(Q.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ge(e,i,n)}_handleTauriEvent(e,i){return Q.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new w(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new w(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new W(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new W(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===j.Critical?i={type:"Critical"}:i={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:i})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof S?e:new S(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof S?e:e?new S(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof S?e:e?new S(e):null})}async setSizeConstraints(e){function i(n){return n?{Logical:n}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:i(e?.minWidth),minHeight:i(e?.minHeight),maxWidth:i(e?.maxWidth),maxHeight:i(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:E(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?E(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(u.WINDOW_RESIZED,i=>{i.payload=new W(i.payload),e(i)})}async onMoved(e){return this.listen(u.WINDOW_MOVED,i=>{i.payload=new w(i.payload),e(i)})}async onCloseRequested(e){return this.listen(u.WINDOW_CLOSE_REQUESTED,async i=>{const n=new He(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(u.DRAG_ENTER,r=>{e({...r,payload:{type:"enter",paths:r.payload.paths,position:new w(r.payload.position)}})}),n=await this.listen(u.DRAG_OVER,r=>{e({...r,payload:{type:"over",position:new w(r.payload.position)}})}),a=await this.listen(u.DRAG_DROP,r=>{e({...r,payload:{type:"drop",paths:r.payload.paths,position:new w(r.payload.position)}})}),o=await this.listen(u.DRAG_LEAVE,r=>{e({...r,payload:{type:"leave"}})});return()=>{i(),a(),n(),o()}}async onFocusChanged(e){const i=await this.listen(u.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(u.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(u.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(u.WINDOW_THEME_CHANGED,e)}}var ne;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(ne||(ne={}));var se;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(se||(se={}));var ae;(function(t){t.AppearanceBased="appearanceBased",t.Light="light",t.Dark="dark",t.MediumLight="mediumLight",t.UltraDark="ultraDark",t.Titlebar="titlebar",t.Selection="selection",t.Menu="menu",t.Popover="popover",t.Sidebar="sidebar",t.HeaderView="headerView",t.Sheet="sheet",t.WindowBackground="windowBackground",t.HudWindow="hudWindow",t.FullScreenUI="fullScreenUI",t.Tooltip="tooltip",t.ContentBackground="contentBackground",t.UnderWindowBackground="underWindowBackground",t.UnderPageBackground="underPageBackground",t.Mica="mica",t.Blur="blur",t.Acrylic="acrylic",t.Tabbed="tabbed",t.TabbedDark="tabbedDark",t.TabbedLight="tabbedLight"})(ae||(ae={}));var re;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(re||(re={}));function Ue(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new w(t.position),size:new W(t.size),workArea:{position:new w(t.workArea.position),size:new W(t.workArea.size)}}}async function Qe(){return s("plugin:window|primary_monitor").then(Ue)}function be(){return new K(ye(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function oe(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new K(new F(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const $=["tauri://created","tauri://error"];class K{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...n,label:i}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await oe()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return be()}static async getAll(){return oe()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:q(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Y(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if($.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return he(e,i)}async emitTo(e,i,n){if($.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ge(e,i,n)}_handleTauriEvent(e,i){return $.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new w(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new W(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof S?e:new S(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof A?e:new A(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(u.DRAG_ENTER,r=>{e({...r,payload:{type:"enter",paths:r.payload.paths,position:new w(r.payload.position)}})}),n=await this.listen(u.DRAG_OVER,r=>{e({...r,payload:{type:"over",position:new w(r.payload.position)}})}),a=await this.listen(u.DRAG_DROP,r=>{e({...r,payload:{type:"drop",paths:r.payload.paths,position:new w(r.payload.position)}})}),o=await this.listen(u.DRAG_LEAVE,r=>{e({...r,payload:{type:"leave"}})});return()=>{i(),a(),n(),o()}}}function M(){const t=be();return new D(t.label,{skip:!0})}async function le(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new D(e,{skip:!0})))}class D{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview_window",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;const n=(i=(await le()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new D(n.label,{skip:!0}):null}static getCurrent(){return M()}static async getAll(){return le()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:q(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Y(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}}$e(D,[F,K]);function $e(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var a;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(a=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&a!==void 0?a:Object.create(null))})})}const C=new Map,je=()=>navigator.platform.toLowerCase().includes("mac")||navigator.userAgent.toLowerCase().includes("mac"),Ge=t=>{if(!t||t.trim()==="")return!1;try{return!!(t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("tauri://"))}catch{return!1}},pe=async()=>{let t=1920,e=1080;try{const i=await Qe();if(i?.size){const n=i.scaleFactor||1;t=i.size.width/n,e=i.size.height/n}}catch(i){console.warn("Failed to get monitor info, using defaults:",i)}return{screenWidth:t,screenHeight:e}},X=async(t,e,i)=>{const n=i?.padding??20;if(i?.x!==void 0&&i?.y!==void 0)return{x:i.x,y:i.y};const{screenWidth:a,screenHeight:o}=await pe();switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:o-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:o-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(o-e)/2};default:return{x:a-t-n,y:o-e-n}}},fe=async t=>{const e=String(t.id),i=c.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=L(),a=`notice-${e}`;let o=`${n.routePrefix}/${t.type}?id=${t.id}`;Ge(o)||(console.warn(`Invalid window URL: ${o}. Using fallback 404 page.`),o=n.notFoundUrl||"/404");const r=t.min_width||n.defaultWidth,g=t.min_height||n.defaultHeight,m=t.decorations??n.defaultDecorations??!0,y=n.autoSize??!0,{x:N,y:x}=await X(r,g,t.windowPosition);try{const h={url:o,title:t.title,width:r,height:g,x:N,y:x,resizable:!0,skipTaskbar:!1,alwaysOnTop:!0};y&&(h.visible=!1),m?h.decorations=!0:je()?(h.decorations=!0,h.titleBarStyle="overlay",h.hiddenTitle=!0):(h.decorations=!1,h.transparent=!0);const f=new D(a,h);C.set(e,f),i.addActiveWindow(e);let l=null;const _=n.loadTimeout??1e4;!m&&_>0&&(l=setTimeout(async()=>{console.warn(`Notice window ${a} load timeout - auto closing`);try{await f.close()}catch{}},_)),f.once("tauri://created",()=>{l&&(clearTimeout(l),l=null),console.log(`Notice window created successfully: ${a}`)}),f.once("tauri://error",async v=>{if(console.error(`Notice window error: ${a}`,v),l&&(clearTimeout(l),l=null),!m)try{await f.close()}catch{}}),f.once("tauri://destroyed",async()=>{l&&(clearTimeout(l),l=null),C.delete(e),i.removeActiveWindow(e),await i.markMessageAsShown(e),i.clearCurrent()}),console.log(`Created notice window: ${a} (autoSize: ${y}, visible: ${!y})`)}catch(h){console.error("Failed to create notice window:",h),i.removeActiveWindow(e),i.clearCurrent()}},B=async t=>{const e=String(t),i=C.get(e),n=c.getState();if(i)try{await i.close(),C.delete(e),n.removeActiveWindow(e),await n.markMessageAsShown(e),n.clearCurrent(),console.log(`Closed notice window: ${e}`)}catch(a){console.error("Failed to close notice window:",a)}},_e=async()=>{const t=Array.from(C.keys()).map(e=>B(e));await Promise.all(t)},me=()=>{let t=null;c.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,fe(i)):i||(t=null)}),console.log("Notice window system initialized")},Ve=()=>{const t=c(i=>i.currentMessage);return{closeNotice:d.useCallback(async()=>{t&&await B(t.id)},[t])}},Je=()=>{const t=c(i=>i.hideMessage);return{hideNotice:d.useCallback(async i=>{await t(i),await B(i)},[t])}},Ze=()=>{const t=c(i=>i.clearOnLogout);return{hideAllNotices:d.useCallback(async()=>{await _e(),await t()},[t])}},Ye=()=>{const t=c(P.queueLength),e=c(P.currentMessage),i=c(P.isProcessing),n=c(P.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Ke=async t=>{try{const e=L(),i=e.defaultWidth||400,n=e.maxHeight??800,a=e.defaultHeight||300,o=Math.max(a,Math.min(Math.ceil(t),n)),{LogicalSize:r}=await Promise.resolve().then(()=>te),g=M();await g.setSize(new r(i,o));const{x:m,y}=await X(i,o),{LogicalPosition:N}=await Promise.resolve().then(()=>te);await g.setPosition(new N(m,y)),await g.show(),console.log(`[NoticeLayout] Auto-sized window to ${i}x${o}`)}catch(e){console.error("[NoticeLayout] Failed to auto-size, showing window as-is:",e);try{await M().show()}catch{}}},Xe=({children:t,onLoad:e,onClose:i})=>{const[n,a]=d.useState(null),[o,r]=d.useState(!0),[g,m]=d.useState(null),[y,N]=d.useState(!1),x=d.useRef(null),h=d.useRef(!1),f=L(),l=f.autoSize??!0;return d.useEffect(()=>{l||N(!0)},[l]),d.useEffect(()=>{(async()=>{try{const z=new URLSearchParams(window.location.search).get("id");if(!z){m("No message ID provided"),r(!1),setTimeout(async()=>{try{await M().close()}catch(O){console.error("Failed to close window:",O)}},1e3);return}const H=await V(z);if(!H){console.log(`Message ${z} not found in database, closing window`),m("Message not found"),r(!1),setTimeout(async()=>{try{await M().close()}catch(O){console.error("Failed to close window:",O)}},500);return}a(H),r(!1),e&&e(H)}catch(v){console.error("Failed to load message:",v),m("Failed to load message"),r(!1),setTimeout(async()=>{try{await M().close()}catch(z){console.error("Failed to close window:",z)}},1e3)}})()},[e]),d.useEffect(()=>{if(!l||!n||y||h.current)return;const _=requestAnimationFrame(()=>{if(!x.current||h.current)return;h.current=!0;const v=x.current.getBoundingClientRect();Ke(v.height).then(()=>{N(!0)})});return()=>cancelAnimationFrame(_)},[l,n,y]),d.useEffect(()=>{if(!l||y)return;const _=f.autoSizeTimeout??3e3,v=setTimeout(async()=>{if(!y){console.warn("[NoticeLayout] Auto-size timeout reached, showing window as-is");try{await M().show()}catch{}N(!0)}},_);return()=>clearTimeout(v)},[l,y,f.autoSizeTimeout]),d.useEffect(()=>{if(!n||!i)return;const _=()=>{i(n)};return window.addEventListener("beforeunload",_),()=>{window.removeEventListener("beforeunload",_)}},[n,i]),o?T.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):g?T.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:g}):n?T.jsx("div",{ref:x,style:y?{height:"100vh"}:void 0,children:t(n)}):T.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:"Closing window..."})},et=async()=>{G(),me();const{initializeFromDatabase:t}=c.getState();await t(),console.log("Tauri Notice System initialized")},tt=async t=>{await c.getState().deleteMessage(t)},it=async t=>{await c.getState().hideMessage(t)},nt=async t=>{await c.getState().markMessageAsShown(t)};exports.NoticeLayout=Xe;exports.calculateWindowPosition=X;exports.closeAllNoticeWindows=_e;exports.closeNoticeWindow=B;exports.createNoticeWindow=fe;exports.deleteMessageById=tt;exports.getLogicalScreenSize=pe;exports.getMessage=V;exports.getNoticeConfig=L;exports.getPendingMessages=de;exports.hideMessageById=it;exports.initializeDatabase=G;exports.initializeNoticeSystem=et;exports.initializeNoticeWindowSystem=me;exports.markMessageAsShown=nt;exports.messageQueueSelectors=P;exports.setNoticeConfig=Ne;exports.useCloseNotice=Ve;exports.useHideAllNotices=Ze;exports.useHideNotice=Je;exports.useMessageQueue=Ye;exports.useMessageQueueStore=c;exports.useNoticeWindow=Re;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const We=require("zustand"),Ne=require("zustand-sync"),ze=require("dexie"),u=require("react"),P=require("react/jsx-runtime"),ce="tauri-notice-config",ie={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300,notFoundUrl:"/404",defaultDecorations:!0,loadTimeout:4e3,autoSize:!0,maxWidth:600,maxHeight:800,autoSizeTimeout:3e3},de=()=>{try{const t=localStorage.getItem(ce);if(t)return{...ie,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return ie},Ae=t=>{try{localStorage.setItem(ce,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},xe=t=>{const i={...de(),...t};Ae(i)},T=()=>de();class Me extends ze{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let k=null;const j=()=>{if(!k){const t=T();k=new Me(t.databaseName)}return k},f=()=>k||j(),De=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await f().messages.put(e)},Oe=async t=>!!await f().messages.get(t),Ce=async t=>{const e=await f().messages.get(t);return e?.isShown===!0||e?.queueStatus==="shown"},we=async()=>await f().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),Pe=async(t,e)=>{await f().messages.update(t,{queueStatus:e})},Ie=async t=>{await f().messages.update(t,{queueStatus:"shown",isShown:!0})},ke=async t=>{await f().messages.update(t,{queueStatus:"hidden"})},V=async t=>await f().messages.get(t),Le=async t=>{await f().messages.delete(t)},Re=async()=>{await f().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},Te=async t=>{const e=t.map(i=>f().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},Ee=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await Ce(i.id)){console.log(`Message ${i.id} was already shown, skipping`);return}if(await Oe(i.id)||await De(i),!n.queue.some(b=>b.id===i.id)){const b=[...n.queue,i];t({queue:b}),await e().persistQueue()}!n.isProcessing&&!n.currentMessage&&await e().showNext()},dequeue:()=>{const i=e();if(i.queue.length===0)return null;const[n,...a]=i.queue;return t({queue:a}),n},showNext:async()=>{if(e().isProcessing)return;const n=e().dequeue();if(!n){t({isProcessing:!1,currentMessage:null});return}if(!await V(n.id)){console.log(`Message ${n.id} was deleted, skipping to next`),await e().showNext();return}t({currentMessage:n,isProcessing:!0}),await Pe(n.id,"showing"),await e().persistQueue()},clearCurrent:()=>{t({currentMessage:null,isProcessing:!1}),e().queue.length>0&&e().showNext()},setCurrentMessage:i=>{t({currentMessage:i})},setIsProcessing:i=>{t({isProcessing:i})},setQueue:i=>{t({queue:i})},initializeFromDatabase:async()=>{if(e().initialized)return;t({initialized:!0});const n=await we();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,o)=>({id:a.id,position:o}));await Te(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await Re()},removeFromQueue:async i=>{const n=e(),a=n.queue.filter(o=>o.id!==i);t({queue:a}),await e().persistQueue(),n.currentMessage?.id===i&&e().clearCurrent()},deleteMessage:async i=>{await Le(i),await e().removeFromQueue(i)},hideMessage:async i=>{await ke(i),await e().removeFromQueue(i)},markMessageAsShown:async i=>{await Ie(i)},addActiveWindow:i=>{const n=e(),a=String(i);n.activeWindowIds.includes(a)||t({activeWindowIds:[...n.activeWindowIds,a]})},removeActiveWindow:i=>{const n=e(),a=String(i);t({activeWindowIds:n.activeWindowIds.filter(o=>o!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),d=We.create()(Ne.syncTabs(Ee,{name:"tauri-notice-queue"})),I={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},qe=()=>{const t=d(i=>i.enqueue);return{showNotice:u.useCallback(async i=>{await t(i)},[t])}};function Fe(t,e,i,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function Be(t,e,i,n,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}var E;const y="__TAURI_TO_IPC_KEY__";function He(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}class Ue{get rid(){return Fe(this,E,"f")}constructor(e){E.set(this,void 0),Be(this,E,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}E=new WeakMap;class J{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new z(this.width*e,this.height*e)}[y](){return{width:this.width,height:this.height}}toJSON(){return this[y]()}}class z{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new J(this.width/e,this.height/e)}[y](){return{width:this.width,height:this.height}}toJSON(){return this[y]()}}class N{constructor(e){this.size=e}toLogical(e){return this.size instanceof J?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof z?this.size:this.size.toPhysical(e)}[y](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[y]()}}class Z{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new g(this.x*e,this.y*e)}[y](){return{x:this.x,y:this.y}}toJSON(){return this[y]()}}class g{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new Z(this.x/e,this.y/e)}[y](){return{x:this.x,y:this.y}}toJSON(){return this[y]()}}class M{constructor(e){this.position=e}toLogical(e){return this.position instanceof Z?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof g?this.position:this.position.toPhysical(e)}[y](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[y]()}}var c;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(c||(c={}));async function he(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function F(t,e,i){var n;const a=typeof i?.target=="string"?{kind:"AnyLabel",label:i.target}:(n=i?.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:a,handler:He(e)}).then(o=>async()=>he(t,o))}async function Y(t,e,i){return F(t,n=>{he(t,n.id),e(n)},i)}async function ge(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ye(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class L extends Ue{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:q(e),width:i,height:n}).then(a=>new L(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:q(e)}).then(i=>new L(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new L(i))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}function q(t){return t==null?null:typeof t=="string"?t:t instanceof L?t.rid:t}var G;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(G||(G={}));class $e{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var ne;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(ne||(ne={}));function be(){return new B(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function U(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new B(e,{skip:!0})))}const $=["tauri://created","tauri://error"];class B{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:window|create",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await U()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return be()}static async getAll(){return U()}static async getFocusedWindow(){for(const e of await U())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:F(e,i,{target:{kind:"Window",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Y(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if($.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ge(e,i)}async emitTo(e,i,n){if($.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ye(e,i,n)}_handleTauriEvent(e,i){return $.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new g(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new g(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new z(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new z(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===G.Critical?i={type:"Critical"}:i={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:i})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof N?e:new N(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof N?e:e?new N(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof N?e:e?new N(e):null})}async setSizeConstraints(e){function i(n){return n?{Logical:n}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:i(e?.minWidth),minHeight:i(e?.minHeight),maxWidth:i(e?.maxWidth),maxHeight:i(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof M?e:new M(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:q(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof M?e:new M(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?q(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(c.WINDOW_RESIZED,i=>{i.payload=new z(i.payload),e(i)})}async onMoved(e){return this.listen(c.WINDOW_MOVED,i=>{i.payload=new g(i.payload),e(i)})}async onCloseRequested(e){return this.listen(c.WINDOW_CLOSE_REQUESTED,async i=>{const n=new $e(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(c.DRAG_ENTER,r=>{e({...r,payload:{type:"enter",paths:r.payload.paths,position:new g(r.payload.position)}})}),n=await this.listen(c.DRAG_OVER,r=>{e({...r,payload:{type:"over",position:new g(r.payload.position)}})}),a=await this.listen(c.DRAG_DROP,r=>{e({...r,payload:{type:"drop",paths:r.payload.paths,position:new g(r.payload.position)}})}),o=await this.listen(c.DRAG_LEAVE,r=>{e({...r,payload:{type:"leave"}})});return()=>{i(),a(),n(),o()}}async onFocusChanged(e){const i=await this.listen(c.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(c.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(c.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(c.WINDOW_THEME_CHANGED,e)}}var se;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(se||(se={}));var ae;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(ae||(ae={}));var re;(function(t){t.AppearanceBased="appearanceBased",t.Light="light",t.Dark="dark",t.MediumLight="mediumLight",t.UltraDark="ultraDark",t.Titlebar="titlebar",t.Selection="selection",t.Menu="menu",t.Popover="popover",t.Sidebar="sidebar",t.HeaderView="headerView",t.Sheet="sheet",t.WindowBackground="windowBackground",t.HudWindow="hudWindow",t.FullScreenUI="fullScreenUI",t.Tooltip="tooltip",t.ContentBackground="contentBackground",t.UnderWindowBackground="underWindowBackground",t.UnderPageBackground="underPageBackground",t.Mica="mica",t.Blur="blur",t.Acrylic="acrylic",t.Tabbed="tabbed",t.TabbedDark="tabbedDark",t.TabbedLight="tabbedLight"})(re||(re={}));var oe;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(oe||(oe={}));function Qe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new g(t.position),size:new z(t.size),workArea:{position:new g(t.workArea.position),size:new z(t.workArea.size)}}}async function Ge(){return s("plugin:window|primary_monitor").then(Qe)}function pe(){return new K(be(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function le(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new K(new B(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const Q=["tauri://created","tauri://error"];class K{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...n,label:i}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await le()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return pe()}static async getAll(){return le()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:F(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Y(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(Q.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return ge(e,i)}async emitTo(e,i,n){if(Q.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ye(e,i,n)}_handleTauriEvent(e,i){return Q.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new g(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new z(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof N?e:new N(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof M?e:new M(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(c.DRAG_ENTER,r=>{e({...r,payload:{type:"enter",paths:r.payload.paths,position:new g(r.payload.position)}})}),n=await this.listen(c.DRAG_OVER,r=>{e({...r,payload:{type:"over",position:new g(r.payload.position)}})}),a=await this.listen(c.DRAG_DROP,r=>{e({...r,payload:{type:"drop",paths:r.payload.paths,position:new g(r.payload.position)}})}),o=await this.listen(c.DRAG_LEAVE,r=>{e({...r,payload:{type:"leave"}})});return()=>{i(),a(),n(),o()}}}function x(){const t=pe();return new D(t.label,{skip:!0})}async function ue(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new D(e,{skip:!0})))}class D{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview_window",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;const n=(i=(await ue()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new D(n.label,{skip:!0}):null}static getCurrent(){return x()}static async getAll(){return ue()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:F(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:Y(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}}je(D,[B,K]);function je(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var a;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(a=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&a!==void 0?a:Object.create(null))})})}const R=new Map,Ve=()=>navigator.platform.toLowerCase().includes("mac")||navigator.userAgent.toLowerCase().includes("mac"),Je=t=>{if(!t||t.trim()==="")return!1;try{return!!(t.startsWith("/")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("tauri://"))}catch{return!1}},fe=async()=>{let t=1920,e=1080;try{const i=await Ge();if(i?.size){const n=i.scaleFactor||1;t=i.size.width/n,e=i.size.height/n}}catch(i){console.warn("Failed to get monitor info, using defaults:",i)}return{screenWidth:t,screenHeight:e}},X=async(t,e,i)=>{const n=i?.padding??20;if(i?.x!==void 0&&i?.y!==void 0)return{x:i.x,y:i.y};const{screenWidth:a,screenHeight:o}=await fe();switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:o-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:o-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(o-e)/2};default:return{x:a-t-n,y:o-e-n}}},me=async t=>{const e=String(t.id),i=d.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=T(),a=`notice-${e}`;let o=`${n.routePrefix}/${t.type}?id=${t.id}`;Je(o)||(console.warn(`Invalid window URL: ${o}. Using fallback 404 page.`),o=n.notFoundUrl||"/404");const r=t.min_width||n.defaultWidth,b=t.min_height||n.defaultHeight,v=t.decorations??n.defaultDecorations??!0,p=n.autoSize??!0,{x:O,y:W}=await X(r,b,t.windowPosition);try{const h={url:o,title:t.title,width:r,height:b,x:O,y:W,resizable:!0,skipTaskbar:!1,alwaysOnTop:!0};p&&(h.visible=!1),v?h.decorations=!0:Ve()?(h.decorations=!0,h.titleBarStyle="overlay",h.hiddenTitle=!0):(h.decorations=!1,h.transparent=!0);const m=new D(a,h);R.set(e,m),i.addActiveWindow(e);let l=null;const _=n.loadTimeout??1e4;!v&&_>0&&(l=setTimeout(async()=>{console.warn(`Notice window ${a} load timeout - auto closing`);try{await m.close()}catch{}},_)),m.once("tauri://created",()=>{l&&(clearTimeout(l),l=null),console.log(`Notice window created successfully: ${a}`)}),m.once("tauri://error",async S=>{if(console.error(`Notice window error: ${a}`,S),l&&(clearTimeout(l),l=null),!v)try{await m.close()}catch{}}),m.once("tauri://destroyed",async()=>{l&&(clearTimeout(l),l=null),R.delete(e),i.removeActiveWindow(e),await i.markMessageAsShown(e),i.clearCurrent()}),console.log(`Created notice window: ${a} (autoSize: ${p}, visible: ${!p})`)}catch(h){console.error("Failed to create notice window:",h),i.removeActiveWindow(e),i.clearCurrent()}},H=async t=>{const e=String(t),i=R.get(e),n=d.getState();if(i)try{await i.close(),R.delete(e),n.removeActiveWindow(e),await n.markMessageAsShown(e),n.clearCurrent(),console.log(`Closed notice window: ${e}`)}catch(a){console.error("Failed to close notice window:",a)}},_e=async()=>{const t=Array.from(R.keys()).map(e=>H(e));await Promise.all(t)},ve=()=>{let t=null;d.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,me(i)):i||(t=null)}),console.log("Notice window system initialized")},Ze=()=>{const t=d(i=>i.currentMessage);return{closeNotice:u.useCallback(async()=>{t&&await H(t.id)},[t])}},Ye=()=>{const t=d(i=>i.hideMessage);return{hideNotice:u.useCallback(async i=>{await t(i),await H(i)},[t])}},Ke=()=>{const t=d(i=>i.clearOnLogout);return{hideAllNotices:u.useCallback(async()=>{await _e(),await t()},[t])}},Xe=()=>{const t=d(I.queueLength),e=d(I.currentMessage),i=d(I.isProcessing),n=d(I.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Se=u.createContext({windowReady:!0}),et=()=>u.useContext(Se),tt=async t=>{try{const e=T(),i=e.defaultWidth||400,n=e.maxHeight??800,a=e.defaultHeight||300,o=Math.max(a,Math.min(Math.ceil(t),n)),r=x();await r.setSize(new J(i,o));const{x:b,y:v}=await X(i,o);await r.setPosition(new Z(b,v)),await r.show(),console.log(`[NoticeLayout] Auto-sized window to ${i}x${o}`)}catch(e){console.error("[NoticeLayout] Failed to auto-size, showing window as-is:",e);try{await x().show()}catch{}}},it=({children:t,onLoad:e,onClose:i})=>{const[n,a]=u.useState(null),[o,r]=u.useState(!0),[b,v]=u.useState(null),[p,O]=u.useState(!1),W=u.useRef(null),h=u.useRef(!1),m=T(),l=m.autoSize??!0;return u.useEffect(()=>{l||O(!0)},[l]),u.useEffect(()=>{(async()=>{try{const w=new URLSearchParams(window.location.search).get("id");if(!w){v("No message ID provided"),r(!1),setTimeout(async()=>{try{await x().close()}catch(A){console.error("Failed to close window:",A)}},1e3);return}const C=await V(w);if(!C){console.log(`Message ${w} not found in database, closing window`),v("Message not found"),r(!1),setTimeout(async()=>{try{await x().close()}catch(A){console.error("Failed to close window:",A)}},500);return}a(C),r(!1),e&&e(C)}catch(S){console.error("Failed to load message:",S),v("Failed to load message"),r(!1),setTimeout(async()=>{try{await x().close()}catch(w){console.error("Failed to close window:",w)}},1e3)}})()},[e]),u.useEffect(()=>{if(!l||!n||p||h.current)return;const _=requestAnimationFrame(()=>{const S=requestAnimationFrame(()=>{if(!W.current||h.current)return;h.current=!0;const w=document.body,C=w.style.height,A=w.style.overflow;w.style.height="auto",w.style.overflow="visible",W.current.offsetHeight;const ee=W.current.getBoundingClientRect(),te=Math.max(ee.height,W.current.scrollHeight);console.log(`[NoticeLayout] Measured natural content height: ${te}px (rect=${ee.height}, scroll=${W.current.scrollHeight})`),w.style.height=C,w.style.overflow=A,tt(te).then(()=>{O(!0)})});return()=>cancelAnimationFrame(S)});return()=>cancelAnimationFrame(_)},[l,n,p]),u.useEffect(()=>{if(!l||p)return;const _=m.autoSizeTimeout??3e3,S=setTimeout(async()=>{if(!p){console.warn("[NoticeLayout] Auto-size timeout reached, showing window as-is");try{await x().show()}catch{}O(!0)}},_);return()=>clearTimeout(S)},[l,p,m.autoSizeTimeout]),u.useEffect(()=>{if(!n||!i)return;const _=()=>{i(n)};return window.addEventListener("beforeunload",_),()=>window.removeEventListener("beforeunload",_)},[n,i]),o?P.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):b?P.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:b}):n?P.jsx(Se.Provider,{value:{windowReady:p},children:P.jsx("div",{ref:W,style:p?{height:"100vh"}:void 0,children:t(n)})}):P.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:"Closing window..."})},nt=async()=>{j(),ve();const{initializeFromDatabase:t}=d.getState();await t(),console.log("Tauri Notice System initialized")},st=async t=>{await d.getState().deleteMessage(t)},at=async t=>{await d.getState().hideMessage(t)},rt=async t=>{await d.getState().markMessageAsShown(t)};exports.NoticeLayout=it;exports.calculateWindowPosition=X;exports.closeAllNoticeWindows=_e;exports.closeNoticeWindow=H;exports.createNoticeWindow=me;exports.deleteMessageById=st;exports.getLogicalScreenSize=fe;exports.getMessage=V;exports.getNoticeConfig=T;exports.getPendingMessages=we;exports.hideMessageById=at;exports.initializeDatabase=j;exports.initializeNoticeSystem=nt;exports.initializeNoticeWindowSystem=ve;exports.markMessageAsShown=rt;exports.messageQueueSelectors=I;exports.setNoticeConfig=xe;exports.useCloseNotice=Ze;exports.useHideAllNotices=Ke;exports.useHideNotice=Ye;exports.useMessageQueue=Xe;exports.useMessageQueueStore=d;exports.useNoticeWindow=qe;exports.useNoticeWindowContext=et;
2
2
  //# sourceMappingURL=index.cjs.map