@qumra/fanar 0.0.33 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/shihab.js +1 -1
- package/package.json +6 -1
- package/dist/chunk-4NDBVW4K.js +0 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{ToastHost,Tooltip,useToasts}from"./chunk-HSZOC7QG.js";import{ChoiceCards,DataTable,Sparkline}from"./chunk-2EYFCJZV.js";import{Calendar,Checkbox,DateField,DateRangePicker,Input,Radio,RadioGroup,SearchInput,Select,Switch,Textarea,daysBetween,formatDate,formatRange,presets}from"./chunk-TJMMFUQJ.js";import{Alert,Drawer,EmptyState,Modal,Sheet,Toast}from"./chunk-4ZNTBLVW.js";import{RatingInput,Stars}from"./chunk-4NDBVW4K.js";import{BarChart,FunnelChart,Heatmap,Money,MoneyProvider,ShareList,TrendChart,currencyName,currencySymbol,isCurrency,useCurrency,useCurrencySymbol}from"./chunk-NHKZAYI6.js";import{Button}from"./chunk-NHZYT3B4.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{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{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 jsx9,jsxs as jsxs9}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 jsxs9("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:[jsx9("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:jsx9(UploadCloud,{size:22,strokeWidth:1.8})}),jsx9("span",{className:"text-body font-extrabold text-ink",children:title??ui.dropImages}),hint&&jsx9("span",{className:"text-caption leading-[1.7] text-muted max-w-note",children:hint}),jsx9("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}),jsx9("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:jsx9(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:jsx9(Check4,{size:13,"aria-hidden":"true"}),label:"\u062A\u0645 \u0627\u0644\u0631\u0641\u0639"},rejected:{box:"bg-red-bg text-red",icon:jsx9(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 jsxs9("div",{className:"flex items-center gap-3 p-2.5 rounded-card border border-line bg-surface",children:[jsxs9("span",{className:"relative size-11 rounded-sm overflow-clip bg-hover border border-line shrink-0",children:[file.preview?jsx9("img",{src:file.preview,alt:"",className:"w-full h-full object-cover"}):jsx9("span",{className:"w-full h-full flex items-center justify-center text-muted2",children:jsx9(ImageIcon,{size:17,"aria-hidden":"true"})}),isCover&&coverLabel&&jsx9("span",{className:"absolute inset-x-0 bottom-0 bg-brand/90 text-white text-micro font-extrabold text-center py-px",children:coverLabel})]}),jsxs9("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsxs9("span",{className:"flex items-center gap-2 min-w-0",children:[jsx9("span",{dir:"auto",className:"text-ui font-bold text-ink truncate",children:file.name}),jsxs9("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"?jsx9("span",{className:"h-1 rounded-full bg-hover overflow-clip block",children:jsx9("span",{className:"block h-full rounded-full bg-brand transition-[width] duration-200",style:{width:`${file.progress??0}%`}})}):jsx9("span",{className:cn("text-caption",file.state==="rejected"?"text-red":"text-muted"),children:file.state==="rejected"?file.error:formatBytes(file.size)})]}),onRemove&&jsx9("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:jsx9(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 jsx10}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 jsx10("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 jsx11,jsxs as jsxs10}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=>jsx11("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?jsx11(ChevronRight,{size:17,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx11(ChevronLeft,{size:17,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})});return jsxs10("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:[jsxs10("div",{className:"relative",children:[jsx11("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)=>jsx11("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&&jsxs10("div",{className:"flex items-center justify-center gap-3",children:[autoplay&&jsx11("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?jsx11(Play,{size:13,"aria-hidden":"true"}):jsx11(Pause,{size:13,"aria-hidden":"true"})}),dots&&jsx11("span",{className:"flex items-center gap-1.5",children:slides.map((_,i)=>jsx11("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&&jsxs10("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)=>jsx11("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 jsxs10("div",{className:cn("flex flex-col gap-2.5",className),children:[jsx11(Carousel,{label,index,onIndexChange:setIndex,counter:images.length>1,dots:!thumbs&&images.length>1,gap:8,children:images.map((im,i)=>zoom?jsxs10("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),jsx11("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:jsx11(ZoomIn,{size:14})})]},i):jsx11("div",{style:frame,className:"overflow-clip rounded-card bg-hover",children:img(im,false)},i))}),thumbs&&images.length>1&&jsx11("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)=>jsx11("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:jsx11("img",{src:im.src,alt:"",loading:"lazy",decoding:"async",draggable:false,className:"w-full h-full object-cover"})},i))}),zoom&&jsx11(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=>jsx11("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?jsx11(ChevronRight,{size:20,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx11(ChevronLeft,{size:20,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})});return jsxs10("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:[jsxs10("header",{className:"shrink-0 h-14 px-4 flex items-center justify-between gap-3",children:[jsxs10("span",{dir:"ltr","data-num":true,className:"text-caption font-bold text-white/70 tabular-nums",children:[index+1," / ",count]}),jsx11("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:jsx11(X4,{size:18,"aria-hidden":"true"})})]}),jsxs10("div",{className:"relative flex-1 min-h-0 flex items-center justify-center p-4 pb-8",children:[jsx11("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 jsx12,jsxs as jsxs11}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 jsxs11("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&&jsxs11("div",{className:"shrink-0 h-7 px-5 flex items-center justify-between bg-bg","aria-hidden":"true",children:[jsxs11("span",{className:"flex items-center gap-1 text-muted2",children:[jsx12(Signal,{size:11}),jsx12(Wifi,{size:11}),jsx12("span",{className:"w-4 h-2 rounded-[2px] border border-muted2"})]}),jsx12("span",{className:"w-16 h-4 rounded-full bg-night"})]}),tab&&!mobile&&jsx12("div",{className:"shrink-0 flex items-end gap-1 px-2.5 pt-2 bg-bg border-b border-line",children:jsxs11("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:[jsx12("span",{"aria-hidden":"true",className:"size-3 rounded-[3px] bg-soft2 shrink-0"}),jsx12("span",{className:"text-micro text-ink2 truncate",children:tab})]})}),jsxs11("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&&jsx12("span",{"aria-hidden":"true",className:"flex items-center gap-1.5 shrink-0 me-1",children:[0,1,2].map(i=>jsx12("span",{className:"size-2.5 rounded-full bg-line border border-border/40"},i))}),nav&&!mobile&&jsxs11("span",{className:"flex items-center gap-0.5 shrink-0 text-muted2/60",children:[jsx12("span",{className:cn(control,"cursor-not-allowed"),"aria-hidden":"true",children:jsx12(ChevronRight2,{size:13})}),jsx12("span",{className:cn(control,"cursor-not-allowed"),"aria-hidden":"true",children:jsx12(ChevronLeft2,{size:13})})]}),jsxs11("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:[jsx12(Lock,{size:mobile?9:10,className:"text-green shrink-0","aria-hidden":"true"}),jsx12(TechnicalText,{className:cn("truncate text-muted",mobile?"text-[9.5px]":"text-micro"),children:url})]}),onReload&&!mobile&&jsx12("button",{type:"button",onClick:onReload,"aria-label":ui.reloadPreview,className:cn(control,"text-muted2 hover:bg-hover hover:text-ink cursor-pointer"),children:jsx12(RotateCw,{size:12,"aria-hidden":"true",className:cn(loading&&"animate-spin")})}),loading&&jsx12("span",{"aria-hidden":"true",className:"absolute bottom-0 inset-x-0 h-[2px] overflow-clip",children:jsx12("span",{className:"absolute top-0 h-full w-[35%] bg-brand animate-[qload_1.1s_ease-in-out_infinite]"})})]}),jsx12("div",{ref:viewport,className:"relative flex-1 min-h-0 overflow-clip bg-surface",children:contentWidth?jsx12("div",{style:{width:contentWidth,height:`${100/scale}%`,transform:`scale(${scale})`,transformOrigin:`top ${rtl?"right":"left"}`},children}):children}),mobile&&jsx12("span",{"aria-hidden":"true",className:"shrink-0 h-4 bg-bg flex items-center justify-center",children:jsx12("span",{className:"w-24 h-1 rounded-full bg-border/50"})})]})}import"react";import{AlertTriangle,CheckCircle2}from"lucide-react";import{Fragment as Fragment3,jsx as jsx13,jsxs as jsxs12}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 jsxs12("div",{className:cn("flex flex-col",className),children:[jsx13(Line,{label:totalLabel??ui.totalSales,value:total,formatValue,strong:true,children:jsx13("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 jsx13(Line,{label:b.label,meta:b.meta,value:b.value,formatValue,flag:worst?"\u0623\u0643\u0628\u0631 \u062E\u0635\u0645":void 0,children:jsx13("span",{dir:"ltr",className:"relative block h-2.5 rounded-full bg-hover overflow-clip",children:jsx13("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)}),jsx13(Line,{label:netLabel??ui.netToYou,value:net,formatValue,strong:true,net:true,children:jsx13("span",{dir:"ltr",className:"block h-2.5 rounded-full bg-hover overflow-clip",children:jsx13("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 jsxs12("div",{className:cn("flex flex-col gap-1.5 py-2.5",net&&"border-t border-line mt-1 pt-3.5"),children:[jsxs12("span",{className:"flex items-baseline justify-between gap-3",children:[jsxs12("span",{className:"flex items-baseline gap-2 min-w-0",children:[jsx13("span",{className:cn("truncate",strong?"text-ui font-extrabold text-ink":"text-ui text-muted"),children:label}),flag&&jsx13("span",{className:"shrink-0 text-micro font-bold text-red bg-red-bg px-1.5 py-0.5 rounded-mark",children:flag})]}),jsx13("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&&jsx13("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 jsxs12("div",{className:cn("flex flex-col gap-2",className),children:[jsxs12("span",{className:"flex items-baseline justify-between gap-3",children:[label&&jsx13("span",{className:"text-ui font-bold text-ink2 truncate",children:label}),jsxs12("span",{className:"flex items-baseline gap-1.5 shrink-0",children:[jsx13("span",{"data-num":true,className:"text-body font-black text-ink",children:formatValue(value)}),jsxs12("span",{className:"text-micro text-muted2",children:["\u0645\u0646 ",jsx13("span",{"data-num":true,children:formatValue(goal)})]})]})]}),jsxs12("span",{dir:"ltr",className:"relative block h-3 rounded-full bg-hover",children:[jsx13("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&&jsx13("span",{"aria-hidden":"true",title:ui.shouldBeHere,className:"absolute -top-1 -bottom-1 w-0.5 bg-muted2 rounded-full",style:{insetInlineStart:`${paceAt}%`}}),jsx13("span",{"aria-hidden":"true",className:"absolute -top-1.5 -bottom-1.5 w-1 bg-ink rounded-full",style:{insetInlineStart:`${goalAt}%`}})]}),paceAt!==null&&jsx13("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 jsxs12("div",{className:cn("flex flex-col gap-2.5",className),children:[jsxs12("span",{className:"text-caption text-muted [text-wrap:pretty]",children:[jsx13("span",{"data-num":true,className:"font-extrabold text-ink",children:vital})," ","\u0645\u0646"," ",jsx13("span",{"data-num":true,className:"font-extrabold text-ink",children:rows.length})," ","\u0628\u064A\u0639\u0645\u0644\u0648\u0627"," ",jsx13("span",{"data-num":true,className:"font-extrabold text-ink",children:threshold}),"\u066A \u0645\u0646 \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A"]}),jsxs12("div",{className:"relative flex items-end gap-1.5",style:{height},children:[jsx13("span",{"aria-hidden":"true",className:"absolute inset-x-0 border-t border-dashed border-muted2",style:{top:`${100-threshold}%`}}),rows.map((r,i)=>jsx13("span",{className:"flex-1 min-w-0 flex flex-col justify-end items-center gap-1 h-full",children:jsx13("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))]}),jsx13("div",{className:"flex items-center gap-1.5",children:rows.map((r,i)=>jsx13("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 jsx13("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 jsxs12("span",{className:"flex flex-col gap-1.5",children:[jsxs12("span",{className:"flex items-baseline justify-between gap-3",children:[jsx13("span",{className:"text-ui text-ink2 truncate min-w-0",children:r.label}),jsxs12("span",{className:"flex items-baseline gap-2 shrink-0",children:[jsxs12("span",{"data-num":true,className:"text-micro text-muted2",children:[r.stock," \u0642\u0637\u0639\u0629"]}),jsx13("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"})]})]}),jsx13("span",{dir:"ltr",className:"block h-1.5 rounded-full bg-hover overflow-clip",children:jsx13("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)})})}var BALANCE_TEXT={balance:["\u0627\u0644\u0631\u0635\u064A\u062F","Balance"],of:["\u0645\u0646","of"],shortBy:["\u064A\u0646\u0642\u0635\u0643","Short by"],covers:["\u0627\u0644\u0631\u0635\u064A\u062F \u064A\u0643\u0641\u064A","Balance covers it"],unavailable:["\u0627\u0644\u0631\u0635\u064A\u062F \u063A\u064A\u0631 \u0645\u062A\u0627\u062D \u0627\u0644\u0622\u0646","Balance unavailable right now"],fee:["\u0627\u0644\u0631\u0633\u0648\u0645","Fee"]};function BalanceCoverage({ref,available,required,currency,label,fee,feeLabel,hint,coveredText,comparable=true,loading=false,unavailable=false,unavailableText,announce=false,className}){const lang=useMoneyLang()?1:0;const T=BALANCE_TEXT;const locale=useMoneyLocale();const short=comparable?Math.max(0,required-available):0;const isShort=short>0;const pct=comparable&&required>0?clamp(available/required*100):100;const heading=label??T.balance[lang];const num=value=>new Intl.NumberFormat(locale).format(value);const amount=value=>jsx13(Money,{value,currency,trimZeros:true,size:"inherit",tone:"inherit"});return jsx13("div",{ref,role:announce?"alert":void 0,className:cn("flex flex-col gap-2.5 rounded-card border px-4 py-3.5",isShort?"border-amber-line bg-amber-bg":"border-line bg-bg",className),children:loading?jsxs12("span",{className:"flex flex-col gap-2.5",children:[jsx13(Skeleton,{width:"60%",className:"h-4"}),jsx13(Skeleton,{variant:"block",className:"h-1.5 rounded-full"})]}):unavailable?jsx13("span",{className:"text-caption text-muted [text-wrap:pretty]",children:unavailableText??T.unavailable[lang]}):jsxs12(Fragment3,{children:[jsxs12("span",{className:"flex items-center justify-between gap-x-3 gap-y-1 flex-wrap",children:[jsx13("span",{className:"text-ui font-bold text-ink",children:heading}),jsxs12("span",{className:"inline-flex items-baseline gap-1 text-ui font-bold text-ink2",children:[jsx13("span",{className:"text-ink",children:amount(available)}),comparable&&jsxs12(Fragment3,{children:[jsx13("span",{className:"font-normal text-muted",children:T.of[lang]}),amount(required)]})]})]}),comparable&&jsx13("span",{role:"progressbar","aria-label":typeof heading==="string"?heading:T.balance[lang],"aria-valuemin":0,"aria-valuemax":required,"aria-valuenow":Math.min(available,required),"aria-valuetext":`${num(available)} ${T.of[lang]} ${num(required)}`,className:"block h-1.5 rounded-full bg-hover overflow-clip",children:jsx13("span",{className:cn("block h-full rounded-full transition-[width] duration-500",isShort?"bg-amber":"bg-green-solid"),style:{width:`${pct}%`}})}),comparable&&(isShort?jsxs12("span",{className:"flex flex-col gap-1 text-amber-ink",children:[jsxs12("span",{className:"flex items-center justify-between gap-x-3 gap-y-0.5 flex-wrap",children:[jsxs12("span",{className:"inline-flex items-center gap-1.5 text-body font-extrabold",children:[jsx13(AlertTriangle,{size:16,className:"shrink-0","aria-hidden":"true"}),jsx13("span",{children:T.shortBy[lang]}),amount(short)]}),typeof fee==="number"&&fee>0&&jsxs12("span",{className:"inline-flex items-center gap-1 text-caption",children:[jsx13("span",{"aria-hidden":"true",children:"+"}),jsx13("span",{children:feeLabel??T.fee[lang]}),jsx13("span",{className:"font-bold",children:amount(fee)})]})]}),hint&&jsx13("span",{className:"text-caption [text-wrap:pretty]",children:hint})]}):jsxs12("span",{className:"flex items-center gap-1.5 text-caption font-bold text-green [text-wrap:pretty]",children:[jsx13(CheckCircle2,{size:15,className:"shrink-0","aria-hidden":"true"}),coveredText??T.covers[lang]]}))]})})}import{BadgeCheck}from"lucide-react";import{jsx as jsx14}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 jsx14("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)=>jsx14("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 jsx14(Tooltip,{content:label,children:jsx14("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 jsx14(MarkChip,{label,size,tone:LEVEL_TONE[level],className,children:jsx14(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 jsx14(MarkChip,{label:en?VERIFIED_LABEL_EN:VERIFIED_LABEL,size,tone:TONE_SOFT.green,className,children:jsx14(BadgeCheck,{size:SIZES[size].mark,strokeWidth:2,"aria-hidden":"true"})})}export{ANIMATE_SCALE,Accordion,Alert,AudioPlayer,Avatar,Badge,BalanceCoverage,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{ChoiceCards,DataTable,Sparkline}from"./chunk-2EYFCJZV.js";import{Calendar,Checkbox,DateField,DateRangePicker,Input,Radio,RadioGroup,SearchInput,Select,Switch,Textarea,daysBetween,formatDate,formatRange,presets}from"./chunk-TJMMFUQJ.js";import{Alert,Drawer,EmptyState,Modal,Sheet,Toast}from"./chunk-4ZNTBLVW.js";import{BarChart,FunnelChart,Heatmap,Money,MoneyProvider,ShareList,TrendChart,currencyName,currencySymbol,isCurrency,useCurrency,useCurrencySymbol}from"./chunk-NHKZAYI6.js";import{Button}from"./chunk-NHZYT3B4.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{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{AlertTriangle,CheckCircle2}from"lucide-react";import{Fragment as Fragment3,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)})})}var BALANCE_TEXT={balance:["\u0627\u0644\u0631\u0635\u064A\u062F","Balance"],of:["\u0645\u0646","of"],shortBy:["\u064A\u0646\u0642\u0635\u0643","Short by"],covers:["\u0627\u0644\u0631\u0635\u064A\u062F \u064A\u0643\u0641\u064A","Balance covers it"],unavailable:["\u0627\u0644\u0631\u0635\u064A\u062F \u063A\u064A\u0631 \u0645\u062A\u0627\u062D \u0627\u0644\u0622\u0646","Balance unavailable right now"],fee:["\u0627\u0644\u0631\u0633\u0648\u0645","Fee"]};function BalanceCoverage({ref,available,required,currency,label,fee,feeLabel,hint,coveredText,comparable=true,loading=false,unavailable=false,unavailableText,announce=false,className}){const lang=useMoneyLang()?1:0;const T=BALANCE_TEXT;const locale=useMoneyLocale();const short=comparable?Math.max(0,required-available):0;const isShort=short>0;const pct=comparable&&required>0?clamp(available/required*100):100;const heading=label??T.balance[lang];const num=value=>new Intl.NumberFormat(locale).format(value);const amount=value=>jsx14(Money,{value,currency,trimZeros:true,size:"inherit",tone:"inherit"});return jsx14("div",{ref,role:announce?"alert":void 0,className:cn("flex flex-col gap-2.5 rounded-card border px-4 py-3.5",isShort?"border-amber-line bg-amber-bg":"border-line bg-bg",className),children:loading?jsxs13("span",{className:"flex flex-col gap-2.5",children:[jsx14(Skeleton,{width:"60%",className:"h-4"}),jsx14(Skeleton,{variant:"block",className:"h-1.5 rounded-full"})]}):unavailable?jsx14("span",{className:"text-caption text-muted [text-wrap:pretty]",children:unavailableText??T.unavailable[lang]}):jsxs13(Fragment3,{children:[jsxs13("span",{className:"flex items-center justify-between gap-x-3 gap-y-1 flex-wrap",children:[jsx14("span",{className:"text-ui font-bold text-ink",children:heading}),jsxs13("span",{className:"inline-flex items-baseline gap-1 text-ui font-bold text-ink2",children:[jsx14("span",{className:"text-ink",children:amount(available)}),comparable&&jsxs13(Fragment3,{children:[jsx14("span",{className:"font-normal text-muted",children:T.of[lang]}),amount(required)]})]})]}),comparable&&jsx14("span",{role:"progressbar","aria-label":typeof heading==="string"?heading:T.balance[lang],"aria-valuemin":0,"aria-valuemax":required,"aria-valuenow":Math.min(available,required),"aria-valuetext":`${num(available)} ${T.of[lang]} ${num(required)}`,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",isShort?"bg-amber":"bg-green-solid"),style:{width:`${pct}%`}})}),comparable&&(isShort?jsxs13("span",{className:"flex flex-col gap-1 text-amber-ink",children:[jsxs13("span",{className:"flex items-center justify-between gap-x-3 gap-y-0.5 flex-wrap",children:[jsxs13("span",{className:"inline-flex items-center gap-1.5 text-body font-extrabold",children:[jsx14(AlertTriangle,{size:16,className:"shrink-0","aria-hidden":"true"}),jsx14("span",{children:T.shortBy[lang]}),amount(short)]}),typeof fee==="number"&&fee>0&&jsxs13("span",{className:"inline-flex items-center gap-1 text-caption",children:[jsx14("span",{"aria-hidden":"true",children:"+"}),jsx14("span",{children:feeLabel??T.fee[lang]}),jsx14("span",{className:"font-bold",children:amount(fee)})]})]}),hint&&jsx14("span",{className:"text-caption [text-wrap:pretty]",children:hint})]}):jsxs13("span",{className:"flex items-center gap-1.5 text-caption font-bold text-green [text-wrap:pretty]",children:[jsx14(CheckCircle2,{size:15,className:"shrink-0","aria-hidden":"true"}),coveredText??T.covers[lang]]}))]})})}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,BalanceCoverage,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/dist/shihab.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{Stars}from"./chunk-4NDBVW4K.js";import{Markdown}from"./chunk-A2AXNC3M.js";import{BarChart,Money,TrendChart,isCurrency}from"./chunk-NHKZAYI6.js";import{Button}from"./chunk-NHZYT3B4.js";import{Badge,Skeleton}from"./chunk-JOHJNMV2.js";import{cn,useMoneyLang,useMoneyLocale}from"./chunk-YJ45RGS6.js";import{useEffect as useEffect2,useMemo}from"react";import{List,TriangleAlert as TriangleAlert2}from"lucide-react";import{createContext,useContext}from"react";var ShihabContext=createContext({live:false});function useShihab(){return useContext(ShihabContext)}var ORDER_STATUS={pending:["\u0642\u064A\u062F \u0627\u0644\u0627\u0646\u062A\u0638\u0627\u0631","Pending","neutral"],confirmed:["\u0645\u0624\u0643\u064E\u0651\u062F","Confirmed","brand"],paid:["\u0645\u062F\u0641\u0648\u0639","Paid","green"],unpaid:["\u063A\u064A\u0631 \u0645\u062F\u0641\u0648\u0639","Unpaid","amber"],fulfilled:["\u062A\u0645 \u0627\u0644\u062A\u062C\u0647\u064A\u0632","Fulfilled","brand"],unfulfilled:["\u0644\u0645 \u064A\u064F\u062C\u0647\u064E\u0651\u0632","Unfulfilled","neutral"],delivered:["\u062A\u0645 \u0627\u0644\u062A\u0648\u0635\u064A\u0644","Delivered","green"],returned:["\u0645\u0631\u062A\u062C\u0639","Returned","amber"],refunded:["\u0645\u0633\u062A\u0631\u064E\u062F","Refunded","amber"],cancelled:["\u0645\u0644\u063A\u064A","Cancelled","red"],canceled:["\u0645\u0644\u063A\u064A","Cancelled","red"]};var DICTS={orderStatus:ORDER_STATUS,orderField:{financialstatus:["\u062D\u0627\u0644\u0629 \u0627\u0644\u062F\u0641\u0639","Payment"],orderstatus:["\u062D\u0627\u0644\u0629 \u0627\u0644\u0637\u0644\u0628","Order"],fulfillmentstatus:["\u062D\u0627\u0644\u0629 \u0627\u0644\u062A\u062C\u0647\u064A\u0632","Fulfillment"]},timelineType:{status_change:["\u062A\u063A\u064A\u064A\u0631 \u062D\u0627\u0644\u0629","Status change"],note:["\u0645\u0644\u0627\u062D\u0638\u0629","Note"]},productStatus:{active:["\u0646\u0634\u0637","Active","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"],archived:["\u0645\u0624\u0631\u0634\u0641","Archived","neutral"]},blogStatus:{active:["\u0645\u0646\u0634\u0648\u0631\u0629","Published","green"],published:["\u0645\u0646\u0634\u0648\u0631\u0629","Published","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"],scheduled:["\u0645\u062C\u062F\u0648\u0644\u0629","Scheduled","brand"]},leadStatus:{draft:["\u0628\u064A\u0627\u0646\u0627\u062A \u0646\u0627\u0642\u0635\u0629","Incomplete","neutral"],abandoned:["\u0645\u0641\u0642\u0648\u062F","Lost","amber"]},paymentType:{cod:["\u0627\u0644\u062F\u0641\u0639 \u0639\u0646\u062F \u0627\u0644\u0627\u0633\u062A\u0644\u0627\u0645","Cash on delivery"],manual:["\u062F\u0641\u0639 \u064A\u062F\u0648\u064A","Manual payment"],gateway:["\u062F\u0641\u0639 \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A","Online payment"]},offerMethod:{discount_code:["\u0643\u0648\u062F \u062E\u0635\u0645","Discount code"],automatic:["\u062A\u0644\u0642\u0627\u0626\u064A","Automatic"]},offerType:{buy_get:["\u0627\u0634\u062A\u0631\u0650 \u0648\u0627\u062D\u0635\u0644","Buy X get Y"],fixed_discount:["\u062E\u0635\u0645 \u0645\u0628\u0644\u063A","Fixed discount"],percentage_discount:["\u062E\u0635\u0645 \u0646\u0633\u0628\u0629","Percentage discount"],free_shipping:["\u0634\u062D\u0646 \u0645\u062C\u0627\u0646\u064A","Free shipping"]},allowTo:{all:["\u0644\u0643\u0644 \u0627\u0644\u0639\u0645\u0644\u0627\u0621","All customers"],specific:["\u0644\u0639\u0645\u0644\u0627\u0621 \u0645\u062D\u062F\u0651\u062F\u064A\u0646","Specific customers"]},appliedOn:{all_products:["\u0643\u0644 \u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A","All products"],selected_products:["\u0645\u0646\u062A\u062C\u0627\u062A \u0645\u062D\u062F\u0651\u062F\u0629","Selected products"],selected_collections:["\u0645\u062C\u0645\u0648\u0639\u0627\u062A \u0645\u062D\u062F\u0651\u062F\u0629","Selected collections"],selected_payment_methods:["\u0648\u0633\u0627\u0626\u0644 \u062F\u0641\u0639 \u0645\u062D\u062F\u0651\u062F\u0629","Selected payment methods"]},marketStatus:{active:["\u0646\u0634\u0637","Active","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"]},fxMode:{dynamic:["\u0633\u0639\u0631 \u0635\u0631\u0641 \u062A\u0644\u0642\u0627\u0626\u064A","Automatic rate"],manual:["\u0633\u0639\u0631 \u0635\u0631\u0641 \u064A\u062F\u0648\u064A","Manual rate"]},mediaKind:{image:["\u0635\u0648\u0631\u0629","Image"],video:["\u0641\u064A\u062F\u064A\u0648","Video"],audio:["\u0635\u0648\u062A","Audio"],pdf:["PDF","PDF"],file:["\u0645\u0644\u0641","File"],other:["\u0623\u062E\u0631\u0649","Other"]},collectionStatus:{active:["\u0646\u0634\u0637\u0629","Active","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"]},operation:{manual:["\u064A\u062F\u0648\u064A\u0629","Manual"],automated:["\u062A\u0644\u0642\u0627\u0626\u064A\u0629","Automated"]},reviewStatus:{pending:["\u0628\u0627\u0646\u062A\u0638\u0627\u0631 \u0627\u0644\u0645\u0631\u0627\u062C\u0639\u0629","Pending","amber"],approved:["\u0645\u0639\u062A\u0645\u062F","Approved","green"],rejected:["\u0645\u0631\u0641\u0648\u0636","Rejected","red"]},locationStatus:{active:["\u0646\u0634\u0637","Active","green"],inactive:["\u0645\u062A\u0648\u0642\u0651\u0641","Inactive","neutral"]},rateSource:{flat:["\u0633\u0639\u0631 \u062B\u0627\u0628\u062A","Flat rate"],carrier:["\u0645\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646","Carrier rate"]},zoneType:{countries:["\u062F\u0648\u0644","Countries"],regions:["\u0645\u0646\u0627\u0637\u0642","Regions"]},supportType:{whatsapp:["\u0648\u0627\u062A\u0633\u0627\u0628","WhatsApp"],phone:["\u0627\u062A\u0635\u0627\u0644","Call"],email:["\u0625\u064A\u0645\u064A\u0644","Email"],chat:["\u0645\u062D\u0627\u062F\u062B\u0629","Chat"]},subscriptionStatus:{active:["\u0641\u0639\u0651\u0627\u0644","Active","green"],expired:["\u0645\u0646\u062A\u0647\u064A","Expired","red"],pending:["\u0628\u0627\u0646\u062A\u0638\u0627\u0631 \u0627\u0644\u062F\u0641\u0639","Payment pending","amber"],cancelled:["\u0645\u0644\u063A\u064A","Cancelled","red"]},blockTitle:{orders:["\u0627\u0644\u0637\u0644\u0628\u0627\u062A","Orders"],order:["\u0627\u0644\u0637\u0644\u0628","Order"],"order-timeline":["\u0633\u062C\u0644 \u0627\u0644\u0637\u0644\u0628","Order history"],"checkout-leads":["\u0627\u0644\u0637\u0644\u0628\u0627\u062A \u0627\u0644\u0645\u0641\u0642\u0648\u062F\u0629","Lost orders"],"sales-summary":["\u0645\u0644\u062E\u0651\u0635 \u0627\u0644\u0645\u0628\u064A\u0639\u0627\u062A","Sales summary"],insights:["\u062A\u062D\u0644\u064A\u0644\u0627\u062A","Insights"],chart:["\u0631\u0633\u0645 \u0628\u064A\u0627\u0646\u064A","Chart"],"ql-result":["\u0627\u0644\u0646\u062A\u064A\u062C\u0629","Result"],products:["\u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A","Products"],product:["\u0627\u0644\u0645\u0646\u062A\u062C","Product"],collections:["\u0627\u0644\u0645\u062C\u0645\u0648\u0639\u0627\u062A","Collections"],inventory:["\u0627\u0644\u0645\u062E\u0632\u0648\u0646","Inventory"],reviews:["\u0627\u0644\u062A\u0642\u064A\u064A\u0645\u0627\u062A","Reviews"],media:["\u0627\u0644\u0648\u0633\u0627\u0626\u0637","Media"],customers:["\u0627\u0644\u0639\u0645\u0644\u0627\u0621","Customers"],offers:["\u0627\u0644\u0639\u0631\u0648\u0636","Offers"],coupons:["\u0627\u0644\u0643\u0648\u0628\u0648\u0646\u0627\u062A","Coupons"],"blog-posts":["\u0627\u0644\u0645\u0642\u0627\u0644\u0627\u062A","Blog posts"],"blog-post":["\u0627\u0644\u0645\u0642\u0627\u0644\u0629","Blog post"],"blog-categories":["\u062A\u0635\u0646\u064A\u0641\u0627\u062A \u0627\u0644\u0645\u062F\u0648\u0646\u0629","Blog categories"],markets:["\u0627\u0644\u0623\u0633\u0648\u0627\u0642","Markets"],locations:["\u0627\u0644\u0641\u0631\u0648\u0639","Locations"],menus:["\u0627\u0644\u0642\u0648\u0627\u0626\u0645","Menus"],countries:["\u0627\u0644\u062F\u0648\u0644","Countries"],provinces:["\u0627\u0644\u0645\u062D\u0627\u0641\u0638\u0627\u062A","Provinces"],"shipping-profiles":["\u0645\u0644\u0641\u0627\u062A \u0627\u0644\u0634\u062D\u0646","Shipping profiles"],"shipping-zones":["\u0645\u0646\u0627\u0637\u0642 \u0627\u0644\u0634\u062D\u0646","Shipping zones"],"shipping-rates":["\u0623\u0633\u0639\u0627\u0631 \u0627\u0644\u0634\u062D\u0646","Shipping rates"],carriers:["\u0634\u0631\u0643\u0627\u062A \u0627\u0644\u0634\u062D\u0646","Carriers"],plans:["\u0627\u0644\u0628\u0627\u0642\u0627\u062A","Plans"],subscription:["\u0627\u0634\u062A\u0631\u0627\u0643\u0643","Your subscription"],"support-methods":["\u062A\u0648\u0627\u0635\u0644 \u0645\u0639 \u0627\u0644\u062F\u0639\u0645","Contact support"],action_confirm:["\u062A\u0623\u0643\u064A\u062F","Confirm"],mermaid:["\u0645\u062E\u0637\u0651\u0637","Diagram"]},testStatus:{success:["\u0646\u062C\u062D","Passed","green"],failed:["\u0641\u0634\u0644","Failed","red"],failure:["\u0641\u0634\u0644","Failed","red"]}};var TEXT={viewAll:["\u0639\u0631\u0636 \u0627\u0644\u0643\u0644","View all"],empty:["\u0645\u0641\u064A\u0634 \u0646\u062A\u0627\u0626\u062C","Nothing to show"],invalid:["\u062A\u0639\u0630\u0651\u0631 \u0639\u0631\u0636 \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A","Couldn't display this data"],preparing:["\u0628\u064A\u062C\u0647\u0651\u0632 \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A\u2026","Preparing data\u2026"],copy:["\u0646\u0633\u062E","Copy"],copied:["\u0627\u062A\u0646\u0633\u062E","Copied"],open:["\u0641\u062A\u062D","Open"],more:["\u0627\u0644\u0645\u0632\u064A\u062F","More"],less:["\u0623\u0642\u0644","Less"],isDefault:["\u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A","Default"],active:["\u0645\u0641\u0639\u0651\u0644","Active"],inactive:["\u0645\u062A\u0648\u0642\u0651\u0641","Inactive"],unlimited:["\u063A\u064A\u0631 \u0645\u062D\u062F\u0648\u062F","Unlimited"],system:["\u0627\u0644\u0646\u0638\u0627\u0645","System"],by:["\u0628\u0648\u0627\u0633\u0637\u0629","by"],confirm:["\u062A\u0623\u0643\u064A\u062F","Confirm"],cancel:["\u0625\u0644\u063A\u0627\u0621","Cancel"],confirmed:["\u0627\u062A\u0623\u0643\u0651\u062F","Confirmed"],cancelledState:["\u0627\u062A\u0644\u063A\u0649","Cancelled"],before:["\u0642\u0628\u0644","Before"],after:["\u0628\u0639\u062F","After"],items:["\u0645\u0646\u062A\u062C\u0627\u062A","items"],total:["\u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A","Total"],customer:["\u0627\u0644\u0639\u0645\u064A\u0644","Customer"],phone:["\u0627\u0644\u0631\u0642\u0645","Phone"],date:["\u0627\u0644\u062A\u0627\u0631\u064A\u062E","Date"],shipTo:["\u0627\u0644\u062A\u0648\u0635\u064A\u0644 \u0625\u0644\u0649","Ship to"],totalLeads:["\u0627\u0644\u0637\u0644\u0628\u0627\u062A \u0627\u0644\u0645\u0641\u0642\u0648\u062F\u0629","Lost orders"],totalCartValue:["\u0642\u064A\u0645\u0629 \u0627\u0644\u0633\u0644\u0627\u0644","Cart value"],avgCartValue:["\u0645\u062A\u0648\u0633\u0651\u0637 \u0627\u0644\u0633\u0644\u0629","Average cart"],withEmail:["\u0628\u0625\u064A\u0645\u064A\u0644","With email"],withAddress:["\u0628\u0639\u0646\u0648\u0627\u0646","With address"],withCOD:["\u062F\u0641\u0639 \u0639\u0646\u062F \u0627\u0644\u0627\u0633\u062A\u0644\u0627\u0645","Cash on delivery"],marketingOptIn:["\u0645\u0648\u0627\u0641\u0642 \u0639\u0644\u0649 \u0627\u0644\u062A\u0633\u0648\u064A\u0642","Marketing opt-in"],hasAddress:["\u0639\u0646\u062F\u0647 \u0639\u0646\u0648\u0627\u0646","Has address"],hasCoupon:["\u0641\u064A\u0647 \u0643\u0648\u0628\u0648\u0646","Has coupon"],phoneVerified:["\u0627\u0644\u0631\u0642\u0645 \u0645\u062A\u0623\u0643\u0651\u062F","Phone verified"],lastActivity:["\u0622\u062E\u0631 \u0646\u0634\u0627\u0637","Last activity"],noPayment:["\u0644\u0645 \u064A\u062E\u062A\u0631","Not chosen"],revenue:["\u0627\u0644\u0625\u064A\u0631\u0627\u062F\u0627\u062A","Revenue"],ordersCount:["\u0627\u0644\u0637\u0644\u0628\u0627\u062A","Orders"],avgOrder:["\u0645\u062A\u0648\u0633\u0651\u0637 \u0627\u0644\u0637\u0644\u0628","Average order"],vsPrev:["\u0639\u0646 \u0627\u0644\u0641\u062A\u0631\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629","vs previous period"],highlights:["\u0623\u0647\u0645 \u0627\u0644\u0645\u0644\u0627\u062D\u0638\u0627\u062A","Highlights"],recommendations:["\u0627\u0642\u062A\u0631\u0627\u062D\u0627\u062A","Recommendations"],outOfStock:["\u0646\u0641\u062F","Out of stock"],inStock:["\u0641\u064A \u0627\u0644\u0645\u062E\u0632\u0648\u0646","in stock"],sold30:["\u0627\u062A\u0628\u0627\u0639 \u0641\u064A \u0622\u062E\u0631 \u0663\u0660 \u064A\u0648\u0645","sold in the last 30 days"],products:["\u0645\u0646\u062A\u062C","products"],onHand:["\u0627\u0644\u0641\u0639\u0644\u064A","On hand"],available:["\u0627\u0644\u0645\u062A\u0627\u062D","Available"],committed:["\u0645\u062D\u062C\u0648\u0632","Committed"],incoming:["\u0648\u0627\u0631\u062F","Incoming"],unavailable:["\u063A\u064A\u0631 \u0645\u062A\u0627\u062D","Unavailable"],on:["\u0639\u0644\u0649","on"],views:["\u0645\u0634\u0627\u0647\u062F\u0629","views"],afterCompression:["\u0628\u0639\u062F \u0627\u0644\u0636\u063A\u0637","compressed"],shownSize:["\u062D\u062C\u0645 \u0627\u0644\u0645\u0639\u0631\u0648\u0636","Size shown"],copyLink:["\u0646\u0633\u062E \u0627\u0644\u0631\u0627\u0628\u0637","Copy link"],verified:["\u0645\u0648\u062B\u0651\u0642","Verified"],blocked:["\u0645\u062D\u0638\u0648\u0631","Blocked"],ordersUnit:["\u0637\u0644\u0628\u0627\u062A","orders"],lastSeen:["\u0622\u062E\u0631 \u0638\u0647\u0648\u0631","Last seen"],live:["\u0634\u063A\u0651\u0627\u0644","Live"],ended:["\u0627\u0646\u062A\u0647\u0649","Ended"],notStarted:["\u0644\u0633\u0647 \u0645\u0627\u0628\u062F\u0623\u0634","Not started"],paused:["\u0645\u062A\u0648\u0642\u0651\u0641","Paused"],daysLeft:["\u064A\u0648\u0645 \u0645\u062A\u0628\u0642\u0651\u064A","days left"],minPurchase:["\u062D\u062F\u0651 \u0623\u062F\u0646\u0649","Minimum"],maxDiscount:["\u0623\u0642\u0635\u0649 \u062E\u0635\u0645","Max discount"],liveNow:["\u0634\u063A\u0651\u0627\u0644 \u062F\u0644\u0648\u0642\u062A\u064A","Live now"],totalOffers:["\u0643\u0644 \u0627\u0644\u0639\u0631\u0648\u0636","All offers"],countriesUnit:["\u062F\u0648\u0644","countries"],rounding:["\u062A\u0642\u0631\u064A\u0628 \u0627\u0644\u0623\u0633\u0639\u0627\u0631","Price rounding"],localCurrencies:["\u0639\u0645\u0644\u0627\u062A \u0645\u062D\u0644\u0651\u064A\u0629","Local currencies"],fulfillsOnline:["\u0628\u064A\u062C\u0647\u0651\u0632 \u0637\u0644\u0628\u0627\u062A \u0627\u0644\u0623\u0648\u0646\u0644\u0627\u064A\u0646","Fulfills online orders"],shipsInventory:["\u0628\u064A\u0634\u062D\u0646 \u0645\u062E\u0632\u0648\u0646","Ships inventory"],hasInventory:["\u0641\u064A\u0647 \u0645\u062E\u0632\u0648\u0646 \u0646\u0634\u0637","Has active inventory"],links:["\u0631\u0648\u0627\u0628\u0637","links"],groups:["\u0645\u062C\u0645\u0648\u0639\u0627\u062A \u0645\u0648\u0627\u0642\u0639","location groups"],freeOver:["\u0645\u062C\u0627\u0646\u064A \u0641\u0648\u0642","Free over"],autoRates:["\u0628\u062A\u062C\u064A\u0628 \u0623\u0633\u0639\u0627\u0631 \u062A\u0644\u0642\u0627\u0626\u064A\u0627\u064B","Live rates"],keySaved:["\u0627\u0644\u0645\u0641\u062A\u0627\u062D \u0645\u062D\u0641\u0648\u0638","API key saved"],lastTest:["\u0622\u062E\u0631 \u0627\u062E\u062A\u0628\u0627\u0631","Last test"],available_country:["\u0645\u062A\u0627\u062D\u0629","Enabled"],monthly:["\u0634\u0647\u0631\u064A","Monthly"],yearly:["\u0633\u0646\u0648\u064A","Yearly"],perMonth:["\u0634\u0647\u0631","month"],perYear:["\u0633\u0646\u0629","year"],popular:["\u0627\u0644\u0623\u0643\u062B\u0631 \u0637\u0644\u0628\u0627\u064B","Most popular"],free:["\u0645\u062C\u0627\u0646\u064A\u0629","Free"],subscribe:["\u0627\u0634\u062A\u0631\u0643","Subscribe"],renews:["\u0628\u064A\u062A\u062C\u062F\u0651\u062F","Renews"],upgradeTo:["\u062A\u0631\u0642\u064A\u0629 \u0644\u0640","Upgrade to"],startsOn:["\u0628\u062A\u0628\u062F\u0623","starts"],productsLimit:["\u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A","Products"],storage:["\u0627\u0644\u0645\u0633\u0627\u062D\u0629","Storage"],staff:["\u062D\u0633\u0627\u0628\u0627\u062A \u0627\u0644\u0645\u0648\u0638\u0641\u064A\u0646","Staff accounts"]};function useShihabText(){const en=useMoneyLang();const locale=useMoneyLocale();const i=en?1:0;const entry=(dict,value)=>typeof value==="string"?DICTS[dict][value.toLowerCase()]:void 0;return{t:key=>TEXT[key][i],label:(dict,value)=>{if(typeof value!=="string"||!value.trim())return void 0;return entry(dict,value)?.[i]??value},tone:(dict,value)=>entry(dict,value)?.[2]??"neutral",locale,en}}import{useEffect,useRef,useState}from"react";import{Check,Copy,ImageOff}from"lucide-react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";function useHref(entity,id){const{hrefFor}=useShihab();return hrefFor?.(entity,id)}function Go({href,className,children}){const{Link}=useShihab();if(!href)return jsx("span",{className,children});if(Link)return jsx(Link,{href,className,children});return jsx("a",{href,className,children})}function BlockCard({icon:Icon,title,count,children,footer,footerHref,className}){const{locale}=useShihabText();const head=Icon||title;return jsxs("section",{className:cn("@container w-full min-w-0 bg-surface border border-line rounded-card overflow-clip",className),children:[head&&jsxs("header",{className:"flex items-center gap-2 px-3.5 pt-3 pb-2",children:[Icon&&jsx("span",{"aria-hidden":"true",className:"size-7 rounded-sm bg-soft text-brand-ink flex items-center justify-center shrink-0",children:jsx(Icon,{size:15,strokeWidth:2})}),title&&jsx("h3",{dir:"auto",className:"flex-1 min-w-0 m-0 text-ui font-extrabold text-ink truncate",children:title}),count!==void 0&&count>0&&jsx("span",{"data-num":true,className:"shrink-0 text-micro font-bold text-muted2",children:new Intl.NumberFormat(locale).format(count)})]}),children,footer&&jsx("footer",{className:"border-t border-line px-3.5 py-2.5 text-caption",children:jsx(Go,{href:footerHref,className:cn("block truncate",footerHref?"font-bold text-brand hover:text-brand-hover":"text-muted"),children:jsx("span",{dir:"auto",children:footer})})})]})}function Body({children,className}){return jsx("div",{className:cn("px-3.5 pb-3.5 flex flex-col gap-3",className),children})}function Rows({children,scroll}){return jsx("ul",{className:cn("m-0 p-0 list-none border-t border-line divide-y divide-line",scroll&&"max-h-96 overflow-y-auto overscroll-contain"),children})}function Row({href,lead,title,sub,chips,end,endSub,children}){const body=jsxs(Fragment,{children:[lead,jsxs("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsx("span",{dir:"auto",className:"text-ui font-bold text-ink truncate",children:title}),sub&&jsx("span",{className:"text-micro text-muted [overflow-wrap:anywhere]",children:sub}),chips&&jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:chips}),children]}),(end!==void 0||endSub)&&jsxs("span",{className:cn("shrink-0 flex flex-col items-end gap-1 text-end max-w-1/2","@max-xs:w-full @max-xs:max-w-full @max-xs:flex-row @max-xs:items-baseline @max-xs:justify-between",lead&&"@max-xs:ps-13"),children:[end!==void 0&&jsx("span",{className:"text-ui font-extrabold text-ink",children:end}),endSub&&jsx("span",{className:"text-micro text-muted2",children:endSub})]})]});const cls="flex flex-wrap @xs:flex-nowrap items-start gap-x-3 gap-y-1.5 px-3.5 py-2.5";return jsx("li",{children:href?jsx(Go,{href,className:cn(cls,"no-underline transition-colors hover:bg-hover","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand"),children:body}):jsx("div",{className:cls,children:body})})}function Thumb({src,icon:Icon=ImageOff,size:size2="md",round}){const[broken,setBroken]=useState(false);const box=size2==="lg"?"size-20 @md:size-24":"size-10";const shape=round?"rounded-full":"rounded-sm";if(!src||broken)return jsx("span",{"aria-hidden":"true",className:cn(box,shape,"shrink-0 bg-hover text-muted2 flex items-center justify-center"),children:jsx(Icon,{size:size2==="lg"?22:16,strokeWidth:1.75})});return jsx("img",{src,alt:"",loading:"lazy",onError:()=>setBroken(true),className:cn(box,shape,"shrink-0 object-cover bg-hover")})}function Initial({name,src}){const[broken,setBroken]=useState(false);if(src&&!broken)return jsx("img",{src,alt:"",loading:"lazy",onError:()=>setBroken(true),className:"size-10 rounded-full shrink-0 object-cover bg-hover"});const letter=name?.trim().charAt(0)??"";return jsx("span",{"aria-hidden":"true",className:"size-10 rounded-full shrink-0 bg-soft text-brand-ink text-body font-extrabold flex items-center justify-center",children:letter||"\u061F"})}function IconTile({icon:Icon,tone="neutral"}){return jsx("span",{"aria-hidden":"true",className:cn("size-10 rounded-sm shrink-0 flex items-center justify-center",tone==="brand"?"bg-soft text-brand-ink":"bg-hover text-muted"),children:jsx(Icon,{size:17,strokeWidth:1.9})})}function Pill({tone="neutral",children}){if(children===void 0||children===null||children==="")return null;return jsx(Badge,{size:"sm",tone,className:"max-w-full whitespace-normal",children})}function Facts({items}){const shown=items.filter(f=>!!f&&f.value!==void 0&&f.value!==null&&f.value!=="");if(shown.length===0)return null;return jsx("dl",{className:"m-0 grid grid-cols-2 @md:grid-cols-3 gap-x-4 gap-y-2.5",children:shown.map((f,i)=>jsxs("div",{className:"min-w-0 flex flex-col gap-0.5",children:[jsx("dt",{className:"text-micro text-muted2 truncate",children:f.label}),jsx("dd",{className:"m-0 text-ui font-bold text-ink [overflow-wrap:anywhere]",children:f.value})]},i))})}function Stats({items,lead}){const shown=items.filter(s=>!!s&&s.value!==void 0&&s.value!==null);if(shown.length===0)return null;return jsx("div",{className:"grid grid-cols-1 @3xs:grid-cols-2 @lg:grid-cols-4 gap-2",children:shown.map((s,i)=>jsxs("div",{className:cn("min-w-0 rounded-field bg-bg px-3 py-2.5 flex flex-col gap-1",lead&&i===0&&"@3xs:col-span-2 @lg:col-span-1"),children:[jsx("span",{className:"text-micro text-muted truncate",children:s.label}),jsx("span",{className:cn("font-extrabold text-ink leading-none [overflow-wrap:anywhere]",lead&&i===0?"text-h3":"text-lead"),children:s.value}),s.hint&&jsx("span",{className:"text-micro",children:s.hint})]},i))})}function Delta({value}){const{locale}=useShihabText();if(value===void 0||value===null||value==="")return null;const raw=String(value).trim();const n=typeof value==="number"?value:Number(raw.replace(/[%٪+\s]/g,""));const sign=raw.startsWith("-")||raw.startsWith("\u2212")||n<0?-1:n>0?1:0;const text=typeof value==="number"?`${new Intl.NumberFormat(locale,{maximumFractionDigits:1}).format(Math.abs(value))}\u066A`:raw.replace(/^[+\-−]/,"");return jsxs("span",{"data-num":true,dir:"ltr",className:cn("font-bold",sign>0?"text-green":sign<0?"text-red":"text-muted2"),children:[sign>0?"\u25B2 ":sign<0?"\u25BC ":"",text]})}function CopyChip({value,label,mono=true}){const{t}=useShihabText();const[done,setDone]=useState(false);const timer=useRef(void 0);useEffect(()=>()=>clearTimeout(timer.current),[]);async function copy(){try{await navigator.clipboard.writeText(value);setDone(true);clearTimeout(timer.current);timer.current=setTimeout(()=>setDone(false),1600)}catch{}}return jsxs("button",{type:"button",onClick:()=>void copy(),title:done?t("copied"):t("copy"),"aria-label":`${t("copy")} ${label??value}`,className:cn("inline-flex items-center gap-1.5 max-w-full min-w-0 px-2 py-0.5 rounded-xs border border-border","text-caption font-bold text-ink2 bg-surface cursor-pointer transition-colors","hover:border-brand hover:text-brand","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:[jsx("span",{dir:"ltr",className:cn("truncate",mono&&"font-mono"),children:label??value}),done?jsx(Check,{size:12,"aria-hidden":"true",className:"shrink-0 text-green"}):jsx(Copy,{size:12,"aria-hidden":"true",className:"shrink-0 text-muted2"}),jsx("span",{className:"sr-only","aria-live":"polite",children:done?t("copied"):""})]})}function Num({value,max}){const{locale}=useShihabText();return jsx("span",{"data-num":true,children:new Intl.NumberFormat(locale,{maximumFractionDigits:max??2}).format(value)})}function Clamp({text}){const{t}=useShihabText();const[open,setOpen]=useState(false);const long=text.length>160;return jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[jsx("span",{dir:"auto",className:cn("text-caption text-ink2 whitespace-pre-line",!open&&long&&"line-clamp-3"),children:text}),long&&jsx("button",{type:"button",onClick:()=>setOpen(v=>!v),"aria-expanded":open,className:"text-micro font-bold text-brand cursor-pointer hover:text-brand-hover",children:open?t("less"):t("more")})]})}function Price({value,currency}){const{locale}=useShihabText();if(value===void 0)return null;if(currency&&!isCurrency(currency))return jsxs("span",{className:"inline-flex items-baseline gap-1 whitespace-nowrap",children:[jsx("span",{"data-num":true,children:new Intl.NumberFormat(locale,{maximumFractionDigits:2}).format(value)}),jsx("span",{className:"opacity-65",children:currency})]});return jsx(Money,{value,currency:currency&&isCurrency(currency)?currency:void 0,trimZeros:true})}function useNow(){const[now]=useState(()=>Date.now());return now}var SHIHAB_BLOCKS=["action_confirm","products","product","orders","order","order-timeline","checkout-leads","sales-summary","insights","chart","ql-result","customers","collections","coupons","offers","reviews","inventory","media","blog-posts","blog-post","blog-categories","markets","locations","menus","countries","provinces","shipping-profiles","shipping-zones","shipping-rates","carriers","plans","subscription","support-methods"];var KNOWN=new Set(SHIHAB_BLOCKS);function isShihabBlock(name){return KNOWN.has(name)}var OPEN=/^```([A-Za-z][\w-]*)?\s*$/;var ONE_LINE=/^```([A-Za-z][\w-]*)\s+(\{.*\})\s*```$/;function parseShihab(text){const lines=normalizeFences(text.replace(/\r\n/g,"\n")).split("\n");const out=[];let md=[];const flush=()=>{const joined=md.join("\n");if(joined.trim())out.push(...splitInline(joined));md=[]};for(let i=0;i<lines.length;i++){const line=lines[i].trim();const single2=ONE_LINE.exec(line);if(single2){flush();out.push(toSegment(single2[1],single2[2]));continue}const open=OPEN.exec(line);if(!open){md.push(lines[i]);continue}flush();const lang=open[1]??"";const body=[];let j=i+1;while(j<lines.length&&lines[j].trim()!=="```")body.push(lines[j++]);if(j>=lines.length){out.push(isShihabBlock(lang)||lang==="mermaid"?{kind:"pending",type:lang}:{kind:"code",lang,code:body.join("\n")});return out}out.push(toSegment(lang,body.join("\n")));i=j}flush();return out}var NAMES=[...SHIHAB_BLOCKS,"mermaid"].sort((a,b)=>b.length-a.length).map(n=>n.replace(/-/g,"\\-")).join("|");var OPEN_INLINE=new RegExp("([^\\n])(```(?:"+NAMES+")(?![\\w-]))","g");var BODY_ON_OPEN=new RegExp("^(```(?:"+NAMES+"))(?![\\w-])[ \\t]*(?=\\S)","gm");function normalizeFences(text){if(!text.includes("```"))return text;return text.replace(OPEN_INLINE,"$1\n$2").replace(BODY_ON_OPEN,"$1\n").replace(/([}\]])[ \t]*```/g,"$1\n```").replace(/^```[ \t]*(?=[^\sA-Za-z])/gm,"```\n")}function toSegment(lang,raw){if(lang==="mermaid")return{kind:"mermaid",code:raw};if(!isShihabBlock(lang))return{kind:"code",lang,code:raw};try{return{kind:"block",type:lang,data:JSON.parse(raw)}}catch{return{kind:"invalid",type:lang,raw}}}function splitInline(text){const out=[];let md=[];const flush=()=>{const joined=md.join("\n");if(joined.trim())out.push({kind:"markdown",text:joined});md=[]};for(const line of text.split("\n")){const t=line.trim();if(t.startsWith("{")&&t.endsWith("}")){let obj2;try{obj2=JSON.parse(t)}catch{obj2=void 0}if(isRecord(obj2)&&typeof obj2.tool==="string"&&typeof obj2.confirmMessage==="string"){flush();out.push({kind:"block",type:"action_confirm",data:obj2});continue}if(isRecord(obj2)&&Array.isArray(obj2.items)){flush();out.push({kind:"leak",data:obj2});continue}}md.push(line)}flush();return out}function isRecord(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function isObj(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function obj(v){return isObj(v)?v:{}}function pick(o,...keys){for(const k of keys){const v=o[k];if(v!==void 0&&v!==null&&v!=="")return v}return void 0}function str(o,...keys){const v=pick(o,...keys);if(typeof v==="string")return v.trim()||void 0;if(typeof v==="number"&&Number.isFinite(v))return String(v);return void 0}function num(o,...keys){const v=pick(o,...keys);if(typeof v==="boolean")return void 0;const n=typeof v==="number"?v:typeof v==="string"?Number(v.replace(/,/g,"")):NaN;return Number.isFinite(n)?n:void 0}function bool(o,...keys){const v=pick(o,...keys);return typeof v==="boolean"?v:void 0}function strs(o,...keys){const v=pick(o,...keys);return Array.isArray(v)?v.filter(x=>typeof x==="string"&&x.trim()!==""):[]}var LIST_KEYS=["items","products","matches","orders","leads","customers","collections","coupons","blogs","categories","menus","countries","provinces","profiles","zones","rates","carriers","events","timeline"];function list(data){const o=obj(data);for(const k of LIST_KEYS){const v=o[k];if(Array.isArray(v))return v.filter(isObj)}return[]}function single(data,marker){const o=obj(data);if(o[marker]===void 0&&Array.isArray(o.items)&&isObj(o.items[0]))return o.items[0];return o}function date(o,...keys){const s=str(o,...keys);if(!s)return void 0;const d=new Date(s);return Number.isNaN(d.getTime())?void 0:d}var UNITS=[["year",365*24*3600],["month",30*24*3600],["week",7*24*3600],["day",24*3600],["hour",3600],["minute",60]];function formatWhen(d,locale,now=Date.now()){const diff=(d.getTime()-now)/1e3;if(Math.abs(diff)<7*24*3600){const rtf=new Intl.RelativeTimeFormat(locale,{numeric:"auto"});if(Math.abs(diff)<60)return rtf.format(0,"minute");for(const[unit,sec]of UNITS){if(Math.abs(diff)>=sec)return rtf.format(Math.round(diff/sec),unit)}}return formatDate(d,locale)}function formatDate(d,locale){const sameYear=d.getFullYear()===new Date().getFullYear();return new Intl.DateTimeFormat(locale,{day:"numeric",month:"short",...sameYear?{}:{year:"numeric"}}).format(d)}import{useState as useState2}from"react";import{Banknote,Check as Check2,ClipboardCheck,Layers,Package,Percent,ShieldCheck,Trash2,TriangleAlert,Truck,X,XCircle}from"lucide-react";import{Fragment as Fragment2,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";var TEMPLATE_ICON={paid:Banknote,unpaid:Banknote,refunded:Banknote,order_confirmed:ClipboardCheck,order_cancelled:XCircle,fulfilled:Truck,delivered:Truck,returned:Truck,bulk:Layers,product_create:Package,product_edit:Package,product_delete:Trash2,offer_create:Percent};var DANGER=new Set(["product_delete","order_cancelled","refunded"]);var CANCEL_MESSAGE="\u0625\u0644\u063A\u0627\u0621";function ConfirmBlock({data}){const x=useShihabText();const{live,onSend,answer}=useShihab();const c=obj(data);const template=(str(c,"template")??"generic").toLowerCase();const message=str(c,"confirmMessage");const warning=str(c,"warning");const tool=str(c,"tool")??"";const danger=DANGER.has(template)||!!warning||/^(delete|remove|cancel)/i.test(tool);const Icon=TEMPLATE_ICON[template]??(danger?Trash2:ShieldCheck);const args=obj(c.args??c.params);const bulk=Object.values(args).find(v=>Array.isArray(v));const[local,setLocal]=useState2();const fromHistory=answer===void 0?void 0:message&&answer.trim()===message.trim()?"confirmed":"closed";const state=local??fromHistory;const canAct=live&&!!onSend&&!!message&&!state;function confirm(){if(!canAct)return;setLocal("confirmed");onSend(message)}function cancel(){if(!canAct)return;setLocal("cancelled");onSend(CANCEL_MESSAGE)}return jsxs2("section",{className:cn("@container w-full min-w-0 rounded-card border bg-surface overflow-clip",danger?"border-red-line":"border-brand"),children:[jsxs2("div",{className:"p-3.5 flex gap-3 items-start",children:[jsx2("span",{"aria-hidden":"true",className:cn("size-9 rounded-sm shrink-0 flex items-center justify-center",danger?"bg-red-bg text-red":"bg-soft text-brand-ink"),children:jsx2(Icon,{size:18,strokeWidth:2})}),jsxs2("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsx2("h3",{dir:"auto",className:"m-0 text-ui font-extrabold text-ink [overflow-wrap:anywhere]",children:str(c,"title")??x.label("blockTitle","action_confirm")}),str(c,"summary")&&jsx2("p",{dir:"auto",className:"m-0 text-caption text-ink2 leading-relaxed [overflow-wrap:anywhere]",children:str(c,"summary")}),template==="bulk"&&bulk&&jsx2("span",{children:jsx2(Pill,{tone:"brand",children:jsx2("span",{"data-num":true,children:new Intl.NumberFormat(x.locale).format(bulk.length)})})})]})]}),warning&&jsxs2("p",{role:"note",className:"m-0 mx-3.5 mb-3 flex items-start gap-2 rounded-field bg-red-bg px-3 py-2 text-caption text-red",children:[jsx2(TriangleAlert,{size:15,"aria-hidden":"true",className:"mt-0.5 shrink-0"}),jsx2("span",{dir:"auto",children:warning})]}),jsx2(Diff,{value:c.diff}),jsx2("div",{className:"border-t border-line px-3.5 py-2.5 flex items-center gap-2 flex-wrap",children:state?jsxs2("span",{role:"status",className:cn("inline-flex items-center gap-1.5 text-caption font-bold",state==="confirmed"?"text-green":"text-muted"),children:[state==="confirmed"?jsx2(Check2,{size:15,"aria-hidden":"true"}):jsx2(X,{size:15,"aria-hidden":"true"}),state==="confirmed"?x.t("confirmed"):x.t("cancelledState")]}):jsxs2(Fragment2,{children:[jsx2(Button,{size:"sm",variant:danger?"danger":"primary",onClick:confirm,disabled:!canAct,className:"flex-1 @sm:flex-none",children:x.t("confirm")}),jsx2(Button,{size:"sm",variant:"outline",onClick:cancel,disabled:!canAct,children:x.t("cancel")})]})})]})}function Diff({value}){const x=useShihabText();if(value===void 0||value===null||value==="")return null;if(typeof value==="string")return jsx2("p",{dir:"auto",className:"m-0 mx-3.5 mb-3 text-caption text-ink2",children:value});const rows=Array.isArray(value)?value.map((v,i)=>[String(i+1),v]):isObj(value)?Object.entries(value):[];if(rows.length===0)return null;return jsx2("dl",{className:"m-0 mx-3.5 mb-3 rounded-field bg-bg divide-y divide-line text-caption",children:rows.map(([k,v])=>{const pair=isObj(v)&&("from"in v||"to"in v)?v:void 0;return jsxs2("div",{className:"px-3 py-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[jsx2("dt",{className:"text-muted",children:k}),jsx2("dd",{className:"m-0 min-w-0 font-bold text-ink [overflow-wrap:anywhere]",children:pair?jsxs2(Fragment2,{children:[jsxs2("span",{className:"sr-only",children:[x.t("before"),": "]}),jsx2("span",{className:"text-muted2 line-through decoration-1",children:plain(pair.from)??"\u2014"}),jsx2("span",{"aria-hidden":"true",className:"mx-1.5 text-muted2 rtl:-scale-x-100 inline-block",children:"\u2192"}),jsxs2("span",{className:"sr-only",children:[x.t("after"),": "]}),plain(pair.to)??"\u2014"]}):plain(v)??"\u2014"})]},k)})})}function plain(v){if(v===void 0||v===null)return void 0;if(typeof v==="string"||typeof v==="number"||typeof v==="boolean")return String(v);if(isObj(v)){const s=str(v,"title","name","label");return s}return void 0}import{BarChart3,History,Lightbulb,ReceiptText,ShoppingBag,ShoppingCart,Table2,TrendingUp}from"lucide-react";var CTA=/^\s*(عرض|شوف|افتح|view|see|open|show)/i;function footerLinks(footer,href){return{footer,footerHref:footer&&href&&CTA.test(footer)?href:void 0}}import{Fragment as Fragment3,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";function OrderPills({o}){const{label,tone}=useShihabText();const one=str(o,"status");const axes=one?[one]:[str(o,"financialStatus"),str(o,"orderStatus"),str(o,"fulfillmentStatus")];const shown=[...new Set(axes.filter(s=>!!s))];return jsx3(Fragment3,{children:shown.map(s=>jsx3(Pill,{tone:tone("orderStatus",s),children:label("orderStatus",s)},s))})}function orderNumber(o){const n=str(o,"orderId","orderNumber","number");return n?`#${n.replace(/^#/,"")}`:void 0}function OrdersBlock({data}){const x=useShihabText();const items=list(data);const d=obj(data);const footer=footerLinks(str(d,"footer"),useHref("order"));return jsx3(BlockCard,{icon:ShoppingBag,title:str(d,"title")??x.label("blockTitle","orders"),count:items.length,...footer,children:jsx3(Rows,{children:items.map((o,i)=>jsx3(OrderRow,{o},str(o,"id")??i))})})}function OrderRow({o}){const x=useShihabText();const href=useHref("order",str(o,"id","_id"));const customer=str(o,"customerName")??str(obj(o.customer),"name");const count=num(o,"itemsCount");const when=date(o,"createdAt");return jsx3(Row,{href,lead:jsx3(IconTile,{icon:ReceiptText}),title:jsx3("span",{"data-num":true,children:orderNumber(o)??customer??"\u2014"}),sub:[orderNumber(o)?customer:void 0,count!==void 0?`${x.en?count:new Intl.NumberFormat(x.locale).format(count)} ${x.t("items")}`:void 0].filter(Boolean).join(" \xB7 "),chips:jsx3(OrderPills,{o}),end:jsx3(Price,{value:num(o,"total","totalPrice")}),endSub:when&&formatWhen(when,x.locale)})}function OrderBlock({data}){const x=useShihabText();const o=single(data,"orderId");const href=useHref("order",str(o,"id","_id"));const customer=obj(o.customer);const phone=str(o,"customerPhone")??str(customer,"phone");const when=date(o,"createdAt");const lines=Array.isArray(o.items)?o.items.filter(isObj):[];const ship=obj(o.shipping);const address=["street","district","city","country"].map(k=>str(ship,k)).filter(Boolean);return jsxs3(BlockCard,{icon:ShoppingBag,title:jsx3("span",{"data-num":true,children:orderNumber(o)??x.label("blockTitle","order")}),footer:href?x.t("open"):void 0,footerHref:href,children:[jsxs3(Body,{children:[jsx3("span",{className:"flex flex-wrap gap-1.5",children:jsx3(OrderPills,{o})}),jsx3(Facts,{items:[{label:x.t("total"),value:jsx3(Price,{value:num(o,"total","totalPrice")})},{label:x.t("customer"),value:str(o,"customerName")??str(customer,"name")},phone&&{label:x.t("phone"),value:jsx3(CopyChip,{value:phone})},when&&{label:x.t("date"),value:formatWhen(when,x.locale)}]})]}),lines.length>0&&jsx3(Rows,{children:lines.map((l,i)=>{const qty=num(l,"qty","quantity");return jsx3(Row,{title:str(l,"title","productTitle")??"\u2014",sub:str(l,"sku"),end:jsx3(Price,{value:num(l,"subtotal","totalPrice","price")}),endSub:qty!==void 0?jsxs3("span",{"data-num":true,children:["\xD7 ",qty]}):void 0},i)})}),address.length>0&&jsxs3("p",{className:"m-0 border-t border-line px-3.5 py-2.5 text-caption text-muted",children:[jsxs3("span",{className:"font-bold text-ink2",children:[x.t("shipTo"),": "]}),jsx3("span",{dir:"auto",children:address.join("\u060C ")})]})]})}function TimelineBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx3(BlockCard,{icon:History,title:str(d,"title")??x.label("blockTitle","order-timeline"),footer:str(d,"footer"),children:jsx3("ol",{className:"m-0 px-3.5 pb-3.5 pt-1 list-none flex flex-col",children:items.map((e,i)=>{const field=str(e,"field","axisField");const from=str(e,"from","previousValue");const to=str(e,"to","newValue");const actor=str(obj(e.actor),"name");const at=date(e,"at","createdAt");const note=str(e,"note");const last=i===items.length-1;return jsxs3("li",{className:"relative flex gap-3 pb-3 last:pb-0",children:[!last&&jsx3("span",{"aria-hidden":"true",className:"absolute top-4 bottom-0 start-1 w-px bg-line"}),jsx3("span",{"aria-hidden":"true",className:cn("relative mt-1.5 size-2.5 rounded-full shrink-0",i===0?"bg-brand":"bg-border")}),jsxs3("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsx3("span",{className:"text-ui font-bold text-ink",children:field?x.label("orderField",field):x.label("timelineType",str(e,"type"))??"\u2014"}),(from||to)&&jsxs3("span",{className:"flex flex-wrap items-center gap-1.5",children:[from&&jsx3(Pill,{tone:x.tone("orderStatus",from),children:x.label("orderStatus",from)}),from&&to&&jsx3("span",{"aria-hidden":"true",className:"text-muted2 rtl:-scale-x-100",children:"\u2192"}),to&&jsx3(Pill,{tone:x.tone("orderStatus",to),children:x.label("orderStatus",to)})]}),note&&jsx3("span",{dir:"auto",className:"text-caption text-ink2",children:note}),jsxs3("span",{className:"text-micro text-muted2",children:[x.t("by")," ",actor??x.t("system"),at&&` \xB7 ${formatWhen(at,x.locale)}`]})]})]},i)})})})}function LeadsBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("checkout"));return jsxs3(BlockCard,{icon:ShoppingCart,title:str(d,"title")??x.label("blockTitle","checkout-leads"),count:items.length,...footer,children:[Object.keys(s).length>0&&jsx3(Body,{children:jsx3(Stats,{items:[num(s,"totalLeads")!==void 0&&{label:x.t("totalLeads"),value:jsx3(Num,{value:num(s,"totalLeads")})},num(s,"totalCartValue")!==void 0&&{label:x.t("totalCartValue"),value:jsx3(Price,{value:num(s,"totalCartValue")})},num(s,"avgCartValue")!==void 0&&{label:x.t("avgCartValue"),value:jsx3(Price,{value:num(s,"avgCartValue")})},num(s,"withCOD")!==void 0&&{label:x.t("withCOD"),value:jsx3(Num,{value:num(s,"withCOD")})}]})}),jsx3(Rows,{children:items.map((l,i)=>{const name=str(l,"customerName");const phone=str(l,"phone");const status=str(l,"status");const pay=str(l,"paymentName")??x.label("paymentType",str(l,"paymentType"));const last=date(l,"lastActivityAt","createdAt");const count=num(l,"cartItemsCount");const flags=["hasAddress","hasCoupon","phoneVerified","marketingOptIn"].filter(k=>bool(l,k));return jsx3(Row,{lead:jsx3(IconTile,{icon:ShoppingCart}),title:name??jsx3("span",{dir:"ltr",children:phone??"\u2014"}),sub:last&&`${x.t("lastActivity")} ${formatWhen(last,x.locale)}`,chips:jsxs3(Fragment3,{children:[status&&jsx3(Pill,{tone:x.tone("leadStatus",status),children:x.label("leadStatus",status)}),pay&&jsx3(Pill,{children:pay}),flags.map(k=>jsx3(Pill,{tone:"brand",children:x.t(k)},k))]}),end:jsx3(Price,{value:num(l,"cartTotal")}),endSub:count!==void 0?`${new Intl.NumberFormat(x.locale).format(count)} ${x.t("items")}`:void 0,children:name&&phone&&jsx3("span",{children:jsx3(CopyChip,{value:phone})})},str(l,"id")??i)})})]})}function SalesSummaryBlock({data}){const x=useShihabText();const d=obj(data);const prev=obj(d.vsPrev);const orders=num(d,"orders");return jsx3(BlockCard,{icon:TrendingUp,title:str(d,"period","title")??x.label("blockTitle","sales-summary"),children:jsxs3(Body,{children:[jsx3(Stats,{lead:true,items:[{label:x.t("revenue"),value:jsx3(Price,{value:num(d,"total","revenue")}),hint:jsx3(Delta,{value:prev.total})},orders!==void 0&&{label:x.t("ordersCount"),value:jsx3(Num,{value:orders}),hint:jsx3(Delta,{value:prev.orders})},num(d,"avgOrderValue")!==void 0&&{label:x.t("avgOrder"),value:jsx3(Price,{value:num(d,"avgOrderValue")})}]}),(prev.total!==void 0||prev.orders!==void 0)&&jsx3("span",{className:"text-micro text-muted2",children:x.t("vsPrev")})]})})}function InsightsBlock({data}){const x=useShihabText();const d=obj(data);const scores=Array.isArray(d.scores)?d.scores.filter(isObj):[];const highlights=strs(d,"highlights");const tips=strs(d,"recommendations");return jsx3(BlockCard,{icon:BarChart3,title:str(d,"title")??x.label("blockTitle","insights"),children:jsxs3(Body,{children:[jsx3(Stats,{items:scores.map(s=>{const v=num(s,"value");return{label:str(s,"label")??"\u2014",value:v!==void 0?jsx3(Num,{value:v}):str(s,"value"),hint:jsx3(Delta,{value:pick(s,"trend")})}})}),highlights.length>0&&jsxs3("section",{className:"flex flex-col gap-1.5",children:[jsx3("h4",{className:"m-0 text-caption font-extrabold text-ink2",children:x.t("highlights")}),jsx3("ul",{className:"m-0 ps-5 list-disc marker:text-muted2 flex flex-col gap-1 text-caption text-ink2",children:highlights.map((h,i)=>jsx3("li",{dir:"auto",children:h},i))})]}),tips.length>0&&jsxs3("section",{className:"rounded-field bg-soft px-3 py-2.5 flex flex-col gap-1.5",children:[jsxs3("h4",{className:"m-0 flex items-center gap-1.5 text-caption font-extrabold text-brand-ink",children:[jsx3(Lightbulb,{size:14,"aria-hidden":"true"}),x.t("recommendations")]}),jsx3("ul",{className:"m-0 ps-5 list-disc marker:text-brand flex flex-col gap-1 text-caption text-ink2",children:tips.map((h,i)=>jsx3("li",{dir:"auto",children:h},i))})]})]})})}function ChartBlock({data}){const x=useShihabText();const d=obj(data);const raw=Array.isArray(d.x)?d.x.map(String):[];const series=(Array.isArray(d.series)?d.series.filter(isObj):[]).map(s=>({label:str(s,"name")??"",values:Array.isArray(s.data)?s.data.map(v=>typeof v==="number"?v:Number(v)||0):[]})).filter(s=>s.values.length>0);const labels=raw.map(l=>/^\d{4}-\d{2}-\d{2}/.test(l)?formatDate(new Date(l),x.locale):l);const nf=new Intl.NumberFormat(x.locale,{maximumFractionDigits:1,notation:"compact"});const fmt=v=>nf.format(v);const type=str(d,"type");return jsx3(BlockCard,{icon:BarChart3,title:str(d,"title")??x.label("blockTitle","chart"),children:jsxs3(Body,{children:[series.length===0?jsx3("span",{className:"text-caption text-muted",children:x.t("empty")}):type==="line"&&series.length===1?jsx3(TrendChart,{labels:axisLabels(labels),values:series[0].values,pointLabels:labels,formatValue:fmt,height:170}):jsx3(BarChart,{labels,series:type==="pie"?series.slice(0,1):series,formatValue:fmt,height:170}),series.length>1&&type!=="pie"&&jsx3("span",{className:"flex flex-wrap gap-3 text-micro text-muted",children:series.map((s,i)=>jsxs3("span",{className:"inline-flex items-center gap-1.5",children:[jsx3("span",{"aria-hidden":"true",className:cn("size-2 rounded-full",i===0?"bg-brand":"bg-border")}),s.label]},i))})]})})}function axisLabels(all){if(all.length<=3)return all;return[all[0],all[Math.floor(all.length/2)],all[all.length-1]]}function QlResultBlock({data}){const x=useShihabText();const d=obj(data);const cols=(Array.isArray(d.columns)?d.columns.filter(isObj):[]).map(c=>({key:str(c,"key")??"",label:str(c,"label")??str(c,"key")??"",type:str(c,"type")??"string"})).filter(c=>c.key);const rows=Array.isArray(d.rows)?d.rows.filter(isObj):[];const numeric=t=>t==="number"||t==="currency"||t==="percent";function cell(row,c){if(c.type==="string")return str(row,c.key)??"\u2014";if(c.type==="date"){const dt=date(row,c.key);return dt?formatDate(dt,x.locale):str(row,c.key)??"\u2014"}const n=num(row,c.key);if(n===void 0)return str(row,c.key)??"\u2014";if(c.type==="currency")return jsx3(Price,{value:n});if(c.type==="percent")return jsxs3("span",{"data-num":true,children:[new Intl.NumberFormat(x.locale,{maximumFractionDigits:1}).format(n),"\u066A"]});return jsx3(Num,{value:n})}return jsx3(BlockCard,{icon:Table2,title:str(d,"title")??x.label("blockTitle","ql-result"),count:rows.length,footer:str(d,"footer"),children:jsx3("div",{className:"overflow-x-auto overscroll-x-contain border-t border-line",children:jsxs3("table",{className:"w-full min-w-max border-collapse text-caption",children:[jsx3("thead",{children:jsx3("tr",{className:"bg-bg",children:cols.map(c=>jsx3("th",{scope:"col",className:cn("px-3.5 py-2 font-bold text-muted whitespace-nowrap",numeric(c.type)?"text-end":"text-start"),children:c.label},c.key))})}),jsx3("tbody",{className:"divide-y divide-line",children:rows.map((r,i)=>jsx3("tr",{children:cols.map((c,j)=>jsx3("td",{className:cn("px-3.5 py-2 whitespace-nowrap",numeric(c.type)?"text-end font-bold text-ink":"text-start text-ink2",j===0&&"font-bold text-ink"),children:cell(r,c)},c.key))},i))})]})})})}import{FileText,FolderOpen,Image as ImageIcon,Layers as Layers2,Music,Newspaper,Package as Package2,Star,Tags,Video,Warehouse}from"lucide-react";import{Fragment as Fragment4,jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";function StockPill({stock}){const x=useShihabText();if(stock===void 0)return null;if(stock<=0)return jsx4(Pill,{tone:"red",children:x.t("outOfStock")});return jsxs4(Pill,{children:[jsx4(Num,{value:stock})," ",x.t("inStock")]})}function ProductsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("product"));return jsx4(BlockCard,{icon:Package2,title:str(d,"title")??x.label("blockTitle","products"),count:items.length,...footer,children:jsx4(Rows,{children:items.map((p,i)=>jsx4(ProductRow,{p},str(p,"id")??i))})})}function ProductRow({p}){const x=useShihabText();const status=str(p,"status");return jsx4(Row,{href:useHref("product",str(p,"id","_id")),lead:jsx4(Thumb,{src:str(p,"image","imageUrl"),icon:Package2}),title:str(p,"title")??"\u2014",chips:jsxs4(Fragment4,{children:[status&&jsx4(Pill,{tone:x.tone("productStatus",status),children:x.label("productStatus",status)}),jsx4(StockPill,{stock:num(p,"stock","quantity")})]}),end:jsx4(Price,{value:num(p,"price")})})}function ProductBlock({data}){const x=useShihabText();const p=single(data,"title");const href=useHref("product",str(p,"id","_id"));const status=str(p,"status");const sold=num(p,"soldLast30d");const variants=Array.isArray(p.variants)?p.variants.filter(isObj):[];const tags=strs(p,"tags");return jsxs4(BlockCard,{footer:href?x.t("open"):void 0,footerHref:href,children:[jsxs4(Body,{className:"pt-3.5",children:[jsxs4("div",{className:"flex gap-3.5 items-start",children:[jsx4(Thumb,{src:str(p,"image","imageUrl"),icon:Package2,size:"lg"}),jsxs4("div",{className:"flex-1 min-w-0 flex flex-col gap-1.5",children:[jsx4("h3",{dir:"auto",className:"m-0 text-body font-extrabold text-ink [overflow-wrap:anywhere]",children:str(p,"title")??x.label("blockTitle","product")}),jsxs4("span",{className:"flex flex-wrap gap-1.5",children:[status&&jsx4(Pill,{tone:x.tone("productStatus",status),children:x.label("productStatus",status)}),jsx4(StockPill,{stock:num(p,"stock","quantity")})]}),num(p,"price")!==void 0&&jsx4("span",{className:"text-lead font-extrabold text-ink",children:jsx4(Price,{value:num(p,"price")})})]})]}),jsx4(Facts,{items:[str(p,"sku")&&{label:"SKU",value:jsx4("span",{className:"font-mono",dir:"ltr",children:str(p,"sku")})},sold!==void 0&&{label:x.t("sold30"),value:jsx4(Num,{value:sold})}]}),tags.length>0&&jsx4("span",{className:"flex flex-wrap gap-1.5",children:tags.map(t=>jsx4(Pill,{children:t},t))})]}),variants.length>0&&jsx4(Rows,{children:variants.slice(0,8).map((v,i)=>jsx4(Row,{title:str(v,"title")??str(v,"sku")??"\u2014",sub:str(v,"sku"),chips:jsx4(StockPill,{stock:num(v,"quantity","stock")}),end:jsx4(Price,{value:num(v,"price")})},str(v,"qid","id")??i))})]})}function CollectionsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("collection"));return jsx4(BlockCard,{icon:Layers2,title:str(d,"title")??x.label("blockTitle","collections"),count:items.length,...footer,children:jsx4(Rows,{children:items.map((c,i)=>jsx4(CollectionRow,{c},str(c,"id","qid")??i))})})}function CollectionRow({c}){const x=useShihabText();const status=str(c,"status");const count=num(c,"productCount");return jsx4(Row,{href:useHref("collection",str(c,"id","_id")),lead:jsx4(Thumb,{src:str(c,"imageUrl","image"),icon:Layers2}),title:str(c,"title")??"\u2014",sub:str(c,"handle")&&jsxs4("span",{dir:"ltr",children:["/",str(c,"handle")]}),chips:jsxs4(Fragment4,{children:[status&&jsx4(Pill,{tone:x.tone("collectionStatus",status),children:x.label("collectionStatus",status)}),str(c,"operation")&&jsx4(Pill,{children:x.label("operation",str(c,"operation"))})]}),end:count!==void 0?jsx4(Num,{value:count}):void 0,endSub:count!==void 0?x.t("products"):void 0})}function InventoryBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx4(BlockCard,{icon:Warehouse,title:str(d,"title")??x.label("blockTitle","inventory"),count:items.length,footer:str(d,"footer"),children:jsx4(Rows,{children:items.map((r,i)=>jsx4(InventoryRow,{r},str(r,"id")??i))})})}function InventoryRow({r}){const x=useShihabText();const p=obj(r.product);const v=obj(r.variant);const available=num(r,"available");const opts=strs(v,"options").join(" \xB7 ");const minor=["onHand","committed","incoming","unavailable"].map(k=>[k,num(r,k)]).filter(([,n])=>n!==void 0&&n!==0);return jsx4(Row,{href:useHref("product",str(p,"id")),lead:jsx4(Thumb,{src:str(v,"image")??str(p,"image"),icon:Package2}),title:str(p,"title")??str(v,"sku")??"\u2014",sub:[opts,str(v,"sku")].filter(Boolean).join(" \xB7 ")||void 0,end:available!==void 0?jsx4("span",{className:cn(available<=0?"text-red":available<=5?"text-amber-ink":"text-ink"),children:jsx4(Num,{value:available})}):void 0,endSub:available!==void 0?x.t("available"):void 0,children:minor.length>0&&jsx4("span",{className:"text-micro text-muted2",children:minor.map(([k,n],i)=>jsxs4("span",{children:[i>0&&" \xB7 ",x.t(k)," ",jsx4(Num,{value:n})]},k))})})}function ReviewsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const summary=Object.entries(obj(d.summary)).filter(([,v])=>typeof v==="number"||typeof v==="string");const footer=footerLinks(str(d,"footer"),useHref("review"));return jsxs4(BlockCard,{icon:Star,title:str(d,"title")??x.label("blockTitle","reviews"),count:items.length,...footer,children:[summary.length>0&&jsx4(Body,{children:jsx4(Stats,{items:summary.slice(0,4).map(([k,v])=>({label:k,value:typeof v==="number"?jsx4(Num,{value:v}):String(v)}))})}),jsx4(Rows,{children:items.map((r,i)=>jsx4(ReviewRow,{r},str(r,"id","qid")??i))})]})}function ReviewRow({r}){const x=useShihabText();const status=str(r,"status");const product=obj(r.product);const rating=num(r,"rating");const at=date(r,"createdAt");const productHref=useHref("product",str(product,"id"));const comment=str(r,"comment");return jsx4(Row,{lead:jsx4(Initial,{name:str(r,"customerName")}),title:str(r,"customerName")??"\u2014",sub:str(product,"title")&&jsxs4(Fragment4,{children:[x.t("on"),":"," ",jsx4(Go,{href:productHref,className:cn(productHref&&"font-bold text-brand hover:text-brand-hover"),children:str(product,"title")})]}),chips:jsxs4(Fragment4,{children:[rating!==void 0&&jsx4(Stars,{value:rating,size:12}),status&&jsx4(Pill,{tone:x.tone("reviewStatus",status),children:x.label("reviewStatus",status)})]}),endSub:at&&formatWhen(at,x.locale),children:comment&&jsx4(Clamp,{text:comment})})}var KIND_ICON={image:ImageIcon,video:Video,audio:Music,pdf:FileText,file:FileText,other:FolderOpen};function size(mb,kb,locale){const nf=new Intl.NumberFormat(locale,{maximumFractionDigits:1});if(mb!==void 0&&mb>=1)return`${nf.format(mb)} MB`;if(kb!==void 0)return`${nf.format(kb)} KB`;if(mb!==void 0)return`${nf.format(mb*1024)} KB`;return void 0}function MediaBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("media"));const total=num(s,"totalItems");const shown=num(s,"pageSizeMB");return jsxs4(BlockCard,{icon:ImageIcon,title:str(d,"title")??x.label("blockTitle","media"),count:items.length,...footer,children:[(total!==void 0||shown!==void 0)&&jsx4(Body,{children:jsx4(Stats,{items:[total!==void 0&&{label:x.label("blockTitle","media"),value:jsx4(Num,{value:total})},shown!==void 0&&{label:x.t("shownSize"),value:jsx4("span",{"data-num":true,children:size(shown,void 0,x.locale)})}]})}),jsx4(Rows,{children:items.map((m,i)=>jsx4(MediaRow,{m},str(m,"id","qid")??i))})]})}function MediaRow({m}){const x=useShihabText();const kind=(str(m,"kind")??"other").toLowerCase();const raw=str(m,"url");const url=raw&&/^https:/i.test(raw)?raw:void 0;const name=str(m,"title")??str(m,"file")??"\u2014";const full=size(num(m,"sizeMB"),num(m,"sizeKB"),x.locale);const packed=size(num(m,"compressedSizeMB"),num(m,"compressedSizeKB"),x.locale);return jsx4(Row,{lead:kind==="image"&&url?jsx4("a",{href:url,target:"_blank",rel:"noopener noreferrer","aria-label":name,className:"shrink-0",children:jsx4(Thumb,{src:url,icon:ImageIcon})}):jsx4(IconTile,{icon:KIND_ICON[kind]??FolderOpen}),title:jsx4("span",{dir:"auto",children:name}),sub:[x.label("mediaKind",kind),full,packed&&`${x.t("afterCompression")} ${packed}`].filter(Boolean).join(" \xB7 "),children:url&&jsx4("span",{children:jsx4(CopyChip,{value:url,label:x.t("copyLink"),mono:false})})})}function BlogMeta({b}){const x=useShihabText();const at=date(b,"publishedAt","createdAt");const views=num(b,"views");return jsx4(Fragment4,{children:[at&&formatDate(at,x.locale),views?`${new Intl.NumberFormat(x.locale).format(views)} ${x.t("views")}`:void 0].filter(Boolean).join(" \xB7 ")})}function category(b){return str(b,"category")??str(obj(b.category),"title")}function BlogPostsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("blog"));return jsx4(BlockCard,{icon:Newspaper,title:str(d,"title")??x.label("blockTitle","blog-posts"),count:items.length,...footer,children:jsx4(Rows,{children:items.map((b,i)=>jsx4(BlogRow,{b},str(b,"qid","id")??i))})})}function BlogRow({b}){const x=useShihabText();const status=str(b,"status");const excerpt=str(b,"excerpt","description");return jsx4(Row,{href:useHref("blog",str(b,"qid","id")),lead:jsx4(Thumb,{src:str(b,"image","imageUrl"),icon:Newspaper}),title:str(b,"title")??"\u2014",sub:jsx4(BlogMeta,{b}),chips:jsxs4(Fragment4,{children:[status&&jsx4(Pill,{tone:x.tone("blogStatus",status),children:x.label("blogStatus",status)}),category(b)&&jsx4(Pill,{children:category(b)})]}),children:excerpt&&jsx4("span",{dir:"auto",className:"text-caption text-ink2 line-clamp-2",children:excerpt})})}function BlogPostBlock({data}){const x=useShihabText();const b=single(data,"title");const href=useHref("blog",str(b,"qid","id"));const image=str(b,"image","imageUrl");const status=str(b,"status");const tags=strs(b,"tags");const excerpt=str(b,"excerpt","description");return jsxs4(BlockCard,{footer:href?x.t("open"):void 0,footerHref:href,children:[image&&jsx4(Cover,{src:image}),jsxs4(Body,{className:"pt-3.5",children:[jsx4("h3",{dir:"auto",className:"m-0 text-body font-extrabold text-ink [overflow-wrap:anywhere]",children:str(b,"title")??x.label("blockTitle","blog-post")}),excerpt&&jsx4("p",{dir:"auto",className:"m-0 text-caption text-ink2 leading-relaxed",children:excerpt}),jsxs4("span",{className:"flex flex-wrap items-center gap-1.5",children:[status&&jsx4(Pill,{tone:x.tone("blogStatus",status),children:x.label("blogStatus",status)}),category(b)&&jsx4(Pill,{tone:"brand",children:category(b)}),tags.map(t=>jsxs4(Pill,{children:["#",t]},t))]}),jsx4("span",{className:"text-micro text-muted2",children:jsx4(BlogMeta,{b})})]})]})}function Cover({src}){return jsx4("img",{src,alt:"",loading:"lazy",onError:e=>{e.currentTarget.hidden=true},className:"block w-full aspect-video object-cover bg-hover"})}function BlogCategoriesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx4(BlockCard,{icon:Tags,title:str(d,"title")??x.label("blockTitle","blog-categories"),count:items.length,footer:str(d,"footer"),children:jsx4(Rows,{children:items.map((c,i)=>jsx4(Row,{lead:jsx4(Thumb,{src:str(c,"imageUrl"),icon:Tags}),title:str(c,"title")??"\u2014",sub:str(c,"description")??(str(c,"handle")&&jsxs4("span",{dir:"ltr",children:["/",str(c,"handle")]}))},str(c,"qid","id")??i))})})}import{Flag,Globe2,ListTree,Map,MapPin,Menu,Package as Package3,Percent as Percent2,Ticket,Truck as Truck2,Users}from"lucide-react";import{Fragment as Fragment5,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function CustomersBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("customer"));return jsx5(BlockCard,{icon:Users,title:str(d,"title")??x.label("blockTitle","customers"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((c,i)=>jsx5(CustomerRow,{c},str(c,"id","qid")??i))})})}function CustomerRow({c}){const x=useShihabText();const name=str(c,"name");const phone=str(c,"phone");const orders=num(c,"orderCount");const seen=date(c,"lastSeen");return jsx5(Row,{href:useHref("customer",str(c,"id","_id")),lead:jsx5(Initial,{name:name??phone,src:str(c,"avatarUrl")}),title:name??jsx5("span",{dir:"ltr",children:phone??"\u2014"}),sub:[name&&phone,str(c,"email")].filter(Boolean).join(" \xB7 ")||void 0,chips:jsxs5(Fragment5,{children:[bool(c,"verified")&&jsx5(Pill,{tone:"green",children:x.t("verified")}),bool(c,"blocked")&&jsx5(Pill,{tone:"red",children:x.t("blocked")})]}),end:orders!==void 0?jsx5(Num,{value:orders}):void 0,endSub:orders!==void 0?x.t("ordersUnit"):seen&&`${x.t("lastSeen")} ${formatWhen(seen,x.locale)}`})}function Discount({o}){const x=useShihabText();const type=str(o,"offerType");if(type==="free_shipping")return jsx5(Fragment5,{children:x.label("offerType",type)});const pct=num(o,"discountPercentage")??(type==="percentage_discount"?num(o,"amount"):void 0);if(pct!==void 0)return jsxs5("span",{"data-num":true,children:[new Intl.NumberFormat(x.locale).format(pct),"\u066A"]});const amount=num(o,"discountAmount")??(type==="fixed_discount"?num(o,"amount"):void 0);return amount!==void 0?jsx5(Price,{value:amount}):null}function OfferState({o}){const x=useShihabText();const live=bool(o,"isLive");const active=bool(o,"active");const start=date(o,"startDate");const end=date(o,"endDate");const now=useNow();if(live)return jsx5(Pill,{tone:"green",children:x.t("live")});if(end&&end.getTime()<now)return jsx5(Pill,{tone:"neutral",children:x.t("ended")});if(start&&start.getTime()>now)return jsx5(Pill,{tone:"amber",children:x.t("notStarted")});if(active===false)return jsx5(Pill,{tone:"neutral",children:x.t("paused")});if(active)return jsx5(Pill,{tone:"green",children:x.t("active")});return null}function OfferRows({items,icon}){const x=useShihabText();return jsx5(Rows,{children:items.map((o,i)=>{const code=str(o,"code");const days=num(o,"daysLeft");const start=date(o,"startDate");const end=date(o,"endDate");const min=num(o,"minPurchase");const max=num(o,"maxDiscount");const range=[start&&formatDate(start,x.locale),end&&formatDate(end,x.locale)].filter(Boolean).join(" \u2190 ");return jsx5(Row,{lead:jsx5(IconTile,{icon,tone:"brand"}),title:str(o,"title")??code??"\u2014",sub:str(o,"summary")??x.label("appliedOn",str(o,"appliedOn")),chips:jsxs5(Fragment5,{children:[jsx5(OfferState,{o}),str(o,"method")&&jsx5(Pill,{children:x.label("offerMethod",str(o,"method"))}),code&&jsx5(CopyChip,{value:code})]}),end:jsx5(Discount,{o}),endSub:days!==void 0&&days>0?`${new Intl.NumberFormat(x.locale).format(days)} ${x.t("daysLeft")}`:range||void 0,children:(min!==void 0||max!==void 0)&&jsxs5("span",{className:"text-micro text-muted2",children:[min!==void 0&&jsxs5(Fragment5,{children:[x.t("minPurchase")," ",jsx5(Price,{value:min})]}),min!==void 0&&max!==void 0&&" \xB7 ",max!==void 0&&jsxs5(Fragment5,{children:[x.t("maxDiscount")," ",jsx5(Price,{value:max})]})]})},str(o,"id","qid")??i)})})}function OffersBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("offer"));const live=num(s,"liveNow");const total=num(s,"totalOffers");return jsxs5(BlockCard,{icon:Percent2,title:str(d,"title")??x.label("blockTitle","offers"),count:items.length,...footer,children:[(live!==void 0||total!==void 0)&&jsx5(Body,{children:jsx5(Stats,{items:[live!==void 0&&{label:x.t("liveNow"),value:jsx5(Num,{value:live})},total!==void 0&&{label:x.t("totalOffers"),value:jsx5(Num,{value:total})}]})}),jsx5(OfferRows,{items,icon:Percent2})]})}function CouponsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("coupon"));return jsx5(BlockCard,{icon:Ticket,title:str(d,"title")??x.label("blockTitle","coupons"),count:items.length,...footer,children:jsx5(OfferRows,{items,icon:Ticket})})}function MarketsBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);return jsxs5(BlockCard,{icon:Globe2,title:str(d,"title")??x.label("blockTitle","markets"),count:items.length,footer:str(d,"footer"),children:[Object.keys(s).length>0&&jsx5(Body,{children:jsx5(Stats,{items:[num(s,"totalMarkets")!==void 0&&{label:x.label("blockTitle","markets"),value:jsx5(Num,{value:num(s,"totalMarkets")})},num(s,"activeCount")!==void 0&&{label:x.label("marketStatus","active"),value:jsx5(Num,{value:num(s,"activeCount")})},num(s,"draftCount")!==void 0&&{label:x.label("marketStatus","draft"),value:jsx5(Num,{value:num(s,"draftCount")})},str(s,"defaultMarket")&&{label:x.t("isDefault"),value:str(s,"defaultMarket")}]})}),jsx5(Rows,{children:items.map((m,i)=>{const status=str(m,"status");const cur=str(m,"targetCurrencyCode");const rate=num(m,"exchangeRate");const count=num(m,"countriesCount");const codes=strs(m,"countryCodes");return jsx5(Row,{lead:jsx5(IconTile,{icon:Globe2}),title:str(m,"title")??"\u2014",sub:[cur&&rate!==void 0?`1 = ${new Intl.NumberFormat(x.locale,{maximumFractionDigits:4}).format(rate)} ${cur}`:cur,count!==void 0?`${new Intl.NumberFormat(x.locale).format(count)} ${x.t("countriesUnit")}`:void 0].filter(Boolean).join(" \xB7 "),chips:jsxs5(Fragment5,{children:[bool(m,"isDefault")&&jsx5(Pill,{tone:"brand",children:x.t("isDefault")}),status&&jsx5(Pill,{tone:x.tone("marketStatus",status),children:x.label("marketStatus",status)}),str(m,"fxMode")&&jsx5(Pill,{children:x.label("fxMode",str(m,"fxMode"))}),bool(m,"enableRounding")&&jsx5(Pill,{children:x.t("rounding")}),bool(m,"localCurrencies")&&jsx5(Pill,{children:x.t("localCurrencies")})]}),children:codes.length>0&&jsx5("span",{dir:"ltr",className:"flex flex-wrap gap-1 justify-end rtl:justify-end",children:codes.slice(0,12).map(c=>jsx5("span",{className:"px-1.5 rounded-xs bg-hover text-micro font-bold text-muted font-mono",children:c},c))})},str(m,"id","qid")??i)})})]})}function LocationsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("location"));return jsx5(BlockCard,{icon:MapPin,title:str(d,"title")??x.label("blockTitle","locations"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((l,i)=>{const status=str(l,"status");const flags=[["fulfillsOnlineOrders","fulfillsOnline"],["shipsInventory","shipsInventory"],["hasActiveInventory","hasInventory"]].filter(([k])=>bool(l,k));return jsx5(Row,{lead:jsx5(IconTile,{icon:MapPin}),title:str(l,"name")??"\u2014",sub:[str(l,"address1"),str(l,"city"),str(l,"country")].filter(Boolean).join("\u060C ")||void 0,chips:jsxs5(Fragment5,{children:[bool(l,"isPrimary")&&jsx5(Pill,{tone:"brand",children:x.t("isDefault")}),status&&jsx5(Pill,{tone:x.tone("locationStatus",status),children:x.label("locationStatus",status)}),flags.map(([k,t])=>jsx5(Pill,{children:x.t(t)},k))]}),children:str(l,"phone")&&jsx5("span",{children:jsx5(CopyChip,{value:str(l,"phone")})})},str(l,"id","qid")??i)})})})}function MenusBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("menu"));return jsx5(BlockCard,{icon:Menu,title:str(d,"title")??x.label("blockTitle","menus"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((m,i)=>{const n=num(m,"itemsCount");return jsx5(Row,{lead:jsx5(IconTile,{icon:ListTree}),title:str(m,"title")??"\u2014",sub:str(m,"handle")&&jsxs5("span",{dir:"ltr",children:["/",str(m,"handle")]}),end:n!==void 0?jsx5(Num,{value:n}):void 0,endSub:n!==void 0?x.t("links"):void 0},str(m,"id","qid")??i)})})})}function CodeTile({code}){if(!code)return jsx5(IconTile,{icon:Flag});return jsx5("span",{"aria-hidden":"true",dir:"ltr",className:"size-10 rounded-sm shrink-0 bg-hover text-caption font-extrabold text-muted font-mono flex items-center justify-center",children:code.slice(0,3)})}function CountriesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Flag,title:str(d,"title")??x.label("blockTitle","countries"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{scroll:true,children:items.map((c,i)=>{const cur=obj(c.currency);const active=bool(c,"active");return jsx5(Row,{lead:jsx5(CodeTile,{code:str(c,"code")}),title:str(c,"name","title")??"\u2014",sub:[str(c,"capital"),str(c,"continent"),str(c,"phonekey")&&`\u2066${str(c,"phonekey")}\u2069`].filter(Boolean).join(" \xB7 ")||void 0,chips:active===false?jsx5(Pill,{children:x.t("inactive")}):void 0,end:str(cur,"symbol")??str(cur,"code"),endSub:str(cur,"title")},str(c,"id","code")??i)})})})}function ProvincesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Map,title:str(d,"title")??x.label("blockTitle","provinces"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{scroll:true,children:items.map((p,i)=>jsx5(Row,{title:str(p,"name")??"\u2014",sub:str(p,"nameEn")&&jsx5("span",{dir:"ltr",children:str(p,"nameEn")}),end:str(p,"code")&&jsx5("span",{className:"font-mono text-muted",dir:"ltr",children:str(p,"code")})},str(p,"qid","code")??i))})})}function ShippingProfilesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("shipping"));return jsx5(BlockCard,{icon:Package3,title:str(d,"title")??x.label("blockTitle","shipping-profiles"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((p,i)=>{const products=num(p,"productCount");const groups=num(p,"groupCount");return jsx5(Row,{lead:jsx5(IconTile,{icon:Package3}),title:str(p,"name")??"\u2014",sub:[products!==void 0&&`${new Intl.NumberFormat(x.locale).format(products)} ${x.t("products")}`,groups!==void 0&&`${new Intl.NumberFormat(x.locale).format(groups)} ${x.t("groups")}`].filter(Boolean).join(" \xB7 "),chips:bool(p,"isDefault")?jsx5(Pill,{tone:"brand",children:x.t("isDefault")}):void 0},str(p,"qid")??i)})})})}function ShippingZonesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Globe2,title:str(d,"title")??x.label("blockTitle","shipping-zones"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{children:items.map((z,i)=>jsx5(Row,{lead:jsx5(IconTile,{icon:Globe2}),title:str(z,"name")??"\u2014",chips:str(z,"zoneType")?jsx5(Pill,{children:x.label("zoneType",str(z,"zoneType"))}):void 0},str(z,"qid")??i))})})}function loose(v){if(v===void 0||v===null||v==="")return void 0;if(isObj(v))return Object.entries(v).filter(([,val])=>val!==null&&val!==void 0&&typeof val!=="object").map(([k,val])=>`${k}: ${String(val)}`).join(" \xB7 ");if(typeof v==="object")return void 0;return String(v)}function ShippingRatesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Truck2,title:str(d,"title")??x.label("blockTitle","shipping-rates"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{children:items.map((r,i)=>{const minor=num(r,"priceMinor");const price=minor!==void 0?minor/100:num(r,"price");const free=r.freeOverride;const cond=loose(r.conditions);return jsx5(Row,{lead:jsx5(IconTile,{icon:Truck2}),title:str(r,"name")??"\u2014",sub:str(r,"transit"),chips:str(r,"source")?jsx5(Pill,{children:x.label("rateSource",str(r,"source"))}):void 0,end:price===0?x.label("offerType","free_shipping"):jsx5(Price,{value:price,currency:str(r,"currency")}),children:free!==void 0&&free!==null||cond?jsxs5("span",{className:"text-micro text-muted2",children:[typeof free==="number"?jsxs5(Fragment5,{children:[x.t("freeOver")," ",jsx5(Price,{value:free,currency:str(r,"currency")})]}):loose(free),cond&&` \xB7 ${cond}`]}):null},str(r,"qid")??i)})})})}function CarriersBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Truck2,title:str(d,"title")??x.label("blockTitle","carriers"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{children:items.map((c,i)=>{const tested=date(c,"lastTestedAt");const status=str(c,"lastTestStatus");return jsx5(Row,{lead:jsx5(IconTile,{icon:Truck2}),title:str(c,"name")??"\u2014",sub:tested&&`${x.t("lastTest")}: ${formatDate(tested,x.locale)}`,chips:jsxs5(Fragment5,{children:[bool(c,"active")!==void 0&&(bool(c,"active")?jsx5(Pill,{tone:"green",children:x.t("active")}):jsx5(Pill,{children:x.t("inactive")})),bool(c,"supportsServiceDiscovery")&&jsx5(Pill,{children:x.t("autoRates")}),bool(c,"hasApiKey")&&jsx5(Pill,{children:x.t("keySaved")}),status&&jsx5(Pill,{tone:x.tone("testStatus",status),children:x.label("testStatus",status)})]})},str(c,"qid")??i)})})})}import{useState as useState3}from"react";import{Check as Check3,CreditCard,Headset,Mail,MessageCircle,Phone,Sparkles}from"lucide-react";import{Fragment as Fragment6,jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";function PlansBlock({data}){const x=useShihabText();const{live,onSend}=useShihab();const d=obj(data);const items=list(data);const hasYearly=items.some(p=>num(obj(p.price),"yearly")!==void 0);const[period,setPeriod]=useState3("monthly");const[sent,setSent]=useState3();function subscribe(p){const title=str(p,"title")??str(p,"key")??"";setSent(str(p,"id")??title);onSend?.(`\u0627\u0634\u062A\u0631\u0643 \u0641\u064A \u0628\u0627\u0642\u0629 ${title} ${period==="yearly"?"\u0633\u0646\u0648\u064A":"\u0634\u0647\u0631\u064A"}`)}return jsx6(BlockCard,{icon:CreditCard,title:str(d,"title")??x.label("blockTitle","plans"),footer:str(d,"footer"),children:jsxs6(Body,{children:[hasYearly&&jsx6("div",{role:"radiogroup","aria-label":x.label("blockTitle","plans"),className:"self-start flex p-0.5 rounded-field bg-hover",children:["monthly","yearly"].map(p=>jsx6("button",{type:"button",role:"radio","aria-checked":period===p,onClick:()=>setPeriod(p),className:cn("px-3 py-1 rounded-sm text-caption font-bold cursor-pointer transition-colors",period===p?"bg-surface text-ink shadow-raise":"text-muted hover:text-ink"),children:x.t(p)},p))}),jsx6("div",{className:"grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 gap-2.5",children:items.map((p,i)=>{const price=obj(p.price);const amount=num(price,period)??num(price,"monthly");const shownPeriod=num(price,period)!==void 0?period:"monthly";const popular=bool(p,"popular");const paid=bool(p,"isPaid");const canBuy=bool(p,"subscribable")&&live&&!!onSend&&!sent;const limits=obj(p.limits);const features=strs(p,"features").slice(0,8);const id=str(p,"id")??str(p,"title");return jsxs6("article",{className:cn("min-w-0 rounded-card border p-3.5 flex flex-col gap-2.5",popular?"border-brand bg-soft":"border-line bg-surface"),children:[jsxs6("header",{className:"flex items-start justify-between gap-2",children:[jsxs6("span",{className:"min-w-0 flex flex-col gap-0.5",children:[jsx6("h4",{className:"m-0 text-body font-extrabold text-ink",children:str(p,"title")??str(p,"key")}),str(p,"tagline")&&jsx6("span",{className:"text-micro text-muted",children:str(p,"tagline")})]}),popular&&jsxs6(Pill,{tone:"brand",children:[jsx6(Sparkles,{size:11,"aria-hidden":"true"}),x.t("popular")]})]}),jsx6("span",{className:"flex items-baseline gap-1.5 text-h3 font-extrabold text-ink",children:paid===false||amount===0?x.t("free"):jsxs6(Fragment6,{children:[jsx6(Price,{value:amount,currency:str(price,"currency")}),jsxs6("span",{className:"text-caption font-bold text-muted",children:["/ ",x.t(shownPeriod==="yearly"?"perYear":"perMonth")]})]})}),features.length>0&&jsx6("ul",{className:"m-0 p-0 list-none flex flex-col gap-1.5 text-caption text-ink2",children:features.map((f,j)=>jsxs6("li",{className:"flex items-start gap-1.5",children:[jsx6(Check3,{size:14,"aria-hidden":"true",className:"mt-0.5 shrink-0 text-green"}),jsx6("span",{dir:"auto",children:f})]},j))}),Object.keys(limits).length>0&&jsx6(Facts,{items:[["products","productsLimit"],["storage","storage"],["staffAccounts","staff"]].filter(([k])=>k in limits).map(([k,t])=>({label:x.t(t),value:limits[k]===null?x.t("unlimited"):str(limits,k)??x.t("unlimited")}))}),bool(p,"subscribable")&&onSend&&jsx6(Button,{size:"sm",variant:popular?"primary":"outline",disabled:!canBuy,onClick:()=>subscribe(p),className:"mt-auto",children:x.t("subscribe")})]},id??i)})})]})})}function SubscriptionBlock({data}){const x=useShihabText();const s=obj(data);const status=str(s,"status")??(bool(s,"expired")?"expired":bool(s,"paymentPending")?"pending":"active");const renews=date(s,"renewsAt","endDate");const rawInterval=str(s,"interval","period");const interval=rawInterval==="monthly"?x.t("perMonth"):rawInterval==="yearly"?x.t("perYear"):rawInterval;const price=num(s,"price");const up=obj(s.pendingUpgrade);const upStart=date(up,"startDate");const features=strs(s,"promotedFeatures");return jsx6(BlockCard,{icon:CreditCard,title:str(s,"plan","planTitle")??x.label("blockTitle","subscription"),children:jsxs6(Body,{children:[jsx6("span",{className:"flex flex-wrap gap-1.5",children:jsx6(Pill,{tone:x.tone("subscriptionStatus",status),children:x.label("subscriptionStatus",status)})}),jsx6(Facts,{items:[price!==void 0&&{label:x.label("blockTitle","plans"),value:jsxs6("span",{className:"inline-flex items-baseline gap-1",children:[jsx6(Price,{value:price}),interval&&jsxs6("span",{className:"text-caption text-muted",children:["/ ",interval]})]})},renews&&{label:x.t("renews"),value:formatDate(renews,x.locale)}]}),str(up,"planTitle")&&jsxs6("p",{className:"m-0 rounded-field bg-soft px-3 py-2 text-caption text-brand-ink",children:[x.t("upgradeTo"),str(up,"planTitle"),upStart&&` \xB7 ${x.t("startsOn")} ${formatDate(upStart,x.locale)}`]}),features.length>0&&jsx6("span",{className:"flex flex-wrap gap-1.5",children:features.map(f=>jsx6(Pill,{children:f},f))})]})})}var SUPPORT_ICON={whatsapp:MessageCircle,phone:Phone,email:Mail,chat:Headset};function SupportBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data).filter(m=>isSafeUrl(str(m,"actionUrl")));return jsx6(BlockCard,{icon:Headset,title:str(d,"title")??x.label("blockTitle","support-methods"),children:jsxs6(Body,{children:[jsx6("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-2",children:items.map((m,i)=>{const type=(str(m,"type")??"chat").toLowerCase();const Icon=SUPPORT_ICON[type]??Headset;const url=str(m,"actionUrl");const external=/^https?:/i.test(url);return jsxs6("a",{href:url,...external?{target:"_blank",rel:"noopener noreferrer"}:{},className:cn("min-w-0 flex items-center gap-3 p-3 rounded-card border border-line bg-surface no-underline","transition-colors hover:border-brand hover:bg-soft","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:[jsx6("span",{"aria-hidden":"true",className:cn("size-10 rounded-full shrink-0 flex items-center justify-center",type==="whatsapp"?"bg-green-bg2 text-green":"bg-soft text-brand-ink"),children:jsx6(Icon,{size:18,strokeWidth:2})}),jsxs6("span",{className:"min-w-0 flex flex-col gap-0.5",children:[jsx6("span",{className:"text-ui font-bold text-ink truncate",children:str(m,"label")??x.label("supportType",type)}),str(m,"value")&&jsx6("span",{dir:"ltr",className:"text-micro text-muted truncate text-start",children:str(m,"value")})]})]},i)})}),str(d,"footer")&&jsx6("p",{className:"m-0 text-caption font-bold text-ink2",children:str(d,"footer")})]})})}function isSafeUrl(u){return!!u&&/^(https:|tel:|mailto:)/i.test(u)}import{Fragment as Fragment7,jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";var RENDERERS={action_confirm:ConfirmBlock,orders:OrdersBlock,order:OrderBlock,"order-timeline":TimelineBlock,"checkout-leads":LeadsBlock,"sales-summary":SalesSummaryBlock,insights:InsightsBlock,chart:ChartBlock,"ql-result":QlResultBlock,products:ProductsBlock,product:ProductBlock,collections:CollectionsBlock,inventory:InventoryBlock,reviews:ReviewsBlock,media:MediaBlock,"blog-posts":BlogPostsBlock,"blog-post":BlogPostBlock,"blog-categories":BlogCategoriesBlock,customers:CustomersBlock,offers:OffersBlock,coupons:CouponsBlock,markets:MarketsBlock,locations:LocationsBlock,menus:MenusBlock,countries:CountriesBlock,provinces:ProvincesBlock,"shipping-profiles":ShippingProfilesBlock,"shipping-zones":ShippingZonesBlock,"shipping-rates":ShippingRatesBlock,carriers:CarriersBlock,plans:PlansBlock,subscription:SubscriptionBlock,"support-methods":SupportBlock};var SINGLE=new Set(["action_confirm","order","product","sales-summary","insights","chart","ql-result","blog-post","subscription"]);function ShihabReply({text,onSend,hrefFor,linkAs,live=false,answer,renderMermaid,onInvalid,className}){const segments=useMemo(()=>parseShihab(text),[text]);const ctx=useMemo(()=>({onSend,hrefFor,Link:linkAs,live,answer,renderMermaid}),[onSend,hrefFor,linkAs,live,answer,renderMermaid]);useEffect2(()=>{if(!onInvalid)return;for(const s of segments){if(s.kind==="invalid")onInvalid(s.type,s.raw);if(s.kind==="leak")onInvalid("leak",JSON.stringify(s.data))}},[segments,onInvalid]);return jsx7(ShihabContext.Provider,{value:ctx,children:jsx7("div",{className:cn("min-w-0 flex flex-col gap-2.5 text-ui text-ink leading-relaxed",className),children:segments.map((s,i)=>jsx7(Segment,{s},i))})})}function Segment({s}){const x=useShihabText();const ctx=useShihab();switch(s.kind){case"markdown":return jsx7("div",{dir:"auto",className:"min-w-0 [overflow-wrap:anywhere]",children:jsx7(Markdown,{md:s.text})});case"block":{if(!SINGLE.has(s.type)&&list(s.data).length===0){const title=str(obj(s.data),"title");return jsxs7("p",{className:"m-0 text-caption text-muted",children:[title?`${title} \u2014 `:"",x.t("empty")]})}const Block=RENDERERS[s.type];return jsx7(Block,{data:s.data})}case"leak":return jsx7(LeakBlock,{data:s.data});case"pending":return jsx7(PendingBlock,{type:s.type});case"mermaid":return ctx.renderMermaid?jsx7(Fragment7,{children:ctx.renderMermaid(s.code)}):jsx7(Code,{code:s.code});case"code":return jsx7(Code,{code:s.code});case"invalid":return jsxs7("p",{role:"note",className:"m-0 flex items-center gap-2 rounded-field bg-hover px-3 py-2 text-caption text-muted",children:[jsx7(TriangleAlert2,{size:14,"aria-hidden":"true",className:"shrink-0"}),x.t("invalid")]})}}function PendingBlock({type}){const x=useShihabText();return jsx7(BlockCard,{title:x.label("blockTitle",type)??x.t("preparing"),children:jsxs7("div",{"aria-busy":"true",className:"px-3.5 pb-3.5 flex flex-col gap-3",children:[jsx7("span",{className:"sr-only",children:x.t("preparing")}),[0,1,2].map(i=>jsxs7("span",{className:"flex items-center gap-3",children:[jsx7(Skeleton,{variant:"circle",className:"size-10 rounded-sm"}),jsxs7("span",{className:"flex-1 flex flex-col gap-1.5",children:[jsx7(Skeleton,{width:i===1?"55%":"70%"}),jsx7(Skeleton,{width:"35%",className:"h-2.5"})]})]},i))]})})}function LeakBlock({data}){const items=list(data);return jsx7(BlockCard,{icon:List,title:str(obj(data),"title"),count:items.length,footer:str(obj(data),"footer"),children:jsx7(Rows,{children:items.map((it,i)=>jsx7(Row,{title:str(it,"title","name","label","customerName","orderId","phone")??"\u2014",sub:str(it,"summary","description","status")},i))})})}function Code({code}){return jsx7("pre",{dir:"ltr",className:"m-0 max-w-full overflow-x-auto rounded-field bg-code-bg px-3 py-2.5 text-caption font-mono text-code-plain text-start",children:jsx7("code",{children:code})})}export{SHIHAB_BLOCKS,ShihabReply,isShihabBlock,parseShihab};
|
|
2
|
+
import{Markdown}from"./chunk-A2AXNC3M.js";import{BarChart,Money,TrendChart,isCurrency}from"./chunk-NHKZAYI6.js";import{Button}from"./chunk-NHZYT3B4.js";import{Badge,Skeleton}from"./chunk-JOHJNMV2.js";import{cn,useMoneyLang,useMoneyLocale}from"./chunk-YJ45RGS6.js";import{useEffect as useEffect2,useMemo}from"react";import{UiAlert as UiAlert2,ViewList as ViewList2}from"qumra-icons";import{createContext,useContext}from"react";var ShihabContext=createContext({live:false});function useShihab(){return useContext(ShihabContext)}var ORDER_STATUS={pending:["\u0642\u064A\u062F \u0627\u0644\u0627\u0646\u062A\u0638\u0627\u0631","Pending","neutral"],confirmed:["\u0645\u0624\u0643\u064E\u0651\u062F","Confirmed","brand"],paid:["\u0645\u062F\u0641\u0648\u0639","Paid","green"],unpaid:["\u063A\u064A\u0631 \u0645\u062F\u0641\u0648\u0639","Unpaid","amber"],fulfilled:["\u062A\u0645 \u0627\u0644\u062A\u062C\u0647\u064A\u0632","Fulfilled","brand"],unfulfilled:["\u0644\u0645 \u064A\u064F\u062C\u0647\u064E\u0651\u0632","Unfulfilled","neutral"],delivered:["\u062A\u0645 \u0627\u0644\u062A\u0648\u0635\u064A\u0644","Delivered","green"],returned:["\u0645\u0631\u062A\u062C\u0639","Returned","amber"],refunded:["\u0645\u0633\u062A\u0631\u064E\u062F","Refunded","amber"],cancelled:["\u0645\u0644\u063A\u064A","Cancelled","red"],canceled:["\u0645\u0644\u063A\u064A","Cancelled","red"]};var DICTS={orderStatus:ORDER_STATUS,orderField:{financialstatus:["\u062D\u0627\u0644\u0629 \u0627\u0644\u062F\u0641\u0639","Payment"],orderstatus:["\u062D\u0627\u0644\u0629 \u0627\u0644\u0637\u0644\u0628","Order"],fulfillmentstatus:["\u062D\u0627\u0644\u0629 \u0627\u0644\u062A\u062C\u0647\u064A\u0632","Fulfillment"]},timelineType:{status_change:["\u062A\u063A\u064A\u064A\u0631 \u062D\u0627\u0644\u0629","Status change"],note:["\u0645\u0644\u0627\u062D\u0638\u0629","Note"]},productStatus:{active:["\u0646\u0634\u0637","Active","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"],archived:["\u0645\u0624\u0631\u0634\u0641","Archived","neutral"]},blogStatus:{active:["\u0645\u0646\u0634\u0648\u0631\u0629","Published","green"],published:["\u0645\u0646\u0634\u0648\u0631\u0629","Published","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"],scheduled:["\u0645\u062C\u062F\u0648\u0644\u0629","Scheduled","brand"]},leadStatus:{draft:["\u0628\u064A\u0627\u0646\u0627\u062A \u0646\u0627\u0642\u0635\u0629","Incomplete","neutral"],abandoned:["\u0645\u0641\u0642\u0648\u062F","Lost","amber"]},paymentType:{cod:["\u0627\u0644\u062F\u0641\u0639 \u0639\u0646\u062F \u0627\u0644\u0627\u0633\u062A\u0644\u0627\u0645","Cash on delivery"],manual:["\u062F\u0641\u0639 \u064A\u062F\u0648\u064A","Manual payment"],gateway:["\u062F\u0641\u0639 \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A","Online payment"]},offerMethod:{discount_code:["\u0643\u0648\u062F \u062E\u0635\u0645","Discount code"],automatic:["\u062A\u0644\u0642\u0627\u0626\u064A","Automatic"]},offerType:{buy_get:["\u0627\u0634\u062A\u0631\u0650 \u0648\u0627\u062D\u0635\u0644","Buy X get Y"],fixed_discount:["\u062E\u0635\u0645 \u0645\u0628\u0644\u063A","Fixed discount"],percentage_discount:["\u062E\u0635\u0645 \u0646\u0633\u0628\u0629","Percentage discount"],free_shipping:["\u0634\u062D\u0646 \u0645\u062C\u0627\u0646\u064A","Free shipping"]},allowTo:{all:["\u0644\u0643\u0644 \u0627\u0644\u0639\u0645\u0644\u0627\u0621","All customers"],specific:["\u0644\u0639\u0645\u0644\u0627\u0621 \u0645\u062D\u062F\u0651\u062F\u064A\u0646","Specific customers"]},appliedOn:{all_products:["\u0643\u0644 \u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A","All products"],selected_products:["\u0645\u0646\u062A\u062C\u0627\u062A \u0645\u062D\u062F\u0651\u062F\u0629","Selected products"],selected_collections:["\u0645\u062C\u0645\u0648\u0639\u0627\u062A \u0645\u062D\u062F\u0651\u062F\u0629","Selected collections"],selected_payment_methods:["\u0648\u0633\u0627\u0626\u0644 \u062F\u0641\u0639 \u0645\u062D\u062F\u0651\u062F\u0629","Selected payment methods"]},marketStatus:{active:["\u0646\u0634\u0637","Active","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"]},fxMode:{dynamic:["\u0633\u0639\u0631 \u0635\u0631\u0641 \u062A\u0644\u0642\u0627\u0626\u064A","Automatic rate"],manual:["\u0633\u0639\u0631 \u0635\u0631\u0641 \u064A\u062F\u0648\u064A","Manual rate"]},mediaKind:{image:["\u0635\u0648\u0631\u0629","Image"],video:["\u0641\u064A\u062F\u064A\u0648","Video"],audio:["\u0635\u0648\u062A","Audio"],pdf:["PDF","PDF"],file:["\u0645\u0644\u0641","File"],other:["\u0623\u062E\u0631\u0649","Other"]},collectionStatus:{active:["\u0646\u0634\u0637\u0629","Active","green"],draft:["\u0645\u0633\u0648\u062F\u0629","Draft","neutral"]},operation:{manual:["\u064A\u062F\u0648\u064A\u0629","Manual"],automated:["\u062A\u0644\u0642\u0627\u0626\u064A\u0629","Automated"]},reviewStatus:{pending:["\u0628\u0627\u0646\u062A\u0638\u0627\u0631 \u0627\u0644\u0645\u0631\u0627\u062C\u0639\u0629","Pending","amber"],approved:["\u0645\u0639\u062A\u0645\u062F","Approved","green"],rejected:["\u0645\u0631\u0641\u0648\u0636","Rejected","red"]},locationStatus:{active:["\u0646\u0634\u0637","Active","green"],inactive:["\u0645\u062A\u0648\u0642\u0651\u0641","Inactive","neutral"]},rateSource:{flat:["\u0633\u0639\u0631 \u062B\u0627\u0628\u062A","Flat rate"],carrier:["\u0645\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646","Carrier rate"]},zoneType:{countries:["\u062F\u0648\u0644","Countries"],regions:["\u0645\u0646\u0627\u0637\u0642","Regions"]},supportType:{whatsapp:["\u0648\u0627\u062A\u0633\u0627\u0628","WhatsApp"],phone:["\u0627\u062A\u0635\u0627\u0644","Call"],email:["\u0625\u064A\u0645\u064A\u0644","Email"],chat:["\u0645\u062D\u0627\u062F\u062B\u0629","Chat"]},subscriptionStatus:{active:["\u0641\u0639\u0651\u0627\u0644","Active","green"],expired:["\u0645\u0646\u062A\u0647\u064A","Expired","red"],pending:["\u0628\u0627\u0646\u062A\u0638\u0627\u0631 \u0627\u0644\u062F\u0641\u0639","Payment pending","amber"],cancelled:["\u0645\u0644\u063A\u064A","Cancelled","red"]},blockTitle:{orders:["\u0627\u0644\u0637\u0644\u0628\u0627\u062A","Orders"],order:["\u0627\u0644\u0637\u0644\u0628","Order"],"order-timeline":["\u0633\u062C\u0644 \u0627\u0644\u0637\u0644\u0628","Order history"],"checkout-leads":["\u0627\u0644\u0637\u0644\u0628\u0627\u062A \u0627\u0644\u0645\u0641\u0642\u0648\u062F\u0629","Lost orders"],"sales-summary":["\u0645\u0644\u062E\u0651\u0635 \u0627\u0644\u0645\u0628\u064A\u0639\u0627\u062A","Sales summary"],insights:["\u062A\u062D\u0644\u064A\u0644\u0627\u062A","Insights"],chart:["\u0631\u0633\u0645 \u0628\u064A\u0627\u0646\u064A","Chart"],"ql-result":["\u0627\u0644\u0646\u062A\u064A\u062C\u0629","Result"],products:["\u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A","Products"],product:["\u0627\u0644\u0645\u0646\u062A\u062C","Product"],collections:["\u0627\u0644\u0645\u062C\u0645\u0648\u0639\u0627\u062A","Collections"],inventory:["\u0627\u0644\u0645\u062E\u0632\u0648\u0646","Inventory"],reviews:["\u0627\u0644\u062A\u0642\u064A\u064A\u0645\u0627\u062A","Reviews"],media:["\u0627\u0644\u0648\u0633\u0627\u0626\u0637","Media"],customers:["\u0627\u0644\u0639\u0645\u0644\u0627\u0621","Customers"],offers:["\u0627\u0644\u0639\u0631\u0648\u0636","Offers"],coupons:["\u0627\u0644\u0643\u0648\u0628\u0648\u0646\u0627\u062A","Coupons"],"blog-posts":["\u0627\u0644\u0645\u0642\u0627\u0644\u0627\u062A","Blog posts"],"blog-post":["\u0627\u0644\u0645\u0642\u0627\u0644\u0629","Blog post"],"blog-categories":["\u062A\u0635\u0646\u064A\u0641\u0627\u062A \u0627\u0644\u0645\u062F\u0648\u0646\u0629","Blog categories"],markets:["\u0627\u0644\u0623\u0633\u0648\u0627\u0642","Markets"],locations:["\u0627\u0644\u0641\u0631\u0648\u0639","Locations"],menus:["\u0627\u0644\u0642\u0648\u0627\u0626\u0645","Menus"],countries:["\u0627\u0644\u062F\u0648\u0644","Countries"],provinces:["\u0627\u0644\u0645\u062D\u0627\u0641\u0638\u0627\u062A","Provinces"],"shipping-profiles":["\u0645\u0644\u0641\u0627\u062A \u0627\u0644\u0634\u062D\u0646","Shipping profiles"],"shipping-zones":["\u0645\u0646\u0627\u0637\u0642 \u0627\u0644\u0634\u062D\u0646","Shipping zones"],"shipping-rates":["\u0623\u0633\u0639\u0627\u0631 \u0627\u0644\u0634\u062D\u0646","Shipping rates"],carriers:["\u0634\u0631\u0643\u0627\u062A \u0627\u0644\u0634\u062D\u0646","Carriers"],plans:["\u0627\u0644\u0628\u0627\u0642\u0627\u062A","Plans"],subscription:["\u0627\u0634\u062A\u0631\u0627\u0643\u0643","Your subscription"],"support-methods":["\u062A\u0648\u0627\u0635\u0644 \u0645\u0639 \u0627\u0644\u062F\u0639\u0645","Contact support"],action_confirm:["\u062A\u0623\u0643\u064A\u062F","Confirm"],mermaid:["\u0645\u062E\u0637\u0651\u0637","Diagram"]},testStatus:{success:["\u0646\u062C\u062D","Passed","green"],failed:["\u0641\u0634\u0644","Failed","red"],failure:["\u0641\u0634\u0644","Failed","red"]}};var TEXT={viewAll:["\u0639\u0631\u0636 \u0627\u0644\u0643\u0644","View all"],empty:["\u0645\u0641\u064A\u0634 \u0646\u062A\u0627\u0626\u062C","Nothing to show"],invalid:["\u062A\u0639\u0630\u0651\u0631 \u0639\u0631\u0636 \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A","Couldn't display this data"],preparing:["\u0628\u064A\u062C\u0647\u0651\u0632 \u0627\u0644\u0628\u064A\u0627\u0646\u0627\u062A\u2026","Preparing data\u2026"],copy:["\u0646\u0633\u062E","Copy"],copied:["\u0627\u062A\u0646\u0633\u062E","Copied"],open:["\u0641\u062A\u062D","Open"],more:["\u0627\u0644\u0645\u0632\u064A\u062F","More"],less:["\u0623\u0642\u0644","Less"],isDefault:["\u0627\u0644\u0627\u0641\u062A\u0631\u0627\u0636\u064A","Default"],active:["\u0645\u0641\u0639\u0651\u0644","Active"],inactive:["\u0645\u062A\u0648\u0642\u0651\u0641","Inactive"],unlimited:["\u063A\u064A\u0631 \u0645\u062D\u062F\u0648\u062F","Unlimited"],system:["\u0627\u0644\u0646\u0638\u0627\u0645","System"],by:["\u0628\u0648\u0627\u0633\u0637\u0629","by"],confirm:["\u062A\u0623\u0643\u064A\u062F","Confirm"],cancel:["\u0625\u0644\u063A\u0627\u0621","Cancel"],confirmed:["\u0627\u062A\u0623\u0643\u0651\u062F","Confirmed"],cancelledState:["\u0627\u062A\u0644\u063A\u0649","Cancelled"],before:["\u0642\u0628\u0644","Before"],after:["\u0628\u0639\u062F","After"],items:["\u0645\u0646\u062A\u062C\u0627\u062A","items"],total:["\u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A","Total"],customer:["\u0627\u0644\u0639\u0645\u064A\u0644","Customer"],phone:["\u0627\u0644\u0631\u0642\u0645","Phone"],date:["\u0627\u0644\u062A\u0627\u0631\u064A\u062E","Date"],shipTo:["\u0627\u0644\u062A\u0648\u0635\u064A\u0644 \u0625\u0644\u0649","Ship to"],totalLeads:["\u0627\u0644\u0637\u0644\u0628\u0627\u062A \u0627\u0644\u0645\u0641\u0642\u0648\u062F\u0629","Lost orders"],totalCartValue:["\u0642\u064A\u0645\u0629 \u0627\u0644\u0633\u0644\u0627\u0644","Cart value"],avgCartValue:["\u0645\u062A\u0648\u0633\u0651\u0637 \u0627\u0644\u0633\u0644\u0629","Average cart"],withEmail:["\u0628\u0625\u064A\u0645\u064A\u0644","With email"],withAddress:["\u0628\u0639\u0646\u0648\u0627\u0646","With address"],withCOD:["\u062F\u0641\u0639 \u0639\u0646\u062F \u0627\u0644\u0627\u0633\u062A\u0644\u0627\u0645","Cash on delivery"],marketingOptIn:["\u0645\u0648\u0627\u0641\u0642 \u0639\u0644\u0649 \u0627\u0644\u062A\u0633\u0648\u064A\u0642","Marketing opt-in"],hasAddress:["\u0639\u0646\u062F\u0647 \u0639\u0646\u0648\u0627\u0646","Has address"],hasCoupon:["\u0641\u064A\u0647 \u0643\u0648\u0628\u0648\u0646","Has coupon"],phoneVerified:["\u0627\u0644\u0631\u0642\u0645 \u0645\u062A\u0623\u0643\u0651\u062F","Phone verified"],lastActivity:["\u0622\u062E\u0631 \u0646\u0634\u0627\u0637","Last activity"],noPayment:["\u0644\u0645 \u064A\u062E\u062A\u0631","Not chosen"],revenue:["\u0627\u0644\u0625\u064A\u0631\u0627\u062F\u0627\u062A","Revenue"],ordersCount:["\u0627\u0644\u0637\u0644\u0628\u0627\u062A","Orders"],avgOrder:["\u0645\u062A\u0648\u0633\u0651\u0637 \u0627\u0644\u0637\u0644\u0628","Average order"],vsPrev:["\u0639\u0646 \u0627\u0644\u0641\u062A\u0631\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629","vs previous period"],highlights:["\u0623\u0647\u0645 \u0627\u0644\u0645\u0644\u0627\u062D\u0638\u0627\u062A","Highlights"],recommendations:["\u0627\u0642\u062A\u0631\u0627\u062D\u0627\u062A","Recommendations"],outOfStock:["\u0646\u0641\u062F","Out of stock"],inStock:["\u0641\u064A \u0627\u0644\u0645\u062E\u0632\u0648\u0646","in stock"],sold30:["\u0627\u062A\u0628\u0627\u0639 \u0641\u064A \u0622\u062E\u0631 \u0663\u0660 \u064A\u0648\u0645","sold in the last 30 days"],products:["\u0645\u0646\u062A\u062C","products"],onHand:["\u0627\u0644\u0641\u0639\u0644\u064A","On hand"],available:["\u0627\u0644\u0645\u062A\u0627\u062D","Available"],committed:["\u0645\u062D\u062C\u0648\u0632","Committed"],incoming:["\u0648\u0627\u0631\u062F","Incoming"],unavailable:["\u063A\u064A\u0631 \u0645\u062A\u0627\u062D","Unavailable"],on:["\u0639\u0644\u0649","on"],views:["\u0645\u0634\u0627\u0647\u062F\u0629","views"],afterCompression:["\u0628\u0639\u062F \u0627\u0644\u0636\u063A\u0637","compressed"],shownSize:["\u062D\u062C\u0645 \u0627\u0644\u0645\u0639\u0631\u0648\u0636","Size shown"],copyLink:["\u0646\u0633\u062E \u0627\u0644\u0631\u0627\u0628\u0637","Copy link"],verified:["\u0645\u0648\u062B\u0651\u0642","Verified"],blocked:["\u0645\u062D\u0638\u0648\u0631","Blocked"],ordersUnit:["\u0637\u0644\u0628\u0627\u062A","orders"],lastSeen:["\u0622\u062E\u0631 \u0638\u0647\u0648\u0631","Last seen"],live:["\u0634\u063A\u0651\u0627\u0644","Live"],ended:["\u0627\u0646\u062A\u0647\u0649","Ended"],notStarted:["\u0644\u0633\u0647 \u0645\u0627\u0628\u062F\u0623\u0634","Not started"],paused:["\u0645\u062A\u0648\u0642\u0651\u0641","Paused"],daysLeft:["\u064A\u0648\u0645 \u0645\u062A\u0628\u0642\u0651\u064A","days left"],minPurchase:["\u062D\u062F\u0651 \u0623\u062F\u0646\u0649","Minimum"],maxDiscount:["\u0623\u0642\u0635\u0649 \u062E\u0635\u0645","Max discount"],liveNow:["\u0634\u063A\u0651\u0627\u0644 \u062F\u0644\u0648\u0642\u062A\u064A","Live now"],totalOffers:["\u0643\u0644 \u0627\u0644\u0639\u0631\u0648\u0636","All offers"],countriesUnit:["\u062F\u0648\u0644","countries"],rounding:["\u062A\u0642\u0631\u064A\u0628 \u0627\u0644\u0623\u0633\u0639\u0627\u0631","Price rounding"],localCurrencies:["\u0639\u0645\u0644\u0627\u062A \u0645\u062D\u0644\u0651\u064A\u0629","Local currencies"],fulfillsOnline:["\u0628\u064A\u062C\u0647\u0651\u0632 \u0637\u0644\u0628\u0627\u062A \u0627\u0644\u0623\u0648\u0646\u0644\u0627\u064A\u0646","Fulfills online orders"],shipsInventory:["\u0628\u064A\u0634\u062D\u0646 \u0645\u062E\u0632\u0648\u0646","Ships inventory"],hasInventory:["\u0641\u064A\u0647 \u0645\u062E\u0632\u0648\u0646 \u0646\u0634\u0637","Has active inventory"],links:["\u0631\u0648\u0627\u0628\u0637","links"],groups:["\u0645\u062C\u0645\u0648\u0639\u0627\u062A \u0645\u0648\u0627\u0642\u0639","location groups"],freeOver:["\u0645\u062C\u0627\u0646\u064A \u0641\u0648\u0642","Free over"],autoRates:["\u0628\u062A\u062C\u064A\u0628 \u0623\u0633\u0639\u0627\u0631 \u062A\u0644\u0642\u0627\u0626\u064A\u0627\u064B","Live rates"],keySaved:["\u0627\u0644\u0645\u0641\u062A\u0627\u062D \u0645\u062D\u0641\u0648\u0638","API key saved"],lastTest:["\u0622\u062E\u0631 \u0627\u062E\u062A\u0628\u0627\u0631","Last test"],available_country:["\u0645\u062A\u0627\u062D\u0629","Enabled"],monthly:["\u0634\u0647\u0631\u064A","Monthly"],yearly:["\u0633\u0646\u0648\u064A","Yearly"],perMonth:["\u0634\u0647\u0631","month"],perYear:["\u0633\u0646\u0629","year"],popular:["\u0627\u0644\u0623\u0643\u062B\u0631 \u0637\u0644\u0628\u0627\u064B","Most popular"],free:["\u0645\u062C\u0627\u0646\u064A\u0629","Free"],subscribe:["\u0627\u0634\u062A\u0631\u0643","Subscribe"],renews:["\u0628\u064A\u062A\u062C\u062F\u0651\u062F","Renews"],upgradeTo:["\u062A\u0631\u0642\u064A\u0629 \u0644\u0640","Upgrade to"],startsOn:["\u0628\u062A\u0628\u062F\u0623","starts"],productsLimit:["\u0627\u0644\u0645\u0646\u062A\u062C\u0627\u062A","Products"],storage:["\u0627\u0644\u0645\u0633\u0627\u062D\u0629","Storage"],staff:["\u062D\u0633\u0627\u0628\u0627\u062A \u0627\u0644\u0645\u0648\u0638\u0641\u064A\u0646","Staff accounts"]};function useShihabText(){const en=useMoneyLang();const locale=useMoneyLocale();const i=en?1:0;const entry=(dict,value)=>typeof value==="string"?DICTS[dict][value.toLowerCase()]:void 0;return{t:key=>TEXT[key][i],label:(dict,value)=>{if(typeof value!=="string"||!value.trim())return void 0;return entry(dict,value)?.[i]??value},tone:(dict,value)=>entry(dict,value)?.[2]??"neutral",locale,en}}import{useEffect,useRef,useState}from"react";import{UiCheck,UiCopy,UiImageOff,UiTrendDown,UiTrendUp}from"qumra-icons";import{Fragment,jsx,jsxs}from"react/jsx-runtime";function BrandIcon({icon:Icon,size:size2}){return jsx(Icon,{size:size2,"aria-hidden":"true",injectStyles:false,className:"shrink-0"})}function useHref(entity,id){const{hrefFor}=useShihab();return hrefFor?.(entity,id)}function Go({href,className,children}){const{Link}=useShihab();if(!href)return jsx("span",{className,children});if(Link)return jsx(Link,{href,className,children});return jsx("a",{href,className,children})}function BlockCard({icon:Icon,title,count,children,footer,footerHref,className}){const{locale}=useShihabText();const head=Icon||title;return jsxs("section",{className:cn("@container w-full min-w-0 bg-surface border border-line rounded-card overflow-clip",className),children:[head&&jsxs("header",{className:"flex items-center gap-2 px-3.5 pt-3 pb-2",children:[Icon&&jsx(BrandIcon,{icon:Icon,size:26}),title&&jsx("h3",{dir:"auto",className:"flex-1 min-w-0 m-0 text-ui font-extrabold text-ink truncate",children:title}),count!==void 0&&count>0&&jsx("span",{"data-num":true,className:"shrink-0 text-micro font-bold text-muted2",children:new Intl.NumberFormat(locale).format(count)})]}),children,footer&&jsx("footer",{className:"border-t border-line px-3.5 py-2.5 text-caption",children:jsx(Go,{href:footerHref,className:cn("block truncate",footerHref?"font-bold text-brand hover:text-brand-hover":"text-muted"),children:jsx("span",{dir:"auto",children:footer})})})]})}function Body({children,className}){return jsx("div",{className:cn("px-3.5 pb-3.5 flex flex-col gap-3",className),children})}function Rows({children,scroll}){return jsx("ul",{className:cn("m-0 p-0 list-none border-t border-line divide-y divide-line",scroll&&"max-h-96 overflow-y-auto overscroll-contain"),children})}function Row({href,lead,title,sub,chips,end,endSub,children}){const body=jsxs(Fragment,{children:[lead,jsxs("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsx("span",{dir:"auto",className:"text-ui font-bold text-ink truncate",children:title}),sub&&jsx("span",{className:"text-micro text-muted [overflow-wrap:anywhere]",children:sub}),chips&&jsx("span",{className:"flex flex-wrap items-center gap-1.5",children:chips}),children]}),(end!==void 0||endSub)&&jsxs("span",{className:cn("shrink-0 flex flex-col items-end gap-1 text-end max-w-1/2","@max-xs:w-full @max-xs:max-w-full @max-xs:flex-row @max-xs:items-baseline @max-xs:justify-between",lead&&"@max-xs:ps-13"),children:[end!==void 0&&jsx("span",{className:"text-ui font-extrabold text-ink",children:end}),endSub&&jsx("span",{className:"text-micro text-muted2",children:endSub})]})]});const cls="flex flex-wrap @xs:flex-nowrap items-start gap-x-3 gap-y-1.5 px-3.5 py-2.5";return jsx("li",{children:href?jsx(Go,{href,className:cn(cls,"no-underline transition-colors hover:bg-hover","focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand"),children:body}):jsx("div",{className:cls,children:body})})}function Thumb({src,icon:Icon=UiImageOff,size:size2="md",round}){const[broken,setBroken]=useState(false);const box=size2==="lg"?"size-20 @md:size-24":"size-10";const shape=round?"rounded-full":"rounded-sm";if(!src||broken)return jsx("span",{"aria-hidden":"true",className:cn(box,shape,"shrink-0 bg-hover text-muted2 flex items-center justify-center"),children:jsx(Icon,{size:size2==="lg"?22:16,injectStyles:false})});return jsx("img",{src,alt:"",loading:"lazy",onError:()=>setBroken(true),className:cn(box,shape,"shrink-0 object-cover bg-hover")})}function Initial({name,src}){const[broken,setBroken]=useState(false);if(src&&!broken)return jsx("img",{src,alt:"",loading:"lazy",onError:()=>setBroken(true),className:"size-10 rounded-full shrink-0 object-cover bg-hover"});const letter=name?.trim().charAt(0)??"";return jsx("span",{"aria-hidden":"true",className:"size-10 rounded-full shrink-0 bg-soft text-brand-ink text-body font-extrabold flex items-center justify-center",children:letter||"\u061F"})}function IconTile({icon}){return jsx("span",{"aria-hidden":"true",className:"size-10 shrink-0 flex items-center justify-center",children:jsx(BrandIcon,{icon,size:34})})}function Pill({tone="neutral",children}){if(children===void 0||children===null||children==="")return null;return jsx(Badge,{size:"sm",tone,className:"max-w-full whitespace-normal",children})}function Facts({items}){const shown=items.filter(f=>!!f&&f.value!==void 0&&f.value!==null&&f.value!=="");if(shown.length===0)return null;return jsx("dl",{className:"m-0 grid grid-cols-2 @md:grid-cols-3 gap-x-4 gap-y-2.5",children:shown.map((f,i)=>jsxs("div",{className:"min-w-0 flex flex-col gap-0.5",children:[jsx("dt",{className:"text-micro text-muted2 truncate",children:f.label}),jsx("dd",{className:"m-0 text-ui font-bold text-ink [overflow-wrap:anywhere]",children:f.value})]},i))})}function Stats({items,lead}){const shown=items.filter(s=>!!s&&s.value!==void 0&&s.value!==null);if(shown.length===0)return null;return jsx("div",{className:"grid grid-cols-1 @3xs:grid-cols-2 @lg:grid-cols-4 gap-2",children:shown.map((s,i)=>jsxs("div",{className:cn("min-w-0 rounded-field bg-bg px-3 py-2.5 flex flex-col gap-1",lead&&i===0&&"@3xs:col-span-2 @lg:col-span-1"),children:[jsx("span",{className:"text-micro text-muted truncate",children:s.label}),jsx("span",{className:cn("font-extrabold text-ink leading-none [overflow-wrap:anywhere]",lead&&i===0?"text-h3":"text-lead"),children:s.value}),s.hint&&jsx("span",{className:"text-micro",children:s.hint})]},i))})}function Delta({value}){const{locale}=useShihabText();if(value===void 0||value===null||value==="")return null;const raw=String(value).trim();const n=typeof value==="number"?value:Number(raw.replace(/[%٪+\s]/g,""));const sign=raw.startsWith("-")||raw.startsWith("\u2212")||n<0?-1:n>0?1:0;const text=typeof value==="number"?`${new Intl.NumberFormat(locale,{maximumFractionDigits:1}).format(Math.abs(value))}\u066A`:raw.replace(/^[+\-−]/,"");return jsxs("span",{"data-num":true,dir:"ltr",className:cn("font-bold",sign>0?"text-green":sign<0?"text-red":"text-muted2"),children:[sign!==0&&jsx("span",{className:"inline-flex align-middle me-0.5",children:sign>0?jsx(UiTrendUp,{size:13,"aria-hidden":"true",injectStyles:false}):jsx(UiTrendDown,{size:13,"aria-hidden":"true",injectStyles:false})}),text]})}function CopyChip({value,label,mono=true}){const{t}=useShihabText();const[done,setDone]=useState(false);const timer=useRef(void 0);useEffect(()=>()=>clearTimeout(timer.current),[]);async function copy(){try{await navigator.clipboard.writeText(value);setDone(true);clearTimeout(timer.current);timer.current=setTimeout(()=>setDone(false),1600)}catch{}}return jsxs("button",{type:"button",onClick:()=>void copy(),title:done?t("copied"):t("copy"),"aria-label":`${t("copy")} ${label??value}`,className:cn("inline-flex items-center gap-1.5 max-w-full min-w-0 px-2 py-0.5 rounded-xs border border-border","text-caption font-bold text-ink2 bg-surface cursor-pointer transition-colors","hover:border-brand hover:text-brand","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:[jsx("span",{dir:"ltr",className:cn("truncate",mono&&"font-mono"),children:label??value}),done?jsx(UiCheck,{size:13,"aria-hidden":"true",injectStyles:false,className:"shrink-0 text-green"}):jsx(UiCopy,{size:13,"aria-hidden":"true",injectStyles:false,className:"shrink-0 text-muted2"}),jsx("span",{className:"sr-only","aria-live":"polite",children:done?t("copied"):""})]})}function Num({value,max}){const{locale}=useShihabText();return jsx("span",{"data-num":true,children:new Intl.NumberFormat(locale,{maximumFractionDigits:max??2}).format(value)})}function Clamp({text}){const{t}=useShihabText();const[open,setOpen]=useState(false);const long=text.length>160;return jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[jsx("span",{dir:"auto",className:cn("text-caption text-ink2 whitespace-pre-line",!open&&long&&"line-clamp-3"),children:text}),long&&jsx("button",{type:"button",onClick:()=>setOpen(v=>!v),"aria-expanded":open,className:"text-micro font-bold text-brand cursor-pointer hover:text-brand-hover",children:open?t("less"):t("more")})]})}function Price({value,currency}){const{locale}=useShihabText();if(value===void 0)return null;if(currency&&!isCurrency(currency))return jsxs("span",{className:"inline-flex items-baseline gap-1 whitespace-nowrap",children:[jsx("span",{"data-num":true,children:new Intl.NumberFormat(locale,{maximumFractionDigits:2}).format(value)}),jsx("span",{className:"opacity-65",children:currency})]});return jsx(Money,{value,currency:currency&&isCurrency(currency)?currency:void 0,trimZeros:true})}function useNow(){const[now]=useState(()=>Date.now());return now}var SHIHAB_BLOCKS=["action_confirm","products","product","orders","order","order-timeline","checkout-leads","sales-summary","insights","chart","ql-result","customers","collections","coupons","offers","reviews","inventory","media","blog-posts","blog-post","blog-categories","markets","locations","menus","countries","provinces","shipping-profiles","shipping-zones","shipping-rates","carriers","plans","subscription","support-methods"];var KNOWN=new Set(SHIHAB_BLOCKS);function isShihabBlock(name){return KNOWN.has(name)}var OPEN=/^```([A-Za-z][\w-]*)?\s*$/;var ONE_LINE=/^```([A-Za-z][\w-]*)\s+(\{.*\})\s*```$/;function parseShihab(text){const lines=normalizeFences(text.replace(/\r\n/g,"\n")).split("\n");const out=[];let md=[];const flush=()=>{const joined=md.join("\n");if(joined.trim())out.push(...splitInline(joined));md=[]};for(let i=0;i<lines.length;i++){const line=lines[i].trim();const single2=ONE_LINE.exec(line);if(single2){flush();out.push(toSegment(single2[1],single2[2]));continue}const open=OPEN.exec(line);if(!open){md.push(lines[i]);continue}flush();const lang=open[1]??"";const body=[];let j=i+1;while(j<lines.length&&lines[j].trim()!=="```")body.push(lines[j++]);if(j>=lines.length){out.push(isShihabBlock(lang)||lang==="mermaid"?{kind:"pending",type:lang}:{kind:"code",lang,code:body.join("\n")});return out}out.push(toSegment(lang,body.join("\n")));i=j}flush();return out}var NAMES=[...SHIHAB_BLOCKS,"mermaid"].sort((a,b)=>b.length-a.length).map(n=>n.replace(/-/g,"\\-")).join("|");var OPEN_INLINE=new RegExp("([^\\n])(```(?:"+NAMES+")(?![\\w-]))","g");var BODY_ON_OPEN=new RegExp("^(```(?:"+NAMES+"))(?![\\w-])[ \\t]*(?=\\S)","gm");function normalizeFences(text){if(!text.includes("```"))return text;return text.replace(OPEN_INLINE,"$1\n$2").replace(BODY_ON_OPEN,"$1\n").replace(/([}\]])[ \t]*```/g,"$1\n```").replace(/^```[ \t]*(?=[^\sA-Za-z])/gm,"```\n")}function toSegment(lang,raw){if(lang==="mermaid")return{kind:"mermaid",code:raw};if(!isShihabBlock(lang))return{kind:"code",lang,code:raw};try{return{kind:"block",type:lang,data:JSON.parse(raw)}}catch{return{kind:"invalid",type:lang,raw}}}function splitInline(text){const out=[];let md=[];const flush=()=>{const joined=md.join("\n");if(joined.trim())out.push({kind:"markdown",text:joined});md=[]};for(const line of text.split("\n")){const t=line.trim();if(t.startsWith("{")&&t.endsWith("}")){let obj2;try{obj2=JSON.parse(t)}catch{obj2=void 0}if(isRecord(obj2)&&typeof obj2.tool==="string"&&typeof obj2.confirmMessage==="string"){flush();out.push({kind:"block",type:"action_confirm",data:obj2});continue}if(isRecord(obj2)&&Array.isArray(obj2.items)){flush();out.push({kind:"leak",data:obj2});continue}}md.push(line)}flush();return out}function isRecord(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function isObj(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function obj(v){return isObj(v)?v:{}}function pick(o,...keys){for(const k of keys){const v=o[k];if(v!==void 0&&v!==null&&v!=="")return v}return void 0}function str(o,...keys){const v=pick(o,...keys);if(typeof v==="string")return v.trim()||void 0;if(typeof v==="number"&&Number.isFinite(v))return String(v);return void 0}function num(o,...keys){const v=pick(o,...keys);if(typeof v==="boolean")return void 0;const n=typeof v==="number"?v:typeof v==="string"?Number(v.replace(/,/g,"")):NaN;return Number.isFinite(n)?n:void 0}function bool(o,...keys){const v=pick(o,...keys);return typeof v==="boolean"?v:void 0}function strs(o,...keys){const v=pick(o,...keys);return Array.isArray(v)?v.filter(x=>typeof x==="string"&&x.trim()!==""):[]}var LIST_KEYS=["items","products","matches","orders","leads","customers","collections","coupons","blogs","categories","menus","countries","provinces","profiles","zones","rates","carriers","events","timeline"];function list(data){const o=obj(data);for(const k of LIST_KEYS){const v=o[k];if(Array.isArray(v))return v.filter(isObj)}return[]}function single(data,marker){const o=obj(data);if(o[marker]===void 0&&Array.isArray(o.items)&&isObj(o.items[0]))return o.items[0];return o}function date(o,...keys){const s=str(o,...keys);if(!s)return void 0;const d=new Date(s);return Number.isNaN(d.getTime())?void 0:d}var UNITS=[["year",365*24*3600],["month",30*24*3600],["week",7*24*3600],["day",24*3600],["hour",3600],["minute",60]];function formatWhen(d,locale,now=Date.now()){const diff=(d.getTime()-now)/1e3;if(Math.abs(diff)<7*24*3600){const rtf=new Intl.RelativeTimeFormat(locale,{numeric:"auto"});if(Math.abs(diff)<60)return rtf.format(0,"minute");for(const[unit,sec]of UNITS){if(Math.abs(diff)>=sec)return rtf.format(Math.round(diff/sec),unit)}}return formatDate(d,locale)}function formatDate(d,locale){const sameYear=d.getFullYear()===new Date().getFullYear();return new Intl.DateTimeFormat(locale,{day:"numeric",month:"short",...sameYear?{}:{year:"numeric"}}).format(d)}import{useState as useState2}from"react";import{Catalog,Forbidden,Offers,Orders,Payment,Settings,Shipping,Trash,UiAlert,UiCheck as UiCheck2,UiClose,ViewList}from"qumra-icons";import{Fragment as Fragment2,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";var TEMPLATE_ICON={paid:Payment,unpaid:Payment,refunded:Payment,order_confirmed:Orders,order_cancelled:Forbidden,fulfilled:Shipping,delivered:Shipping,returned:Shipping,bulk:ViewList,product_create:Catalog,product_edit:Catalog,product_delete:Trash,offer_create:Offers};var DANGER=new Set(["product_delete","order_cancelled","refunded"]);var CANCEL_MESSAGE="\u0625\u0644\u063A\u0627\u0621";function ConfirmBlock({data}){const x=useShihabText();const{live,onSend,answer}=useShihab();const c=obj(data);const template=(str(c,"template")??"generic").toLowerCase();const message=str(c,"confirmMessage");const warning=str(c,"warning");const tool=str(c,"tool")??"";const danger=DANGER.has(template)||!!warning||/^(delete|remove|cancel)/i.test(tool);const Icon=TEMPLATE_ICON[template]??(danger?Trash:Settings);const args=obj(c.args??c.params);const bulk=Object.values(args).find(v=>Array.isArray(v));const[local,setLocal]=useState2();const fromHistory=answer===void 0?void 0:message&&answer.trim()===message.trim()?"confirmed":"closed";const state=local??fromHistory;const canAct=live&&!!onSend&&!!message&&!state;function confirm(){if(!canAct)return;setLocal("confirmed");onSend(message)}function cancel(){if(!canAct)return;setLocal("cancelled");onSend(CANCEL_MESSAGE)}return jsxs2("section",{className:cn("@container w-full min-w-0 rounded-card border bg-surface overflow-clip",danger?"border-red-line":"border-brand"),children:[jsxs2("div",{className:"p-3.5 flex gap-3 items-start",children:[jsx2(BrandIcon,{icon:Icon,size:36}),jsxs2("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsx2("h3",{dir:"auto",className:"m-0 text-ui font-extrabold text-ink [overflow-wrap:anywhere]",children:str(c,"title")??x.label("blockTitle","action_confirm")}),str(c,"summary")&&jsx2("p",{dir:"auto",className:"m-0 text-caption text-ink2 leading-relaxed [overflow-wrap:anywhere]",children:str(c,"summary")}),template==="bulk"&&bulk&&jsx2("span",{children:jsx2(Pill,{tone:"brand",children:jsx2("span",{"data-num":true,children:new Intl.NumberFormat(x.locale).format(bulk.length)})})})]})]}),warning&&jsxs2("p",{role:"note",className:"m-0 mx-3.5 mb-3 flex items-start gap-2 rounded-field bg-red-bg px-3 py-2 text-caption text-red",children:[jsx2(UiAlert,{size:15,"aria-hidden":"true",injectStyles:false,className:"mt-0.5 shrink-0"}),jsx2("span",{dir:"auto",children:warning})]}),jsx2(Diff,{value:c.diff}),jsx2("div",{className:"border-t border-line px-3.5 py-2.5 flex items-center gap-2 flex-wrap",children:state?jsxs2("span",{role:"status",className:cn("inline-flex items-center gap-1.5 text-caption font-bold",state==="confirmed"?"text-green":"text-muted"),children:[state==="confirmed"?jsx2(UiCheck2,{size:15,"aria-hidden":"true",injectStyles:false}):jsx2(UiClose,{size:15,"aria-hidden":"true",injectStyles:false}),state==="confirmed"?x.t("confirmed"):x.t("cancelledState")]}):jsxs2(Fragment2,{children:[jsx2(Button,{size:"sm",variant:danger?"danger":"primary",onClick:confirm,disabled:!canAct,className:"flex-1 @sm:flex-none",children:x.t("confirm")}),jsx2(Button,{size:"sm",variant:"outline",onClick:cancel,disabled:!canAct,children:x.t("cancel")})]})})]})}function Diff({value}){const x=useShihabText();if(value===void 0||value===null||value==="")return null;if(typeof value==="string")return jsx2("p",{dir:"auto",className:"m-0 mx-3.5 mb-3 text-caption text-ink2",children:value});const rows=Array.isArray(value)?value.map((v,i)=>[String(i+1),v]):isObj(value)?Object.entries(value):[];if(rows.length===0)return null;return jsx2("dl",{className:"m-0 mx-3.5 mb-3 rounded-field bg-bg divide-y divide-line text-caption",children:rows.map(([k,v])=>{const pair=isObj(v)&&("from"in v||"to"in v)?v:void 0;return jsxs2("div",{className:"px-3 py-2 flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[jsx2("dt",{className:"text-muted",children:k}),jsx2("dd",{className:"m-0 min-w-0 font-bold text-ink [overflow-wrap:anywhere]",children:pair?jsxs2(Fragment2,{children:[jsxs2("span",{className:"sr-only",children:[x.t("before"),": "]}),jsx2("span",{className:"text-muted2 line-through decoration-1",children:plain(pair.from)??"\u2014"}),jsx2("span",{"aria-hidden":"true",className:"mx-1.5 text-muted2 rtl:-scale-x-100 inline-block",children:"\u2192"}),jsxs2("span",{className:"sr-only",children:[x.t("after"),": "]}),plain(pair.to)??"\u2014"]}):plain(v)??"\u2014"})]},k)})})}function plain(v){if(v===void 0||v===null)return void 0;if(typeof v==="string"||typeof v==="number"||typeof v==="boolean")return String(v);if(isObj(v)){const s=str(v,"title","name","label");return s}return void 0}import{Analytics,CartAbandoned,Data,Orders as Orders2,Pending,StatsOverview,StatsSales,UiBulb}from"qumra-icons";var CTA=/^\s*(عرض|شوف|افتح|view|see|open|show)/i;function footerLinks(footer,href){return{footer,footerHref:footer&&href&&CTA.test(footer)?href:void 0}}import{Fragment as Fragment3,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";function OrderPills({o}){const{label,tone}=useShihabText();const one=str(o,"status");const axes=one?[one]:[str(o,"financialStatus"),str(o,"orderStatus"),str(o,"fulfillmentStatus")];const shown=[...new Set(axes.filter(s=>!!s))];return jsx3(Fragment3,{children:shown.map(s=>jsx3(Pill,{tone:tone("orderStatus",s),children:label("orderStatus",s)},s))})}function orderNumber(o){const n=str(o,"orderId","orderNumber","number");return n?`#${n.replace(/^#/,"")}`:void 0}function OrdersBlock({data}){const x=useShihabText();const items=list(data);const d=obj(data);const footer=footerLinks(str(d,"footer"),useHref("order"));return jsx3(BlockCard,{icon:Orders2,title:str(d,"title")??x.label("blockTitle","orders"),count:items.length,...footer,children:jsx3(Rows,{children:items.map((o,i)=>jsx3(OrderRow,{o},str(o,"id")??i))})})}function OrderRow({o}){const x=useShihabText();const href=useHref("order",str(o,"id","_id"));const customer=str(o,"customerName")??str(obj(o.customer),"name");const count=num(o,"itemsCount");const when=date(o,"createdAt");return jsx3(Row,{href,lead:jsx3(IconTile,{icon:Orders2}),title:jsx3("span",{"data-num":true,children:orderNumber(o)??customer??"\u2014"}),sub:[orderNumber(o)?customer:void 0,count!==void 0?`${x.en?count:new Intl.NumberFormat(x.locale).format(count)} ${x.t("items")}`:void 0].filter(Boolean).join(" \xB7 "),chips:jsx3(OrderPills,{o}),end:jsx3(Price,{value:num(o,"total","totalPrice")}),endSub:when&&formatWhen(when,x.locale)})}function OrderBlock({data}){const x=useShihabText();const o=single(data,"orderId");const href=useHref("order",str(o,"id","_id"));const customer=obj(o.customer);const phone=str(o,"customerPhone")??str(customer,"phone");const when=date(o,"createdAt");const lines=Array.isArray(o.items)?o.items.filter(isObj):[];const ship=obj(o.shipping);const address=["street","district","city","country"].map(k=>str(ship,k)).filter(Boolean);return jsxs3(BlockCard,{icon:Orders2,title:jsx3("span",{"data-num":true,children:orderNumber(o)??x.label("blockTitle","order")}),footer:href?x.t("open"):void 0,footerHref:href,children:[jsxs3(Body,{children:[jsx3("span",{className:"flex flex-wrap gap-1.5",children:jsx3(OrderPills,{o})}),jsx3(Facts,{items:[{label:x.t("total"),value:jsx3(Price,{value:num(o,"total","totalPrice")})},{label:x.t("customer"),value:str(o,"customerName")??str(customer,"name")},phone&&{label:x.t("phone"),value:jsx3(CopyChip,{value:phone})},when&&{label:x.t("date"),value:formatWhen(when,x.locale)}]})]}),lines.length>0&&jsx3(Rows,{children:lines.map((l,i)=>{const qty=num(l,"qty","quantity");return jsx3(Row,{title:str(l,"title","productTitle")??"\u2014",sub:str(l,"sku"),end:jsx3(Price,{value:num(l,"subtotal","totalPrice","price")}),endSub:qty!==void 0?jsxs3("span",{"data-num":true,children:["\xD7 ",qty]}):void 0},i)})}),address.length>0&&jsxs3("p",{className:"m-0 border-t border-line px-3.5 py-2.5 text-caption text-muted",children:[jsxs3("span",{className:"font-bold text-ink2",children:[x.t("shipTo"),": "]}),jsx3("span",{dir:"auto",children:address.join("\u060C ")})]})]})}function TimelineBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx3(BlockCard,{icon:Pending,title:str(d,"title")??x.label("blockTitle","order-timeline"),footer:str(d,"footer"),children:jsx3("ol",{className:"m-0 px-3.5 pb-3.5 pt-1 list-none flex flex-col",children:items.map((e,i)=>{const field=str(e,"field","axisField");const from=str(e,"from","previousValue");const to=str(e,"to","newValue");const actor=str(obj(e.actor),"name");const at=date(e,"at","createdAt");const note=str(e,"note");const last=i===items.length-1;return jsxs3("li",{className:"relative flex gap-3 pb-3 last:pb-0",children:[!last&&jsx3("span",{"aria-hidden":"true",className:"absolute top-4 bottom-0 start-1 w-px bg-line"}),jsx3("span",{"aria-hidden":"true",className:cn("relative mt-1.5 size-2.5 rounded-full shrink-0",i===0?"bg-brand":"bg-border")}),jsxs3("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[jsx3("span",{className:"text-ui font-bold text-ink",children:field?x.label("orderField",field):x.label("timelineType",str(e,"type"))??"\u2014"}),(from||to)&&jsxs3("span",{className:"flex flex-wrap items-center gap-1.5",children:[from&&jsx3(Pill,{tone:x.tone("orderStatus",from),children:x.label("orderStatus",from)}),from&&to&&jsx3("span",{"aria-hidden":"true",className:"text-muted2 rtl:-scale-x-100",children:"\u2192"}),to&&jsx3(Pill,{tone:x.tone("orderStatus",to),children:x.label("orderStatus",to)})]}),note&&jsx3("span",{dir:"auto",className:"text-caption text-ink2",children:note}),jsxs3("span",{className:"text-micro text-muted2",children:[x.t("by")," ",actor??x.t("system"),at&&` \xB7 ${formatWhen(at,x.locale)}`]})]})]},i)})})})}function LeadsBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("checkout"));return jsxs3(BlockCard,{icon:CartAbandoned,title:str(d,"title")??x.label("blockTitle","checkout-leads"),count:items.length,...footer,children:[Object.keys(s).length>0&&jsx3(Body,{children:jsx3(Stats,{items:[num(s,"totalLeads")!==void 0&&{label:x.t("totalLeads"),value:jsx3(Num,{value:num(s,"totalLeads")})},num(s,"totalCartValue")!==void 0&&{label:x.t("totalCartValue"),value:jsx3(Price,{value:num(s,"totalCartValue")})},num(s,"avgCartValue")!==void 0&&{label:x.t("avgCartValue"),value:jsx3(Price,{value:num(s,"avgCartValue")})},num(s,"withCOD")!==void 0&&{label:x.t("withCOD"),value:jsx3(Num,{value:num(s,"withCOD")})}]})}),jsx3(Rows,{children:items.map((l,i)=>{const name=str(l,"customerName");const phone=str(l,"phone");const status=str(l,"status");const pay=str(l,"paymentName")??x.label("paymentType",str(l,"paymentType"));const last=date(l,"lastActivityAt","createdAt");const count=num(l,"cartItemsCount");const flags=["hasAddress","hasCoupon","phoneVerified","marketingOptIn"].filter(k=>bool(l,k));return jsx3(Row,{lead:jsx3(IconTile,{icon:CartAbandoned}),title:name??jsx3("span",{dir:"ltr",children:phone??"\u2014"}),sub:last&&`${x.t("lastActivity")} ${formatWhen(last,x.locale)}`,chips:jsxs3(Fragment3,{children:[status&&jsx3(Pill,{tone:x.tone("leadStatus",status),children:x.label("leadStatus",status)}),pay&&jsx3(Pill,{children:pay}),flags.map(k=>jsx3(Pill,{tone:"brand",children:x.t(k)},k))]}),end:jsx3(Price,{value:num(l,"cartTotal")}),endSub:count!==void 0?`${new Intl.NumberFormat(x.locale).format(count)} ${x.t("items")}`:void 0,children:name&&phone&&jsx3("span",{children:jsx3(CopyChip,{value:phone})})},str(l,"id")??i)})})]})}function SalesSummaryBlock({data}){const x=useShihabText();const d=obj(data);const prev=obj(d.vsPrev);const orders=num(d,"orders");return jsx3(BlockCard,{icon:StatsSales,title:str(d,"period","title")??x.label("blockTitle","sales-summary"),children:jsxs3(Body,{children:[jsx3(Stats,{lead:true,items:[{label:x.t("revenue"),value:jsx3(Price,{value:num(d,"total","revenue")}),hint:jsx3(Delta,{value:prev.total})},orders!==void 0&&{label:x.t("ordersCount"),value:jsx3(Num,{value:orders}),hint:jsx3(Delta,{value:prev.orders})},num(d,"avgOrderValue")!==void 0&&{label:x.t("avgOrder"),value:jsx3(Price,{value:num(d,"avgOrderValue")})}]}),(prev.total!==void 0||prev.orders!==void 0)&&jsx3("span",{className:"text-micro text-muted2",children:x.t("vsPrev")})]})})}function InsightsBlock({data}){const x=useShihabText();const d=obj(data);const scores=Array.isArray(d.scores)?d.scores.filter(isObj):[];const highlights=strs(d,"highlights");const tips=strs(d,"recommendations");return jsx3(BlockCard,{icon:Analytics,title:str(d,"title")??x.label("blockTitle","insights"),children:jsxs3(Body,{children:[jsx3(Stats,{items:scores.map(s=>{const v=num(s,"value");return{label:str(s,"label")??"\u2014",value:v!==void 0?jsx3(Num,{value:v}):str(s,"value"),hint:jsx3(Delta,{value:pick(s,"trend")})}})}),highlights.length>0&&jsxs3("section",{className:"flex flex-col gap-1.5",children:[jsx3("h4",{className:"m-0 text-caption font-extrabold text-ink2",children:x.t("highlights")}),jsx3("ul",{className:"m-0 ps-5 list-disc marker:text-muted2 flex flex-col gap-1 text-caption text-ink2",children:highlights.map((h,i)=>jsx3("li",{dir:"auto",children:h},i))})]}),tips.length>0&&jsxs3("section",{className:"rounded-field bg-soft px-3 py-2.5 flex flex-col gap-1.5",children:[jsxs3("h4",{className:"m-0 flex items-center gap-1.5 text-caption font-extrabold text-brand-ink",children:[jsx3(UiBulb,{size:14,"aria-hidden":"true",injectStyles:false}),x.t("recommendations")]}),jsx3("ul",{className:"m-0 ps-5 list-disc marker:text-brand flex flex-col gap-1 text-caption text-ink2",children:tips.map((h,i)=>jsx3("li",{dir:"auto",children:h},i))})]})]})})}function ChartBlock({data}){const x=useShihabText();const d=obj(data);const raw=Array.isArray(d.x)?d.x.map(String):[];const series=(Array.isArray(d.series)?d.series.filter(isObj):[]).map(s=>({label:str(s,"name")??"",values:Array.isArray(s.data)?s.data.map(v=>typeof v==="number"?v:Number(v)||0):[]})).filter(s=>s.values.length>0);const labels=raw.map(l=>/^\d{4}-\d{2}-\d{2}/.test(l)?formatDate(new Date(l),x.locale):l);const nf=new Intl.NumberFormat(x.locale,{maximumFractionDigits:1,notation:"compact"});const fmt=v=>nf.format(v);const type=str(d,"type");return jsx3(BlockCard,{icon:StatsOverview,title:str(d,"title")??x.label("blockTitle","chart"),children:jsxs3(Body,{children:[series.length===0?jsx3("span",{className:"text-caption text-muted",children:x.t("empty")}):type==="line"&&series.length===1?jsx3(TrendChart,{labels:axisLabels(labels),values:series[0].values,pointLabels:labels,formatValue:fmt,height:170}):jsx3(BarChart,{labels,series:type==="pie"?series.slice(0,1):series,formatValue:fmt,height:170}),series.length>1&&type!=="pie"&&jsx3("span",{className:"flex flex-wrap gap-3 text-micro text-muted",children:series.map((s,i)=>jsxs3("span",{className:"inline-flex items-center gap-1.5",children:[jsx3("span",{"aria-hidden":"true",className:cn("size-2 rounded-full",i===0?"bg-brand":"bg-border")}),s.label]},i))})]})})}function axisLabels(all){if(all.length<=3)return all;return[all[0],all[Math.floor(all.length/2)],all[all.length-1]]}function QlResultBlock({data}){const x=useShihabText();const d=obj(data);const cols=(Array.isArray(d.columns)?d.columns.filter(isObj):[]).map(c=>({key:str(c,"key")??"",label:str(c,"label")??str(c,"key")??"",type:str(c,"type")??"string"})).filter(c=>c.key);const rows=Array.isArray(d.rows)?d.rows.filter(isObj):[];const numeric=t=>t==="number"||t==="currency"||t==="percent";function cell(row,c){if(c.type==="string")return str(row,c.key)??"\u2014";if(c.type==="date"){const dt=date(row,c.key);return dt?formatDate(dt,x.locale):str(row,c.key)??"\u2014"}const n=num(row,c.key);if(n===void 0)return str(row,c.key)??"\u2014";if(c.type==="currency")return jsx3(Price,{value:n});if(c.type==="percent")return jsxs3("span",{"data-num":true,children:[new Intl.NumberFormat(x.locale,{maximumFractionDigits:1}).format(n),"\u066A"]});return jsx3(Num,{value:n})}return jsx3(BlockCard,{icon:Data,title:str(d,"title")??x.label("blockTitle","ql-result"),count:rows.length,footer:str(d,"footer"),children:jsx3("div",{className:"overflow-x-auto overscroll-x-contain border-t border-line",children:jsxs3("table",{className:"w-full min-w-max border-collapse text-caption",children:[jsx3("thead",{children:jsx3("tr",{className:"bg-bg",children:cols.map(c=>jsx3("th",{scope:"col",className:cn("px-3.5 py-2 font-bold text-muted whitespace-nowrap",numeric(c.type)?"text-end":"text-start"),children:c.label},c.key))})}),jsx3("tbody",{className:"divide-y divide-line",children:rows.map((r,i)=>jsx3("tr",{children:cols.map((c,j)=>jsx3("td",{className:cn("px-3.5 py-2 whitespace-nowrap",numeric(c.type)?"text-end font-bold text-ink":"text-start text-ink2",j===0&&"font-bold text-ink"),children:cell(r,c)},c.key))},i))})]})})})}import{Article,Blog,Catalog as Catalog2,Collection,Community,Content,Inventory,Page,UiBox,UiFile,UiImage,UiLayers,UiStar,UiTag,Video}from"qumra-icons";import{Fragment as Fragment4,jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";function StockPill({stock}){const x=useShihabText();if(stock===void 0)return null;if(stock<=0)return jsx4(Pill,{tone:"red",children:x.t("outOfStock")});return jsxs4(Pill,{children:[jsx4(Num,{value:stock})," ",x.t("inStock")]})}function ProductsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("product"));return jsx4(BlockCard,{icon:Catalog2,title:str(d,"title")??x.label("blockTitle","products"),count:items.length,...footer,children:jsx4(Rows,{children:items.map((p,i)=>jsx4(ProductRow,{p},str(p,"id")??i))})})}function ProductRow({p}){const x=useShihabText();const status=str(p,"status");return jsx4(Row,{href:useHref("product",str(p,"id","_id")),lead:jsx4(Thumb,{src:str(p,"image","imageUrl"),icon:UiBox}),title:str(p,"title")??"\u2014",chips:jsxs4(Fragment4,{children:[status&&jsx4(Pill,{tone:x.tone("productStatus",status),children:x.label("productStatus",status)}),jsx4(StockPill,{stock:num(p,"stock","quantity")})]}),end:jsx4(Price,{value:num(p,"price")})})}function ProductBlock({data}){const x=useShihabText();const p=single(data,"title");const href=useHref("product",str(p,"id","_id"));const status=str(p,"status");const sold=num(p,"soldLast30d");const variants=Array.isArray(p.variants)?p.variants.filter(isObj):[];const tags=strs(p,"tags");return jsxs4(BlockCard,{footer:href?x.t("open"):void 0,footerHref:href,children:[jsxs4(Body,{className:"pt-3.5",children:[jsxs4("div",{className:"flex gap-3.5 items-start",children:[jsx4(Thumb,{src:str(p,"image","imageUrl"),icon:UiBox,size:"lg"}),jsxs4("div",{className:"flex-1 min-w-0 flex flex-col gap-1.5",children:[jsx4("h3",{dir:"auto",className:"m-0 text-body font-extrabold text-ink [overflow-wrap:anywhere]",children:str(p,"title")??x.label("blockTitle","product")}),jsxs4("span",{className:"flex flex-wrap gap-1.5",children:[status&&jsx4(Pill,{tone:x.tone("productStatus",status),children:x.label("productStatus",status)}),jsx4(StockPill,{stock:num(p,"stock","quantity")})]}),num(p,"price")!==void 0&&jsx4("span",{className:"text-lead font-extrabold text-ink",children:jsx4(Price,{value:num(p,"price")})})]})]}),jsx4(Facts,{items:[str(p,"sku")&&{label:"SKU",value:jsx4("span",{className:"font-mono",dir:"ltr",children:str(p,"sku")})},sold!==void 0&&{label:x.t("sold30"),value:jsx4(Num,{value:sold})}]}),tags.length>0&&jsx4("span",{className:"flex flex-wrap gap-1.5",children:tags.map(t=>jsx4(Pill,{children:t},t))})]}),variants.length>0&&jsx4(Rows,{children:variants.slice(0,8).map((v,i)=>jsx4(Row,{title:str(v,"title")??str(v,"sku")??"\u2014",sub:str(v,"sku"),chips:jsx4(StockPill,{stock:num(v,"quantity","stock")}),end:jsx4(Price,{value:num(v,"price")})},str(v,"qid","id")??i))})]})}function CollectionsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("collection"));return jsx4(BlockCard,{icon:Collection,title:str(d,"title")??x.label("blockTitle","collections"),count:items.length,...footer,children:jsx4(Rows,{children:items.map((c,i)=>jsx4(CollectionRow,{c},str(c,"id","qid")??i))})})}function CollectionRow({c}){const x=useShihabText();const status=str(c,"status");const count=num(c,"productCount");return jsx4(Row,{href:useHref("collection",str(c,"id","_id")),lead:jsx4(Thumb,{src:str(c,"imageUrl","image"),icon:UiLayers}),title:str(c,"title")??"\u2014",sub:str(c,"handle")&&jsxs4("span",{dir:"ltr",children:["/",str(c,"handle")]}),chips:jsxs4(Fragment4,{children:[status&&jsx4(Pill,{tone:x.tone("collectionStatus",status),children:x.label("collectionStatus",status)}),str(c,"operation")&&jsx4(Pill,{children:x.label("operation",str(c,"operation"))})]}),end:count!==void 0?jsx4(Num,{value:count}):void 0,endSub:count!==void 0?x.t("products"):void 0})}function InventoryBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx4(BlockCard,{icon:Inventory,title:str(d,"title")??x.label("blockTitle","inventory"),count:items.length,footer:str(d,"footer"),children:jsx4(Rows,{children:items.map((r,i)=>jsx4(InventoryRow,{r},str(r,"id")??i))})})}function InventoryRow({r}){const x=useShihabText();const p=obj(r.product);const v=obj(r.variant);const available=num(r,"available");const opts=strs(v,"options").join(" \xB7 ");const minor=["onHand","committed","incoming","unavailable"].map(k=>[k,num(r,k)]).filter(([,n])=>n!==void 0&&n!==0);return jsx4(Row,{href:useHref("product",str(p,"id")),lead:jsx4(Thumb,{src:str(v,"image")??str(p,"image"),icon:UiBox}),title:str(p,"title")??str(v,"sku")??"\u2014",sub:[opts,str(v,"sku")].filter(Boolean).join(" \xB7 ")||void 0,end:available!==void 0?jsx4("span",{className:cn(available<=0?"text-red":available<=5?"text-amber-ink":"text-ink"),children:jsx4(Num,{value:available})}):void 0,endSub:available!==void 0?x.t("available"):void 0,children:minor.length>0&&jsx4("span",{className:"text-micro text-muted2",children:minor.map(([k,n],i)=>jsxs4("span",{children:[i>0&&" \xB7 ",x.t(k)," ",jsx4(Num,{value:n})]},k))})})}function Rating({value}){const n=Math.max(0,Math.min(5,Math.round(value)));return jsxs4("span",{className:"inline-flex items-center gap-1 text-caption font-extrabold text-amber-ink",children:[jsx4(UiStar,{size:13,"aria-hidden":"true",injectStyles:false}),jsx4("span",{"data-num":true,children:n}),jsx4("span",{className:"sr-only",children:"/ 5"})]})}function ReviewsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const summary=Object.entries(obj(d.summary)).filter(([,v])=>typeof v==="number"||typeof v==="string");const footer=footerLinks(str(d,"footer"),useHref("review"));return jsxs4(BlockCard,{icon:Community,title:str(d,"title")??x.label("blockTitle","reviews"),count:items.length,...footer,children:[summary.length>0&&jsx4(Body,{children:jsx4(Stats,{items:summary.slice(0,4).map(([k,v])=>({label:k,value:typeof v==="number"?jsx4(Num,{value:v}):String(v)}))})}),jsx4(Rows,{children:items.map((r,i)=>jsx4(ReviewRow,{r},str(r,"id","qid")??i))})]})}function ReviewRow({r}){const x=useShihabText();const status=str(r,"status");const product=obj(r.product);const rating=num(r,"rating");const at=date(r,"createdAt");const productHref=useHref("product",str(product,"id"));const comment=str(r,"comment");return jsx4(Row,{lead:jsx4(Initial,{name:str(r,"customerName")}),title:str(r,"customerName")??"\u2014",sub:str(product,"title")&&jsxs4(Fragment4,{children:[x.t("on"),":"," ",jsx4(Go,{href:productHref,className:cn(productHref&&"font-bold text-brand hover:text-brand-hover"),children:str(product,"title")})]}),chips:jsxs4(Fragment4,{children:[rating!==void 0&&jsx4(Rating,{value:rating}),status&&jsx4(Pill,{tone:x.tone("reviewStatus",status),children:x.label("reviewStatus",status)})]}),endSub:at&&formatWhen(at,x.locale),children:comment&&jsx4(Clamp,{text:comment})})}var KIND_ICON={image:Content,video:Video,audio:Content,pdf:Page,file:Page,other:Page};function size(mb,kb,locale){const nf=new Intl.NumberFormat(locale,{maximumFractionDigits:1});if(mb!==void 0&&mb>=1)return`${nf.format(mb)} MB`;if(kb!==void 0)return`${nf.format(kb)} KB`;if(mb!==void 0)return`${nf.format(mb*1024)} KB`;return void 0}function MediaBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("media"));const total=num(s,"totalItems");const shown=num(s,"pageSizeMB");return jsxs4(BlockCard,{icon:Content,title:str(d,"title")??x.label("blockTitle","media"),count:items.length,...footer,children:[(total!==void 0||shown!==void 0)&&jsx4(Body,{children:jsx4(Stats,{items:[total!==void 0&&{label:x.label("blockTitle","media"),value:jsx4(Num,{value:total})},shown!==void 0&&{label:x.t("shownSize"),value:jsx4("span",{"data-num":true,children:size(shown,void 0,x.locale)})}]})}),jsx4(Rows,{children:items.map((m,i)=>jsx4(MediaRow,{m},str(m,"id","qid")??i))})]})}function MediaRow({m}){const x=useShihabText();const kind=(str(m,"kind")??"other").toLowerCase();const raw=str(m,"url");const url=raw&&/^https:/i.test(raw)?raw:void 0;const name=str(m,"title")??str(m,"file")??"\u2014";const full=size(num(m,"sizeMB"),num(m,"sizeKB"),x.locale);const packed=size(num(m,"compressedSizeMB"),num(m,"compressedSizeKB"),x.locale);return jsx4(Row,{lead:kind==="image"&&url?jsx4("a",{href:url,target:"_blank",rel:"noopener noreferrer","aria-label":name,className:"shrink-0",children:jsx4(Thumb,{src:url,icon:UiImage})}):jsx4(IconTile,{icon:KIND_ICON[kind]??Page}),title:jsx4("span",{dir:"auto",children:name}),sub:[x.label("mediaKind",kind),full,packed&&`${x.t("afterCompression")} ${packed}`].filter(Boolean).join(" \xB7 "),children:url&&jsx4("span",{children:jsx4(CopyChip,{value:url,label:x.t("copyLink"),mono:false})})})}function BlogMeta({b}){const x=useShihabText();const at=date(b,"publishedAt","createdAt");const views=num(b,"views");return jsx4(Fragment4,{children:[at&&formatDate(at,x.locale),views?`${new Intl.NumberFormat(x.locale).format(views)} ${x.t("views")}`:void 0].filter(Boolean).join(" \xB7 ")})}function category(b){return str(b,"category")??str(obj(b.category),"title")}function BlogPostsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("blog"));return jsx4(BlockCard,{icon:Blog,title:str(d,"title")??x.label("blockTitle","blog-posts"),count:items.length,...footer,children:jsx4(Rows,{children:items.map((b,i)=>jsx4(BlogRow,{b},str(b,"qid","id")??i))})})}function BlogRow({b}){const x=useShihabText();const status=str(b,"status");const excerpt=str(b,"excerpt","description");return jsx4(Row,{href:useHref("blog",str(b,"qid","id")),lead:jsx4(Thumb,{src:str(b,"image","imageUrl"),icon:UiFile}),title:str(b,"title")??"\u2014",sub:jsx4(BlogMeta,{b}),chips:jsxs4(Fragment4,{children:[status&&jsx4(Pill,{tone:x.tone("blogStatus",status),children:x.label("blogStatus",status)}),category(b)&&jsx4(Pill,{children:category(b)})]}),children:excerpt&&jsx4("span",{dir:"auto",className:"text-caption text-ink2 line-clamp-2",children:excerpt})})}function BlogPostBlock({data}){const x=useShihabText();const b=single(data,"title");const href=useHref("blog",str(b,"qid","id"));const image=str(b,"image","imageUrl");const status=str(b,"status");const tags=strs(b,"tags");const excerpt=str(b,"excerpt","description");return jsxs4(BlockCard,{footer:href?x.t("open"):void 0,footerHref:href,children:[image&&jsx4(Cover,{src:image}),jsxs4(Body,{className:"pt-3.5",children:[jsx4("h3",{dir:"auto",className:"m-0 text-body font-extrabold text-ink [overflow-wrap:anywhere]",children:str(b,"title")??x.label("blockTitle","blog-post")}),excerpt&&jsx4("p",{dir:"auto",className:"m-0 text-caption text-ink2 leading-relaxed",children:excerpt}),jsxs4("span",{className:"flex flex-wrap items-center gap-1.5",children:[status&&jsx4(Pill,{tone:x.tone("blogStatus",status),children:x.label("blogStatus",status)}),category(b)&&jsx4(Pill,{tone:"brand",children:category(b)}),tags.map(t=>jsxs4(Pill,{children:["#",t]},t))]}),jsx4("span",{className:"text-micro text-muted2",children:jsx4(BlogMeta,{b})})]})]})}function Cover({src}){return jsx4("img",{src,alt:"",loading:"lazy",onError:e=>{e.currentTarget.hidden=true},className:"block w-full aspect-video object-cover bg-hover"})}function BlogCategoriesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx4(BlockCard,{icon:Article,title:str(d,"title")??x.label("blockTitle","blog-categories"),count:items.length,footer:str(d,"footer"),children:jsx4(Rows,{children:items.map((c,i)=>jsx4(Row,{lead:jsx4(Thumb,{src:str(c,"imageUrl"),icon:UiTag}),title:str(c,"title")??"\u2014",sub:str(c,"description")??(str(c,"handle")&&jsxs4("span",{dir:"ltr",children:["/",str(c,"handle")]}))},str(c,"qid","id")??i))})})}import*as QumraIcons from"qumra-icons";import{Cities,Countries,Customers,InventoryBuilding,Menu,Offers as Offers2,Shipping as Shipping2,ShippingParcel,ShippingVan}from"qumra-icons";import{Fragment as Fragment5,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function CustomersBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("customer"));return jsx5(BlockCard,{icon:Customers,title:str(d,"title")??x.label("blockTitle","customers"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((c,i)=>jsx5(CustomerRow,{c},str(c,"id","qid")??i))})})}function CustomerRow({c}){const x=useShihabText();const name=str(c,"name");const phone=str(c,"phone");const orders=num(c,"orderCount");const seen=date(c,"lastSeen");return jsx5(Row,{href:useHref("customer",str(c,"id","_id")),lead:jsx5(Initial,{name:name??phone,src:str(c,"avatarUrl")}),title:name??jsx5("span",{dir:"ltr",children:phone??"\u2014"}),sub:[name&&phone,str(c,"email")].filter(Boolean).join(" \xB7 ")||void 0,chips:jsxs5(Fragment5,{children:[bool(c,"verified")&&jsx5(Pill,{tone:"green",children:x.t("verified")}),bool(c,"blocked")&&jsx5(Pill,{tone:"red",children:x.t("blocked")})]}),end:orders!==void 0?jsx5(Num,{value:orders}):void 0,endSub:orders!==void 0?x.t("ordersUnit"):seen&&`${x.t("lastSeen")} ${formatWhen(seen,x.locale)}`})}function Discount({o}){const x=useShihabText();const type=str(o,"offerType");if(type==="free_shipping")return jsx5(Fragment5,{children:x.label("offerType",type)});const pct=num(o,"discountPercentage")??(type==="percentage_discount"?num(o,"amount"):void 0);if(pct!==void 0)return jsxs5("span",{"data-num":true,children:[new Intl.NumberFormat(x.locale).format(pct),"\u066A"]});const amount=num(o,"discountAmount")??(type==="fixed_discount"?num(o,"amount"):void 0);return amount!==void 0?jsx5(Price,{value:amount}):null}function OfferState({o}){const x=useShihabText();const live=bool(o,"isLive");const active=bool(o,"active");const start=date(o,"startDate");const end=date(o,"endDate");const now=useNow();if(live)return jsx5(Pill,{tone:"green",children:x.t("live")});if(end&&end.getTime()<now)return jsx5(Pill,{tone:"neutral",children:x.t("ended")});if(start&&start.getTime()>now)return jsx5(Pill,{tone:"amber",children:x.t("notStarted")});if(active===false)return jsx5(Pill,{tone:"neutral",children:x.t("paused")});if(active)return jsx5(Pill,{tone:"green",children:x.t("active")});return null}function OfferRows({items,icon}){const x=useShihabText();return jsx5(Rows,{children:items.map((o,i)=>{const code=str(o,"code");const days=num(o,"daysLeft");const start=date(o,"startDate");const end=date(o,"endDate");const min=num(o,"minPurchase");const max=num(o,"maxDiscount");const range=[start&&formatDate(start,x.locale),end&&formatDate(end,x.locale)].filter(Boolean).join(" \u2190 ");return jsx5(Row,{lead:jsx5(IconTile,{icon}),title:str(o,"title")??code??"\u2014",sub:str(o,"summary")??x.label("appliedOn",str(o,"appliedOn")),chips:jsxs5(Fragment5,{children:[jsx5(OfferState,{o}),str(o,"method")&&jsx5(Pill,{children:x.label("offerMethod",str(o,"method"))}),code&&jsx5(CopyChip,{value:code})]}),end:jsx5(Discount,{o}),endSub:days!==void 0&&days>0?`${new Intl.NumberFormat(x.locale).format(days)} ${x.t("daysLeft")}`:range||void 0,children:(min!==void 0||max!==void 0)&&jsxs5("span",{className:"text-micro text-muted2",children:[min!==void 0&&jsxs5(Fragment5,{children:[x.t("minPurchase")," ",jsx5(Price,{value:min})]}),min!==void 0&&max!==void 0&&" \xB7 ",max!==void 0&&jsxs5(Fragment5,{children:[x.t("maxDiscount")," ",jsx5(Price,{value:max})]})]})},str(o,"id","qid")??i)})})}function OffersBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("offer"));const live=num(s,"liveNow");const total=num(s,"totalOffers");return jsxs5(BlockCard,{icon:Offers2,title:str(d,"title")??x.label("blockTitle","offers"),count:items.length,...footer,children:[(live!==void 0||total!==void 0)&&jsx5(Body,{children:jsx5(Stats,{items:[live!==void 0&&{label:x.t("liveNow"),value:jsx5(Num,{value:live})},total!==void 0&&{label:x.t("totalOffers"),value:jsx5(Num,{value:total})}]})}),jsx5(OfferRows,{items,icon:Offers2})]})}function CouponsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("coupon"));return jsx5(BlockCard,{icon:Offers2,title:str(d,"title")??x.label("blockTitle","coupons"),count:items.length,...footer,children:jsx5(OfferRows,{items,icon:Offers2})})}function MarketsBlock({data}){const x=useShihabText();const d=obj(data);const s=obj(d.summary);const items=list(data);return jsxs5(BlockCard,{icon:Countries,title:str(d,"title")??x.label("blockTitle","markets"),count:items.length,footer:str(d,"footer"),children:[Object.keys(s).length>0&&jsx5(Body,{children:jsx5(Stats,{items:[num(s,"totalMarkets")!==void 0&&{label:x.label("blockTitle","markets"),value:jsx5(Num,{value:num(s,"totalMarkets")})},num(s,"activeCount")!==void 0&&{label:x.label("marketStatus","active"),value:jsx5(Num,{value:num(s,"activeCount")})},num(s,"draftCount")!==void 0&&{label:x.label("marketStatus","draft"),value:jsx5(Num,{value:num(s,"draftCount")})},str(s,"defaultMarket")&&{label:x.t("isDefault"),value:str(s,"defaultMarket")}]})}),jsx5(Rows,{children:items.map((m,i)=>{const status=str(m,"status");const cur=str(m,"targetCurrencyCode");const rate=num(m,"exchangeRate");const count=num(m,"countriesCount");const codes=strs(m,"countryCodes");return jsx5(Row,{lead:jsx5(IconTile,{icon:Countries}),title:str(m,"title")??"\u2014",sub:[cur&&rate!==void 0?`1 = ${new Intl.NumberFormat(x.locale,{maximumFractionDigits:4}).format(rate)} ${cur}`:cur,count!==void 0?`${new Intl.NumberFormat(x.locale).format(count)} ${x.t("countriesUnit")}`:void 0].filter(Boolean).join(" \xB7 "),chips:jsxs5(Fragment5,{children:[bool(m,"isDefault")&&jsx5(Pill,{tone:"brand",children:x.t("isDefault")}),status&&jsx5(Pill,{tone:x.tone("marketStatus",status),children:x.label("marketStatus",status)}),str(m,"fxMode")&&jsx5(Pill,{children:x.label("fxMode",str(m,"fxMode"))}),bool(m,"enableRounding")&&jsx5(Pill,{children:x.t("rounding")}),bool(m,"localCurrencies")&&jsx5(Pill,{children:x.t("localCurrencies")})]}),children:codes.length>0&&jsx5("span",{dir:"ltr",className:"flex flex-wrap gap-1 justify-end rtl:justify-end",children:codes.slice(0,12).map(c=>jsx5("span",{className:"px-1.5 rounded-xs bg-hover text-micro font-bold text-muted font-mono",children:c},c))})},str(m,"id","qid")??i)})})]})}function LocationsBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("location"));return jsx5(BlockCard,{icon:InventoryBuilding,title:str(d,"title")??x.label("blockTitle","locations"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((l,i)=>{const status=str(l,"status");const flags=[["fulfillsOnlineOrders","fulfillsOnline"],["shipsInventory","shipsInventory"],["hasActiveInventory","hasInventory"]].filter(([k])=>bool(l,k));return jsx5(Row,{lead:jsx5(IconTile,{icon:InventoryBuilding}),title:str(l,"name")??"\u2014",sub:[str(l,"address1"),str(l,"city"),str(l,"country")].filter(Boolean).join("\u060C ")||void 0,chips:jsxs5(Fragment5,{children:[bool(l,"isPrimary")&&jsx5(Pill,{tone:"brand",children:x.t("isDefault")}),status&&jsx5(Pill,{tone:x.tone("locationStatus",status),children:x.label("locationStatus",status)}),flags.map(([k,t])=>jsx5(Pill,{children:x.t(t)},k))]}),children:str(l,"phone")&&jsx5("span",{children:jsx5(CopyChip,{value:str(l,"phone")})})},str(l,"id","qid")??i)})})})}function MenusBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("menu"));return jsx5(BlockCard,{icon:Menu,title:str(d,"title")??x.label("blockTitle","menus"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((m,i)=>{const n=num(m,"itemsCount");return jsx5(Row,{lead:jsx5(IconTile,{icon:Menu}),title:str(m,"title")??"\u2014",sub:str(m,"handle")&&jsxs5("span",{dir:"ltr",children:["/",str(m,"handle")]}),end:n!==void 0?jsx5(Num,{value:n}):void 0,endSub:n!==void 0?x.t("links"):void 0},str(m,"id","qid")??i)})})})}function flagOf(code){if(!code||!/^[A-Za-z]{2}$/.test(code))return void 0;const name=`Flag${code[0].toUpperCase()}${code[1].toLowerCase()}`;const icon=QumraIcons[name];return typeof icon==="object"||typeof icon==="function"?icon:void 0}function CodeTile({code}){const flag=flagOf(code);if(flag)return jsx5(IconTile,{icon:flag});if(!code)return jsx5(IconTile,{icon:Countries});return jsx5("span",{"aria-hidden":"true",dir:"ltr",className:"size-10 rounded-sm shrink-0 bg-hover text-caption font-extrabold text-muted font-mono flex items-center justify-center",children:code.slice(0,3)})}function CountriesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Countries,title:str(d,"title")??x.label("blockTitle","countries"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{scroll:true,children:items.map((c,i)=>{const cur=obj(c.currency);const active=bool(c,"active");return jsx5(Row,{lead:jsx5(CodeTile,{code:str(c,"code")}),title:str(c,"name","title")??"\u2014",sub:jsxs5(Fragment5,{children:[[str(c,"capital"),str(c,"continent")].filter(Boolean).join(" \xB7 "),str(c,"phonekey")&&jsxs5(Fragment5,{children:[str(c,"capital")||str(c,"continent")?" \xB7 ":"",jsx5("span",{dir:"ltr","data-num":true,children:str(c,"phonekey")})]})]}),chips:active===false?jsx5(Pill,{children:x.t("inactive")}):void 0,end:str(cur,"symbol")??str(cur,"code"),endSub:str(cur,"title")},str(c,"id","code")??i)})})})}function ProvincesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Cities,title:str(d,"title")??x.label("blockTitle","provinces"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{scroll:true,children:items.map((p,i)=>jsx5(Row,{title:str(p,"name")??"\u2014",sub:str(p,"nameEn")&&jsx5("span",{dir:"ltr",children:str(p,"nameEn")}),end:str(p,"code")&&jsx5("span",{className:"font-mono text-muted",dir:"ltr",children:str(p,"code")})},str(p,"qid","code")??i))})})}function ShippingProfilesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);const footer=footerLinks(str(d,"footer"),useHref("shipping"));return jsx5(BlockCard,{icon:Shipping2,title:str(d,"title")??x.label("blockTitle","shipping-profiles"),count:items.length,...footer,children:jsx5(Rows,{children:items.map((p,i)=>{const products=num(p,"productCount");const groups=num(p,"groupCount");return jsx5(Row,{lead:jsx5(IconTile,{icon:Shipping2}),title:str(p,"name")??"\u2014",sub:[products!==void 0&&`${new Intl.NumberFormat(x.locale).format(products)} ${x.t("products")}`,groups!==void 0&&`${new Intl.NumberFormat(x.locale).format(groups)} ${x.t("groups")}`].filter(Boolean).join(" \xB7 "),chips:bool(p,"isDefault")?jsx5(Pill,{tone:"brand",children:x.t("isDefault")}):void 0},str(p,"qid")??i)})})})}function ShippingZonesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:Countries,title:str(d,"title")??x.label("blockTitle","shipping-zones"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{children:items.map((z,i)=>jsx5(Row,{lead:jsx5(IconTile,{icon:Countries}),title:str(z,"name")??"\u2014",chips:str(z,"zoneType")?jsx5(Pill,{children:x.label("zoneType",str(z,"zoneType"))}):void 0},str(z,"qid")??i))})})}function loose(v){if(v===void 0||v===null||v==="")return void 0;if(isObj(v))return Object.entries(v).filter(([,val])=>val!==null&&val!==void 0&&typeof val!=="object").map(([k,val])=>`${k}: ${String(val)}`).join(" \xB7 ");if(typeof v==="object")return void 0;return String(v)}function ShippingRatesBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:ShippingParcel,title:str(d,"title")??x.label("blockTitle","shipping-rates"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{children:items.map((r,i)=>{const minor=num(r,"priceMinor");const price=minor!==void 0?minor/100:num(r,"price");const free=r.freeOverride;const cond=loose(r.conditions);return jsx5(Row,{lead:jsx5(IconTile,{icon:ShippingParcel}),title:str(r,"name")??"\u2014",sub:str(r,"transit"),chips:str(r,"source")?jsx5(Pill,{children:x.label("rateSource",str(r,"source"))}):void 0,end:price===0?x.label("offerType","free_shipping"):jsx5(Price,{value:price,currency:str(r,"currency")}),children:free!==void 0&&free!==null||cond?jsxs5("span",{className:"text-micro text-muted2",children:[typeof free==="number"?jsxs5(Fragment5,{children:[x.t("freeOver")," ",jsx5(Price,{value:free,currency:str(r,"currency")})]}):loose(free),cond&&` \xB7 ${cond}`]}):null},str(r,"qid")??i)})})})}function CarriersBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data);return jsx5(BlockCard,{icon:ShippingVan,title:str(d,"title")??x.label("blockTitle","carriers"),count:items.length,footer:str(d,"footer"),children:jsx5(Rows,{children:items.map((c,i)=>{const tested=date(c,"lastTestedAt");const status=str(c,"lastTestStatus");return jsx5(Row,{lead:jsx5(IconTile,{icon:ShippingVan}),title:str(c,"name")??"\u2014",sub:tested&&`${x.t("lastTest")}: ${formatDate(tested,x.locale)}`,chips:jsxs5(Fragment5,{children:[bool(c,"active")!==void 0&&(bool(c,"active")?jsx5(Pill,{tone:"green",children:x.t("active")}):jsx5(Pill,{children:x.t("inactive")})),bool(c,"supportsServiceDiscovery")&&jsx5(Pill,{children:x.t("autoRates")}),bool(c,"hasApiKey")&&jsx5(Pill,{children:x.t("keySaved")}),status&&jsx5(Pill,{tone:x.tone("testStatus",status),children:x.label("testStatus",status)})]})},str(c,"qid")??i)})})})}import{useState as useState3}from"react";import{Chat,Email,Phone,Premium,SocialWhatsapp,Support,UiCheck as UiCheck3,UiSparkle,Upgrade}from"qumra-icons";import{Fragment as Fragment6,jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";function PlansBlock({data}){const x=useShihabText();const{live,onSend}=useShihab();const d=obj(data);const items=list(data);const hasYearly=items.some(p=>num(obj(p.price),"yearly")!==void 0);const[period,setPeriod]=useState3("monthly");const[sent,setSent]=useState3();function subscribe(p){const title=str(p,"title")??str(p,"key")??"";setSent(str(p,"id")??title);onSend?.(`\u0627\u0634\u062A\u0631\u0643 \u0641\u064A \u0628\u0627\u0642\u0629 ${title} ${period==="yearly"?"\u0633\u0646\u0648\u064A":"\u0634\u0647\u0631\u064A"}`)}return jsx6(BlockCard,{icon:Premium,title:str(d,"title")??x.label("blockTitle","plans"),footer:str(d,"footer"),children:jsxs6(Body,{children:[hasYearly&&jsx6("div",{role:"radiogroup","aria-label":x.label("blockTitle","plans"),className:"self-start flex p-0.5 rounded-field bg-hover",children:["monthly","yearly"].map(p=>jsx6("button",{type:"button",role:"radio","aria-checked":period===p,onClick:()=>setPeriod(p),className:cn("px-3 py-1 rounded-sm text-caption font-bold cursor-pointer transition-colors",period===p?"bg-surface text-ink shadow-raise":"text-muted hover:text-ink"),children:x.t(p)},p))}),jsx6("div",{className:"grid grid-cols-1 @lg:grid-cols-2 @3xl:grid-cols-3 gap-2.5",children:items.map((p,i)=>{const price=obj(p.price);const amount=num(price,period)??num(price,"monthly");const shownPeriod=num(price,period)!==void 0?period:"monthly";const popular=bool(p,"popular");const paid=bool(p,"isPaid");const canBuy=bool(p,"subscribable")&&live&&!!onSend&&!sent;const limits=obj(p.limits);const features=strs(p,"features").slice(0,8);const id=str(p,"id")??str(p,"title");return jsxs6("article",{className:cn("min-w-0 rounded-card border p-3.5 flex flex-col gap-2.5",popular?"border-brand bg-soft":"border-line bg-surface"),children:[jsxs6("header",{className:"flex items-start justify-between gap-2",children:[jsxs6("span",{className:"min-w-0 flex flex-col gap-0.5",children:[jsx6("h4",{className:"m-0 text-body font-extrabold text-ink",children:str(p,"title")??str(p,"key")}),str(p,"tagline")&&jsx6("span",{className:"text-micro text-muted",children:str(p,"tagline")})]}),popular&&jsxs6(Pill,{tone:"brand",children:[jsx6(UiSparkle,{size:12,"aria-hidden":"true",injectStyles:false}),x.t("popular")]})]}),jsx6("span",{className:"flex items-baseline gap-1.5 text-h3 font-extrabold text-ink",children:paid===false||amount===0?x.t("free"):jsxs6(Fragment6,{children:[jsx6(Price,{value:amount,currency:str(price,"currency")}),jsxs6("span",{className:"text-caption font-bold text-muted",children:["/ ",x.t(shownPeriod==="yearly"?"perYear":"perMonth")]})]})}),features.length>0&&jsx6("ul",{className:"m-0 p-0 list-none flex flex-col gap-1.5 text-caption text-ink2",children:features.map((f,j)=>jsxs6("li",{className:"flex items-start gap-1.5",children:[jsx6(UiCheck3,{size:14,"aria-hidden":"true",injectStyles:false,className:"mt-0.5 shrink-0 text-green"}),jsx6("span",{dir:"auto",children:f})]},j))}),Object.keys(limits).length>0&&jsx6(Facts,{items:[["products","productsLimit"],["storage","storage"],["staffAccounts","staff"]].filter(([k])=>k in limits).map(([k,t])=>({label:x.t(t),value:limits[k]===null?x.t("unlimited"):str(limits,k)??x.t("unlimited")}))}),bool(p,"subscribable")&&onSend&&jsx6(Button,{size:"sm",variant:popular?"primary":"outline",disabled:!canBuy,onClick:()=>subscribe(p),className:"mt-auto",children:x.t("subscribe")})]},id??i)})})]})})}function SubscriptionBlock({data}){const x=useShihabText();const s=obj(data);const status=str(s,"status")??(bool(s,"expired")?"expired":bool(s,"paymentPending")?"pending":"active");const renews=date(s,"renewsAt","endDate");const rawInterval=str(s,"interval","period");const interval=rawInterval==="monthly"?x.t("perMonth"):rawInterval==="yearly"?x.t("perYear"):rawInterval;const price=num(s,"price");const up=obj(s.pendingUpgrade);const upStart=date(up,"startDate");const features=strs(s,"promotedFeatures");return jsx6(BlockCard,{icon:Upgrade,title:str(s,"plan","planTitle")??x.label("blockTitle","subscription"),children:jsxs6(Body,{children:[jsx6("span",{className:"flex flex-wrap gap-1.5",children:jsx6(Pill,{tone:x.tone("subscriptionStatus",status),children:x.label("subscriptionStatus",status)})}),jsx6(Facts,{items:[price!==void 0&&{label:x.label("blockTitle","plans"),value:jsxs6("span",{className:"inline-flex items-baseline gap-1",children:[jsx6(Price,{value:price}),interval&&jsxs6("span",{className:"text-caption text-muted",children:["/ ",interval]})]})},renews&&{label:x.t("renews"),value:formatDate(renews,x.locale)}]}),str(up,"planTitle")&&jsxs6("p",{className:"m-0 rounded-field bg-soft px-3 py-2 text-caption text-brand-ink",children:[x.t("upgradeTo"),str(up,"planTitle"),upStart&&` \xB7 ${x.t("startsOn")} ${formatDate(upStart,x.locale)}`]}),features.length>0&&jsx6("span",{className:"flex flex-wrap gap-1.5",children:features.map(f=>jsx6(Pill,{children:f},f))})]})})}var SUPPORT_ICON={whatsapp:SocialWhatsapp,phone:Phone,email:Email,chat:Chat};function SupportBlock({data}){const x=useShihabText();const d=obj(data);const items=list(data).filter(m=>isSafeUrl(str(m,"actionUrl")));return jsx6(BlockCard,{icon:Support,title:str(d,"title")??x.label("blockTitle","support-methods"),children:jsxs6(Body,{children:[jsx6("div",{className:"grid grid-cols-1 @md:grid-cols-2 gap-2",children:items.map((m,i)=>{const type=(str(m,"type")??"chat").toLowerCase();const Icon=SUPPORT_ICON[type]??Support;const url=str(m,"actionUrl");const external=/^https?:/i.test(url);return jsxs6("a",{href:url,...external?{target:"_blank",rel:"noopener noreferrer"}:{},className:cn("min-w-0 flex items-center gap-3 p-3 rounded-card border border-line bg-surface no-underline","transition-colors hover:border-brand hover:bg-soft","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:[jsx6(BrandIcon,{icon:Icon,size:34}),jsxs6("span",{className:"min-w-0 flex flex-col gap-0.5",children:[jsx6("span",{className:"text-ui font-bold text-ink truncate",children:str(m,"label")??x.label("supportType",type)}),str(m,"value")&&jsx6("span",{dir:"ltr",className:"text-micro text-muted truncate text-start",children:str(m,"value")})]})]},i)})}),str(d,"footer")&&jsx6("p",{className:"m-0 text-caption font-bold text-ink2",children:str(d,"footer")})]})})}function isSafeUrl(u){return!!u&&/^(https:|tel:|mailto:)/i.test(u)}import{Fragment as Fragment7,jsx as jsx7,jsxs as jsxs7}from"react/jsx-runtime";var RENDERERS={action_confirm:ConfirmBlock,orders:OrdersBlock,order:OrderBlock,"order-timeline":TimelineBlock,"checkout-leads":LeadsBlock,"sales-summary":SalesSummaryBlock,insights:InsightsBlock,chart:ChartBlock,"ql-result":QlResultBlock,products:ProductsBlock,product:ProductBlock,collections:CollectionsBlock,inventory:InventoryBlock,reviews:ReviewsBlock,media:MediaBlock,"blog-posts":BlogPostsBlock,"blog-post":BlogPostBlock,"blog-categories":BlogCategoriesBlock,customers:CustomersBlock,offers:OffersBlock,coupons:CouponsBlock,markets:MarketsBlock,locations:LocationsBlock,menus:MenusBlock,countries:CountriesBlock,provinces:ProvincesBlock,"shipping-profiles":ShippingProfilesBlock,"shipping-zones":ShippingZonesBlock,"shipping-rates":ShippingRatesBlock,carriers:CarriersBlock,plans:PlansBlock,subscription:SubscriptionBlock,"support-methods":SupportBlock};var SINGLE=new Set(["action_confirm","order","product","sales-summary","insights","chart","ql-result","blog-post","subscription"]);function ShihabReply({text,onSend,hrefFor,linkAs,live=false,answer,renderMermaid,onInvalid,className}){const segments=useMemo(()=>parseShihab(text),[text]);const ctx=useMemo(()=>({onSend,hrefFor,Link:linkAs,live,answer,renderMermaid}),[onSend,hrefFor,linkAs,live,answer,renderMermaid]);useEffect2(()=>{if(!onInvalid)return;for(const s of segments){if(s.kind==="invalid")onInvalid(s.type,s.raw);if(s.kind==="leak")onInvalid("leak",JSON.stringify(s.data))}},[segments,onInvalid]);return jsx7(ShihabContext.Provider,{value:ctx,children:jsx7("div",{className:cn("min-w-0 flex flex-col gap-2.5 text-ui text-ink leading-relaxed",className),children:segments.map((s,i)=>jsx7(Segment,{s},i))})})}function Segment({s}){const x=useShihabText();const ctx=useShihab();switch(s.kind){case"markdown":return jsx7("div",{dir:"auto",className:"min-w-0 [overflow-wrap:anywhere]",children:jsx7(Markdown,{md:s.text})});case"block":{if(!SINGLE.has(s.type)&&list(s.data).length===0){const title=str(obj(s.data),"title");return jsxs7("p",{className:"m-0 text-caption text-muted",children:[title?`${title} \u2014 `:"",x.t("empty")]})}const Block=RENDERERS[s.type];return jsx7(Block,{data:s.data})}case"leak":return jsx7(LeakBlock,{data:s.data});case"pending":return jsx7(PendingBlock,{type:s.type});case"mermaid":return ctx.renderMermaid?jsx7(Fragment7,{children:ctx.renderMermaid(s.code)}):jsx7(Code,{code:s.code});case"code":return jsx7(Code,{code:s.code});case"invalid":return jsxs7("p",{role:"note",className:"m-0 flex items-center gap-2 rounded-field bg-hover px-3 py-2 text-caption text-muted",children:[jsx7(UiAlert2,{size:14,"aria-hidden":"true",injectStyles:false,className:"shrink-0"}),x.t("invalid")]})}}function PendingBlock({type}){const x=useShihabText();return jsx7(BlockCard,{title:x.label("blockTitle",type)??x.t("preparing"),children:jsxs7("div",{"aria-busy":"true",className:"px-3.5 pb-3.5 flex flex-col gap-3",children:[jsx7("span",{className:"sr-only",children:x.t("preparing")}),[0,1,2].map(i=>jsxs7("span",{className:"flex items-center gap-3",children:[jsx7(Skeleton,{variant:"circle",className:"size-10 rounded-sm"}),jsxs7("span",{className:"flex-1 flex flex-col gap-1.5",children:[jsx7(Skeleton,{width:i===1?"55%":"70%"}),jsx7(Skeleton,{width:"35%",className:"h-2.5"})]})]},i))]})})}function LeakBlock({data}){const items=list(data);return jsx7(BlockCard,{icon:ViewList2,title:str(obj(data),"title"),count:items.length,footer:str(obj(data),"footer"),children:jsx7(Rows,{children:items.map((it,i)=>jsx7(Row,{title:str(it,"title","name","label","customerName","orderId","phone")??"\u2014",sub:str(it,"summary","description","status")},i))})})}function Code({code}){return jsx7("pre",{dir:"ltr",className:"m-0 max-w-full overflow-x-auto rounded-field bg-code-bg px-3 py-2.5 text-caption font-mono text-code-plain text-start",children:jsx7("code",{children:code})})}export{SHIHAB_BLOCKS,ShihabReply,isShihabBlock,parseShihab};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qumra/fanar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Qumra's Arabic-first component library and design tokens. Tailwind 4, RSC-safe.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"globals": "^17.11.0",
|
|
89
89
|
"happy-dom": "^20.11.6",
|
|
90
90
|
"prettier": "^3.9.6",
|
|
91
|
+
"qumra-icons": "^1.15.0",
|
|
91
92
|
"react": "^19.2.8",
|
|
92
93
|
"react-dom": "^19.2.8",
|
|
93
94
|
"size-limit": "^13.0.3",
|
|
@@ -136,6 +137,7 @@
|
|
|
136
137
|
"@react-three/fiber": ">=9.0.0",
|
|
137
138
|
"@types/react": "^19.0.0",
|
|
138
139
|
"@types/react-dom": "^19.0.0",
|
|
140
|
+
"qumra-icons": "^1.13.0",
|
|
139
141
|
"react": "^19.0.0",
|
|
140
142
|
"react-dom": "^19.0.0",
|
|
141
143
|
"tailwindcss": "^4.0.0",
|
|
@@ -160,6 +162,9 @@
|
|
|
160
162
|
"@types/react-dom": {
|
|
161
163
|
"optional": true
|
|
162
164
|
},
|
|
165
|
+
"qumra-icons": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
163
168
|
"tailwindcss": {
|
|
164
169
|
"optional": true
|
|
165
170
|
},
|
package/dist/chunk-4NDBVW4K.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{cn,useUIText}from"./chunk-YJ45RGS6.js";import{Star}from"lucide-react";import{jsx,jsxs}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 jsxs("span",{className:cn("flex items-center gap-0.5 shrink-0",className),children:[jsx("span",{className:"sr-only",children:`${n} / ${MAX}`}),Array.from({length:MAX},(_,i)=>jsx(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 jsxs("span",{className:cn("flex items-center gap-1",className),children:[Array.from({length:MAX},(_,i)=>{const n=i+1;return jsx("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:jsx(Star,{size:22,"aria-hidden":"true",className:cn("shrink-0",n<=value?"fill-amber text-amber":"text-muted2")})},n)}),!hideValue&&value>0&&jsx("span",{"data-numeric":true,className:"ms-2 text-caption font-bold text-muted",children:`${value}/${MAX}`})]})}export{Stars,RatingInput};
|