@qumra/fanar 0.0.32 → 0.0.33

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/shihab.js ADDED
@@ -0,0 +1,2 @@
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qumra/fanar",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "type": "module",
5
5
  "description": "Qumra's Arabic-first component library and design tokens. Tailwind 4, RSC-safe.",
6
6
  "license": "UNLICENSED",
@@ -45,6 +45,10 @@
45
45
  "types": "./dist/ai.d.ts",
46
46
  "import": "./dist/ai.js"
47
47
  },
48
+ "./shihab": {
49
+ "types": "./dist/shihab.d.ts",
50
+ "import": "./dist/shihab.js"
51
+ },
48
52
  "./editor.css": "./dist/editor.css",
49
53
  "./tokens.css": "./dist/tokens.css",
50
54
  "./tokens.json": "./dist/tokens.json",
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{buttonClasses,cn,toLatinDigits,useUIText}from"./chunk-YJ45RGS6.js";import{forwardRef}from"react";import{Loader2}from"lucide-react";import{jsx,jsxs}from"react/jsx-runtime";var ICON_ONLY={sm:"w-9 px-0!",md:"w-10 px-0!",lg:"w-12 px-0!",xl:"w-14 px-0!"};var SPINNER={sm:14,md:15,lg:17,xl:20};var Button=forwardRef(function Button2({variant="primary",size="md",icon,iconEnd,iconOnly,loading,block,disabled,className,children,type="button",...rest},ref){return jsxs("button",{ref,type,disabled:disabled||loading,"aria-busy":loading||void 0,className:buttonClasses(variant,size,cn("disabled:opacity-50 disabled:cursor-not-allowed",iconOnly&&ICON_ONLY[size],block&&"w-full",className)),...rest,children:[loading?jsx(Loader2,{size:SPINNER[size],className:"animate-spin shrink-0","aria-hidden":"true"}):icon&&jsx("span",{className:"flex shrink-0",children:icon}),!iconOnly&&children,!loading&&iconEnd&&jsx("span",{className:"flex shrink-0",children:iconEnd})]})});import{useMemo,useState}from"react";import{ChevronLeft,ChevronRight}from"lucide-react";import{Fragment,jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";var MONTHS_AR=["\u064A\u0646\u0627\u064A\u0631","\u0641\u0628\u0631\u0627\u064A\u0631","\u0645\u0627\u0631\u0633","\u0623\u0628\u0631\u064A\u0644","\u0645\u0627\u064A\u0648","\u064A\u0648\u0646\u064A\u0648","\u064A\u0648\u0644\u064A\u0648","\u0623\u063A\u0633\u0637\u0633","\u0633\u0628\u062A\u0645\u0628\u0631","\u0623\u0643\u062A\u0648\u0628\u0631","\u0646\u0648\u0641\u0645\u0628\u0631","\u062F\u064A\u0633\u0645\u0628\u0631"];var WEEKDAYS_AR=["\u0633","\u062D","\u0646","\u062B","\u0631","\u062E","\u062C"];var weekIndex=d=>(d.getDay()+1)%7;var sameDay=(a,b)=>a.getFullYear()===b.getFullYear()&&a.getMonth()===b.getMonth()&&a.getDate()===b.getDate();var startOfDay=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate());function monthCells(month){const first=new Date(month.getFullYear(),month.getMonth(),1);const total=new Date(month.getFullYear(),month.getMonth()+1,0).getDate();return[...Array.from({length:weekIndex(first)},()=>null),...Array.from({length:total},(_,i)=>new Date(month.getFullYear(),month.getMonth(),i+1))]}function daysBetween(from,to){return Math.round((startOfDay(to).getTime()-startOfDay(from).getTime())/864e5)+1}function formatDate(d){return`${d.getDate()} ${MONTHS_AR[d.getMonth()]}`}function formatRange(r){if(!r.from)return"\u0627\u062E\u062A\u0631 \u064A\u0648\u0645 \u0627\u0644\u0628\u062F\u0627\u064A\u0629";if(!r.to)return`${formatDate(r.from)} \u2014 \u0627\u062E\u062A\u0631 \u064A\u0648\u0645 \u0627\u0644\u0646\u0647\u0627\u064A\u0629`;if(sameDay(r.from,r.to))return formatDate(r.from);return`${formatDate(r.from)} \u2014 ${formatDate(r.to)}`}function presets(today){const mk=backDays=>{const to=startOfDay(today);const from=new Date(to);from.setDate(from.getDate()-backDays+1);return{from,to}};return[{key:"today",label:"\u0627\u0644\u0646\u0647\u0627\u0631\u062F\u0647",range:mk(1)},{key:"d7",label:"\u0622\u062E\u0631 \u0667 \u0623\u064A\u0627\u0645",range:mk(7)},{key:"d30",label:"\u0622\u062E\u0631 \u0663\u0660 \u064A\u0648\u0645",range:mk(30)},{key:"month",label:"\u0627\u0644\u0634\u0647\u0631 \u062F\u0647",range:{from:new Date(today.getFullYear(),today.getMonth(),1),to:startOfDay(today)}}]}function DateRangePicker({value,onChange,month,onMonthChange,today,className}){const[hover,setHover]=useState(null);const cells=useMemo(()=>monthCells(month),[month]);const provisionalTo=value.from&&!value.to?hover:value.to;function inRange(d){if(!value.from||!provisionalTo)return false;const[a,b]=value.from<=provisionalTo?[value.from,provisionalTo]:[provisionalTo,value.from];return d>=startOfDay(a)&&d<=startOfDay(b)}function pick(d){if(!value.from||value.to)return onChange({from:d,to:null});if(d<value.from)return onChange({from:d,to:value.from});onChange({from:value.from,to:d})}const shift=by=>onMonthChange(new Date(month.getFullYear(),month.getMonth()+by,1));return jsxs2("div",{className:cn("flex flex-col gap-3",className),children:[jsx2(MonthNav,{month,onShift:shift}),jsxs2("div",{className:"grid grid-cols-7 gap-0.5",role:"grid",children:[jsx2(Weekdays,{}),cells.map((d,i)=>{if(!d)return jsx2("span",{},`p${i}`);const isFrom=value.from&&sameDay(d,value.from);const isTo=provisionalTo&&sameDay(d,provisionalTo);const edge=isFrom||isTo;const mid=inRange(d)&&!edge;const isToday=sameDay(d,today);return jsxs2("button",{type:"button",onClick:()=>pick(d),onMouseEnter:()=>setHover(d),"aria-pressed":Boolean(edge||mid),className:cn("h-9 flex items-center justify-center text-ui font-bold cursor-pointer transition-colors relative",mid&&"bg-soft text-brand-ink rounded-none",edge&&"bg-brand text-white rounded-sm z-10",!edge&&!mid&&"text-ink2 rounded-sm hover:bg-hover",isToday&&!edge&&"text-brand-ink"),children:[jsx2("span",{"data-num":true,children:d.getDate()}),isToday&&!edge&&jsx2("span",{"aria-hidden":"true",className:"absolute bottom-1 size-1 rounded-full bg-brand"})]},d.toISOString())})]})]})}function MonthNav({month,onShift}){const ui=useUIText();return jsxs2("div",{className:"flex items-center justify-between gap-3",children:[jsx2("button",{type:"button",onClick:()=>onShift(-1),"aria-label":ui.previousMonth,className:"size-8 rounded-sm flex items-center justify-center text-muted cursor-pointer transition-colors hover:bg-hover hover:text-ink",children:jsx2(ChevronRight,{size:16,"aria-hidden":"true"})}),jsxs2("span",{className:"text-body font-extrabold text-ink",children:[MONTHS_AR[month.getMonth()]," ",jsx2("span",{"data-num":true,children:month.getFullYear()})]}),jsx2("button",{type:"button",onClick:()=>onShift(1),"aria-label":ui.nextMonth,className:"size-8 rounded-sm flex items-center justify-center text-muted cursor-pointer transition-colors hover:bg-hover hover:text-ink",children:jsx2(ChevronLeft,{size:16,"aria-hidden":"true"})})]})}function Weekdays(){return jsx2(Fragment,{children:WEEKDAYS_AR.map((w,i)=>jsx2("span",{className:"h-7 flex items-center justify-center text-micro font-bold text-muted2",children:w},i))})}function Calendar({value,onChange,month,onMonthChange,today,min,max,className}){const cells=useMemo(()=>monthCells(month),[month]);const shift=by=>onMonthChange(new Date(month.getFullYear(),month.getMonth()+by,1));function blocked(d){if(min&&startOfDay(d)<startOfDay(min))return true;if(max&&startOfDay(d)>startOfDay(max))return true;return false}return jsxs2("div",{className:cn("flex flex-col gap-3",className),children:[jsx2(MonthNav,{month,onShift:shift}),jsxs2("div",{className:"grid grid-cols-7 gap-0.5",role:"grid",children:[jsx2(Weekdays,{}),cells.map((d,i)=>{if(!d)return jsx2("span",{},`p${i}`);const picked=Boolean(value&&sameDay(d,value));const isToday=sameDay(d,today);const off=blocked(d);return jsxs2("button",{type:"button",onClick:()=>!off&&onChange(d),"aria-pressed":picked,"aria-disabled":off||void 0,className:cn("h-9 flex items-center justify-center text-ui font-bold rounded-sm transition-colors relative",off?"text-muted2 opacity-45 cursor-not-allowed":picked?"bg-brand text-white cursor-pointer":cn("text-ink2 cursor-pointer hover:bg-hover",isToday&&"text-brand-ink")),children:[jsx2("span",{"data-num":true,children:d.getDate()}),isToday&&!picked&&jsx2("span",{"aria-hidden":"true",className:"absolute bottom-1 size-1 rounded-full bg-brand"})]},d.toISOString())})]})]})}import{forwardRef as forwardRef2,useCallback,useEffect,useId,useRef,useState as useState2}from"react";import{createPortal}from"react-dom";import{AlertCircle,CalendarDays,Check,ChevronDown,Minus,Search,X}from"lucide-react";import{jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";function FieldShell({id,label,labelAside,labelSize,hint,error,required,hideLabel,className,children}){const labelEl=label&&jsxs3("label",{id:`${id}-label`,htmlFor:id,className:cn(labelSize??"text-ui","font-bold text-ink2",hideLabel&&"sr-only"),children:[label,required&&jsx3("span",{className:"text-danger ms-1","aria-hidden":"true",children:"*"})]});return jsxs3("div",{className:cn("flex flex-col gap-1.5",className),children:[labelAside?jsxs3("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[labelEl,labelAside]}):labelEl,children,error?jsxs3("span",{id:`${id}-error`,role:"alert",className:"flex items-center gap-1.5 text-caption text-red",children:[jsx3(AlertCircle,{size:12,className:"shrink-0","aria-hidden":"true"}),error]}):hint?jsx3("span",{id:`${id}-hint`,className:"text-caption text-muted",children:hint}):null]})}var SIZES={sm:"h-9 text-ui",md:"h-11 text-body",lg:"h-14 text-base border-[1.5px]!"};var base=invalid=>cn("w-full bg-surface text-ink rounded-field border transition-colors outline-none","placeholder:text-muted2","focus:border-brand","disabled:bg-bg disabled:text-muted disabled:cursor-not-allowed",invalid?"border-danger":"border-border hover:border-brand");var Input=forwardRef2(function Input2({label,labelAside,hint,error,size="md",hideLabel,icon,suffix,action,numeric,required,className,wrapperClassName,id:idProp,onChange,type,inputMode,...rest},ref){const auto=useId();const id=idProp??auto;const invalid=Boolean(error);const lg=size==="lg";return jsx3(FieldShell,{id,label,labelAside,labelSize:lg?"text-body":void 0,hint,error,required,hideLabel,className:wrapperClassName,children:jsxs3("div",{className:"relative flex items-center",children:[icon&&jsx3("span",{className:cn("absolute flex text-muted pointer-events-none",lg?"start-4.5":"start-3.5"),"aria-hidden":"true",children:icon}),jsx3("input",{ref,id,required,type:numeric?"text":type,inputMode:numeric?inputMode??"decimal":inputMode,"aria-invalid":invalid||void 0,"aria-describedby":error?`${id}-error`:hint?`${id}-hint`:void 0,"data-num":numeric||void 0,"data-suffix":numeric&&suffix?"":void 0,"data-icon":numeric&&icon?"":void 0,onChange:numeric?e=>{const fixed=toLatinDigits(e.target.value);if(fixed!==e.target.value)e.target.value=fixed;onChange?.(e)}:onChange,className:cn(base(invalid),SIZES[size],lg?"px-4.5":"px-3.5",icon&&(lg?"ps-12":"ps-10"),suffix&&"pe-14",action&&(lg?"pe-14":"pe-11"),className),...rest}),suffix&&jsx3("span",{className:cn("absolute text-ui text-muted pointer-events-none",lg?"end-4.5":"end-3.5"),children:suffix}),action&&jsx3("span",{className:cn("absolute flex",lg?"end-4":"end-3"),children:action})]})})});var SearchInput=forwardRef2(function SearchInput2(props,ref){return jsx3(Input,{ref,icon:jsx3(Search,{size:16}),hideLabel:true,...props})});var Textarea=forwardRef2(function Textarea2({label,hint,error,required,hideLabel,rows=3,className,wrapperClassName,id:idProp,...rest},ref){const auto=useId();const id=idProp??auto;return jsx3(FieldShell,{id,label,hint,error,required,hideLabel,className:wrapperClassName,children:jsx3("textarea",{ref,id,rows,required,"aria-invalid":Boolean(error)||void 0,className:cn(base(Boolean(error)),"text-body px-3.5 py-3 resize-y min-h-20",className),...rest})})});var Select=forwardRef2(function Select2({label,hint,error,size="md",hideLabel,options,required,className,wrapperClassName,id:idProp,...rest},ref){const auto=useId();const id=idProp??auto;return jsx3(FieldShell,{id,label,hint,error,required,hideLabel,className:wrapperClassName,children:jsxs3("div",{className:"relative flex items-center",children:[jsx3("select",{ref,id,required,className:cn(base(Boolean(error)),SIZES[size],"appearance-none ps-3.5 pe-9 cursor-pointer font-medium",className),...rest,children:options.map(o=>jsx3("option",{value:o.value,children:o.label},o.value))}),jsx3(ChevronDown,{size:15,"aria-hidden":"true",className:"absolute end-3.5 text-muted2 pointer-events-none"})]})})});var CONTROL="peer appearance-none size-[19px] shrink-0 bg-surface border-[1.5px] border-border cursor-pointer transition-colors checked:bg-brand checked:border-brand hover:border-brand focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand disabled:bg-bg disabled:cursor-not-allowed";var Checkbox=forwardRef2(function Checkbox2({label,description,indeterminate,className,id:idProp,...rest},ref){const auto=useId();const id=idProp??auto;return jsxs3("span",{className:"flex items-start gap-2.5",children:[jsxs3("span",{className:"relative inline-flex items-center justify-center mt-px",children:[jsx3("input",{ref:el=>{if(el)el.indeterminate=Boolean(indeterminate);if(typeof ref==="function")ref(el);else if(ref)ref.current=el},id,type:"checkbox",className:cn(CONTROL,"rounded-xs",indeterminate&&"bg-brand border-brand",className),...rest}),indeterminate?jsx3(Minus,{size:12,strokeWidth:3,"aria-hidden":"true",className:"absolute text-white pointer-events-none"}):jsx3(Check,{size:12,strokeWidth:3,"aria-hidden":"true",className:"absolute text-white opacity-0 peer-checked:opacity-100 pointer-events-none transition-opacity"})]}),(label||description)&&jsxs3("label",{htmlFor:id,className:"flex flex-col gap-0.5 cursor-pointer select-none",children:[label&&jsx3("span",{className:"text-body text-ink",children:label}),description&&jsx3("span",{className:"text-caption text-muted",children:description})]})]})});var Radio=forwardRef2(function Radio2({label,description,className,id:idProp,...rest},ref){const auto=useId();const id=idProp??auto;return jsxs3("span",{className:"flex items-start gap-2.5",children:[jsxs3("span",{className:"relative inline-flex items-center justify-center mt-px",children:[jsx3("input",{ref,id,type:"radio",className:cn(CONTROL,"rounded-full",className),...rest}),jsx3("span",{"aria-hidden":"true",className:"absolute size-1.5 rounded-full bg-white opacity-0 peer-checked:opacity-100 pointer-events-none transition-opacity"})]}),(label||description)&&jsxs3("label",{htmlFor:id,className:"flex flex-col gap-0.5 cursor-pointer select-none",children:[label&&jsx3("span",{className:"text-body text-ink",children:label}),description&&jsx3("span",{className:"text-caption text-muted",children:description})]})]})});function RadioGroup({label,children,inline}){return jsxs3("fieldset",{className:"flex flex-col gap-2.5 border-0 p-0 m-0",children:[jsx3("legend",{className:"text-ui font-bold text-ink2 p-0 mb-1",children:label}),jsx3("div",{className:cn("flex gap-3",inline?"flex-row flex-wrap gap-5":"flex-col"),children})]})}function Switch({checked,onCheckedChange,label,description,disabled,id:idProp}){const auto=useId();const id=idProp??auto;const control=jsx3("button",{id,type:"button",role:"switch","aria-checked":checked,"aria-labelledby":label?`${id}-label`:void 0,disabled,onClick:()=>onCheckedChange(!checked),className:cn("relative shrink-0 w-11 h-6 rounded-full cursor-pointer transition-colors duration-200","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand","disabled:opacity-50 disabled:cursor-not-allowed",checked?"bg-brand":"bg-border"),children:jsx3("span",{"aria-hidden":"true",className:cn("absolute top-1/2 -translate-y-1/2 size-5 rounded-full bg-white shadow-sm transition-all duration-200",checked?"start-[calc(100%-1.375rem)]":"start-0.5")})});if(!label)return control;return jsxs3("span",{className:"flex items-start gap-3",children:[control,jsxs3("span",{className:"flex flex-col gap-0.5",children:[jsx3("span",{id:`${id}-label`,className:"text-body text-ink",children:label}),description&&jsx3("span",{className:"text-caption text-muted",children:description})]})]})}var pad2=n=>String(n).padStart(2,"0");function toValue(d,time){const day=`${d.getFullYear()}-${pad2(d.getMonth()+1)}-${pad2(d.getDate())}`;return time?`${day}T${time}`:day}function fromValue(v){const m=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(v.trim());if(!m)return{day:null,time:""};const day=new Date(Number(m[1]),Number(m[2])-1,Number(m[3]));return{day:Number.isNaN(day.getTime())?null:day,time:m[4]?`${m[4]}:${m[5]}`:""}}var EDGE=8;var GAP=6;function DateField({value,onChange,withTime=false,min,max,label,hint,error,required,hideLabel,placeholder,disabled,size="md",id:idProp,className}){const ui=useUIText();const auto=useId();const id=idProp??auto;const invalid=Boolean(error);const lg=size==="lg";const{day,time}=fromValue(value);const[open,setOpen]=useState2(false);const[month,setMonth]=useState2(()=>startOfMonth(day??new Date));const anchor=useRef(null);const panel=useRef(null);const[wasOpen,setWasOpen]=useState2(open);if(wasOpen!==open){setWasOpen(open);if(open)setMonth(startOfMonth(day??new Date))}const place=useCallback(()=>{const el=panel.current;const host=anchor.current;if(!el||!host)return;const r=host.getBoundingClientRect();const w=el.offsetWidth;const h=el.offsetHeight;const vw=document.documentElement.clientWidth;const vh=document.documentElement.clientHeight;const left=Math.min(Math.max(r.left,EDGE),Math.max(EDGE,vw-EDGE-w));const below=r.bottom+GAP+h<=vh-EDGE;const top=below?r.bottom+GAP:Math.max(EDGE,r.top-GAP-h);el.style.left=`${left}px`;el.style.top=`${top}px`;el.style.visibility="visible"},[]);useEffect(()=>{if(!open)return;window.addEventListener("scroll",place,{capture:true,passive:true});window.addEventListener("resize",place,{passive:true});return()=>{window.removeEventListener("scroll",place,{capture:true});window.removeEventListener("resize",place)}},[open,place]);useEffect(()=>{if(!open)return;function onDown(e){const t=e.target;if(panel.current?.contains(t)||anchor.current?.contains(t))return;setOpen(false)}function onKey(e){if(e.key==="Escape")setOpen(false)}document.addEventListener("mousedown",onDown);document.addEventListener("keydown",onKey);return()=>{document.removeEventListener("mousedown",onDown);document.removeEventListener("keydown",onKey)}},[open]);const mount=useCallback(el=>{panel.current=el;if(el)place()},[place]);function pickDay(d){onChange(toValue(d,withTime?time||"00:00":null));if(!withTime)setOpen(false)}function pickTime(next){onChange(toValue(day??new Date,next||"00:00"))}function pickNow(){const d=new Date;onChange(toValue(d,withTime?`${pad2(d.getHours())}:${pad2(d.getMinutes())}`:null));if(!withTime)setOpen(false)}return jsx3(FieldShell,{id,label,labelSize:lg?"text-body":void 0,hint,error,required,hideLabel,className,children:jsxs3("div",{ref:anchor,className:"relative flex items-center",children:[jsxs3("button",{type:"button",id,disabled,onClick:()=>setOpen(o=>!o),"aria-haspopup":"dialog","aria-expanded":open,"aria-labelledby":label?`${id}-label ${id}-value`:`${id}-value`,"aria-describedby":error?`${id}-error`:hint?`${id}-hint`:void 0,className:cn(base(invalid),SIZES[size],lg?"px-4.5":"px-3.5","flex items-center gap-2 text-start cursor-pointer","disabled:cursor-not-allowed"),children:[jsx3(CalendarDays,{size:lg?18:16,className:"shrink-0 text-muted","aria-hidden":"true"}),jsx3("span",{id:`${id}-value`,className:cn("flex-1 min-w-0 truncate",!day&&"text-muted2"),children:day?jsx3("span",{"data-num":true,children:withTime&&time?`${labelOf(day)} \xB7 ${time}`:labelOf(day)}):placeholder??ui.pickDate}),day&&!disabled&&jsx3("span",{role:"button",tabIndex:0,"aria-label":ui.clear,onClick:e=>{e.stopPropagation();onChange("")},onKeyDown:e=>{if(e.key!=="Enter"&&e.key!==" ")return;e.preventDefault();e.stopPropagation();onChange("")},className:"shrink-0 size-5 rounded-xs flex items-center justify-center text-muted transition-colors hover:bg-hover hover:text-ink",children:jsx3(X,{size:13,"aria-hidden":"true"})})]}),open&&typeof document!=="undefined"&&createPortal(jsxs3("div",{ref:mount,role:"dialog","aria-label":typeof label==="string"?label:ui.pickDate,style:{visibility:"hidden",left:0,top:0},className:cn("fixed z-[60] w-[19rem] p-3 rounded-card","bg-surface border border-line shadow-modal animate-[fade-in_.12s_ease-out]"),children:[jsx3(Calendar,{value:day,onChange:pickDay,month,onMonthChange:setMonth,today:new Date,min:min?fromValue(min).day:null,max:max?fromValue(max).day:null}),withTime&&jsxs3("label",{className:"mt-3 pt-3 border-t border-line flex items-center justify-between gap-3",children:[jsx3("span",{className:"text-caption font-bold text-ink2",children:ui.time}),jsx3("input",{type:"time",value:time,onChange:e=>pickTime(e.target.value),className:cn(base(false),"h-9 w-32 px-2.5 text-ui")})]}),jsxs3("div",{className:"mt-3 flex items-center justify-between gap-2",children:[jsx3("button",{type:"button",onClick:pickNow,className:"px-2.5 h-8 rounded-sm text-caption font-bold text-brand-ink cursor-pointer transition-colors hover:bg-hover",children:withTime?ui.now:ui.today}),jsx3("button",{type:"button",onClick:()=>setOpen(false),className:"px-2.5 h-8 rounded-sm text-caption font-bold text-muted cursor-pointer transition-colors hover:bg-hover hover:text-ink",children:ui.close})]})]}),document.body)]})})}var startOfMonth=d=>new Date(d.getFullYear(),d.getMonth(),1);function labelOf(d){return`${d.getDate()} ${MONTHS_AR[d.getMonth()]} ${d.getFullYear()}`}export{Button,daysBetween,formatDate,formatRange,presets,DateRangePicker,Calendar,Input,SearchInput,Textarea,Select,Checkbox,Radio,RadioGroup,Switch,DateField};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{Coach,useCoachOptional}from"./chunk-JOHJNMV2.js";import{LocaleCtx,cn,useMoneyLocale,useUIText}from"./chunk-YJ45RGS6.js";import{createContext,useContext}from"react";import{Fragment,jsx,jsxs}from"react/jsx-runtime";function Glyph({children,label,w=24}){return jsx("svg",{viewBox:`0 0 ${w} 24`,width:`${w/24}em`,height:"1em",fill:"none",stroke:"currentColor",strokeWidth:2.1,strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":label,className:"inline-block shrink-0 translate-y-[0.1em]",children})}var Dollar=jsxs(Glyph,{label:"\u062F\u0648\u0644\u0627\u0631",children:[jsx("path",{d:"M12 2.5v19"}),jsx("path",{d:"M16.5 7c0-1.9-2-3.2-4.5-3.2S7.5 5.1 7.5 7s2 2.8 4.5 3.4 4.5 1.5 4.5 3.4-2 3.2-4.5 3.2S7.5 15.7 7.5 13.8"})]});var Euro=jsxs(Glyph,{label:"\u064A\u0648\u0631\u0648",children:[jsx("path",{d:"M17.5 6.4A7 7 0 1 0 17.5 17.6"}),jsx("path",{d:"M3.5 10h10"}),jsx("path",{d:"M3.5 14h10"})]});var Pound=jsxs(Glyph,{label:"\u062C\u0646\u064A\u0647",children:[jsx("path",{d:"M16 6.2A3.7 3.7 0 0 0 9 7.8v6.4a5 5 0 0 1-2 4h11"}),jsx("path",{d:"M6 12h7"})]});var EgyptianPound=jsxs(Glyph,{label:"\u062C\u0646\u064A\u0647 \u0645\u0635\u0631\u064A",w:31,children:[jsx("path",{d:"M10.5 6H3.5v12h7"}),jsx("path",{d:"M3.5 12h5.5"}),jsx("path",{d:"M26.5 6.2A3.7 3.7 0 0 0 19.5 7.8v6.4a5 5 0 0 1-2 4h11"}),jsx("path",{d:"M16.5 12h7"})]});var Riyal=jsx("svg",{viewBox:"0 0 24 24",width:"1em",height:"1em",fill:"currentColor",role:"img","aria-label":"\u0631\u064A\u0627\u0644 \u0633\u0639\u0648\u062F\u064A",className:"inline-block shrink-0 translate-y-[0.08em]",children:jsx("path",{d:"M13.89 3.36L13.89 18.83L21.99 17.11C22.37 16.22 22.62 15.31 22.75 14.36L16.43 15.69L16.43 1.24C15.38 1.82 14.53 2.53 13.89 3.36M2.46 16.08L21.99 11.97C22.37 11.04 22.62 10.12 22.75 9.19L3.19 13.33C2.77 14.24 2.52 15.15 2.46 16.08M13.89 24.0L21.99 22.28C22.37 21.37 22.62 20.45 22.75 19.53L14.58 21.25C14.4 21.65 14.25 22.09 14.13 22.55C14.01 23.01 13.93 23.5 13.89 24.0M1.25 22.22L8.42 20.64C8.98 20.52 9.45 20.21 9.81 19.71L11.14 17.77C11.2 17.67 11.25 17.56 11.29 17.44C11.33 17.32 11.35 17.2 11.35 17.08L11.35 0.0C10.38 0.56 9.54 1.27 8.81 2.12L8.81 18.02L1.98 19.47C1.54 20.47 1.29 21.39 1.25 22.22"})});var CURRENCY={SAR:{short:"\u0631.\u0633",word:"\u0631\u064A\u0627\u0644",best:"sign",code:"SAR",sign:Riyal,name:"\u0631\u064A\u0627\u0644 \u0633\u0639\u0648\u062F\u064A",en:"Saudi riyals",decimals:2},AED:{short:"\u062F.\u0625",word:"\u062F\u0631\u0647\u0645",best:"word",code:"AED",sign:null,name:"\u062F\u0631\u0647\u0645 \u0625\u0645\u0627\u0631\u0627\u062A\u064A",en:"UAE dirhams",decimals:2},QAR:{short:"\u0631.\u0642",word:"\u0631\u064A\u0627\u0644",best:"word",code:"QAR",sign:null,name:"\u0631\u064A\u0627\u0644 \u0642\u0637\u0631\u064A",en:"Qatari riyals",decimals:2},KWD:{short:"\u062F.\u0643",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"KWD",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u0643\u0648\u064A\u062A\u064A",en:"Kuwaiti dinars",decimals:3},BHD:{short:"\u062F.\u0628",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"BHD",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u0628\u062D\u0631\u064A\u0646\u064A",en:"Bahraini dinars",decimals:3},OMR:{short:"\u0631.\u0639",word:"\u0631\u064A\u0627\u0644",best:"word",code:"OMR",sign:null,name:"\u0631\u064A\u0627\u0644 \u0639\u0645\u0627\u0646\u064A",en:"Omani riyals",decimals:3},EGP:{short:"\u062C.\u0645",word:"\u062C\u0646\u064A\u0647",best:"word",code:"EGP",sign:EgyptianPound,name:"\u062C\u0646\u064A\u0647 \u0645\u0635\u0631\u064A",en:"Egyptian pounds",decimals:2},JOD:{short:"\u062F.\u0623",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"JOD",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u0623\u0631\u062F\u0646\u064A",en:"Jordanian dinars",decimals:3},IQD:{short:"\u062F.\u0639",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"IQD",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u0639\u0631\u0627\u0642\u064A",en:"Iraqi dinars",decimals:3},LBP:{short:"\u0644.\u0644",word:"\u0644\u064A\u0631\u0629",best:"word",code:"LBP",sign:null,name:"\u0644\u064A\u0631\u0629 \u0644\u0628\u0646\u0627\u0646\u064A\u0629",en:"Lebanese pounds",decimals:2},SYP:{short:"\u0644.\u0633",word:"\u0644\u064A\u0631\u0629",best:"word",code:"SYP",sign:null,name:"\u0644\u064A\u0631\u0629 \u0633\u0648\u0631\u064A\u0629",en:"Syrian pounds",decimals:2},YER:{short:"\u0631.\u064A",word:"\u0631\u064A\u0627\u0644",best:"word",code:"YER",sign:null,name:"\u0631\u064A\u0627\u0644 \u064A\u0645\u0646\u064A",en:"Yemeni rials",decimals:2},SDG:{short:"\u062C.\u0633",word:"\u062C\u0646\u064A\u0647",best:"word",code:"SDG",sign:null,name:"\u062C\u0646\u064A\u0647 \u0633\u0648\u062F\u0627\u0646\u064A",en:"Sudanese pounds",decimals:2},MAD:{short:"\u062F.\u0645",word:"\u062F\u0631\u0647\u0645",best:"word",code:"MAD",sign:null,name:"\u062F\u0631\u0647\u0645 \u0645\u063A\u0631\u0628\u064A",en:"Moroccan dirhams",decimals:2},DZD:{short:"\u062F.\u062C",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"DZD",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u062C\u0632\u0627\u0626\u0631\u064A",en:"Algerian dinars",decimals:2},TND:{short:"\u062F.\u062A",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"TND",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u062A\u0648\u0646\u0633\u064A",en:"Tunisian dinars",decimals:3},LYD:{short:"\u062F.\u0644",word:"\u062F\u064A\u0646\u0627\u0631",best:"word",code:"LYD",sign:null,name:"\u062F\u064A\u0646\u0627\u0631 \u0644\u064A\u0628\u064A",en:"Libyan dinars",decimals:3},MRU:{short:"\u0623.\u0645",word:"\u0623\u0648\u0642\u064A\u0629",best:"word",code:"MRU",sign:null,name:"\u0623\u0648\u0642\u064A\u0629 \u0645\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u0629",en:"Mauritanian ouguiya",decimals:2},SOS:{short:"\u0634.\u0635",word:"\u0634\u0644\u0646",best:"word",code:"SOS",sign:null,name:"\u0634\u0644\u0646 \u0635\u0648\u0645\u0627\u0644\u064A",en:"Somali shillings",decimals:0},DJF:{short:"\u0641.\u062C",word:"\u0641\u0631\u0646\u0643",best:"word",code:"DJF",sign:null,name:"\u0641\u0631\u0646\u0643 \u062C\u064A\u0628\u0648\u062A\u064A",en:"Djiboutian francs",decimals:0},KMF:{short:"\u0641.\u0642",word:"\u0641\u0631\u0646\u0643",best:"word",code:"KMF",sign:null,name:"\u0641\u0631\u0646\u0643 \u0642\u0645\u0631\u064A",en:"Comorian francs",decimals:0},USD:{short:"$",word:"\u062F\u0648\u0644\u0627\u0631",best:"sign",code:"USD",sign:Dollar,name:"\u062F\u0648\u0644\u0627\u0631 \u0623\u0645\u0631\u064A\u0643\u064A",en:"US dollars",decimals:2},EUR:{short:"\u20AC",word:"\u064A\u0648\u0631\u0648",best:"sign",code:"EUR",sign:Euro,name:"\u064A\u0648\u0631\u0648",en:"euros",decimals:2},GBP:{short:"\xA3",word:"\u0625\u0633\u062A\u0631\u0644\u064A\u0646\u064A",best:"sign",code:"GBP",sign:Pound,name:"\u062C\u0646\u064A\u0647 \u0625\u0633\u062A\u0631\u0644\u064A\u0646\u064A",en:"pounds sterling",decimals:2}};function isCurrency(c){return!!c&&c in CURRENCY}var CurrencyCtx=createContext(null);function MoneyProvider({currency,locale,children}){return jsx(CurrencyCtx.Provider,{value:currency,children:jsx(LocaleCtx.Provider,{value:locale??null,children})})}function useCurrency(){return useContext(CurrencyCtx)??"EGP"}function resolve(style,c,locale){if(style!=="best")return style;if(locale.startsWith("ar"))return c.best;return c.sign?"sign":"code"}var UNIT={short:"text-[0.82em]",word:"text-[0.86em] font-normal tracking-wide",code:"text-[0.78em] font-bold tracking-wide",sign:"text-[0.9em]"};var SIZE={inherit:"",sm:"text-caption",md:"text-ui",lg:"text-body font-extrabold",xl:"text-h2 font-black"};var TONE={inherit:"",muted:"text-muted",ink:"text-ink",green:"text-green",red:"text-red"};function Money({value,currency,size="md",tone="inherit",signed,compact,trimZeros,was,symbol,hideSymbol,className}){const locale=useMoneyLocale();const isEn=locale.startsWith("en");const store=useCurrency();const c=CURRENCY[currency??store];const decimals=c.decimals;const style=resolve(symbol??"best",c,locale);const unit=style==="code"?c.code:style==="word"?c.word:style==="sign"?c.sign??c.short:c.short;return jsxs("span",{className:cn("inline-flex items-baseline gap-1 whitespace-nowrap",SIZE[size],TONE[tone],className),children:[jsx("span",{"data-num":true,children:format(value,decimals,locale,{signed,compact,trimZeros})}),!hideSymbol&&jsxs(Fragment,{children:[jsx("span",{"aria-hidden":"true",className:cn("opacity-65",UNIT[style]),children:unit}),jsx("span",{className:"sr-only",children:locale.startsWith("ar")?c.name:isEn?c.en:c.code})]}),was!==void 0&&was!==value&&jsx("span",{className:"text-[0.82em] text-muted2 line-through decoration-1",children:jsx("span",{"data-num":true,children:format(was,decimals,locale,{compact,trimZeros})})})]})}function format(v,decimals,locale,{signed,compact,trimZeros}){const whole=trimZeros&&Number.isInteger(v);const nf=new Intl.NumberFormat(locale,compact?{notation:"compact",minimumFractionDigits:0,maximumFractionDigits:1}:{minimumFractionDigits:whole?0:decimals,maximumFractionDigits:whole?0:decimals});const sign=v<0?"\u2212":signed&&v>0?"+":"";return sign+nf.format(Math.abs(v))}function currencySymbol(c="EGP",style="best",locale="ar"){const cur=CURRENCY[c];const s=resolve(style,cur,locale);if(s==="code")return cur.code;if(s==="word")return cur.word;if(s==="sign")return cur.sign??cur.short;return cur.short}var currencyName=(c="EGP")=>CURRENCY[c].name;function useCurrencySymbol(c,style){const locale=useMoneyLocale();const store=useCurrency();return currencySymbol(c??store,style??"best",locale)}import{useState}from"react";import{ChevronLeft,ChevronRight}from"lucide-react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function DataTable({columns,rows,rowKey,grid,minWidth,onRowClick,mobileCard,empty,footer,pageSize,unit,className}){const ui=useUIText();const gridClass=`grid-cols-[${grid}]`;const[page,setPage]=useState(0);const pages=pageSize?Math.max(1,Math.ceil(rows.length/pageSize)):1;const safePage=Math.min(page,Math.max(0,pages-1));const shown=pageSize?rows.slice(safePage*pageSize,safePage*pageSize+pageSize):rows;if(rows.length===0&&empty){return jsx2("div",{className:cn("bg-surface border border-line rounded-card",className),children:empty})}return jsxs2("div",{role:"table",className:cn("bg-surface border border-line rounded-card overflow-clip",className),children:[mobileCard&&jsx2("ul",{className:"md:hidden flex flex-col m-0 p-0 list-none",children:shown.map(row=>jsx2("li",{className:"border-b border-line last:border-0",children:onRowClick?jsx2("button",{type:"button",onClick:()=>onRowClick(row),className:"w-full text-start px-4 py-3 cursor-pointer transition-colors active:bg-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-brand",children:mobileCard(row)}):jsx2("div",{className:"px-4 py-3",children:mobileCard(row)})},rowKey(row)))}),jsx2("div",{className:cn("overflow-x-auto",mobileCard&&"max-md:hidden"),children:jsxs2("div",{style:{minWidth},children:[jsx2("div",{role:"row",className:cn("grid gap-3 items-center px-4 py-3 bg-bg border-b border-line",gridClass),style:{gridTemplateColumns:grid.replace(/_/g," ")},children:columns.map(c=>jsx2("span",{role:"columnheader",className:cn("text-caption font-bold text-muted",c.end&&"text-end"),children:c.header},c.key))}),shown.map(row=>jsx2("div",{role:"row",tabIndex:onRowClick?0:void 0,onKeyDown:onRowClick?e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();onRowClick(row)}}:void 0,onClick:onRowClick?()=>onRowClick(row):void 0,className:cn("grid gap-3 items-center px-4 py-3 border-b border-line last:border-0 transition-colors",onRowClick&&"cursor-pointer hover:bg-hover focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-brand",!onRowClick&&"hover:bg-hover"),style:{gridTemplateColumns:grid.replace(/_/g," ")},children:columns.map(c=>jsx2("span",{role:"cell",className:cn("min-w-0",c.end&&"flex justify-end"),children:c.cell(row)},c.key))},rowKey(row)))]})}),(footer||pageSize)&&jsxs2("div",{className:"flex items-center justify-between gap-3 px-4 py-3 bg-bg flex-wrap",children:[footer,pageSize&&jsx2(Pager,{page:safePage,pages,from:page*pageSize+1,to:Math.min(rows.length,(page+1)*pageSize),total:rows.length,unit:unit??ui.row,onPage:setPage})]})]})}function Pager({page,pages,from,to,total,unit,onPage}){const ar=new Intl.NumberFormat("ar-EG");const first=page===0;const last=page>=pages-1;const btn=dir=>{const off=dir===-1?first:last;return jsx2("button",{type:"button",disabled:off,"aria-label":dir===-1?"\u0627\u0644\u0635\u0641\u062D\u0629 \u0627\u0644\u0633\u0627\u0628\u0642\u0629":"\u0627\u0644\u0635\u0641\u062D\u0629 \u0627\u0644\u062A\u0627\u0644\u064A\u0629",onClick:()=>onPage(page+dir),className:cn("size-8 rounded-sm flex items-center justify-center transition-colors",off?"text-muted2/40 cursor-not-allowed":"text-ink2 hover:bg-hover cursor-pointer"),children:dir===-1?jsx2(ChevronRight,{size:16,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"}):jsx2(ChevronLeft,{size:16,className:"rtl:rotate-0 ltr:rotate-180","aria-hidden":"true"})})};return jsxs2("div",{className:"flex items-center gap-2 ms-auto",children:[jsxs2("span",{className:"text-caption text-muted",children:[jsxs2("span",{"data-num":true,className:"font-bold text-ink2",children:[ar.format(from),"\u2013",ar.format(to)]})," ","\u0645\u0646"," ",jsx2("span",{"data-num":true,className:"font-bold text-ink2",children:ar.format(total)})," ",unit]}),jsx2("span",{"aria-live":"polite",className:"sr-only",children:`\u0639\u0631\u0636 ${from} \u0625\u0644\u0649 ${to} \u0645\u0646 ${total}`}),btn(-1),btn(1)]})}import{useEffect,useId,useMemo,useRef,useState as useState2}from"react";import{scaleLinear}from"@visx/scale";import{AreaClosed,LinePath}from"@visx/shape";import{curveMonotoneX}from"@visx/curve";import{TooltipWithBounds}from"@visx/tooltip";import{Fragment as Fragment2,jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";var clamp=(v,lo=0,hi=100)=>Math.min(hi,Math.max(lo,v));function BarChart({labels,series,height=180,formatValue=String,showValues,className}){const plot=useRef(null);const[at,setAt]=useState2(null);const cols=useRef([]);const[tipX,setTipX]=useState2(0);const[,setW]=useState2(0);useEffect(()=>{const el=plot.current;if(!el)return;const measure=()=>setW(el.clientWidth);measure();const ro=new ResizeObserver(measure);ro.observe(el);return()=>ro.disconnect()},[]);const peak=Math.max(1,...series.flatMap(s=>s.values));const n=labels.length;const plotH=height-26;const single=series.length===1;const numbers=showValues??single;const peakAt=at===null?0:Math.max(...series.map(s=>s.values[at]??0));function activate(i){const el=cols.current[i];if(el)setTipX(el.offsetLeft+el.offsetWidth/2);setAt(i)}function onKey(e){const step=e.key==="ArrowRight"?1:e.key==="ArrowLeft"?-1:0;if(step){e.preventDefault();activate(Math.min(n-1,Math.max(0,(at??0)+step)))}else if(e.key==="Home"){e.preventDefault();activate(0)}else if(e.key==="End"){e.preventDefault();activate(n-1)}else if(e.key==="Escape"){setAt(null)}}return jsxs3("div",{className:cn("flex flex-col gap-2.5",className),children:[series.length>1&&jsx3("div",{className:"flex items-center gap-4 text-micro text-muted",children:series.map(s=>jsxs3("span",{className:"flex items-center gap-1.5",children:[jsx3("span",{"aria-hidden":"true",className:cn("size-2.5 rounded-mark",s.muted?"bg-brand-100":"bg-brand")}),s.label]},s.label))}),jsxs3("div",{ref:plot,className:"relative outline-none focus-visible:ring-2 focus-visible:ring-brand/40 rounded-xs",style:{height},tabIndex:0,role:"img","aria-label":labels.join("\u060C "),onKeyDown:onKey,onPointerLeave:()=>setAt(null),onBlur:()=>setAt(null),children:[[1,.5,0].map(f=>jsx3("span",{"aria-hidden":"true",className:"absolute inset-x-0 border-t border-line flex items-start",style:{top:plotH-plotH*f},children:jsx3("span",{"data-num":true,dir:"auto",className:"text-micro text-muted2 -mt-2 bg-surface pe-1",children:formatValue(Math.round(peak*f))})},f)),jsx3("div",{className:"absolute inset-0 flex items-end gap-1.5",children:labels.map((label,i)=>jsxs3("div",{ref:el=>{cols.current[i]=el},onPointerEnter:()=>activate(i),className:cn("flex-1 flex flex-col items-center justify-end gap-1.5 h-full min-w-0 rounded-xs transition-colors",at===i&&"bg-hover"),children:[jsx3("span",{className:"w-full flex items-end justify-center gap-[3px]",style:{height:plotH},children:series.map(s=>jsx3("span",{className:cn("relative flex justify-center rounded-t-mark transition-[height,background-color] duration-300",series.length>1?"w-1/2":"w-3/5",s.muted?"bg-brand-100":at===null||at===i?"bg-brand":"bg-brand-100"),style:{height:Math.max(2,Math.round((s.values[i]??0)/peak*plotH))},children:numbers&&jsx3("span",{"data-num":true,className:"absolute bottom-full mb-1 text-micro font-bold text-ink whitespace-nowrap",children:formatValue(s.values[i]??0)})},s.label))}),jsx3("span",{className:cn("text-micro truncate max-w-full transition-colors",at===i?"text-ink font-bold":"text-muted2"),children:label})]},label))}),at!==null&&jsxs3(TooltipWithBounds,{unstyled:true,applyPositionStyle:true,left:tipX,top:plotH-peakAt/peak*plotH,dir:"rtl",className:"pointer-events-none rounded-sm border border-line bg-surface px-2.5 py-1.5 shadow-tip flex flex-col gap-0.5",children:[jsx3("span",{className:"text-micro text-muted2",children:labels[at]}),series.map(s=>jsxs3("span",{className:"flex items-center gap-2 text-caption text-ink",children:[series.length>1&&jsx3("span",{className:"text-micro text-muted2",children:s.label}),jsx3("span",{"data-num":true,className:"font-extrabold",children:formatValue(s.values[at]??0)})]},s.label))]})]}),jsx3("span",{className:"sr-only","aria-live":"polite",children:at!==null?[labels[at],...series.map(s=>`${s.label}: ${formatValue(s.values[at]??0)}`)].join(" \u2014 "):""}),jsx3("ul",{className:"sr-only",children:labels.map((label,i)=>jsx3("li",{children:[label,...series.map(s=>`${s.label}: ${formatValue(s.values[i]??0)}`)].join(" \u2014 ")},label))})]})}function TrendChart({labels,values,compare,pointLabels,mode="area",height=200,formatValue=String,compareLabel,className}){const ui=useUIText();const gid=useId().replace(/:/g,"");const plot=useRef(null);const[w,setW]=useState2(0);const[at,setAt]=useState2(null);const H=height-24;const PAD_T=6;useEffect(()=>{const el=plot.current;if(!el)return;const measure=()=>setW(el.clientWidth);measure();const ro=new ResizeObserver(measure);ro.observe(el);return()=>ro.disconnect()},[]);const max=Math.max(1,...values,...compare??[]);const n=values.length;const nameAt=i=>pointLabels?.[i]??(labels.length===n?labels[i]:void 0);const slot=n>0?w/n:w;const bw=slot*.62;const inset=mode==="bars"?slot/2:0;const x=useMemo(()=>scaleLinear({domain:[0,Math.max(1,n-1)],range:[inset,w-inset]}),[n,w,inset]);const y=useMemo(()=>scaleLinear({domain:[0,max],range:[H,PAD_T]}),[max,H]);function pick(clientX){const el=plot.current;if(!el||!w)return;const rect=el.getBoundingClientRect();const i=Math.round(x.invert(clientX-rect.left));setAt(Math.min(n-1,Math.max(0,i)))}function onKey(e){const step=e.key==="ArrowRight"?1:e.key==="ArrowLeft"?-1:0;if(step){e.preventDefault();setAt(p=>Math.min(n-1,Math.max(0,(p??0)+step)))}else if(e.key==="Home"){e.preventDefault();setAt(0)}else if(e.key==="End"){e.preventDefault();setAt(n-1)}else if(e.key==="Escape"){setAt(null)}}return jsxs3("div",{className:cn("flex flex-col gap-2",className),children:[jsxs3("div",{ref:plot,dir:"ltr",className:"relative outline-none focus-visible:ring-2 focus-visible:ring-brand/40 rounded-xs",style:{height:H},tabIndex:0,role:"img","aria-label":`${labels[0]} \u2014 ${labels[labels.length-1]}`,onKeyDown:onKey,onPointerMove:e=>pick(e.clientX),onPointerLeave:()=>setAt(null),onBlur:()=>setAt(null),children:[[1,.5,0].map(f=>jsx3("span",{"aria-hidden":"true",className:"absolute inset-x-0 border-t border-line flex items-start",style:{top:y(max*f)},children:jsx3("span",{"data-num":true,dir:"auto",className:"text-micro text-muted2 -mt-2 bg-surface pe-1",children:formatValue(Math.round(max*f))})},f)),jsxs3("svg",{width:w,height:H,className:"absolute inset-0","aria-hidden":"true",children:[jsx3("defs",{children:jsxs3("linearGradient",{id:`g${gid}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[jsx3("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:"0.16"}),jsx3("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:"0"})]})}),mode==="area"?jsxs3(Fragment2,{children:[jsx3(AreaClosed,{data:values,x:(_,i)=>x(i),y:v=>y(v),yScale:y,curve:curveMonotoneX,className:"text-brand",fill:`url(#g${gid})`,stroke:"none"}),jsx3(LinePath,{data:values,x:(_,i)=>x(i),y:v=>y(v),curve:curveMonotoneX,fill:"none",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:"stroke-brand"})]}):values.map((v,i)=>jsx3("rect",{x:x(i)-bw/2,y:y(v),width:bw,height:Math.max(2,H-y(v)),rx:3,className:at===i?"fill-brand":"fill-brand-100"},i)),compare&&jsx3(LinePath,{data:compare,x:(_,i)=>x(i),y:v=>y(v),curve:curveMonotoneX,fill:"none",strokeWidth:1.5,strokeDasharray:"3 3",strokeLinecap:"round",className:"stroke-brand-100"}),at!==null&&jsxs3(Fragment2,{children:[jsx3("line",{x1:x(at),y1:0,x2:x(at),y2:H,strokeWidth:1,strokeDasharray:"4 4",className:"stroke-brand opacity-45"}),mode==="area"&&jsx3("circle",{cx:x(at),cy:y(values[at]),r:5,strokeWidth:3,className:"fill-surface stroke-brand"})]})]}),at!==null&&w>0&&jsxs3(TooltipWithBounds,{unstyled:true,applyPositionStyle:true,left:x(at),top:y(values[at]),dir:"rtl",className:"pointer-events-none rounded-sm border border-line bg-surface px-2.5 py-1.5 shadow-tip flex flex-col gap-0.5",children:[nameAt(at)&&jsx3("span",{className:"text-micro text-muted2",children:nameAt(at)}),jsx3("span",{"data-num":true,className:"text-caption font-extrabold text-ink",children:formatValue(values[at])}),compare?.[at]!==void 0&&jsxs3("span",{"data-num":true,className:"text-micro text-muted2",children:[compareLabel??ui.previousPeriod,": ",formatValue(compare[at])]})]})]}),jsx3("span",{className:"sr-only","aria-live":"polite",children:at!==null?[nameAt(at),formatValue(values[at])].filter(Boolean).join(": "):""}),jsx3("ul",{className:"sr-only",children:values.map((v,i)=>jsx3("li",{children:[nameAt(i),formatValue(v)].filter(Boolean).join(": ")},i))}),jsx3("div",{dir:"ltr",className:"flex items-center justify-between text-micro text-muted2",children:labels.map(l=>jsx3("span",{children:l},l))})]})}function FunnelChart({stages,formatValue=String,className}){const[at,setAt]=useState2(null);const top=Math.max(1,stages[0]?.value??1);const drops=stages.map((s,i)=>{if(i===0)return null;const prev=stages[i-1].value;return prev>0?(prev-s.value)/prev*100:0});const worst=drops.reduce((acc,d,i)=>d!==null&&d>acc.d?{i,d}:acc,{i:-1,d:-1});return jsxs3("div",{className:cn("flex flex-col",className),children:[stages.map((s,i)=>{const share=clamp(s.value/top*100);const drop=drops[i];const isWorst=i===worst.i;return jsxs3("div",{tabIndex:0,role:"img","aria-label":`${s.label}: ${formatValue(s.value)}`,onPointerEnter:()=>setAt(i),onPointerLeave:()=>setAt(null),onFocus:()=>setAt(i),onBlur:()=>setAt(null),className:cn("flex flex-col rounded-xs outline-none transition-colors","focus-visible:ring-2 focus-visible:ring-brand/40",at===i&&"bg-hover"),children:[drop!==null&&jsxs3("span",{className:cn("flex items-center gap-1.5 ps-1 py-1 text-micro",isWorst?"font-extrabold text-amber-ink":"text-muted2"),children:[jsx3("span",{"aria-hidden":"true",className:cn("w-px h-3",isWorst?"bg-amber":"bg-line")}),jsxs3("span",{"data-num":true,children:["\u2212",drop.toFixed(0),"%"]}),isWorst&&jsx3("span",{children:"\xB7 \u0623\u0643\u0628\u0631 \u062A\u0633\u0631\u0651\u0628"})]}),jsxs3("div",{className:"flex items-center gap-3",children:[jsx3("span",{className:"w-32 sm:w-40 shrink-0 text-ui text-ink2 truncate",children:s.label}),jsx3("span",{className:"flex-1 h-8 rounded-xs bg-hover overflow-clip",children:jsx3("span",{className:cn("block h-full rounded-xs transition-[width] duration-500",isWorst?"bg-amber":"bg-brand"),style:{width:`${share}%`}})}),jsx3("span",{"data-num":true,className:"w-20 shrink-0 text-ui font-extrabold text-ink text-end",children:formatValue(s.value)})]}),at===i&&jsxs3("span",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 ps-1 pb-1.5 text-micro text-muted",children:[jsxs3("span",{"data-num":true,children:[share.toFixed(share<10?1:0),"% ","\xB7"," ",stages[0]?.label]}),i>0&&jsxs3("span",{"data-num":true,children:["\u2212",formatValue(Math.max(0,stages[i-1].value-s.value))]})]})]},s.key)}),worst.i>0&&stages[worst.i].advice&&jsx3("span",{className:"mt-3 flex items-start gap-2 p-3 rounded-field bg-amber-bg text-caption leading-[1.7] text-amber-ink",children:stages[worst.i].advice})]})}function Heatmap({rows,cols,values,formatCell=v=>String(v),lowLabel,highLabel,className}){const ui=useUIText();const peak=Math.max(1,...values.flat());const step=v=>v===0?0:Math.min(3,Math.ceil(v/peak*3));const TINT=["bg-hover","bg-brand/25","bg-brand/55","bg-brand"];const grid={gridTemplateColumns:`56px repeat(${cols.length}, minmax(0,1fr))`};return jsxs3("div",{className:cn("flex flex-col gap-1",className),children:[jsxs3("span",{className:"grid gap-1",style:grid,children:[jsx3("span",{}),cols.map(c=>jsx3("span",{"data-num":true,className:"text-micro text-muted2 text-center",children:c},c))]}),rows.map((r,ri)=>jsxs3("span",{className:"grid gap-1 items-center",style:grid,children:[jsx3("span",{className:"text-micro text-muted truncate",children:r}),cols.map((c,ci)=>{const v=values[ri]?.[ci]??0;return jsx3("span",{title:formatCell(v,r,c),className:cn("h-6 rounded-mark transition-colors",TINT[step(v)])},c)})]},r)),jsxs3("span",{className:"flex items-center gap-2 pt-1 text-micro text-muted2",children:[lowLabel??ui.less,jsx3("span",{className:"flex gap-1",children:TINT.map(c=>jsx3("span",{className:cn("size-3 rounded-mark",c)},c))}),highLabel??ui.more]})]})}var SHARE_FILL={brand:"bg-brand",amber:"bg-amber",red:"bg-danger",muted:"bg-border"};function ShareList({items,total,layout="stacked",showPercent=true,labelWidth="6rem",formatValue=String,className}){const sum=total??items.reduce((s,i)=>s+i.value,0);const inline=layout==="inline";return jsx3("div",{className:cn("flex flex-col",inline?"gap-1.5":"gap-3",className),children:items.map(it=>{const pct=sum>0?it.value/sum*100:0;const bar=jsx3("span",{className:cn("rounded-full bg-hover overflow-clip",inline?"flex-1 h-1.5 min-w-0":"block h-1.5"),children:jsx3("span",{className:cn("block h-full rounded-full transition-[width] duration-500",SHARE_FILL[it.tone??"brand"]),style:{width:`${clamp(pct)}%`}})});if(inline){return jsxs3("span",{className:"flex items-center gap-2.5",children:[jsx3("span",{style:{width:labelWidth},className:"shrink-0 text-micro text-muted truncate",children:it.label}),bar,jsx3("span",{"data-num":true,style:{width:labelWidth},className:"shrink-0 text-caption text-muted2 text-end truncate",children:it.trailing??formatValue(it.value)})]},it.key)}return jsxs3("span",{className:"flex flex-col gap-1.5",children:[jsxs3("span",{className:"flex items-center justify-between gap-3",children:[jsxs3("span",{className:"flex flex-col min-w-0",children:[jsx3("span",{className:"text-ui font-bold text-ink truncate",children:it.label}),it.meta&&jsx3("span",{className:"text-micro text-muted truncate",children:it.meta})]}),jsxs3("span",{className:"flex items-center gap-3 shrink-0",children:[it.trailing,jsx3("span",{"data-num":true,className:"text-ui font-extrabold text-ink min-w-[64px] text-end",children:formatValue(it.value)}),showPercent&&jsxs3("span",{"data-num":true,className:"text-micro text-muted2 w-9 text-end",children:[pct.toFixed(0),"%"]})]})]}),bar]},it.key)})})}import{useState as useState3}from"react";import{Check,Info,Lock}from"lucide-react";import{Fragment as Fragment3,jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";function ChoiceCards({name,value,onChange,options,columns=1,hideMark,multiple,disabled:allDisabled,className}){const ui=useUIText();const coach=useCoachOptional();const cols={1:"",2:"sm:grid-cols-2",3:"sm:grid-cols-3"}[columns];const picked=Array.isArray(value)?new Set(value):null;return jsx4("div",{role:multiple?"group":"radiogroup",className:cn("grid gap-2.5",cols,className),children:options.map(o=>{const on=picked?picked.has(o.value):o.value===value;const off=o.disabled||allDisabled;const card=jsxs4("label",{className:cn("relative flex items-start gap-3 p-3.5 rounded-card border transition-colors",off?"border-line bg-bg cursor-not-allowed opacity-70":"cursor-pointer hover:border-brand",on&&!off?"border-brand bg-soft":"border-border bg-surface"),children:[jsx4("input",{type:multiple?"checkbox":"radio",name,value:o.value,checked:on,disabled:off,onChange:()=>onChange(o.value),className:"sr-only peer"}),!hideMark&&jsx4("span",{"aria-hidden":"true",className:cn("mt-0.5 size-[19px] border-[1.5px] flex items-center justify-center shrink-0 transition-colors",multiple?"rounded-mark":"rounded-full","peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-brand",on&&!off?"border-brand bg-brand":"border-border bg-surface"),children:on&&!off&&jsx4(Check,{size:12,strokeWidth:3,className:"text-white"})}),o.icon&&jsx4("span",{"aria-hidden":"true",className:cn("size-9 rounded-field flex items-center justify-center shrink-0 transition-colors",on&&!off?"bg-brand text-white":"bg-hover text-muted"),children:jsx4(o.icon,{size:17,strokeWidth:2})}),jsxs4("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[jsx4("span",{className:"text-body font-extrabold text-ink",children:o.label}),o.meta&&jsx4("span",{className:"text-caption leading-[1.6] text-muted",children:o.meta}),off&&o.lockReason&&jsxs4("span",{className:"inline-flex items-center gap-1 mt-1 text-caption font-bold text-amber-ink",children:[jsx4(Lock,{size:11,"aria-hidden":"true"}),o.lockReason]})]}),o.price&&jsx4("span",{"data-num":true,className:"text-ui font-extrabold text-ink shrink-0",children:o.price}),o.coachId&&coach&&jsx4("button",{type:"button",onClick:e=>{e.preventDefault();e.stopPropagation();coach.replay(o.coachId)},"aria-label":typeof o.label==="string"?`\u0645\u0627 \u0645\u0639\u0646\u0649 \xAB${o.label}\xBB\u061F`:"\u0645\u0627 \u0647\u0630\u0627 \u0627\u0644\u062E\u064A\u0627\u0631\u061F",title:ui.whatIsThisOption,className:cn("self-start ms-auto -me-1 -mt-1 size-7 rounded-full shrink-0 flex items-center justify-center","text-brand cursor-pointer transition-colors","hover:bg-soft hover:text-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:jsx4(Info,{size:15,strokeWidth:2,"aria-hidden":"true"})})]});return o.coachId&&coach?jsx4(Coach,{id:o.coachId,children:card},o.value):jsx4("span",{className:"contents",children:card},o.value)})})}function Sparkline({values,width=72,height=24,tone="brand",fluid,labels,formatValue=String,className}){const[at,setAt]=useState3(null);if(values.length<2)return null;const max=Math.max(...values);const min=Math.min(...values);const span=max-min||1;const step=width/(values.length-1);const points=values.map((v,i)=>{const x=i*step;const y=height-(v-min)/span*(height-3)-1.5;return[x,y]});const line=points.map(([x,y],i)=>`${i===0?"M":"L"}${x.toFixed(1)},${y.toFixed(1)}`).join(" ");const area=`${line} L${width},${height} L0,${height} Z`;const stroke={brand:"stroke-brand",green:"stroke-green",red:"stroke-danger",muted:"stroke-muted2"}[tone];const fill={brand:"fill-brand/10",green:"fill-green/10",red:"fill-danger/10",muted:"fill-muted2/10"}[tone];const pct=at===null?0:at/(values.length-1)*100;function pick(e){const el=e.currentTarget;const w=el.clientWidth||1;const x=e.clientX-el.getBoundingClientRect().left;const i=Math.round(x/w*(values.length-1));setAt(Math.min(values.length-1,Math.max(0,i)))}const text={brand:"text-brand",green:"text-green",red:"text-danger",muted:"text-muted2"}[tone];return jsxs4("span",{className:cn("relative block",text,fluid?"w-full":"inline-block w-fit"),onPointerMove:pick,onPointerLeave:()=>setAt(null),children:[jsxs4("svg",{width:fluid?void 0:width,height:fluid?void 0:height,viewBox:`0 0 ${width} ${height}`,preserveAspectRatio:fluid?"none":void 0,"aria-hidden":"true",style:{direction:"ltr"},className:cn(fluid?"w-full block":"shrink-0","overflow-visible",className),children:[jsx4("path",{d:area,className:cn("stroke-none",fill)}),jsx4("path",{d:line,fill:"none",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke",className:stroke})]}),at!==null&&jsxs4(Fragment3,{children:[jsx4("span",{"aria-hidden":"true",style:{left:`${pct}%`,top:`${points[at][1]/height*100}%`},className:"pointer-events-none absolute z-10 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-current bg-surface"}),jsxs4("span",{style:{left:`${pct}%`},className:"pointer-events-none absolute bottom-full z-10 mb-1 -translate-x-1/2 whitespace-nowrap rounded-sm border border-line bg-surface px-1.5 py-0.5 shadow-tip text-micro text-ink",children:[labels?.[at]&&jsxs4("span",{className:"text-muted2",children:[labels[at]," \xB7 "]}),jsx4("span",{"data-num":true,className:"font-bold",children:formatValue(values[at])})]})]}),labels&&jsx4("ul",{className:"sr-only",children:values.map((v,i)=>jsxs4("li",{children:[labels[i],": ",formatValue(v)]},i))})]})}export{isCurrency,MoneyProvider,useCurrency,Money,currencySymbol,currencyName,useCurrencySymbol,DataTable,BarChart,TrendChart,FunnelChart,Heatmap,ShareList,ChoiceCards,Sparkline};