@qumra/fanar 0.0.29 → 0.0.31

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,2 +1,2 @@
1
1
  "use client";
2
- import{cn,useUIText}from"./chunk-YJ45RGS6.js";import{cloneElement,isValidElement,useCallback,useEffect,useId,useRef,useState}from"react";import{createPortal}from"react-dom";import{AlertTriangle,CheckCircle2,Info,Loader2,X,XCircle}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";function useToasts(){const[toasts,setToasts]=useState([]);const seq=useRef(0);const timers=useRef(new Map);const dismiss=useCallback(id=>{const t=timers.current.get(id);if(t)clearTimeout(t);timers.current.delete(id);setToasts(prev=>prev.filter(x=>x.id!==id))},[]);const push=useCallback(input=>{const id=++seq.current;const duration=input.duration??(input.actionLabel?6500:3800);setToasts(prev=>[...prev.slice(-3),{...input,id}]);if(duration>0&&!input.pending){timers.current.set(id,setTimeout(()=>dismiss(id),duration))}return id},[dismiss]);const update=useCallback((id,patch)=>{setToasts(prev=>prev.map(t=>t.id===id?{...t,...patch}:t))},[]);const clear=useCallback(()=>{timers.current.forEach(clearTimeout);timers.current.clear();setToasts([])},[]);return{toasts,push,dismiss,update,clear}}var TOAST_ICON={neutral:Info,brand:Info,green:CheckCircle2,amber:AlertTriangle,red:XCircle};var TOAST_ACCENT={neutral:"text-muted2",brand:"text-brand-100",green:"text-mint",amber:"text-amber",red:"text-red-100"};function ToastHost({toasts,onDismiss,closeLabel}){const ui=useUIText();if(toasts.length===0)return null;return jsx("div",{role:"region","aria-label":ui.alerts,className:"fixed z-[60] bottom-4 inset-x-4 sm:inset-x-auto sm:start-5 sm:w-[360px] flex flex-col gap-2 pointer-events-none",children:toasts.map(t=>{const Icon=TOAST_ICON[t.tone];return jsxs("div",{role:t.tone==="red"?"alert":"status",className:"pointer-events-auto flex items-start gap-3 p-3.5 rounded-card bg-night text-white shadow-toast animate-[toast-in_.22s_cubic-bezier(.22,.61,.36,1)]",children:[jsx("span",{"aria-hidden":"true",className:cn("shrink-0 mt-0.5",TOAST_ACCENT[t.tone]),children:t.pending?jsx(Loader2,{size:17,className:"animate-spin"}):jsx(Icon,{size:17})}),jsxs("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx("span",{className:"text-ui font-bold leading-snug",children:t.title}),t.description&&jsx("span",{className:"text-caption leading-[1.6] text-white/65",children:t.description})]}),t.actionLabel&&jsx("button",{type:"button",onClick:()=>{t.onAction?.();onDismiss(t.id)},className:"shrink-0 text-ui font-extrabold text-mint cursor-pointer hover:underline underline-offset-4",children:t.actionLabel}),jsx("button",{type:"button",onClick:()=>onDismiss(t.id),"aria-label":closeLabel??ui.close,className:"shrink-0 text-white/40 hover:text-white cursor-pointer transition-colors",children:jsx(X,{size:15,"aria-hidden":"true"})})]},t.id)})})}function Tooltip({content,children,side="top"}){const[open,setOpen]=useState(false);const anchor=useRef(null);const tip=useRef(null);const id=useId();const GAP=7;const EDGE=8;const place=useCallback(()=>{const el=tip.current;const host=anchor.current;if(!el||!host)return;const r=host.getBoundingClientRect();const w=el.offsetWidth;const h=el.offsetHeight;const vw=document.documentElement.clientWidth;const vh=document.documentElement.clientHeight;const left=Math.min(Math.max(r.left+r.width/2-w/2,EDGE),Math.max(EDGE,vw-EDGE-w));const above=side==="top"?r.top-GAP-h>=EDGE:r.bottom+GAP+h>vh-EDGE;const top=above?r.top-GAP-h:r.bottom+GAP;el.style.left=`${left}px`;el.style.top=`${Math.min(Math.max(top,EDGE),Math.max(EDGE,vh-EDGE-h))}px`;el.style.visibility="visible"},[side]);useEffect(()=>{if(!open)return;window.addEventListener("scroll",place,{capture:true,passive:true});window.addEventListener("resize",place,{passive:true});return()=>{window.removeEventListener("scroll",place,{capture:true});window.removeEventListener("resize",place)}},[open,place]);const mount=useCallback(el=>{tip.current=el;if(el)place()},[place]);const described=isValidElement(children)?cloneElement(children,{"aria-describedby":open?id:void 0}):children;return jsxs("span",{ref:anchor,className:"relative inline-flex",onMouseEnter:()=>setOpen(true),onMouseLeave:()=>setOpen(false),onFocus:()=>setOpen(true),onBlur:()=>setOpen(false),children:[described,open&&typeof document!=="undefined"&&createPortal(jsx("span",{id,role:"tooltip",ref:mount,style:{visibility:"hidden",left:0,top:0},className:cn("fixed z-[60] w-max max-w-[220px] px-2.5 py-1.5 rounded-xs","bg-night text-white text-caption leading-[1.6] text-center shadow-tip","animate-[fade-in_.12s_ease-out] pointer-events-none"),children:content}),document.body)]})}export{useToasts,ToastHost,Tooltip};
2
+ import{cn,useUIText}from"./chunk-YJ45RGS6.js";import{cloneElement,isValidElement,useCallback,useEffect,useId,useRef,useState}from"react";import{createPortal}from"react-dom";import{AlertTriangle,CheckCircle2,Info,Loader2,X,XCircle}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";function useToasts(){const[toasts,setToasts]=useState([]);const seq=useRef(0);const timers=useRef(new Map);const dismiss=useCallback(id=>{const t=timers.current.get(id);if(t)clearTimeout(t);timers.current.delete(id);setToasts(prev=>prev.filter(x=>x.id!==id))},[]);const push=useCallback(input=>{const id=++seq.current;const duration=input.duration??(input.actionLabel?6500:3800);setToasts(prev=>[...prev.slice(-3),{...input,id}]);if(duration>0&&!input.pending){timers.current.set(id,setTimeout(()=>dismiss(id),duration))}return id},[dismiss]);const update=useCallback((id,patch)=>{setToasts(prev=>prev.map(t=>t.id===id?{...t,...patch}:t))},[]);const clear=useCallback(()=>{timers.current.forEach(clearTimeout);timers.current.clear();setToasts([])},[]);return{toasts,push,dismiss,update,clear}}var TOAST_ICON={neutral:Info,brand:Info,green:CheckCircle2,amber:AlertTriangle,red:XCircle};var TOAST_ACCENT={neutral:"text-muted2",brand:"text-brand-100",green:"text-mint",amber:"text-amber",red:"text-red-100"};function ToastHost({toasts,onDismiss,closeLabel}){const ui=useUIText();if(toasts.length===0)return null;return jsx("div",{role:"region","aria-label":ui.alerts,className:"fixed z-[60] bottom-4 inset-x-4 sm:inset-x-auto sm:start-5 sm:w-[360px] flex flex-col gap-2 pointer-events-none",children:toasts.map(t=>{const Icon=TOAST_ICON[t.tone];return jsxs("div",{role:t.tone==="red"?"alert":"status",className:"pointer-events-auto flex items-start gap-3 p-3.5 rounded-card bg-night text-white shadow-toast animate-[toast-in_.22s_cubic-bezier(.22,.61,.36,1)]",children:[jsx("span",{"aria-hidden":"true",className:cn("shrink-0 mt-0.5",TOAST_ACCENT[t.tone]),children:t.pending?jsx(Loader2,{size:17,className:"animate-spin"}):jsx(Icon,{size:17})}),jsxs("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx("span",{className:"text-ui font-bold leading-snug",children:t.title}),t.description&&jsx("span",{className:"text-caption leading-[1.6] text-white/65",children:t.description})]}),t.actionLabel&&jsx("button",{type:"button",onClick:()=>{t.onAction?.();onDismiss(t.id)},className:"shrink-0 text-ui font-extrabold text-mint cursor-pointer hover:underline underline-offset-4",children:t.actionLabel}),jsx("button",{type:"button",onClick:()=>onDismiss(t.id),"aria-label":closeLabel??ui.close,className:"shrink-0 text-white/40 hover:text-white cursor-pointer transition-colors",children:jsx(X,{size:15,"aria-hidden":"true"})})]},t.id)})})}function Tooltip({content,children,side="top",size="sm"}){const[open,setOpen]=useState(false);const anchor=useRef(null);const tip=useRef(null);const id=useId();const GAP=7;const EDGE=8;const place=useCallback(()=>{const el=tip.current;const host=anchor.current;if(!el||!host)return;const r=host.getBoundingClientRect();const w=el.offsetWidth;const h=el.offsetHeight;const vw=document.documentElement.clientWidth;const vh=document.documentElement.clientHeight;const left=Math.min(Math.max(r.left+r.width/2-w/2,EDGE),Math.max(EDGE,vw-EDGE-w));const above=side==="top"?r.top-GAP-h>=EDGE:r.bottom+GAP+h>vh-EDGE;const top=above?r.top-GAP-h:r.bottom+GAP;el.style.left=`${left}px`;el.style.top=`${Math.min(Math.max(top,EDGE),Math.max(EDGE,vh-EDGE-h))}px`;el.style.visibility="visible"},[side]);useEffect(()=>{if(!open)return;window.addEventListener("scroll",place,{capture:true,passive:true});window.addEventListener("resize",place,{passive:true});return()=>{window.removeEventListener("scroll",place,{capture:true});window.removeEventListener("resize",place)}},[open,place]);const mount=useCallback(el=>{tip.current=el;if(el)place()},[place]);const described=isValidElement(children)?cloneElement(children,{"aria-describedby":open?id:void 0}):children;return jsxs("span",{ref:anchor,className:"relative inline-flex",onMouseEnter:()=>setOpen(true),onMouseLeave:()=>setOpen(false),onFocus:()=>setOpen(true),onBlur:()=>setOpen(false),children:[described,open&&typeof document!=="undefined"&&createPortal(jsx("span",{id,role:"tooltip",ref:mount,style:{visibility:"hidden",left:0,top:0},className:cn("fixed z-[60] w-max rounded-xs","bg-night text-white text-caption leading-[1.6] shadow-tip","animate-[fade-in_.12s_ease-out] pointer-events-none",size==="md"?"max-w-xs px-3 py-2 text-start":"max-w-[220px] px-2.5 py-1.5 text-center"),children:content}),document.body)]})}export{useToasts,ToastHost,Tooltip};
package/dist/editor.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{Tooltip}from"./chunk-V7VYOWMO.js";import{Button,Input}from"./chunk-EM4MF5B3.js";import{Modal}from"./chunk-4ZNTBLVW.js";import{cn}from"./chunk-YJ45RGS6.js";import{useEffect as useEffect4,useMemo as useMemo2,useRef as useRef4,useState as useState6}from"react";import{EditorProvider,useCurrentEditor as useCurrentEditor6}from"@tiptap/react";import{CharacterCount as CharacterCount2}from"@tiptap/extension-character-count";import{Placeholder}from"@tiptap/extension-placeholder";import StarterKit from"@tiptap/starter-kit";import{Color}from"@tiptap/extension-color";import{Highlight}from"@tiptap/extension-highlight";import Image from"@tiptap/extension-image";import ListItem from"@tiptap/extension-list-item";import{Table}from"@tiptap/extension-table";import{TableCell}from"@tiptap/extension-table-cell";import{TableHeader}from"@tiptap/extension-table-header";import{TableRow}from"@tiptap/extension-table-row";import TextAlign from"@tiptap/extension-text-align";import{TextStyle}from"@tiptap/extension-text-style";import ImageResize from"tiptap-extension-resize-image";import TextDirection from"tiptap-text-direction";function contentExtensions(){return[StarterKit.configure({bulletList:{keepMarks:true,keepAttributes:false},orderedList:{keepMarks:true,keepAttributes:false},link:{openOnClick:false,autolink:true,defaultProtocol:"https"},dropcursor:{color:"var(--color-brand)",width:2}}),TextDirection.configure({types:["heading","paragraph"],defaultDirection:"rtl"}),TextAlign.configure({types:["heading","paragraph"]}),TextStyle,Color.configure({types:[TextStyle.name,ListItem.name]}),Highlight.configure({multicolor:true}),Image.configure({inline:true}),ImageResize.configure(),Table.configure({resizable:true}),TableRow,TableHeader,TableCell]}import{useCallback,useId,useMemo,useRef}from"react";import{useCurrentEditor}from"@tiptap/react";import{BubbleMenu}from"@tiptap/react/menus";import{PluginKey}from"@tiptap/pm/state";import{Bold,Code,Highlighter,Italic,Link2,Strikethrough,Underline}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";function BubbleButton({onClick,isActive,label,children}){return jsx("button",{type:"button",onClick,"aria-label":label,"aria-pressed":isActive,className:cn("size-7 rounded-xs inline-flex items-center justify-center cursor-pointer transition-colors",isActive?"bg-brand text-white":"text-ink2 hover:bg-hover hover:text-ink"),children})}function EditorBubbleMenu(){const{editor}=useCurrentEditor();const key=useId();const pluginKey=useMemo(()=>new PluginKey(`qumraBubble${key}`),[key]);const menuRef=useRef(null);const onShow=useCallback(()=>{const el=menuRef.current;if(el)el.style.opacity="0"},[]);const onUpdate=useCallback(()=>{const el=menuRef.current;if(el)el.style.opacity="1"},[]);const scrollTarget=useMemo(()=>{if(typeof window==="undefined")return void 0;const dom=editor?.view?.dom;let node=dom?.parentElement??null;while(node){const{overflowY}=getComputedStyle(node);if(overflowY==="auto"||overflowY==="scroll")return node;node=node.parentElement}return void 0},[editor]);if(!editor)return null;const e=editor;return jsx(BubbleMenu,{editor,pluginKey,ref:el=>{menuRef.current=el},options:{placement:"top",offset:8,...scrollTarget?{scrollTarget}:{},onShow,onUpdate},shouldShow:({editor:ed,from,to})=>{if(from===to)return false;if(ed.isActive("image")||ed.isActive("codeBlock"))return false;return true},children:jsxs("div",{className:"flex items-center gap-0.5 p-1 rounded-card border border-line bg-surface shadow-pop",children:[jsx(BubbleButton,{label:"\u0639\u0631\u064A\u0636",onClick:()=>e.chain().focus().toggleBold().run(),isActive:e.isActive("bold"),children:jsx(Bold,{size:14})}),jsx(BubbleButton,{label:"\u0645\u0627\u0626\u0644",onClick:()=>e.chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),children:jsx(Italic,{size:14})}),jsx(BubbleButton,{label:"\u062A\u062D\u062A\u0647 \u062E\u0637",onClick:()=>e.chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),children:jsx(Underline,{size:14})}),jsx(BubbleButton,{label:"\u064A\u062A\u0634\u0637\u0628",onClick:()=>e.chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),children:jsx(Strikethrough,{size:14})}),jsx("span",{"aria-hidden":"true",className:"w-px h-5 bg-line mx-0.5"}),jsx(BubbleButton,{label:"\u0643\u0648\u062F",onClick:()=>e.chain().focus().toggleCode().run(),isActive:e.isActive("code"),children:jsx(Code,{size:14})}),jsx(BubbleButton,{label:"\u062A\u0638\u0644\u064A\u0644",onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),children:jsx(Highlighter,{size:14})}),jsx("span",{"aria-hidden":"true",className:"w-px h-5 bg-line mx-0.5"}),jsx(BubbleButton,{label:"\u0631\u0627\u0628\u0637",isActive:e.isActive("link"),onClick:()=>{const previous=e.getAttributes("link").href||"";const url=window.prompt("\u0631\u0627\u0628\u0637",previous);if(url===null)return;const chain=e.chain().focus().extendMarkRange("link");if(url==="")chain.unsetLink().run();else chain.setLink({href:/^https?:\/\//i.test(url)?url:`https://${url}`}).run()},children:jsx(Link2,{size:14})})]})})}import{useEffect as useEffect2,useRef as useRef3,useState as useState4}from"react";import{useCurrentEditor as useCurrentEditor5}from"@tiptap/react";import{useEffect,useRef as useRef2,useState}from"react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function useDismiss(open,close){const ref=useRef2(null);useEffect(()=>{if(!open)return;function onDown(e){if(ref.current&&!ref.current.contains(e.target))close()}function onKey(e){if(e.key==="Escape")close()}document.addEventListener("mousedown",onDown);document.addEventListener("keydown",onKey);return()=>{document.removeEventListener("mousedown",onDown);document.removeEventListener("keydown",onKey)}},[open,close]);return ref}var PANEL="absolute z-50 top-[calc(100%+6px)] start-0 bg-surface border border-line rounded-card shadow-panel overflow-clip animate-[fade-in_.14s_ease-out]";function Popover({trigger,children,width,className}){const[open,setOpen]=useState(false);const ref=useDismiss(open,()=>setOpen(false));return jsxs2("div",{ref,className:cn("relative flex",className),children:[trigger({open,toggle:()=>setOpen(v=>!v)}),open&&jsx2("div",{className:cn(PANEL,width??"w-56"),children:children({close:()=>setOpen(false)})})]})}function MenuItem({onClick,icon,children,danger,active}){return jsxs2("button",{type:"button",onClick,className:cn("w-full px-3 py-2 flex items-center gap-2.5 text-start text-ui cursor-pointer transition-colors",danger?"text-red hover:bg-red-bg":"text-ink2 hover:bg-hover",active&&"bg-soft text-brand-ink font-bold"),children:[icon,jsx2("span",{className:"flex-1 min-w-0 truncate",children})]})}function MenuSeparator(){return jsx2("span",{"aria-hidden":"true",className:"block h-px bg-line my-1"})}function ToolbarButton({onClick,isActive,disabled,tooltip,shortcut,children}){return jsx2(Tooltip,{content:jsxs2("span",{className:"flex items-center gap-2",children:[tooltip,shortcut&&jsx2("kbd",{dir:"ltr",className:"px-1 py-px rounded-xs bg-white/15 text-micro font-mono",children:shortcut})]}),children:jsx2("button",{type:"button",onClick,disabled,"aria-label":tooltip,"aria-pressed":isActive,className:cn("size-8 rounded-sm inline-flex items-center justify-center shrink-0 cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand","disabled:opacity-40 disabled:cursor-not-allowed",isActive?"bg-soft text-brand-ink":"text-muted hover:bg-hover hover:text-ink"),children})})}function ToolbarGroup({children}){return jsx2("div",{className:"flex items-center gap-0.5 pe-1 me-1 border-e border-line last:border-e-0 last:pe-0 last:me-0",children})}function ColorGrid({colors,current,onPick,onClear,clearLabel,fallback}){return jsxs2("div",{className:"p-3 flex flex-col gap-2.5",children:[jsx2("div",{className:"grid grid-cols-4 gap-1.5",children:colors.map(color=>jsx2("button",{type:"button",onClick:()=>onPick(color),"aria-label":color,style:{background:color},className:cn("size-8 rounded-sm border cursor-pointer transition-transform hover:scale-110",current.toLowerCase()===color.toLowerCase()?"border-ink ring-2 ring-brand":"border-line")},color))}),jsxs2("div",{className:"flex items-center gap-2.5 pt-2.5 border-t border-line",children:[jsx2("input",{type:"color",value:current||fallback,onChange:e=>onPick(e.target.value),"aria-label":"\u0644\u0648\u0646 \u0645\u062E\u0635\u0651\u0635",className:"size-8 p-0 border-none bg-transparent cursor-pointer"}),jsx2("button",{type:"button",onClick:onClear,className:"text-caption text-muted hover:text-ink cursor-pointer transition-colors",children:clearLabel})]})]})}import{useCurrentEditor as useCurrentEditor2}from"@tiptap/react";import{AlignCenter,AlignLeft,AlignRight,Bold as BoldIcon,Code as CodeIcon,Eraser,Italic as ItalicIcon,List,ListOrdered,Minus,Quote,Redo,Strikethrough as StrikeIcon,Underline as UnderlineIcon,Undo}from"lucide-react";import{Fragment,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";function Bold2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleBold().run(),isActive:editor.isActive("bold"),tooltip:"\u0639\u0631\u064A\u0636",shortcut:"Ctrl+B",children:jsx3(BoldIcon,{size:16})})}function Italic2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleItalic().run(),isActive:editor.isActive("italic"),tooltip:"\u0645\u0627\u0626\u0644",shortcut:"Ctrl+I",children:jsx3(ItalicIcon,{size:16})})}function Underline2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleUnderline().run(),isActive:editor.isActive("underline"),tooltip:"\u062A\u062D\u062A\u0647 \u062E\u0637",shortcut:"Ctrl+U",children:jsx3(UnderlineIcon,{size:16})})}function Strikethrough2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleStrike().run(),isActive:editor.isActive("strike"),tooltip:"\u064A\u062A\u0634\u0637\u0628",shortcut:"Ctrl+Shift+S",children:jsx3(StrikeIcon,{size:16})})}function Code2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleCode().run(),isActive:editor.isActive("code"),tooltip:"\u0643\u0648\u062F",shortcut:"Ctrl+E",children:jsx3(CodeIcon,{size:16})})}function BulletList(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleBulletList().run(),isActive:editor.isActive("bulletList"),tooltip:"\u0642\u0627\u0626\u0645\u0629 \u0646\u0642\u0637\u064A\u0629",shortcut:"Ctrl+Shift+8",children:jsx3(List,{size:16})})}function OrderedList(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleOrderedList().run(),isActive:editor.isActive("orderedList"),tooltip:"\u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0642\u0651\u0645\u0629",shortcut:"Ctrl+Shift+7",children:jsx3(ListOrdered,{size:16})})}function BlockQuote(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleBlockquote().run(),isActive:editor.isActive("blockquote"),tooltip:"\u0627\u0642\u062A\u0628\u0627\u0633",shortcut:"Ctrl+Shift+B",children:jsx3(Quote,{size:16})})}function HorizontalRule(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().setHorizontalRule().run(),tooltip:"\u0641\u0627\u0635\u0644 \u0623\u0641\u0642\u064A",children:jsx3(Minus,{size:16})})}function ClearMarks(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().unsetAllMarks().run(),tooltip:"\u0645\u0633\u062D \u0627\u0644\u062A\u0646\u0633\u064A\u0642",children:jsx3(Eraser,{size:16})})}function UndoRedo(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsxs3(Fragment,{children:[jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().undo().run(),disabled:!editor.can().chain().focus().undo().run(),tooltip:"\u062A\u0631\u0627\u062C\u0639",shortcut:"Ctrl+Z",children:jsx3(Undo,{size:16})}),jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().redo().run(),disabled:!editor.can().chain().focus().redo().run(),tooltip:"\u0625\u0639\u0627\u062F\u0629",shortcut:"Ctrl+Y",children:jsx3(Redo,{size:16})})]})}function Alignment(){const{editor}=useCurrentEditor2();if(!editor)return null;const items=[{key:"right",tooltip:"\u0645\u062D\u0627\u0630\u0627\u0629 \u064A\u0645\u064A\u0646",Icon:AlignRight},{key:"center",tooltip:"\u062A\u0648\u0633\u064A\u0637",Icon:AlignCenter},{key:"left",tooltip:"\u0645\u062D\u0627\u0630\u0627\u0629 \u0634\u0645\u0627\u0644",Icon:AlignLeft}];return jsx3(Fragment,{children:items.map(({key,tooltip,Icon})=>jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().setTextAlign(key).run(),isActive:editor.isActive({textAlign:key}),disabled:!editor.can().chain().focus().setTextAlign(key).run(),tooltip,children:jsx3(Icon,{size:16})},key))})}function CharacterCount({maxChars}){const{editor}=useCurrentEditor2();if(!editor)return null;const chars=editor.storage.characterCount?.characters()??0;const words=editor.storage.characterCount?.words()??0;const over=maxChars?chars>maxChars:false;const near=maxChars?chars>maxChars*.9:false;return jsxs3("span",{className:cn("flex items-center gap-2 text-caption select-none",over?"text-red font-bold":near?"text-amber-ink font-bold":"text-muted2"),children:[jsxs3("span",{"data-num":true,children:[chars,maxChars?`/${maxChars}`:""," \u062D\u0631\u0641"]}),jsx3("span",{"aria-hidden":"true",className:"text-line",children:"|"}),jsxs3("span",{"data-num":true,children:[words," \u0643\u0644\u0645\u0629"]})]})}import{useState as useState2}from"react";import{useCurrentEditor as useCurrentEditor3}from"@tiptap/react";import{CalendarClock,ChevronDown,Columns,Highlighter as Highlighter2,Image as ImageIcon,Link2 as Link22,Merge,Palette,Plus,Rows,Split,Table as TableIcon,Trash2}from"lucide-react";import{Fragment as Fragment2,jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";var HEADINGS=[{level:0,label:"\u0646\u0635 \u0639\u0627\u062F\u064A",size:"text-body"},{level:1,label:"\u0639\u0646\u0648\u0627\u0646 \u0661",size:"text-h2"},{level:2,label:"\u0639\u0646\u0648\u0627\u0646 \u0662",size:"text-h3"},{level:3,label:"\u0639\u0646\u0648\u0627\u0646 \u0663",size:"text-h4"},{level:4,label:"\u0639\u0646\u0648\u0627\u0646 \u0664",size:"text-lead"},{level:5,label:"\u0639\u0646\u0648\u0627\u0646 \u0665",size:"text-body"},{level:6,label:"\u0639\u0646\u0648\u0627\u0646 \u0666",size:"text-ui"}];function HeadingSelector(){const{editor}=useCurrentEditor3();if(!editor)return null;const current=HEADINGS.find(h=>h.level===0?editor.isActive("paragraph"):editor.isActive("heading",{level:h.level}))??HEADINGS[0];return jsx4(Popover,{width:"w-48",trigger:({open,toggle})=>jsxs4("button",{type:"button",onClick:toggle,"aria-haspopup":"menu","aria-expanded":open,className:cn("h-8 px-2.5 rounded-sm inline-flex items-center gap-1.5 text-ui font-bold cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",open?"bg-soft text-brand-ink":"text-ink2 hover:bg-hover"),children:[jsx4("span",{className:"truncate max-w-24",children:current.label}),jsx4(ChevronDown,{size:14,className:cn("shrink-0 transition-transform",open&&"rotate-180")})]}),children:({close})=>jsx4("div",{role:"menu",className:"py-1",children:HEADINGS.map(h=>{const active=h.level===0?editor.isActive("paragraph"):editor.isActive("heading",{level:h.level});return jsx4("button",{type:"button",role:"menuitem",onClick:()=>{if(h.level===0)editor.chain().focus().setParagraph().run();else editor.chain().focus().toggleHeading({level:h.level}).run();close()},className:cn("w-full px-3 py-2 flex items-center justify-between gap-3 text-start cursor-pointer transition-colors",active?"bg-soft text-brand-ink":"text-ink2 hover:bg-hover"),children:jsx4("span",{className:cn(h.size,active?"font-extrabold":"font-bold"),children:h.label})},h.level)})})})}function normalizeUrl(url){const t=url.trim();if(!t)return"";if(/^(https?:\/\/|mailto:|#)/i.test(t))return t;return`https://${t}`}function Link(){const{editor}=useCurrentEditor3();const[open,setOpen]=useState2(false);const[url,setUrl]=useState2("");if(!editor)return null;function apply(){const chain=editor.chain().focus().extendMarkRange("link");if(url.trim()==="")chain.unsetLink().run();else chain.setLink({href:normalizeUrl(url)}).run();setOpen(false)}return jsxs4(Fragment2,{children:[jsx4(ToolbarButton,{onClick:()=>{setUrl(editor.getAttributes("link").href||"");setOpen(true)},isActive:editor.isActive("link"),tooltip:"\u0631\u0627\u0628\u0637",shortcut:"Ctrl+K",children:jsx4(Link22,{size:16})}),jsx4(Modal,{open,onClose:()=>setOpen(false),title:"\u0625\u0636\u0627\u0641\u0629 \u0631\u0627\u0628\u0637",description:"\u0633\u064A\u0628\u0647 \u0641\u0627\u0636\u064A \u0648\u0627\u0645\u0633\u062D \u0639\u0634\u0627\u0646 \u062A\u0634\u064A\u0644 \u0627\u0644\u0631\u0627\u0628\u0637.",size:"sm",footer:jsxs4(Fragment2,{children:[jsx4(Button,{variant:"outline",onClick:()=>setOpen(false),children:"\u0625\u0644\u063A\u0627\u0621"}),jsx4(Button,{onClick:apply,children:url.trim()?"\u0623\u0636\u0641":"\u0634\u064A\u0644 \u0627\u0644\u0631\u0627\u0628\u0637"})]}),children:jsx4(Input,{label:"\u0627\u0644\u0639\u0646\u0648\u0627\u0646",dir:"ltr",placeholder:"example.com",value:url,onChange:e=>setUrl(e.target.value),onKeyDown:e=>e.key==="Enter"&&apply()})})]})}function ImageTool({onPick}){const{editor}=useCurrentEditor3();const[open,setOpen]=useState2(false);const[src,setSrc]=useState2("");if(!editor)return null;const insert=url=>editor.chain().focus().setImage({src:url}).run();return jsxs4(Fragment2,{children:[jsx4(ToolbarButton,{onClick:()=>onPick?onPick(insert):setOpen(true),isActive:editor.isActive("image"),tooltip:"\u0635\u0648\u0631\u0629",children:jsx4(ImageIcon,{size:16})}),!onPick&&jsx4(Modal,{open,onClose:()=>setOpen(false),title:"\u0625\u062F\u0631\u0627\u062C \u0635\u0648\u0631\u0629",size:"sm",footer:jsxs4(Fragment2,{children:[jsx4(Button,{variant:"outline",onClick:()=>setOpen(false),children:"\u0625\u0644\u063A\u0627\u0621"}),jsx4(Button,{disabled:!src.trim(),onClick:()=>{insert(src.trim());setSrc("");setOpen(false)},children:"\u0623\u062F\u0631\u062C"})]}),children:jsx4(Input,{label:"\u0631\u0627\u0628\u0637 \u0627\u0644\u0635\u0648\u0631\u0629",dir:"ltr",placeholder:"https://\u2026",value:src,onChange:e=>setSrc(e.target.value),hint:"\u0648\u062A\u0642\u062F\u0631 \u0643\u0645\u0627\u0646 \u062A\u0633\u062D\u0628 \u0635\u0648\u0631\u0629 \u0648\u062A\u0641\u0644\u062A\u0647\u0627 \u062C\u0648\u0651\u0647 \u0627\u0644\u0645\u062D\u0631\u0631 \u0645\u0628\u0627\u0634\u0631\u0629\u064B."})})]})}function TableTool(){const{editor}=useCurrentEditor3();if(!editor)return null;const inTable=editor.isActive("table");return jsx4(Popover,{width:"w-56",trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:inTable||open,tooltip:"\u062C\u062F\u0648\u0644",children:jsx4(TableIcon,{size:16})}),children:({close})=>{const run=fn=>()=>{fn();close()};return jsxs4("div",{role:"menu",className:"py-1",children:[jsx4(MenuItem,{icon:jsx4(Plus,{size:14}),onClick:run(()=>editor.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:true}).run()),children:"\u0623\u062F\u0631\u062C \u062C\u062F\u0648\u0644 \u0663\xD7\u0663"}),inTable&&jsxs4(Fragment2,{children:[jsx4(MenuSeparator,{}),jsx4(MenuItem,{icon:jsx4(Rows,{size:14}),onClick:run(()=>editor.chain().focus().addRowBefore().run()),children:"\u0635\u0641 \u0642\u0628\u0644"}),jsx4(MenuItem,{icon:jsx4(Rows,{size:14}),onClick:run(()=>editor.chain().focus().addRowAfter().run()),children:"\u0635\u0641 \u0628\u0639\u062F"}),jsx4(MenuItem,{danger:true,icon:jsx4(Trash2,{size:14}),onClick:run(()=>editor.chain().focus().deleteRow().run()),children:"\u0627\u062D\u0630\u0641 \u0627\u0644\u0635\u0641"}),jsx4(MenuSeparator,{}),jsx4(MenuItem,{icon:jsx4(Columns,{size:14}),onClick:run(()=>editor.chain().focus().addColumnBefore().run()),children:"\u0639\u0645\u0648\u062F \u0642\u0628\u0644"}),jsx4(MenuItem,{icon:jsx4(Columns,{size:14}),onClick:run(()=>editor.chain().focus().addColumnAfter().run()),children:"\u0639\u0645\u0648\u062F \u0628\u0639\u062F"}),jsx4(MenuItem,{danger:true,icon:jsx4(Trash2,{size:14}),onClick:run(()=>editor.chain().focus().deleteColumn().run()),children:"\u0627\u062D\u0630\u0641 \u0627\u0644\u0639\u0645\u0648\u062F"}),jsx4(MenuSeparator,{}),jsx4(MenuItem,{icon:jsx4(Merge,{size:14}),onClick:run(()=>editor.chain().focus().mergeCells().run()),children:"\u0627\u062F\u0645\u062C \u0627\u0644\u062E\u0644\u0627\u064A\u0627"}),jsx4(MenuItem,{icon:jsx4(Split,{size:14}),onClick:run(()=>editor.chain().focus().splitCell().run()),children:"\u0627\u0642\u0633\u0645 \u0627\u0644\u062E\u0644\u064A\u0629"}),jsx4(MenuSeparator,{}),jsx4(MenuItem,{danger:true,icon:jsx4(Trash2,{size:14}),onClick:run(()=>editor.chain().focus().deleteTable().run()),children:"\u0627\u062D\u0630\u0641 \u0627\u0644\u062C\u062F\u0648\u0644"})]})]})}})}var TEXT_COLORS=["#000000","#434343","#666666","#999999","#E03131","#C2255C","#9C36B5","#6741D9","#3B5BDB","#1971C2","#0C8599","#099268","#2F9E44","#66A80F","#F08C00","#E8590C"];var HIGHLIGHT_COLORS=["#FBBF24","#F87171","#FB923C","#A78BFA","#60A5FA","#34D399","#F472B6","#2DD4BF","#FCD34D","#FCA5A5","#FDBA74","#C4B5FD","#93C5FD","#6EE7B7","#F9A8D4","#99F6E4"];function ColorTool(){const{editor}=useCurrentEditor3();if(!editor)return null;const current=editor.getAttributes("textStyle").color||"";return jsx4(Popover,{trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:open,tooltip:"\u0644\u0648\u0646 \u0627\u0644\u0646\u0635",children:jsxs4("span",{className:"flex flex-col items-center gap-0.5",children:[jsx4(Palette,{size:16,style:current?{color:current}:void 0}),jsx4("span",{"aria-hidden":"true",className:"w-4 h-0.5 rounded-full",style:{background:current||"currentColor"}})]})}),children:({close})=>jsx4(ColorGrid,{colors:TEXT_COLORS,current,fallback:"#000000",clearLabel:"\u0634\u064A\u0644 \u0627\u0644\u0644\u0648\u0646",onPick:c=>{editor.chain().focus().setColor(c).run();close()},onClear:()=>{editor.chain().focus().unsetColor().run();close()}})})}function HighlightTool(){const{editor}=useCurrentEditor3();if(!editor)return null;const current=editor.getAttributes("highlight").color||"";return jsx4(Popover,{trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:editor.isActive("highlight")||open,tooltip:"\u062A\u0638\u0644\u064A\u0644",children:jsxs4("span",{className:"flex flex-col items-center gap-0.5",children:[jsx4(Highlighter2,{size:16}),jsx4("span",{"aria-hidden":"true",className:"w-4 h-0.5 rounded-full",style:{background:current||"transparent"}})]})}),children:({close})=>jsx4(ColorGrid,{colors:HIGHLIGHT_COLORS,current,fallback:"#FBBF24",clearLabel:"\u0634\u064A\u0644 \u0627\u0644\u062A\u0638\u0644\u064A\u0644",onPick:c=>{editor.chain().focus().toggleHighlight({color:c}).run();close()},onClear:()=>{editor.chain().focus().unsetHighlight().run();close()}})})}var DATE_FORMATS=[{label:"\u0663\u0661 \u064A\u0648\u0644\u064A\u0648 \u0662\u0660\u0662\u0666",opts:{day:"numeric",month:"long",year:"numeric"}},{label:"\u0663\u0661 \u064A\u0648\u0644 \u0662\u0660\u0662\u0666",opts:{day:"numeric",month:"short",year:"numeric"}},{label:"\u0627\u0644\u062C\u0645\u0639\u0629\u060C \u0663\u0661 \u064A\u0648\u0644\u064A\u0648",opts:{weekday:"long",day:"numeric",month:"long"}},{label:"\u0662\u0660\u0662\u0666/\u0660\u0667/\u0663\u0661",opts:{year:"numeric",month:"2-digit",day:"2-digit"}},{label:"\u0660\u0662:\u0665\u0661 \u0635",opts:{hour:"2-digit",minute:"2-digit"}},{label:"\u0660\u0662:\u0665\u0661:\u0663\u0660 \u0635",opts:{hour:"2-digit",minute:"2-digit",second:"2-digit"}}];function DateTime({locale="ar-EG"}){const{editor}=useCurrentEditor3();if(!editor)return null;return jsx4(Popover,{width:"w-56",trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:open,tooltip:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A",children:jsx4(CalendarClock,{size:16})}),children:({close})=>jsx4("div",{role:"menu",className:"py-1",children:DATE_FORMATS.map(f=>{const text=new Intl.DateTimeFormat(locale,f.opts).format(new Date);return jsx4(MenuItem,{onClick:()=>{editor.chain().focus().insertContent(text).run();close()},children:text},f.label)})})})}import{useCallback as useCallback2,useState as useState3}from"react";import{useCurrentEditor as useCurrentEditor4}from"@tiptap/react";import{ChevronDown as ChevronDown2,ChevronUp,Replace,Search}from"lucide-react";import{Fragment as Fragment3,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function FindReplace(){const{editor}=useCurrentEditor4();const[term,setTerm]=useState3("");const[replacement,setReplacement]=useState3("");const[matches,setMatches]=useState3([]);const[index,setIndex]=useState3(0);const jump=useCallback2(m=>editor?.chain().setTextSelection(m).scrollIntoView().run(),[editor]);const find=useCallback2(value=>{if(!editor||!value.trim()){setMatches([]);setIndex(0);return}const found=[];const needle=value.toLowerCase();editor.state.doc.descendants((node,pos)=>{if(!node.isText)return;const text=node.text?.toLowerCase()??"";let at=text.indexOf(needle);while(at!==-1){found.push({from:pos+at,to:pos+at+value.length});at=text.indexOf(needle,at+1)}});setMatches(found);setIndex(0);if(found[0])jump(found[0])},[editor,jump]);if(!editor)return null;const step=by=>{if(matches.length===0)return;const next=(index+by+matches.length)%matches.length;setIndex(next);jump(matches[next])};const replaceOne=()=>{const m=matches[index];if(!m)return;editor.chain().focus().setTextSelection(m).insertContent(replacement).run();find(term)};const replaceAll=()=>{if(matches.length===0)return;const chain=editor.chain().focus();for(const m of[...matches].sort((a,b)=>b.from-a.from)){chain.setTextSelection(m).insertContent(replacement)}chain.run();find(term)};return jsx5(Popover,{width:"w-72",trigger:({open,toggle})=>jsx5(ToolbarButton,{onClick:toggle,isActive:open,tooltip:"\u0628\u062D\u062B \u0648\u0627\u0633\u062A\u0628\u062F\u0627\u0644",shortcut:"Ctrl+H",children:jsx5(Search,{size:16})}),children:()=>jsxs5("div",{className:"p-3 flex flex-col gap-2.5",children:[jsxs5("div",{className:"flex items-end gap-1.5",children:[jsx5(Input,{autoFocus:true,size:"sm",label:"\u0627\u0628\u062D\u062B \u0639\u0646",hideLabel:true,placeholder:"\u0627\u0628\u062D\u062B \u0639\u0646\u2026",value:term,wrapperClassName:"flex-1 min-w-0",onChange:e=>{setTerm(e.target.value);find(e.target.value)},onKeyDown:e=>{if(e.key!=="Enter")return;e.preventDefault();step(e.shiftKey?-1:1)}}),jsx5(Button,{size:"sm",variant:"outline",iconOnly:true,"aria-label":"\u0627\u0644\u0633\u0627\u0628\u0642",disabled:matches.length===0,onClick:()=>step(-1),icon:jsx5(ChevronUp,{size:14})}),jsx5(Button,{size:"sm",variant:"outline",iconOnly:true,"aria-label":"\u0627\u0644\u062A\u0627\u0644\u064A",disabled:matches.length===0,onClick:()=>step(1),icon:jsx5(ChevronDown2,{size:14})})]}),term.trim()&&jsx5("span",{className:"text-micro text-muted2","aria-live":"polite",children:matches.length>0?jsxs5(Fragment3,{children:[jsx5("span",{"data-num":true,children:index+1})," \u0645\u0646 ",jsx5("span",{"data-num":true,children:matches.length})]}):"\u0645\u0627\u0641\u064A\u0634 \u0646\u062A\u0627\u064A\u062C"}),jsxs5("div",{className:"flex items-end gap-1.5",children:[jsx5(Input,{size:"sm",label:"\u0627\u0633\u062A\u0628\u062F\u0644 \u0628\u0640",hideLabel:true,placeholder:"\u0627\u0633\u062A\u0628\u062F\u0644 \u0628\u0640\u2026",value:replacement,wrapperClassName:"flex-1 min-w-0",onChange:e=>setReplacement(e.target.value),onKeyDown:e=>{if(e.key==="Enter"){e.preventDefault();replaceOne()}}}),jsx5(Button,{size:"sm",variant:"outline",iconOnly:true,"aria-label":"\u0627\u0633\u062A\u0628\u062F\u0644",disabled:matches.length===0,onClick:replaceOne,icon:jsx5(Replace,{size:14})})]}),jsx5(Button,{size:"sm",variant:"soft",block:true,disabled:matches.length===0,onClick:replaceAll,children:"\u0627\u0633\u062A\u0628\u062F\u0644 \u0627\u0644\u0643\u0644"})]})})}import{jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";function useEditorTick(){const[,setTick]=useState4(0);const{editor}=useCurrentEditor5();const raf=useRef3(0);useEffect2(()=>{if(!editor)return;const bump=()=>{cancelAnimationFrame(raf.current);raf.current=requestAnimationFrame(()=>setTick(t=>t+1))};editor.on("selectionUpdate",bump);editor.on("transaction",bump);return()=>{cancelAnimationFrame(raf.current);editor.off("selectionUpdate",bump);editor.off("transaction",bump)}},[editor])}function Toolbar({basic,onPickImage,hideImage,locale}){useEditorTick();const{editor}=useCurrentEditor5();if(!editor)return null;if(basic){return jsxs6("div",{className:"w-full border-b border-line px-1.5 py-1 flex flex-wrap items-center gap-0.5",children:[jsx6(ToolbarGroup,{children:jsx6(UndoRedo,{})}),jsx6(ToolbarGroup,{children:jsx6(HeadingSelector,{})}),jsxs6(ToolbarGroup,{children:[jsx6(Bold2,{}),jsx6(Italic2,{}),jsx6(Underline2,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(BulletList,{}),jsx6(OrderedList,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(Link,{}),!hideImage&&jsx6(ImageTool,{onPick:onPickImage}),jsx6(ColorTool,{})]})]})}return jsxs6("div",{className:"w-full border-b border-line px-1.5 py-1.5 flex flex-wrap items-center gap-y-1",children:[jsx6(ToolbarGroup,{children:jsx6(UndoRedo,{})}),jsx6(ToolbarGroup,{children:jsx6(HeadingSelector,{})}),jsxs6(ToolbarGroup,{children:[jsx6(Bold2,{}),jsx6(Italic2,{}),jsx6(Underline2,{}),jsx6(Strikethrough2,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(BulletList,{}),jsx6(OrderedList,{}),jsx6(BlockQuote,{})]}),jsx6(ToolbarGroup,{children:jsx6(Alignment,{})}),jsxs6(ToolbarGroup,{children:[jsx6(Link,{}),!hideImage&&jsx6(ImageTool,{onPick:onPickImage}),jsx6(TableTool,{}),jsx6(DateTime,{locale})]}),jsxs6(ToolbarGroup,{children:[jsx6(ColorTool,{}),jsx6(HighlightTool,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(Code2,{}),jsx6(HorizontalRule,{}),jsx6(ClearMarks,{}),jsx6(FindReplace,{})]})]})}function EditorFooter({maxChars}){return jsx6("div",{className:"border-t border-line px-3 py-1.5 flex justify-end",children:jsx6(CharacterCount,{maxChars})})}import{forwardRef,useEffect as useEffect3,useImperativeHandle,useState as useState5}from"react";import{Extension}from"@tiptap/core";import{PluginKey as PluginKey2}from"@tiptap/pm/state";import{ReactRenderer}from"@tiptap/react";import Suggestion from"@tiptap/suggestion";import{jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";var SLASH_ITEMS=[{title:"\u0639\u0646\u0648\u0627\u0646 \u0643\u0628\u064A\u0631",hint:"H1",icon:"H1",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHeading({level:1}).run()},{title:"\u0639\u0646\u0648\u0627\u0646 \u0645\u062A\u0648\u0633\u0637",hint:"H2",icon:"H2",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHeading({level:2}).run()},{title:"\u0639\u0646\u0648\u0627\u0646 \u0635\u063A\u064A\u0631",hint:"H3",icon:"H3",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHeading({level:3}).run()},{title:"\u0642\u0627\u0626\u0645\u0629 \u0646\u0642\u0637\u064A\u0629",icon:"\u2022",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleBulletList().run()},{title:"\u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0642\u0651\u0645\u0629",icon:"\u0661.",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleOrderedList().run()},{title:"\u0627\u0642\u062A\u0628\u0627\u0633",icon:"\u275D",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleBlockquote().run()},{title:"\u0628\u0644\u0648\u0643 \u0643\u0648\u062F",icon:"</>",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleCodeBlock().run()},{title:"\u062C\u062F\u0648\u0644",hint:"\u0663\xD7\u0663",icon:"\u229E",command:({editor,range})=>editor.chain().focus().deleteRange(range).insertTable({rows:3,cols:3,withHeaderRow:true}).run()},{title:"\u0641\u0627\u0635\u0644 \u0623\u0641\u0642\u064A",icon:"\u2500",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHorizontalRule().run()}];var SlashList=forwardRef(function SlashList2({items,command},ref){const[active,setActive]=useState5(0);useEffect3(()=>setActive(0),[items]);useImperativeHandle(ref,()=>({onKeyDown:({event})=>{if(event.key==="ArrowUp"){setActive(i=>i<=0?items.length-1:i-1);return true}if(event.key==="ArrowDown"){setActive(i=>i>=items.length-1?0:i+1);return true}if(event.key==="Enter"){const item=items[active];if(item)command(item);return true}return false}}));if(items.length===0)return null;return jsx7("div",{className:"w-64 max-h-72 overflow-y-auto rounded-card border border-line bg-surface shadow-pop py-1 animate-[fade-in_.12s_ease-out]",children:items.map((item,i)=>jsxs7("button",{type:"button",onMouseEnter:()=>setActive(i),onClick:()=>command(item),className:cn("w-full px-3 py-2 flex items-center gap-3 text-start cursor-pointer transition-colors",i===active?"bg-soft text-brand-ink":"text-ink2 hover:bg-hover"),children:[jsx7("span",{"aria-hidden":"true",className:"size-7 shrink-0 rounded-sm bg-bg border border-line flex items-center justify-center text-micro font-extrabold",children:item.icon}),jsx7("span",{className:"flex-1 min-w-0 text-ui font-bold truncate",children:item.title}),item.hint&&jsx7("span",{dir:"ltr",className:"text-micro text-muted2 shrink-0",children:item.hint})]},item.title))})});var SlashCommandsPluginKey=new PluginKey2("qumraSlashCommands");var SlashCommands=Extension.create({name:"qumraSlashCommands",addOptions(){return{suggestion:{char:"/",pluginKey:SlashCommandsPluginKey,command:({editor,range,props})=>{props.command({editor,range})}}}},addProseMirrorPlugins(){return[Suggestion({editor:this.editor,...this.options.suggestion})]}});function place(el,rect){const rtl=getComputedStyle(document.documentElement).direction==="rtl";const gap=6;const{offsetHeight:h,offsetWidth:w}=el;const below=window.innerHeight-rect.bottom;const top=below<h+gap&&rect.top>h+gap?rect.top-h-gap:rect.bottom+gap;let left=rtl?rect.right-w:rect.left;left=Math.max(8,Math.min(left,window.innerWidth-w-8));el.style.top=`${top+window.scrollY}px`;el.style.left=`${left+window.scrollX}px`}function createSlashSuggestion(){return{items:({query})=>!query?SLASH_ITEMS:SLASH_ITEMS.filter(i=>i.title.includes(query)||i.icon.toLowerCase().includes(query.toLowerCase())),render:()=>{let component=null;let host=null;const reposition=clientRect=>{const rect=clientRect?.();if(host&&rect)place(host,rect)};return{onStart:props=>{component=new ReactRenderer(SlashList,{props,editor:props.editor});host=document.createElement("div");host.style.position="absolute";host.style.zIndex="60";host.appendChild(component.element);document.body.appendChild(host);reposition(props.clientRect)},onUpdate:props=>{component?.updateProps(props);reposition(props.clientRect)},onKeyDown:props=>{if(props.event.key==="Escape"){host?.remove();return true}const api=component?.ref;return api?.onKeyDown?.(props)??false},onExit:()=>{host?.remove();component?.destroy();host=null;component=null}}}}}import"react";import{mergeAttributes,Node,nodePasteRule}from"@tiptap/core";import{NodeViewWrapper,ReactNodeViewRenderer}from"@tiptap/react";import{jsx as jsx8}from"react/jsx-runtime";var TOKEN_SPAN_RE=/<span\b([^>]*)\bdata-token="([^"]+)"([^>]*)>([\s\S]*?)<\/span>/gi;var ENTITIES={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&apos;":"'"};function decode(s){return s.replace(/&(amp|lt|gt|quot|#39|apos);/g,m=>ENTITIES[m]??m)}function encode(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var MASK_OPEN="\uE000";var MASK_CLOSE="\uE001";var MASK_RE=/\uE000(\d+)\uE001/g;function fresh(re){return new RegExp(re.source,re.flags.includes("g")?re.flags:`${re.flags}g`)}function wrapTokens(html,pattern){if(!html)return html;const masked=[];const safe=html.replace(TOKEN_SPAN_RE,full=>{const i=masked.push(full)-1;return`${MASK_OPEN}${i}${MASK_CLOSE}`});const wrapped=safe.replace(fresh(pattern),raw=>`<span data-token="${encode(raw)}"></span>`);return wrapped.replace(MASK_RE,(_,i)=>masked[Number(i)])}function textToTokenHtml(text,pattern){if(!text)return"<p></p>";let out="";let cursor=0;for(const m of text.matchAll(fresh(pattern))){const at=m.index??0;if(at>cursor)out+=encode(text.slice(cursor,at));out+=`<span data-token="${encode(m[0])}"></span>`;cursor=at+m[0].length}if(cursor<text.length)out+=encode(text.slice(cursor));return`<p>${out}</p>`}function unwrapTokens(html){if(!html)return html;return html.replace(TOKEN_SPAN_RE,(_,_pre,attr)=>decode(attr))}function createTokenNode({pattern,render}){return Node.create({name:"qumraToken",group:"inline",inline:true,atom:true,selectable:true,addAttributes(){return{raw:{default:"",parseHTML:el=>el.getAttribute("data-token")??"",renderHTML:attrs=>attrs.raw?{"data-token":String(attrs.raw)}:{}}}},parseHTML(){return[{tag:"span[data-token]"}]},renderHTML({HTMLAttributes}){return["span",mergeAttributes({class:"qumra-token"},HTMLAttributes)]},renderText({node}){return String(node.attrs.raw??"")},addNodeView(){return ReactNodeViewRenderer(props=>jsx8(NodeViewWrapper,{as:"span",className:"qumra-token","data-drag-handle":void 0,children:render(String(props.node.attrs.raw??""))}))},addPasteRules(){return[nodePasteRule({find:fresh(pattern),type:this.type,getAttributes:match=>({raw:match[0]})})]}})}import{jsx as jsx9,jsxs as jsxs8}from"react/jsx-runtime";function Editor({content,onChange,placeholder,maxChars,basic,disabled,onPickImage,hideImage,locale="ar-EG",tokens,className}){const extensions=useMemo2(()=>[...contentExtensions(),Placeholder.configure({placeholder:placeholder??""}),CharacterCount2.configure(maxChars?{limit:maxChars}:{}),SlashCommands.configure({suggestion:createSlashSuggestion()}),...tokens?[createTokenNode(tokens)]:[]],[placeholder,maxChars,tokens]);const lastEmitted=useRef4("");const[initialContent]=useState6(()=>tokens?wrapTokens(content||"",tokens.pattern):content||"");const editorProps=useMemo2(()=>({attributes:{class:"qumra-tiptap",dir:"auto"},handleDrop:(view,event,_slice,moved)=>{if(moved||!event.dataTransfer?.files?.length)return false;const file=event.dataTransfer.files[0];if(!file?.type.startsWith("image/"))return false;const reader=new FileReader;reader.onload=()=>{const at=view.posAtCoords({left:event.clientX,top:event.clientY});if(!at)return;const node=view.state.schema.nodes.image.create({src:reader.result});view.dispatch(view.state.tr.insert(at.pos,node))};reader.readAsDataURL(file);return true},handlePaste:(view,event)=>{const items=event.clipboardData?.items;if(!items)return false;for(const item of Array.from(items)){if(!item.type.startsWith("image/"))continue;const file=item.getAsFile();if(!file)continue;const reader=new FileReader;reader.onload=()=>{const node=view.state.schema.nodes.image.create({src:reader.result});view.dispatch(view.state.tr.insert(view.state.selection.from,node))};reader.readAsDataURL(file);return true}return false}}),[]);const handleUpdate=({editor})=>{const html=tokens?unwrapTokens(editor.getHTML()):editor.getHTML();if(html===lastEmitted.current)return;lastEmitted.current=html;onChange(html)};return jsx9("div",{className:cn("relative","bg-surface border border-border rounded-field","focus-within:border-brand transition-colors","[&>*:first-child]:rounded-t-field",disabled&&"opacity-60 pointer-events-none",className),children:jsxs8(EditorProvider,{immediatelyRender:false,extensions,content:initialContent,onUpdate:handleUpdate,slotBefore:!disabled&&jsx9(Toolbar,{basic,onPickImage,hideImage,locale}),slotAfter:!disabled&&jsx9(EditorFooter,{maxChars}),editorProps,children:[jsx9(EditorBubbleMenu,{}),jsx9(SyncContent,{content,disabled,lastEmitted,tokens})]})})}function SyncContent({content,disabled,lastEmitted,tokens}){const{editor}=useCurrentEditor6();useEffect4(()=>{if(!editor)return;const incoming=content||"";const current=tokens?unwrapTokens(editor.getHTML()):editor.getHTML();if(incoming!==current){editor.commands.setContent(tokens?wrapTokens(incoming,tokens.pattern):incoming,{emitUpdate:false});lastEmitted.current=tokens?unwrapTokens(editor.getHTML()):editor.getHTML()}if(editor.isEditable===Boolean(disabled)){editor.setEditable(!disabled,false)}},[content,disabled,editor,lastEmitted,tokens]);return null}import{generateHTML,generateJSON}from"@tiptap/core";function emptyDoc(){return{type:"doc",content:[{type:"paragraph"}]}}function htmlToDoc(html){try{return generateJSON(html?.trim()?html:"<p></p>",contentExtensions())}catch{return emptyDoc()}}function docToHtml(doc){if(!isDoc(doc))return"";try{return generateHTML(doc,contentExtensions())}catch{return""}}function isDoc(value){return!!value&&typeof value==="object"&&!Array.isArray(value)&&value.type==="doc"}import{useEffect as useEffect5,useMemo as useMemo3,useRef as useRef5,useState as useState7}from"react";import{Extension as Extension2,Node as Node2}from"@tiptap/core";import{EditorContent,useEditor}from"@tiptap/react";import{Placeholder as Placeholder2}from"@tiptap/extension-placeholder";import{jsx as jsx10}from"react/jsx-runtime";var SIZES={sm:"min-h-9 text-ui px-3",md:"min-h-11 text-body px-3.5"};var Doc=Node2.create({name:"doc",topNode:true,content:"paragraph"});var Para=Node2.create({name:"paragraph",group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML:()=>["p",0]});var Txt=Node2.create({name:"text",group:"inline"});var SingleLine=Extension2.create({name:"qumraSingleLine",addKeyboardShortcuts(){return{Enter:()=>true,"Shift-Enter":()=>true}}});function TokenInput({value,onChange,tokens,placeholder,disabled,size="md",className,"aria-labelledby":labelledBy}){const extensions=useMemo3(()=>[Doc,Para,Txt,SingleLine,Placeholder2.configure({placeholder:placeholder??""}),...tokens?[createTokenNode(tokens)]:[]],[placeholder,tokens]);const emitted=useRef5(value);const[seed]=useState7(()=>tokens?textToTokenHtml(value,tokens.pattern):`<p>${value}</p>`);const editor=useEditor({immediatelyRender:false,editable:!disabled,extensions,content:seed,editorProps:{attributes:{class:"qumra-token-input",dir:"auto",...labelledBy?{"aria-labelledby":labelledBy}:{}}},onUpdate:({editor:e})=>{const text=e.getText();emitted.current=text;onChange(text)}},[extensions]);useEffect5(()=>{if(!editor)return;if(value===emitted.current||value===editor.getText())return;editor.commands.setContent(tokens?textToTokenHtml(value,tokens.pattern):`<p>${value}</p>`,{emitUpdate:false});emitted.current=value},[editor,value,tokens]);useEffect5(()=>{if(editor&&editor.isEditable===Boolean(disabled))editor.setEditable(!disabled,false)},[editor,disabled]);return jsx10(EditorContent,{editor,className:cn("w-full bg-surface text-ink rounded-field border transition-colors","border-border hover:border-brand focus-within:border-brand","[&_.ProseMirror]:outline-none [&_.ProseMirror]:py-2","[&_.ProseMirror_p]:m-0",SIZES[size],disabled&&"bg-bg text-muted cursor-not-allowed opacity-70",className)})}export{Editor,TokenInput,docToHtml,htmlToDoc,isDoc,textToTokenHtml,unwrapTokens,wrapTokens};
2
+ import{Tooltip}from"./chunk-HSZOC7QG.js";import{Button,Input}from"./chunk-EM4MF5B3.js";import{Modal}from"./chunk-4ZNTBLVW.js";import{cn}from"./chunk-YJ45RGS6.js";import{useEffect as useEffect4,useMemo as useMemo2,useRef as useRef4,useState as useState6}from"react";import{EditorProvider,useCurrentEditor as useCurrentEditor6}from"@tiptap/react";import{CharacterCount as CharacterCount2}from"@tiptap/extension-character-count";import{Placeholder}from"@tiptap/extension-placeholder";import StarterKit from"@tiptap/starter-kit";import{Color}from"@tiptap/extension-color";import{Highlight}from"@tiptap/extension-highlight";import Image from"@tiptap/extension-image";import ListItem from"@tiptap/extension-list-item";import{Table}from"@tiptap/extension-table";import{TableCell}from"@tiptap/extension-table-cell";import{TableHeader}from"@tiptap/extension-table-header";import{TableRow}from"@tiptap/extension-table-row";import TextAlign from"@tiptap/extension-text-align";import{TextStyle}from"@tiptap/extension-text-style";import ImageResize from"tiptap-extension-resize-image";import TextDirection from"tiptap-text-direction";function contentExtensions(){return[StarterKit.configure({bulletList:{keepMarks:true,keepAttributes:false},orderedList:{keepMarks:true,keepAttributes:false},link:{openOnClick:false,autolink:true,defaultProtocol:"https"},dropcursor:{color:"var(--color-brand)",width:2}}),TextDirection.configure({types:["heading","paragraph"],defaultDirection:"rtl"}),TextAlign.configure({types:["heading","paragraph"]}),TextStyle,Color.configure({types:[TextStyle.name,ListItem.name]}),Highlight.configure({multicolor:true}),Image.configure({inline:true}),ImageResize.configure(),Table.configure({resizable:true}),TableRow,TableHeader,TableCell]}import{useCallback,useId,useMemo,useRef}from"react";import{useCurrentEditor}from"@tiptap/react";import{BubbleMenu}from"@tiptap/react/menus";import{PluginKey}from"@tiptap/pm/state";import{Bold,Code,Highlighter,Italic,Link2,Strikethrough,Underline}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";function BubbleButton({onClick,isActive,label,children}){return jsx("button",{type:"button",onClick,"aria-label":label,"aria-pressed":isActive,className:cn("size-7 rounded-xs inline-flex items-center justify-center cursor-pointer transition-colors",isActive?"bg-brand text-white":"text-ink2 hover:bg-hover hover:text-ink"),children})}function EditorBubbleMenu(){const{editor}=useCurrentEditor();const key=useId();const pluginKey=useMemo(()=>new PluginKey(`qumraBubble${key}`),[key]);const menuRef=useRef(null);const onShow=useCallback(()=>{const el=menuRef.current;if(el)el.style.opacity="0"},[]);const onUpdate=useCallback(()=>{const el=menuRef.current;if(el)el.style.opacity="1"},[]);const scrollTarget=useMemo(()=>{if(typeof window==="undefined")return void 0;const dom=editor?.view?.dom;let node=dom?.parentElement??null;while(node){const{overflowY}=getComputedStyle(node);if(overflowY==="auto"||overflowY==="scroll")return node;node=node.parentElement}return void 0},[editor]);if(!editor)return null;const e=editor;return jsx(BubbleMenu,{editor,pluginKey,ref:el=>{menuRef.current=el},options:{placement:"top",offset:8,...scrollTarget?{scrollTarget}:{},onShow,onUpdate},shouldShow:({editor:ed,from,to})=>{if(from===to)return false;if(ed.isActive("image")||ed.isActive("codeBlock"))return false;return true},children:jsxs("div",{className:"flex items-center gap-0.5 p-1 rounded-card border border-line bg-surface shadow-pop",children:[jsx(BubbleButton,{label:"\u0639\u0631\u064A\u0636",onClick:()=>e.chain().focus().toggleBold().run(),isActive:e.isActive("bold"),children:jsx(Bold,{size:14})}),jsx(BubbleButton,{label:"\u0645\u0627\u0626\u0644",onClick:()=>e.chain().focus().toggleItalic().run(),isActive:e.isActive("italic"),children:jsx(Italic,{size:14})}),jsx(BubbleButton,{label:"\u062A\u062D\u062A\u0647 \u062E\u0637",onClick:()=>e.chain().focus().toggleUnderline().run(),isActive:e.isActive("underline"),children:jsx(Underline,{size:14})}),jsx(BubbleButton,{label:"\u064A\u062A\u0634\u0637\u0628",onClick:()=>e.chain().focus().toggleStrike().run(),isActive:e.isActive("strike"),children:jsx(Strikethrough,{size:14})}),jsx("span",{"aria-hidden":"true",className:"w-px h-5 bg-line mx-0.5"}),jsx(BubbleButton,{label:"\u0643\u0648\u062F",onClick:()=>e.chain().focus().toggleCode().run(),isActive:e.isActive("code"),children:jsx(Code,{size:14})}),jsx(BubbleButton,{label:"\u062A\u0638\u0644\u064A\u0644",onClick:()=>e.chain().focus().toggleHighlight().run(),isActive:e.isActive("highlight"),children:jsx(Highlighter,{size:14})}),jsx("span",{"aria-hidden":"true",className:"w-px h-5 bg-line mx-0.5"}),jsx(BubbleButton,{label:"\u0631\u0627\u0628\u0637",isActive:e.isActive("link"),onClick:()=>{const previous=e.getAttributes("link").href||"";const url=window.prompt("\u0631\u0627\u0628\u0637",previous);if(url===null)return;const chain=e.chain().focus().extendMarkRange("link");if(url==="")chain.unsetLink().run();else chain.setLink({href:/^https?:\/\//i.test(url)?url:`https://${url}`}).run()},children:jsx(Link2,{size:14})})]})})}import{useEffect as useEffect2,useRef as useRef3,useState as useState4}from"react";import{useCurrentEditor as useCurrentEditor5}from"@tiptap/react";import{useEffect,useRef as useRef2,useState}from"react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function useDismiss(open,close){const ref=useRef2(null);useEffect(()=>{if(!open)return;function onDown(e){if(ref.current&&!ref.current.contains(e.target))close()}function onKey(e){if(e.key==="Escape")close()}document.addEventListener("mousedown",onDown);document.addEventListener("keydown",onKey);return()=>{document.removeEventListener("mousedown",onDown);document.removeEventListener("keydown",onKey)}},[open,close]);return ref}var PANEL="absolute z-50 top-[calc(100%+6px)] start-0 bg-surface border border-line rounded-card shadow-panel overflow-clip animate-[fade-in_.14s_ease-out]";function Popover({trigger,children,width,className}){const[open,setOpen]=useState(false);const ref=useDismiss(open,()=>setOpen(false));return jsxs2("div",{ref,className:cn("relative flex",className),children:[trigger({open,toggle:()=>setOpen(v=>!v)}),open&&jsx2("div",{className:cn(PANEL,width??"w-56"),children:children({close:()=>setOpen(false)})})]})}function MenuItem({onClick,icon,children,danger,active}){return jsxs2("button",{type:"button",onClick,className:cn("w-full px-3 py-2 flex items-center gap-2.5 text-start text-ui cursor-pointer transition-colors",danger?"text-red hover:bg-red-bg":"text-ink2 hover:bg-hover",active&&"bg-soft text-brand-ink font-bold"),children:[icon,jsx2("span",{className:"flex-1 min-w-0 truncate",children})]})}function MenuSeparator(){return jsx2("span",{"aria-hidden":"true",className:"block h-px bg-line my-1"})}function ToolbarButton({onClick,isActive,disabled,tooltip,shortcut,children}){return jsx2(Tooltip,{content:jsxs2("span",{className:"flex items-center gap-2",children:[tooltip,shortcut&&jsx2("kbd",{dir:"ltr",className:"px-1 py-px rounded-xs bg-white/15 text-micro font-mono",children:shortcut})]}),children:jsx2("button",{type:"button",onClick,disabled,"aria-label":tooltip,"aria-pressed":isActive,className:cn("size-8 rounded-sm inline-flex items-center justify-center shrink-0 cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand","disabled:opacity-40 disabled:cursor-not-allowed",isActive?"bg-soft text-brand-ink":"text-muted hover:bg-hover hover:text-ink"),children})})}function ToolbarGroup({children}){return jsx2("div",{className:"flex items-center gap-0.5 pe-1 me-1 border-e border-line last:border-e-0 last:pe-0 last:me-0",children})}function ColorGrid({colors,current,onPick,onClear,clearLabel,fallback}){return jsxs2("div",{className:"p-3 flex flex-col gap-2.5",children:[jsx2("div",{className:"grid grid-cols-4 gap-1.5",children:colors.map(color=>jsx2("button",{type:"button",onClick:()=>onPick(color),"aria-label":color,style:{background:color},className:cn("size-8 rounded-sm border cursor-pointer transition-transform hover:scale-110",current.toLowerCase()===color.toLowerCase()?"border-ink ring-2 ring-brand":"border-line")},color))}),jsxs2("div",{className:"flex items-center gap-2.5 pt-2.5 border-t border-line",children:[jsx2("input",{type:"color",value:current||fallback,onChange:e=>onPick(e.target.value),"aria-label":"\u0644\u0648\u0646 \u0645\u062E\u0635\u0651\u0635",className:"size-8 p-0 border-none bg-transparent cursor-pointer"}),jsx2("button",{type:"button",onClick:onClear,className:"text-caption text-muted hover:text-ink cursor-pointer transition-colors",children:clearLabel})]})]})}import{useCurrentEditor as useCurrentEditor2}from"@tiptap/react";import{AlignCenter,AlignLeft,AlignRight,Bold as BoldIcon,Code as CodeIcon,Eraser,Italic as ItalicIcon,List,ListOrdered,Minus,Quote,Redo,Strikethrough as StrikeIcon,Underline as UnderlineIcon,Undo}from"lucide-react";import{Fragment,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";function Bold2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleBold().run(),isActive:editor.isActive("bold"),tooltip:"\u0639\u0631\u064A\u0636",shortcut:"Ctrl+B",children:jsx3(BoldIcon,{size:16})})}function Italic2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleItalic().run(),isActive:editor.isActive("italic"),tooltip:"\u0645\u0627\u0626\u0644",shortcut:"Ctrl+I",children:jsx3(ItalicIcon,{size:16})})}function Underline2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleUnderline().run(),isActive:editor.isActive("underline"),tooltip:"\u062A\u062D\u062A\u0647 \u062E\u0637",shortcut:"Ctrl+U",children:jsx3(UnderlineIcon,{size:16})})}function Strikethrough2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleStrike().run(),isActive:editor.isActive("strike"),tooltip:"\u064A\u062A\u0634\u0637\u0628",shortcut:"Ctrl+Shift+S",children:jsx3(StrikeIcon,{size:16})})}function Code2(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleCode().run(),isActive:editor.isActive("code"),tooltip:"\u0643\u0648\u062F",shortcut:"Ctrl+E",children:jsx3(CodeIcon,{size:16})})}function BulletList(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleBulletList().run(),isActive:editor.isActive("bulletList"),tooltip:"\u0642\u0627\u0626\u0645\u0629 \u0646\u0642\u0637\u064A\u0629",shortcut:"Ctrl+Shift+8",children:jsx3(List,{size:16})})}function OrderedList(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleOrderedList().run(),isActive:editor.isActive("orderedList"),tooltip:"\u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0642\u0651\u0645\u0629",shortcut:"Ctrl+Shift+7",children:jsx3(ListOrdered,{size:16})})}function BlockQuote(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().toggleBlockquote().run(),isActive:editor.isActive("blockquote"),tooltip:"\u0627\u0642\u062A\u0628\u0627\u0633",shortcut:"Ctrl+Shift+B",children:jsx3(Quote,{size:16})})}function HorizontalRule(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().setHorizontalRule().run(),tooltip:"\u0641\u0627\u0635\u0644 \u0623\u0641\u0642\u064A",children:jsx3(Minus,{size:16})})}function ClearMarks(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().unsetAllMarks().run(),tooltip:"\u0645\u0633\u062D \u0627\u0644\u062A\u0646\u0633\u064A\u0642",children:jsx3(Eraser,{size:16})})}function UndoRedo(){const{editor}=useCurrentEditor2();if(!editor)return null;return jsxs3(Fragment,{children:[jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().undo().run(),disabled:!editor.can().chain().focus().undo().run(),tooltip:"\u062A\u0631\u0627\u062C\u0639",shortcut:"Ctrl+Z",children:jsx3(Undo,{size:16})}),jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().redo().run(),disabled:!editor.can().chain().focus().redo().run(),tooltip:"\u0625\u0639\u0627\u062F\u0629",shortcut:"Ctrl+Y",children:jsx3(Redo,{size:16})})]})}function Alignment(){const{editor}=useCurrentEditor2();if(!editor)return null;const items=[{key:"right",tooltip:"\u0645\u062D\u0627\u0630\u0627\u0629 \u064A\u0645\u064A\u0646",Icon:AlignRight},{key:"center",tooltip:"\u062A\u0648\u0633\u064A\u0637",Icon:AlignCenter},{key:"left",tooltip:"\u0645\u062D\u0627\u0630\u0627\u0629 \u0634\u0645\u0627\u0644",Icon:AlignLeft}];return jsx3(Fragment,{children:items.map(({key,tooltip,Icon})=>jsx3(ToolbarButton,{onClick:()=>editor.chain().focus().setTextAlign(key).run(),isActive:editor.isActive({textAlign:key}),disabled:!editor.can().chain().focus().setTextAlign(key).run(),tooltip,children:jsx3(Icon,{size:16})},key))})}function CharacterCount({maxChars}){const{editor}=useCurrentEditor2();if(!editor)return null;const chars=editor.storage.characterCount?.characters()??0;const words=editor.storage.characterCount?.words()??0;const over=maxChars?chars>maxChars:false;const near=maxChars?chars>maxChars*.9:false;return jsxs3("span",{className:cn("flex items-center gap-2 text-caption select-none",over?"text-red font-bold":near?"text-amber-ink font-bold":"text-muted2"),children:[jsxs3("span",{"data-num":true,children:[chars,maxChars?`/${maxChars}`:""," \u062D\u0631\u0641"]}),jsx3("span",{"aria-hidden":"true",className:"text-line",children:"|"}),jsxs3("span",{"data-num":true,children:[words," \u0643\u0644\u0645\u0629"]})]})}import{useState as useState2}from"react";import{useCurrentEditor as useCurrentEditor3}from"@tiptap/react";import{CalendarClock,ChevronDown,Columns,Highlighter as Highlighter2,Image as ImageIcon,Link2 as Link22,Merge,Palette,Plus,Rows,Split,Table as TableIcon,Trash2}from"lucide-react";import{Fragment as Fragment2,jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";var HEADINGS=[{level:0,label:"\u0646\u0635 \u0639\u0627\u062F\u064A",size:"text-body"},{level:1,label:"\u0639\u0646\u0648\u0627\u0646 \u0661",size:"text-h2"},{level:2,label:"\u0639\u0646\u0648\u0627\u0646 \u0662",size:"text-h3"},{level:3,label:"\u0639\u0646\u0648\u0627\u0646 \u0663",size:"text-h4"},{level:4,label:"\u0639\u0646\u0648\u0627\u0646 \u0664",size:"text-lead"},{level:5,label:"\u0639\u0646\u0648\u0627\u0646 \u0665",size:"text-body"},{level:6,label:"\u0639\u0646\u0648\u0627\u0646 \u0666",size:"text-ui"}];function HeadingSelector(){const{editor}=useCurrentEditor3();if(!editor)return null;const current=HEADINGS.find(h=>h.level===0?editor.isActive("paragraph"):editor.isActive("heading",{level:h.level}))??HEADINGS[0];return jsx4(Popover,{width:"w-48",trigger:({open,toggle})=>jsxs4("button",{type:"button",onClick:toggle,"aria-haspopup":"menu","aria-expanded":open,className:cn("h-8 px-2.5 rounded-sm inline-flex items-center gap-1.5 text-ui font-bold cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",open?"bg-soft text-brand-ink":"text-ink2 hover:bg-hover"),children:[jsx4("span",{className:"truncate max-w-24",children:current.label}),jsx4(ChevronDown,{size:14,className:cn("shrink-0 transition-transform",open&&"rotate-180")})]}),children:({close})=>jsx4("div",{role:"menu",className:"py-1",children:HEADINGS.map(h=>{const active=h.level===0?editor.isActive("paragraph"):editor.isActive("heading",{level:h.level});return jsx4("button",{type:"button",role:"menuitem",onClick:()=>{if(h.level===0)editor.chain().focus().setParagraph().run();else editor.chain().focus().toggleHeading({level:h.level}).run();close()},className:cn("w-full px-3 py-2 flex items-center justify-between gap-3 text-start cursor-pointer transition-colors",active?"bg-soft text-brand-ink":"text-ink2 hover:bg-hover"),children:jsx4("span",{className:cn(h.size,active?"font-extrabold":"font-bold"),children:h.label})},h.level)})})})}function normalizeUrl(url){const t=url.trim();if(!t)return"";if(/^(https?:\/\/|mailto:|#)/i.test(t))return t;return`https://${t}`}function Link(){const{editor}=useCurrentEditor3();const[open,setOpen]=useState2(false);const[url,setUrl]=useState2("");if(!editor)return null;function apply(){const chain=editor.chain().focus().extendMarkRange("link");if(url.trim()==="")chain.unsetLink().run();else chain.setLink({href:normalizeUrl(url)}).run();setOpen(false)}return jsxs4(Fragment2,{children:[jsx4(ToolbarButton,{onClick:()=>{setUrl(editor.getAttributes("link").href||"");setOpen(true)},isActive:editor.isActive("link"),tooltip:"\u0631\u0627\u0628\u0637",shortcut:"Ctrl+K",children:jsx4(Link22,{size:16})}),jsx4(Modal,{open,onClose:()=>setOpen(false),title:"\u0625\u0636\u0627\u0641\u0629 \u0631\u0627\u0628\u0637",description:"\u0633\u064A\u0628\u0647 \u0641\u0627\u0636\u064A \u0648\u0627\u0645\u0633\u062D \u0639\u0634\u0627\u0646 \u062A\u0634\u064A\u0644 \u0627\u0644\u0631\u0627\u0628\u0637.",size:"sm",footer:jsxs4(Fragment2,{children:[jsx4(Button,{variant:"outline",onClick:()=>setOpen(false),children:"\u0625\u0644\u063A\u0627\u0621"}),jsx4(Button,{onClick:apply,children:url.trim()?"\u0623\u0636\u0641":"\u0634\u064A\u0644 \u0627\u0644\u0631\u0627\u0628\u0637"})]}),children:jsx4(Input,{label:"\u0627\u0644\u0639\u0646\u0648\u0627\u0646",dir:"ltr",placeholder:"example.com",value:url,onChange:e=>setUrl(e.target.value),onKeyDown:e=>e.key==="Enter"&&apply()})})]})}function ImageTool({onPick}){const{editor}=useCurrentEditor3();const[open,setOpen]=useState2(false);const[src,setSrc]=useState2("");if(!editor)return null;const insert=url=>editor.chain().focus().setImage({src:url}).run();return jsxs4(Fragment2,{children:[jsx4(ToolbarButton,{onClick:()=>onPick?onPick(insert):setOpen(true),isActive:editor.isActive("image"),tooltip:"\u0635\u0648\u0631\u0629",children:jsx4(ImageIcon,{size:16})}),!onPick&&jsx4(Modal,{open,onClose:()=>setOpen(false),title:"\u0625\u062F\u0631\u0627\u062C \u0635\u0648\u0631\u0629",size:"sm",footer:jsxs4(Fragment2,{children:[jsx4(Button,{variant:"outline",onClick:()=>setOpen(false),children:"\u0625\u0644\u063A\u0627\u0621"}),jsx4(Button,{disabled:!src.trim(),onClick:()=>{insert(src.trim());setSrc("");setOpen(false)},children:"\u0623\u062F\u0631\u062C"})]}),children:jsx4(Input,{label:"\u0631\u0627\u0628\u0637 \u0627\u0644\u0635\u0648\u0631\u0629",dir:"ltr",placeholder:"https://\u2026",value:src,onChange:e=>setSrc(e.target.value),hint:"\u0648\u062A\u0642\u062F\u0631 \u0643\u0645\u0627\u0646 \u062A\u0633\u062D\u0628 \u0635\u0648\u0631\u0629 \u0648\u062A\u0641\u0644\u062A\u0647\u0627 \u062C\u0648\u0651\u0647 \u0627\u0644\u0645\u062D\u0631\u0631 \u0645\u0628\u0627\u0634\u0631\u0629\u064B."})})]})}function TableTool(){const{editor}=useCurrentEditor3();if(!editor)return null;const inTable=editor.isActive("table");return jsx4(Popover,{width:"w-56",trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:inTable||open,tooltip:"\u062C\u062F\u0648\u0644",children:jsx4(TableIcon,{size:16})}),children:({close})=>{const run=fn=>()=>{fn();close()};return jsxs4("div",{role:"menu",className:"py-1",children:[jsx4(MenuItem,{icon:jsx4(Plus,{size:14}),onClick:run(()=>editor.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:true}).run()),children:"\u0623\u062F\u0631\u062C \u062C\u062F\u0648\u0644 \u0663\xD7\u0663"}),inTable&&jsxs4(Fragment2,{children:[jsx4(MenuSeparator,{}),jsx4(MenuItem,{icon:jsx4(Rows,{size:14}),onClick:run(()=>editor.chain().focus().addRowBefore().run()),children:"\u0635\u0641 \u0642\u0628\u0644"}),jsx4(MenuItem,{icon:jsx4(Rows,{size:14}),onClick:run(()=>editor.chain().focus().addRowAfter().run()),children:"\u0635\u0641 \u0628\u0639\u062F"}),jsx4(MenuItem,{danger:true,icon:jsx4(Trash2,{size:14}),onClick:run(()=>editor.chain().focus().deleteRow().run()),children:"\u0627\u062D\u0630\u0641 \u0627\u0644\u0635\u0641"}),jsx4(MenuSeparator,{}),jsx4(MenuItem,{icon:jsx4(Columns,{size:14}),onClick:run(()=>editor.chain().focus().addColumnBefore().run()),children:"\u0639\u0645\u0648\u062F \u0642\u0628\u0644"}),jsx4(MenuItem,{icon:jsx4(Columns,{size:14}),onClick:run(()=>editor.chain().focus().addColumnAfter().run()),children:"\u0639\u0645\u0648\u062F \u0628\u0639\u062F"}),jsx4(MenuItem,{danger:true,icon:jsx4(Trash2,{size:14}),onClick:run(()=>editor.chain().focus().deleteColumn().run()),children:"\u0627\u062D\u0630\u0641 \u0627\u0644\u0639\u0645\u0648\u062F"}),jsx4(MenuSeparator,{}),jsx4(MenuItem,{icon:jsx4(Merge,{size:14}),onClick:run(()=>editor.chain().focus().mergeCells().run()),children:"\u0627\u062F\u0645\u062C \u0627\u0644\u062E\u0644\u0627\u064A\u0627"}),jsx4(MenuItem,{icon:jsx4(Split,{size:14}),onClick:run(()=>editor.chain().focus().splitCell().run()),children:"\u0627\u0642\u0633\u0645 \u0627\u0644\u062E\u0644\u064A\u0629"}),jsx4(MenuSeparator,{}),jsx4(MenuItem,{danger:true,icon:jsx4(Trash2,{size:14}),onClick:run(()=>editor.chain().focus().deleteTable().run()),children:"\u0627\u062D\u0630\u0641 \u0627\u0644\u062C\u062F\u0648\u0644"})]})]})}})}var TEXT_COLORS=["#000000","#434343","#666666","#999999","#E03131","#C2255C","#9C36B5","#6741D9","#3B5BDB","#1971C2","#0C8599","#099268","#2F9E44","#66A80F","#F08C00","#E8590C"];var HIGHLIGHT_COLORS=["#FBBF24","#F87171","#FB923C","#A78BFA","#60A5FA","#34D399","#F472B6","#2DD4BF","#FCD34D","#FCA5A5","#FDBA74","#C4B5FD","#93C5FD","#6EE7B7","#F9A8D4","#99F6E4"];function ColorTool(){const{editor}=useCurrentEditor3();if(!editor)return null;const current=editor.getAttributes("textStyle").color||"";return jsx4(Popover,{trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:open,tooltip:"\u0644\u0648\u0646 \u0627\u0644\u0646\u0635",children:jsxs4("span",{className:"flex flex-col items-center gap-0.5",children:[jsx4(Palette,{size:16,style:current?{color:current}:void 0}),jsx4("span",{"aria-hidden":"true",className:"w-4 h-0.5 rounded-full",style:{background:current||"currentColor"}})]})}),children:({close})=>jsx4(ColorGrid,{colors:TEXT_COLORS,current,fallback:"#000000",clearLabel:"\u0634\u064A\u0644 \u0627\u0644\u0644\u0648\u0646",onPick:c=>{editor.chain().focus().setColor(c).run();close()},onClear:()=>{editor.chain().focus().unsetColor().run();close()}})})}function HighlightTool(){const{editor}=useCurrentEditor3();if(!editor)return null;const current=editor.getAttributes("highlight").color||"";return jsx4(Popover,{trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:editor.isActive("highlight")||open,tooltip:"\u062A\u0638\u0644\u064A\u0644",children:jsxs4("span",{className:"flex flex-col items-center gap-0.5",children:[jsx4(Highlighter2,{size:16}),jsx4("span",{"aria-hidden":"true",className:"w-4 h-0.5 rounded-full",style:{background:current||"transparent"}})]})}),children:({close})=>jsx4(ColorGrid,{colors:HIGHLIGHT_COLORS,current,fallback:"#FBBF24",clearLabel:"\u0634\u064A\u0644 \u0627\u0644\u062A\u0638\u0644\u064A\u0644",onPick:c=>{editor.chain().focus().toggleHighlight({color:c}).run();close()},onClear:()=>{editor.chain().focus().unsetHighlight().run();close()}})})}var DATE_FORMATS=[{label:"\u0663\u0661 \u064A\u0648\u0644\u064A\u0648 \u0662\u0660\u0662\u0666",opts:{day:"numeric",month:"long",year:"numeric"}},{label:"\u0663\u0661 \u064A\u0648\u0644 \u0662\u0660\u0662\u0666",opts:{day:"numeric",month:"short",year:"numeric"}},{label:"\u0627\u0644\u062C\u0645\u0639\u0629\u060C \u0663\u0661 \u064A\u0648\u0644\u064A\u0648",opts:{weekday:"long",day:"numeric",month:"long"}},{label:"\u0662\u0660\u0662\u0666/\u0660\u0667/\u0663\u0661",opts:{year:"numeric",month:"2-digit",day:"2-digit"}},{label:"\u0660\u0662:\u0665\u0661 \u0635",opts:{hour:"2-digit",minute:"2-digit"}},{label:"\u0660\u0662:\u0665\u0661:\u0663\u0660 \u0635",opts:{hour:"2-digit",minute:"2-digit",second:"2-digit"}}];function DateTime({locale="ar-EG"}){const{editor}=useCurrentEditor3();if(!editor)return null;return jsx4(Popover,{width:"w-56",trigger:({open,toggle})=>jsx4(ToolbarButton,{onClick:toggle,isActive:open,tooltip:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A",children:jsx4(CalendarClock,{size:16})}),children:({close})=>jsx4("div",{role:"menu",className:"py-1",children:DATE_FORMATS.map(f=>{const text=new Intl.DateTimeFormat(locale,f.opts).format(new Date);return jsx4(MenuItem,{onClick:()=>{editor.chain().focus().insertContent(text).run();close()},children:text},f.label)})})})}import{useCallback as useCallback2,useState as useState3}from"react";import{useCurrentEditor as useCurrentEditor4}from"@tiptap/react";import{ChevronDown as ChevronDown2,ChevronUp,Replace,Search}from"lucide-react";import{Fragment as Fragment3,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function FindReplace(){const{editor}=useCurrentEditor4();const[term,setTerm]=useState3("");const[replacement,setReplacement]=useState3("");const[matches,setMatches]=useState3([]);const[index,setIndex]=useState3(0);const jump=useCallback2(m=>editor?.chain().setTextSelection(m).scrollIntoView().run(),[editor]);const find=useCallback2(value=>{if(!editor||!value.trim()){setMatches([]);setIndex(0);return}const found=[];const needle=value.toLowerCase();editor.state.doc.descendants((node,pos)=>{if(!node.isText)return;const text=node.text?.toLowerCase()??"";let at=text.indexOf(needle);while(at!==-1){found.push({from:pos+at,to:pos+at+value.length});at=text.indexOf(needle,at+1)}});setMatches(found);setIndex(0);if(found[0])jump(found[0])},[editor,jump]);if(!editor)return null;const step=by=>{if(matches.length===0)return;const next=(index+by+matches.length)%matches.length;setIndex(next);jump(matches[next])};const replaceOne=()=>{const m=matches[index];if(!m)return;editor.chain().focus().setTextSelection(m).insertContent(replacement).run();find(term)};const replaceAll=()=>{if(matches.length===0)return;const chain=editor.chain().focus();for(const m of[...matches].sort((a,b)=>b.from-a.from)){chain.setTextSelection(m).insertContent(replacement)}chain.run();find(term)};return jsx5(Popover,{width:"w-72",trigger:({open,toggle})=>jsx5(ToolbarButton,{onClick:toggle,isActive:open,tooltip:"\u0628\u062D\u062B \u0648\u0627\u0633\u062A\u0628\u062F\u0627\u0644",shortcut:"Ctrl+H",children:jsx5(Search,{size:16})}),children:()=>jsxs5("div",{className:"p-3 flex flex-col gap-2.5",children:[jsxs5("div",{className:"flex items-end gap-1.5",children:[jsx5(Input,{autoFocus:true,size:"sm",label:"\u0627\u0628\u062D\u062B \u0639\u0646",hideLabel:true,placeholder:"\u0627\u0628\u062D\u062B \u0639\u0646\u2026",value:term,wrapperClassName:"flex-1 min-w-0",onChange:e=>{setTerm(e.target.value);find(e.target.value)},onKeyDown:e=>{if(e.key!=="Enter")return;e.preventDefault();step(e.shiftKey?-1:1)}}),jsx5(Button,{size:"sm",variant:"outline",iconOnly:true,"aria-label":"\u0627\u0644\u0633\u0627\u0628\u0642",disabled:matches.length===0,onClick:()=>step(-1),icon:jsx5(ChevronUp,{size:14})}),jsx5(Button,{size:"sm",variant:"outline",iconOnly:true,"aria-label":"\u0627\u0644\u062A\u0627\u0644\u064A",disabled:matches.length===0,onClick:()=>step(1),icon:jsx5(ChevronDown2,{size:14})})]}),term.trim()&&jsx5("span",{className:"text-micro text-muted2","aria-live":"polite",children:matches.length>0?jsxs5(Fragment3,{children:[jsx5("span",{"data-num":true,children:index+1})," \u0645\u0646 ",jsx5("span",{"data-num":true,children:matches.length})]}):"\u0645\u0627\u0641\u064A\u0634 \u0646\u062A\u0627\u064A\u062C"}),jsxs5("div",{className:"flex items-end gap-1.5",children:[jsx5(Input,{size:"sm",label:"\u0627\u0633\u062A\u0628\u062F\u0644 \u0628\u0640",hideLabel:true,placeholder:"\u0627\u0633\u062A\u0628\u062F\u0644 \u0628\u0640\u2026",value:replacement,wrapperClassName:"flex-1 min-w-0",onChange:e=>setReplacement(e.target.value),onKeyDown:e=>{if(e.key==="Enter"){e.preventDefault();replaceOne()}}}),jsx5(Button,{size:"sm",variant:"outline",iconOnly:true,"aria-label":"\u0627\u0633\u062A\u0628\u062F\u0644",disabled:matches.length===0,onClick:replaceOne,icon:jsx5(Replace,{size:14})})]}),jsx5(Button,{size:"sm",variant:"soft",block:true,disabled:matches.length===0,onClick:replaceAll,children:"\u0627\u0633\u062A\u0628\u062F\u0644 \u0627\u0644\u0643\u0644"})]})})}import{jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";function useEditorTick(){const[,setTick]=useState4(0);const{editor}=useCurrentEditor5();const raf=useRef3(0);useEffect2(()=>{if(!editor)return;const bump=()=>{cancelAnimationFrame(raf.current);raf.current=requestAnimationFrame(()=>setTick(t=>t+1))};editor.on("selectionUpdate",bump);editor.on("transaction",bump);return()=>{cancelAnimationFrame(raf.current);editor.off("selectionUpdate",bump);editor.off("transaction",bump)}},[editor])}function Toolbar({basic,onPickImage,hideImage,locale}){useEditorTick();const{editor}=useCurrentEditor5();if(!editor)return null;if(basic){return jsxs6("div",{className:"w-full border-b border-line px-1.5 py-1 flex flex-wrap items-center gap-0.5",children:[jsx6(ToolbarGroup,{children:jsx6(UndoRedo,{})}),jsx6(ToolbarGroup,{children:jsx6(HeadingSelector,{})}),jsxs6(ToolbarGroup,{children:[jsx6(Bold2,{}),jsx6(Italic2,{}),jsx6(Underline2,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(BulletList,{}),jsx6(OrderedList,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(Link,{}),!hideImage&&jsx6(ImageTool,{onPick:onPickImage}),jsx6(ColorTool,{})]})]})}return jsxs6("div",{className:"w-full border-b border-line px-1.5 py-1.5 flex flex-wrap items-center gap-y-1",children:[jsx6(ToolbarGroup,{children:jsx6(UndoRedo,{})}),jsx6(ToolbarGroup,{children:jsx6(HeadingSelector,{})}),jsxs6(ToolbarGroup,{children:[jsx6(Bold2,{}),jsx6(Italic2,{}),jsx6(Underline2,{}),jsx6(Strikethrough2,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(BulletList,{}),jsx6(OrderedList,{}),jsx6(BlockQuote,{})]}),jsx6(ToolbarGroup,{children:jsx6(Alignment,{})}),jsxs6(ToolbarGroup,{children:[jsx6(Link,{}),!hideImage&&jsx6(ImageTool,{onPick:onPickImage}),jsx6(TableTool,{}),jsx6(DateTime,{locale})]}),jsxs6(ToolbarGroup,{children:[jsx6(ColorTool,{}),jsx6(HighlightTool,{})]}),jsxs6(ToolbarGroup,{children:[jsx6(Code2,{}),jsx6(HorizontalRule,{}),jsx6(ClearMarks,{}),jsx6(FindReplace,{})]})]})}function EditorFooter({maxChars}){return jsx6("div",{className:"border-t border-line px-3 py-1.5 flex justify-end",children:jsx6(CharacterCount,{maxChars})})}import{forwardRef,useEffect as useEffect3,useImperativeHandle,useState as useState5}from"react";import{Extension}from"@tiptap/core";import{PluginKey as PluginKey2}from"@tiptap/pm/state";import{ReactRenderer}from"@tiptap/react";import Suggestion from"@tiptap/suggestion";import{jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";var SLASH_ITEMS=[{title:"\u0639\u0646\u0648\u0627\u0646 \u0643\u0628\u064A\u0631",hint:"H1",icon:"H1",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHeading({level:1}).run()},{title:"\u0639\u0646\u0648\u0627\u0646 \u0645\u062A\u0648\u0633\u0637",hint:"H2",icon:"H2",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHeading({level:2}).run()},{title:"\u0639\u0646\u0648\u0627\u0646 \u0635\u063A\u064A\u0631",hint:"H3",icon:"H3",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHeading({level:3}).run()},{title:"\u0642\u0627\u0626\u0645\u0629 \u0646\u0642\u0637\u064A\u0629",icon:"\u2022",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleBulletList().run()},{title:"\u0642\u0627\u0626\u0645\u0629 \u0645\u0631\u0642\u0651\u0645\u0629",icon:"\u0661.",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleOrderedList().run()},{title:"\u0627\u0642\u062A\u0628\u0627\u0633",icon:"\u275D",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleBlockquote().run()},{title:"\u0628\u0644\u0648\u0643 \u0643\u0648\u062F",icon:"</>",command:({editor,range})=>editor.chain().focus().deleteRange(range).toggleCodeBlock().run()},{title:"\u062C\u062F\u0648\u0644",hint:"\u0663\xD7\u0663",icon:"\u229E",command:({editor,range})=>editor.chain().focus().deleteRange(range).insertTable({rows:3,cols:3,withHeaderRow:true}).run()},{title:"\u0641\u0627\u0635\u0644 \u0623\u0641\u0642\u064A",icon:"\u2500",command:({editor,range})=>editor.chain().focus().deleteRange(range).setHorizontalRule().run()}];var SlashList=forwardRef(function SlashList2({items,command},ref){const[active,setActive]=useState5(0);useEffect3(()=>setActive(0),[items]);useImperativeHandle(ref,()=>({onKeyDown:({event})=>{if(event.key==="ArrowUp"){setActive(i=>i<=0?items.length-1:i-1);return true}if(event.key==="ArrowDown"){setActive(i=>i>=items.length-1?0:i+1);return true}if(event.key==="Enter"){const item=items[active];if(item)command(item);return true}return false}}));if(items.length===0)return null;return jsx7("div",{className:"w-64 max-h-72 overflow-y-auto rounded-card border border-line bg-surface shadow-pop py-1 animate-[fade-in_.12s_ease-out]",children:items.map((item,i)=>jsxs7("button",{type:"button",onMouseEnter:()=>setActive(i),onClick:()=>command(item),className:cn("w-full px-3 py-2 flex items-center gap-3 text-start cursor-pointer transition-colors",i===active?"bg-soft text-brand-ink":"text-ink2 hover:bg-hover"),children:[jsx7("span",{"aria-hidden":"true",className:"size-7 shrink-0 rounded-sm bg-bg border border-line flex items-center justify-center text-micro font-extrabold",children:item.icon}),jsx7("span",{className:"flex-1 min-w-0 text-ui font-bold truncate",children:item.title}),item.hint&&jsx7("span",{dir:"ltr",className:"text-micro text-muted2 shrink-0",children:item.hint})]},item.title))})});var SlashCommandsPluginKey=new PluginKey2("qumraSlashCommands");var SlashCommands=Extension.create({name:"qumraSlashCommands",addOptions(){return{suggestion:{char:"/",pluginKey:SlashCommandsPluginKey,command:({editor,range,props})=>{props.command({editor,range})}}}},addProseMirrorPlugins(){return[Suggestion({editor:this.editor,...this.options.suggestion})]}});function place(el,rect){const rtl=getComputedStyle(document.documentElement).direction==="rtl";const gap=6;const{offsetHeight:h,offsetWidth:w}=el;const below=window.innerHeight-rect.bottom;const top=below<h+gap&&rect.top>h+gap?rect.top-h-gap:rect.bottom+gap;let left=rtl?rect.right-w:rect.left;left=Math.max(8,Math.min(left,window.innerWidth-w-8));el.style.top=`${top+window.scrollY}px`;el.style.left=`${left+window.scrollX}px`}function createSlashSuggestion(){return{items:({query})=>!query?SLASH_ITEMS:SLASH_ITEMS.filter(i=>i.title.includes(query)||i.icon.toLowerCase().includes(query.toLowerCase())),render:()=>{let component=null;let host=null;const reposition=clientRect=>{const rect=clientRect?.();if(host&&rect)place(host,rect)};return{onStart:props=>{component=new ReactRenderer(SlashList,{props,editor:props.editor});host=document.createElement("div");host.style.position="absolute";host.style.zIndex="60";host.appendChild(component.element);document.body.appendChild(host);reposition(props.clientRect)},onUpdate:props=>{component?.updateProps(props);reposition(props.clientRect)},onKeyDown:props=>{if(props.event.key==="Escape"){host?.remove();return true}const api=component?.ref;return api?.onKeyDown?.(props)??false},onExit:()=>{host?.remove();component?.destroy();host=null;component=null}}}}}import"react";import{mergeAttributes,Node,nodePasteRule}from"@tiptap/core";import{NodeViewWrapper,ReactNodeViewRenderer}from"@tiptap/react";import{jsx as jsx8}from"react/jsx-runtime";var TOKEN_SPAN_RE=/<span\b([^>]*)\bdata-token="([^"]+)"([^>]*)>([\s\S]*?)<\/span>/gi;var ENTITIES={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&apos;":"'"};function decode(s){return s.replace(/&(amp|lt|gt|quot|#39|apos);/g,m=>ENTITIES[m]??m)}function encode(s){return s.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var MASK_OPEN="\uE000";var MASK_CLOSE="\uE001";var MASK_RE=/\uE000(\d+)\uE001/g;function fresh(re){return new RegExp(re.source,re.flags.includes("g")?re.flags:`${re.flags}g`)}function wrapTokens(html,pattern){if(!html)return html;const masked=[];const safe=html.replace(TOKEN_SPAN_RE,full=>{const i=masked.push(full)-1;return`${MASK_OPEN}${i}${MASK_CLOSE}`});const wrapped=safe.replace(fresh(pattern),raw=>`<span data-token="${encode(raw)}"></span>`);return wrapped.replace(MASK_RE,(_,i)=>masked[Number(i)])}function textToTokenHtml(text,pattern){if(!text)return"<p></p>";let out="";let cursor=0;for(const m of text.matchAll(fresh(pattern))){const at=m.index??0;if(at>cursor)out+=encode(text.slice(cursor,at));out+=`<span data-token="${encode(m[0])}"></span>`;cursor=at+m[0].length}if(cursor<text.length)out+=encode(text.slice(cursor));return`<p>${out}</p>`}function unwrapTokens(html){if(!html)return html;return html.replace(TOKEN_SPAN_RE,(_,_pre,attr)=>decode(attr))}function createTokenNode({pattern,render}){return Node.create({name:"qumraToken",group:"inline",inline:true,atom:true,selectable:true,addAttributes(){return{raw:{default:"",parseHTML:el=>el.getAttribute("data-token")??"",renderHTML:attrs=>attrs.raw?{"data-token":String(attrs.raw)}:{}}}},parseHTML(){return[{tag:"span[data-token]"}]},renderHTML({HTMLAttributes}){return["span",mergeAttributes({class:"qumra-token"},HTMLAttributes)]},renderText({node}){return String(node.attrs.raw??"")},addNodeView(){return ReactNodeViewRenderer(props=>jsx8(NodeViewWrapper,{as:"span",className:"qumra-token","data-drag-handle":void 0,children:render(String(props.node.attrs.raw??""))}))},addPasteRules(){return[nodePasteRule({find:fresh(pattern),type:this.type,getAttributes:match=>({raw:match[0]})})]}})}import{jsx as jsx9,jsxs as jsxs8}from"react/jsx-runtime";function Editor({content,onChange,placeholder,maxChars,basic,disabled,onPickImage,hideImage,locale="ar-EG",tokens,className}){const extensions=useMemo2(()=>[...contentExtensions(),Placeholder.configure({placeholder:placeholder??""}),CharacterCount2.configure(maxChars?{limit:maxChars}:{}),SlashCommands.configure({suggestion:createSlashSuggestion()}),...tokens?[createTokenNode(tokens)]:[]],[placeholder,maxChars,tokens]);const lastEmitted=useRef4("");const[initialContent]=useState6(()=>tokens?wrapTokens(content||"",tokens.pattern):content||"");const editorProps=useMemo2(()=>({attributes:{class:"qumra-tiptap",dir:"auto"},handleDrop:(view,event,_slice,moved)=>{if(moved||!event.dataTransfer?.files?.length)return false;const file=event.dataTransfer.files[0];if(!file?.type.startsWith("image/"))return false;const reader=new FileReader;reader.onload=()=>{const at=view.posAtCoords({left:event.clientX,top:event.clientY});if(!at)return;const node=view.state.schema.nodes.image.create({src:reader.result});view.dispatch(view.state.tr.insert(at.pos,node))};reader.readAsDataURL(file);return true},handlePaste:(view,event)=>{const items=event.clipboardData?.items;if(!items)return false;for(const item of Array.from(items)){if(!item.type.startsWith("image/"))continue;const file=item.getAsFile();if(!file)continue;const reader=new FileReader;reader.onload=()=>{const node=view.state.schema.nodes.image.create({src:reader.result});view.dispatch(view.state.tr.insert(view.state.selection.from,node))};reader.readAsDataURL(file);return true}return false}}),[]);const handleUpdate=({editor})=>{const html=tokens?unwrapTokens(editor.getHTML()):editor.getHTML();if(html===lastEmitted.current)return;lastEmitted.current=html;onChange(html)};return jsx9("div",{className:cn("relative","bg-surface border border-border rounded-field","focus-within:border-brand transition-colors","[&>*:first-child]:rounded-t-field",disabled&&"opacity-60 pointer-events-none",className),children:jsxs8(EditorProvider,{immediatelyRender:false,extensions,content:initialContent,onUpdate:handleUpdate,slotBefore:!disabled&&jsx9(Toolbar,{basic,onPickImage,hideImage,locale}),slotAfter:!disabled&&jsx9(EditorFooter,{maxChars}),editorProps,children:[jsx9(EditorBubbleMenu,{}),jsx9(SyncContent,{content,disabled,lastEmitted,tokens})]})})}function SyncContent({content,disabled,lastEmitted,tokens}){const{editor}=useCurrentEditor6();useEffect4(()=>{if(!editor)return;const incoming=content||"";const current=tokens?unwrapTokens(editor.getHTML()):editor.getHTML();if(incoming!==current){editor.commands.setContent(tokens?wrapTokens(incoming,tokens.pattern):incoming,{emitUpdate:false});lastEmitted.current=tokens?unwrapTokens(editor.getHTML()):editor.getHTML()}if(editor.isEditable===Boolean(disabled)){editor.setEditable(!disabled,false)}},[content,disabled,editor,lastEmitted,tokens]);return null}import{generateHTML,generateJSON}from"@tiptap/core";function emptyDoc(){return{type:"doc",content:[{type:"paragraph"}]}}function htmlToDoc(html){try{return generateJSON(html?.trim()?html:"<p></p>",contentExtensions())}catch{return emptyDoc()}}function docToHtml(doc){if(!isDoc(doc))return"";try{return generateHTML(doc,contentExtensions())}catch{return""}}function isDoc(value){return!!value&&typeof value==="object"&&!Array.isArray(value)&&value.type==="doc"}import{useEffect as useEffect5,useMemo as useMemo3,useRef as useRef5,useState as useState7}from"react";import{Extension as Extension2,Node as Node2}from"@tiptap/core";import{EditorContent,useEditor}from"@tiptap/react";import{Placeholder as Placeholder2}from"@tiptap/extension-placeholder";import{jsx as jsx10}from"react/jsx-runtime";var SIZES={sm:"min-h-9 text-ui px-3",md:"min-h-11 text-body px-3.5"};var Doc=Node2.create({name:"doc",topNode:true,content:"paragraph"});var Para=Node2.create({name:"paragraph",group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML:()=>["p",0]});var Txt=Node2.create({name:"text",group:"inline"});var SingleLine=Extension2.create({name:"qumraSingleLine",addKeyboardShortcuts(){return{Enter:()=>true,"Shift-Enter":()=>true}}});function TokenInput({value,onChange,tokens,placeholder,disabled,size="md",className,"aria-labelledby":labelledBy}){const extensions=useMemo3(()=>[Doc,Para,Txt,SingleLine,Placeholder2.configure({placeholder:placeholder??""}),...tokens?[createTokenNode(tokens)]:[]],[placeholder,tokens]);const emitted=useRef5(value);const[seed]=useState7(()=>tokens?textToTokenHtml(value,tokens.pattern):`<p>${value}</p>`);const editor=useEditor({immediatelyRender:false,editable:!disabled,extensions,content:seed,editorProps:{attributes:{class:"qumra-token-input",dir:"auto",...labelledBy?{"aria-labelledby":labelledBy}:{}}},onUpdate:({editor:e})=>{const text=e.getText();emitted.current=text;onChange(text)}},[extensions]);useEffect5(()=>{if(!editor)return;if(value===emitted.current||value===editor.getText())return;editor.commands.setContent(tokens?textToTokenHtml(value,tokens.pattern):`<p>${value}</p>`,{emitUpdate:false});emitted.current=value},[editor,value,tokens]);useEffect5(()=>{if(editor&&editor.isEditable===Boolean(disabled))editor.setEditable(!disabled,false)},[editor,disabled]);return jsx10(EditorContent,{editor,className:cn("w-full bg-surface text-ink rounded-field border transition-colors","border-border hover:border-brand focus-within:border-brand","[&_.ProseMirror]:outline-none [&_.ProseMirror]:py-2","[&_.ProseMirror_p]:m-0",SIZES[size],disabled&&"bg-bg text-muted cursor-not-allowed opacity-70",className)})}export{Editor,TokenInput,docToHtml,htmlToDoc,isDoc,textToTokenHtml,unwrapTokens,wrapTokens};
package/dist/index.d.ts CHANGED
@@ -1334,10 +1334,23 @@ declare function ToastHost({ toasts, onDismiss, closeLabel, }: {
1334
1334
  * بتحطّها على العنصر الحقيقيّ لا على غلافه، لأن الغلاف مش هو اللي
1335
1335
  * بيتركّز عليه.
1336
1336
  */
1337
- declare function Tooltip({ content, children, side, }: {
1337
+ declare function Tooltip({ content, children, side, size, }: {
1338
1338
  content: ReactNode;
1339
1339
  children: ReactNode;
1340
1340
  side?: 'top' | 'bottom';
1341
+ /**
1342
+ * `sm` لكلمتين على زرّ أيقونة، و`md` لفقرة شرح.
1343
+ *
1344
+ * ── ⚠️ ليه مقاسين لا عرض حرّ ─────────────────────────────────────────
1345
+ * ٢٢٠ بكسل متوسّطة كانت على مقاس «بيحذف نهائياً». وشرح رقم في كارت
1346
+ * («الطلبات المدفوعة اللي اتسلّمت… بلا شحن ولا ضريبة») بيطلع فيها
1347
+ * خمس سطور متوسّطة — والفقرة المتوسّطة بتتقري مسنّنة، كل سطر بيبدأ من
1348
+ * مكان. فـ`md` أعرض (`max-w-xs`، ٣٢٠) وبتبدأ من أوّل السطر وبحشوة
1349
+ * أوسع: فقرة تتقري لا شارة.
1350
+ *
1351
+ * والعرض من السلّم لا رقم حرّ — نفس قاعدة ٦.
1352
+ */
1353
+ size?: 'sm' | 'md';
1341
1354
  }): react.JSX.Element;
1342
1355
 
1343
1356
  interface Option {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{ToastHost,Tooltip,useToasts}from"./chunk-V7VYOWMO.js";import{BarChart,ChoiceCards,DataTable,FunnelChart,Heatmap,Money,MoneyProvider,ShareList,Sparkline,TrendChart,currencyName,currencySymbol,isCurrency,useCurrency,useCurrencySymbol}from"./chunk-QFJSDPEB.js";import{Button,Calendar,Checkbox,DateField,DateRangePicker,Input,Radio,RadioGroup,SearchInput,Select,Switch,Textarea,daysBetween,formatDate,formatRange,presets}from"./chunk-EM4MF5B3.js";import{AudioPlayer,Avatar,Badge,Card,CardHeader,Coach,CoachProvider,Counter,PageHeader,Progress,Scrubber,Skeleton,StatCard,VideoPlayer,coachSeconds,formatTime,useAudioLevel,useCoach,useCoachOptional,useMedia}from"./chunk-JOHJNMV2.js";import{Alert,Drawer,EmptyState,Modal,Sheet,Toast}from"./chunk-4ZNTBLVW.js";import{ANIMATE_SCALE,COLOR_SCALE,CONTAINER_SCALE,DARK_TOKENS,LocaleCtx,RADIUS_SCALE,SHADOW_SCALE,TEXT_SCALE,TOKENS,TONE_SOFT,TONE_SOLID,buttonClasses,cn,toLatinDigits,useMoneyLang,useMoneyLocale,useUIText}from"./chunk-YJ45RGS6.js";import{useEffect,useRef,useState}from"react";import{Minus,Plus,Trash2}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";var ar=new Intl.NumberFormat("ar-EG");var BOX={sm:"h-8",md:"h-11",lg:"h-14"};var BTN={sm:"w-8",md:"w-11",lg:"w-14"};var NUM={sm:"text-ui w-10",md:"text-body w-14",lg:"text-h3 w-20"};var ICON={sm:14,md:16,lg:20};function NumberStepper({value,onChange,min=0,max=Infinity,step=1,size="md",unit,onRemove,disabled,label,className}){const[draft,setDraft]=useState(null);const timer=useRef(void 0);useEffect(()=>()=>clearTimeout(timer.current),[]);const atMin=value<=min;const atMax=value>=max;const showRemove=Boolean(onRemove)&&atMin;const bump=dir=>onChange(Math.min(max,Math.max(min,value+dir*step)));const latest=useRef(value);useEffect(()=>{latest.current=value},[value]);function hold(dir){let delay=400;const tick=()=>{const next=Math.min(max,Math.max(min,latest.current+dir*step));if(next===latest.current)return;onChange(next);delay=Math.max(60,delay*.72);timer.current=setTimeout(tick,delay)};timer.current=setTimeout(tick,delay)}const stop=()=>clearTimeout(timer.current);function commit(raw){setDraft(null);const n=Number(toLatinDigits(raw).replace(/[^\d.-]/g,""));if(Number.isNaN(n))return;onChange(Math.min(max,Math.max(min,n)))}const btn=dir=>{const off=disabled||(dir===1?atMax:atMin&&!showRemove);const Icon=dir===1?Plus:showRemove?Trash2:Minus;return jsx("button",{type:"button",disabled:off,"aria-label":dir===1?"\u0632\u064A\u0627\u062F\u0629":showRemove?"\u062D\u0630\u0641":"\u0646\u0642\u0635\u0627\u0646",onClick:()=>dir===-1&&showRemove?onRemove?.():bump(dir),onPointerDown:()=>!off&&!showRemove&&hold(dir),onPointerUp:stop,onPointerLeave:stop,className:cn("flex items-center justify-center shrink-0 self-stretch cursor-pointer select-none","transition-colors",BTN[size],off?"text-muted2/45 cursor-not-allowed":cn("text-ink2 hover:bg-hover active:bg-soft",showRemove&&dir===-1&&"text-danger hover:bg-red-bg")),children:jsx(Icon,{size:ICON[size],strokeWidth:2.4,"aria-hidden":"true"})})};return jsxs("div",{dir:"ltr",className:cn("inline-flex items-center rounded-field border border-line bg-surface overflow-clip","divide-x divide-line","hover:border-border","focus-within:border-brand focus-within:ring-2 focus-within:ring-brand/25","transition-[border-color,box-shadow]",BOX[size],disabled&&"opacity-60",className),children:[btn(-1),jsxs("span",{className:"flex items-center justify-center gap-1 px-1 self-stretch",children:[jsx("input",{"data-num":true,value:draft??ar.format(value),disabled,inputMode:"numeric","aria-label":label??"\u0627\u0644\u0642\u064A\u0645\u0629",onFocus:()=>setDraft(String(value)),onChange:e=>setDraft(toLatinDigits(e.target.value)),onBlur:e=>commit(e.target.value),onKeyDown:e=>e.key==="Enter"&&e.target.blur(),className:cn("bg-transparent outline-none text-center font-extrabold text-ink","disabled:text-muted2",NUM[size])}),unit&&jsx("span",{className:"text-micro text-muted2 select-none shrink-0",children:unit})]}),btn(1)]})}import{MessageSquare,Phone as PhoneIcon}from"lucide-react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function WhatsAppIcon({size=15,...rest}){return jsx2("svg",{viewBox:"0 0 24 24",width:size,height:size,fill:"currentColor","aria-hidden":"true",...rest,children:jsx2("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"})})}var DIAL={"20":{groups:[3,3,4],name:"\u0645\u0635\u0631"},"966":{groups:[2,3,4],name:"\u0627\u0644\u0633\u0639\u0648\u062F\u064A\u0629"},"971":{groups:[2,3,4],name:"\u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062A"},"965":{groups:[4,4],name:"\u0627\u0644\u0643\u0648\u064A\u062A"},"974":{groups:[4,4],name:"\u0642\u0637\u0631"},"973":{groups:[4,4],name:"\u0627\u0644\u0628\u062D\u0631\u064A\u0646"},"968":{groups:[4,4],name:"\u0639\u064F\u0645\u0627\u0646"},"962":{groups:[1,4,4],name:"\u0627\u0644\u0623\u0631\u062F\u0646"},"964":{groups:[3,3,4],name:"\u0627\u0644\u0639\u0631\u0627\u0642"},"961":{groups:[2,3,3],name:"\u0644\u0628\u0646\u0627\u0646"},"963":{groups:[3,3,3],name:"\u0633\u0648\u0631\u064A\u0627"},"970":{groups:[2,3,4],name:"\u0641\u0644\u0633\u0637\u064A\u0646"},"967":{groups:[3,3,3],name:"\u0627\u0644\u064A\u0645\u0646"},"249":{groups:[3,3,3],name:"\u0627\u0644\u0633\u0648\u062F\u0627\u0646"},"212":{groups:[3,3,3],name:"\u0627\u0644\u0645\u063A\u0631\u0628"},"213":{groups:[3,3,3],name:"\u0627\u0644\u062C\u0632\u0627\u0626\u0631"},"216":{groups:[2,3,3],name:"\u062A\u0648\u0646\u0633"},"218":{groups:[2,3,4],name:"\u0644\u064A\u0628\u064A\u0627"},"222":{groups:[2,2,2,2],name:"\u0645\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u0627"},"252":{groups:[2,3,4],name:"\u0627\u0644\u0635\u0648\u0645\u0627\u0644"},"253":{groups:[2,2,2,2],name:"\u062C\u064A\u0628\u0648\u062A\u064A"},"269":{groups:[3,4],name:"\u062C\u0632\u0631 \u0627\u0644\u0642\u0645\u0631"}};var DIALS=Object.keys(DIAL).sort((a,b)=>b.length-a.length);function parsePhone(raw,defaultDial="20"){const digits=raw.replace(/\D/g,"");let rest=digits;const intl=raw.trim().startsWith("+")||digits.startsWith("00");if(digits.startsWith("00"))rest=digits.slice(2);if(intl){for(const d of DIALS){if(rest.startsWith(d)){return{dial:d,local:rest.slice(d.length),country:DIAL[d].name}}}return{dial:"",local:rest}}const local=rest.replace(/^0/,"");return{dial:defaultDial,local,country:DIAL[defaultDial]?.name}}function join(parts,format){if(format==="spaces"||parts.length<2)return parts.join(" ");const[head,...tail]=parts;return`(${head}) ${tail.join("-")}`}function group(local,dial){const rule=DIAL[dial]?.groups;const out=[];let i=0;if(rule){for(const n of rule){if(i>=local.length)break;out.push(local.slice(i,i+n));i+=n}}while(i<local.length){out.push(local.slice(i,i+3));i+=3}return out.filter(Boolean)}var SIZE={inherit:"",sm:"text-caption",md:"text-ui"};function Phone({value,defaultDial="20",format="parens",mask,call,sms,whatsapp,size="md",className}){const{dial,local,country}=parsePhone(value,defaultDial);const e164=`+${dial}${local}`;const shown=mask?`\u2022\u2022\u2022 ${local.slice(-4)}`:dial?join(group(local,dial),format):`+${local}`;const bare=size==="inherit";return jsxs2("span",{className:cn("inline-flex items-center gap-2 min-w-0",className),children:[jsxs2("span",{dir:"ltr",className:cn("inline-flex items-baseline gap-1.5 whitespace-nowrap min-w-0",SIZE[size]),children:[dial&&!mask&&jsxs2("span",{className:cn("opacity-70",!bare&&"text-muted2 font-normal"),title:country,children:["+",dial]}),jsx2("span",{style:{unicodeBidi:"isolate",fontVariantNumeric:"tabular-nums"},className:cn("truncate",!bare&&"font-bold text-ink"),children:shown})]}),(call||sms||whatsapp)&&!mask&&jsxs2("span",{className:"inline-flex items-center gap-0.5 shrink-0",children:[call&&jsx2(Action,{href:`tel:${e164}`,label:`\u0627\u062A\u0635\u0627\u0644 \u0628\u0640${e164}`,children:jsx2(PhoneIcon,{size:14,"aria-hidden":"true"})}),sms&&jsx2(Action,{href:`sms:${e164}`,label:`\u0631\u0633\u0627\u0644\u0629 \u0646\u0635\u0651\u064A\u0629 \u0625\u0644\u0649 ${e164}`,children:jsx2(MessageSquare,{size:14,"aria-hidden":"true"})}),whatsapp&&jsx2(Action,{href:`https://wa.me/${dial}${local}`,label:`\u0648\u0627\u062A\u0633\u0627\u0628 ${e164}`,external:true,className:"hover:text-green",children:jsx2(WhatsAppIcon,{size:15})})]})]})}function Action({href,label,external,className,children}){return jsx2("a",{href,"aria-label":label,title:label,...external?{target:"_blank",rel:"noreferrer"}:{},className:cn("size-7 rounded-sm inline-flex items-center justify-center shrink-0","text-muted hover:text-brand-ink hover:bg-hover transition-colors no-underline",className),children})}import{forwardRef,useId}from"react";import{jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";var LEAD={hex:"#",url:"/"};var TechnicalInput=forwardRef(function TechnicalInput2({kind="code",className,wrapperClassName,...rest},ref){return jsx3(Input,{ref,dir:"ltr",spellCheck:false,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",inputMode:kind==="url"?"url":"text",wrapperClassName:cn("[unicode-bidi:isolate]",wrapperClassName),className:cn("font-mono tracking-[.01em] [unicode-bidi:isolate] text-start [[dir=rtl]_&]:text-right",className),...rest})});function TechnicalText({children,className}){return jsx3("span",{dir:"ltr",className:cn("inline-block font-mono [unicode-bidi:isolate]",className),children})}function ColorField({label,note,value,onChange,disabled,id:idProp}){const auto=useId();const id=idProp??auto;return jsxs3("div",{className:"flex flex-col gap-1.5 min-w-0",children:[jsx3("label",{htmlFor:`${id}-hex`,className:"text-ui font-bold text-ink2",children:label}),note&&jsx3("span",{className:"text-caption leading-[1.6] text-muted",children:note}),jsxs3("div",{className:"flex items-center gap-2 min-w-0",children:[jsxs3("span",{className:"relative shrink-0 size-11",children:[jsx3("input",{id,type:"color",value:normalizeHex(value)??"#000000",disabled,onChange:e=>onChange(e.target.value.toUpperCase()),"aria-label":typeof label==="string"?label:void 0,className:"absolute inset-0 size-full opacity-0 cursor-pointer disabled:cursor-not-allowed"}),jsx3("span",{"aria-hidden":"true",className:"pointer-events-none block size-11 rounded-field border border-border",style:{background:normalizeHex(value)??"transparent"}})]}),jsx3(TechnicalInput,{id:`${id}-hex`,kind:"hex",hideLabel:true,size:"md",maxLength:7,disabled,value,onChange:e=>onChange(e.target.value),onBlur:()=>{const fixed=normalizeHex(value);if(fixed&&fixed!==value)onChange(fixed);else if(!fixed&&value&&!value.startsWith(LEAD.hex))onChange(`#${value}`)},wrapperClassName:"flex-1 min-w-0"})]})]})}function normalizeHex(input){const raw=input.trim().replace(/^#/,"");if(/^[0-9a-fA-F]{3}$/.test(raw)){return`#${raw.split("").map(c=>c+c).join("").toUpperCase()}`}if(/^[0-9a-fA-F]{6}$/.test(raw))return`#${raw.toUpperCase()}`;return null}import{useCallback,useEffect as useEffect2,useRef as useRef2,useState as useState2}from"react";import{Box,Loader2}from"lucide-react";import{jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";function detailOf(e){return e.detail??{}}function Product3DViewer({src,iosSrc,poster,alt,autoRotate=true,onLoad,onError,onARLaunch,className}){const en=useMoneyLang();const host=useRef2(null);const slot=useRef2(null);const viewer=useRef2(null);const[phase,setPhase]=useState2("idle");const[progress,setProgress]=useState2(0);const[canAR,setCanAR]=useState2(false);const cb=useRef2({onLoad,onError,onARLaunch});useEffect2(()=>{cb.current={onLoad,onError,onARLaunch}},[onLoad,onError,onARLaunch]);useEffect2(()=>{const mount=slot.current;const box=host.current;if(!mount||!box)return;let dead=false;let el=null;setPhase("idle");setProgress(0);setCanAR(false);async function build(target){try{await import("@google/model-viewer");await customElements.whenDefined("model-viewer");if(dead)return;el=document.createElement("model-viewer");viewer.current=el;el.setAttribute("src",src);if(iosSrc)el.setAttribute("ios-src",iosSrc);el.setAttribute("alt",alt);el.setAttribute("camera-controls","");el.setAttribute("touch-action","pan-y");el.setAttribute("shadow-intensity","1");el.setAttribute("ar","");el.setAttribute("ar-modes","webxr scene-viewer quick-look");el.setAttribute("loading","eager");el.style.width="100%";el.style.height="100%";el.style.backgroundColor="transparent";const silence=document.createElement("button");silence.slot="ar-button";silence.style.display="none";silence.tabIndex=-1;silence.setAttribute("aria-hidden","true");el.appendChild(silence);const reduce=typeof matchMedia!=="undefined"&&matchMedia("(prefers-reduced-motion: reduce)").matches;if(autoRotate&&!reduce)el.setAttribute("auto-rotate","");el.addEventListener("progress",e=>{const total=detailOf(e).totalProgress??0;if(!dead)setProgress(total)});el.addEventListener("load",()=>{if(dead)return;setPhase("ready");setCanAR(Boolean(el?.canActivateAR));cb.current.onLoad?.()});el.addEventListener("error",e=>{if(dead)return;setPhase("error");cb.current.onError?.(detailOf(e).type??"load-failed")});target.appendChild(el);setPhase("loading")}catch{if(dead)return;setPhase("error");cb.current.onError?.("viewer-unavailable")}}const io=new IntersectionObserver(entries=>{if(entries.some(x=>x.isIntersecting)){io.disconnect();void build(mount)}},{rootMargin:"200px"});io.observe(box);return()=>{dead=true;io.disconnect();el?.remove();viewer.current=null}},[src,iosSrc,alt,autoRotate]);const launchAR=useCallback(()=>{cb.current.onARLaunch?.();void viewer.current?.activateAR().catch(()=>{})},[]);const pct=Math.round(progress*100);const showPoster=phase!=="ready";return jsxs4("div",{ref:host,className:cn("relative aspect-square w-full overflow-clip rounded-card bg-hover border border-line",className),children:[showPoster&&jsx4("img",{src:poster,alt,loading:"lazy",decoding:"async",draggable:false,className:"absolute inset-0 size-full object-contain"}),jsx4("div",{ref:slot,className:cn("absolute inset-0",showPoster&&"opacity-0"),"aria-hidden":showPoster}),phase==="loading"&&jsxs4("div",{className:"absolute inset-x-0 bottom-0 flex flex-col gap-1.5 p-3",children:[jsxs4("span",{className:"flex items-center gap-2 text-micro font-bold text-ink2",children:[jsx4(Loader2,{size:12,className:"animate-spin shrink-0","aria-hidden":"true"}),en?"Loading 3D model":"\u062C\u0627\u0631\u064A \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062C\u0633\u0651\u0645",jsxs4("span",{dir:"ltr","data-num":true,className:"ms-auto text-muted",children:[pct,"%"]})]}),jsx4("span",{role:"progressbar","aria-valuenow":pct,"aria-valuemin":0,"aria-valuemax":100,"aria-label":en?"Model loading progress":"\u062A\u0642\u062F\u0651\u0645 \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062C\u0633\u0651\u0645",className:"h-1 w-full rounded-full bg-line overflow-clip",children:jsx4("span",{className:"block h-full rounded-full bg-brand transition-[width] duration-200",style:{width:`${pct}%`}})})]}),phase==="ready"&&canAR&&jsxs4("button",{type:"button",onClick:launchAR,className:cn("absolute bottom-3 end-3 inline-flex items-center gap-2 h-9 px-3.5 rounded-full","bg-surface/92 backdrop-blur border border-line shadow-pop","text-ui font-bold text-ink2 cursor-pointer transition-colors hover:text-brand-ink"),children:[jsx4(Box,{size:15,"aria-hidden":"true"}),en?"See it in your space":"\u0634\u0648\u0641\u0647 \u0641\u064A \u0645\u0643\u0627\u0646\u0643"]})]})}import{X}from"lucide-react";import{jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function Tabs({items,value,onChange,variant="pill",label,className}){if(variant==="segmented"){return jsx5("div",{role:"tablist","aria-label":label,className:cn("flex flex-wrap gap-0.5 p-0.5 rounded-field bg-bg self-start","max-w-full overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",className),children:items.map(it=>{const on=it.key===value;return jsxs5("button",{role:"tab",type:"button","aria-selected":on,onClick:()=>onChange(it.key),className:cn("h-9 px-2 sm:px-3.5 rounded-sm inline-flex items-center gap-2 text-ui font-bold cursor-pointer transition-colors","shrink-0 whitespace-nowrap","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",on?"bg-surface text-ink shadow-raise":"text-muted hover:text-ink"),children:[it.icon&&jsx5(it.icon,{size:14}),it.label,typeof it.count==="number"&&jsx5("span",{"data-num":true,className:"opacity-60",children:it.count})]},it.key)})})}return jsx5("div",{role:"tablist","aria-label":label,className:cn("flex items-center gap-2.5 flex-wrap",className),children:items.map(it=>{const on=it.key===value;return jsxs5("button",{role:"tab",type:"button","aria-selected":on,onClick:()=>onChange(it.key),className:cn("h-10 px-3.5 rounded-field border inline-flex items-center gap-1.5 text-ui font-bold cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",on?"border-brand bg-soft text-brand-ink":"border-border bg-surface text-ink2 hover:border-brand"),children:[it.icon&&jsx5(it.icon,{size:14}),it.label,typeof it.count==="number"&&jsx5("span",{"data-num":true,className:"text-micro opacity-70",children:it.count})]},it.key)})})}function FilterChips({chips,onClearAll,label,clearAllLabel}){const ui=useUIText();if(chips.length===0)return null;return jsxs5("div",{className:"flex items-center gap-2 flex-wrap",children:[jsx5("span",{className:"text-caption text-muted",children:label??ui.activeFilters}),chips.map(c=>jsxs5("button",{type:"button",onClick:c.onClear,className:"inline-flex items-center gap-1.5 h-7 ps-3 pe-2 rounded-full bg-soft text-brand-ink text-caption font-bold cursor-pointer transition-colors hover:bg-soft2",children:[c.label,jsx5(X,{size:12,strokeWidth:2.5,"aria-hidden":"true"})]},c.label)),onClearAll&&jsx5("button",{type:"button",onClick:onClearAll,className:"text-caption font-bold text-muted cursor-pointer hover:text-ink transition-colors",children:clearAllLabel??ui.clearAll})]})}import{useEffect as useEffect3,useMemo,useRef as useRef3,useState as useState3}from"react";import{Check,ChevronDown,Loader2 as Loader22,Minus as Minus2,SlidersHorizontal}from"lucide-react";import{useInView}from"react-intersection-observer";import{Fragment,jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";function leavesOf(item){if(!item.children?.length)return[item];return item.children.flatMap(leavesOf)}function Picker({open,onClose,title,description,closeLabel,items,icon,isLoading,isError,errorText,emptyIcon,emptyText,search,onSearch,searchPlaceholder,header,multiple=false,selected,onPick,closeOnPick=true,onConfirm,hintText,cancelLabel,confirmLabel,selectedCountText,itemsCountText,allTabLabel,selectedTabLabel,selectAllLabel,deselectAllLabel,hasMore,isLoadingMore,onLoadMore}){const ui=useUIText();const current=selected??[];const[tab,setTab]=useState3("all");const[saved,setSaved]=useState3(()=>new Set(current));const[pending,setPending]=useState3(()=>new Set);const[removed,setRemoved]=useState3(()=>new Set);const[wasOpen,setWasOpen]=useState3(open);if(wasOpen!==open){setWasOpen(open);if(open){setTab("all");setSaved(new Set(current));setPending(new Set);setRemoved(new Set)}}const total=saved.size-removed.size+pending.size;const tabbed=multiple;const visible=useMemo(()=>{if(!tabbed)return items;const keep=i=>tab==="selected"?saved.has(i.id):!saved.has(i.id);return items.map(item=>{if(!item.children?.length)return keep(item)?item:null;const kids=item.children.filter(keep);return kids.length>0?{...item,children:kids}:null}).filter(i=>i!==null)},[items,tabbed,tab,saved]);const[expanded,setExpanded]=useState3(()=>new Set);const rows=useMemo(()=>{const out=[];for(const item of visible){const kids=item.children??[];out.push({item,child:false});if(kids.length>0&&expanded.has(item.id))for(const kid of kids)out.push({item:kid,child:true})}return out},[visible,expanded]);function isChecked(id){if(!tabbed)return pending.has(id)||saved.has(id)&&!removed.has(id);if(tab==="selected")return!removed.has(id);return pending.has(id)}const[scroller,setScroller]=useState3(null);const{ref:sentinelRef,inView}=useInView({root:scroller,rootMargin:"160px"});const loadMore=useRef3(onLoadMore);useEffect3(()=>{loadMore.current=onLoadMore});useEffect3(()=>{if(inView&&hasMore&&!isLoadingMore)loadMore.current?.()},[inView,hasMore,isLoadingMore]);const anchor=useRef3(-1);function toggle(id){if(!tabbed){const item=items.flatMap(leavesOf).find(i=>i.id===id);if(item)onPick?.(item);if(closeOnPick)onClose();return}if(tab==="selected"){setRemoved(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next});return}setPending(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})}function clickRow(id,index,shiftKey){const row=rows[index];if(row?.item.children?.length){setExpanded(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next});return}if(tabbed&&shiftKey&&tab==="all"&&anchor.current>=0){const from=Math.min(anchor.current,index);const to=Math.max(anchor.current,index);setPending(prev=>{const next=new Set(prev);for(let i=from;i<=to;i++){const target=rows[i]?.item;if(target&&!target.disabled&&!target.children?.length)next.add(target.id)}return next})}else{toggle(id)}anchor.current=index}const pickable=visible.flatMap(leavesOf).filter(i=>!i.disabled);const allPicked=pickable.length>0&&pickable.every(i=>pending.has(i.id));function save(){const out=new Set([...saved,...pending]);for(const id of removed)out.delete(id);onConfirm?.([...out]);onClose()}return jsx6(Modal,{open,onClose,size:"lg",bodyClassName:"flex flex-col",title:tabbed&&total>0?jsxs6("span",{className:"flex items-center gap-2 flex-wrap",children:[title,jsx6("span",{className:"text-caption font-bold px-2 py-0.5 rounded-full bg-soft text-brand-ink",children:selectedCountText?selectedCountText(total):jsxs6(Fragment,{children:[jsx6("span",{"data-num":true,children:total})," ",ui.selectedCount]})})]}):title,description,closeLabel:closeLabel??ui.close,footer:tabbed?jsxs6(Fragment,{children:[jsxs6("span",{className:"text-caption text-muted me-auto",children:[itemsCountText?itemsCountText(items.length):jsxs6(Fragment,{children:[jsx6("span",{"data-num":true,children:items.length})," ",ui.items]}),jsx6("span",{className:"text-muted2",children:" \xB7 Shift+Click"})]}),jsx6(Button,{variant:"ghost",size:"sm",onClick:onClose,children:cancelLabel??ui.cancel}),jsx6(Button,{size:"sm",onClick:save,children:confirmLabel??ui.save})]}):jsxs6(Fragment,{children:[jsx6("span",{className:"text-caption text-muted me-auto",children:hintText??ui.pickToSelect}),jsx6(Button,{variant:"ghost",size:"sm",onClick:onClose,children:cancelLabel??ui.cancel})]}),children:jsxs6("div",{className:"flex-auto min-h-0 flex flex-col gap-3",children:[header,jsx6(SearchInput,{label:ui.search,hideLabel:true,size:"sm",value:search,onChange:e=>onSearch(e.target.value),placeholder:searchPlaceholder??ui.search}),tabbed&&jsxs6("div",{role:"tablist",className:"flex items-center gap-1.5",children:[jsx6(TabButton,{active:tab==="all",onClick:()=>setTab("all"),children:allTabLabel??ui.all}),jsxs6(TabButton,{active:tab==="selected",onClick:()=>setTab("selected"),children:[jsx6(SlidersHorizontal,{size:12,"aria-hidden":"true"}),selectedTabLabel??ui.selectedTab,saved.size>removed.size&&jsx6("span",{"data-num":true,className:"text-micro leading-none px-1.5 py-0.5 rounded-full bg-soft text-brand-ink",children:saved.size-removed.size})]})]}),jsx6("div",{ref:setScroller,className:"flex-auto min-h-0 max-h-96 overflow-y-auto overscroll-contain [scrollbar-gutter:stable] -mx-1 px-1",children:isLoading?jsx6("div",{className:"flex flex-col gap-1.5",children:Array.from({length:6},(_,i)=>jsx6(Skeleton,{variant:"block",className:"h-13 rounded-sm"},i))}):isError?jsx6(Alert,{tone:"red",title:errorText??ui.somethingWentWrong}):visible.length===0?jsx6(EmptyState,{icon:emptyIcon,title:emptyText??ui.noResults}):jsxs6(Fragment,{children:[tabbed&&tab==="all"&&pickable.length>0&&jsxs6("button",{type:"button","aria-pressed":allPicked,onClick:()=>{if(allPicked)setPending(new Set);else setPending(prev=>new Set([...prev,...pickable.map(i=>i.id)]))},className:"w-full flex items-center gap-3 p-2 mb-1.5 rounded-sm border border-dashed border-line cursor-pointer text-start transition-colors hover:bg-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",children:[jsx6(Box2,{checked:allPicked,partial:!allPicked&&pending.size>0}),jsxs6("span",{className:"text-caption text-muted",children:[allPicked?deselectAllLabel??ui.deselectAll:selectAllLabel??ui.selectAll," ",jsxs6("span",{"data-num":true,children:["(",pickable.length,")"]})]})]}),jsx6("ul",{role:"listbox","aria-multiselectable":multiple,"aria-label":typeof title==="string"?title:void 0,className:"flex flex-col gap-1.5 list-none m-0 p-0",children:rows.map(({item,child},index)=>jsx6(Row,{item,icon,box:tabbed,child,expanded:item.children?.length?expanded.has(item.id):void 0,selected:isChecked(item.id),onPick:shiftKey=>clickRow(item.id,index,shiftKey)},item.id))}),hasMore&&(!tabbed||tab==="all")&&jsx6("div",{ref:sentinelRef,role:"status","aria-label":isLoadingMore?ui.loadingMore:void 0,className:"h-11 flex items-center justify-center",children:isLoadingMore&&jsx6(Loader22,{size:16,"aria-hidden":"true",className:"animate-spin text-muted"})})]})})]})})}function TabButton({active,onClick,children}){return jsx6("button",{type:"button",role:"tab","aria-selected":active,onClick,className:cn("flex items-center gap-1.5 px-3 py-1.5 rounded-sm text-caption font-bold border cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",active?"border-line bg-surface text-ink":"border-transparent text-muted hover:text-ink hover:bg-hover"),children})}function Box2({checked,partial=false}){return jsx6("span",{"aria-hidden":"true",className:cn("shrink-0 size-5 rounded-xs border flex items-center justify-center transition-colors",checked||partial?"bg-brand border-brand text-white":"border-line bg-surface"),children:checked?jsx6(Check,{size:13,strokeWidth:3}):partial?jsx6(Minus2,{size:13,strokeWidth:3}):null})}function Row({item,icon,box,child=false,expanded,selected,onPick}){const[errored,setErrored]=useState3(false);const disabled=item.disabled??false;const parent=expanded!==void 0;const src=item.image?.trim();const showImage=Boolean(src)&&!errored;return jsx6("li",{role:"none",children:jsxs6("button",{type:"button",role:parent?void 0:"option","aria-selected":parent?void 0:selected,"aria-disabled":disabled||void 0,"aria-expanded":parent?expanded:void 0,title:disabled?item.disabledReason:void 0,onClick:e=>{if(!disabled)onPick(e.shiftKey)},className:cn("w-full flex items-center gap-3 p-2 rounded-sm text-start","border transition-colors",child&&"ps-11",disabled?"opacity-45 cursor-not-allowed border-transparent":"cursor-pointer",!disabled&&(selected?"border-brand bg-soft":"border-transparent hover:border-line hover:bg-hover"),"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:[box&&!parent&&jsx6(Box2,{checked:selected}),showImage?jsx6("img",{src,alt:"",loading:"lazy",onError:()=>setErrored(true),className:"size-9 rounded-sm border border-line object-cover shrink-0"}):jsx6("span",{"aria-hidden":"true",className:"size-9 shrink-0 inline-flex items-center justify-center [&>svg]:size-full",children:icon}),jsxs6("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx6("span",{className:"text-caption font-bold text-ink truncate",children:jsx6("bdi",{children:item.title})}),item.sub&&jsx6("span",{className:"text-micro text-muted truncate",children:jsx6("bdi",{children:item.sub})})]}),parent&&jsx6(ChevronDown,{size:16,"aria-hidden":"true",className:cn("shrink-0 text-muted transition-transform",expanded&&"rotate-180")}),!box&&!parent&&selected&&jsx6("span",{"aria-hidden":"true",className:"shrink-0 size-5 rounded-full bg-brand text-white flex items-center justify-center",children:jsx6(Check,{size:12,strokeWidth:3})})]})})}import{useEffect as useEffect4,useId as useId2,useLayoutEffect,useMemo as useMemo2,useRef as useRef4,useState as useState4}from"react";import{Check as Check2,ChevronDown as ChevronDown2,Plus as Plus2,Search,X as X2}from"lucide-react";import{jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";function useDismiss(open,close){const ref=useRef4(null);useEffect4(()=>{if(!open)return;function onDown(e){if(ref.current&&!ref.current.contains(e.target))close()}function onKey(e){if(e.key==="Escape")close()}document.addEventListener("mousedown",onDown);document.addEventListener("keydown",onKey);return()=>{document.removeEventListener("mousedown",onDown);document.removeEventListener("keydown",onKey)}},[open,close]);return ref}var TRIGGER="w-full h-10 px-3.5 rounded-field border bg-surface flex items-center gap-2.5 text-body cursor-pointer transition-colors outline-none focus-visible:border-brand";var GAP=6;var EDGE=8;var PANEL="absolute z-30 inset-x-0 bg-surface border border-line rounded-card shadow-panel overflow-clip animate-[fade-in_.14s_ease-out]";function useFlip(open,anchor){const panel=useRef4(null);const[up,setUp]=useState4(false);useLayoutEffect(()=>{if(!open)return;function place(){const target=anchor.current;const self=panel.current;if(!target||!self)return;const a=target.getBoundingClientRect();const h=self.offsetHeight;const below=window.innerHeight-a.bottom-GAP;const above=a.top-GAP;setUp(h>below-EDGE&&above>below)}place();window.addEventListener("scroll",place,true);window.addEventListener("resize",place);return()=>{window.removeEventListener("scroll",place,true);window.removeEventListener("resize",place)}},[open,anchor]);const side=up?"bottom-[calc(100%+6px)]":"top-[calc(100%+6px)]";return[panel,side]}var ITEM="w-full px-3 py-2.5 flex items-center gap-2.5 text-start text-ui cursor-pointer transition-colors hover:bg-hover disabled:opacity-45 disabled:cursor-not-allowed";function Label({id,children}){if(!children)return null;return jsx7("label",{htmlFor:id,className:"text-ui font-bold text-ink2",children})}function Dropdown({label,value,onChange,options,placeholder,className}){const ui=useUIText();const id=useId2();const[open,setOpen]=useState4(false);const ref=useDismiss(open,()=>setOpen(false));const[panelRef,side]=useFlip(open,ref);const current=options.find(o=>o.value===value);return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[jsx7(Label,{id,children:label}),jsxs7("div",{ref,className:"relative",children:[jsxs7("button",{id,type:"button","aria-haspopup":"listbox","aria-expanded":open,onClick:()=>setOpen(v=>!v),className:cn(TRIGGER,open?"border-brand":"border-border hover:border-brand"),children:[current?.icon,jsx7("span",{className:cn("flex-1 min-w-0 text-start truncate",!current&&"text-muted2"),children:current?.label??placeholder??ui.select}),current?.meta&&jsx7("span",{className:"text-caption text-muted shrink-0",children:current.meta}),jsx7(ChevronDown2,{size:15,"aria-hidden":"true",className:cn("text-muted2 shrink-0 transition-transform",open&&"rotate-180")})]}),open&&jsx7("div",{ref:panelRef,role:"listbox",className:cn(PANEL,side,"max-h-72 overflow-y-auto py-1"),children:options.map(o=>jsxs7("button",{type:"button",role:"option","aria-selected":o.value===value,disabled:o.disabled,onClick:()=>{onChange(o.value);setOpen(false)},className:cn(ITEM,o.value===value&&"bg-soft"),children:[o.icon,jsxs7("span",{className:"flex-1 min-w-0 flex flex-col",children:[jsx7("span",{className:"font-bold truncate",children:o.label}),o.meta&&jsx7("span",{className:"text-caption text-muted",children:o.meta})]}),o.value===value&&jsx7(Check2,{size:14,className:"text-brand-ink shrink-0","aria-hidden":"true"})]},o.value))})]})]})}function Combobox({label,value,onChange,options,placeholder,searchPlaceholder,emptyText,className}){const ui=useUIText();const id=useId2();const[open,setOpen]=useState4(false);const[query,setQuery]=useState4("");const ref=useDismiss(open,()=>setOpen(false));const[panelRef,side]=useFlip(open,ref);const current=options.find(o=>o.value===value);const results=useMemo2(()=>{const q=query.trim();if(!q)return options;return options.filter(o=>o.label.includes(q)||o.meta?.includes(q))},[options,query]);return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[jsx7(Label,{id,children:label}),jsxs7("div",{ref,className:"relative",children:[jsxs7("button",{id,type:"button","aria-haspopup":"listbox","aria-expanded":open,onClick:()=>{setOpen(v=>!v);setQuery("")},className:cn(TRIGGER,open?"border-brand":"border-border hover:border-brand"),children:[jsx7("span",{className:cn("flex-1 min-w-0 text-start truncate",!current&&"text-muted2"),children:current?.label??placeholder??ui.select}),current?.meta&&jsx7("span",{className:"text-caption text-muted shrink-0",children:current.meta}),jsx7(ChevronDown2,{size:15,"aria-hidden":"true",className:cn("text-muted2 shrink-0 transition-transform",open&&"rotate-180")})]}),open&&jsxs7("div",{ref:panelRef,className:cn(PANEL,side),children:[jsxs7("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-line",children:[jsx7(Search,{size:15,className:"text-muted2 shrink-0","aria-hidden":"true"}),jsx7("input",{autoFocus:true,value:query,onChange:e=>setQuery(e.target.value),placeholder:searchPlaceholder??ui.search,"aria-label":searchPlaceholder??ui.search,className:"flex-1 min-w-0 bg-transparent border-none outline-none text-ui text-ink placeholder:text-muted2"}),query&&jsx7("button",{type:"button",onClick:()=>setQuery(""),"aria-label":ui.clearSearch,className:"shrink-0 text-muted2 hover:text-ink cursor-pointer transition-colors",children:jsx7(X2,{size:14,"aria-hidden":"true"})}),jsx7("kbd",{dir:"ltr",className:"shrink-0 px-1.5 py-0.5 rounded-xs bg-bg border border-line text-micro font-bold text-muted2",children:"Esc"})]}),jsxs7("div",{role:"listbox",className:"max-h-64 overflow-y-auto py-1",children:[results.map(o=>jsxs7("button",{type:"button",role:"option","aria-selected":o.value===value,onClick:()=>{onChange(o.value);setOpen(false)},className:cn(ITEM,o.value===value&&"bg-soft"),children:[jsxs7("span",{className:"flex-1 min-w-0 flex flex-col",children:[jsx7("span",{className:"font-bold truncate",children:o.label}),o.meta&&jsx7("span",{className:"text-caption text-muted",children:o.meta})]}),o.value===value&&jsx7(Check2,{size:14,className:"text-brand-ink shrink-0","aria-hidden":"true"})]},o.value)),results.length===0&&jsx7("span",{className:"block px-3 py-6 text-center text-ui text-muted2",children:emptyText??ui.noResults})]})]})]})]})}function MultiSelect({label,values,onChange,options,placeholder,createLabel,onCreate,className}){const ui=useUIText();const id=useId2();const[open,setOpen]=useState4(false);const[query,setQuery]=useState4("");const ref=useDismiss(open,()=>setOpen(false));const[panelRef,side]=useFlip(open,ref);const results=useMemo2(()=>{const q=query.trim();if(!q)return options;return options.filter(o=>o.label.includes(q))},[options,query]);const exact=results.some(o=>o.label===query.trim());const canCreate=Boolean(onCreate&&query.trim()&&!exact);function toggle(v){onChange(values.includes(v)?values.filter(x=>x!==v):[...values,v])}return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[jsxs7("div",{className:"flex items-center justify-between gap-3",children:[jsx7(Label,{id,children:label}),values.length>0&&jsx7("button",{type:"button",onClick:()=>onChange([]),className:"text-caption font-bold text-muted cursor-pointer hover:text-ink transition-colors",children:ui.clearAll})]}),jsxs7("div",{ref,className:"relative",children:[jsxs7("div",{className:cn(TRIGGER,"h-auto min-h-10 py-1.5 flex-wrap cursor-default",open?"border-brand":"border-border hover:border-brand","has-[:focus-visible]:border-brand"),children:[values.map(v=>{const o=options.find(x=>x.value===v);return jsxs7("span",{className:"inline-flex items-center gap-1 h-7 ps-2.5 pe-1.5 rounded-full bg-soft text-brand-ink text-caption font-bold",children:[o?.label??v,jsx7("button",{type:"button","aria-label":`${ui.remove} ${o?.label??v}`,onClick:e=>{e.stopPropagation();toggle(v)},className:"flex text-brand-ink/60 hover:text-brand-ink cursor-pointer",children:jsx7(X2,{size:12,strokeWidth:2.5,"aria-hidden":"true"})})]},v)}),jsxs7("button",{id,type:"button","aria-haspopup":"listbox","aria-expanded":open,onClick:()=>setOpen(v=>!v),className:"flex-1 min-w-12 self-stretch flex items-center gap-2.5 text-start cursor-pointer outline-none",children:[values.length===0&&jsx7("span",{className:"text-muted2 flex-1 text-start",children:placeholder??ui.select}),jsx7(ChevronDown2,{size:15,"aria-hidden":"true",className:cn("text-muted2 shrink-0 ms-auto transition-transform",open&&"rotate-180")})]})]}),open&&jsxs7("div",{ref:panelRef,className:cn(PANEL,side),children:[jsxs7("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-line",children:[jsx7(Search,{size:15,className:"text-muted2 shrink-0","aria-hidden":"true"}),jsx7("input",{autoFocus:true,value:query,onChange:e=>setQuery(e.target.value),placeholder:ui.searchOrAdd,"aria-label":ui.searchOrAdd,className:"flex-1 min-w-0 bg-transparent border-none outline-none text-ui text-ink placeholder:text-muted2"})]}),jsxs7("div",{role:"listbox","aria-multiselectable":true,className:"max-h-56 overflow-y-auto py-1",children:[results.map(o=>{const on=values.includes(o.value);return jsxs7("button",{type:"button",role:"option","aria-selected":on,onClick:()=>toggle(o.value),className:ITEM,children:[jsx7("span",{"aria-hidden":"true",className:cn("size-[18px] rounded-xs border-[1.5px] flex items-center justify-center shrink-0 transition-colors",on?"bg-brand border-brand":"bg-surface border-border"),children:jsx7(Check2,{size:11,strokeWidth:3,className:cn("text-white",!on&&"opacity-0")})}),jsx7("span",{className:"flex-1 min-w-0 truncate",children:o.label}),o.meta&&jsx7("span",{className:"text-caption text-muted2 shrink-0",children:o.meta})]},o.value)}),canCreate&&jsxs7("button",{type:"button",onClick:()=>{onCreate?.(query.trim());setQuery("")},className:cn(ITEM,"text-brand-ink font-bold border-t border-line mt-1 pt-3"),children:[jsx7(Plus2,{size:14,"aria-hidden":"true",className:"shrink-0"}),createLabel?createLabel(query.trim()):`\u0623\u0636\u0641 \xAB${query.trim()}\xBB`]}),results.length===0&&!canCreate&&jsx7("span",{className:"block px-3 py-6 text-center text-ui text-muted2",children:ui.noResults})]})]})]})]})}function CommandPalette({open,onClose,items,placeholder,emptyText}){const ui=useUIText();const[query,setQuery]=useState4("");useEffect4(()=>{if(!open)return;function onKey(e){if(e.key==="Escape")onClose()}document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[open,onClose]);const groups=useMemo2(()=>{const q=query.trim();const hits=q?items.filter(i=>i.title.includes(q)||i.meta?.includes(q)):items;const out=new Map;for(const i of hits)out.set(i.group,[...out.get(i.group)??[],i]);return[...out.entries()]},[items,query]);if(!open)return null;return jsxs7("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[12vh] px-4",role:"dialog","aria-modal":"true",children:[jsx7("button",{type:"button","aria-label":ui.close,onClick:onClose,className:"absolute inset-0 bg-black/40 backdrop-blur-[2px] cursor-default"}),jsxs7("div",{className:"relative w-full max-w-[560px] bg-surface border border-line rounded-lg shadow-modal overflow-clip animate-[fade-in_.16s_ease-out]",children:[jsxs7("div",{className:"flex items-center gap-3 px-4 h-14 border-b border-line",children:[jsx7(Search,{size:17,className:"text-muted2 shrink-0","aria-hidden":"true"}),jsx7("input",{autoFocus:true,value:query,onChange:e=>setQuery(e.target.value),placeholder:placeholder??ui.searchEverything,"aria-label":placeholder??ui.searchEverything,className:"flex-1 min-w-0 bg-transparent border-none outline-none text-body text-ink placeholder:text-muted2"}),jsx7("kbd",{dir:"ltr",className:"shrink-0 px-1.5 py-0.5 rounded-xs bg-bg border border-line text-micro font-bold text-muted2",children:"Esc"})]}),jsxs7("div",{className:"max-h-[52vh] overflow-y-auto py-2",children:[groups.map(([group2,list])=>jsxs7("div",{className:"flex flex-col",children:[jsx7("span",{className:"px-4 pt-2 pb-1 text-micro font-extrabold text-muted2 tracking-wide",children:group2}),list.map(i=>jsxs7("button",{type:"button",onClick:()=>{i.onRun?.();onClose()},className:"px-4 py-2.5 flex items-center gap-3 text-start cursor-pointer transition-colors hover:bg-hover",children:[i.icon&&jsx7("span",{className:"text-muted shrink-0",children:i.icon}),jsx7("span",{className:"flex-1 min-w-0 text-body font-bold text-ink truncate",children:i.title}),i.meta&&jsx7("span",{className:"text-caption text-muted2 shrink-0",children:i.meta})]},i.id))]},group2)),groups.length===0&&jsx7("span",{className:"block px-4 py-10 text-center text-ui text-muted2",children:emptyText??ui.noResults})]})]})]})}import{useState as useState5}from"react";import{Check as Check3,ChevronDown as ChevronDown3}from"lucide-react";import{Fragment as Fragment2,jsx as jsx8,jsxs as jsxs8}from"react/jsx-runtime";function Accordion({items,mode="single",defaultOpen=[],className}){const[open,setOpen]=useState5(defaultOpen);function toggle(key){setOpen(prev=>{if(prev.includes(key))return prev.filter(k=>k!==key);return mode==="single"?[key]:[...prev,key]})}return jsx8("div",{className:cn("bg-surface border border-line rounded-card overflow-clip",className),children:items.map(it=>{const on=open.includes(it.key);return jsxs8("div",{className:"border-b border-line last:border-0",children:[jsxs8("button",{type:"button","aria-expanded":on,onClick:()=>toggle(it.key),className:"w-full px-4 py-3.5 flex items-center gap-3 text-start cursor-pointer transition-colors hover:bg-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",children:[it.icon&&jsx8("span",{"aria-hidden":"true",className:"size-8 rounded-sm bg-soft text-brand-ink flex items-center justify-center shrink-0",children:jsx8(it.icon,{size:15})}),jsxs8("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx8("span",{className:"text-body font-extrabold text-ink",children:it.title}),it.description&&jsx8("span",{className:"text-caption text-muted",children:it.description})]}),jsx8(ChevronDown3,{size:16,"aria-hidden":"true",className:cn("text-muted2 shrink-0 transition-transform duration-200",on&&"rotate-180")})]}),jsx8("div",{className:cn("grid transition-[grid-template-rows] duration-200 ease-out",on?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:jsx8("div",{className:"min-h-0 overflow-clip",children:jsx8("div",{className:"px-4 pb-4 pt-0.5 text-ui leading-[1.85] text-ink2",children:it.children})})})]},it.key)})})}function Timeline({steps,current,nowLabel,className}){const ui=useUIText();return jsx8("ol",{className:cn("flex flex-col m-0 p-0 list-none",className),children:steps.map((s,i)=>{const done=i<current;const active=i===current;const last=i===steps.length-1;return jsxs8("li",{className:"flex gap-3",children:[jsxs8("span",{className:"flex flex-col items-center shrink-0",children:[jsx8("span",{"aria-hidden":"true",className:cn("size-7 rounded-full flex items-center justify-center border-2 transition-colors",done&&"bg-brand border-brand text-white",active&&"bg-surface border-brand text-brand-ink",!done&&!active&&"bg-surface border-border text-muted2"),children:done?jsx8(Check3,{size:14,strokeWidth:3}):jsx8("span",{className:cn("size-2 rounded-full",active?"bg-brand":"bg-border")})}),!last&&jsx8("span",{"aria-hidden":"true",className:cn("w-0.5 flex-1 min-h-8 transition-colors",done?"bg-brand":"bg-line")})]}),jsxs8("span",{className:cn("flex flex-col gap-0.5 min-w-0",last?"pb-0":"pb-5"),children:[jsxs8("span",{className:"flex items-center gap-2.5 flex-wrap",children:[jsx8("span",{className:cn("text-body font-extrabold",done||active?"text-ink":"text-muted2"),children:s.title}),s.time&&jsx8("span",{"data-num":true,className:"text-micro text-muted2",children:s.time}),active&&jsx8("span",{className:cn("px-2 py-0.5 rounded-full text-micro font-extrabold",TONE_SOFT[s.tone??"brand"]),children:nowLabel??ui.now})]}),s.note&&jsx8("span",{className:"text-caption leading-[1.7] text-muted",children:s.note})]})]},s.key)})})}function Stepper({steps,done,onPick,className}){return jsx8("ol",{className:cn("flex items-start gap-1 m-0 p-0 list-none",className),children:steps.map((s,i)=>{const on=done.includes(s.key);const isCurrent=!on&&steps.slice(0,i).every(x=>done.includes(x.key));const last=i===steps.length-1;const Tag=onPick?"button":"div";return jsxs8("li",{className:"flex-1 flex flex-col items-center gap-2 min-w-0",children:[jsxs8("span",{className:"w-full flex items-center gap-1",children:[jsx8("span",{"aria-hidden":"true",className:cn("h-0.5 flex-1 rounded-full",i===0?"bg-transparent":on?"bg-brand":"bg-line")}),jsx8(Tag,{...onPick?{type:"button",onClick:()=>onPick(s.key)}:{},"aria-current":isCurrent?"step":void 0,className:cn("size-8 rounded-full flex items-center justify-center shrink-0 border-2 transition-colors",on?"bg-brand border-brand text-white":"bg-surface border-border text-muted",onPick&&"cursor-pointer hover:border-brand"),children:on?jsxs8(Fragment2,{children:[jsx8(Check3,{size:15,strokeWidth:3,"aria-hidden":"true"}),jsx8("span",{className:"sr-only",children:"\u0645\u0643\u062A\u0645\u0644\u0629"})]}):jsx8("span",{"data-num":true,className:"text-caption font-extrabold",children:i+1})}),jsx8("span",{"aria-hidden":"true",className:cn("h-0.5 flex-1 rounded-full",last?"bg-transparent":on?"bg-brand":"bg-line")})]}),jsx8("span",{className:cn("text-caption font-bold text-center leading-tight [text-wrap:balance]",on?"text-ink":"text-muted"),children:s.title})]},s.key)})})}import{Star}from"lucide-react";import{jsx as jsx9,jsxs as jsxs9}from"react/jsx-runtime";var MAX=5;function Stars({value,size=13,className}){const n=Math.max(0,Math.min(MAX,Math.round(value)));return jsxs9("span",{className:cn("flex items-center gap-0.5 shrink-0",className),children:[jsx9("span",{className:"sr-only",children:`${n} / ${MAX}`}),Array.from({length:MAX},(_,i)=>jsx9(Star,{size,"aria-hidden":"true",className:cn("shrink-0",i<n?"fill-amber text-amber":"text-muted2")},i))]})}function RatingInput({value,onChange,disabled,hideValue,className}){const ui=useUIText();return jsxs9("span",{className:cn("flex items-center gap-1",className),children:[Array.from({length:MAX},(_,i)=>{const n=i+1;return jsx9("button",{type:"button",disabled,"aria-pressed":value===n,"aria-label":`${n} / ${MAX} \u2014 ${ui.rating}`,onClick:()=>onChange(n),className:cn("size-9 rounded-sm flex items-center justify-center transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",disabled?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-hover"),children:jsx9(Star,{size:22,"aria-hidden":"true",className:cn("shrink-0",n<=value?"fill-amber text-amber":"text-muted2")})},n)}),!hideValue&&value>0&&jsx9("span",{"data-numeric":true,className:"ms-2 text-caption font-bold text-muted",children:`${value}/${MAX}`})]})}import{useRef as useRef5,useState as useState6}from"react";import{AlertCircle,Check as Check4,Image as ImageIcon,Loader2 as Loader23,UploadCloud,X as X3}from"lucide-react";import{jsx as jsx10,jsxs as jsxs10}from"react/jsx-runtime";function formatBytes(bytes){if(bytes<1024)return`${bytes} \u0628\u0627\u064A\u062A`;if(bytes<1024*1024)return`${Math.round(bytes/1024)} \u0643.\u0628`;return`${(bytes/(1024*1024)).toFixed(1)} \u0645\u064A\u062C\u0627`}function Dropzone({onFiles,accept="image/*",multiple=true,disabled,title,hint,buttonLabel,className}){const ui=useUIText();const input=useRef5(null);const[over,setOver]=useState6(false);function take(list){if(!list||disabled)return;onFiles(Array.from(list))}function onDrop(e){e.preventDefault();setOver(false);take(e.dataTransfer.files)}return jsxs10("div",{onDragOver:e=>{e.preventDefault();if(!disabled)setOver(true)},onDragLeave:()=>setOver(false),onDrop,className:cn("flex flex-col items-center justify-center gap-2.5 px-5 py-9 rounded-card border-2 border-dashed transition-colors text-center",disabled&&"opacity-55 cursor-not-allowed border-border bg-bg",!disabled&&over&&"border-brand bg-soft",!disabled&&!over&&"border-border bg-bg hover:border-brand",className),children:[jsx10("span",{"aria-hidden":"true",className:cn("size-12 rounded-card flex items-center justify-center transition-colors",over?"bg-brand text-white":"bg-surface text-muted border border-line"),children:jsx10(UploadCloud,{size:22,strokeWidth:1.8})}),jsx10("span",{className:"text-body font-extrabold text-ink",children:title??ui.dropImages}),hint&&jsx10("span",{className:"text-caption leading-[1.7] text-muted max-w-note",children:hint}),jsx10("button",{type:"button",disabled,onClick:()=>input.current?.click(),className:"mt-1 h-9 px-4 rounded-sm bg-surface border border-border text-ui font-bold text-ink2 cursor-pointer transition-colors hover:border-brand hover:text-brand-ink disabled:cursor-not-allowed",children:buttonLabel??ui.chooseFromDevice}),jsx10("input",{ref:input,type:"file",accept,multiple,hidden:true,onChange:e=>{take(e.target.files);e.target.value=""}})]})}var STATE_STYLE={uploading:{box:"bg-soft text-brand-ink",icon:jsx10(Loader23,{size:13,className:"animate-spin","aria-hidden":"true"}),label:"\u062C\u0627\u0631\u064A \u0627\u0644\u0631\u0641\u0639"},done:{box:"bg-green-bg2 text-green",icon:jsx10(Check4,{size:13,"aria-hidden":"true"}),label:"\u062A\u0645 \u0627\u0644\u0631\u0641\u0639"},rejected:{box:"bg-red-bg text-red",icon:jsx10(AlertCircle,{size:13,"aria-hidden":"true"}),label:"\u0645\u0631\u0641\u0648\u0636"}};function FileRow({file,onRemove,coverLabel,isCover}){const s=STATE_STYLE[file.state];return jsxs10("div",{className:"flex items-center gap-3 p-2.5 rounded-card border border-line bg-surface",children:[jsxs10("span",{className:"relative size-11 rounded-sm overflow-clip bg-hover border border-line shrink-0",children:[file.preview?jsx10("img",{src:file.preview,alt:"",className:"w-full h-full object-cover"}):jsx10("span",{className:"w-full h-full flex items-center justify-center text-muted2",children:jsx10(ImageIcon,{size:17,"aria-hidden":"true"})}),isCover&&coverLabel&&jsx10("span",{className:"absolute inset-x-0 bottom-0 bg-brand/90 text-white text-micro font-extrabold text-center py-px",children:coverLabel})]}),jsxs10("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsxs10("span",{className:"flex items-center gap-2 min-w-0",children:[jsx10("span",{dir:"auto",className:"text-ui font-bold text-ink truncate",children:file.name}),jsxs10("span",{className:cn("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-micro font-extrabold shrink-0",s.box),children:[s.icon,s.label]})]}),file.state==="uploading"?jsx10("span",{className:"h-1 rounded-full bg-hover overflow-clip block",children:jsx10("span",{className:"block h-full rounded-full bg-brand transition-[width] duration-200",style:{width:`${file.progress??0}%`}})}):jsx10("span",{className:cn("text-caption",file.state==="rejected"?"text-red":"text-muted"),children:file.state==="rejected"?file.error:formatBytes(file.size)})]}),onRemove&&jsx10("button",{type:"button",onClick:onRemove,"aria-label":`\u0625\u0632\u0627\u0644\u0629 ${file.name}`,className:"shrink-0 size-8 rounded-sm flex items-center justify-center text-muted2 cursor-pointer transition-colors hover:bg-hover hover:text-red",children:jsx10(X3,{size:15,"aria-hidden":"true"})})]})}import{useCallback as useCallback2,useEffect as useEffect5,useLayoutEffect as useLayoutEffect2,useRef as useRef6,useState as useState7}from"react";import{jsx as jsx11}from"react/jsx-runtime";function fill(tpl,vars){return tpl.replace(/\{(\w+)\}/g,(_,k)=>String(vars[k]??""))}function reducedMotion(){return typeof window!=="undefined"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function hitSlot(x,y,boxes,count){for(let i=0;i<count;i++){const b=boxes[i];if(!b)continue;if(x>=b.left&&x<=b.left+b.width&&y>=b.top&&y<=b.top+b.height)return i}let best=-1;let closest=Infinity;for(let i=0;i<count;i++){const b=boxes[i];if(!b)continue;const dx=b.left+b.width/2-x;const dy=b.top+b.height/2-y;const d=dx*dx+dy*dy;if(d<closest){closest=d;best=i}}return best}function slotOf(index,from,to){if(index===from)return to;if(to>from&&index>from&&index<=to)return index-1;if(to<from&&index>=to&&index<from)return index+1;return index}function useSortable({count,onMove,axis:axis2="y",disabled,threshold=4,itemLabel}){const ui=useUIText();const grid=axis2==="grid";const nodes=useRef6([]);const rects=useRef6([]);const host=useRef6(null);const hostBox=useRef6(null);const[frozen,setFrozen]=useState7(null);const[dragging,setDragging]=useState7(null);const[over,setOver]=useState7(null);const[grabbed,setGrabbed]=useState7(null);const[message,setMessage]=useState7("");const run=useRef6({active:false,from:0,to:0,startX:0,startY:0,dx:0,dy:0,slot:0,raf:0,pointerId:-1});const overRef=useRef6(null);useEffect5(()=>{overRef.current=over},[over]);const detach=useRef6(null);const finishRef=useRef6(()=>{});const countRef=useRef6(count);useEffect5(()=>{countRef.current=count},[count]);const soft=!reducedMotion();const EASE="cubic-bezier(.2,.8,.2,1)";const measure=useCallback2(()=>{const list=nodes.current.slice(0,count);rects.current=list.map(el=>{const r=el?.getBoundingClientRect();return{left:r?.left??0,top:r?.top??0,width:r?.width??0,height:r?.height??0}});const h=host.current?.getBoundingClientRect();hostBox.current=h?{left:h.left,top:h.top,width:h.width,height:h.height}:null;const gap=rects.current.length>1?Math.max(0,rects.current[1].top-(rects.current[0].top+rects.current[0].height)):0;return gap},[count]);const finish=useCallback2(()=>{const s=run.current;if(!s.active)return;s.active=false;cancelAnimationFrame(s.raf);detach.current?.();detach.current=null;const from=s.from;const to=overRef.current??from;const el=nodes.current[from];const settle=()=>{setDragging(null);setOver(null);setFrozen(null);overRef.current=null;if(el){el.style.transition="";el.style.removeProperty("--drag-x");el.style.removeProperty("--drag-y")}if(to!==from){onMove(from,to);setMessage(fill(ui.sortMovedTo,{name:itemLabel?.(from)??ui.sortItem,n:to+1,total:count}))}};if(!el||!soft||to===from)return settle();const r=rects.current;if(grid){el.style.transition=`transform 190ms ${EASE}`;el.style.setProperty("--drag-x",`${r[to].left-r[from].left}px`);el.style.setProperty("--drag-y",`${r[to].top-r[from].top}px`);window.setTimeout(settle,200);return}const target=to>from?r[to].top+r[to].height-(r[from].top+r[from].height):r[to].top-r[from].top;el.style.transition=`transform 190ms ${EASE}`;el.style.setProperty("--drag-y",`${target}px`);window.setTimeout(settle,200)},[count,grid,itemLabel,onMove,soft,ui]);useEffect5(()=>{finishRef.current=finish},[finish]);const clamp2=useCallback2((dy,from)=>{const r=rects.current;const last=r[r.length-1];if(!r.length||!r[from]||!last)return dy;const min=r[0].top-r[from].top;const max=last.top+last.height-(r[from].top+r[from].height);return Math.min(Math.max(dy,min),max)},[]);const attach=useCallback2(()=>{function onPointerMove(e){const s=run.current;if(!s.active||e.pointerId!==s.pointerId)return;s.dy=e.clientY-s.startY;if(grid){s.dx=e.clientX-s.startX;const next2=hitSlot(e.clientX,e.clientY,rects.current,countRef.current);if(next2!==-1&&next2!==overRef.current){overRef.current=next2;setOver(next2)}cancelAnimationFrame(s.raf);s.raf=requestAnimationFrame(()=>{const el=nodes.current[s.from];el?.style.setProperty("--drag-x",`${s.dx}px`);el?.style.setProperty("--drag-y",`${s.dy}px`)});return}const r=rects.current;const n=countRef.current;const center=r[s.from].top+r[s.from].height/2+s.dy;let next=s.from;if(s.dy>0){for(let i=s.from+1;i<n;i++){if(center>r[i].top+r[i].height/2)next=i}}else{for(let i=s.from-1;i>=0;i--){if(center<r[i].top+r[i].height/2)next=i}}if(next!==overRef.current){overRef.current=next;setOver(next)}cancelAnimationFrame(s.raf);s.raf=requestAnimationFrame(()=>{nodes.current[s.from]?.style.setProperty("--drag-y",`${clamp2(s.dy,s.from)}px`)})}function onUp(e){if(e.pointerId!==run.current.pointerId)return;finishRef.current()}function onKey(e){if(e.key==="Escape"){overRef.current=run.current.from;finishRef.current()}}window.addEventListener("pointermove",onPointerMove,{passive:true});window.addEventListener("pointerup",onUp);window.addEventListener("pointercancel",onUp);window.addEventListener("keydown",onKey);detach.current=()=>{window.removeEventListener("pointermove",onPointerMove);window.removeEventListener("pointerup",onUp);window.removeEventListener("pointercancel",onUp);window.removeEventListener("keydown",onKey)}},[clamp2,grid]);useEffect5(()=>()=>detach.current?.(),[]);useLayoutEffect2(()=>{if(grabbed!==null)nodes.current[grabbed]?.focus()},[grabbed]);const item=useCallback2(index=>{const isDragged=dragging===index;const isGrabbed=grabbed===index;const slot2=dragging!==null&&over!==null?slotOf(index,dragging,over):index;let shift=0;if(dragging!==null&&over!==null&&!isDragged){const slot3=run.current.slot;if(over>dragging&&index>dragging&&index<=over)shift=-slot3;else if(over<dragging&&index>=over&&index<dragging)shift=slot3}const box=grid&&dragging!==null?rects.current[isDragged?dragging:slot2]:null;const frame=hostBox.current;const gridStyle=box&&frame?{position:"absolute",left:box.left-frame.left,top:box.top-frame.top,width:box.width,height:box.height,transform:isDragged?"translate3d(var(--drag-x, 0px), var(--drag-y, 0px), 0)":void 0,transition:isDragged?void 0:soft?`left 160ms ${EASE}, top 160ms ${EASE}, width 160ms ${EASE}, height 160ms ${EASE}`:void 0,zIndex:isDragged?20:1,cursor:isDragged?"grabbing":void 0,touchAction:"none",willChange:isDragged?"transform":void 0}:null;const style=gridStyle??(isDragged?{transform:"translate3d(0, var(--drag-y, 0px), 0)",position:"relative",zIndex:20,cursor:"grabbing",touchAction:"none",willChange:"transform"}:{transform:shift?`translate3d(0, ${shift}px, 0)`:void 0,transition:dragging!==null&&soft?`transform 160ms ${EASE}`:void 0,touchAction:disabled?void 0:"none"});return{ref:el=>{nodes.current[index]=el},style,tabIndex:disabled?-1:0,"aria-roledescription":ui.grabHint,"data-dragging":isDragged?"":void 0,"data-grabbed":isGrabbed?"":void 0,onPointerDown:e=>{if(disabled||e.button!==0)return;const startX=e.clientX;const startY=e.clientY;const el=e.currentTarget;const begin=ev=>{const moved=grid?Math.abs(ev.clientX-startX)>=threshold||Math.abs(ev.clientY-startY)>=threshold:Math.abs(ev.clientY-startY)>=threshold;if(!moved)return;window.removeEventListener("pointermove",begin);const gap=measure();const s=run.current;s.active=true;s.from=index;s.startX=startX;s.startY=startY;s.dx=ev.clientX-startX;s.dy=ev.clientY-startY;s.slot=rects.current[index].height+gap;s.pointerId=ev.pointerId;el.setPointerCapture?.(ev.pointerId);if(grid){el.style.setProperty("--drag-x",`${s.dx}px`);el.style.setProperty("--drag-y",`${s.dy}px`);setFrozen(hostBox.current?.height??null)}else{el.style.setProperty("--drag-y",`${clamp2(s.dy,index)}px`)}overRef.current=index;attach();setOver(index);setDragging(index);setMessage(fill(ui.sortMoving,{name:itemLabel?.(index)??ui.sortItem}))};const stop=()=>{window.removeEventListener("pointermove",begin);window.removeEventListener("pointerup",stop)};window.addEventListener("pointermove",begin);window.addEventListener("pointerup",stop)},onKeyDown:e=>{if(disabled)return;if(e.key===" "||e.key==="Enter"){e.preventDefault();if(grabbed===index){setGrabbed(null);setMessage(fill(ui.sortSettled,{name:itemLabel?.(index)??ui.sortItem,n:index+1}))}else{setGrabbed(index);setMessage(fill(ui.sortGrabbed,{name:itemLabel?.(index)??ui.sortItem}))}return}if(grabbed!==index)return;const rtl=grid&&getComputedStyle(e.currentTarget).direction==="rtl";const back=grid?rtl?"ArrowRight":"ArrowLeft":null;const forth=grid?rtl?"ArrowLeft":"ArrowRight":null;const dir=e.key==="ArrowUp"||e.key===back?-1:e.key==="ArrowDown"||e.key===forth?1:0;if(dir){e.preventDefault();const to=index+dir;if(to<0||to>=count)return;onMove(index,to);setGrabbed(to);setMessage(fill(ui.sortAt,{name:itemLabel?.(index)??ui.sortItem,n:to+1,total:count}))}if(e.key==="Escape"){e.preventDefault();setGrabbed(null);setMessage(ui.sortCancelled)}}}},[attach,clamp2,count,disabled,dragging,grabbed,grid,itemLabel,measure,onMove,over,soft,threshold,ui]);const container=useCallback2(()=>({ref:el=>{host.current=el},style:frozen===null?{}:{height:frozen}}),[frozen]);const rank=useCallback2(index=>dragging===null||over===null?index:slotOf(index,dragging,over),[dragging,over]);const slot=useCallback2(index=>{if(dragging===null)return null;const b=rects.current[index];const frame=hostBox.current;if(!b||!frame)return null;return{left:b.left-frame.left,top:b.top-frame.top,width:b.width,height:b.height}},[dragging]);return{item,container,rank,slot,dragging,grabbed,over,message}}function SortableStatus({message}){return jsx11("span",{role:"status","aria-live":"polite",className:"sr-only",children:message})}import{Children,useCallback as useCallback3,useEffect as useEffect6,useRef as useRef7,useState as useState8}from"react";import{ChevronLeft,ChevronRight,Pause,Play,X as X4,ZoomIn}from"lucide-react";import{jsx as jsx12,jsxs as jsxs11}from"react/jsx-runtime";function axis(track){const rtl=getComputedStyle(track).direction==="rtl";return{rtl,start:r=>rtl?-r.right:r.left,end:r=>rtl?-r.left:r.right}}var EDGE2=1;function readTrack(track){const slides=Array.from(track.children);if(slides.length===0)return{index:0,atStart:true,atEnd:true};const{start,end}=axis(track);const box=track.getBoundingClientRect();const from=start(box);let index=0;let best=Infinity;slides.forEach((el,i)=>{const d=start(el.getBoundingClientRect())-from;const score=d<0?-d:d;if(score<best){best=score;index=i}});return{index,atStart:start(slides[0].getBoundingClientRect())>=from-EDGE2,atEnd:end(slides[slides.length-1].getBoundingClientRect())<=end(box)+EDGE2}}function scrollToIndex(track,i,behavior){const el=track.children[i];if(!el)return;const{rtl}=axis(track);const box=track.getBoundingClientRect();const r=el.getBoundingClientRect();track.scrollBy({left:rtl?r.right-box.right:r.left-box.left,behavior})}function ease(){return typeof matchMedia!=="undefined"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}var BASIS="calc((100% - (var(--per) - 1) * var(--gap)) / var(--per))";function Carousel({label,children,perView,gap=12,arrows=true,dots=false,counter=false,autoplay,index,onIndexChange,className,trackClassName}){const en=useMoneyLang();const trackRef=useRef7(null);const[state,setState]=useState8({index:0,atStart:true,atEnd:true});const[paused,setPaused]=useState8(false);const[held,setHeld]=useState8(false);const slides=Children.toArray(children);const count=slides.length;const latest=useRef7(state);const notify=useRef7(onIndexChange);useEffect6(()=>{latest.current=state},[state]);useEffect6(()=>{notify.current=onIndexChange},[onIndexChange]);const measure=useCallback3(()=>{const track=trackRef.current;if(!track)return;const next=readTrack(track);setState(prev=>prev.index===next.index&&prev.atStart===next.atStart&&prev.atEnd===next.atEnd?prev:next)},[]);const target=useRef7(0);const go=useCallback3(to=>{const track=trackRef.current;if(!track)return;const i=Math.min(Math.max(to,0),track.children.length-1);target.current=i;scrollToIndex(track,i,ease())},[]);const first=useRef7(true);const told=useRef7(null);useEffect6(()=>{const track=trackRef.current;if(index==null||!track)return;if(index===told.current)return;target.current=index;scrollToIndex(track,index,first.current?"auto":ease())},[index]);useEffect6(()=>{const track=trackRef.current;if(!track)return;let frame=0;let idle;const onScroll=()=>{cancelAnimationFrame(frame);frame=requestAnimationFrame(measure);clearTimeout(idle);idle=setTimeout(()=>{const t=trackRef.current;if(t)target.current=readTrack(t).index},140)};track.addEventListener("scroll",onScroll,{passive:true});const ro=new ResizeObserver(onScroll);ro.observe(track);measure();first.current=false;return()=>{cancelAnimationFrame(frame);clearTimeout(idle);track.removeEventListener("scroll",onScroll);ro.disconnect()}},[measure,count]);useEffect6(()=>{if(told.current===state.index)return;const knew=told.current!==null;told.current=state.index;if(knew||state.index!==(index??0))notify.current?.(state.index)},[state.index,index]);useEffect6(()=>{if(!autoplay||paused||held||count<2)return;if(typeof matchMedia!=="undefined"&&matchMedia("(prefers-reduced-motion: reduce)").matches){return}const id=setInterval(()=>{const track=trackRef.current;if(!track||document.hidden)return;const now=latest.current;scrollToIndex(track,now.atEnd?0:now.index+1,ease())},autoplay);return()=>clearInterval(id)},[autoplay,paused,held,count]);function onKeyDown(e){const track=trackRef.current;if(!track)return;const{rtl}=axis(track);const forward=rtl?"ArrowLeft":"ArrowRight";const back=rtl?"ArrowRight":"ArrowLeft";const to=e.key===forward?target.current+1:e.key===back?target.current-1:e.key==="Home"?0:e.key==="End"?count-1:null;if(to===null)return;e.preventDefault();go(to)}const many=count>1;const showArrows=arrows&&many;const showBar=many&&(dots||counter||Boolean(autoplay));const arrow=back=>jsx12("button",{type:"button",disabled:back?state.atStart:state.atEnd,"aria-label":back?en?"Previous":"\u0627\u0644\u0633\u0627\u0628\u0642":en?"Next":"\u0627\u0644\u062A\u0627\u0644\u064A",onClick:()=>go(back?target.current-1:target.current+1),className:cn("absolute top-1/2 -translate-y-1/2 z-10 size-9 rounded-full flex items-center justify-center","bg-surface/92 backdrop-blur border border-line shadow-pop text-ink2","transition-opacity cursor-pointer hover:text-brand-ink","disabled:opacity-0 disabled:pointer-events-none",back?"start-2":"end-2"),children:back?jsx12(ChevronRight,{size:17,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx12(ChevronLeft,{size:17,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})});return jsxs11("section",{"aria-roledescription":en?"carousel":"\u0639\u0627\u0631\u0636 \u0634\u0631\u0627\u0626\u062D","aria-label":label,onPointerEnter:()=>autoplay&&setHeld(true),onPointerLeave:()=>autoplay&&setHeld(false),onFocusCapture:()=>autoplay&&setHeld(true),onBlurCapture:()=>autoplay&&setHeld(false),className:cn("flex flex-col gap-3 [--per:1]",className),style:{"--gap":`${gap}px`,...perView===void 0?null:{"--per":String(perView)}},children:[jsxs11("div",{className:"relative",children:[jsx12("div",{ref:trackRef,tabIndex:0,role:"group","aria-label":en?"Slides":"\u0627\u0644\u0634\u0631\u0627\u0626\u062D",onKeyDown,className:cn("flex overflow-x-auto overscroll-x-contain snap-x snap-mandatory","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden","rounded-card focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",trackClassName),style:{gap:"var(--gap)"},children:slides.map((slide,i)=>jsx12("div",{role:"group","aria-roledescription":en?"slide":"\u0634\u0631\u064A\u062D\u0629","aria-label":en?`${i+1} of ${count}`:`${i+1} \u0645\u0646 ${count}`,className:"snap-start shrink-0 grow-0 min-w-0 relative",style:{flexBasis:BASIS},children:slide},i))}),showArrows&&arrow(true),showArrows&&arrow(false)]}),showBar&&jsxs11("div",{className:"flex items-center justify-center gap-3",children:[autoplay&&jsx12("button",{type:"button",onClick:()=>setPaused(p=>!p),"aria-label":paused?en?"Start auto-rotation":"\u0634\u063A\u0651\u0644 \u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0627\u0644\u062A\u0644\u0642\u0627\u0626\u064A":en?"Stop auto-rotation":"\u0623\u0648\u0642\u0641 \u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0627\u0644\u062A\u0644\u0642\u0627\u0626\u064A",className:"size-7 rounded-full flex items-center justify-center text-muted hover:bg-hover hover:text-ink transition-colors cursor-pointer",children:paused?jsx12(Play,{size:13,"aria-hidden":"true"}):jsx12(Pause,{size:13,"aria-hidden":"true"})}),dots&&jsx12("span",{className:"flex items-center gap-1.5",children:slides.map((_,i)=>jsx12("button",{type:"button",onClick:()=>go(i),"aria-label":en?`Go to slide ${i+1}`:`\u0627\u0630\u0647\u0628 \u0644\u0644\u0634\u0631\u064A\u062D\u0629 ${i+1}`,"aria-current":i===state.index||void 0,className:cn("h-1.5 rounded-full transition-all duration-200 cursor-pointer","before:absolute before:-inset-2 relative",i===state.index?"w-5 bg-brand":"w-1.5 bg-border hover:bg-muted2")},i))}),counter&&jsxs11("span",{dir:"ltr","data-num":true,"aria-live":autoplay?void 0:"polite",className:"text-caption font-bold text-muted tabular-nums",children:[state.index+1," / ",count]})]})]})}function Gallery({label,images,ratio="4/3",fit="cover",thumbs=true,zoom=true,className}){const en=useMoneyLang();const[index,setIndex]=useState8(0);const[open,setOpen]=useState8(false);const activeThumb=useRef7(null);useEffect6(()=>{activeThumb.current?.scrollIntoView({inline:"nearest",block:"nearest",behavior:ease()})},[index]);if(images.length===0)return null;const frame={aspectRatio:ratio};const img=(im,decorative)=>jsx12("img",{src:im.src,alt:decorative?"":im.alt,loading:"lazy",decoding:"async",draggable:false,className:cn("w-full h-full",fit==="cover"?"object-cover":"object-contain")});return jsxs11("div",{className:cn("flex flex-col gap-2.5",className),children:[jsx12(Carousel,{label,index,onIndexChange:setIndex,counter:images.length>1,dots:!thumbs&&images.length>1,gap:8,children:images.map((im,i)=>zoom?jsxs11("button",{type:"button",onClick:()=>setOpen(true),"aria-label":`${im.alt} \u2014 ${en?"open viewer":"\u0641\u062A\u062D \u0627\u0644\u0639\u0627\u0631\u0636"}`,style:frame,className:"group relative block w-full overflow-clip rounded-card bg-hover cursor-zoom-in",children:[img(im,true),jsx12("span",{"aria-hidden":"true",className:"absolute top-2 end-2 size-7 rounded-full bg-black/45 backdrop-blur text-white flex items-center justify-center opacity-70 transition-opacity group-hover:opacity-100",children:jsx12(ZoomIn,{size:14})})]},i):jsx12("div",{style:frame,className:"overflow-clip rounded-card bg-hover",children:img(im,false)},i))}),thumbs&&images.length>1&&jsx12("div",{role:"group","aria-label":en?"Thumbnails":"\u0627\u0644\u0645\u0635\u063A\u0651\u0631\u0627\u062A",className:"flex gap-2 overflow-x-auto pb-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:images.map((im,i)=>jsx12("button",{ref:i===index?activeThumb:void 0,type:"button",onClick:()=>setIndex(i),"aria-current":i===index||void 0,"aria-label":en?`Image ${i+1}`:`\u0627\u0644\u0635\u0648\u0631\u0629 ${i+1}`,className:cn("shrink-0 size-14 rounded-sm overflow-clip border-2 bg-hover cursor-pointer transition-colors",i===index?"border-brand":"border-line hover:border-border"),children:jsx12("img",{src:im.src,alt:"",loading:"lazy",decoding:"async",draggable:false,className:"w-full h-full object-cover"})},i))}),zoom&&jsx12(Lightbox,{open,images,index,onIndexChange:setIndex,onClose:()=>setOpen(false),label})]})}function Lightbox({open,images,index,onIndexChange,onClose,label,closeLabel}){const ui=useUIText();const en=useMoneyLang();const panel=useRef7(null);const count=images.length;useEffect6(()=>{if(!open)return;const from=document.activeElement;panel.current?.focus();return()=>from?.focus?.()},[open]);useEffect6(()=>{if(!open)return;function onKey(e){const rtl=getComputedStyle(document.documentElement).direction==="rtl";const forward=rtl?"ArrowLeft":"ArrowRight";const back=rtl?"ArrowRight":"ArrowLeft";if(e.key==="Escape")onClose();else if(e.key===forward)onIndexChange(Math.min(index+1,count-1));else if(e.key===back)onIndexChange(Math.max(index-1,0));else if(e.key==="Home")onIndexChange(0);else if(e.key==="End")onIndexChange(count-1)}document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[open,index,count,onClose,onIndexChange]);if(!open||count===0)return null;const current=images[Math.min(Math.max(index,0),count-1)];const step=back=>jsx12("button",{type:"button",disabled:back?index===0:index>=count-1,onClick:()=>onIndexChange(back?index-1:index+1),"aria-label":back?en?"Previous":"\u0627\u0644\u0633\u0627\u0628\u0642":en?"Next":"\u0627\u0644\u062A\u0627\u0644\u064A",className:cn("absolute top-1/2 -translate-y-1/2 z-10 size-11 rounded-full flex items-center justify-center","bg-white/10 backdrop-blur text-white transition-opacity cursor-pointer hover:bg-white/20","disabled:opacity-0 disabled:pointer-events-none",back?"start-3":"end-3"),children:back?jsx12(ChevronRight,{size:20,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx12(ChevronLeft,{size:20,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})});return jsxs11("div",{ref:panel,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":label??(en?"Image viewer":"\u0639\u0627\u0631\u0636 \u0627\u0644\u0635\u0648\u0631"),className:"fixed inset-0 z-50 bg-night/95 flex flex-col animate-[fade-in_0.18s_ease-out] outline-none",children:[jsxs11("header",{className:"shrink-0 h-14 px-4 flex items-center justify-between gap-3",children:[jsxs11("span",{dir:"ltr","data-num":true,className:"text-caption font-bold text-white/70 tabular-nums",children:[index+1," / ",count]}),jsx12("button",{type:"button",onClick:onClose,"aria-label":closeLabel??ui.close,className:"size-9 rounded-full bg-white/10 backdrop-blur flex items-center justify-center text-white transition-colors cursor-pointer hover:bg-white/20",children:jsx12(X4,{size:18,"aria-hidden":"true"})})]}),jsxs11("div",{className:"relative flex-1 min-h-0 flex items-center justify-center p-4 pb-8",children:[jsx12("img",{src:current.src,alt:current.alt,decoding:"async",draggable:false,className:"max-w-full max-h-full object-contain rounded-card animate-qfade"},current.src),count>1&&step(true),count>1&&step(false)]})]})}import{useEffect as useEffect7,useLayoutEffect as useLayoutEffect3,useRef as useRef8,useState as useState9}from"react";import{ChevronLeft as ChevronLeft2,ChevronRight as ChevronRight2,Lock,RotateCw,Signal,Wifi}from"lucide-react";import{jsx as jsx13,jsxs as jsxs12}from"react/jsx-runtime";function BrowserFrame({url,device="desktop",tab,nav,loading,contentWidth,onScale,onReload,children,className}){const ui=useUIText();const mobile=device==="mobile";const viewport=useRef8(null);const[scale,setScale]=useState9(1);const[rtl,setRtl]=useState9(true);useLayoutEffect3(()=>{const box=viewport.current;if(!box||!contentWidth)return setScale(1);setRtl(getComputedStyle(box).direction==="rtl");const read=()=>{const w=box.clientWidth;setScale(w>0?Math.min(1,w/contentWidth):1)};read();const ro=new ResizeObserver(read);ro.observe(box);return()=>ro.disconnect()},[contentWidth]);useEffect7(()=>{onScale?.(scale)},[scale,onScale]);const control="shrink-0 size-6 rounded-full flex items-center justify-center transition-colors";return jsxs12("div",{className:cn("flex flex-col overflow-clip bg-surface border border-line shadow-panel",mobile?"rounded-[30px] border-[7px] border-night":"rounded-lg",className),children:[mobile&&jsxs12("div",{className:"shrink-0 h-7 px-5 flex items-center justify-between bg-bg","aria-hidden":"true",children:[jsxs12("span",{className:"flex items-center gap-1 text-muted2",children:[jsx13(Signal,{size:11}),jsx13(Wifi,{size:11}),jsx13("span",{className:"w-4 h-2 rounded-[2px] border border-muted2"})]}),jsx13("span",{className:"w-16 h-4 rounded-full bg-night"})]}),tab&&!mobile&&jsx13("div",{className:"shrink-0 flex items-end gap-1 px-2.5 pt-2 bg-bg border-b border-line",children:jsxs12("span",{className:"flex items-center gap-2 h-8 max-w-[220px] px-3 rounded-t-sm bg-surface border border-line border-b-0",children:[jsx13("span",{"aria-hidden":"true",className:"size-3 rounded-[3px] bg-soft2 shrink-0"}),jsx13("span",{className:"text-micro text-ink2 truncate",children:tab})]})}),jsxs12("div",{className:cn("relative shrink-0 flex items-center gap-2 bg-bg border-b border-line",mobile?"px-2.5 py-2":"px-3 py-2.5"),children:[!mobile&&!tab&&jsx13("span",{"aria-hidden":"true",className:"flex items-center gap-1.5 shrink-0 me-1",children:[0,1,2].map(i=>jsx13("span",{className:"size-2.5 rounded-full bg-line border border-border/40"},i))}),nav&&!mobile&&jsxs12("span",{className:"flex items-center gap-0.5 shrink-0 text-muted2/60",children:[jsx13("span",{className:cn(control,"cursor-not-allowed"),"aria-hidden":"true",children:jsx13(ChevronRight2,{size:13})}),jsx13("span",{className:cn(control,"cursor-not-allowed"),"aria-hidden":"true",children:jsx13(ChevronLeft2,{size:13})})]}),jsxs12("span",{className:cn("flex-1 min-w-0 flex items-center gap-1.5 rounded-full bg-surface border border-line",mobile?"h-6 px-2.5":"h-7 px-3"),children:[jsx13(Lock,{size:mobile?9:10,className:"text-green shrink-0","aria-hidden":"true"}),jsx13(TechnicalText,{className:cn("truncate text-muted",mobile?"text-[9.5px]":"text-micro"),children:url})]}),onReload&&!mobile&&jsx13("button",{type:"button",onClick:onReload,"aria-label":ui.reloadPreview,className:cn(control,"text-muted2 hover:bg-hover hover:text-ink cursor-pointer"),children:jsx13(RotateCw,{size:12,"aria-hidden":"true",className:cn(loading&&"animate-spin")})}),loading&&jsx13("span",{"aria-hidden":"true",className:"absolute bottom-0 inset-x-0 h-[2px] overflow-clip",children:jsx13("span",{className:"absolute top-0 h-full w-[35%] bg-brand animate-[qload_1.1s_ease-in-out_infinite]"})})]}),jsx13("div",{ref:viewport,className:"relative flex-1 min-h-0 overflow-clip bg-surface",children:contentWidth?jsx13("div",{style:{width:contentWidth,height:`${100/scale}%`,transform:`scale(${scale})`,transformOrigin:`top ${rtl?"right":"left"}`},children}):children}),mobile&&jsx13("span",{"aria-hidden":"true",className:"shrink-0 h-4 bg-bg flex items-center justify-center",children:jsx13("span",{className:"w-24 h-1 rounded-full bg-border/50"})})]})}import"react";import{jsx as jsx14,jsxs as jsxs13}from"react/jsx-runtime";var clamp=(v,lo=0,hi=100)=>Math.min(hi,Math.max(lo,v));var signedString=v=>(v<0?"\u2212":"")+String(Math.abs(v));function WaterfallChart({total,steps,totalLabel,netLabel,formatValue=signedString,className}){const ui=useUIText();const top=Math.max(1,total);const bars=steps.reduce((acc,s)=>{const from=acc.length?acc[acc.length-1].to:total;acc.push({...s,from,to:from+s.value});return acc},[]);const net=bars.length?bars[bars.length-1].to:total;const biggest=bars.reduce((acc,b,i)=>b.value<acc.v?{i,v:b.value}:acc,{i:-1,v:0});return jsxs13("div",{className:cn("flex flex-col",className),children:[jsx14(Line,{label:totalLabel??ui.totalSales,value:total,formatValue,strong:true,children:jsx14("span",{className:"block h-2.5 rounded-full bg-brand"})}),bars.map((b,i)=>{const drop=b.value<0;const lo=clamp(Math.min(b.from,b.to)/top*100);const span=clamp(Math.abs(b.value)/top*100);const worst=i===biggest.i;return jsx14(Line,{label:b.label,meta:b.meta,value:b.value,formatValue,flag:worst?"\u0623\u0643\u0628\u0631 \u062E\u0635\u0645":void 0,children:jsx14("span",{dir:"ltr",className:"relative block h-2.5 rounded-full bg-hover overflow-clip",children:jsx14("span",{className:cn("absolute inset-y-0 rounded-full",drop?worst?"bg-danger":"bg-brand-100":"bg-green-solid"),style:{insetInlineStart:`${lo}%`,width:`${span}%`}})})},b.key)}),jsx14(Line,{label:netLabel??ui.netToYou,value:net,formatValue,strong:true,net:true,children:jsx14("span",{dir:"ltr",className:"block h-2.5 rounded-full bg-hover overflow-clip",children:jsx14("span",{className:"block h-full rounded-full bg-green-solid",style:{width:`${clamp(net/top*100)}%`}})})})]})}function Line({label,meta,value,formatValue,flag,strong,net,children}){return jsxs13("div",{className:cn("flex flex-col gap-1.5 py-2.5",net&&"border-t border-line mt-1 pt-3.5"),children:[jsxs13("span",{className:"flex items-baseline justify-between gap-3",children:[jsxs13("span",{className:"flex items-baseline gap-2 min-w-0",children:[jsx14("span",{className:cn("truncate",strong?"text-ui font-extrabold text-ink":"text-ui text-muted"),children:label}),flag&&jsx14("span",{className:"shrink-0 text-micro font-bold text-red bg-red-bg px-1.5 py-0.5 rounded-mark",children:flag})]}),jsx14("span",{"data-num":true,className:cn("shrink-0",strong?"text-body font-black text-ink":"text-ui font-bold text-ink2"),children:formatValue(value)})]}),children,meta&&jsx14("span",{className:"text-micro text-muted2",children:meta})]})}function GoalBar({value,goal,pace,label,formatValue=String,className}){const ui=useUIText();const top=Math.max(value,goal)*1.06;const pct=clamp(value/top*100);const goalAt=clamp(goal/top*100);const paceAt=pace===void 0?null:clamp(goalAt*clamp(pace,0,1));const behind=paceAt!==null&&pct<paceAt;return jsxs13("div",{className:cn("flex flex-col gap-2",className),children:[jsxs13("span",{className:"flex items-baseline justify-between gap-3",children:[label&&jsx14("span",{className:"text-ui font-bold text-ink2 truncate",children:label}),jsxs13("span",{className:"flex items-baseline gap-1.5 shrink-0",children:[jsx14("span",{"data-num":true,className:"text-body font-black text-ink",children:formatValue(value)}),jsxs13("span",{className:"text-micro text-muted2",children:["\u0645\u0646 ",jsx14("span",{"data-num":true,children:formatValue(goal)})]})]})]}),jsxs13("span",{dir:"ltr",className:"relative block h-3 rounded-full bg-hover",children:[jsx14("span",{className:cn("absolute inset-y-0 start-0 rounded-full transition-[width] duration-500",behind?"bg-amber":"bg-brand"),style:{width:`${pct}%`}}),paceAt!==null&&jsx14("span",{"aria-hidden":"true",title:ui.shouldBeHere,className:"absolute -top-1 -bottom-1 w-0.5 bg-muted2 rounded-full",style:{insetInlineStart:`${paceAt}%`}}),jsx14("span",{"aria-hidden":"true",className:"absolute -top-1.5 -bottom-1.5 w-1 bg-ink rounded-full",style:{insetInlineStart:`${goalAt}%`}})]}),paceAt!==null&&jsx14("span",{className:cn("text-micro",behind?"text-amber-ink":"text-muted2"),children:behind?"\u0648\u0631\u0627 \u0627\u0644\u0625\u064A\u0642\u0627\u0639 \u0627\u0644\u0645\u0637\u0644\u0648\u0628":"\u0642\u062F\u0651\u0627\u0645 \u0627\u0644\u0625\u064A\u0642\u0627\u0639 \u0627\u0644\u0645\u0637\u0644\u0648\u0628"})]})}function ParetoChart({items,height=140,threshold=80,formatValue=String,className}){const sorted=[...items].sort((a,b)=>b.value-a.value);const sum=sorted.reduce((s,i)=>s+i.value,0)||1;const top=Math.max(1,sorted[0]?.value??1);const rows=sorted.reduce((out,it)=>{const acc=(out.length?out[out.length-1].cum*sum/100:0)+it.value;out.push({...it,cum:acc/sum*100});return out},[]);const vital=rows.findIndex(r=>r.cum>=threshold)+1;return jsxs13("div",{className:cn("flex flex-col gap-2.5",className),children:[jsxs13("span",{className:"text-caption text-muted [text-wrap:pretty]",children:[jsx14("span",{"data-num":true,className:"font-extrabold text-ink",children:vital})," ","\u0645\u0646"," ",jsx14("span",{"data-num":true,className:"font-extrabold text-ink",children:rows.length})," ","\u0628\u064A\u0639\u0645\u0644\u0648\u0627"," ",jsx14("span",{"data-num":true,className:"font-extrabold text-ink",children:threshold}),"\u066A \u0645\u0646 \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A"]}),jsxs13("div",{className:"relative flex items-end gap-1.5",style:{height},children:[jsx14("span",{"aria-hidden":"true",className:"absolute inset-x-0 border-t border-dashed border-muted2",style:{top:`${100-threshold}%`}}),rows.map((r,i)=>jsx14("span",{className:"flex-1 min-w-0 flex flex-col justify-end items-center gap-1 h-full",children:jsx14("span",{title:`${String(r.label)} \xB7 ${formatValue(r.value)}`,className:cn("w-full rounded-t-mark transition-[height] duration-500",i<vital?"bg-brand":"bg-brand-100"),style:{height:`${clamp(r.value/top*100)}%`}})},r.key))]}),jsx14("div",{className:"flex items-center gap-1.5",children:rows.map((r,i)=>jsx14("span",{className:cn("flex-1 min-w-0 text-micro text-center truncate",i<vital?"text-ink2 font-bold":"text-muted2"),children:r.label},r.key))})]})}function StockRunway({items,urgentDays=7,horizonDays=30,className}){const rows=items.map(it=>({...it,days:it.perDay>0?it.stock/it.perDay:Infinity})).sort((a,b)=>a.days-b.days);return jsx14("div",{className:cn("flex flex-col gap-2.5",className),children:rows.map(r=>{const urgent=r.days<=urgentDays;const soon=!urgent&&r.days<=horizonDays/2;const pct=Number.isFinite(r.days)?clamp(r.days/horizonDays*100):100;return jsxs13("span",{className:"flex flex-col gap-1.5",children:[jsxs13("span",{className:"flex items-baseline justify-between gap-3",children:[jsx14("span",{className:"text-ui text-ink2 truncate min-w-0",children:r.label}),jsxs13("span",{className:"flex items-baseline gap-2 shrink-0",children:[jsxs13("span",{"data-num":true,className:"text-micro text-muted2",children:[r.stock," \u0642\u0637\u0639\u0629"]}),jsx14("span",{"data-num":true,className:cn("text-ui font-extrabold",urgent?"text-red":soon?"text-amber-ink":"text-ink"),children:Number.isFinite(r.days)?`${Math.floor(r.days)} \u064A\u0648\u0645`:"\u2014"})]})]}),jsx14("span",{dir:"ltr",className:"block h-1.5 rounded-full bg-hover overflow-clip",children:jsx14("span",{className:cn("block h-full rounded-full transition-[width] duration-500",urgent?"bg-danger":soon?"bg-amber":"bg-brand"),style:{width:`${pct}%`}})})]},r.key)})})}import{BadgeCheck}from"lucide-react";import{jsx as jsx15}from"react/jsx-runtime";var PROVIDER_LEVEL_LABEL={1:"\u0645\u0642\u062F\u0651\u0645 \u062C\u062F\u064A\u062F",2:"\u0645\u0642\u062F\u0651\u0645 \u0645\u062D\u062A\u0631\u0641",3:"\u0645\u0642\u062F\u0651\u0645 \u062E\u0628\u064A\u0631"};var PROVIDER_LEVEL_LABEL_EN={1:"New provider",2:"Pro provider",3:"Expert provider"};var CHEVRONS=[1.7,6,10.3];var DIM=.28;function ProviderMark({level,size=16,className}){return jsx15("svg",{width:size,height:size,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:cn("shrink-0",className),children:CHEVRONS.map((y,i)=>jsx15("path",{d:`M3.2 ${y+4}L8 ${y}L12.8 ${y+4}`,stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",opacity:i>=CHEVRONS.length-level?1:DIM},y))})}var LEVEL_TONE={1:"bg-hover text-ink2",2:"bg-soft text-brand-ink",3:TONE_SOLID.brand};var SIZES={sm:{box:"size-6",mark:14},md:{box:"size-7",mark:16}};function MarkChip({label,size,tone,className,children}){return jsx15(Tooltip,{content:label,children:jsx15("span",{role:"img","aria-label":label,tabIndex:0,className:cn("inline-flex items-center justify-center rounded-sm shrink-0 cursor-pointer","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",SIZES[size].box,tone,className),children})})}function ProviderBadge({level,size="sm",className}){const en=useMoneyLang();const label=en?PROVIDER_LEVEL_LABEL_EN[level]:PROVIDER_LEVEL_LABEL[level];return jsx15(MarkChip,{label,size,tone:LEVEL_TONE[level],className,children:jsx15(ProviderMark,{level,size:SIZES[size].mark})})}var VERIFIED_LABEL="\u062D\u0633\u0627\u0628 \u0645\u0648\u062B\u0651\u0642";var VERIFIED_LABEL_EN="Verified account";function VerifiedBadge({size="sm",className}){const en=useMoneyLang();return jsx15(MarkChip,{label:en?VERIFIED_LABEL_EN:VERIFIED_LABEL,size,tone:TONE_SOFT.green,className,children:jsx15(BadgeCheck,{size:SIZES[size].mark,strokeWidth:2,"aria-hidden":"true"})})}export{ANIMATE_SCALE,Accordion,Alert,AudioPlayer,Avatar,Badge,BarChart,BrowserFrame,Button,COLOR_SCALE,CONTAINER_SCALE,Calendar,Card,CardHeader,Carousel,Checkbox,ChoiceCards,Coach,CoachProvider,ColorField,Combobox,CommandPalette,Counter,DARK_TOKENS,DataTable,DateField,DateRangePicker,Drawer,Dropdown,Dropzone,EmptyState,FileRow,FilterChips,FunnelChart,Gallery,GoalBar,Heatmap,Input,Lightbox,LocaleCtx,Modal,Money,MoneyProvider,MultiSelect,NumberStepper,PROVIDER_LEVEL_LABEL,PROVIDER_LEVEL_LABEL_EN,PageHeader,ParetoChart,Phone,Picker,Product3DViewer,Progress,ProviderBadge,ProviderMark,RADIUS_SCALE,Radio,RadioGroup,RatingInput,SHADOW_SCALE,Scrubber,SearchInput,Select,ShareList,Sheet,Skeleton,SortableStatus,Sparkline,Stars,StatCard,Stepper,StockRunway,Switch,TEXT_SCALE,TOKENS,TONE_SOFT,TONE_SOLID,Tabs,TechnicalInput,TechnicalText,Textarea,Timeline,Toast,ToastHost,Tooltip,TrendChart,VerifiedBadge,VideoPlayer,WaterfallChart,WhatsAppIcon,buttonClasses,cn,coachSeconds,currencyName,currencySymbol,daysBetween,formatBytes,formatDate,formatRange,formatTime,isCurrency,normalizeHex,parsePhone,presets,toLatinDigits,useAudioLevel,useCoach,useCoachOptional,useCurrency,useCurrencySymbol,useMedia,useMoneyLang,useMoneyLocale,useSortable,useToasts,useUIText};
2
+ import{ToastHost,Tooltip,useToasts}from"./chunk-HSZOC7QG.js";import{BarChart,ChoiceCards,DataTable,FunnelChart,Heatmap,Money,MoneyProvider,ShareList,Sparkline,TrendChart,currencyName,currencySymbol,isCurrency,useCurrency,useCurrencySymbol}from"./chunk-QFJSDPEB.js";import{Button,Calendar,Checkbox,DateField,DateRangePicker,Input,Radio,RadioGroup,SearchInput,Select,Switch,Textarea,daysBetween,formatDate,formatRange,presets}from"./chunk-EM4MF5B3.js";import{AudioPlayer,Avatar,Badge,Card,CardHeader,Coach,CoachProvider,Counter,PageHeader,Progress,Scrubber,Skeleton,StatCard,VideoPlayer,coachSeconds,formatTime,useAudioLevel,useCoach,useCoachOptional,useMedia}from"./chunk-JOHJNMV2.js";import{Alert,Drawer,EmptyState,Modal,Sheet,Toast}from"./chunk-4ZNTBLVW.js";import{ANIMATE_SCALE,COLOR_SCALE,CONTAINER_SCALE,DARK_TOKENS,LocaleCtx,RADIUS_SCALE,SHADOW_SCALE,TEXT_SCALE,TOKENS,TONE_SOFT,TONE_SOLID,buttonClasses,cn,toLatinDigits,useMoneyLang,useMoneyLocale,useUIText}from"./chunk-YJ45RGS6.js";import{useEffect,useRef,useState}from"react";import{Minus,Plus,Trash2}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";var ar=new Intl.NumberFormat("ar-EG");var BOX={sm:"h-8",md:"h-11",lg:"h-14"};var BTN={sm:"w-8",md:"w-11",lg:"w-14"};var NUM={sm:"text-ui w-10",md:"text-body w-14",lg:"text-h3 w-20"};var ICON={sm:14,md:16,lg:20};function NumberStepper({value,onChange,min=0,max=Infinity,step=1,size="md",unit,onRemove,disabled,label,className}){const[draft,setDraft]=useState(null);const timer=useRef(void 0);useEffect(()=>()=>clearTimeout(timer.current),[]);const atMin=value<=min;const atMax=value>=max;const showRemove=Boolean(onRemove)&&atMin;const bump=dir=>onChange(Math.min(max,Math.max(min,value+dir*step)));const latest=useRef(value);useEffect(()=>{latest.current=value},[value]);function hold(dir){let delay=400;const tick=()=>{const next=Math.min(max,Math.max(min,latest.current+dir*step));if(next===latest.current)return;onChange(next);delay=Math.max(60,delay*.72);timer.current=setTimeout(tick,delay)};timer.current=setTimeout(tick,delay)}const stop=()=>clearTimeout(timer.current);function commit(raw){setDraft(null);const n=Number(toLatinDigits(raw).replace(/[^\d.-]/g,""));if(Number.isNaN(n))return;onChange(Math.min(max,Math.max(min,n)))}const btn=dir=>{const off=disabled||(dir===1?atMax:atMin&&!showRemove);const Icon=dir===1?Plus:showRemove?Trash2:Minus;return jsx("button",{type:"button",disabled:off,"aria-label":dir===1?"\u0632\u064A\u0627\u062F\u0629":showRemove?"\u062D\u0630\u0641":"\u0646\u0642\u0635\u0627\u0646",onClick:()=>dir===-1&&showRemove?onRemove?.():bump(dir),onPointerDown:()=>!off&&!showRemove&&hold(dir),onPointerUp:stop,onPointerLeave:stop,className:cn("flex items-center justify-center shrink-0 self-stretch cursor-pointer select-none","transition-colors",BTN[size],off?"text-muted2/45 cursor-not-allowed":cn("text-ink2 hover:bg-hover active:bg-soft",showRemove&&dir===-1&&"text-danger hover:bg-red-bg")),children:jsx(Icon,{size:ICON[size],strokeWidth:2.4,"aria-hidden":"true"})})};return jsxs("div",{dir:"ltr",className:cn("inline-flex items-center rounded-field border border-line bg-surface overflow-clip","divide-x divide-line","hover:border-border","focus-within:border-brand focus-within:ring-2 focus-within:ring-brand/25","transition-[border-color,box-shadow]",BOX[size],disabled&&"opacity-60",className),children:[btn(-1),jsxs("span",{className:"flex items-center justify-center gap-1 px-1 self-stretch",children:[jsx("input",{"data-num":true,value:draft??ar.format(value),disabled,inputMode:"numeric","aria-label":label??"\u0627\u0644\u0642\u064A\u0645\u0629",onFocus:()=>setDraft(String(value)),onChange:e=>setDraft(toLatinDigits(e.target.value)),onBlur:e=>commit(e.target.value),onKeyDown:e=>e.key==="Enter"&&e.target.blur(),className:cn("bg-transparent outline-none text-center font-extrabold text-ink","disabled:text-muted2",NUM[size])}),unit&&jsx("span",{className:"text-micro text-muted2 select-none shrink-0",children:unit})]}),btn(1)]})}import{MessageSquare,Phone as PhoneIcon}from"lucide-react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function WhatsAppIcon({size=15,...rest}){return jsx2("svg",{viewBox:"0 0 24 24",width:size,height:size,fill:"currentColor","aria-hidden":"true",...rest,children:jsx2("path",{d:"M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"})})}var DIAL={"20":{groups:[3,3,4],name:"\u0645\u0635\u0631"},"966":{groups:[2,3,4],name:"\u0627\u0644\u0633\u0639\u0648\u062F\u064A\u0629"},"971":{groups:[2,3,4],name:"\u0627\u0644\u0625\u0645\u0627\u0631\u0627\u062A"},"965":{groups:[4,4],name:"\u0627\u0644\u0643\u0648\u064A\u062A"},"974":{groups:[4,4],name:"\u0642\u0637\u0631"},"973":{groups:[4,4],name:"\u0627\u0644\u0628\u062D\u0631\u064A\u0646"},"968":{groups:[4,4],name:"\u0639\u064F\u0645\u0627\u0646"},"962":{groups:[1,4,4],name:"\u0627\u0644\u0623\u0631\u062F\u0646"},"964":{groups:[3,3,4],name:"\u0627\u0644\u0639\u0631\u0627\u0642"},"961":{groups:[2,3,3],name:"\u0644\u0628\u0646\u0627\u0646"},"963":{groups:[3,3,3],name:"\u0633\u0648\u0631\u064A\u0627"},"970":{groups:[2,3,4],name:"\u0641\u0644\u0633\u0637\u064A\u0646"},"967":{groups:[3,3,3],name:"\u0627\u0644\u064A\u0645\u0646"},"249":{groups:[3,3,3],name:"\u0627\u0644\u0633\u0648\u062F\u0627\u0646"},"212":{groups:[3,3,3],name:"\u0627\u0644\u0645\u063A\u0631\u0628"},"213":{groups:[3,3,3],name:"\u0627\u0644\u062C\u0632\u0627\u0626\u0631"},"216":{groups:[2,3,3],name:"\u062A\u0648\u0646\u0633"},"218":{groups:[2,3,4],name:"\u0644\u064A\u0628\u064A\u0627"},"222":{groups:[2,2,2,2],name:"\u0645\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u0627"},"252":{groups:[2,3,4],name:"\u0627\u0644\u0635\u0648\u0645\u0627\u0644"},"253":{groups:[2,2,2,2],name:"\u062C\u064A\u0628\u0648\u062A\u064A"},"269":{groups:[3,4],name:"\u062C\u0632\u0631 \u0627\u0644\u0642\u0645\u0631"}};var DIALS=Object.keys(DIAL).sort((a,b)=>b.length-a.length);function localLength(dial){return DIAL[dial]?.groups.reduce((a,b)=>a+b,0)??0}function parsePhone(raw,defaultDial="20"){const digits=raw.replace(/\D/g,"");let rest=digits;const intl=raw.trim().startsWith("+")||digits.startsWith("00");if(digits.startsWith("00"))rest=digits.slice(2);if(intl){for(const d of DIALS){if(rest.startsWith(d)){return{dial:d,local:rest.slice(d.length),country:DIAL[d].name}}}return{dial:"",local:rest}}if(!rest.startsWith("0")&&rest.length>localLength(defaultDial)){for(const d of DIALS){if(rest.startsWith(d)&&rest.length-d.length===localLength(d)){return{dial:d,local:rest.slice(d.length),country:DIAL[d].name}}}}const local=rest.replace(/^0/,"");return{dial:defaultDial,local,country:DIAL[defaultDial]?.name}}function join(parts,format){if(format==="spaces"||parts.length<2)return parts.join(" ");const[head,...tail]=parts;return`(${head}) ${tail.join("-")}`}function group(local,dial){const rule=DIAL[dial]?.groups;const out=[];let i=0;if(rule){for(const n of rule){if(i>=local.length)break;out.push(local.slice(i,i+n));i+=n}}while(i<local.length){out.push(local.slice(i,i+3));i+=3}return out.filter(Boolean)}var SIZE={inherit:"",sm:"text-caption",md:"text-ui"};function Phone({value,defaultDial="20",format="parens",mask,call,sms,whatsapp,size="md",className}){const{dial,local,country}=parsePhone(value,defaultDial);const e164=`+${dial}${local}`;const shown=mask?`\u2022\u2022\u2022 ${local.slice(-4)}`:dial?join(group(local,dial),format):`+${local}`;const bare=size==="inherit";return jsxs2("span",{className:cn("inline-flex items-center gap-2 min-w-0",className),children:[jsxs2("span",{dir:"ltr",className:cn("inline-flex items-baseline gap-1.5 whitespace-nowrap min-w-0",SIZE[size]),children:[dial&&!mask&&jsxs2("span",{className:cn("opacity-70",!bare&&"text-muted2 font-normal"),title:country,children:["+",dial]}),jsx2("span",{style:{unicodeBidi:"isolate",fontVariantNumeric:"tabular-nums"},className:cn("truncate",!bare&&"font-bold text-ink"),children:shown})]}),(call||sms||whatsapp)&&!mask&&jsxs2("span",{className:"inline-flex items-center gap-0.5 shrink-0",children:[call&&jsx2(Action,{href:`tel:${e164}`,label:`\u0627\u062A\u0635\u0627\u0644 \u0628\u0640${e164}`,children:jsx2(PhoneIcon,{size:14,"aria-hidden":"true"})}),sms&&jsx2(Action,{href:`sms:${e164}`,label:`\u0631\u0633\u0627\u0644\u0629 \u0646\u0635\u0651\u064A\u0629 \u0625\u0644\u0649 ${e164}`,children:jsx2(MessageSquare,{size:14,"aria-hidden":"true"})}),whatsapp&&jsx2(Action,{href:`https://wa.me/${dial}${local}`,label:`\u0648\u0627\u062A\u0633\u0627\u0628 ${e164}`,external:true,className:"hover:text-green",children:jsx2(WhatsAppIcon,{size:15})})]})]})}function Action({href,label,external,className,children}){return jsx2("a",{href,"aria-label":label,title:label,...external?{target:"_blank",rel:"noreferrer"}:{},className:cn("size-7 rounded-sm inline-flex items-center justify-center shrink-0","text-muted hover:text-brand-ink hover:bg-hover transition-colors no-underline",className),children})}import{forwardRef,useId}from"react";import{jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";var LEAD={hex:"#",url:"/"};var TechnicalInput=forwardRef(function TechnicalInput2({kind="code",className,wrapperClassName,...rest},ref){return jsx3(Input,{ref,dir:"ltr",spellCheck:false,autoCapitalize:"off",autoCorrect:"off",autoComplete:"off",inputMode:kind==="url"?"url":"text",wrapperClassName:cn("[unicode-bidi:isolate]",wrapperClassName),className:cn("font-mono tracking-[.01em] [unicode-bidi:isolate] text-start [[dir=rtl]_&]:text-right",className),...rest})});function TechnicalText({children,className}){return jsx3("span",{dir:"ltr",className:cn("inline-block font-mono [unicode-bidi:isolate]",className),children})}function ColorField({label,note,value,onChange,disabled,id:idProp}){const auto=useId();const id=idProp??auto;return jsxs3("div",{className:"flex flex-col gap-1.5 min-w-0",children:[jsx3("label",{htmlFor:`${id}-hex`,className:"text-ui font-bold text-ink2",children:label}),note&&jsx3("span",{className:"text-caption leading-[1.6] text-muted",children:note}),jsxs3("div",{className:"flex items-center gap-2 min-w-0",children:[jsxs3("span",{className:"relative shrink-0 size-11",children:[jsx3("input",{id,type:"color",value:normalizeHex(value)??"#000000",disabled,onChange:e=>onChange(e.target.value.toUpperCase()),"aria-label":typeof label==="string"?label:void 0,className:"absolute inset-0 size-full opacity-0 cursor-pointer disabled:cursor-not-allowed"}),jsx3("span",{"aria-hidden":"true",className:"pointer-events-none block size-11 rounded-field border border-border",style:{background:normalizeHex(value)??"transparent"}})]}),jsx3(TechnicalInput,{id:`${id}-hex`,kind:"hex",hideLabel:true,size:"md",maxLength:7,disabled,value,onChange:e=>onChange(e.target.value),onBlur:()=>{const fixed=normalizeHex(value);if(fixed&&fixed!==value)onChange(fixed);else if(!fixed&&value&&!value.startsWith(LEAD.hex))onChange(`#${value}`)},wrapperClassName:"flex-1 min-w-0"})]})]})}function normalizeHex(input){const raw=input.trim().replace(/^#/,"");if(/^[0-9a-fA-F]{3}$/.test(raw)){return`#${raw.split("").map(c=>c+c).join("").toUpperCase()}`}if(/^[0-9a-fA-F]{6}$/.test(raw))return`#${raw.toUpperCase()}`;return null}import{useCallback,useEffect as useEffect2,useRef as useRef2,useState as useState2}from"react";import{Box,Loader2}from"lucide-react";import{jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";function detailOf(e){return e.detail??{}}function Product3DViewer({src,iosSrc,poster,alt,autoRotate=true,onLoad,onError,onARLaunch,className}){const en=useMoneyLang();const host=useRef2(null);const slot=useRef2(null);const viewer=useRef2(null);const[phase,setPhase]=useState2("idle");const[progress,setProgress]=useState2(0);const[canAR,setCanAR]=useState2(false);const cb=useRef2({onLoad,onError,onARLaunch});useEffect2(()=>{cb.current={onLoad,onError,onARLaunch}},[onLoad,onError,onARLaunch]);useEffect2(()=>{const mount=slot.current;const box=host.current;if(!mount||!box)return;let dead=false;let el=null;setPhase("idle");setProgress(0);setCanAR(false);async function build(target){try{await import("@google/model-viewer");await customElements.whenDefined("model-viewer");if(dead)return;el=document.createElement("model-viewer");viewer.current=el;el.setAttribute("src",src);if(iosSrc)el.setAttribute("ios-src",iosSrc);el.setAttribute("alt",alt);el.setAttribute("camera-controls","");el.setAttribute("touch-action","pan-y");el.setAttribute("shadow-intensity","1");el.setAttribute("ar","");el.setAttribute("ar-modes","webxr scene-viewer quick-look");el.setAttribute("loading","eager");el.style.width="100%";el.style.height="100%";el.style.backgroundColor="transparent";const silence=document.createElement("button");silence.slot="ar-button";silence.style.display="none";silence.tabIndex=-1;silence.setAttribute("aria-hidden","true");el.appendChild(silence);const reduce=typeof matchMedia!=="undefined"&&matchMedia("(prefers-reduced-motion: reduce)").matches;if(autoRotate&&!reduce)el.setAttribute("auto-rotate","");el.addEventListener("progress",e=>{const total=detailOf(e).totalProgress??0;if(!dead)setProgress(total)});el.addEventListener("load",()=>{if(dead)return;setPhase("ready");setCanAR(Boolean(el?.canActivateAR));cb.current.onLoad?.()});el.addEventListener("error",e=>{if(dead)return;setPhase("error");cb.current.onError?.(detailOf(e).type??"load-failed")});target.appendChild(el);setPhase("loading")}catch{if(dead)return;setPhase("error");cb.current.onError?.("viewer-unavailable")}}const io=new IntersectionObserver(entries=>{if(entries.some(x=>x.isIntersecting)){io.disconnect();void build(mount)}},{rootMargin:"200px"});io.observe(box);return()=>{dead=true;io.disconnect();el?.remove();viewer.current=null}},[src,iosSrc,alt,autoRotate]);const launchAR=useCallback(()=>{cb.current.onARLaunch?.();void viewer.current?.activateAR().catch(()=>{})},[]);const pct=Math.round(progress*100);const showPoster=phase!=="ready";return jsxs4("div",{ref:host,className:cn("relative aspect-square w-full overflow-clip rounded-card bg-hover border border-line",className),children:[showPoster&&jsx4("img",{src:poster,alt,loading:"lazy",decoding:"async",draggable:false,className:"absolute inset-0 size-full object-contain"}),jsx4("div",{ref:slot,className:cn("absolute inset-0",showPoster&&"opacity-0"),"aria-hidden":showPoster}),phase==="loading"&&jsxs4("div",{className:"absolute inset-x-0 bottom-0 flex flex-col gap-1.5 p-3",children:[jsxs4("span",{className:"flex items-center gap-2 text-micro font-bold text-ink2",children:[jsx4(Loader2,{size:12,className:"animate-spin shrink-0","aria-hidden":"true"}),en?"Loading 3D model":"\u062C\u0627\u0631\u064A \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062C\u0633\u0651\u0645",jsxs4("span",{dir:"ltr","data-num":true,className:"ms-auto text-muted",children:[pct,"%"]})]}),jsx4("span",{role:"progressbar","aria-valuenow":pct,"aria-valuemin":0,"aria-valuemax":100,"aria-label":en?"Model loading progress":"\u062A\u0642\u062F\u0651\u0645 \u062A\u062D\u0645\u064A\u0644 \u0627\u0644\u0645\u062C\u0633\u0651\u0645",className:"h-1 w-full rounded-full bg-line overflow-clip",children:jsx4("span",{className:"block h-full rounded-full bg-brand transition-[width] duration-200",style:{width:`${pct}%`}})})]}),phase==="ready"&&canAR&&jsxs4("button",{type:"button",onClick:launchAR,className:cn("absolute bottom-3 end-3 inline-flex items-center gap-2 h-9 px-3.5 rounded-full","bg-surface/92 backdrop-blur border border-line shadow-pop","text-ui font-bold text-ink2 cursor-pointer transition-colors hover:text-brand-ink"),children:[jsx4(Box,{size:15,"aria-hidden":"true"}),en?"See it in your space":"\u0634\u0648\u0641\u0647 \u0641\u064A \u0645\u0643\u0627\u0646\u0643"]})]})}import{X}from"lucide-react";import{jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function Tabs({items,value,onChange,variant="pill",label,className}){if(variant==="segmented"){return jsx5("div",{role:"tablist","aria-label":label,className:cn("flex flex-wrap gap-0.5 p-0.5 rounded-field bg-bg self-start","max-w-full overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",className),children:items.map(it=>{const on=it.key===value;return jsxs5("button",{role:"tab",type:"button","aria-selected":on,onClick:()=>onChange(it.key),className:cn("h-9 px-2 sm:px-3.5 rounded-sm inline-flex items-center gap-2 text-ui font-bold cursor-pointer transition-colors","shrink-0 whitespace-nowrap","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",on?"bg-surface text-ink shadow-raise":"text-muted hover:text-ink"),children:[it.icon&&jsx5(it.icon,{size:14}),it.label,typeof it.count==="number"&&jsx5("span",{"data-num":true,className:"opacity-60",children:it.count})]},it.key)})})}return jsx5("div",{role:"tablist","aria-label":label,className:cn("flex items-center gap-2.5 flex-wrap",className),children:items.map(it=>{const on=it.key===value;return jsxs5("button",{role:"tab",type:"button","aria-selected":on,onClick:()=>onChange(it.key),className:cn("h-10 px-3.5 rounded-field border inline-flex items-center gap-1.5 text-ui font-bold cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",on?"border-brand bg-soft text-brand-ink":"border-border bg-surface text-ink2 hover:border-brand"),children:[it.icon&&jsx5(it.icon,{size:14}),it.label,typeof it.count==="number"&&jsx5("span",{"data-num":true,className:"text-micro opacity-70",children:it.count})]},it.key)})})}function FilterChips({chips,onClearAll,label,clearAllLabel}){const ui=useUIText();if(chips.length===0)return null;return jsxs5("div",{className:"flex items-center gap-2 flex-wrap",children:[jsx5("span",{className:"text-caption text-muted",children:label??ui.activeFilters}),chips.map(c=>jsxs5("button",{type:"button",onClick:c.onClear,className:"inline-flex items-center gap-1.5 h-7 ps-3 pe-2 rounded-full bg-soft text-brand-ink text-caption font-bold cursor-pointer transition-colors hover:bg-soft2",children:[c.label,jsx5(X,{size:12,strokeWidth:2.5,"aria-hidden":"true"})]},c.label)),onClearAll&&jsx5("button",{type:"button",onClick:onClearAll,className:"text-caption font-bold text-muted cursor-pointer hover:text-ink transition-colors",children:clearAllLabel??ui.clearAll})]})}import{useEffect as useEffect3,useMemo,useRef as useRef3,useState as useState3}from"react";import{Check,ChevronDown,Loader2 as Loader22,Minus as Minus2,SlidersHorizontal}from"lucide-react";import{useInView}from"react-intersection-observer";import{Fragment,jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";function leavesOf(item){if(!item.children?.length)return[item];return item.children.flatMap(leavesOf)}function Picker({open,onClose,title,description,closeLabel,items,icon,isLoading,isError,errorText,emptyIcon,emptyText,search,onSearch,searchPlaceholder,header,multiple=false,selected,onPick,closeOnPick=true,onConfirm,hintText,cancelLabel,confirmLabel,selectedCountText,itemsCountText,allTabLabel,selectedTabLabel,selectAllLabel,deselectAllLabel,hasMore,isLoadingMore,onLoadMore}){const ui=useUIText();const current=selected??[];const[tab,setTab]=useState3("all");const[saved,setSaved]=useState3(()=>new Set(current));const[pending,setPending]=useState3(()=>new Set);const[removed,setRemoved]=useState3(()=>new Set);const[wasOpen,setWasOpen]=useState3(open);if(wasOpen!==open){setWasOpen(open);if(open){setTab("all");setSaved(new Set(current));setPending(new Set);setRemoved(new Set)}}const total=saved.size-removed.size+pending.size;const tabbed=multiple;const visible=useMemo(()=>{if(!tabbed)return items;const keep=i=>tab==="selected"?saved.has(i.id):!saved.has(i.id);return items.map(item=>{if(!item.children?.length)return keep(item)?item:null;const kids=item.children.filter(keep);return kids.length>0?{...item,children:kids}:null}).filter(i=>i!==null)},[items,tabbed,tab,saved]);const[expanded,setExpanded]=useState3(()=>new Set);const rows=useMemo(()=>{const out=[];for(const item of visible){const kids=item.children??[];out.push({item,child:false});if(kids.length>0&&expanded.has(item.id))for(const kid of kids)out.push({item:kid,child:true})}return out},[visible,expanded]);function isChecked(id){if(!tabbed)return pending.has(id)||saved.has(id)&&!removed.has(id);if(tab==="selected")return!removed.has(id);return pending.has(id)}const[scroller,setScroller]=useState3(null);const{ref:sentinelRef,inView}=useInView({root:scroller,rootMargin:"160px"});const loadMore=useRef3(onLoadMore);useEffect3(()=>{loadMore.current=onLoadMore});useEffect3(()=>{if(inView&&hasMore&&!isLoadingMore)loadMore.current?.()},[inView,hasMore,isLoadingMore]);const anchor=useRef3(-1);function toggle(id){if(!tabbed){const item=items.flatMap(leavesOf).find(i=>i.id===id);if(item)onPick?.(item);if(closeOnPick)onClose();return}if(tab==="selected"){setRemoved(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next});return}setPending(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next})}function clickRow(id,index,shiftKey){const row=rows[index];if(row?.item.children?.length){setExpanded(prev=>{const next=new Set(prev);if(next.has(id))next.delete(id);else next.add(id);return next});return}if(tabbed&&shiftKey&&tab==="all"&&anchor.current>=0){const from=Math.min(anchor.current,index);const to=Math.max(anchor.current,index);setPending(prev=>{const next=new Set(prev);for(let i=from;i<=to;i++){const target=rows[i]?.item;if(target&&!target.disabled&&!target.children?.length)next.add(target.id)}return next})}else{toggle(id)}anchor.current=index}const pickable=visible.flatMap(leavesOf).filter(i=>!i.disabled);const allPicked=pickable.length>0&&pickable.every(i=>pending.has(i.id));function save(){const out=new Set([...saved,...pending]);for(const id of removed)out.delete(id);onConfirm?.([...out]);onClose()}return jsx6(Modal,{open,onClose,size:"lg",bodyClassName:"flex flex-col",title:tabbed&&total>0?jsxs6("span",{className:"flex items-center gap-2 flex-wrap",children:[title,jsx6("span",{className:"text-caption font-bold px-2 py-0.5 rounded-full bg-soft text-brand-ink",children:selectedCountText?selectedCountText(total):jsxs6(Fragment,{children:[jsx6("span",{"data-num":true,children:total})," ",ui.selectedCount]})})]}):title,description,closeLabel:closeLabel??ui.close,footer:tabbed?jsxs6(Fragment,{children:[jsxs6("span",{className:"text-caption text-muted me-auto",children:[itemsCountText?itemsCountText(items.length):jsxs6(Fragment,{children:[jsx6("span",{"data-num":true,children:items.length})," ",ui.items]}),jsx6("span",{className:"text-muted2",children:" \xB7 Shift+Click"})]}),jsx6(Button,{variant:"ghost",size:"sm",onClick:onClose,children:cancelLabel??ui.cancel}),jsx6(Button,{size:"sm",onClick:save,children:confirmLabel??ui.save})]}):jsxs6(Fragment,{children:[jsx6("span",{className:"text-caption text-muted me-auto",children:hintText??ui.pickToSelect}),jsx6(Button,{variant:"ghost",size:"sm",onClick:onClose,children:cancelLabel??ui.cancel})]}),children:jsxs6("div",{className:"flex-auto min-h-0 flex flex-col gap-3",children:[header,jsx6(SearchInput,{label:ui.search,hideLabel:true,size:"sm",value:search,onChange:e=>onSearch(e.target.value),placeholder:searchPlaceholder??ui.search}),tabbed&&jsxs6("div",{role:"tablist",className:"flex items-center gap-1.5",children:[jsx6(TabButton,{active:tab==="all",onClick:()=>setTab("all"),children:allTabLabel??ui.all}),jsxs6(TabButton,{active:tab==="selected",onClick:()=>setTab("selected"),children:[jsx6(SlidersHorizontal,{size:12,"aria-hidden":"true"}),selectedTabLabel??ui.selectedTab,saved.size>removed.size&&jsx6("span",{"data-num":true,className:"text-micro leading-none px-1.5 py-0.5 rounded-full bg-soft text-brand-ink",children:saved.size-removed.size})]})]}),jsx6("div",{ref:setScroller,className:"flex-auto min-h-0 max-h-96 overflow-y-auto overscroll-contain [scrollbar-gutter:stable] -mx-1 px-1",children:isLoading?jsx6("div",{className:"flex flex-col gap-1.5",children:Array.from({length:6},(_,i)=>jsx6(Skeleton,{variant:"block",className:"h-13 rounded-sm"},i))}):isError?jsx6(Alert,{tone:"red",title:errorText??ui.somethingWentWrong}):visible.length===0?jsx6(EmptyState,{icon:emptyIcon,title:emptyText??ui.noResults}):jsxs6(Fragment,{children:[tabbed&&tab==="all"&&pickable.length>0&&jsxs6("button",{type:"button","aria-pressed":allPicked,onClick:()=>{if(allPicked)setPending(new Set);else setPending(prev=>new Set([...prev,...pickable.map(i=>i.id)]))},className:"w-full flex items-center gap-3 p-2 mb-1.5 rounded-sm border border-dashed border-line cursor-pointer text-start transition-colors hover:bg-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",children:[jsx6(Box2,{checked:allPicked,partial:!allPicked&&pending.size>0}),jsxs6("span",{className:"text-caption text-muted",children:[allPicked?deselectAllLabel??ui.deselectAll:selectAllLabel??ui.selectAll," ",jsxs6("span",{"data-num":true,children:["(",pickable.length,")"]})]})]}),jsx6("ul",{role:"listbox","aria-multiselectable":multiple,"aria-label":typeof title==="string"?title:void 0,className:"flex flex-col gap-1.5 list-none m-0 p-0",children:rows.map(({item,child},index)=>jsx6(Row,{item,icon,box:tabbed,child,expanded:item.children?.length?expanded.has(item.id):void 0,selected:isChecked(item.id),onPick:shiftKey=>clickRow(item.id,index,shiftKey)},item.id))}),hasMore&&(!tabbed||tab==="all")&&jsx6("div",{ref:sentinelRef,role:"status","aria-label":isLoadingMore?ui.loadingMore:void 0,className:"h-11 flex items-center justify-center",children:isLoadingMore&&jsx6(Loader22,{size:16,"aria-hidden":"true",className:"animate-spin text-muted"})})]})})]})})}function TabButton({active,onClick,children}){return jsx6("button",{type:"button",role:"tab","aria-selected":active,onClick,className:cn("flex items-center gap-1.5 px-3 py-1.5 rounded-sm text-caption font-bold border cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",active?"border-line bg-surface text-ink":"border-transparent text-muted hover:text-ink hover:bg-hover"),children})}function Box2({checked,partial=false}){return jsx6("span",{"aria-hidden":"true",className:cn("shrink-0 size-5 rounded-xs border flex items-center justify-center transition-colors",checked||partial?"bg-brand border-brand text-white":"border-line bg-surface"),children:checked?jsx6(Check,{size:13,strokeWidth:3}):partial?jsx6(Minus2,{size:13,strokeWidth:3}):null})}function Row({item,icon,box,child=false,expanded,selected,onPick}){const[errored,setErrored]=useState3(false);const disabled=item.disabled??false;const parent=expanded!==void 0;const src=item.image?.trim();const showImage=Boolean(src)&&!errored;return jsx6("li",{role:"none",children:jsxs6("button",{type:"button",role:parent?void 0:"option","aria-selected":parent?void 0:selected,"aria-disabled":disabled||void 0,"aria-expanded":parent?expanded:void 0,title:disabled?item.disabledReason:void 0,onClick:e=>{if(!disabled)onPick(e.shiftKey)},className:cn("w-full flex items-center gap-3 p-2 rounded-sm text-start","border transition-colors",child&&"ps-11",disabled?"opacity-45 cursor-not-allowed border-transparent":"cursor-pointer",!disabled&&(selected?"border-brand bg-soft":"border-transparent hover:border-line hover:bg-hover"),"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:[box&&!parent&&jsx6(Box2,{checked:selected}),showImage?jsx6("img",{src,alt:"",loading:"lazy",onError:()=>setErrored(true),className:"size-9 rounded-sm border border-line object-cover shrink-0"}):jsx6("span",{"aria-hidden":"true",className:"size-9 shrink-0 inline-flex items-center justify-center [&>svg]:size-full",children:icon}),jsxs6("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx6("span",{className:"text-caption font-bold text-ink truncate",children:jsx6("bdi",{children:item.title})}),item.sub&&jsx6("span",{className:"text-micro text-muted truncate",children:jsx6("bdi",{children:item.sub})})]}),parent&&jsx6(ChevronDown,{size:16,"aria-hidden":"true",className:cn("shrink-0 text-muted transition-transform",expanded&&"rotate-180")}),!box&&!parent&&selected&&jsx6("span",{"aria-hidden":"true",className:"shrink-0 size-5 rounded-full bg-brand text-white flex items-center justify-center",children:jsx6(Check,{size:12,strokeWidth:3})})]})})}import{useEffect as useEffect4,useId as useId2,useLayoutEffect,useMemo as useMemo2,useRef as useRef4,useState as useState4}from"react";import{Check as Check2,ChevronDown as ChevronDown2,Plus as Plus2,Search,X as X2}from"lucide-react";import{jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";function useDismiss(open,close){const ref=useRef4(null);useEffect4(()=>{if(!open)return;function onDown(e){if(ref.current&&!ref.current.contains(e.target))close()}function onKey(e){if(e.key==="Escape")close()}document.addEventListener("mousedown",onDown);document.addEventListener("keydown",onKey);return()=>{document.removeEventListener("mousedown",onDown);document.removeEventListener("keydown",onKey)}},[open,close]);return ref}var TRIGGER="w-full h-10 px-3.5 rounded-field border bg-surface flex items-center gap-2.5 text-body cursor-pointer transition-colors outline-none focus-visible:border-brand";var GAP=6;var EDGE=8;var PANEL="absolute z-30 inset-x-0 bg-surface border border-line rounded-card shadow-panel overflow-clip animate-[fade-in_.14s_ease-out]";function useFlip(open,anchor){const panel=useRef4(null);const[up,setUp]=useState4(false);useLayoutEffect(()=>{if(!open)return;function place(){const target=anchor.current;const self=panel.current;if(!target||!self)return;const a=target.getBoundingClientRect();const h=self.offsetHeight;const below=window.innerHeight-a.bottom-GAP;const above=a.top-GAP;setUp(h>below-EDGE&&above>below)}place();window.addEventListener("scroll",place,true);window.addEventListener("resize",place);return()=>{window.removeEventListener("scroll",place,true);window.removeEventListener("resize",place)}},[open,anchor]);const side=up?"bottom-[calc(100%+6px)]":"top-[calc(100%+6px)]";return[panel,side]}var ITEM="w-full px-3 py-2.5 flex items-center gap-2.5 text-start text-ui cursor-pointer transition-colors hover:bg-hover disabled:opacity-45 disabled:cursor-not-allowed";function Label({id,children}){if(!children)return null;return jsx7("label",{htmlFor:id,className:"text-ui font-bold text-ink2",children})}function Dropdown({label,value,onChange,options,placeholder,className}){const ui=useUIText();const id=useId2();const[open,setOpen]=useState4(false);const ref=useDismiss(open,()=>setOpen(false));const[panelRef,side]=useFlip(open,ref);const current=options.find(o=>o.value===value);return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[jsx7(Label,{id,children:label}),jsxs7("div",{ref,className:"relative",children:[jsxs7("button",{id,type:"button","aria-haspopup":"listbox","aria-expanded":open,onClick:()=>setOpen(v=>!v),className:cn(TRIGGER,open?"border-brand":"border-border hover:border-brand"),children:[current?.icon,jsx7("span",{className:cn("flex-1 min-w-0 text-start truncate",!current&&"text-muted2"),children:current?.label??placeholder??ui.select}),current?.meta&&jsx7("span",{className:"text-caption text-muted shrink-0",children:current.meta}),jsx7(ChevronDown2,{size:15,"aria-hidden":"true",className:cn("text-muted2 shrink-0 transition-transform",open&&"rotate-180")})]}),open&&jsx7("div",{ref:panelRef,role:"listbox",className:cn(PANEL,side,"max-h-72 overflow-y-auto py-1"),children:options.map(o=>jsxs7("button",{type:"button",role:"option","aria-selected":o.value===value,disabled:o.disabled,onClick:()=>{onChange(o.value);setOpen(false)},className:cn(ITEM,o.value===value&&"bg-soft"),children:[o.icon,jsxs7("span",{className:"flex-1 min-w-0 flex flex-col",children:[jsx7("span",{className:"font-bold truncate",children:o.label}),o.meta&&jsx7("span",{className:"text-caption text-muted",children:o.meta})]}),o.value===value&&jsx7(Check2,{size:14,className:"text-brand-ink shrink-0","aria-hidden":"true"})]},o.value))})]})]})}function Combobox({label,value,onChange,options,placeholder,searchPlaceholder,emptyText,className}){const ui=useUIText();const id=useId2();const[open,setOpen]=useState4(false);const[query,setQuery]=useState4("");const ref=useDismiss(open,()=>setOpen(false));const[panelRef,side]=useFlip(open,ref);const current=options.find(o=>o.value===value);const results=useMemo2(()=>{const q=query.trim();if(!q)return options;return options.filter(o=>o.label.includes(q)||o.meta?.includes(q))},[options,query]);return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[jsx7(Label,{id,children:label}),jsxs7("div",{ref,className:"relative",children:[jsxs7("button",{id,type:"button","aria-haspopup":"listbox","aria-expanded":open,onClick:()=>{setOpen(v=>!v);setQuery("")},className:cn(TRIGGER,open?"border-brand":"border-border hover:border-brand"),children:[jsx7("span",{className:cn("flex-1 min-w-0 text-start truncate",!current&&"text-muted2"),children:current?.label??placeholder??ui.select}),current?.meta&&jsx7("span",{className:"text-caption text-muted shrink-0",children:current.meta}),jsx7(ChevronDown2,{size:15,"aria-hidden":"true",className:cn("text-muted2 shrink-0 transition-transform",open&&"rotate-180")})]}),open&&jsxs7("div",{ref:panelRef,className:cn(PANEL,side),children:[jsxs7("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-line",children:[jsx7(Search,{size:15,className:"text-muted2 shrink-0","aria-hidden":"true"}),jsx7("input",{autoFocus:true,value:query,onChange:e=>setQuery(e.target.value),placeholder:searchPlaceholder??ui.search,"aria-label":searchPlaceholder??ui.search,className:"flex-1 min-w-0 bg-transparent border-none outline-none text-ui text-ink placeholder:text-muted2"}),query&&jsx7("button",{type:"button",onClick:()=>setQuery(""),"aria-label":ui.clearSearch,className:"shrink-0 text-muted2 hover:text-ink cursor-pointer transition-colors",children:jsx7(X2,{size:14,"aria-hidden":"true"})}),jsx7("kbd",{dir:"ltr",className:"shrink-0 px-1.5 py-0.5 rounded-xs bg-bg border border-line text-micro font-bold text-muted2",children:"Esc"})]}),jsxs7("div",{role:"listbox",className:"max-h-64 overflow-y-auto py-1",children:[results.map(o=>jsxs7("button",{type:"button",role:"option","aria-selected":o.value===value,onClick:()=>{onChange(o.value);setOpen(false)},className:cn(ITEM,o.value===value&&"bg-soft"),children:[jsxs7("span",{className:"flex-1 min-w-0 flex flex-col",children:[jsx7("span",{className:"font-bold truncate",children:o.label}),o.meta&&jsx7("span",{className:"text-caption text-muted",children:o.meta})]}),o.value===value&&jsx7(Check2,{size:14,className:"text-brand-ink shrink-0","aria-hidden":"true"})]},o.value)),results.length===0&&jsx7("span",{className:"block px-3 py-6 text-center text-ui text-muted2",children:emptyText??ui.noResults})]})]})]})]})}function MultiSelect({label,values,onChange,options,placeholder,createLabel,onCreate,className}){const ui=useUIText();const id=useId2();const[open,setOpen]=useState4(false);const[query,setQuery]=useState4("");const ref=useDismiss(open,()=>setOpen(false));const[panelRef,side]=useFlip(open,ref);const results=useMemo2(()=>{const q=query.trim();if(!q)return options;return options.filter(o=>o.label.includes(q))},[options,query]);const exact=results.some(o=>o.label===query.trim());const canCreate=Boolean(onCreate&&query.trim()&&!exact);function toggle(v){onChange(values.includes(v)?values.filter(x=>x!==v):[...values,v])}return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[jsxs7("div",{className:"flex items-center justify-between gap-3",children:[jsx7(Label,{id,children:label}),values.length>0&&jsx7("button",{type:"button",onClick:()=>onChange([]),className:"text-caption font-bold text-muted cursor-pointer hover:text-ink transition-colors",children:ui.clearAll})]}),jsxs7("div",{ref,className:"relative",children:[jsxs7("div",{className:cn(TRIGGER,"h-auto min-h-10 py-1.5 flex-wrap cursor-default",open?"border-brand":"border-border hover:border-brand","has-[:focus-visible]:border-brand"),children:[values.map(v=>{const o=options.find(x=>x.value===v);return jsxs7("span",{className:"inline-flex items-center gap-1 h-7 ps-2.5 pe-1.5 rounded-full bg-soft text-brand-ink text-caption font-bold",children:[o?.label??v,jsx7("button",{type:"button","aria-label":`${ui.remove} ${o?.label??v}`,onClick:e=>{e.stopPropagation();toggle(v)},className:"flex text-brand-ink/60 hover:text-brand-ink cursor-pointer",children:jsx7(X2,{size:12,strokeWidth:2.5,"aria-hidden":"true"})})]},v)}),jsxs7("button",{id,type:"button","aria-haspopup":"listbox","aria-expanded":open,onClick:()=>setOpen(v=>!v),className:"flex-1 min-w-12 self-stretch flex items-center gap-2.5 text-start cursor-pointer outline-none",children:[values.length===0&&jsx7("span",{className:"text-muted2 flex-1 text-start",children:placeholder??ui.select}),jsx7(ChevronDown2,{size:15,"aria-hidden":"true",className:cn("text-muted2 shrink-0 ms-auto transition-transform",open&&"rotate-180")})]})]}),open&&jsxs7("div",{ref:panelRef,className:cn(PANEL,side),children:[jsxs7("div",{className:"flex items-center gap-2.5 px-3 h-11 border-b border-line",children:[jsx7(Search,{size:15,className:"text-muted2 shrink-0","aria-hidden":"true"}),jsx7("input",{autoFocus:true,value:query,onChange:e=>setQuery(e.target.value),placeholder:ui.searchOrAdd,"aria-label":ui.searchOrAdd,className:"flex-1 min-w-0 bg-transparent border-none outline-none text-ui text-ink placeholder:text-muted2"})]}),jsxs7("div",{role:"listbox","aria-multiselectable":true,className:"max-h-56 overflow-y-auto py-1",children:[results.map(o=>{const on=values.includes(o.value);return jsxs7("button",{type:"button",role:"option","aria-selected":on,onClick:()=>toggle(o.value),className:ITEM,children:[jsx7("span",{"aria-hidden":"true",className:cn("size-[18px] rounded-xs border-[1.5px] flex items-center justify-center shrink-0 transition-colors",on?"bg-brand border-brand":"bg-surface border-border"),children:jsx7(Check2,{size:11,strokeWidth:3,className:cn("text-white",!on&&"opacity-0")})}),jsx7("span",{className:"flex-1 min-w-0 truncate",children:o.label}),o.meta&&jsx7("span",{className:"text-caption text-muted2 shrink-0",children:o.meta})]},o.value)}),canCreate&&jsxs7("button",{type:"button",onClick:()=>{onCreate?.(query.trim());setQuery("")},className:cn(ITEM,"text-brand-ink font-bold border-t border-line mt-1 pt-3"),children:[jsx7(Plus2,{size:14,"aria-hidden":"true",className:"shrink-0"}),createLabel?createLabel(query.trim()):`\u0623\u0636\u0641 \xAB${query.trim()}\xBB`]}),results.length===0&&!canCreate&&jsx7("span",{className:"block px-3 py-6 text-center text-ui text-muted2",children:ui.noResults})]})]})]})]})}function CommandPalette({open,onClose,items,placeholder,emptyText}){const ui=useUIText();const[query,setQuery]=useState4("");useEffect4(()=>{if(!open)return;function onKey(e){if(e.key==="Escape")onClose()}document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[open,onClose]);const groups=useMemo2(()=>{const q=query.trim();const hits=q?items.filter(i=>i.title.includes(q)||i.meta?.includes(q)):items;const out=new Map;for(const i of hits)out.set(i.group,[...out.get(i.group)??[],i]);return[...out.entries()]},[items,query]);if(!open)return null;return jsxs7("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[12vh] px-4",role:"dialog","aria-modal":"true",children:[jsx7("button",{type:"button","aria-label":ui.close,onClick:onClose,className:"absolute inset-0 bg-black/40 backdrop-blur-[2px] cursor-default"}),jsxs7("div",{className:"relative w-full max-w-[560px] bg-surface border border-line rounded-lg shadow-modal overflow-clip animate-[fade-in_.16s_ease-out]",children:[jsxs7("div",{className:"flex items-center gap-3 px-4 h-14 border-b border-line",children:[jsx7(Search,{size:17,className:"text-muted2 shrink-0","aria-hidden":"true"}),jsx7("input",{autoFocus:true,value:query,onChange:e=>setQuery(e.target.value),placeholder:placeholder??ui.searchEverything,"aria-label":placeholder??ui.searchEverything,className:"flex-1 min-w-0 bg-transparent border-none outline-none text-body text-ink placeholder:text-muted2"}),jsx7("kbd",{dir:"ltr",className:"shrink-0 px-1.5 py-0.5 rounded-xs bg-bg border border-line text-micro font-bold text-muted2",children:"Esc"})]}),jsxs7("div",{className:"max-h-[52vh] overflow-y-auto py-2",children:[groups.map(([group2,list])=>jsxs7("div",{className:"flex flex-col",children:[jsx7("span",{className:"px-4 pt-2 pb-1 text-micro font-extrabold text-muted2 tracking-wide",children:group2}),list.map(i=>jsxs7("button",{type:"button",onClick:()=>{i.onRun?.();onClose()},className:"px-4 py-2.5 flex items-center gap-3 text-start cursor-pointer transition-colors hover:bg-hover",children:[i.icon&&jsx7("span",{className:"text-muted shrink-0",children:i.icon}),jsx7("span",{className:"flex-1 min-w-0 text-body font-bold text-ink truncate",children:i.title}),i.meta&&jsx7("span",{className:"text-caption text-muted2 shrink-0",children:i.meta})]},i.id))]},group2)),groups.length===0&&jsx7("span",{className:"block px-4 py-10 text-center text-ui text-muted2",children:emptyText??ui.noResults})]})]})]})}import{useState as useState5}from"react";import{Check as Check3,ChevronDown as ChevronDown3}from"lucide-react";import{Fragment as Fragment2,jsx as jsx8,jsxs as jsxs8}from"react/jsx-runtime";function Accordion({items,mode="single",defaultOpen=[],className}){const[open,setOpen]=useState5(defaultOpen);function toggle(key){setOpen(prev=>{if(prev.includes(key))return prev.filter(k=>k!==key);return mode==="single"?[key]:[...prev,key]})}return jsx8("div",{className:cn("bg-surface border border-line rounded-card overflow-clip",className),children:items.map(it=>{const on=open.includes(it.key);return jsxs8("div",{className:"border-b border-line last:border-0",children:[jsxs8("button",{type:"button","aria-expanded":on,onClick:()=>toggle(it.key),className:"w-full px-4 py-3.5 flex items-center gap-3 text-start cursor-pointer transition-colors hover:bg-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",children:[it.icon&&jsx8("span",{"aria-hidden":"true",className:"size-8 rounded-sm bg-soft text-brand-ink flex items-center justify-center shrink-0",children:jsx8(it.icon,{size:15})}),jsxs8("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx8("span",{className:"text-body font-extrabold text-ink",children:it.title}),it.description&&jsx8("span",{className:"text-caption text-muted",children:it.description})]}),jsx8(ChevronDown3,{size:16,"aria-hidden":"true",className:cn("text-muted2 shrink-0 transition-transform duration-200",on&&"rotate-180")})]}),jsx8("div",{className:cn("grid transition-[grid-template-rows] duration-200 ease-out",on?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:jsx8("div",{className:"min-h-0 overflow-clip",children:jsx8("div",{className:"px-4 pb-4 pt-0.5 text-ui leading-[1.85] text-ink2",children:it.children})})})]},it.key)})})}function Timeline({steps,current,nowLabel,className}){const ui=useUIText();return jsx8("ol",{className:cn("flex flex-col m-0 p-0 list-none",className),children:steps.map((s,i)=>{const done=i<current;const active=i===current;const last=i===steps.length-1;return jsxs8("li",{className:"flex gap-3",children:[jsxs8("span",{className:"flex flex-col items-center shrink-0",children:[jsx8("span",{"aria-hidden":"true",className:cn("size-7 rounded-full flex items-center justify-center border-2 transition-colors",done&&"bg-brand border-brand text-white",active&&"bg-surface border-brand text-brand-ink",!done&&!active&&"bg-surface border-border text-muted2"),children:done?jsx8(Check3,{size:14,strokeWidth:3}):jsx8("span",{className:cn("size-2 rounded-full",active?"bg-brand":"bg-border")})}),!last&&jsx8("span",{"aria-hidden":"true",className:cn("w-0.5 flex-1 min-h-8 transition-colors",done?"bg-brand":"bg-line")})]}),jsxs8("span",{className:cn("flex flex-col gap-0.5 min-w-0",last?"pb-0":"pb-5"),children:[jsxs8("span",{className:"flex items-center gap-2.5 flex-wrap",children:[jsx8("span",{className:cn("text-body font-extrabold",done||active?"text-ink":"text-muted2"),children:s.title}),s.time&&jsx8("span",{"data-num":true,className:"text-micro text-muted2",children:s.time}),active&&jsx8("span",{className:cn("px-2 py-0.5 rounded-full text-micro font-extrabold",TONE_SOFT[s.tone??"brand"]),children:nowLabel??ui.now})]}),s.note&&jsx8("span",{className:"text-caption leading-[1.7] text-muted",children:s.note})]})]},s.key)})})}function Stepper({steps,done,onPick,className}){return jsx8("ol",{className:cn("flex items-start gap-1 m-0 p-0 list-none",className),children:steps.map((s,i)=>{const on=done.includes(s.key);const isCurrent=!on&&steps.slice(0,i).every(x=>done.includes(x.key));const last=i===steps.length-1;const Tag=onPick?"button":"div";return jsxs8("li",{className:"flex-1 flex flex-col items-center gap-2 min-w-0",children:[jsxs8("span",{className:"w-full flex items-center gap-1",children:[jsx8("span",{"aria-hidden":"true",className:cn("h-0.5 flex-1 rounded-full",i===0?"bg-transparent":on?"bg-brand":"bg-line")}),jsx8(Tag,{...onPick?{type:"button",onClick:()=>onPick(s.key)}:{},"aria-current":isCurrent?"step":void 0,className:cn("size-8 rounded-full flex items-center justify-center shrink-0 border-2 transition-colors",on?"bg-brand border-brand text-white":"bg-surface border-border text-muted",onPick&&"cursor-pointer hover:border-brand"),children:on?jsxs8(Fragment2,{children:[jsx8(Check3,{size:15,strokeWidth:3,"aria-hidden":"true"}),jsx8("span",{className:"sr-only",children:"\u0645\u0643\u062A\u0645\u0644\u0629"})]}):jsx8("span",{"data-num":true,className:"text-caption font-extrabold",children:i+1})}),jsx8("span",{"aria-hidden":"true",className:cn("h-0.5 flex-1 rounded-full",last?"bg-transparent":on?"bg-brand":"bg-line")})]}),jsx8("span",{className:cn("text-caption font-bold text-center leading-tight [text-wrap:balance]",on?"text-ink":"text-muted"),children:s.title})]},s.key)})})}import{Star}from"lucide-react";import{jsx as jsx9,jsxs as jsxs9}from"react/jsx-runtime";var MAX=5;function Stars({value,size=13,className}){const n=Math.max(0,Math.min(MAX,Math.round(value)));return jsxs9("span",{className:cn("flex items-center gap-0.5 shrink-0",className),children:[jsx9("span",{className:"sr-only",children:`${n} / ${MAX}`}),Array.from({length:MAX},(_,i)=>jsx9(Star,{size,"aria-hidden":"true",className:cn("shrink-0",i<n?"fill-amber text-amber":"text-muted2")},i))]})}function RatingInput({value,onChange,disabled,hideValue,className}){const ui=useUIText();return jsxs9("span",{className:cn("flex items-center gap-1",className),children:[Array.from({length:MAX},(_,i)=>{const n=i+1;return jsx9("button",{type:"button",disabled,"aria-pressed":value===n,"aria-label":`${n} / ${MAX} \u2014 ${ui.rating}`,onClick:()=>onChange(n),className:cn("size-9 rounded-sm flex items-center justify-center transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",disabled?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-hover"),children:jsx9(Star,{size:22,"aria-hidden":"true",className:cn("shrink-0",n<=value?"fill-amber text-amber":"text-muted2")})},n)}),!hideValue&&value>0&&jsx9("span",{"data-numeric":true,className:"ms-2 text-caption font-bold text-muted",children:`${value}/${MAX}`})]})}import{useRef as useRef5,useState as useState6}from"react";import{AlertCircle,Check as Check4,Image as ImageIcon,Loader2 as Loader23,UploadCloud,X as X3}from"lucide-react";import{jsx as jsx10,jsxs as jsxs10}from"react/jsx-runtime";function formatBytes(bytes){if(bytes<1024)return`${bytes} \u0628\u0627\u064A\u062A`;if(bytes<1024*1024)return`${Math.round(bytes/1024)} \u0643.\u0628`;return`${(bytes/(1024*1024)).toFixed(1)} \u0645\u064A\u062C\u0627`}function Dropzone({onFiles,accept="image/*",multiple=true,disabled,title,hint,buttonLabel,className}){const ui=useUIText();const input=useRef5(null);const[over,setOver]=useState6(false);function take(list){if(!list||disabled)return;onFiles(Array.from(list))}function onDrop(e){e.preventDefault();setOver(false);take(e.dataTransfer.files)}return jsxs10("div",{onDragOver:e=>{e.preventDefault();if(!disabled)setOver(true)},onDragLeave:()=>setOver(false),onDrop,className:cn("flex flex-col items-center justify-center gap-2.5 px-5 py-9 rounded-card border-2 border-dashed transition-colors text-center",disabled&&"opacity-55 cursor-not-allowed border-border bg-bg",!disabled&&over&&"border-brand bg-soft",!disabled&&!over&&"border-border bg-bg hover:border-brand",className),children:[jsx10("span",{"aria-hidden":"true",className:cn("size-12 rounded-card flex items-center justify-center transition-colors",over?"bg-brand text-white":"bg-surface text-muted border border-line"),children:jsx10(UploadCloud,{size:22,strokeWidth:1.8})}),jsx10("span",{className:"text-body font-extrabold text-ink",children:title??ui.dropImages}),hint&&jsx10("span",{className:"text-caption leading-[1.7] text-muted max-w-note",children:hint}),jsx10("button",{type:"button",disabled,onClick:()=>input.current?.click(),className:"mt-1 h-9 px-4 rounded-sm bg-surface border border-border text-ui font-bold text-ink2 cursor-pointer transition-colors hover:border-brand hover:text-brand-ink disabled:cursor-not-allowed",children:buttonLabel??ui.chooseFromDevice}),jsx10("input",{ref:input,type:"file",accept,multiple,hidden:true,onChange:e=>{take(e.target.files);e.target.value=""}})]})}var STATE_STYLE={uploading:{box:"bg-soft text-brand-ink",icon:jsx10(Loader23,{size:13,className:"animate-spin","aria-hidden":"true"}),label:"\u062C\u0627\u0631\u064A \u0627\u0644\u0631\u0641\u0639"},done:{box:"bg-green-bg2 text-green",icon:jsx10(Check4,{size:13,"aria-hidden":"true"}),label:"\u062A\u0645 \u0627\u0644\u0631\u0641\u0639"},rejected:{box:"bg-red-bg text-red",icon:jsx10(AlertCircle,{size:13,"aria-hidden":"true"}),label:"\u0645\u0631\u0641\u0648\u0636"}};function FileRow({file,onRemove,coverLabel,isCover}){const s=STATE_STYLE[file.state];return jsxs10("div",{className:"flex items-center gap-3 p-2.5 rounded-card border border-line bg-surface",children:[jsxs10("span",{className:"relative size-11 rounded-sm overflow-clip bg-hover border border-line shrink-0",children:[file.preview?jsx10("img",{src:file.preview,alt:"",className:"w-full h-full object-cover"}):jsx10("span",{className:"w-full h-full flex items-center justify-center text-muted2",children:jsx10(ImageIcon,{size:17,"aria-hidden":"true"})}),isCover&&coverLabel&&jsx10("span",{className:"absolute inset-x-0 bottom-0 bg-brand/90 text-white text-micro font-extrabold text-center py-px",children:coverLabel})]}),jsxs10("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsxs10("span",{className:"flex items-center gap-2 min-w-0",children:[jsx10("span",{dir:"auto",className:"text-ui font-bold text-ink truncate",children:file.name}),jsxs10("span",{className:cn("inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-micro font-extrabold shrink-0",s.box),children:[s.icon,s.label]})]}),file.state==="uploading"?jsx10("span",{className:"h-1 rounded-full bg-hover overflow-clip block",children:jsx10("span",{className:"block h-full rounded-full bg-brand transition-[width] duration-200",style:{width:`${file.progress??0}%`}})}):jsx10("span",{className:cn("text-caption",file.state==="rejected"?"text-red":"text-muted"),children:file.state==="rejected"?file.error:formatBytes(file.size)})]}),onRemove&&jsx10("button",{type:"button",onClick:onRemove,"aria-label":`\u0625\u0632\u0627\u0644\u0629 ${file.name}`,className:"shrink-0 size-8 rounded-sm flex items-center justify-center text-muted2 cursor-pointer transition-colors hover:bg-hover hover:text-red",children:jsx10(X3,{size:15,"aria-hidden":"true"})})]})}import{useCallback as useCallback2,useEffect as useEffect5,useLayoutEffect as useLayoutEffect2,useRef as useRef6,useState as useState7}from"react";import{jsx as jsx11}from"react/jsx-runtime";function fill(tpl,vars){return tpl.replace(/\{(\w+)\}/g,(_,k)=>String(vars[k]??""))}function reducedMotion(){return typeof window!=="undefined"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function hitSlot(x,y,boxes,count){for(let i=0;i<count;i++){const b=boxes[i];if(!b)continue;if(x>=b.left&&x<=b.left+b.width&&y>=b.top&&y<=b.top+b.height)return i}let best=-1;let closest=Infinity;for(let i=0;i<count;i++){const b=boxes[i];if(!b)continue;const dx=b.left+b.width/2-x;const dy=b.top+b.height/2-y;const d=dx*dx+dy*dy;if(d<closest){closest=d;best=i}}return best}function slotOf(index,from,to){if(index===from)return to;if(to>from&&index>from&&index<=to)return index-1;if(to<from&&index>=to&&index<from)return index+1;return index}function useSortable({count,onMove,axis:axis2="y",disabled,threshold=4,itemLabel}){const ui=useUIText();const grid=axis2==="grid";const nodes=useRef6([]);const rects=useRef6([]);const host=useRef6(null);const hostBox=useRef6(null);const[frozen,setFrozen]=useState7(null);const[dragging,setDragging]=useState7(null);const[over,setOver]=useState7(null);const[grabbed,setGrabbed]=useState7(null);const[message,setMessage]=useState7("");const run=useRef6({active:false,from:0,to:0,startX:0,startY:0,dx:0,dy:0,slot:0,raf:0,pointerId:-1});const overRef=useRef6(null);useEffect5(()=>{overRef.current=over},[over]);const detach=useRef6(null);const finishRef=useRef6(()=>{});const countRef=useRef6(count);useEffect5(()=>{countRef.current=count},[count]);const soft=!reducedMotion();const EASE="cubic-bezier(.2,.8,.2,1)";const measure=useCallback2(()=>{const list=nodes.current.slice(0,count);rects.current=list.map(el=>{const r=el?.getBoundingClientRect();return{left:r?.left??0,top:r?.top??0,width:r?.width??0,height:r?.height??0}});const h=host.current?.getBoundingClientRect();hostBox.current=h?{left:h.left,top:h.top,width:h.width,height:h.height}:null;const gap=rects.current.length>1?Math.max(0,rects.current[1].top-(rects.current[0].top+rects.current[0].height)):0;return gap},[count]);const finish=useCallback2(()=>{const s=run.current;if(!s.active)return;s.active=false;cancelAnimationFrame(s.raf);detach.current?.();detach.current=null;const from=s.from;const to=overRef.current??from;const el=nodes.current[from];const settle=()=>{setDragging(null);setOver(null);setFrozen(null);overRef.current=null;if(el){el.style.transition="";el.style.removeProperty("--drag-x");el.style.removeProperty("--drag-y")}if(to!==from){onMove(from,to);setMessage(fill(ui.sortMovedTo,{name:itemLabel?.(from)??ui.sortItem,n:to+1,total:count}))}};if(!el||!soft||to===from)return settle();const r=rects.current;if(grid){el.style.transition=`transform 190ms ${EASE}`;el.style.setProperty("--drag-x",`${r[to].left-r[from].left}px`);el.style.setProperty("--drag-y",`${r[to].top-r[from].top}px`);window.setTimeout(settle,200);return}const target=to>from?r[to].top+r[to].height-(r[from].top+r[from].height):r[to].top-r[from].top;el.style.transition=`transform 190ms ${EASE}`;el.style.setProperty("--drag-y",`${target}px`);window.setTimeout(settle,200)},[count,grid,itemLabel,onMove,soft,ui]);useEffect5(()=>{finishRef.current=finish},[finish]);const clamp2=useCallback2((dy,from)=>{const r=rects.current;const last=r[r.length-1];if(!r.length||!r[from]||!last)return dy;const min=r[0].top-r[from].top;const max=last.top+last.height-(r[from].top+r[from].height);return Math.min(Math.max(dy,min),max)},[]);const attach=useCallback2(()=>{function onPointerMove(e){const s=run.current;if(!s.active||e.pointerId!==s.pointerId)return;s.dy=e.clientY-s.startY;if(grid){s.dx=e.clientX-s.startX;const next2=hitSlot(e.clientX,e.clientY,rects.current,countRef.current);if(next2!==-1&&next2!==overRef.current){overRef.current=next2;setOver(next2)}cancelAnimationFrame(s.raf);s.raf=requestAnimationFrame(()=>{const el=nodes.current[s.from];el?.style.setProperty("--drag-x",`${s.dx}px`);el?.style.setProperty("--drag-y",`${s.dy}px`)});return}const r=rects.current;const n=countRef.current;const center=r[s.from].top+r[s.from].height/2+s.dy;let next=s.from;if(s.dy>0){for(let i=s.from+1;i<n;i++){if(center>r[i].top+r[i].height/2)next=i}}else{for(let i=s.from-1;i>=0;i--){if(center<r[i].top+r[i].height/2)next=i}}if(next!==overRef.current){overRef.current=next;setOver(next)}cancelAnimationFrame(s.raf);s.raf=requestAnimationFrame(()=>{nodes.current[s.from]?.style.setProperty("--drag-y",`${clamp2(s.dy,s.from)}px`)})}function onUp(e){if(e.pointerId!==run.current.pointerId)return;finishRef.current()}function onKey(e){if(e.key==="Escape"){overRef.current=run.current.from;finishRef.current()}}window.addEventListener("pointermove",onPointerMove,{passive:true});window.addEventListener("pointerup",onUp);window.addEventListener("pointercancel",onUp);window.addEventListener("keydown",onKey);detach.current=()=>{window.removeEventListener("pointermove",onPointerMove);window.removeEventListener("pointerup",onUp);window.removeEventListener("pointercancel",onUp);window.removeEventListener("keydown",onKey)}},[clamp2,grid]);useEffect5(()=>()=>detach.current?.(),[]);useLayoutEffect2(()=>{if(grabbed!==null)nodes.current[grabbed]?.focus()},[grabbed]);const item=useCallback2(index=>{const isDragged=dragging===index;const isGrabbed=grabbed===index;const slot2=dragging!==null&&over!==null?slotOf(index,dragging,over):index;let shift=0;if(dragging!==null&&over!==null&&!isDragged){const slot3=run.current.slot;if(over>dragging&&index>dragging&&index<=over)shift=-slot3;else if(over<dragging&&index>=over&&index<dragging)shift=slot3}const box=grid&&dragging!==null?rects.current[isDragged?dragging:slot2]:null;const frame=hostBox.current;const gridStyle=box&&frame?{position:"absolute",left:box.left-frame.left,top:box.top-frame.top,width:box.width,height:box.height,transform:isDragged?"translate3d(var(--drag-x, 0px), var(--drag-y, 0px), 0)":void 0,transition:isDragged?void 0:soft?`left 160ms ${EASE}, top 160ms ${EASE}, width 160ms ${EASE}, height 160ms ${EASE}`:void 0,zIndex:isDragged?20:1,cursor:isDragged?"grabbing":void 0,touchAction:"none",willChange:isDragged?"transform":void 0}:null;const style=gridStyle??(isDragged?{transform:"translate3d(0, var(--drag-y, 0px), 0)",position:"relative",zIndex:20,cursor:"grabbing",touchAction:"none",willChange:"transform"}:{transform:shift?`translate3d(0, ${shift}px, 0)`:void 0,transition:dragging!==null&&soft?`transform 160ms ${EASE}`:void 0,touchAction:disabled?void 0:"none"});return{ref:el=>{nodes.current[index]=el},style,tabIndex:disabled?-1:0,"aria-roledescription":ui.grabHint,"data-dragging":isDragged?"":void 0,"data-grabbed":isGrabbed?"":void 0,onPointerDown:e=>{if(disabled||e.button!==0)return;const startX=e.clientX;const startY=e.clientY;const el=e.currentTarget;const begin=ev=>{const moved=grid?Math.abs(ev.clientX-startX)>=threshold||Math.abs(ev.clientY-startY)>=threshold:Math.abs(ev.clientY-startY)>=threshold;if(!moved)return;window.removeEventListener("pointermove",begin);const gap=measure();const s=run.current;s.active=true;s.from=index;s.startX=startX;s.startY=startY;s.dx=ev.clientX-startX;s.dy=ev.clientY-startY;s.slot=rects.current[index].height+gap;s.pointerId=ev.pointerId;el.setPointerCapture?.(ev.pointerId);if(grid){el.style.setProperty("--drag-x",`${s.dx}px`);el.style.setProperty("--drag-y",`${s.dy}px`);setFrozen(hostBox.current?.height??null)}else{el.style.setProperty("--drag-y",`${clamp2(s.dy,index)}px`)}overRef.current=index;attach();setOver(index);setDragging(index);setMessage(fill(ui.sortMoving,{name:itemLabel?.(index)??ui.sortItem}))};const stop=()=>{window.removeEventListener("pointermove",begin);window.removeEventListener("pointerup",stop)};window.addEventListener("pointermove",begin);window.addEventListener("pointerup",stop)},onKeyDown:e=>{if(disabled)return;if(e.key===" "||e.key==="Enter"){e.preventDefault();if(grabbed===index){setGrabbed(null);setMessage(fill(ui.sortSettled,{name:itemLabel?.(index)??ui.sortItem,n:index+1}))}else{setGrabbed(index);setMessage(fill(ui.sortGrabbed,{name:itemLabel?.(index)??ui.sortItem}))}return}if(grabbed!==index)return;const rtl=grid&&getComputedStyle(e.currentTarget).direction==="rtl";const back=grid?rtl?"ArrowRight":"ArrowLeft":null;const forth=grid?rtl?"ArrowLeft":"ArrowRight":null;const dir=e.key==="ArrowUp"||e.key===back?-1:e.key==="ArrowDown"||e.key===forth?1:0;if(dir){e.preventDefault();const to=index+dir;if(to<0||to>=count)return;onMove(index,to);setGrabbed(to);setMessage(fill(ui.sortAt,{name:itemLabel?.(index)??ui.sortItem,n:to+1,total:count}))}if(e.key==="Escape"){e.preventDefault();setGrabbed(null);setMessage(ui.sortCancelled)}}}},[attach,clamp2,count,disabled,dragging,grabbed,grid,itemLabel,measure,onMove,over,soft,threshold,ui]);const container=useCallback2(()=>({ref:el=>{host.current=el},style:frozen===null?{}:{height:frozen}}),[frozen]);const rank=useCallback2(index=>dragging===null||over===null?index:slotOf(index,dragging,over),[dragging,over]);const slot=useCallback2(index=>{if(dragging===null)return null;const b=rects.current[index];const frame=hostBox.current;if(!b||!frame)return null;return{left:b.left-frame.left,top:b.top-frame.top,width:b.width,height:b.height}},[dragging]);return{item,container,rank,slot,dragging,grabbed,over,message}}function SortableStatus({message}){return jsx11("span",{role:"status","aria-live":"polite",className:"sr-only",children:message})}import{Children,useCallback as useCallback3,useEffect as useEffect6,useRef as useRef7,useState as useState8}from"react";import{ChevronLeft,ChevronRight,Pause,Play,X as X4,ZoomIn}from"lucide-react";import{jsx as jsx12,jsxs as jsxs11}from"react/jsx-runtime";function axis(track){const rtl=getComputedStyle(track).direction==="rtl";return{rtl,start:r=>rtl?-r.right:r.left,end:r=>rtl?-r.left:r.right}}var EDGE2=1;function readTrack(track){const slides=Array.from(track.children);if(slides.length===0)return{index:0,atStart:true,atEnd:true};const{start,end}=axis(track);const box=track.getBoundingClientRect();const from=start(box);let index=0;let best=Infinity;slides.forEach((el,i)=>{const d=start(el.getBoundingClientRect())-from;const score=d<0?-d:d;if(score<best){best=score;index=i}});return{index,atStart:start(slides[0].getBoundingClientRect())>=from-EDGE2,atEnd:end(slides[slides.length-1].getBoundingClientRect())<=end(box)+EDGE2}}function scrollToIndex(track,i,behavior){const el=track.children[i];if(!el)return;const{rtl}=axis(track);const box=track.getBoundingClientRect();const r=el.getBoundingClientRect();track.scrollBy({left:rtl?r.right-box.right:r.left-box.left,behavior})}function ease(){return typeof matchMedia!=="undefined"&&matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth"}var BASIS="calc((100% - (var(--per) - 1) * var(--gap)) / var(--per))";function Carousel({label,children,perView,gap=12,arrows=true,dots=false,counter=false,autoplay,index,onIndexChange,className,trackClassName}){const en=useMoneyLang();const trackRef=useRef7(null);const[state,setState]=useState8({index:0,atStart:true,atEnd:true});const[paused,setPaused]=useState8(false);const[held,setHeld]=useState8(false);const slides=Children.toArray(children);const count=slides.length;const latest=useRef7(state);const notify=useRef7(onIndexChange);useEffect6(()=>{latest.current=state},[state]);useEffect6(()=>{notify.current=onIndexChange},[onIndexChange]);const measure=useCallback3(()=>{const track=trackRef.current;if(!track)return;const next=readTrack(track);setState(prev=>prev.index===next.index&&prev.atStart===next.atStart&&prev.atEnd===next.atEnd?prev:next)},[]);const target=useRef7(0);const go=useCallback3(to=>{const track=trackRef.current;if(!track)return;const i=Math.min(Math.max(to,0),track.children.length-1);target.current=i;scrollToIndex(track,i,ease())},[]);const first=useRef7(true);const told=useRef7(null);useEffect6(()=>{const track=trackRef.current;if(index==null||!track)return;if(index===told.current)return;target.current=index;scrollToIndex(track,index,first.current?"auto":ease())},[index]);useEffect6(()=>{const track=trackRef.current;if(!track)return;let frame=0;let idle;const onScroll=()=>{cancelAnimationFrame(frame);frame=requestAnimationFrame(measure);clearTimeout(idle);idle=setTimeout(()=>{const t=trackRef.current;if(t)target.current=readTrack(t).index},140)};track.addEventListener("scroll",onScroll,{passive:true});const ro=new ResizeObserver(onScroll);ro.observe(track);measure();first.current=false;return()=>{cancelAnimationFrame(frame);clearTimeout(idle);track.removeEventListener("scroll",onScroll);ro.disconnect()}},[measure,count]);useEffect6(()=>{if(told.current===state.index)return;const knew=told.current!==null;told.current=state.index;if(knew||state.index!==(index??0))notify.current?.(state.index)},[state.index,index]);useEffect6(()=>{if(!autoplay||paused||held||count<2)return;if(typeof matchMedia!=="undefined"&&matchMedia("(prefers-reduced-motion: reduce)").matches){return}const id=setInterval(()=>{const track=trackRef.current;if(!track||document.hidden)return;const now=latest.current;scrollToIndex(track,now.atEnd?0:now.index+1,ease())},autoplay);return()=>clearInterval(id)},[autoplay,paused,held,count]);function onKeyDown(e){const track=trackRef.current;if(!track)return;const{rtl}=axis(track);const forward=rtl?"ArrowLeft":"ArrowRight";const back=rtl?"ArrowRight":"ArrowLeft";const to=e.key===forward?target.current+1:e.key===back?target.current-1:e.key==="Home"?0:e.key==="End"?count-1:null;if(to===null)return;e.preventDefault();go(to)}const many=count>1;const showArrows=arrows&&many;const showBar=many&&(dots||counter||Boolean(autoplay));const arrow=back=>jsx12("button",{type:"button",disabled:back?state.atStart:state.atEnd,"aria-label":back?en?"Previous":"\u0627\u0644\u0633\u0627\u0628\u0642":en?"Next":"\u0627\u0644\u062A\u0627\u0644\u064A",onClick:()=>go(back?target.current-1:target.current+1),className:cn("absolute top-1/2 -translate-y-1/2 z-10 size-9 rounded-full flex items-center justify-center","bg-surface/92 backdrop-blur border border-line shadow-pop text-ink2","transition-opacity cursor-pointer hover:text-brand-ink","disabled:opacity-0 disabled:pointer-events-none",back?"start-2":"end-2"),children:back?jsx12(ChevronRight,{size:17,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx12(ChevronLeft,{size:17,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})});return jsxs11("section",{"aria-roledescription":en?"carousel":"\u0639\u0627\u0631\u0636 \u0634\u0631\u0627\u0626\u062D","aria-label":label,onPointerEnter:()=>autoplay&&setHeld(true),onPointerLeave:()=>autoplay&&setHeld(false),onFocusCapture:()=>autoplay&&setHeld(true),onBlurCapture:()=>autoplay&&setHeld(false),className:cn("flex flex-col gap-3 [--per:1]",className),style:{"--gap":`${gap}px`,...perView===void 0?null:{"--per":String(perView)}},children:[jsxs11("div",{className:"relative",children:[jsx12("div",{ref:trackRef,tabIndex:0,role:"group","aria-label":en?"Slides":"\u0627\u0644\u0634\u0631\u0627\u0626\u062D",onKeyDown,className:cn("flex overflow-x-auto overscroll-x-contain snap-x snap-mandatory","[scrollbar-width:none] [&::-webkit-scrollbar]:hidden","rounded-card focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",trackClassName),style:{gap:"var(--gap)"},children:slides.map((slide,i)=>jsx12("div",{role:"group","aria-roledescription":en?"slide":"\u0634\u0631\u064A\u062D\u0629","aria-label":en?`${i+1} of ${count}`:`${i+1} \u0645\u0646 ${count}`,className:"snap-start shrink-0 grow-0 min-w-0 relative",style:{flexBasis:BASIS},children:slide},i))}),showArrows&&arrow(true),showArrows&&arrow(false)]}),showBar&&jsxs11("div",{className:"flex items-center justify-center gap-3",children:[autoplay&&jsx12("button",{type:"button",onClick:()=>setPaused(p=>!p),"aria-label":paused?en?"Start auto-rotation":"\u0634\u063A\u0651\u0644 \u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0627\u0644\u062A\u0644\u0642\u0627\u0626\u064A":en?"Stop auto-rotation":"\u0623\u0648\u0642\u0641 \u0627\u0644\u062A\u0628\u062F\u064A\u0644 \u0627\u0644\u062A\u0644\u0642\u0627\u0626\u064A",className:"size-7 rounded-full flex items-center justify-center text-muted hover:bg-hover hover:text-ink transition-colors cursor-pointer",children:paused?jsx12(Play,{size:13,"aria-hidden":"true"}):jsx12(Pause,{size:13,"aria-hidden":"true"})}),dots&&jsx12("span",{className:"flex items-center gap-1.5",children:slides.map((_,i)=>jsx12("button",{type:"button",onClick:()=>go(i),"aria-label":en?`Go to slide ${i+1}`:`\u0627\u0630\u0647\u0628 \u0644\u0644\u0634\u0631\u064A\u062D\u0629 ${i+1}`,"aria-current":i===state.index||void 0,className:cn("h-1.5 rounded-full transition-all duration-200 cursor-pointer","before:absolute before:-inset-2 relative",i===state.index?"w-5 bg-brand":"w-1.5 bg-border hover:bg-muted2")},i))}),counter&&jsxs11("span",{dir:"ltr","data-num":true,"aria-live":autoplay?void 0:"polite",className:"text-caption font-bold text-muted tabular-nums",children:[state.index+1," / ",count]})]})]})}function Gallery({label,images,ratio="4/3",fit="cover",thumbs=true,zoom=true,className}){const en=useMoneyLang();const[index,setIndex]=useState8(0);const[open,setOpen]=useState8(false);const activeThumb=useRef7(null);useEffect6(()=>{activeThumb.current?.scrollIntoView({inline:"nearest",block:"nearest",behavior:ease()})},[index]);if(images.length===0)return null;const frame={aspectRatio:ratio};const img=(im,decorative)=>jsx12("img",{src:im.src,alt:decorative?"":im.alt,loading:"lazy",decoding:"async",draggable:false,className:cn("w-full h-full",fit==="cover"?"object-cover":"object-contain")});return jsxs11("div",{className:cn("flex flex-col gap-2.5",className),children:[jsx12(Carousel,{label,index,onIndexChange:setIndex,counter:images.length>1,dots:!thumbs&&images.length>1,gap:8,children:images.map((im,i)=>zoom?jsxs11("button",{type:"button",onClick:()=>setOpen(true),"aria-label":`${im.alt} \u2014 ${en?"open viewer":"\u0641\u062A\u062D \u0627\u0644\u0639\u0627\u0631\u0636"}`,style:frame,className:"group relative block w-full overflow-clip rounded-card bg-hover cursor-zoom-in",children:[img(im,true),jsx12("span",{"aria-hidden":"true",className:"absolute top-2 end-2 size-7 rounded-full bg-black/45 backdrop-blur text-white flex items-center justify-center opacity-70 transition-opacity group-hover:opacity-100",children:jsx12(ZoomIn,{size:14})})]},i):jsx12("div",{style:frame,className:"overflow-clip rounded-card bg-hover",children:img(im,false)},i))}),thumbs&&images.length>1&&jsx12("div",{role:"group","aria-label":en?"Thumbnails":"\u0627\u0644\u0645\u0635\u063A\u0651\u0631\u0627\u062A",className:"flex gap-2 overflow-x-auto pb-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:images.map((im,i)=>jsx12("button",{ref:i===index?activeThumb:void 0,type:"button",onClick:()=>setIndex(i),"aria-current":i===index||void 0,"aria-label":en?`Image ${i+1}`:`\u0627\u0644\u0635\u0648\u0631\u0629 ${i+1}`,className:cn("shrink-0 size-14 rounded-sm overflow-clip border-2 bg-hover cursor-pointer transition-colors",i===index?"border-brand":"border-line hover:border-border"),children:jsx12("img",{src:im.src,alt:"",loading:"lazy",decoding:"async",draggable:false,className:"w-full h-full object-cover"})},i))}),zoom&&jsx12(Lightbox,{open,images,index,onIndexChange:setIndex,onClose:()=>setOpen(false),label})]})}function Lightbox({open,images,index,onIndexChange,onClose,label,closeLabel}){const ui=useUIText();const en=useMoneyLang();const panel=useRef7(null);const count=images.length;useEffect6(()=>{if(!open)return;const from=document.activeElement;panel.current?.focus();return()=>from?.focus?.()},[open]);useEffect6(()=>{if(!open)return;function onKey(e){const rtl=getComputedStyle(document.documentElement).direction==="rtl";const forward=rtl?"ArrowLeft":"ArrowRight";const back=rtl?"ArrowRight":"ArrowLeft";if(e.key==="Escape")onClose();else if(e.key===forward)onIndexChange(Math.min(index+1,count-1));else if(e.key===back)onIndexChange(Math.max(index-1,0));else if(e.key==="Home")onIndexChange(0);else if(e.key==="End")onIndexChange(count-1)}document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[open,index,count,onClose,onIndexChange]);if(!open||count===0)return null;const current=images[Math.min(Math.max(index,0),count-1)];const step=back=>jsx12("button",{type:"button",disabled:back?index===0:index>=count-1,onClick:()=>onIndexChange(back?index-1:index+1),"aria-label":back?en?"Previous":"\u0627\u0644\u0633\u0627\u0628\u0642":en?"Next":"\u0627\u0644\u062A\u0627\u0644\u064A",className:cn("absolute top-1/2 -translate-y-1/2 z-10 size-11 rounded-full flex items-center justify-center","bg-white/10 backdrop-blur text-white transition-opacity cursor-pointer hover:bg-white/20","disabled:opacity-0 disabled:pointer-events-none",back?"start-3":"end-3"),children:back?jsx12(ChevronRight,{size:20,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx12(ChevronLeft,{size:20,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})});return jsxs11("div",{ref:panel,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":label??(en?"Image viewer":"\u0639\u0627\u0631\u0636 \u0627\u0644\u0635\u0648\u0631"),className:"fixed inset-0 z-50 bg-night/95 flex flex-col animate-[fade-in_0.18s_ease-out] outline-none",children:[jsxs11("header",{className:"shrink-0 h-14 px-4 flex items-center justify-between gap-3",children:[jsxs11("span",{dir:"ltr","data-num":true,className:"text-caption font-bold text-white/70 tabular-nums",children:[index+1," / ",count]}),jsx12("button",{type:"button",onClick:onClose,"aria-label":closeLabel??ui.close,className:"size-9 rounded-full bg-white/10 backdrop-blur flex items-center justify-center text-white transition-colors cursor-pointer hover:bg-white/20",children:jsx12(X4,{size:18,"aria-hidden":"true"})})]}),jsxs11("div",{className:"relative flex-1 min-h-0 flex items-center justify-center p-4 pb-8",children:[jsx12("img",{src:current.src,alt:current.alt,decoding:"async",draggable:false,className:"max-w-full max-h-full object-contain rounded-card animate-qfade"},current.src),count>1&&step(true),count>1&&step(false)]})]})}import{useEffect as useEffect7,useLayoutEffect as useLayoutEffect3,useRef as useRef8,useState as useState9}from"react";import{ChevronLeft as ChevronLeft2,ChevronRight as ChevronRight2,Lock,RotateCw,Signal,Wifi}from"lucide-react";import{jsx as jsx13,jsxs as jsxs12}from"react/jsx-runtime";function BrowserFrame({url,device="desktop",tab,nav,loading,contentWidth,onScale,onReload,children,className}){const ui=useUIText();const mobile=device==="mobile";const viewport=useRef8(null);const[scale,setScale]=useState9(1);const[rtl,setRtl]=useState9(true);useLayoutEffect3(()=>{const box=viewport.current;if(!box||!contentWidth)return setScale(1);setRtl(getComputedStyle(box).direction==="rtl");const read=()=>{const w=box.clientWidth;setScale(w>0?Math.min(1,w/contentWidth):1)};read();const ro=new ResizeObserver(read);ro.observe(box);return()=>ro.disconnect()},[contentWidth]);useEffect7(()=>{onScale?.(scale)},[scale,onScale]);const control="shrink-0 size-6 rounded-full flex items-center justify-center transition-colors";return jsxs12("div",{className:cn("flex flex-col overflow-clip bg-surface border border-line shadow-panel",mobile?"rounded-[30px] border-[7px] border-night":"rounded-lg",className),children:[mobile&&jsxs12("div",{className:"shrink-0 h-7 px-5 flex items-center justify-between bg-bg","aria-hidden":"true",children:[jsxs12("span",{className:"flex items-center gap-1 text-muted2",children:[jsx13(Signal,{size:11}),jsx13(Wifi,{size:11}),jsx13("span",{className:"w-4 h-2 rounded-[2px] border border-muted2"})]}),jsx13("span",{className:"w-16 h-4 rounded-full bg-night"})]}),tab&&!mobile&&jsx13("div",{className:"shrink-0 flex items-end gap-1 px-2.5 pt-2 bg-bg border-b border-line",children:jsxs12("span",{className:"flex items-center gap-2 h-8 max-w-[220px] px-3 rounded-t-sm bg-surface border border-line border-b-0",children:[jsx13("span",{"aria-hidden":"true",className:"size-3 rounded-[3px] bg-soft2 shrink-0"}),jsx13("span",{className:"text-micro text-ink2 truncate",children:tab})]})}),jsxs12("div",{className:cn("relative shrink-0 flex items-center gap-2 bg-bg border-b border-line",mobile?"px-2.5 py-2":"px-3 py-2.5"),children:[!mobile&&!tab&&jsx13("span",{"aria-hidden":"true",className:"flex items-center gap-1.5 shrink-0 me-1",children:[0,1,2].map(i=>jsx13("span",{className:"size-2.5 rounded-full bg-line border border-border/40"},i))}),nav&&!mobile&&jsxs12("span",{className:"flex items-center gap-0.5 shrink-0 text-muted2/60",children:[jsx13("span",{className:cn(control,"cursor-not-allowed"),"aria-hidden":"true",children:jsx13(ChevronRight2,{size:13})}),jsx13("span",{className:cn(control,"cursor-not-allowed"),"aria-hidden":"true",children:jsx13(ChevronLeft2,{size:13})})]}),jsxs12("span",{className:cn("flex-1 min-w-0 flex items-center gap-1.5 rounded-full bg-surface border border-line",mobile?"h-6 px-2.5":"h-7 px-3"),children:[jsx13(Lock,{size:mobile?9:10,className:"text-green shrink-0","aria-hidden":"true"}),jsx13(TechnicalText,{className:cn("truncate text-muted",mobile?"text-[9.5px]":"text-micro"),children:url})]}),onReload&&!mobile&&jsx13("button",{type:"button",onClick:onReload,"aria-label":ui.reloadPreview,className:cn(control,"text-muted2 hover:bg-hover hover:text-ink cursor-pointer"),children:jsx13(RotateCw,{size:12,"aria-hidden":"true",className:cn(loading&&"animate-spin")})}),loading&&jsx13("span",{"aria-hidden":"true",className:"absolute bottom-0 inset-x-0 h-[2px] overflow-clip",children:jsx13("span",{className:"absolute top-0 h-full w-[35%] bg-brand animate-[qload_1.1s_ease-in-out_infinite]"})})]}),jsx13("div",{ref:viewport,className:"relative flex-1 min-h-0 overflow-clip bg-surface",children:contentWidth?jsx13("div",{style:{width:contentWidth,height:`${100/scale}%`,transform:`scale(${scale})`,transformOrigin:`top ${rtl?"right":"left"}`},children}):children}),mobile&&jsx13("span",{"aria-hidden":"true",className:"shrink-0 h-4 bg-bg flex items-center justify-center",children:jsx13("span",{className:"w-24 h-1 rounded-full bg-border/50"})})]})}import"react";import{jsx as jsx14,jsxs as jsxs13}from"react/jsx-runtime";var clamp=(v,lo=0,hi=100)=>Math.min(hi,Math.max(lo,v));var signedString=v=>(v<0?"\u2212":"")+String(Math.abs(v));function WaterfallChart({total,steps,totalLabel,netLabel,formatValue=signedString,className}){const ui=useUIText();const top=Math.max(1,total);const bars=steps.reduce((acc,s)=>{const from=acc.length?acc[acc.length-1].to:total;acc.push({...s,from,to:from+s.value});return acc},[]);const net=bars.length?bars[bars.length-1].to:total;const biggest=bars.reduce((acc,b,i)=>b.value<acc.v?{i,v:b.value}:acc,{i:-1,v:0});return jsxs13("div",{className:cn("flex flex-col",className),children:[jsx14(Line,{label:totalLabel??ui.totalSales,value:total,formatValue,strong:true,children:jsx14("span",{className:"block h-2.5 rounded-full bg-brand"})}),bars.map((b,i)=>{const drop=b.value<0;const lo=clamp(Math.min(b.from,b.to)/top*100);const span=clamp(Math.abs(b.value)/top*100);const worst=i===biggest.i;return jsx14(Line,{label:b.label,meta:b.meta,value:b.value,formatValue,flag:worst?"\u0623\u0643\u0628\u0631 \u062E\u0635\u0645":void 0,children:jsx14("span",{dir:"ltr",className:"relative block h-2.5 rounded-full bg-hover overflow-clip",children:jsx14("span",{className:cn("absolute inset-y-0 rounded-full",drop?worst?"bg-danger":"bg-brand-100":"bg-green-solid"),style:{insetInlineStart:`${lo}%`,width:`${span}%`}})})},b.key)}),jsx14(Line,{label:netLabel??ui.netToYou,value:net,formatValue,strong:true,net:true,children:jsx14("span",{dir:"ltr",className:"block h-2.5 rounded-full bg-hover overflow-clip",children:jsx14("span",{className:"block h-full rounded-full bg-green-solid",style:{width:`${clamp(net/top*100)}%`}})})})]})}function Line({label,meta,value,formatValue,flag,strong,net,children}){return jsxs13("div",{className:cn("flex flex-col gap-1.5 py-2.5",net&&"border-t border-line mt-1 pt-3.5"),children:[jsxs13("span",{className:"flex items-baseline justify-between gap-3",children:[jsxs13("span",{className:"flex items-baseline gap-2 min-w-0",children:[jsx14("span",{className:cn("truncate",strong?"text-ui font-extrabold text-ink":"text-ui text-muted"),children:label}),flag&&jsx14("span",{className:"shrink-0 text-micro font-bold text-red bg-red-bg px-1.5 py-0.5 rounded-mark",children:flag})]}),jsx14("span",{"data-num":true,className:cn("shrink-0",strong?"text-body font-black text-ink":"text-ui font-bold text-ink2"),children:formatValue(value)})]}),children,meta&&jsx14("span",{className:"text-micro text-muted2",children:meta})]})}function GoalBar({value,goal,pace,label,formatValue=String,className}){const ui=useUIText();const top=Math.max(value,goal)*1.06;const pct=clamp(value/top*100);const goalAt=clamp(goal/top*100);const paceAt=pace===void 0?null:clamp(goalAt*clamp(pace,0,1));const behind=paceAt!==null&&pct<paceAt;return jsxs13("div",{className:cn("flex flex-col gap-2",className),children:[jsxs13("span",{className:"flex items-baseline justify-between gap-3",children:[label&&jsx14("span",{className:"text-ui font-bold text-ink2 truncate",children:label}),jsxs13("span",{className:"flex items-baseline gap-1.5 shrink-0",children:[jsx14("span",{"data-num":true,className:"text-body font-black text-ink",children:formatValue(value)}),jsxs13("span",{className:"text-micro text-muted2",children:["\u0645\u0646 ",jsx14("span",{"data-num":true,children:formatValue(goal)})]})]})]}),jsxs13("span",{dir:"ltr",className:"relative block h-3 rounded-full bg-hover",children:[jsx14("span",{className:cn("absolute inset-y-0 start-0 rounded-full transition-[width] duration-500",behind?"bg-amber":"bg-brand"),style:{width:`${pct}%`}}),paceAt!==null&&jsx14("span",{"aria-hidden":"true",title:ui.shouldBeHere,className:"absolute -top-1 -bottom-1 w-0.5 bg-muted2 rounded-full",style:{insetInlineStart:`${paceAt}%`}}),jsx14("span",{"aria-hidden":"true",className:"absolute -top-1.5 -bottom-1.5 w-1 bg-ink rounded-full",style:{insetInlineStart:`${goalAt}%`}})]}),paceAt!==null&&jsx14("span",{className:cn("text-micro",behind?"text-amber-ink":"text-muted2"),children:behind?"\u0648\u0631\u0627 \u0627\u0644\u0625\u064A\u0642\u0627\u0639 \u0627\u0644\u0645\u0637\u0644\u0648\u0628":"\u0642\u062F\u0651\u0627\u0645 \u0627\u0644\u0625\u064A\u0642\u0627\u0639 \u0627\u0644\u0645\u0637\u0644\u0648\u0628"})]})}function ParetoChart({items,height=140,threshold=80,formatValue=String,className}){const sorted=[...items].sort((a,b)=>b.value-a.value);const sum=sorted.reduce((s,i)=>s+i.value,0)||1;const top=Math.max(1,sorted[0]?.value??1);const rows=sorted.reduce((out,it)=>{const acc=(out.length?out[out.length-1].cum*sum/100:0)+it.value;out.push({...it,cum:acc/sum*100});return out},[]);const vital=rows.findIndex(r=>r.cum>=threshold)+1;return jsxs13("div",{className:cn("flex flex-col gap-2.5",className),children:[jsxs13("span",{className:"text-caption text-muted [text-wrap:pretty]",children:[jsx14("span",{"data-num":true,className:"font-extrabold text-ink",children:vital})," ","\u0645\u0646"," ",jsx14("span",{"data-num":true,className:"font-extrabold text-ink",children:rows.length})," ","\u0628\u064A\u0639\u0645\u0644\u0648\u0627"," ",jsx14("span",{"data-num":true,className:"font-extrabold text-ink",children:threshold}),"\u066A \u0645\u0646 \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A"]}),jsxs13("div",{className:"relative flex items-end gap-1.5",style:{height},children:[jsx14("span",{"aria-hidden":"true",className:"absolute inset-x-0 border-t border-dashed border-muted2",style:{top:`${100-threshold}%`}}),rows.map((r,i)=>jsx14("span",{className:"flex-1 min-w-0 flex flex-col justify-end items-center gap-1 h-full",children:jsx14("span",{title:`${String(r.label)} \xB7 ${formatValue(r.value)}`,className:cn("w-full rounded-t-mark transition-[height] duration-500",i<vital?"bg-brand":"bg-brand-100"),style:{height:`${clamp(r.value/top*100)}%`}})},r.key))]}),jsx14("div",{className:"flex items-center gap-1.5",children:rows.map((r,i)=>jsx14("span",{className:cn("flex-1 min-w-0 text-micro text-center truncate",i<vital?"text-ink2 font-bold":"text-muted2"),children:r.label},r.key))})]})}function StockRunway({items,urgentDays=7,horizonDays=30,className}){const rows=items.map(it=>({...it,days:it.perDay>0?it.stock/it.perDay:Infinity})).sort((a,b)=>a.days-b.days);return jsx14("div",{className:cn("flex flex-col gap-2.5",className),children:rows.map(r=>{const urgent=r.days<=urgentDays;const soon=!urgent&&r.days<=horizonDays/2;const pct=Number.isFinite(r.days)?clamp(r.days/horizonDays*100):100;return jsxs13("span",{className:"flex flex-col gap-1.5",children:[jsxs13("span",{className:"flex items-baseline justify-between gap-3",children:[jsx14("span",{className:"text-ui text-ink2 truncate min-w-0",children:r.label}),jsxs13("span",{className:"flex items-baseline gap-2 shrink-0",children:[jsxs13("span",{"data-num":true,className:"text-micro text-muted2",children:[r.stock," \u0642\u0637\u0639\u0629"]}),jsx14("span",{"data-num":true,className:cn("text-ui font-extrabold",urgent?"text-red":soon?"text-amber-ink":"text-ink"),children:Number.isFinite(r.days)?`${Math.floor(r.days)} \u064A\u0648\u0645`:"\u2014"})]})]}),jsx14("span",{dir:"ltr",className:"block h-1.5 rounded-full bg-hover overflow-clip",children:jsx14("span",{className:cn("block h-full rounded-full transition-[width] duration-500",urgent?"bg-danger":soon?"bg-amber":"bg-brand"),style:{width:`${pct}%`}})})]},r.key)})})}import{BadgeCheck}from"lucide-react";import{jsx as jsx15}from"react/jsx-runtime";var PROVIDER_LEVEL_LABEL={1:"\u0645\u0642\u062F\u0651\u0645 \u062C\u062F\u064A\u062F",2:"\u0645\u0642\u062F\u0651\u0645 \u0645\u062D\u062A\u0631\u0641",3:"\u0645\u0642\u062F\u0651\u0645 \u062E\u0628\u064A\u0631"};var PROVIDER_LEVEL_LABEL_EN={1:"New provider",2:"Pro provider",3:"Expert provider"};var CHEVRONS=[1.7,6,10.3];var DIM=.28;function ProviderMark({level,size=16,className}){return jsx15("svg",{width:size,height:size,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:cn("shrink-0",className),children:CHEVRONS.map((y,i)=>jsx15("path",{d:`M3.2 ${y+4}L8 ${y}L12.8 ${y+4}`,stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",opacity:i>=CHEVRONS.length-level?1:DIM},y))})}var LEVEL_TONE={1:"bg-hover text-ink2",2:"bg-soft text-brand-ink",3:TONE_SOLID.brand};var SIZES={sm:{box:"size-6",mark:14},md:{box:"size-7",mark:16}};function MarkChip({label,size,tone,className,children}){return jsx15(Tooltip,{content:label,children:jsx15("span",{role:"img","aria-label":label,tabIndex:0,className:cn("inline-flex items-center justify-center rounded-sm shrink-0 cursor-pointer","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",SIZES[size].box,tone,className),children})})}function ProviderBadge({level,size="sm",className}){const en=useMoneyLang();const label=en?PROVIDER_LEVEL_LABEL_EN[level]:PROVIDER_LEVEL_LABEL[level];return jsx15(MarkChip,{label,size,tone:LEVEL_TONE[level],className,children:jsx15(ProviderMark,{level,size:SIZES[size].mark})})}var VERIFIED_LABEL="\u062D\u0633\u0627\u0628 \u0645\u0648\u062B\u0651\u0642";var VERIFIED_LABEL_EN="Verified account";function VerifiedBadge({size="sm",className}){const en=useMoneyLang();return jsx15(MarkChip,{label:en?VERIFIED_LABEL_EN:VERIFIED_LABEL,size,tone:TONE_SOFT.green,className,children:jsx15(BadgeCheck,{size:SIZES[size].mark,strokeWidth:2,"aria-hidden":"true"})})}export{ANIMATE_SCALE,Accordion,Alert,AudioPlayer,Avatar,Badge,BarChart,BrowserFrame,Button,COLOR_SCALE,CONTAINER_SCALE,Calendar,Card,CardHeader,Carousel,Checkbox,ChoiceCards,Coach,CoachProvider,ColorField,Combobox,CommandPalette,Counter,DARK_TOKENS,DataTable,DateField,DateRangePicker,Drawer,Dropdown,Dropzone,EmptyState,FileRow,FilterChips,FunnelChart,Gallery,GoalBar,Heatmap,Input,Lightbox,LocaleCtx,Modal,Money,MoneyProvider,MultiSelect,NumberStepper,PROVIDER_LEVEL_LABEL,PROVIDER_LEVEL_LABEL_EN,PageHeader,ParetoChart,Phone,Picker,Product3DViewer,Progress,ProviderBadge,ProviderMark,RADIUS_SCALE,Radio,RadioGroup,RatingInput,SHADOW_SCALE,Scrubber,SearchInput,Select,ShareList,Sheet,Skeleton,SortableStatus,Sparkline,Stars,StatCard,Stepper,StockRunway,Switch,TEXT_SCALE,TOKENS,TONE_SOFT,TONE_SOLID,Tabs,TechnicalInput,TechnicalText,Textarea,Timeline,Toast,ToastHost,Tooltip,TrendChart,VerifiedBadge,VideoPlayer,WaterfallChart,WhatsAppIcon,buttonClasses,cn,coachSeconds,currencyName,currencySymbol,daysBetween,formatBytes,formatDate,formatRange,formatTime,isCurrency,normalizeHex,parsePhone,presets,toLatinDigits,useAudioLevel,useCoach,useCoachOptional,useCurrency,useCurrencySymbol,useMedia,useMoneyLang,useMoneyLocale,useSortable,useToasts,useUIText};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qumra/fanar",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "type": "module",
5
5
  "description": "Qumra's Arabic-first component library and design tokens. Tailwind 4, RSC-safe.",
6
6
  "license": "UNLICENSED",