From 6ce074067687675d93bdb206b791a1c1ad34ad4e Mon Sep 17 00:00:00 2001 From: jokerxue <2509699647@qq.com> Date: Thu, 14 May 2026 11:19:51 +0800 Subject: [PATCH] 提交 --- 美国版/Food Labeling Management App UniApp/src/pages/labels/labels.vue | 10 +--------- 美国版/Food Labeling Management App UniApp/src/services/usAppLabeling.ts | 5 ----- 美国版/Food Labeling Management App UniApp/src/types/usAppLabeling.ts | 5 ----- 美国版/Food Labeling Management Platform/build/assets/index-ChVLtgeV.js | 469 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 美国版/Food Labeling Management Platform/build/assets/index-D3QH2BRm.js | 474 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 美国版/Food Labeling Management Platform/build/index.html | 2 +- 美国版/Food Labeling Management Platform/src/components/bulk/batch-import-dialog.tsx | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------- 美国版/Food Labeling Management Platform/src/components/labels/LabelCategoriesView.tsx | 10 +++------- 美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/ElementsPanel.tsx | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------- 美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx | 14 ++++++++++++-- 美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/PropertiesPanel.tsx | 19 +++++++++---------- 美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/index.tsx | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ 美国版/Food Labeling Management Platform/src/components/labels/LabelTemplatesView.tsx | 22 ++++++++++++++++++---- 美国版/Food Labeling Management Platform/src/components/labels/LabelTypesView.tsx | 10 +++------- 美国版/Food Labeling Management Platform/src/components/labels/LabelsList.tsx | 23 ++--------------------- 美国版/Food Labeling Management Platform/src/components/labels/LabelsView.tsx | 17 ++++++++++++----- 美国版/Food Labeling Management Platform/src/components/layout/Layout.tsx | 42 ++++++++++++++++++++++++++++++++++++++---- 美国版/Food Labeling Management Platform/src/components/locations/LocationsView.tsx | 46 +++++++++++++++++++++++++++++----------------- 美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-dialog.tsx | 279 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-page.tsx | 240 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 美国版/Food Labeling Management Platform/src/components/people/PeopleView.tsx | 4 ++-- 美国版/Food Labeling Management Platform/src/components/products/ProductsView.tsx | 47 ++++++++++++++++++++++++++++++----------------- 美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-dialog.tsx | 235 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-page.tsx | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 美国版/Food Labeling Management Platform/src/components/ui/table.tsx | 4 ++-- 美国版/Food Labeling Management Platform/src/lib/batchFileHttp.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 美国版/Food Labeling Management Platform/src/services/groupService.ts | 4 ++-- 美国版/Food Labeling Management Platform/src/services/locationService.ts | 10 +++++----- 美国版/Food Labeling Management Platform/src/services/partnerService.ts | 4 ++-- 美国版/Food Labeling Management Platform/src/services/productService.ts | 12 ++++++++---- 美国版/Food Labeling Management Platform/src/services/reportsService.ts | 8 ++++---- 美国版/Food Labeling Management Platform/src/services/roleService.ts | 4 ++-- 美国版/Food Labeling Management Platform/src/services/teamMemberService.ts | 59 ++++++++++------------------------------------------------- 项目相关文档/批量导入导出接口说明.md | 18 +++++++++--------- 34 files changed, 1479 insertions(+), 1299 deletions(-) delete mode 100644 美国版/Food Labeling Management Platform/build/assets/index-ChVLtgeV.js create mode 100644 美国版/Food Labeling Management Platform/build/assets/index-D3QH2BRm.js delete mode 100644 美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-dialog.tsx create mode 100644 美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-page.tsx delete mode 100644 美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-dialog.tsx create mode 100644 美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-page.tsx diff --git a/美国版/Food Labeling Management App UniApp/src/pages/labels/labels.vue b/美国版/Food Labeling Management App UniApp/src/pages/labels/labels.vue index 99426ef..b667a5c 100644 --- a/美国版/Food Labeling Management App UniApp/src/pages/labels/labels.vue +++ b/美国版/Food Labeling Management App UniApp/src/pages/labels/labels.vue @@ -159,7 +159,7 @@ @@ -408,16 +408,8 @@ function productPhotoSrc(p: UsAppLabelingProductNodeDto): string { return resolveMediaUrlForApp(p.productImageUrl) } -/** 同一 productId 多模板拆卡时保证列表 :key 唯一 */ -function productCardKey(p: UsAppLabelingProductNodeDto): string { - const tid = (p.templateId ?? '').trim() - return tid ? `${p.productId}|${tid}` : p.productId -} - /** 无商品图时由标签类型尺寸文案拼接展示(接口无单独预览图字段) */ function primaryLabelSizeText(p: UsAppLabelingProductNodeDto): string { - const direct = (p.templateLabelSizeText ?? '').trim() - if (direct) return direct const types = p.labelTypes || [] if (types.length === 0) return '—' const texts = types.map((t) => (t.labelSizeText || '').trim()).filter(Boolean) diff --git a/美国版/Food Labeling Management App UniApp/src/services/usAppLabeling.ts b/美国版/Food Labeling Management App UniApp/src/services/usAppLabeling.ts index 94ec6a3..577d348 100644 --- a/美国版/Food Labeling Management App UniApp/src/services/usAppLabeling.ts +++ b/美国版/Food Labeling Management App UniApp/src/services/usAppLabeling.ts @@ -40,11 +40,6 @@ function normalizeLabelingTreePayload(raw: unknown): UsAppLabelCategoryTreeNodeD })) return { productId: String(x?.productId ?? x?.ProductId ?? ''), - templateId: (x?.templateId ?? x?.TemplateId ?? null) as string | null, - templateCode: (x?.templateCode ?? x?.TemplateCode ?? null) as string | null, - templateLabelSizeText: (x?.templateLabelSizeText ?? x?.TemplateLabelSizeText ?? null) as - | string - | null, productName: String(x?.productName ?? x?.ProductName ?? ''), productCode: String(x?.productCode ?? x?.ProductCode ?? ''), productImageUrl: (x?.productImageUrl ?? x?.ProductImageUrl ?? null) as string | null, diff --git a/美国版/Food Labeling Management App UniApp/src/types/usAppLabeling.ts b/美国版/Food Labeling Management App UniApp/src/types/usAppLabeling.ts index 5bd7076..fbff512 100644 --- a/美国版/Food Labeling Management App UniApp/src/types/usAppLabeling.ts +++ b/美国版/Food Labeling Management App UniApp/src/types/usAppLabeling.ts @@ -11,11 +11,6 @@ export interface UsAppLabelTypeNodeDto { export interface UsAppLabelingProductNodeDto { productId: string - /** 与 productId 组合唯一标识一张卡(多模板拆卡) */ - templateId?: string | null - templateCode?: string | null - /** 当前卡片模板尺寸,与接口 templateLabelSizeText 对齐 */ - templateLabelSizeText?: string | null productName: string productCode: string productImageUrl: string | null diff --git a/美国版/Food Labeling Management Platform/build/assets/index-ChVLtgeV.js b/美国版/Food Labeling Management Platform/build/assets/index-ChVLtgeV.js deleted file mode 100644 index 4481733..0000000 --- a/美国版/Food Labeling Management Platform/build/assets/index-ChVLtgeV.js +++ /dev/null @@ -1,469 +0,0 @@ -function c9(e,t){for(var r=0;rn[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();var Nm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jx={exports:{}},fd={},Nx={exports:{}},St={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var UO;function u9(){if(UO)return St;UO=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),s=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator;function p(D){return D===null||typeof D!="object"?null:(D=h&&D[h]||D["@@iterator"],typeof D=="function"?D:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function w(D,$,K){this.props=D,this.context=$,this.refs=b,this.updater=K||g}w.prototype.isReactComponent={},w.prototype.setState=function(D,$){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,$,"setState")},w.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function j(){}j.prototype=w.prototype;function N(D,$,K){this.props=D,this.context=$,this.refs=b,this.updater=K||g}var C=N.prototype=new j;C.constructor=N,v(C,w.prototype),C.isPureReactComponent=!0;var O=Array.isArray,P=Object.prototype.hasOwnProperty,E={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function A(D,$,K){var J,oe={},re=null,Q=null;if($!=null)for(J in $.ref!==void 0&&(Q=$.ref),$.key!==void 0&&(re=""+$.key),$)P.call($,J)&&!T.hasOwnProperty(J)&&(oe[J]=$[J]);var ue=arguments.length-2;if(ue===1)oe.children=K;else if(1>>1,$=I[D];if(0>>1;Da(oe,F))re<$&&0>a(Q,oe)?(I[D]=Q,I[re]=F,D=re):(I[D]=oe,I[J]=F,D=J);else if(re<$&&0>a(Q,F))I[D]=Q,I[re]=F,D=re;else break e}}return Y}function a(I,Y){var F=I.sortIndex-Y.sortIndex;return F!==0?F:I.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,l=s.now();e.unstable_now=function(){return s.now()-l}}var d=[],u=[],f=1,h=null,p=3,g=!1,v=!1,b=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(I){for(var Y=r(u);Y!==null;){if(Y.callback===null)n(u);else if(Y.startTime<=I)n(u),Y.sortIndex=Y.expirationTime,t(d,Y);else break;Y=r(u)}}function O(I){if(b=!1,C(I),!v)if(r(d)!==null)v=!0,W(P);else{var Y=r(u);Y!==null&&q(O,Y.startTime-I)}}function P(I,Y){v=!1,b&&(b=!1,j(A),A=-1),g=!0;var F=p;try{for(C(Y),h=r(d);h!==null&&(!(h.expirationTime>Y)||I&&!L());){var D=h.callback;if(typeof D=="function"){h.callback=null,p=h.priorityLevel;var $=D(h.expirationTime<=Y);Y=e.unstable_now(),typeof $=="function"?h.callback=$:h===r(d)&&n(d),C(Y)}else n(d);h=r(d)}if(h!==null)var K=!0;else{var J=r(u);J!==null&&q(O,J.startTime-Y),K=!1}return K}finally{h=null,p=F,g=!1}}var E=!1,T=null,A=-1,M=5,R=-1;function L(){return!(e.unstable_now()-RI||125D?(I.sortIndex=F,t(u,I),r(d)===null&&I===r(u)&&(b?(j(A),A=-1):b=!0,q(O,F-D))):(I.sortIndex=$,t(d,I),v||g||(v=!0,W(P))),I},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(I){var Y=p;return function(){var F=p;p=Y;try{return I.apply(this,arguments)}finally{p=F}}}})(Ex)),Ex}var GO;function m9(){return GO||(GO=1,_x.exports=h9()),_x.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var YO;function p9(){if(YO)return An;YO=1;var e=hy(),t=m9();function r(c){for(var m="https://reactjs.org/docs/error-decoder.html?invariant="+c,y=1;y"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},h={};function p(c){return d.call(h,c)?!0:d.call(f,c)?!1:u.test(c)?h[c]=!0:(f[c]=!0,!1)}function g(c,m,y,S){if(y!==null&&y.type===0)return!1;switch(typeof m){case"function":case"symbol":return!0;case"boolean":return S?!1:y!==null?!y.acceptsBooleans:(c=c.toLowerCase().slice(0,5),c!=="data-"&&c!=="aria-");default:return!1}}function v(c,m,y,S){if(m===null||typeof m>"u"||g(c,m,y,S))return!0;if(S)return!1;if(y!==null)switch(y.type){case 3:return!m;case 4:return m===!1;case 5:return isNaN(m);case 6:return isNaN(m)||1>m}return!1}function b(c,m,y,S,_,k,B){this.acceptsBooleans=m===2||m===3||m===4,this.attributeName=S,this.attributeNamespace=_,this.mustUseProperty=y,this.propertyName=c,this.type=m,this.sanitizeURL=k,this.removeEmptyString=B}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(c){w[c]=new b(c,0,!1,c,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(c){var m=c[0];w[m]=new b(m,1,!1,c[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(c){w[c]=new b(c,2,!1,c.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(c){w[c]=new b(c,2,!1,c,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(c){w[c]=new b(c,3,!1,c.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(c){w[c]=new b(c,3,!0,c,null,!1,!1)}),["capture","download"].forEach(function(c){w[c]=new b(c,4,!1,c,null,!1,!1)}),["cols","rows","size","span"].forEach(function(c){w[c]=new b(c,6,!1,c,null,!1,!1)}),["rowSpan","start"].forEach(function(c){w[c]=new b(c,5,!1,c.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(c){return c[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(c){var m=c.replace(j,N);w[m]=new b(m,1,!1,c,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(c){var m=c.replace(j,N);w[m]=new b(m,1,!1,c,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(c){var m=c.replace(j,N);w[m]=new b(m,1,!1,c,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(c){w[c]=new b(c,1,!1,c.toLowerCase(),null,!1,!1)}),w.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(c){w[c]=new b(c,1,!1,c.toLowerCase(),null,!0,!0)});function C(c,m,y,S){var _=w.hasOwnProperty(m)?w[m]:null;(_!==null?_.type!==0:S||!(2X||_[B]!==k[X]){var te=` -`+_[B].replace(" at new "," at ");return c.displayName&&te.includes("")&&(te=te.replace("",c.displayName)),te}while(1<=B&&0<=X);break}}}finally{K=!1,Error.prepareStackTrace=y}return(c=c?c.displayName||c.name:"")?$(c):""}function oe(c){switch(c.tag){case 5:return $(c.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return c=J(c.type,!1),c;case 11:return c=J(c.type.render,!1),c;case 1:return c=J(c.type,!0),c;default:return""}}function re(c){if(c==null)return null;if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case T:return"Fragment";case E:return"Portal";case M:return"Profiler";case A:return"StrictMode";case z:return"Suspense";case G:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case L:return(c.displayName||"Context")+".Consumer";case R:return(c._context.displayName||"Context")+".Provider";case V:var m=c.render;return c=c.displayName,c||(c=m.displayName||m.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case H:return m=c.displayName||null,m!==null?m:re(c.type)||"Memo";case W:m=c._payload,c=c._init;try{return re(c(m))}catch{}}return null}function Q(c){var m=c.type;switch(c.tag){case 24:return"Cache";case 9:return(m.displayName||"Context")+".Consumer";case 10:return(m._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return c=m.render,c=c.displayName||c.name||"",m.displayName||(c!==""?"ForwardRef("+c+")":"ForwardRef");case 7:return"Fragment";case 5:return m;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return re(m);case 8:return m===A?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m}return null}function ue(c){switch(typeof c){case"boolean":case"number":case"string":case"undefined":return c;case"object":return c;default:return""}}function se(c){var m=c.type;return(c=c.nodeName)&&c.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function fe(c){var m=se(c)?"checked":"value",y=Object.getOwnPropertyDescriptor(c.constructor.prototype,m),S=""+c[m];if(!c.hasOwnProperty(m)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var _=y.get,k=y.set;return Object.defineProperty(c,m,{configurable:!0,get:function(){return _.call(this)},set:function(B){S=""+B,k.call(this,B)}}),Object.defineProperty(c,m,{enumerable:y.enumerable}),{getValue:function(){return S},setValue:function(B){S=""+B},stopTracking:function(){c._valueTracker=null,delete c[m]}}}}function we(c){c._valueTracker||(c._valueTracker=fe(c))}function Z(c){if(!c)return!1;var m=c._valueTracker;if(!m)return!0;var y=m.getValue(),S="";return c&&(S=se(c)?c.checked?"true":"false":c.value),c=S,c!==y?(m.setValue(c),!0):!1}function je(c){if(c=c||(typeof document<"u"?document:void 0),typeof c>"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function Ce(c,m){var y=m.checked;return F({},m,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??c._wrapperState.initialChecked})}function qe(c,m){var y=m.defaultValue==null?"":m.defaultValue,S=m.checked!=null?m.checked:m.defaultChecked;y=ue(m.value!=null?m.value:y),c._wrapperState={initialChecked:S,initialValue:y,controlled:m.type==="checkbox"||m.type==="radio"?m.checked!=null:m.value!=null}}function De(c,m){m=m.checked,m!=null&&C(c,"checked",m,!1)}function He(c,m){De(c,m);var y=ue(m.value),S=m.type;if(y!=null)S==="number"?(y===0&&c.value===""||c.value!=y)&&(c.value=""+y):c.value!==""+y&&(c.value=""+y);else if(S==="submit"||S==="reset"){c.removeAttribute("value");return}m.hasOwnProperty("value")?pe(c,m.type,y):m.hasOwnProperty("defaultValue")&&pe(c,m.type,ue(m.defaultValue)),m.checked==null&&m.defaultChecked!=null&&(c.defaultChecked=!!m.defaultChecked)}function ne(c,m,y){if(m.hasOwnProperty("value")||m.hasOwnProperty("defaultValue")){var S=m.type;if(!(S!=="submit"&&S!=="reset"||m.value!==void 0&&m.value!==null))return;m=""+c._wrapperState.initialValue,y||m===c.value||(c.value=m),c.defaultValue=m}y=c.name,y!==""&&(c.name=""),c.defaultChecked=!!c._wrapperState.initialChecked,y!==""&&(c.name=y)}function pe(c,m,y){(m!=="number"||je(c.ownerDocument)!==c)&&(y==null?c.defaultValue=""+c._wrapperState.initialValue:c.defaultValue!==""+y&&(c.defaultValue=""+y))}var _e=Array.isArray;function ve(c,m,y,S){if(c=c.options,m){m={};for(var _=0;_"+m.valueOf().toString()+"",m=Wt.firstChild;c.firstChild;)c.removeChild(c.firstChild);for(;m.firstChild;)c.appendChild(m.firstChild)}});function Ae(c,m){if(m){var y=c.firstChild;if(y&&y===c.lastChild&&y.nodeType===3){y.nodeValue=m;return}}c.textContent=m}var pt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ot=["Webkit","ms","Moz","O"];Object.keys(pt).forEach(function(c){Ot.forEach(function(m){m=m+c.charAt(0).toUpperCase()+c.substring(1),pt[m]=pt[c]})});function Qt(c,m,y){return m==null||typeof m=="boolean"||m===""?"":y||typeof m!="number"||m===0||pt.hasOwnProperty(c)&&pt[c]?(""+m).trim():m+"px"}function Ar(c,m){c=c.style;for(var y in m)if(m.hasOwnProperty(y)){var S=y.indexOf("--")===0,_=Qt(y,m[y],S);y==="float"&&(y="cssFloat"),S?c.setProperty(y,_):c[y]=_}}var Vn=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Jr(c,m){if(m){if(Vn[c]&&(m.children!=null||m.dangerouslySetInnerHTML!=null))throw Error(r(137,c));if(m.dangerouslySetInnerHTML!=null){if(m.children!=null)throw Error(r(60));if(typeof m.dangerouslySetInnerHTML!="object"||!("__html"in m.dangerouslySetInnerHTML))throw Error(r(61))}if(m.style!=null&&typeof m.style!="object")throw Error(r(62))}}function Ur(c,m){if(c.indexOf("-")===-1)return typeof m.is=="string";switch(c){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Er=null;function qt(c){return c=c.target||c.srcElement||window,c.correspondingUseElement&&(c=c.correspondingUseElement),c.nodeType===3?c.parentNode:c}var gr=null,Kt=null,fr=null;function tr(c){if(c=Ju(c)){if(typeof gr!="function")throw Error(r(280));var m=c.stateNode;m&&(m=Fh(m),gr(c.stateNode,c.type,m))}}function Qe(c){Kt?fr?fr.push(c):fr=[c]:Kt=c}function Tt(){if(Kt){var c=Kt,m=fr;if(fr=Kt=null,tr(c),m)for(c=0;c>>=0,c===0?32:31-(Hv(c)/Iu|0)|0}var mi=64,yl=4194304;function pi(c){switch(c&-c){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function vl(c,m){var y=c.pendingLanes;if(y===0)return 0;var S=0,_=c.suspendedLanes,k=c.pingedLanes,B=y&268435455;if(B!==0){var X=B&~_;X!==0?S=pi(X):(k&=B,k!==0&&(S=pi(k)))}else B=y&~_,B!==0?S=pi(B):k!==0&&(S=pi(k));if(S===0)return 0;if(m!==0&&m!==S&&(m&_)===0&&(_=S&-S,k=m&-m,_>=k||_===16&&(k&4194240)!==0))return m;if((S&4)!==0&&(S|=y&16),m=c.entangledLanes,m!==0)for(c=c.entanglements,m&=S;0y;y++)m.push(c);return m}function os(c,m,y){c.pendingLanes|=m,m!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,m=31-_n(m),c[m]=y}function wh(c,m){var y=c.pendingLanes&~m;c.pendingLanes=m,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=m,c.mutableReadLanes&=m,c.entangledLanes&=m,m=c.entanglements;var S=c.eventTimes;for(c=c.expirationTimes;0=Uu),RE=" ",DE=!1;function LE(c,m){switch(c){case"keyup":return aU.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $E(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Nl=!1;function iU(c,m){switch(c){case"compositionend":return $E(m);case"keypress":return m.which!==32?null:(DE=!0,RE);case"textInput":return c=m.data,c===RE&&DE?null:c;default:return null}}function sU(c,m){if(Nl)return c==="compositionend"||!n0&&LE(c,m)?(c=OE(),Ph=Jv=yi=null,Nl=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1=m)return{node:y,offset:m-c};c=S}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=WE(y)}}function GE(c,m){return c&&m?c===m?!0:c&&c.nodeType===3?!1:m&&m.nodeType===3?GE(c,m.parentNode):"contains"in c?c.contains(m):c.compareDocumentPosition?!!(c.compareDocumentPosition(m)&16):!1:!1}function YE(){for(var c=window,m=je();m instanceof c.HTMLIFrameElement;){try{var y=typeof m.contentWindow.location.href=="string"}catch{y=!1}if(y)c=m.contentWindow;else break;m=je(c.document)}return m}function i0(c){var m=c&&c.nodeName&&c.nodeName.toLowerCase();return m&&(m==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||m==="textarea"||c.contentEditable==="true")}function gU(c){var m=YE(),y=c.focusedElem,S=c.selectionRange;if(m!==y&&y&&y.ownerDocument&&GE(y.ownerDocument.documentElement,y)){if(S!==null&&i0(y)){if(m=S.start,c=S.end,c===void 0&&(c=m),"selectionStart"in y)y.selectionStart=m,y.selectionEnd=Math.min(c,y.value.length);else if(c=(m=y.ownerDocument||document)&&m.defaultView||window,c.getSelection){c=c.getSelection();var _=y.textContent.length,k=Math.min(S.start,_);S=S.end===void 0?k:Math.min(S.end,_),!c.extend&&k>S&&(_=S,S=k,k=_),_=HE(y,k);var B=HE(y,S);_&&B&&(c.rangeCount!==1||c.anchorNode!==_.node||c.anchorOffset!==_.offset||c.focusNode!==B.node||c.focusOffset!==B.offset)&&(m=m.createRange(),m.setStart(_.node,_.offset),c.removeAllRanges(),k>S?(c.addRange(m),c.extend(B.node,B.offset)):(m.setEnd(B.node,B.offset),c.addRange(m)))}}for(m=[],c=y;c=c.parentNode;)c.nodeType===1&&m.push({element:c,left:c.scrollLeft,top:c.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y=document.documentMode,Cl=null,s0=null,Hu=null,l0=!1;function KE(c,m,y){var S=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;l0||Cl==null||Cl!==je(S)||(S=Cl,"selectionStart"in S&&i0(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),Hu&&Wu(Hu,S)||(Hu=S,S=Dh(s0,"onSelect"),0Tl||(c.current=b0[Tl],b0[Tl]=null,Tl--)}function rr(c,m){Tl++,b0[Tl]=c.current,c.current=m}var wi={},nn=bi(wi),En=bi(!1),ls=wi;function kl(c,m){var y=c.type.contextTypes;if(!y)return wi;var S=c.stateNode;if(S&&S.__reactInternalMemoizedUnmaskedChildContext===m)return S.__reactInternalMemoizedMaskedChildContext;var _={},k;for(k in y)_[k]=m[k];return S&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=m,c.__reactInternalMemoizedMaskedChildContext=_),_}function Pn(c){return c=c.childContextTypes,c!=null}function Bh(){ur(En),ur(nn)}function uP(c,m,y){if(nn.current!==wi)throw Error(r(168));rr(nn,m),rr(En,y)}function dP(c,m,y){var S=c.stateNode;if(m=m.childContextTypes,typeof S.getChildContext!="function")return y;S=S.getChildContext();for(var _ in S)if(!(_ in m))throw Error(r(108,Q(c)||"Unknown",_));return F({},y,S)}function zh(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||wi,ls=nn.current,rr(nn,c),rr(En,En.current),!0}function fP(c,m,y){var S=c.stateNode;if(!S)throw Error(r(169));y?(c=dP(c,m,ls),S.__reactInternalMemoizedMergedChildContext=c,ur(En),ur(nn),rr(nn,c)):ur(En),rr(En,y)}var Ro=null,Uh=!1,w0=!1;function hP(c){Ro===null?Ro=[c]:Ro.push(c)}function PU(c){Uh=!0,hP(c)}function Si(){if(!w0&&Ro!==null){w0=!0;var c=0,m=$t;try{var y=Ro;for($t=1;c>=B,_-=B,Do=1<<32-_n(m)+_|y<<_|S,Lo=k+c}else Do=1<ft?(Wr=it,it=null):Wr=it.sibling;var Ft=Pe(le,it,he[ft],Me);if(Ft===null){it===null&&(it=Wr);break}c&&it&&Ft.alternate===null&&m(le,it),ie=k(Ft,ie,ft),ot===null?tt=Ft:ot.sibling=Ft,ot=Ft,it=Wr}if(ft===he.length)return y(le,it),mr&&us(le,ft),tt;if(it===null){for(;ftft?(Wr=it,it=null):Wr=it.sibling;var ki=Pe(le,it,Ft.value,Me);if(ki===null){it===null&&(it=Wr);break}c&&it&&ki.alternate===null&&m(le,it),ie=k(ki,ie,ft),ot===null?tt=ki:ot.sibling=ki,ot=ki,it=Wr}if(Ft.done)return y(le,it),mr&&us(le,ft),tt;if(it===null){for(;!Ft.done;ft++,Ft=he.next())Ft=Te(le,Ft.value,Me),Ft!==null&&(ie=k(Ft,ie,ft),ot===null?tt=Ft:ot.sibling=Ft,ot=Ft);return mr&&us(le,ft),tt}for(it=S(le,it);!Ft.done;ft++,Ft=he.next())Ft=Ue(it,le,ft,Ft.value,Me),Ft!==null&&(c&&Ft.alternate!==null&&it.delete(Ft.key===null?ft:Ft.key),ie=k(Ft,ie,ft),ot===null?tt=Ft:ot.sibling=Ft,ot=Ft);return c&&it.forEach(function(l9){return m(le,l9)}),mr&&us(le,ft),tt}function Cr(le,ie,he,Me){if(typeof he=="object"&&he!==null&&he.type===T&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case P:e:{for(var tt=he.key,ot=ie;ot!==null;){if(ot.key===tt){if(tt=he.type,tt===T){if(ot.tag===7){y(le,ot.sibling),ie=_(ot,he.props.children),ie.return=le,le=ie;break e}}else if(ot.elementType===tt||typeof tt=="object"&&tt!==null&&tt.$$typeof===W&&xP(tt)===ot.type){y(le,ot.sibling),ie=_(ot,he.props),ie.ref=Qu(le,ot,he),ie.return=le,le=ie;break e}y(le,ot);break}else m(le,ot);ot=ot.sibling}he.type===T?(ie=vs(he.props.children,le.mode,Me,he.key),ie.return=le,le=ie):(Me=gm(he.type,he.key,he.props,null,le.mode,Me),Me.ref=Qu(le,ie,he),Me.return=le,le=Me)}return B(le);case E:e:{for(ot=he.key;ie!==null;){if(ie.key===ot)if(ie.tag===4&&ie.stateNode.containerInfo===he.containerInfo&&ie.stateNode.implementation===he.implementation){y(le,ie.sibling),ie=_(ie,he.children||[]),ie.return=le,le=ie;break e}else{y(le,ie);break}else m(le,ie);ie=ie.sibling}ie=vx(he,le.mode,Me),ie.return=le,le=ie}return B(le);case W:return ot=he._init,Cr(le,ie,ot(he._payload),Me)}if(_e(he))return Ye(le,ie,he,Me);if(Y(he))return et(le,ie,he,Me);Hh(le,he)}return typeof he=="string"&&he!==""||typeof he=="number"?(he=""+he,ie!==null&&ie.tag===6?(y(le,ie.sibling),ie=_(ie,he),ie.return=le,le=ie):(y(le,ie),ie=yx(he,le.mode,Me),ie.return=le,le=ie),B(le)):y(le,ie)}return Cr}var Rl=bP(!0),wP=bP(!1),Gh=bi(null),Yh=null,Dl=null,E0=null;function P0(){E0=Dl=Yh=null}function O0(c){var m=Gh.current;ur(Gh),c._currentValue=m}function T0(c,m,y){for(;c!==null;){var S=c.alternate;if((c.childLanes&m)!==m?(c.childLanes|=m,S!==null&&(S.childLanes|=m)):S!==null&&(S.childLanes&m)!==m&&(S.childLanes|=m),c===y)break;c=c.return}}function Ll(c,m){Yh=c,E0=Dl=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&m)!==0&&(On=!0),c.firstContext=null)}function ya(c){var m=c._currentValue;if(E0!==c)if(c={context:c,memoizedValue:m,next:null},Dl===null){if(Yh===null)throw Error(r(308));Dl=c,Yh.dependencies={lanes:0,firstContext:c}}else Dl=Dl.next=c;return m}var ds=null;function k0(c){ds===null?ds=[c]:ds.push(c)}function SP(c,m,y,S){var _=m.interleaved;return _===null?(y.next=y,k0(m)):(y.next=_.next,_.next=y),m.interleaved=y,$o(c,S)}function $o(c,m){c.lanes|=m;var y=c.alternate;for(y!==null&&(y.lanes|=m),y=c,c=c.return;c!==null;)c.childLanes|=m,y=c.alternate,y!==null&&(y.childLanes|=m),y=c,c=c.return;return y.tag===3?y.stateNode:null}var ji=!1;function A0(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function jP(c,m){c=c.updateQueue,m.updateQueue===c&&(m.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,effects:c.effects})}function Fo(c,m){return{eventTime:c,lane:m,tag:0,payload:null,callback:null,next:null}}function Ni(c,m,y){var S=c.updateQueue;if(S===null)return null;if(S=S.shared,(Mt&2)!==0){var _=S.pending;return _===null?m.next=m:(m.next=_.next,_.next=m),S.pending=m,$o(c,y)}return _=S.interleaved,_===null?(m.next=m,k0(S)):(m.next=_.next,_.next=m),S.interleaved=m,$o(c,y)}function Kh(c,m,y){if(m=m.updateQueue,m!==null&&(m=m.shared,(y&4194240)!==0)){var S=m.lanes;S&=c.pendingLanes,y|=S,m.lanes=y,Mu(c,y)}}function NP(c,m){var y=c.updateQueue,S=c.alternate;if(S!==null&&(S=S.updateQueue,y===S)){var _=null,k=null;if(y=y.firstBaseUpdate,y!==null){do{var B={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};k===null?_=k=B:k=k.next=B,y=y.next}while(y!==null);k===null?_=k=m:k=k.next=m}else _=k=m;y={baseState:S.baseState,firstBaseUpdate:_,lastBaseUpdate:k,shared:S.shared,effects:S.effects},c.updateQueue=y;return}c=y.lastBaseUpdate,c===null?y.firstBaseUpdate=m:c.next=m,y.lastBaseUpdate=m}function Xh(c,m,y,S){var _=c.updateQueue;ji=!1;var k=_.firstBaseUpdate,B=_.lastBaseUpdate,X=_.shared.pending;if(X!==null){_.shared.pending=null;var te=X,ge=te.next;te.next=null,B===null?k=ge:B.next=ge,B=te;var Oe=c.alternate;Oe!==null&&(Oe=Oe.updateQueue,X=Oe.lastBaseUpdate,X!==B&&(X===null?Oe.firstBaseUpdate=ge:X.next=ge,Oe.lastBaseUpdate=te))}if(k!==null){var Te=_.baseState;B=0,Oe=ge=te=null,X=k;do{var Pe=X.lane,Ue=X.eventTime;if((S&Pe)===Pe){Oe!==null&&(Oe=Oe.next={eventTime:Ue,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Ye=c,et=X;switch(Pe=m,Ue=y,et.tag){case 1:if(Ye=et.payload,typeof Ye=="function"){Te=Ye.call(Ue,Te,Pe);break e}Te=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=et.payload,Pe=typeof Ye=="function"?Ye.call(Ue,Te,Pe):Ye,Pe==null)break e;Te=F({},Te,Pe);break e;case 2:ji=!0}}X.callback!==null&&X.lane!==0&&(c.flags|=64,Pe=_.effects,Pe===null?_.effects=[X]:Pe.push(X))}else Ue={eventTime:Ue,lane:Pe,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Oe===null?(ge=Oe=Ue,te=Te):Oe=Oe.next=Ue,B|=Pe;if(X=X.next,X===null){if(X=_.shared.pending,X===null)break;Pe=X,X=Pe.next,Pe.next=null,_.lastBaseUpdate=Pe,_.shared.pending=null}}while(!0);if(Oe===null&&(te=Te),_.baseState=te,_.firstBaseUpdate=ge,_.lastBaseUpdate=Oe,m=_.shared.interleaved,m!==null){_=m;do B|=_.lane,_=_.next;while(_!==m)}else k===null&&(_.shared.lanes=0);ms|=B,c.lanes=B,c.memoizedState=Te}}function CP(c,m,y){if(c=m.effects,m.effects=null,c!==null)for(m=0;my?y:4,c(!0);var S=L0.transition;L0.transition={};try{c(!1),m()}finally{$t=y,L0.transition=S}}function VP(){return va().memoizedState}function AU(c,m,y){var S=Pi(c);if(y={lane:S,action:y,hasEagerState:!1,eagerState:null,next:null},WP(c))HP(m,y);else if(y=SP(c,m,y,S),y!==null){var _=yn();za(y,c,S,_),GP(y,m,S)}}function IU(c,m,y){var S=Pi(c),_={lane:S,action:y,hasEagerState:!1,eagerState:null,next:null};if(WP(c))HP(m,_);else{var k=c.alternate;if(c.lanes===0&&(k===null||k.lanes===0)&&(k=m.lastRenderedReducer,k!==null))try{var B=m.lastRenderedState,X=k(B,y);if(_.hasEagerState=!0,_.eagerState=X,Da(X,B)){var te=m.interleaved;te===null?(_.next=_,k0(m)):(_.next=te.next,te.next=_),m.interleaved=_;return}}catch{}finally{}y=SP(c,m,_,S),y!==null&&(_=yn(),za(y,c,S,_),GP(y,m,S))}}function WP(c){var m=c.alternate;return c===vr||m!==null&&m===vr}function HP(c,m){rd=Zh=!0;var y=c.pending;y===null?m.next=m:(m.next=y.next,y.next=m),c.pending=m}function GP(c,m,y){if((y&4194240)!==0){var S=m.lanes;S&=c.pendingLanes,y|=S,m.lanes=y,Mu(c,y)}}var rm={readContext:ya,useCallback:an,useContext:an,useEffect:an,useImperativeHandle:an,useInsertionEffect:an,useLayoutEffect:an,useMemo:an,useReducer:an,useRef:an,useState:an,useDebugValue:an,useDeferredValue:an,useTransition:an,useMutableSource:an,useSyncExternalStore:an,useId:an,unstable_isNewReconciler:!1},MU={readContext:ya,useCallback:function(c,m){return so().memoizedState=[c,m===void 0?null:m],c},useContext:ya,useEffect:DP,useImperativeHandle:function(c,m,y){return y=y!=null?y.concat([c]):null,em(4194308,4,FP.bind(null,m,c),y)},useLayoutEffect:function(c,m){return em(4194308,4,c,m)},useInsertionEffect:function(c,m){return em(4,2,c,m)},useMemo:function(c,m){var y=so();return m=m===void 0?null:m,c=c(),y.memoizedState=[c,m],c},useReducer:function(c,m,y){var S=so();return m=y!==void 0?y(m):m,S.memoizedState=S.baseState=m,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:m},S.queue=c,c=c.dispatch=AU.bind(null,vr,c),[S.memoizedState,c]},useRef:function(c){var m=so();return c={current:c},m.memoizedState=c},useState:MP,useDebugValue:V0,useDeferredValue:function(c){return so().memoizedState=c},useTransition:function(){var c=MP(!1),m=c[0];return c=kU.bind(null,c[1]),so().memoizedState=c,[m,c]},useMutableSource:function(){},useSyncExternalStore:function(c,m,y){var S=vr,_=so();if(mr){if(y===void 0)throw Error(r(407));y=y()}else{if(y=m(),Vr===null)throw Error(r(349));(hs&30)!==0||OP(S,m,y)}_.memoizedState=y;var k={value:y,getSnapshot:m};return _.queue=k,DP(kP.bind(null,S,k,c),[c]),S.flags|=2048,od(9,TP.bind(null,S,k,y,m),void 0,null),y},useId:function(){var c=so(),m=Vr.identifierPrefix;if(mr){var y=Lo,S=Do;y=(S&~(1<<32-_n(S)-1)).toString(32)+y,m=":"+m+"R"+y,y=nd++,0<\/script>",c=c.removeChild(c.firstChild)):typeof S.is=="string"?c=B.createElement(y,{is:S.is}):(c=B.createElement(y),y==="select"&&(B=c,S.multiple?B.multiple=!0:S.size&&(B.size=S.size))):c=B.createElementNS(c,y),c[oo]=m,c[Xu]=S,hO(c,m,!1,!1),m.stateNode=c;e:{switch(B=Ur(y,S),y){case"dialog":cr("cancel",c),cr("close",c),_=S;break;case"iframe":case"object":case"embed":cr("load",c),_=S;break;case"video":case"audio":for(_=0;_Ul&&(m.flags|=128,S=!0,id(k,!1),m.lanes=4194304)}else{if(!S)if(c=Jh(B),c!==null){if(m.flags|=128,S=!0,y=c.updateQueue,y!==null&&(m.updateQueue=y,m.flags|=4),id(k,!0),k.tail===null&&k.tailMode==="hidden"&&!B.alternate&&!mr)return on(m),null}else 2*lr()-k.renderingStartTime>Ul&&y!==1073741824&&(m.flags|=128,S=!0,id(k,!1),m.lanes=4194304);k.isBackwards?(B.sibling=m.child,m.child=B):(y=k.last,y!==null?y.sibling=B:m.child=B,k.last=B)}return k.tail!==null?(m=k.tail,k.rendering=m,k.tail=m.sibling,k.renderingStartTime=lr(),m.sibling=null,y=yr.current,rr(yr,S?y&1|2:y&1),m):(on(m),null);case 22:case 23:return mx(),S=m.memoizedState!==null,c!==null&&c.memoizedState!==null!==S&&(m.flags|=8192),S&&(m.mode&1)!==0?(Kn&1073741824)!==0&&(on(m),m.subtreeFlags&6&&(m.flags|=8192)):on(m),null;case 24:return null;case 25:return null}throw Error(r(156,m.tag))}function UU(c,m){switch(j0(m),m.tag){case 1:return Pn(m.type)&&Bh(),c=m.flags,c&65536?(m.flags=c&-65537|128,m):null;case 3:return $l(),ur(En),ur(nn),D0(),c=m.flags,(c&65536)!==0&&(c&128)===0?(m.flags=c&-65537|128,m):null;case 5:return M0(m),null;case 13:if(ur(yr),c=m.memoizedState,c!==null&&c.dehydrated!==null){if(m.alternate===null)throw Error(r(340));Ml()}return c=m.flags,c&65536?(m.flags=c&-65537|128,m):null;case 19:return ur(yr),null;case 4:return $l(),null;case 10:return O0(m.type._context),null;case 22:case 23:return mx(),null;case 24:return null;default:return null}}var im=!1,sn=!1,qU=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function Bl(c,m){var y=c.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(S){wr(c,m,S)}else y.current=null}function rx(c,m,y){try{y()}catch(S){wr(c,m,S)}}var gO=!1;function VU(c,m){if(m0=_h,c=YE(),i0(c)){if("selectionStart"in c)var y={start:c.selectionStart,end:c.selectionEnd};else e:{y=(y=c.ownerDocument)&&y.defaultView||window;var S=y.getSelection&&y.getSelection();if(S&&S.rangeCount!==0){y=S.anchorNode;var _=S.anchorOffset,k=S.focusNode;S=S.focusOffset;try{y.nodeType,k.nodeType}catch{y=null;break e}var B=0,X=-1,te=-1,ge=0,Oe=0,Te=c,Pe=null;t:for(;;){for(var Ue;Te!==y||_!==0&&Te.nodeType!==3||(X=B+_),Te!==k||S!==0&&Te.nodeType!==3||(te=B+S),Te.nodeType===3&&(B+=Te.nodeValue.length),(Ue=Te.firstChild)!==null;)Pe=Te,Te=Ue;for(;;){if(Te===c)break t;if(Pe===y&&++ge===_&&(X=B),Pe===k&&++Oe===S&&(te=B),(Ue=Te.nextSibling)!==null)break;Te=Pe,Pe=Te.parentNode}Te=Ue}y=X===-1||te===-1?null:{start:X,end:te}}else y=null}y=y||{start:0,end:0}}else y=null;for(p0={focusedElem:c,selectionRange:y},_h=!1,Ve=m;Ve!==null;)if(m=Ve,c=m.child,(m.subtreeFlags&1028)!==0&&c!==null)c.return=m,Ve=c;else for(;Ve!==null;){m=Ve;try{var Ye=m.alternate;if((m.flags&1024)!==0)switch(m.tag){case 0:case 11:case 15:break;case 1:if(Ye!==null){var et=Ye.memoizedProps,Cr=Ye.memoizedState,le=m.stateNode,ie=le.getSnapshotBeforeUpdate(m.elementType===m.type?et:$a(m.type,et),Cr);le.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var he=m.stateNode.containerInfo;he.nodeType===1?he.textContent="":he.nodeType===9&&he.documentElement&&he.removeChild(he.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Me){wr(m,m.return,Me)}if(c=m.sibling,c!==null){c.return=m.return,Ve=c;break}Ve=m.return}return Ye=gO,gO=!1,Ye}function sd(c,m,y){var S=m.updateQueue;if(S=S!==null?S.lastEffect:null,S!==null){var _=S=S.next;do{if((_.tag&c)===c){var k=_.destroy;_.destroy=void 0,k!==void 0&&rx(m,y,k)}_=_.next}while(_!==S)}}function sm(c,m){if(m=m.updateQueue,m=m!==null?m.lastEffect:null,m!==null){var y=m=m.next;do{if((y.tag&c)===c){var S=y.create;y.destroy=S()}y=y.next}while(y!==m)}}function nx(c){var m=c.ref;if(m!==null){var y=c.stateNode;switch(c.tag){case 5:c=y;break;default:c=y}typeof m=="function"?m(c):m.current=c}}function yO(c){var m=c.alternate;m!==null&&(c.alternate=null,yO(m)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(m=c.stateNode,m!==null&&(delete m[oo],delete m[Xu],delete m[x0],delete m[_U],delete m[EU])),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function vO(c){return c.tag===5||c.tag===3||c.tag===4}function xO(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||vO(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function ax(c,m,y){var S=c.tag;if(S===5||S===6)c=c.stateNode,m?y.nodeType===8?y.parentNode.insertBefore(c,m):y.insertBefore(c,m):(y.nodeType===8?(m=y.parentNode,m.insertBefore(c,y)):(m=y,m.appendChild(c)),y=y._reactRootContainer,y!=null||m.onclick!==null||(m.onclick=$h));else if(S!==4&&(c=c.child,c!==null))for(ax(c,m,y),c=c.sibling;c!==null;)ax(c,m,y),c=c.sibling}function ox(c,m,y){var S=c.tag;if(S===5||S===6)c=c.stateNode,m?y.insertBefore(c,m):y.appendChild(c);else if(S!==4&&(c=c.child,c!==null))for(ox(c,m,y),c=c.sibling;c!==null;)ox(c,m,y),c=c.sibling}var Zr=null,Fa=!1;function Ci(c,m,y){for(y=y.child;y!==null;)bO(c,m,y),y=y.sibling}function bO(c,m,y){if(Wn&&typeof Wn.onCommitFiberUnmount=="function")try{Wn.onCommitFiberUnmount(gl,y)}catch{}switch(y.tag){case 5:sn||Bl(y,m);case 6:var S=Zr,_=Fa;Zr=null,Ci(c,m,y),Zr=S,Fa=_,Zr!==null&&(Fa?(c=Zr,y=y.stateNode,c.nodeType===8?c.parentNode.removeChild(y):c.removeChild(y)):Zr.removeChild(y.stateNode));break;case 18:Zr!==null&&(Fa?(c=Zr,y=y.stateNode,c.nodeType===8?v0(c.parentNode,y):c.nodeType===1&&v0(c,y),Fu(c)):v0(Zr,y.stateNode));break;case 4:S=Zr,_=Fa,Zr=y.stateNode.containerInfo,Fa=!0,Ci(c,m,y),Zr=S,Fa=_;break;case 0:case 11:case 14:case 15:if(!sn&&(S=y.updateQueue,S!==null&&(S=S.lastEffect,S!==null))){_=S=S.next;do{var k=_,B=k.destroy;k=k.tag,B!==void 0&&((k&2)!==0||(k&4)!==0)&&rx(y,m,B),_=_.next}while(_!==S)}Ci(c,m,y);break;case 1:if(!sn&&(Bl(y,m),S=y.stateNode,typeof S.componentWillUnmount=="function"))try{S.props=y.memoizedProps,S.state=y.memoizedState,S.componentWillUnmount()}catch(X){wr(y,m,X)}Ci(c,m,y);break;case 21:Ci(c,m,y);break;case 22:y.mode&1?(sn=(S=sn)||y.memoizedState!==null,Ci(c,m,y),sn=S):Ci(c,m,y);break;default:Ci(c,m,y)}}function wO(c){var m=c.updateQueue;if(m!==null){c.updateQueue=null;var y=c.stateNode;y===null&&(y=c.stateNode=new qU),m.forEach(function(S){var _=ZU.bind(null,c,S);y.has(S)||(y.add(S),S.then(_,_))})}}function Ba(c,m){var y=m.deletions;if(y!==null)for(var S=0;S_&&(_=B),S&=~k}if(S=_,S=lr()-S,S=(120>S?120:480>S?480:1080>S?1080:1920>S?1920:3e3>S?3e3:4320>S?4320:1960*HU(S/1960))-S,10c?16:c,Ei===null)var S=!1;else{if(c=Ei,Ei=null,fm=0,(Mt&6)!==0)throw Error(r(331));var _=Mt;for(Mt|=4,Ve=c.current;Ve!==null;){var k=Ve,B=k.child;if((Ve.flags&16)!==0){var X=k.deletions;if(X!==null){for(var te=0;telr()-lx?gs(c,0):sx|=y),kn(c,m)}function MO(c,m){m===0&&((c.mode&1)===0?m=1:(m=yl,yl<<=1,(yl&130023424)===0&&(yl=4194304)));var y=yn();c=$o(c,m),c!==null&&(os(c,m,y),kn(c,y))}function QU(c){var m=c.memoizedState,y=0;m!==null&&(y=m.retryLane),MO(c,y)}function ZU(c,m){var y=0;switch(c.tag){case 13:var S=c.stateNode,_=c.memoizedState;_!==null&&(y=_.retryLane);break;case 19:S=c.stateNode;break;default:throw Error(r(314))}S!==null&&S.delete(m),MO(c,y)}var RO;RO=function(c,m,y){if(c!==null)if(c.memoizedProps!==m.pendingProps||En.current)On=!0;else{if((c.lanes&y)===0&&(m.flags&128)===0)return On=!1,BU(c,m,y);On=(c.flags&131072)!==0}else On=!1,mr&&(m.flags&1048576)!==0&&mP(m,Vh,m.index);switch(m.lanes=0,m.tag){case 2:var S=m.type;om(c,m),c=m.pendingProps;var _=kl(m,nn.current);Ll(m,y),_=F0(null,m,S,c,_,y);var k=B0();return m.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(m.tag=1,m.memoizedState=null,m.updateQueue=null,Pn(S)?(k=!0,zh(m)):k=!1,m.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,A0(m),_.updater=nm,m.stateNode=_,_._reactInternals=m,H0(m,S,c,y),m=X0(null,m,S,!0,k,y)):(m.tag=0,mr&&k&&S0(m),gn(null,m,_,y),m=m.child),m;case 16:S=m.elementType;e:{switch(om(c,m),c=m.pendingProps,_=S._init,S=_(S._payload),m.type=S,_=m.tag=t9(S),c=$a(S,c),_){case 0:m=K0(null,m,S,c,y);break e;case 1:m=sO(null,m,S,c,y);break e;case 11:m=rO(null,m,S,c,y);break e;case 14:m=nO(null,m,S,$a(S.type,c),y);break e}throw Error(r(306,S,""))}return m;case 0:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),K0(c,m,S,_,y);case 1:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),sO(c,m,S,_,y);case 3:e:{if(lO(m),c===null)throw Error(r(387));S=m.pendingProps,k=m.memoizedState,_=k.element,jP(c,m),Xh(m,S,null,y);var B=m.memoizedState;if(S=B.element,k.isDehydrated)if(k={element:S,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},m.updateQueue.baseState=k,m.memoizedState=k,m.flags&256){_=Fl(Error(r(423)),m),m=cO(c,m,S,y,_);break e}else if(S!==_){_=Fl(Error(r(424)),m),m=cO(c,m,S,y,_);break e}else for(Yn=xi(m.stateNode.containerInfo.firstChild),Gn=m,mr=!0,La=null,y=wP(m,null,S,y),m.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Ml(),S===_){m=Bo(c,m,y);break e}gn(c,m,S,y)}m=m.child}return m;case 5:return _P(m),c===null&&C0(m),S=m.type,_=m.pendingProps,k=c!==null?c.memoizedProps:null,B=_.children,g0(S,_)?B=null:k!==null&&g0(S,k)&&(m.flags|=32),iO(c,m),gn(c,m,B,y),m.child;case 6:return c===null&&C0(m),null;case 13:return uO(c,m,y);case 4:return I0(m,m.stateNode.containerInfo),S=m.pendingProps,c===null?m.child=Rl(m,null,S,y):gn(c,m,S,y),m.child;case 11:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),rO(c,m,S,_,y);case 7:return gn(c,m,m.pendingProps,y),m.child;case 8:return gn(c,m,m.pendingProps.children,y),m.child;case 12:return gn(c,m,m.pendingProps.children,y),m.child;case 10:e:{if(S=m.type._context,_=m.pendingProps,k=m.memoizedProps,B=_.value,rr(Gh,S._currentValue),S._currentValue=B,k!==null)if(Da(k.value,B)){if(k.children===_.children&&!En.current){m=Bo(c,m,y);break e}}else for(k=m.child,k!==null&&(k.return=m);k!==null;){var X=k.dependencies;if(X!==null){B=k.child;for(var te=X.firstContext;te!==null;){if(te.context===S){if(k.tag===1){te=Fo(-1,y&-y),te.tag=2;var ge=k.updateQueue;if(ge!==null){ge=ge.shared;var Oe=ge.pending;Oe===null?te.next=te:(te.next=Oe.next,Oe.next=te),ge.pending=te}}k.lanes|=y,te=k.alternate,te!==null&&(te.lanes|=y),T0(k.return,y,m),X.lanes|=y;break}te=te.next}}else if(k.tag===10)B=k.type===m.type?null:k.child;else if(k.tag===18){if(B=k.return,B===null)throw Error(r(341));B.lanes|=y,X=B.alternate,X!==null&&(X.lanes|=y),T0(B,y,m),B=k.sibling}else B=k.child;if(B!==null)B.return=k;else for(B=k;B!==null;){if(B===m){B=null;break}if(k=B.sibling,k!==null){k.return=B.return,B=k;break}B=B.return}k=B}gn(c,m,_.children,y),m=m.child}return m;case 9:return _=m.type,S=m.pendingProps.children,Ll(m,y),_=ya(_),S=S(_),m.flags|=1,gn(c,m,S,y),m.child;case 14:return S=m.type,_=$a(S,m.pendingProps),_=$a(S.type,_),nO(c,m,S,_,y);case 15:return aO(c,m,m.type,m.pendingProps,y);case 17:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),om(c,m),m.tag=1,Pn(S)?(c=!0,zh(m)):c=!1,Ll(m,y),KP(m,S,_),H0(m,S,_,y),X0(null,m,S,!0,c,y);case 19:return fO(c,m,y);case 22:return oO(c,m,y)}throw Error(r(156,m.tag))};function DO(c,m){return Tu(c,m)}function e9(c,m,y,S){this.tag=c,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ba(c,m,y,S){return new e9(c,m,y,S)}function gx(c){return c=c.prototype,!(!c||!c.isReactComponent)}function t9(c){if(typeof c=="function")return gx(c)?1:0;if(c!=null){if(c=c.$$typeof,c===V)return 11;if(c===H)return 14}return 2}function Ti(c,m){var y=c.alternate;return y===null?(y=ba(c.tag,m,c.key,c.mode),y.elementType=c.elementType,y.type=c.type,y.stateNode=c.stateNode,y.alternate=c,c.alternate=y):(y.pendingProps=m,y.type=c.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=c.flags&14680064,y.childLanes=c.childLanes,y.lanes=c.lanes,y.child=c.child,y.memoizedProps=c.memoizedProps,y.memoizedState=c.memoizedState,y.updateQueue=c.updateQueue,m=c.dependencies,y.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},y.sibling=c.sibling,y.index=c.index,y.ref=c.ref,y}function gm(c,m,y,S,_,k){var B=2;if(S=c,typeof c=="function")gx(c)&&(B=1);else if(typeof c=="string")B=5;else e:switch(c){case T:return vs(y.children,_,k,m);case A:B=8,_|=8;break;case M:return c=ba(12,y,m,_|2),c.elementType=M,c.lanes=k,c;case z:return c=ba(13,y,m,_),c.elementType=z,c.lanes=k,c;case G:return c=ba(19,y,m,_),c.elementType=G,c.lanes=k,c;case q:return ym(y,_,k,m);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case R:B=10;break e;case L:B=9;break e;case V:B=11;break e;case H:B=14;break e;case W:B=16,S=null;break e}throw Error(r(130,c==null?c:typeof c,""))}return m=ba(B,y,m,_),m.elementType=c,m.type=S,m.lanes=k,m}function vs(c,m,y,S){return c=ba(7,c,S,m),c.lanes=y,c}function ym(c,m,y,S){return c=ba(22,c,S,m),c.elementType=q,c.lanes=y,c.stateNode={isHidden:!1},c}function yx(c,m,y){return c=ba(6,c,null,m),c.lanes=y,c}function vx(c,m,y){return m=ba(4,c.children!==null?c.children:[],c.key,m),m.lanes=y,m.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},m}function r9(c,m,y,S,_){this.tag=m,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=as(0),this.expirationTimes=as(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=as(0),this.identifierPrefix=S,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function xx(c,m,y,S,_,k,B,X,te){return c=new r9(c,m,y,X,te),m===1?(m=1,k===!0&&(m|=8)):m=0,k=ba(3,null,null,m),c.current=k,k.stateNode=c,k.memoizedState={element:S,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},A0(k),c}function n9(c,m,y){var S=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Cx.exports=p9(),Cx.exports}var XO;function g9(){if(XO)return Cm;XO=1;var e=v$();return Cm.createRoot=e.createRoot,Cm.hydrateRoot=e.hydrateRoot,Cm}var y9=g9(),x=hy();const U=Vt(x),aC=c9({__proto__:null,default:U},[x]);var Mf=v$();const x$=Vt(Mf);function v9(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}const x9=e=>{switch(e){case"success":return S9;case"info":return N9;case"warning":return j9;case"error":return C9;default:return null}},b9=Array(12).fill(0),w9=({visible:e,className:t})=>U.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},U.createElement("div",{className:"sonner-spinner"},b9.map((r,n)=>U.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),S9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),j9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),N9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),C9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),_9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},U.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),U.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),E9=()=>{const[e,t]=U.useState(document.hidden);return U.useEffect(()=>{const r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e};let lj=1;class P9{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const r=this.subscribers.indexOf(t);this.subscribers.splice(r,1)}),this.publish=t=>{this.subscribers.forEach(r=>r(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var r;const{message:n,...a}=t,i=typeof t?.id=="number"||((r=t.id)==null?void 0:r.length)>0?t.id:lj++,s=this.toasts.find(d=>d.id===i),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(d=>d.id===i?(this.publish({...d,...t,id:i,title:n}),{...d,...t,id:i,dismissible:l,title:n}):d):this.addToast({title:n,...a,dismissible:l,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:t,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),t),this.message=(t,r)=>this.create({...r,message:t}),this.error=(t,r)=>this.create({...r,message:t,type:"error"}),this.success=(t,r)=>this.create({...r,type:"success",message:t}),this.info=(t,r)=>this.create({...r,type:"info",message:t}),this.warning=(t,r)=>this.create({...r,type:"warning",message:t}),this.loading=(t,r)=>this.create({...r,type:"loading",message:t}),this.promise=(t,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:t,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));const a=Promise.resolve(t instanceof Function?t():t);let i=n!==void 0,s;const l=a.then(async u=>{if(s=["resolve",u],U.isValidElement(u))i=!1,this.create({id:n,type:"default",message:u});else if(T9(u)&&!u.ok){i=!1;const h=typeof r.error=="function"?await r.error(`HTTP error! status: ${u.status}`):r.error,p=typeof r.description=="function"?await r.description(`HTTP error! status: ${u.status}`):r.description,v=typeof h=="object"&&!U.isValidElement(h)?h:{message:h};this.create({id:n,type:"error",description:p,...v})}else if(u instanceof Error){i=!1;const h=typeof r.error=="function"?await r.error(u):r.error,p=typeof r.description=="function"?await r.description(u):r.description,v=typeof h=="object"&&!U.isValidElement(h)?h:{message:h};this.create({id:n,type:"error",description:p,...v})}else if(r.success!==void 0){i=!1;const h=typeof r.success=="function"?await r.success(u):r.success,p=typeof r.description=="function"?await r.description(u):r.description,v=typeof h=="object"&&!U.isValidElement(h)?h:{message:h};this.create({id:n,type:"success",description:p,...v})}}).catch(async u=>{if(s=["reject",u],r.error!==void 0){i=!1;const f=typeof r.error=="function"?await r.error(u):r.error,h=typeof r.description=="function"?await r.description(u):r.description,g=typeof f=="object"&&!U.isValidElement(f)?f:{message:f};this.create({id:n,type:"error",description:h,...g})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),r.finally==null||r.finally.call(r)}),d=()=>new Promise((u,f)=>l.then(()=>s[0]==="reject"?f(s[1]):u(s[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:d}:Object.assign(n,{unwrap:d})},this.custom=(t,r)=>{const n=r?.id||lj++;return this.create({jsx:t(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Rn=new P9,O9=(e,t)=>{const r=t?.id||lj++;return Rn.addToast({title:e,...t,id:r}),r},T9=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",k9=O9,A9=()=>Rn.toasts,I9=()=>Rn.getActiveToasts(),ee=Object.assign(k9,{success:Rn.success,info:Rn.info,warning:Rn.warning,error:Rn.error,custom:Rn.custom,message:Rn.message,promise:Rn.promise,dismiss:Rn.dismiss,loading:Rn.loading},{getHistory:A9,getToasts:I9});v9("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function _m(e){return e.label!==void 0}const M9=3,R9="24px",D9="16px",JO=4e3,L9=356,$9=14,F9=45,B9=200;function co(...e){return e.filter(Boolean).join(" ")}function z9(e){const[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}const U9=e=>{var t,r,n,a,i,s,l,d,u;const{invert:f,toast:h,unstyled:p,interacting:g,setHeights:v,visibleToasts:b,heights:w,index:j,toasts:N,expanded:C,removeToast:O,defaultRichColors:P,closeButton:E,style:T,cancelButtonStyle:A,actionButtonStyle:M,className:R="",descriptionClassName:L="",duration:V,position:z,gap:G,expandByDefault:H,classNames:W,icons:q,closeButtonAriaLabel:I="Close toast"}=e,[Y,F]=U.useState(null),[D,$]=U.useState(null),[K,J]=U.useState(!1),[oe,re]=U.useState(!1),[Q,ue]=U.useState(!1),[se,fe]=U.useState(!1),[we,Z]=U.useState(!1),[je,Ce]=U.useState(0),[qe,De]=U.useState(0),He=U.useRef(h.duration||V||JO),ne=U.useRef(null),pe=U.useRef(null),_e=j===0,ve=j+1<=b,ke=h.type,Ge=h.dismissible!==!1,xe=h.className||"",Je=h.descriptionClassName||"",dt=U.useMemo(()=>w.findIndex(Qe=>Qe.toastId===h.id)||0,[w,h.id]),jt=U.useMemo(()=>{var Qe;return(Qe=h.closeButton)!=null?Qe:E},[h.closeButton,E]),Wt=U.useMemo(()=>h.duration||V||JO,[h.duration,V]),er=U.useRef(0),Ae=U.useRef(0),pt=U.useRef(0),Ot=U.useRef(null),[Qt,Ar]=z.split("-"),Vn=U.useMemo(()=>w.reduce((Qe,Tt,Lt)=>Lt>=dt?Qe:Qe+Tt.height,0),[w,dt]),Jr=E9(),Ur=h.invert||f,Er=ke==="loading";Ae.current=U.useMemo(()=>dt*G+Vn,[dt,Vn]),U.useEffect(()=>{He.current=Wt},[Wt]),U.useEffect(()=>{J(!0)},[]),U.useEffect(()=>{const Qe=pe.current;if(Qe){const Tt=Qe.getBoundingClientRect().height;return De(Tt),v(Lt=>[{toastId:h.id,height:Tt,position:h.position},...Lt]),()=>v(Lt=>Lt.filter(sr=>sr.toastId!==h.id))}},[v,h.id]),U.useLayoutEffect(()=>{if(!K)return;const Qe=pe.current,Tt=Qe.style.height;Qe.style.height="auto";const Lt=Qe.getBoundingClientRect().height;Qe.style.height=Tt,De(Lt),v(sr=>sr.find(Le=>Le.toastId===h.id)?sr.map(Le=>Le.toastId===h.id?{...Le,height:Lt}:Le):[{toastId:h.id,height:Lt,position:h.position},...sr])},[K,h.title,h.description,v,h.id,h.jsx,h.action,h.cancel]);const qt=U.useCallback(()=>{re(!0),Ce(Ae.current),v(Qe=>Qe.filter(Tt=>Tt.toastId!==h.id)),setTimeout(()=>{O(h)},B9)},[h,O,v,Ae]);U.useEffect(()=>{if(h.promise&&ke==="loading"||h.duration===1/0||h.type==="loading")return;let Qe;return C||g||Jr?(()=>{if(pt.current{He.current!==1/0&&(er.current=new Date().getTime(),Qe=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),qt()},He.current))})(),()=>clearTimeout(Qe)},[C,g,h,ke,Jr,qt]),U.useEffect(()=>{h.delete&&(qt(),h.onDismiss==null||h.onDismiss.call(h,h))},[qt,h.delete]);function gr(){var Qe;if(q?.loading){var Tt;return U.createElement("div",{className:co(W?.loader,h==null||(Tt=h.classNames)==null?void 0:Tt.loader,"sonner-loader"),"data-visible":ke==="loading"},q.loading)}return U.createElement(w9,{className:co(W?.loader,h==null||(Qe=h.classNames)==null?void 0:Qe.loader),visible:ke==="loading"})}const Kt=h.icon||q?.[ke]||x9(ke);var fr,tr;return U.createElement("li",{tabIndex:0,ref:pe,className:co(R,xe,W?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,W?.default,W?.[ke],h==null||(r=h.classNames)==null?void 0:r[ke]),"data-sonner-toast":"","data-rich-colors":(fr=h.richColors)!=null?fr:P,"data-styled":!(h.jsx||h.unstyled||p),"data-mounted":K,"data-promise":!!h.promise,"data-swiped":we,"data-removed":oe,"data-visible":ve,"data-y-position":Qt,"data-x-position":Ar,"data-index":j,"data-front":_e,"data-swiping":Q,"data-dismissible":Ge,"data-type":ke,"data-invert":Ur,"data-swipe-out":se,"data-swipe-direction":D,"data-expanded":!!(C||H&&K),"data-testid":h.testId,style:{"--index":j,"--toasts-before":j,"--z-index":N.length-j,"--offset":`${oe?je:Ae.current}px`,"--initial-height":H?"auto":`${qe}px`,...T,...h.style},onDragEnd:()=>{ue(!1),F(null),Ot.current=null},onPointerDown:Qe=>{Qe.button!==2&&(Er||!Ge||(ne.current=new Date,Ce(Ae.current),Qe.target.setPointerCapture(Qe.pointerId),Qe.target.tagName!=="BUTTON"&&(ue(!0),Ot.current={x:Qe.clientX,y:Qe.clientY})))},onPointerUp:()=>{var Qe,Tt,Lt;if(se||!Ge)return;Ot.current=null;const sr=Number(((Qe=pe.current)==null?void 0:Qe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),be=Number(((Tt=pe.current)==null?void 0:Tt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Lt=ne.current)==null?void 0:Lt.getTime()),rt=Y==="x"?sr:be,Xt=Math.abs(rt)/Le;if(Math.abs(rt)>=F9||Xt>.11){Ce(Ae.current),h.onDismiss==null||h.onDismiss.call(h,h),$(Y==="x"?sr>0?"right":"left":be>0?"down":"up"),qt(),fe(!0);return}else{var vt,hr;(vt=pe.current)==null||vt.style.setProperty("--swipe-amount-x","0px"),(hr=pe.current)==null||hr.style.setProperty("--swipe-amount-y","0px")}Z(!1),ue(!1),F(null)},onPointerMove:Qe=>{var Tt,Lt,sr;if(!Ot.current||!Ge||((Tt=window.getSelection())==null?void 0:Tt.toString().length)>0)return;const Le=Qe.clientY-Ot.current.y,rt=Qe.clientX-Ot.current.x;var Xt;const vt=(Xt=e.swipeDirections)!=null?Xt:z9(z);!Y&&(Math.abs(rt)>1||Math.abs(Le)>1)&&F(Math.abs(rt)>Math.abs(Le)?"x":"y");let hr={x:0,y:0};const Qr=Ir=>1/(1.5+Math.abs(Ir)/20);if(Y==="y"){if(vt.includes("top")||vt.includes("bottom"))if(vt.includes("top")&&Le<0||vt.includes("bottom")&&Le>0)hr.y=Le;else{const Ir=Le*Qr(Le);hr.y=Math.abs(Ir)0)hr.x=rt;else{const Ir=rt*Qr(rt);hr.x=Math.abs(Ir)0||Math.abs(hr.y)>0)&&Z(!0),(Lt=pe.current)==null||Lt.style.setProperty("--swipe-amount-x",`${hr.x}px`),(sr=pe.current)==null||sr.style.setProperty("--swipe-amount-y",`${hr.y}px`)}},jt&&!h.jsx&&ke!=="loading"?U.createElement("button",{"aria-label":I,"data-disabled":Er,"data-close-button":!0,onClick:Er||!Ge?()=>{}:()=>{qt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:co(W?.closeButton,h==null||(n=h.classNames)==null?void 0:n.closeButton)},(tr=q?.close)!=null?tr:_9):null,(ke||h.icon||h.promise)&&h.icon!==null&&(q?.[ke]!==null||h.icon)?U.createElement("div",{"data-icon":"",className:co(W?.icon,h==null||(a=h.classNames)==null?void 0:a.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||gr():null,h.type!=="loading"?Kt:null):null,U.createElement("div",{"data-content":"",className:co(W?.content,h==null||(i=h.classNames)==null?void 0:i.content)},U.createElement("div",{"data-title":"",className:co(W?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?U.createElement("div",{"data-description":"",className:co(L,Je,W?.description,h==null||(l=h.classNames)==null?void 0:l.description)},typeof h.description=="function"?h.description():h.description):null),U.isValidElement(h.cancel)?h.cancel:h.cancel&&_m(h.cancel)?U.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||A,onClick:Qe=>{_m(h.cancel)&&Ge&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Qe),qt())},className:co(W?.cancelButton,h==null||(d=h.classNames)==null?void 0:d.cancelButton)},h.cancel.label):null,U.isValidElement(h.action)?h.action:h.action&&_m(h.action)?U.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Qe=>{_m(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Qe),!Qe.defaultPrevented&&qt())},className:co(W?.actionButton,h==null||(u=h.classNames)==null?void 0:u.actionButton)},h.action.label):null)};function QO(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function q9(e,t){const r={};return[e,t].forEach((n,a)=>{const i=a===1,s=i?"--mobile-offset":"--offset",l=i?D9:R9;function d(u){["top","right","bottom","left"].forEach(f=>{r[`${s}-${f}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${s}-${u}`]=l:r[`${s}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):d(l)}),r}const V9=U.forwardRef(function(t,r){const{id:n,invert:a,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:l,closeButton:d,className:u,offset:f,mobileOffset:h,theme:p="light",richColors:g,duration:v,style:b,visibleToasts:w=M9,toastOptions:j,dir:N=QO(),gap:C=$9,icons:O,containerAriaLabel:P="Notifications"}=t,[E,T]=U.useState([]),A=U.useMemo(()=>n?E.filter(K=>K.toasterId===n):E.filter(K=>!K.toasterId),[E,n]),M=U.useMemo(()=>Array.from(new Set([i].concat(A.filter(K=>K.position).map(K=>K.position)))),[A,i]),[R,L]=U.useState([]),[V,z]=U.useState(!1),[G,H]=U.useState(!1),[W,q]=U.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),I=U.useRef(null),Y=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=U.useRef(null),D=U.useRef(!1),$=U.useCallback(K=>{T(J=>{var oe;return(oe=J.find(re=>re.id===K.id))!=null&&oe.delete||Rn.dismiss(K.id),J.filter(({id:re})=>re!==K.id)})},[]);return U.useEffect(()=>Rn.subscribe(K=>{if(K.dismiss){requestAnimationFrame(()=>{T(J=>J.map(oe=>oe.id===K.id?{...oe,delete:!0}:oe))});return}setTimeout(()=>{x$.flushSync(()=>{T(J=>{const oe=J.findIndex(re=>re.id===K.id);return oe!==-1?[...J.slice(0,oe),{...J[oe],...K},...J.slice(oe+1)]:[K,...J]})})})}),[E]),U.useEffect(()=>{if(p!=="system"){q(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;const K=window.matchMedia("(prefers-color-scheme: dark)");try{K.addEventListener("change",({matches:J})=>{q(J?"dark":"light")})}catch{K.addListener(({matches:oe})=>{try{q(oe?"dark":"light")}catch(re){console.error(re)}})}},[p]),U.useEffect(()=>{E.length<=1&&z(!1)},[E]),U.useEffect(()=>{const K=J=>{var oe;if(s.every(ue=>J[ue]||J.code===ue)){var Q;z(!0),(Q=I.current)==null||Q.focus()}J.code==="Escape"&&(document.activeElement===I.current||(oe=I.current)!=null&&oe.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[s]),U.useEffect(()=>{if(I.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,D.current=!1)}},[I.current]),U.createElement("section",{ref:r,"aria-label":`${P} ${Y}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((K,J)=>{var oe;const[re,Q]=K.split("-");return A.length?U.createElement("ol",{key:K,dir:N==="auto"?QO():N,tabIndex:-1,ref:I,className:u,"data-sonner-toaster":!0,"data-sonner-theme":W,"data-y-position":re,"data-x-position":Q,style:{"--front-toast-height":`${((oe=R[0])==null?void 0:oe.height)||0}px`,"--width":`${L9}px`,"--gap":`${C}px`,...b,...q9(f,h)},onBlur:ue=>{D.current&&!ue.currentTarget.contains(ue.relatedTarget)&&(D.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:ue=>{ue.target instanceof HTMLElement&&ue.target.dataset.dismissible==="false"||D.current||(D.current=!0,F.current=ue.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{G||z(!1)},onDragEnd:()=>z(!1),onPointerDown:ue=>{ue.target instanceof HTMLElement&&ue.target.dataset.dismissible==="false"||H(!0)},onPointerUp:()=>H(!1)},A.filter(ue=>!ue.position&&J===0||ue.position===K).map((ue,se)=>{var fe,we;return U.createElement(U9,{key:ue.id,icons:O,index:se,toast:ue,defaultRichColors:g,duration:(fe=j?.duration)!=null?fe:v,className:j?.className,descriptionClassName:j?.descriptionClassName,invert:a,visibleToasts:w,closeButton:(we=j?.closeButton)!=null?we:d,interacting:G,position:K,style:j?.style,unstyled:j?.unstyled,classNames:j?.classNames,cancelButtonStyle:j?.cancelButtonStyle,actionButtonStyle:j?.actionButtonStyle,closeButtonAriaLabel:j?.closeButtonAriaLabel,removeToast:$,toasts:A.filter(Z=>Z.position==ue.position),heights:R.filter(Z=>Z.position==ue.position),setHeights:L,expandByDefault:l,gap:C,expanded:V,swipeDirections:t.swipeDirections})})):null}))});/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const W9=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),H9=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),ZO=e=>{const t=H9(e);return t.charAt(0).toUpperCase()+t.slice(1)},b$=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var G9={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Y9=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:i,iconNode:s,...l},d)=>x.createElement("svg",{ref:d,...G9,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:b$("lucide",a),...l},[...s.map(([u,f])=>x.createElement(u,f)),...Array.isArray(i)?i:[i]]));/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const at=(e,t)=>{const r=x.forwardRef(({className:n,...a},i)=>x.createElement(Y9,{ref:i,iconNode:t,className:b$(`lucide-${W9(ZO(e))}`,`lucide-${e}`,n),...a}));return r.displayName=ZO(e),r};/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const K9=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]],X9=at("arrow-down-a-z",K9);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const J9=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Q9=at("arrow-down-right",J9);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Z9=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],w$=at("arrow-left",Z9);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eq=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],tq=at("arrow-up-down",eq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rq=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],S$=at("arrow-up-right",rq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nq=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],aq=at("calendar",nq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oq=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],iq=at("chart-column",oq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],j$=at("check",sq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bs=at("chevron-down",lq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cq=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],oC=at("chevron-left",cq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uq=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ui=at("chevron-right",uq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dq=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],fq=at("chevron-up",dq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hq=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],N$=at("chevrons-up-down",hq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const mq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Wd=at("circle-help",mq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],gq=at("circle-user",pq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yq=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],vq=at("coffee",yq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xq=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],iC=at("download",xq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bq=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ri=at("ellipsis",bq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wq=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]],sC=at("file-box",wq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Sq=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],zs=at("file-text",Sq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const jq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Nq=at("grid-3x3",jq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Cq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],lC=at("image",Cq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _q=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],cC=at("layers",_q);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Eq=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Vp=at("layout-dashboard",Eq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Pq=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],Oq=at("list",Pq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Tq=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],cj=at("log-out",Tq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kq=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],Aq=at("mail",kq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Iq=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],lu=at("map-pin",Iq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Mq=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],Rq=at("menu",Mq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Dq=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],jc=at("package",Dq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Lq=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],C$=at("palette",Lq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $q=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Rp=at("pencil",$q);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Fq=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],Bq=at("phone",Fq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const zq=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Uq=at("pin",zq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Un=at("plus",qq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Vq=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],_$=at("printer",Vq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Wq=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Hq=at("refresh-cw",Wq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Gq=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Yq=at("save",Gq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Kq=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Rf=at("search",Kq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Xq=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Nc=at("settings",Xq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Jq=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Qq=at("shield",Jq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Zq=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],oa=at("square-pen",Zq);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const e7=[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]],t7=at("store",e7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const r7=[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]],Px=at("syringe",r7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const n7=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],a7=at("tablet",n7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const o7=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Cc=at("tag",o7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const i7=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],s7=at("timer",i7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const l7=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],zt=at("trash-2",l7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const c7=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],u7=at("trending-up",c7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const d7=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],Df=at("type",d7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const f7=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],h7=at("upload",f7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const m7=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],p7=at("user",m7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const g7=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],my=at("users",g7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const y7=[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]],v7=at("utensils",y7);/** - * @license lucide-react v0.487.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const x7=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$i=at("x",x7);function E$(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t{const r=new Array(e.length+t.length);for(let n=0;n({classGroupId:e,validator:t}),P$=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Wp="-",eT=[],S7="arbitrary..",j7=e=>{const t=C7(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return N7(s);const l=s.split(Wp),d=l[0]===""&&l.length>1?1:0;return O$(l,d,t)},getConflictingClassGroupIds:(s,l)=>{if(l){const d=n[s],u=r[s];return d?u?b7(u,d):d:u||eT}return r[s]||eT}}},O$=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const a=e[t],i=r.nextPart.get(a);if(i){const u=O$(e,t+1,i);if(u)return u}const s=r.validators;if(s===null)return;const l=t===0?e.join(Wp):e.slice(t).join(Wp),d=s.length;for(let u=0;ue.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?S7+n:void 0})(),C7=e=>{const{theme:t,classGroups:r}=e;return _7(r,t)},_7=(e,t)=>{const r=P$();for(const n in e){const a=e[n];uC(a,r,n,t)}return r},uC=(e,t,r,n)=>{const a=e.length;for(let i=0;i{if(typeof e=="string"){P7(e,t,r);return}if(typeof e=="function"){O7(e,t,r,n);return}T7(e,t,r,n)},P7=(e,t,r)=>{const n=e===""?t:T$(t,e);n.classGroupId=r},O7=(e,t,r,n)=>{if(k7(e)){uC(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(w7(r,e))},T7=(e,t,r,n)=>{const a=Object.entries(e),i=a.length;for(let s=0;s{let r=e;const n=t.split(Wp),a=n.length;for(let i=0;i"isThemeGetter"in e&&e.isThemeGetter===!0,A7=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const a=(i,s)=>{r[i]=s,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(i){let s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return a(i,s),s},set(i,s){i in r?r[i]=s:a(i,s)}}},uj="!",tT=":",I7=[],rT=(e,t,r,n,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:a}),M7=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const i=[];let s=0,l=0,d=0,u;const f=a.length;for(let b=0;bd?u-d:void 0;return rT(i,g,p,v)};if(t){const a=t+tT,i=n;n=s=>s.startsWith(a)?i(s.slice(a.length)):rT(I7,!1,s,void 0,!0)}if(r){const a=n;n=i=>r({className:i,parseClassName:a})}return n},R7=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let a=[];for(let i=0;i0&&(a.sort(),n.push(...a),a=[]),n.push(s)):a.push(s)}return a.length>0&&(a.sort(),n.push(...a)),n}},D7=e=>({cache:A7(e.cacheSize),parseClassName:M7(e),sortModifiers:R7(e),...j7(e)}),L7=/\s+/,$7=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:i}=t,s=[],l=e.trim().split(L7);let d="";for(let u=l.length-1;u>=0;u-=1){const f=l[u],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:b}=r(f);if(h){d=f+(d.length>0?" "+d:d);continue}let w=!!b,j=n(w?v.substring(0,b):v);if(!j){if(!w){d=f+(d.length>0?" "+d:d);continue}if(j=n(v),!j){d=f+(d.length>0?" "+d:d);continue}w=!1}const N=p.length===0?"":p.length===1?p[0]:i(p).join(":"),C=g?N+uj:N,O=C+j;if(s.indexOf(O)>-1)continue;s.push(O);const P=a(j,w);for(let E=0;E0?" "+d:d)}return d},F7=(...e)=>{let t=0,r,n,a="";for(;t{if(typeof e=="string")return e;let t,r="";for(let n=0;n{let r,n,a,i;const s=d=>{const u=t.reduce((f,h)=>h(f),e());return r=D7(u),n=r.cache.get,a=r.cache.set,i=l,l(d)},l=d=>{const u=n(d);if(u)return u;const f=$7(d,r);return a(d,f),f};return i=s,(...d)=>i(F7(...d))},z7=[],Dr=e=>{const t=r=>r[e]||z7;return t.isThemeGetter=!0,t},A$=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,I$=/^\((?:(\w[\w-]*):)?(.+)\)$/i,U7=/^\d+\/\d+$/,q7=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,V7=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,W7=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,H7=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,G7=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Vl=e=>U7.test(e),bt=e=>!!e&&!Number.isNaN(Number(e)),Ai=e=>!!e&&Number.isInteger(Number(e)),Ox=e=>e.endsWith("%")&&bt(e.slice(0,-1)),Uo=e=>q7.test(e),Y7=()=>!0,K7=e=>V7.test(e)&&!W7.test(e),M$=()=>!1,X7=e=>H7.test(e),J7=e=>G7.test(e),Q7=e=>!Ke(e)&&!Xe(e),Z7=e=>cu(e,L$,M$),Ke=e=>A$.test(e),xs=e=>cu(e,$$,K7),Tx=e=>cu(e,aV,bt),nT=e=>cu(e,R$,M$),eV=e=>cu(e,D$,J7),Em=e=>cu(e,F$,X7),Xe=e=>I$.test(e),hd=e=>uu(e,$$),tV=e=>uu(e,oV),aT=e=>uu(e,R$),rV=e=>uu(e,L$),nV=e=>uu(e,D$),Pm=e=>uu(e,F$,!0),cu=(e,t,r)=>{const n=A$.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},uu=(e,t,r=!1)=>{const n=I$.exec(e);return n?n[1]?t(n[1]):r:!1},R$=e=>e==="position"||e==="percentage",D$=e=>e==="image"||e==="url",L$=e=>e==="length"||e==="size"||e==="bg-size",$$=e=>e==="length",aV=e=>e==="number",oV=e=>e==="family-name",F$=e=>e==="shadow",iV=()=>{const e=Dr("color"),t=Dr("font"),r=Dr("text"),n=Dr("font-weight"),a=Dr("tracking"),i=Dr("leading"),s=Dr("breakpoint"),l=Dr("container"),d=Dr("spacing"),u=Dr("radius"),f=Dr("shadow"),h=Dr("inset-shadow"),p=Dr("text-shadow"),g=Dr("drop-shadow"),v=Dr("blur"),b=Dr("perspective"),w=Dr("aspect"),j=Dr("ease"),N=Dr("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...O(),Xe,Ke],E=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],A=()=>[Xe,Ke,d],M=()=>[Vl,"full","auto",...A()],R=()=>[Ai,"none","subgrid",Xe,Ke],L=()=>["auto",{span:["full",Ai,Xe,Ke]},Ai,Xe,Ke],V=()=>[Ai,"auto",Xe,Ke],z=()=>["auto","min","max","fr",Xe,Ke],G=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],W=()=>["auto",...A()],q=()=>[Vl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],I=()=>[e,Xe,Ke],Y=()=>[...O(),aT,nT,{position:[Xe,Ke]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],D=()=>["auto","cover","contain",rV,Z7,{size:[Xe,Ke]}],$=()=>[Ox,hd,xs],K=()=>["","none","full",u,Xe,Ke],J=()=>["",bt,hd,xs],oe=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[bt,Ox,aT,nT],ue=()=>["","none",v,Xe,Ke],se=()=>["none",bt,Xe,Ke],fe=()=>["none",bt,Xe,Ke],we=()=>[bt,Xe,Ke],Z=()=>[Vl,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Uo],breakpoint:[Uo],color:[Y7],container:[Uo],"drop-shadow":[Uo],ease:["in","out","in-out"],font:[Q7],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Uo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Uo],shadow:[Uo],spacing:["px",bt],text:[Uo],"text-shadow":[Uo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Vl,Ke,Xe,w]}],container:["container"],columns:[{columns:[bt,Ke,Xe,l]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{start:M()}],end:[{end:M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[Ai,"auto",Xe,Ke]}],basis:[{basis:[Vl,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[bt,Vl,"auto","initial","none",Ke]}],grow:[{grow:["",bt,Xe,Ke]}],shrink:[{shrink:["",bt,Xe,Ke]}],order:[{order:[Ai,"first","last","none",Xe,Ke]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...G(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...G()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":G()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:W()}],mx:[{mx:W()}],my:[{my:W()}],ms:[{ms:W()}],me:[{me:W()}],mt:[{mt:W()}],mr:[{mr:W()}],mb:[{mb:W()}],ml:[{ml:W()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],w:[{w:[l,"screen",...q()]}],"min-w":[{"min-w":[l,"screen","none",...q()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[s]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",r,hd,xs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Xe,Tx]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ox,Ke]}],"font-family":[{font:[tV,Ke,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Xe,Ke]}],"line-clamp":[{"line-clamp":[bt,"none",Xe,Tx]}],leading:[{leading:[i,...A()]}],"list-image":[{"list-image":["none",Xe,Ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Xe,Ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[bt,"from-font","auto",Xe,xs]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[bt,"auto",Xe,Ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Xe,Ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Xe,Ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:D()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ai,Xe,Ke],radial:["",Xe,Ke],conic:[Ai,Xe,Ke]},nV,eV]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:K()}],"rounded-s":[{"rounded-s":K()}],"rounded-e":[{"rounded-e":K()}],"rounded-t":[{"rounded-t":K()}],"rounded-r":[{"rounded-r":K()}],"rounded-b":[{"rounded-b":K()}],"rounded-l":[{"rounded-l":K()}],"rounded-ss":[{"rounded-ss":K()}],"rounded-se":[{"rounded-se":K()}],"rounded-ee":[{"rounded-ee":K()}],"rounded-es":[{"rounded-es":K()}],"rounded-tl":[{"rounded-tl":K()}],"rounded-tr":[{"rounded-tr":K()}],"rounded-br":[{"rounded-br":K()}],"rounded-bl":[{"rounded-bl":K()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[bt,Xe,Ke]}],"outline-w":[{outline:["",bt,hd,xs]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",f,Pm,Em]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",h,Pm,Em]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[bt,xs]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",p,Pm,Em]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[bt,Xe,Ke]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[bt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[Xe,Ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[bt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:D()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Xe,Ke]}],filter:[{filter:["","none",Xe,Ke]}],blur:[{blur:ue()}],brightness:[{brightness:[bt,Xe,Ke]}],contrast:[{contrast:[bt,Xe,Ke]}],"drop-shadow":[{"drop-shadow":["","none",g,Pm,Em]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",bt,Xe,Ke]}],"hue-rotate":[{"hue-rotate":[bt,Xe,Ke]}],invert:[{invert:["",bt,Xe,Ke]}],saturate:[{saturate:[bt,Xe,Ke]}],sepia:[{sepia:["",bt,Xe,Ke]}],"backdrop-filter":[{"backdrop-filter":["","none",Xe,Ke]}],"backdrop-blur":[{"backdrop-blur":ue()}],"backdrop-brightness":[{"backdrop-brightness":[bt,Xe,Ke]}],"backdrop-contrast":[{"backdrop-contrast":[bt,Xe,Ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",bt,Xe,Ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[bt,Xe,Ke]}],"backdrop-invert":[{"backdrop-invert":["",bt,Xe,Ke]}],"backdrop-opacity":[{"backdrop-opacity":[bt,Xe,Ke]}],"backdrop-saturate":[{"backdrop-saturate":[bt,Xe,Ke]}],"backdrop-sepia":[{"backdrop-sepia":["",bt,Xe,Ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Xe,Ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[bt,"initial",Xe,Ke]}],ease:[{ease:["linear","initial",j,Xe,Ke]}],delay:[{delay:[bt,Xe,Ke]}],animate:[{animate:["none",N,Xe,Ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Xe,Ke]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:fe()}],"scale-x":[{"scale-x":fe()}],"scale-y":[{"scale-y":fe()}],"scale-z":[{"scale-z":fe()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[Xe,Ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Z()}],"translate-x":[{"translate-x":Z()}],"translate-y":[{"translate-y":Z()}],"translate-z":[{"translate-z":Z()}],"translate-none":["translate-none"],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Xe,Ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Xe,Ke]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[bt,hd,xs,Tx]}],stroke:[{stroke:["none",...I()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},sV=B7(iV);function Ie(...e){return sV(yt(e))}function oT(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Oa(...e){return t=>{let r=!1;const n=e.map(a=>{const i=oT(a,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let a=0;a{const{children:i,...s}=n,l=x.Children.toArray(i),d=l.find(dV);if(d){const u=d.props.children,f=l.map(h=>h===d?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:h);return o.jsx(t,{...s,ref:a,children:x.isValidElement(u)?x.cloneElement(u,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function cV(e){const t=x.forwardRef((r,n)=>{const{children:a,...i}=r;if(x.isValidElement(a)){const s=hV(a),l=fV(i,a.props);return a.type!==x.Fragment&&(l.ref=n?Oa(n,s):s),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var uV=Symbol("radix.slottable");function dV(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===uV}function fV(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function hV(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var mV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],lt=mV.reduce((e,t)=>{const r=lV(`Primitive.${t}`),n=x.forwardRef((a,i)=>{const{asChild:s,...l}=a,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function pV(e,t){e&&Mf.flushSync(()=>e.dispatchEvent(t))}var kr=globalThis?.document?x.useLayoutEffect:()=>{};function gV(e,t){return x.useReducer((r,n)=>t[r][n]??r,e)}var to=e=>{const{present:t,children:r}=e,n=yV(t),a=typeof r=="function"?r({present:n.isPresent}):x.Children.only(r),i=At(n.ref,vV(a));return typeof r=="function"||n.isPresent?x.cloneElement(a,{ref:i}):null};to.displayName="Presence";function yV(e){const[t,r]=x.useState(),n=x.useRef(null),a=x.useRef(e),i=x.useRef("none"),s=e?"mounted":"unmounted",[l,d]=gV(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const u=Om(n.current);i.current=l==="mounted"?u:"none"},[l]),kr(()=>{const u=n.current,f=a.current;if(f!==e){const p=i.current,g=Om(u);e?d("MOUNT"):g==="none"||u?.display==="none"?d("UNMOUNT"):d(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,d]),kr(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,h=g=>{const b=Om(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(d("ANIMATION_END"),!a.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},p=g=>{g.target===t&&(i.current=Om(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:x.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function Om(e){return e?.animationName||"none"}function vV(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function xV(e,t){const r=x.createContext(t),n=i=>{const{children:s,...l}=i,d=x.useMemo(()=>l,Object.values(l));return o.jsx(r.Provider,{value:d,children:s})};n.displayName=e+"Provider";function a(i){const s=x.useContext(r);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[n,a]}function Eo(e,t=[]){let r=[];function n(i,s){const l=x.createContext(s),d=r.length;r=[...r,s];const u=h=>{const{scope:p,children:g,...v}=h,b=p?.[e]?.[d]||l,w=x.useMemo(()=>v,Object.values(v));return o.jsx(b.Provider,{value:w,children:g})};u.displayName=i+"Provider";function f(h,p){const g=p?.[e]?.[d]||l,v=x.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[u,f]}const a=()=>{const i=r.map(s=>x.createContext(s));return function(l){const d=l?.[e]||i;return x.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return a.scopeName=e,[n,bV(a,...t)]}function bV(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const s=n.reduce((l,{useScope:d,scopeName:u})=>{const h=d(i)[`__scope${u}`];return{...l,...h}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}function dn(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...r)=>t.current?.(...r),[])}var wV=x.createContext(void 0);function py(e){const t=x.useContext(wV);return e||t||"ltr"}function dj(e,[t,r]){return Math.min(r,Math.max(t,e))}function mt(e,t,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return t?.(a)}}function SV(e,t){return x.useReducer((r,n)=>t[r][n]??r,e)}var dC="ScrollArea",[B$]=Eo(dC),[jV,Ma]=B$(dC),z$=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:i=600,...s}=e,[l,d]=x.useState(null),[u,f]=x.useState(null),[h,p]=x.useState(null),[g,v]=x.useState(null),[b,w]=x.useState(null),[j,N]=x.useState(0),[C,O]=x.useState(0),[P,E]=x.useState(!1),[T,A]=x.useState(!1),M=At(t,L=>d(L)),R=py(a);return o.jsx(jV,{scope:r,type:n,dir:R,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:f,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:P,onScrollbarXEnabledChange:E,scrollbarY:b,onScrollbarYChange:w,scrollbarYEnabled:T,onScrollbarYEnabledChange:A,onCornerWidthChange:N,onCornerHeightChange:O,children:o.jsx(lt.div,{dir:R,...s,ref:M,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});z$.displayName=dC;var U$="ScrollAreaViewport",q$=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:a,...i}=e,s=Ma(U$,r),l=x.useRef(null),d=At(t,l,s.onViewportChange);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),o.jsx(lt.div,{"data-radix-scroll-area-viewport":"",...i,ref:d,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:o.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});q$.displayName=U$;var Po="ScrollAreaScrollbar",V$=x.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Ma(Po,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=a,l=e.orientation==="horizontal";return x.useEffect(()=>(l?i(!0):s(!0),()=>{l?i(!1):s(!1)}),[l,i,s]),a.type==="hover"?o.jsx(NV,{...n,ref:t,forceMount:r}):a.type==="scroll"?o.jsx(CV,{...n,ref:t,forceMount:r}):a.type==="auto"?o.jsx(W$,{...n,ref:t,forceMount:r}):a.type==="always"?o.jsx(fC,{...n,ref:t}):null});V$.displayName=Po;var NV=x.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Ma(Po,e.__scopeScrollArea),[i,s]=x.useState(!1);return x.useEffect(()=>{const l=a.scrollArea;let d=0;if(l){const u=()=>{window.clearTimeout(d),s(!0)},f=()=>{d=window.setTimeout(()=>s(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",f),()=>{window.clearTimeout(d),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",f)}}},[a.scrollArea,a.scrollHideDelay]),o.jsx(to,{present:r||i,children:o.jsx(W$,{"data-state":i?"visible":"hidden",...n,ref:t})})}),CV=x.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Ma(Po,e.__scopeScrollArea),i=e.orientation==="horizontal",s=yy(()=>d("SCROLL_END"),100),[l,d]=SV("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return x.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,a.scrollHideDelay,d]),x.useEffect(()=>{const u=a.viewport,f=i?"scrollLeft":"scrollTop";if(u){let h=u[f];const p=()=>{const g=u[f];h!==g&&(d("SCROLL"),s()),h=g};return u.addEventListener("scroll",p),()=>u.removeEventListener("scroll",p)}},[a.viewport,i,d,s]),o.jsx(to,{present:r||l!=="hidden",children:o.jsx(fC,{"data-state":l==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:mt(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:mt(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),W$=x.forwardRef((e,t)=>{const r=Ma(Po,e.__scopeScrollArea),{forceMount:n,...a}=e,[i,s]=x.useState(!1),l=e.orientation==="horizontal",d=yy(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=e,a=Ma(Po,e.__scopeScrollArea),i=x.useRef(null),s=x.useRef(0),[l,d]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=X$(l.viewport,l.content),f={...n,sizes:l,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function h(p,g){return kV(p,s.current,l,g)}return r==="horizontal"?o.jsx(_V,{...f,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const p=a.viewport.scrollLeft,g=iT(p,l,a.dir);i.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollLeft=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollLeft=h(p,a.dir))}}):r==="vertical"?o.jsx(EV,{...f,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const p=a.viewport.scrollTop,g=iT(p,l);i.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollTop=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollTop=h(p))}}):null}),_V=x.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...a}=e,i=Ma(Po,e.__scopeScrollArea),[s,l]=x.useState(),d=x.useRef(null),u=At(t,d,i.onScrollbarXChange);return x.useEffect(()=>{d.current&&l(getComputedStyle(d.current))},[d]),o.jsx(G$,{"data-orientation":"horizontal",...a,ref:u,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":gy(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,h)=>{if(i.viewport){const p=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),Q$(p,h)&&f.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Gp(s.paddingLeft),paddingEnd:Gp(s.paddingRight)}})}})}),EV=x.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...a}=e,i=Ma(Po,e.__scopeScrollArea),[s,l]=x.useState(),d=x.useRef(null),u=At(t,d,i.onScrollbarYChange);return x.useEffect(()=>{d.current&&l(getComputedStyle(d.current))},[d]),o.jsx(G$,{"data-orientation":"vertical",...a,ref:u,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":gy(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,h)=>{if(i.viewport){const p=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),Q$(p,h)&&f.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Gp(s.paddingTop),paddingEnd:Gp(s.paddingBottom)}})}})}),[PV,H$]=B$(Po),G$=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:l,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:f,onResize:h,...p}=e,g=Ma(Po,r),[v,b]=x.useState(null),w=At(t,M=>b(M)),j=x.useRef(null),N=x.useRef(""),C=g.viewport,O=n.content-n.viewport,P=dn(f),E=dn(d),T=yy(h,10);function A(M){if(j.current){const R=M.clientX-j.current.left,L=M.clientY-j.current.top;u({x:R,y:L})}}return x.useEffect(()=>{const M=R=>{const L=R.target;v?.contains(L)&&P(R,O)};return document.addEventListener("wheel",M,{passive:!1}),()=>document.removeEventListener("wheel",M,{passive:!1})},[C,v,O,P]),x.useEffect(E,[n,E]),_c(v,T),_c(g.content,T),o.jsx(PV,{scope:r,scrollbar:v,hasThumb:a,onThumbChange:dn(i),onThumbPointerUp:dn(s),onThumbPositionChange:E,onThumbPointerDown:dn(l),children:o.jsx(lt.div,{...p,ref:w,style:{position:"absolute",...p.style},onPointerDown:mt(e.onPointerDown,M=>{M.button===0&&(M.target.setPointerCapture(M.pointerId),j.current=v.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),A(M))}),onPointerMove:mt(e.onPointerMove,A),onPointerUp:mt(e.onPointerUp,M=>{const R=M.target;R.hasPointerCapture(M.pointerId)&&R.releasePointerCapture(M.pointerId),document.body.style.webkitUserSelect=N.current,g.viewport&&(g.viewport.style.scrollBehavior=""),j.current=null})})})}),Hp="ScrollAreaThumb",Y$=x.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=H$(Hp,e.__scopeScrollArea);return o.jsx(to,{present:r||a.hasThumb,children:o.jsx(OV,{ref:t,...n})})}),OV=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...a}=e,i=Ma(Hp,r),s=H$(Hp,r),{onThumbPositionChange:l}=s,d=At(t,h=>s.onThumbChange(h)),u=x.useRef(void 0),f=yy(()=>{u.current&&(u.current(),u.current=void 0)},100);return x.useEffect(()=>{const h=i.viewport;if(h){const p=()=>{if(f(),!u.current){const g=AV(h,l);u.current=g,l()}};return l(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[i.viewport,f,l]),o.jsx(lt.div,{"data-state":s.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:mt(e.onPointerDownCapture,h=>{const g=h.target.getBoundingClientRect(),v=h.clientX-g.left,b=h.clientY-g.top;s.onThumbPointerDown({x:v,y:b})}),onPointerUp:mt(e.onPointerUp,s.onThumbPointerUp)})});Y$.displayName=Hp;var hC="ScrollAreaCorner",K$=x.forwardRef((e,t)=>{const r=Ma(hC,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?o.jsx(TV,{...e,ref:t}):null});K$.displayName=hC;var TV=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,a=Ma(hC,r),[i,s]=x.useState(0),[l,d]=x.useState(0),u=!!(i&&l);return _c(a.scrollbarX,()=>{const f=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(f),d(f)}),_c(a.scrollbarY,()=>{const f=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(f),s(f)}),u?o.jsx(lt.div,{...n,ref:t,style:{width:i,height:l,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Gp(e){return e?parseInt(e,10):0}function X$(e,t){const r=e/t;return isNaN(r)?0:r}function gy(e){const t=X$(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function kV(e,t,r,n="ltr"){const a=gy(r),i=a/2,s=t||i,l=a-s,d=r.scrollbar.paddingStart+s,u=r.scrollbar.size-r.scrollbar.paddingEnd-l,f=r.content-r.viewport,h=n==="ltr"?[0,f]:[f*-1,0];return J$([d,u],h)(e)}function iT(e,t,r="ltr"){const n=gy(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-a,s=t.content-t.viewport,l=i-n,d=r==="ltr"?[0,s]:[s*-1,0],u=dj(e,d);return J$([0,s],[0,l])(u)}function J$(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function Q$(e,t){return e>0&&e{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function a(){const i={left:e.scrollLeft,top:e.scrollTop},s=r.left!==i.left,l=r.top!==i.top;(s||l)&&t(),r=i,n=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(n)};function yy(e,t){const r=dn(e),n=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(n.current),[]),x.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function _c(e,t){const r=dn(t);kr(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,r])}var IV=z$,MV=q$,RV=K$;function Ec({className:e,children:t,...r}){return o.jsxs(IV,{"data-slot":"scroll-area",className:Ie("relative",e),...r,children:[o.jsx(MV,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),o.jsx(DV,{}),o.jsx(RV,{})]})}function DV({className:e,orientation:t="vertical",...r}){return o.jsx(V$,{"data-slot":"scroll-area-scrollbar",orientation:t,className:Ie("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:o.jsx(Y$,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const LV="/assets/773f0c39e1986271e9144596caac519f934a6ae6-Cou8J2R8.png",fj={Dashboard:Vp,Labeling:Cc,Labels:Cc,"Label Categories":cC,"Label Types":Df,"Label Templates":sC,"Multiple Options":Nc,"Location Manager":lu,"Account Management":my,"Menu Management":jc,"System Menu":Nc,Reports:zs,Support:Wd,"Log Out":cj};function hj(e){return e.trim()||"N/A"}function $V(e,t){const r=String(e?.menuIcon??e?.MenuIcon??"").trim();return r&&r in fj?r:t in fj?t:null}function mj({node:e,level:t,currentKey:r,onSelect:n}){const[a,i]=U.useState(!0),s=e.children??[],l=(e.menuType??0)===0||s.length>0,d=hj(String(e.menuName??e.routerName??e.routeUrl??e.id??"")),u=r===d,f=$V(e,d),h=f?fj[f]:null;return l?o.jsxs("div",{className:"space-y-1",children:[o.jsxs("button",{onClick:()=>i(p=>!p),className:Ie("w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium rounded-lg transition-colors","hover:bg-blue-800/50 text-blue-100",t>0&&"ml-1"),style:{paddingLeft:16+t*12},children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t===0&&h?o.jsx(h,{className:"w-4 h-4 shrink-0"}):o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-200 shrink-0"}),o.jsx("span",{className:"truncate",children:d})]}),a?o.jsx(Bs,{className:"w-4 h-4"}):o.jsx(Ui,{className:"w-4 h-4"})]}),a&&s.length>0&&o.jsx("div",{className:"space-y-1",children:s.map(p=>o.jsx(mj,{node:p,level:t+1,currentKey:r,onSelect:n},String(p.id??Math.random())))})]}):o.jsxs("button",{onClick:()=>n(d),className:Ie("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors",u?"bg-blue-700 text-white shadow-md shadow-blue-900/20":"text-blue-100 hover:bg-blue-800 hover:text-white"),style:{paddingLeft:16+t*12},children:[t===0&&h?o.jsx(h,{className:"w-4 h-4 shrink-0"}):o.jsx("div",{className:"w-1 h-1 rounded-full bg-current"}),o.jsx("span",{className:"truncate",children:d})]})}function FV({currentView:e,setCurrentView:t,menus:r,onLogout:n}){const[a,i]=x.useState(!0),s=[{name:"Dashboard",icon:Vp,type:"item"},{type:"header",name:"MODULES"},{name:"Labeling",icon:Cc,type:"sub",isOpen:a,toggle:()=>i(!a),children:[{name:"Labels",icon:Cc},{name:"Label Categories",icon:cC},{name:"Label Types",icon:Df},{name:"Label Templates",icon:sC},{name:"Multiple Options",icon:Nc}]},{type:"header",name:"MANAGEMENT"},{name:"Account Management",icon:my,type:"item"},{name:"Menu Management",icon:jc,type:"item"},{name:"System Menu",icon:Nc,type:"item"},{name:"Reports",icon:zs,type:"item"},{name:"Support",icon:Wd,type:"item"},{name:"Log Out",icon:cj,type:"item"}],l=(r?.length??0)>0,d=()=>n?n():t("Log Out"),u=x.useMemo(()=>r??[],[r]),{moduleMenus:f,accountMenus:h}=x.useMemo(()=>{const p=new Set(["Location Manager","Account Management","Menu Management","System Menu","Reports","Support"]),g=u,v=[],b=[];for(const w of g){const j=hj(String(w.menuName??w.routerName??w.routeUrl??w.id??""));if(j==="Management"){const N=w.children??[];for(const C of N){const O=hj(String(C.menuName??C.routerName??C.routeUrl??C.id??""));p.has(O)?b.push(C):v.push(C)}continue}if(p.has(j)){b.push(w);continue}v.push(w)}return{moduleMenus:v,accountMenus:b}},[u]);return o.jsxs("div",{className:"w-64 bg-[#1e3a8a] text-white flex flex-col h-screen border-r border-blue-800 shadow-xl z-20 shrink-0",children:[o.jsx("div",{className:"flex items-center justify-center border-b border-blue-800/50 bg-white px-4 shrink-0",style:{height:90},children:o.jsx("img",{src:LV,alt:"MedVantage",className:"h-16 w-auto object-contain"})}),o.jsx(Ec,{className:"flex-1 py-4",children:o.jsx("div",{className:"px-3 space-y-1",children:l?o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>t("Dashboard"),className:Ie("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors",e==="Dashboard"?"bg-blue-700 text-white shadow-md shadow-blue-900/20":"text-blue-100 hover:bg-blue-800 hover:text-white"),children:[o.jsx(Vp,{className:"w-4 h-4"}),"Dashboard"]}),o.jsx("div",{className:"px-4 py-2 mt-4 text-xs font-semibold text-blue-300 uppercase tracking-wider",children:"MODULES"}),f.map(p=>o.jsx(mj,{node:p,level:0,currentKey:e,onSelect:t},String(p.id??Math.random()))),o.jsx("div",{className:"px-4 py-2 mt-4 text-xs font-semibold text-blue-300 uppercase tracking-wider",children:"MANAGEMENT"}),h.map(p=>o.jsx(mj,{node:p,level:0,currentKey:e,onSelect:t},String(p.id??Math.random()))),o.jsxs("button",{onClick:d,className:Ie("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors","text-red-300 hover:bg-red-900/20 hover:text-red-200"),children:[o.jsx(cj,{className:"w-4 h-4"}),"Log Out"]})]}):s.map((p,g)=>{if(p.type==="header")return o.jsx("div",{className:"px-4 py-2 mt-4 text-xs font-semibold text-blue-300 uppercase tracking-wider",children:p.name},g);if(p.type==="sub"){const b=p.icon;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("button",{onClick:p.toggle,className:Ie("w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium rounded-lg transition-colors","hover:bg-blue-800/50 text-blue-100"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[b?o.jsx(b,{className:"w-4 h-4"}):null,p.name]}),p.isOpen?o.jsx(Bs,{className:"w-4 h-4"}):o.jsx(Ui,{className:"w-4 h-4"})]}),p.isOpen&&o.jsx("div",{className:"pl-4 space-y-1",children:p.children?.map((w,j)=>o.jsxs("button",{onClick:()=>t(w.name),className:Ie("w-full flex items-center gap-3 px-4 py-2 text-sm font-medium rounded-lg transition-colors border-l-2",e===w.name?"bg-blue-800 border-blue-400 text-white":"border-transparent hover:bg-blue-800/30 text-blue-200 hover:text-white"),children:[o.jsx("div",{className:"w-1 h-1 rounded-full bg-current"}),w.name]},j))})]},g)}const v=p.icon;return o.jsxs("button",{onClick:()=>p.name==="Log Out"?d():t(p.name),className:Ie("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors",e===p.name?"bg-blue-700 text-white shadow-md shadow-blue-900/20":p.name==="Log Out"?"text-red-300 hover:bg-red-900/20 hover:text-red-200":"text-blue-100 hover:bg-blue-800 hover:text-white"),children:[v?o.jsx(v,{className:"w-4 h-4"}):null,p.name]},g)})})})]})}function me({className:e,type:t,...r}){return o.jsx("input",{type:t,"data-slot":"input",className:Ie("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}var BV=Symbol.for("react.lazy"),Yp=aC[" use ".trim().toString()];function zV(e){return typeof e=="object"&&e!==null&&"then"in e}function Z$(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===BV&&"_payload"in e&&zV(e._payload)}function mC(e){const t=UV(e),r=x.forwardRef((n,a)=>{let{children:i,...s}=n;Z$(i)&&typeof Yp=="function"&&(i=Yp(i._payload));const l=x.Children.toArray(i),d=l.find(VV);if(d){const u=d.props.children,f=l.map(h=>h===d?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:h);return o.jsx(t,{...s,ref:a,children:x.isValidElement(u)?x.cloneElement(u,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}var e4=mC("Slot");function UV(e){const t=x.forwardRef((r,n)=>{let{children:a,...i}=r;if(Z$(a)&&typeof Yp=="function"&&(a=Yp(a._payload)),x.isValidElement(a)){const s=HV(a),l=WV(i,a.props);return a.type!==x.Fragment&&(l.ref=n?Oa(n,s):s),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var qV=Symbol("radix.slottable");function VV(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qV}function WV(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function HV(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}const sT=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,lT=yt,pC=(e,t)=>r=>{var n;if(t?.variants==null)return lT(e,r?.class,r?.className);const{variants:a,defaultVariants:i}=t,s=Object.keys(a).map(u=>{const f=r?.[u],h=i?.[u];if(f===null)return null;const p=sT(f)||sT(h);return a[u][p]}),l=r&&Object.entries(r).reduce((u,f)=>{let[h,p]=f;return p===void 0||(u[h]=p),u},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((u,f)=>{let{class:h,className:p,...g}=f;return Object.entries(g).every(v=>{let[b,w]=v;return Array.isArray(w)?w.includes({...i,...l}[b]):{...i,...l}[b]===w})?[...u,h,p]:u},[]);return lT(e,s,d,r?.class,r?.className)},Kp=pC("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),ce=x.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...a},i)=>{const s=n?e4:"button";return o.jsx(s,{ref:i,"data-slot":"button",className:Ie(Kp({variant:t,size:r,className:e})),...a})});ce.displayName="Button";function GV(e,t=[]){let r=[];function n(i,s){const l=x.createContext(s);l.displayName=i+"Context";const d=r.length;r=[...r,s];const u=h=>{const{scope:p,children:g,...v}=h,b=p?.[e]?.[d]||l,w=x.useMemo(()=>v,Object.values(v));return o.jsx(b.Provider,{value:w,children:g})};u.displayName=i+"Provider";function f(h,p){const g=p?.[e]?.[d]||l,v=x.useContext(g);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[u,f]}const a=()=>{const i=r.map(s=>x.createContext(s));return function(l){const d=l?.[e]||i;return x.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return a.scopeName=e,[n,YV(a,...t)]}function YV(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const s=n.reduce((l,{useScope:d,scopeName:u})=>{const h=d(i)[`__scope${u}`];return{...l,...h}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}var KV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gC=KV.reduce((e,t)=>{const r=mC(`Primitive.${t}`),n=x.forwardRef((a,i)=>{const{asChild:s,...l}=a,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),kx={exports:{}},Ax={};/** - * @license React - * use-sync-external-store-shim.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var cT;function XV(){if(cT)return Ax;cT=1;var e=hy();function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function l(h,p){var g=p(),v=n({inst:{value:g,getSnapshot:p}}),b=v[0].inst,w=v[1];return i(function(){b.value=g,b.getSnapshot=p,d(b)&&w({inst:b})},[h,g,p]),a(function(){return d(b)&&w({inst:b}),h(function(){d(b)&&w({inst:b})})},[h]),s(g),g}function d(h){var p=h.getSnapshot;h=h.value;try{var g=p();return!r(h,g)}catch{return!0}}function u(h,p){return p()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return Ax.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Ax}var uT;function JV(){return uT||(uT=1,kx.exports=XV()),kx.exports}var QV=JV();function ZV(){return QV.useSyncExternalStore(eW,()=>!0,()=>!1)}function eW(){return()=>{}}var yC="Avatar",[tW]=GV(yC),[rW,t4]=tW(yC),r4=x.forwardRef((e,t)=>{const{__scopeAvatar:r,...n}=e,[a,i]=x.useState("idle");return o.jsx(rW,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:o.jsx(gC.span,{...n,ref:t})})});r4.displayName=yC;var n4="AvatarImage",a4=x.forwardRef((e,t)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...i}=e,s=t4(n4,r),l=nW(n,i),d=dn(u=>{a(u),s.onImageLoadingStatusChange(u)});return kr(()=>{l!=="idle"&&d(l)},[l,d]),l==="loaded"?o.jsx(gC.img,{...i,ref:t,src:n}):null});a4.displayName=n4;var o4="AvatarFallback",i4=x.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:n,...a}=e,i=t4(o4,r),[s,l]=x.useState(n===void 0);return x.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>l(!0),n);return()=>window.clearTimeout(d)}},[n]),s&&i.imageLoadingStatus!=="loaded"?o.jsx(gC.span,{...a,ref:t}):null});i4.displayName=o4;function dT(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function nW(e,{referrerPolicy:t,crossOrigin:r}){const n=ZV(),a=x.useRef(null),i=n?(a.current||(a.current=new window.Image),a.current):null,[s,l]=x.useState(()=>dT(i,e));return kr(()=>{l(dT(i,e))},[i,e]),kr(()=>{const d=h=>()=>{l(h)};if(!i)return;const u=d("loaded"),f=d("error");return i.addEventListener("load",u),i.addEventListener("error",f),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",u),i.removeEventListener("error",f)}},[i,r,t]),s}var aW=r4,oW=a4,iW=i4;function sW({className:e,...t}){return o.jsx(aW,{"data-slot":"avatar",className:Ie("relative flex size-10 shrink-0 overflow-hidden rounded-full",e),...t})}function lW({className:e,...t}){return o.jsx(oW,{"data-slot":"avatar-image",className:Ie("aspect-square size-full",e),...t})}function cW({className:e,...t}){return o.jsx(iW,{"data-slot":"avatar-fallback",className:Ie("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}function uW({title:e,onSettingsClick:t}){const r=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return o.jsxs("header",{className:"bg-white border-b border-gray-200 px-8 flex items-center justify-between shadow-sm sticky top-0 z-10 shrink-0",style:{height:90},children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold",style:{color:"rgb(43, 50, 143)"},children:[e," Overview"]}),o.jsxs("p",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[r," | Last updated: Just now"]})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"flex items-center w-64 h-9 rounded-md border border-gray-200 bg-gray-50 focus-within:bg-white focus-within:ring-2 focus-within:ring-ring/50 focus-within:border-ring transition-colors overflow-hidden",children:[o.jsx(Rf,{className:"h-4 w-4 text-gray-400 shrink-0 ml-3 pointer-events-none"}),o.jsx(me,{type:"search",placeholder:"Search...",className:"flex-1 min-w-0 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 py-2 px-2 h-full"})]}),o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"text-gray-500 hover:text-gray-700","aria-label":"Open Support",onClick:()=>t?.(),children:o.jsx(Nc,{className:"w-5 h-5"})}),o.jsx("div",{className:"h-8 w-px bg-gray-200 mx-2"}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"text-right hidden md:block",children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Admin User"}),o.jsx("div",{className:"text-xs text-gray-500",children:"Administrator"})]}),o.jsxs(sW,{className:"h-10 w-10 border border-gray-200",children:[o.jsx(lW,{src:"https://github.com/shadcn.png"}),o.jsx(cW,{children:"AD"})]})]})]})]})}function dW({children:e,currentView:t,setCurrentView:r,menus:n,onLogout:a,hideAppChrome:i=!1}){return o.jsxs("div",{className:"flex h-screen bg-gray-50 overflow-hidden font-sans",children:[!i&&o.jsx(FV,{currentView:t,setCurrentView:r,menus:n,onLogout:a}),o.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",children:[!i&&o.jsxs(o.Fragment,{children:[o.jsx(uW,{title:t,onSettingsClick:()=>r("Support")}),o.jsx("div",{className:"mt-8 shrink-0 px-8",children:o.jsxs("nav",{className:"flex items-center gap-2 text-sm font-normal","aria-label":"Breadcrumb",children:[o.jsx("button",{type:"button",onClick:()=>r("Dashboard"),className:"text-gray-500 transition-colors hover:text-gray-700",children:"Home"}),o.jsx(Ui,{className:"h-4 w-4 shrink-0 text-gray-500"}),o.jsx("span",{style:{color:"rgb(43, 50, 143)"},children:t})]})})]}),o.jsx("main",{className:i?"flex min-h-0 flex-1 flex-col overflow-hidden p-0":"min-h-0 flex-1 overflow-y-auto p-8",children:o.jsx("div",{className:"flex h-full min-h-0 w-full flex-col",children:e})})]})]})}function wn({className:e,...t}){return o.jsx("div",{"data-slot":"card",className:Ie("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",e),...t})}function Na({className:e,...t}){return o.jsx("div",{"data-slot":"card-header",className:Ie("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Ca({className:e,...t}){return o.jsx("h4",{"data-slot":"card-title",className:Ie("leading-none",e),...t})}function Hd({className:e,...t}){return o.jsx("p",{"data-slot":"card-description",className:Ie("text-muted-foreground",e),...t})}function Dn({className:e,...t}){return o.jsx("div",{"data-slot":"card-content",className:Ie("px-6 [&:last-child]:pb-6",e),...t})}const fW=pC("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function fn({className:e,variant:t,asChild:r=!1,...n}){const a=r?e4:"span";return o.jsx(a,{"data-slot":"badge",className:Ie(fW({variant:t}),e),...n})}function uo({className:e,...t}){return o.jsx("div",{"data-slot":"skeleton",className:Ie("bg-accent animate-pulse rounded-md",e),...t})}var Ix,fT;function qn(){if(fT)return Ix;fT=1;var e=Array.isArray;return Ix=e,Ix}var Mx,hT;function s4(){if(hT)return Mx;hT=1;var e=typeof Nm=="object"&&Nm&&Nm.Object===Object&&Nm;return Mx=e,Mx}var Rx,mT;function Oo(){if(mT)return Rx;mT=1;var e=s4(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Rx=r,Rx}var Dx,pT;function Lf(){if(pT)return Dx;pT=1;var e=Oo(),t=e.Symbol;return Dx=t,Dx}var Lx,gT;function hW(){if(gT)return Lx;gT=1;var e=Lf(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,a=e?e.toStringTag:void 0;function i(s){var l=r.call(s,a),d=s[a];try{s[a]=void 0;var u=!0}catch{}var f=n.call(s);return u&&(l?s[a]=d:delete s[a]),f}return Lx=i,Lx}var $x,yT;function mW(){if(yT)return $x;yT=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return $x=r,$x}var Fx,vT;function li(){if(vT)return Fx;vT=1;var e=Lf(),t=hW(),r=mW(),n="[object Null]",a="[object Undefined]",i=e?e.toStringTag:void 0;function s(l){return l==null?l===void 0?a:n:i&&i in Object(l)?t(l):r(l)}return Fx=s,Fx}var Bx,xT;function ci(){if(xT)return Bx;xT=1;function e(t){return t!=null&&typeof t=="object"}return Bx=e,Bx}var zx,bT;function du(){if(bT)return zx;bT=1;var e=li(),t=ci(),r="[object Symbol]";function n(a){return typeof a=="symbol"||t(a)&&e(a)==r}return zx=n,zx}var Ux,wT;function vC(){if(wT)return Ux;wT=1;var e=qn(),t=du(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,s){if(e(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||s!=null&&i in Object(s)}return Ux=a,Ux}var qx,ST;function Hi(){if(ST)return qx;ST=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return qx=e,qx}var Vx,jT;function xC(){if(jT)return Vx;jT=1;var e=li(),t=Hi(),r="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function s(l){if(!t(l))return!1;var d=e(l);return d==n||d==a||d==r||d==i}return Vx=s,Vx}var Wx,NT;function pW(){if(NT)return Wx;NT=1;var e=Oo(),t=e["__core-js_shared__"];return Wx=t,Wx}var Hx,CT;function gW(){if(CT)return Hx;CT=1;var e=pW(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Hx=r,Hx}var Gx,_T;function l4(){if(_T)return Gx;_T=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Gx=r,Gx}var Yx,ET;function yW(){if(ET)return Yx;ET=1;var e=xC(),t=gW(),r=Hi(),n=l4(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,l=Object.prototype,d=s.toString,u=l.hasOwnProperty,f=RegExp("^"+d.call(u).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(p){if(!r(p)||t(p))return!1;var g=e(p)?f:i;return g.test(n(p))}return Yx=h,Yx}var Kx,PT;function vW(){if(PT)return Kx;PT=1;function e(t,r){return t?.[r]}return Kx=e,Kx}var Xx,OT;function ol(){if(OT)return Xx;OT=1;var e=yW(),t=vW();function r(n,a){var i=t(n,a);return e(i)?i:void 0}return Xx=r,Xx}var Jx,TT;function vy(){if(TT)return Jx;TT=1;var e=ol(),t=e(Object,"create");return Jx=t,Jx}var Qx,kT;function xW(){if(kT)return Qx;kT=1;var e=vy();function t(){this.__data__=e?e(null):{},this.size=0}return Qx=t,Qx}var Zx,AT;function bW(){if(AT)return Zx;AT=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Zx=e,Zx}var eb,IT;function wW(){if(IT)return eb;IT=1;var e=vy(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function a(i){var s=this.__data__;if(e){var l=s[i];return l===t?void 0:l}return n.call(s,i)?s[i]:void 0}return eb=a,eb}var tb,MT;function SW(){if(MT)return tb;MT=1;var e=vy(),t=Object.prototype,r=t.hasOwnProperty;function n(a){var i=this.__data__;return e?i[a]!==void 0:r.call(i,a)}return tb=n,tb}var rb,RT;function jW(){if(RT)return rb;RT=1;var e=vy(),t="__lodash_hash_undefined__";function r(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&a===void 0?t:a,this}return rb=r,rb}var nb,DT;function NW(){if(DT)return nb;DT=1;var e=xW(),t=bW(),r=wW(),n=SW(),a=jW();function i(s){var l=-1,d=s==null?0:s.length;for(this.clear();++l-1}return cb=t,cb}var ub,qT;function OW(){if(qT)return ub;qT=1;var e=xy();function t(r,n){var a=this.__data__,i=e(a,r);return i<0?(++this.size,a.push([r,n])):a[i][1]=n,this}return ub=t,ub}var db,VT;function by(){if(VT)return db;VT=1;var e=CW(),t=_W(),r=EW(),n=PW(),a=OW();function i(s){var l=-1,d=s==null?0:s.length;for(this.clear();++l0?1:-1},Is=function(t){return Us(t)&&t.indexOf("%")===t.length-1},Re=function(t){return QW(t)&&!$f(t)},ZW=function(t){return gt(t)},Br=function(t){return Re(t)||Us(t)},eH=0,hu=function(t){var r=++eH;return"".concat(t||"").concat(r)},jn=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Re(t)&&!Us(t))return n;var i;if(Is(t)){var s=t.indexOf("%");i=r*parseFloat(t.slice(0,s))/100}else i=+t;return $f(i)&&(i=n),a&&i>r&&(i=r),i},Di=function(t){if(!t)return null;var r=Object.keys(t);return r&&r.length?t[r[0]]:null},tH=function(t){if(!Array.isArray(t))return!1;for(var r=t.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function lH(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function gj(e){"@babel/helpers - typeof";return gj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gj(e)}var vk={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},Qo=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},xk=null,Lb=null,_C=function e(t){if(t===xk&&Array.isArray(Lb))return Lb;var r=[];return x.Children.forEach(t,function(n){gt(n)||(YW.isFragment(n)?r=r.concat(e(n.props.children)):r.push(n))}),Lb=r,xk=t,r};function da(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(function(a){return Qo(a)}):n=[Qo(t)],_C(e).forEach(function(a){var i=ua(a,"type.displayName")||ua(a,"type.name");n.indexOf(i)!==-1&&r.push(a)}),r}function ea(e,t){var r=da(e,t);return r&&r[0]}var bk=function(t){if(!t||!t.props)return!1;var r=t.props,n=r.width,a=r.height;return!(!Re(n)||n<=0||!Re(a)||a<=0)},cH=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],uH=function(t){return t&&t.type&&Us(t.type)&&cH.indexOf(t.type)>=0},dH=function(t){return t&&gj(t)==="object"&&"clipDot"in t},fH=function(t,r,n,a){var i,s=(i=Db?.[a])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!ht(t)&&(a&&s.includes(r)||aH.includes(r))||n&&CC.includes(r)},st=function(t,r,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var a=t;if(x.isValidElement(t)&&(a=t.props),!fu(a))return null;var i={};return Object.keys(a).forEach(function(s){var l;fH((l=a)===null||l===void 0?void 0:l[s],s,r,n)&&(i[s]=a[s])}),i},yj=function e(t,r){if(t===r)return!0;var n=x.Children.count(t);if(n!==x.Children.count(r))return!1;if(n===0)return!0;if(n===1)return wk(Array.isArray(t)?t[0]:t,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function yH(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function xj(e){var t=e.children,r=e.width,n=e.height,a=e.viewBox,i=e.className,s=e.style,l=e.title,d=e.desc,u=gH(e,pH),f=a||{width:r,height:n,x:0,y:0},h=yt("recharts-surface",i);return U.createElement("svg",vj({},st(u,!0,"svg"),{className:h,width:r,height:n,style:s,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height)}),U.createElement("title",null,l),U.createElement("desc",null,d),t)}var vH=["children","className"];function bj(){return bj=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function bH(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Bt=U.forwardRef(function(e,t){var r=e.children,n=e.className,a=xH(e,vH),i=yt("recharts-layer",n);return U.createElement("g",bj({className:i},st(a,!0),{ref:t}),r)}),Ka=function(t,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),i=2;ii?0:i+r),n=n>i?i:n,n<0&&(n+=i),i=r>n?0:n-r>>>0,r>>>=0;for(var s=Array(i);++a=i?r:e(r,n,a)}return Fb=t,Fb}var Bb,Ck;function m4(){if(Ck)return Bb;Ck=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",s="\\u200d",l=RegExp("["+s+e+a+i+"]");function d(u){return l.test(u)}return Bb=d,Bb}var zb,_k;function jH(){if(_k)return zb;_k=1;function e(t){return t.split("")}return zb=e,zb}var Ub,Ek;function NH(){if(Ek)return Ub;Ek=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",s="["+e+"]",l="["+a+"]",d="\\ud83c[\\udffb-\\udfff]",u="(?:"+l+"|"+d+")",f="[^"+e+"]",h="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",g="\\u200d",v=u+"?",b="["+i+"]?",w="(?:"+g+"(?:"+[f,h,p].join("|")+")"+b+v+")*",j=b+v+w,N="(?:"+[f+l+"?",l,h,p,s].join("|")+")",C=RegExp(d+"(?="+d+")|"+N+j,"g");function O(P){return P.match(C)||[]}return Ub=O,Ub}var qb,Pk;function CH(){if(Pk)return qb;Pk=1;var e=jH(),t=m4(),r=NH();function n(a){return t(a)?r(a):e(a)}return qb=n,qb}var Vb,Ok;function _H(){if(Ok)return Vb;Ok=1;var e=SH(),t=m4(),r=CH(),n=u4();function a(i){return function(s){s=n(s);var l=t(s)?r(s):void 0,d=l?l[0]:s.charAt(0),u=l?e(l,1).join(""):s.slice(1);return d[i]()+u}}return Vb=a,Vb}var Wb,Tk;function EH(){if(Tk)return Wb;Tk=1;var e=_H(),t=e("toUpperCase");return Wb=t,Wb}var PH=EH();const jy=Vt(PH);function ar(e){return function(){return e}}const p4=Math.cos,Qp=Math.sin,ro=Math.sqrt,Zp=Math.PI,Ny=2*Zp,wj=Math.PI,Sj=2*wj,Ps=1e-6,OH=Sj-Ps;function g4(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return g4;const r=10**t;return function(n){this._+=n[0];for(let a=1,i=n.length;aPs)if(!(Math.abs(h*d-u*f)>Ps)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let g=n-s,v=a-l,b=d*d+u*u,w=g*g+v*v,j=Math.sqrt(b),N=Math.sqrt(p),C=i*Math.tan((wj-Math.acos((b+p-w)/(2*j*N)))/2),O=C/N,P=C/j;Math.abs(O-1)>Ps&&this._append`L${t+O*f},${r+O*h}`,this._append`A${i},${i},0,0,${+(h*g>f*v)},${this._x1=t+P*d},${this._y1=r+P*u}`}}arc(t,r,n,a,i,s){if(t=+t,r=+r,n=+n,s=!!s,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),d=n*Math.sin(a),u=t+l,f=r+d,h=1^s,p=s?a-i:i-a;this._x1===null?this._append`M${u},${f}`:(Math.abs(this._x1-u)>Ps||Math.abs(this._y1-f)>Ps)&&this._append`L${u},${f}`,n&&(p<0&&(p=p%Sj+Sj),p>OH?this._append`A${n},${n},0,1,${h},${t-l},${r-d}A${n},${n},0,1,${h},${this._x1=u},${this._y1=f}`:p>Ps&&this._append`A${n},${n},0,${+(p>=wj)},${h},${this._x1=t+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(t,r,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function EC(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new kH(t)}function PC(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function y4(e){this._context=e}y4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Cy(e){return new y4(e)}function v4(e){return e[0]}function x4(e){return e[1]}function b4(e,t){var r=ar(!0),n=null,a=Cy,i=null,s=EC(l);e=typeof e=="function"?e:e===void 0?v4:ar(e),t=typeof t=="function"?t:t===void 0?x4:ar(t);function l(d){var u,f=(d=PC(d)).length,h,p=!1,g;for(n==null&&(i=a(g=s())),u=0;u<=f;++u)!(u=g;--v)l.point(C[v],O[v]);l.lineEnd(),l.areaEnd()}j&&(C[p]=+e(w,p,h),O[p]=+t(w,p,h),l.point(n?+n(w,p,h):C[p],r?+r(w,p,h):O[p]))}if(N)return l=null,N+""||null}function f(){return b4().defined(a).curve(s).context(i)}return u.x=function(h){return arguments.length?(e=typeof h=="function"?h:ar(+h),n=null,u):e},u.x0=function(h){return arguments.length?(e=typeof h=="function"?h:ar(+h),u):e},u.x1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:ar(+h),u):n},u.y=function(h){return arguments.length?(t=typeof h=="function"?h:ar(+h),r=null,u):t},u.y0=function(h){return arguments.length?(t=typeof h=="function"?h:ar(+h),u):t},u.y1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:ar(+h),u):r},u.lineX0=u.lineY0=function(){return f().x(e).y(t)},u.lineY1=function(){return f().x(e).y(r)},u.lineX1=function(){return f().x(n).y(t)},u.defined=function(h){return arguments.length?(a=typeof h=="function"?h:ar(!!h),u):a},u.curve=function(h){return arguments.length?(s=h,i!=null&&(l=s(i)),u):s},u.context=function(h){return arguments.length?(h==null?i=l=null:l=s(i=h),u):i},u}class w4{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function AH(e){return new w4(e,!0)}function IH(e){return new w4(e,!1)}const OC={draw(e,t){const r=ro(t/Zp);e.moveTo(r,0),e.arc(0,0,r,0,Ny)}},MH={draw(e,t){const r=ro(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},S4=ro(1/3),RH=S4*2,DH={draw(e,t){const r=ro(t/RH),n=r*S4;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},LH={draw(e,t){const r=ro(t),n=-r/2;e.rect(n,n,r,r)}},$H=.8908130915292852,j4=Qp(Zp/10)/Qp(7*Zp/10),FH=Qp(Ny/10)*j4,BH=-p4(Ny/10)*j4,zH={draw(e,t){const r=ro(t*$H),n=FH*r,a=BH*r;e.moveTo(0,-r),e.lineTo(n,a);for(let i=1;i<5;++i){const s=Ny*i/5,l=p4(s),d=Qp(s);e.lineTo(d*r,-l*r),e.lineTo(l*n-d*a,d*n+l*a)}e.closePath()}},Hb=ro(3),UH={draw(e,t){const r=-ro(t/(Hb*3));e.moveTo(0,r*2),e.lineTo(-Hb*r,-r),e.lineTo(Hb*r,-r),e.closePath()}},wa=-.5,Sa=ro(3)/2,jj=1/ro(12),qH=(jj/2+1)*3,VH={draw(e,t){const r=ro(t/qH),n=r/2,a=r*jj,i=n,s=r*jj+r,l=-i,d=s;e.moveTo(n,a),e.lineTo(i,s),e.lineTo(l,d),e.lineTo(wa*n-Sa*a,Sa*n+wa*a),e.lineTo(wa*i-Sa*s,Sa*i+wa*s),e.lineTo(wa*l-Sa*d,Sa*l+wa*d),e.lineTo(wa*n+Sa*a,wa*a-Sa*n),e.lineTo(wa*i+Sa*s,wa*s-Sa*i),e.lineTo(wa*l+Sa*d,wa*d-Sa*l),e.closePath()}};function WH(e,t){let r=null,n=EC(a);e=typeof e=="function"?e:ar(e||OC),t=typeof t=="function"?t:ar(t===void 0?64:+t);function a(){let i;if(r||(r=i=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:ar(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:ar(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function eg(){}function tg(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function N4(e){this._context=e}N4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:tg(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:tg(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function HH(e){return new N4(e)}function C4(e){this._context=e}C4.prototype={areaStart:eg,areaEnd:eg,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:tg(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function GH(e){return new C4(e)}function _4(e){this._context=e}_4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:tg(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function YH(e){return new _4(e)}function E4(e){this._context=e}E4.prototype={areaStart:eg,areaEnd:eg,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function KH(e){return new E4(e)}function kk(e){return e<0?-1:1}function Ak(e,t,r){var n=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(n||a<0&&-0),s=(r-e._y1)/(a||n<0&&-0),l=(i*a+s*n)/(n+a);return(kk(i)+kk(s))*Math.min(Math.abs(i),Math.abs(s),.5*Math.abs(l))||0}function Ik(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function Gb(e,t,r){var n=e._x0,a=e._y0,i=e._x1,s=e._y1,l=(i-n)/3;e._context.bezierCurveTo(n+l,a+l*t,i-l,s-l*r,i,s)}function rg(e){this._context=e}rg.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Gb(this,this._t0,Ik(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Gb(this,Ik(this,r=Ak(this,e,t)),r);break;default:Gb(this,this._t0,r=Ak(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function P4(e){this._context=new O4(e)}(P4.prototype=Object.create(rg.prototype)).point=function(e,t){rg.prototype.point.call(this,t,e)};function O4(e){this._context=e}O4.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,a,i){this._context.bezierCurveTo(t,e,n,r,i,a)}};function XH(e){return new rg(e)}function JH(e){return new P4(e)}function T4(e){this._context=e}T4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=Mk(e),a=Mk(t),i=0,s=1;s=0;--t)a[t]=(s[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function ZH(e){return new _y(e,.5)}function eG(e){return new _y(e,0)}function tG(e){return new _y(e,1)}function Pc(e,t){if((s=e.length)>1)for(var r=1,n,a,i=e[t[0]],s,l=i.length;r=0;)r[t]=t;return r}function rG(e,t){return e[t]}function nG(e){const t=[];return t.key=e,t}function aG(){var e=ar([]),t=Nj,r=Pc,n=rG;function a(i){var s=Array.from(e.apply(this,arguments),nG),l,d=s.length,u=-1,f;for(const h of i)for(l=0,++u;l0){for(var r,n,a=0,i=e[0].length,s;a0){for(var r=0,n=e[t[0]],a,i=n.length;r0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,n=1,a,i,s;n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function hG(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var k4={symbolCircle:OC,symbolCross:MH,symbolDiamond:DH,symbolSquare:LH,symbolStar:zH,symbolTriangle:UH,symbolWye:VH},mG=Math.PI/180,pG=function(t){var r="symbol".concat(jy(t));return k4[r]||OC},gG=function(t,r,n){if(r==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var a=18*mG;return 1.25*t*t*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},yG=function(t,r){k4["symbol".concat(jy(t))]=r},TC=function(t){var r=t.type,n=r===void 0?"circle":r,a=t.size,i=a===void 0?64:a,s=t.sizeType,l=s===void 0?"area":s,d=fG(t,lG),u=Dk(Dk({},d),{},{type:n,size:i,sizeType:l}),f=function(){var w=pG(n),j=WH().type(w).size(gG(i,l,n));return j()},h=u.className,p=u.cx,g=u.cy,v=st(u,!0);return p===+p&&g===+g&&i===+i?U.createElement("path",Cj({},v,{className:yt("recharts-symbols",h),transform:"translate(".concat(p,", ").concat(g,")"),d:f()})):null};TC.registerSymbol=yG;function Oc(e){"@babel/helpers - typeof";return Oc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oc(e)}function _j(){return _j=Object.assign?Object.assign.bind():function(e){for(var t=1;t`);var N=g.inactive?u:g.color;return U.createElement("li",_j({className:w,style:h,key:"legend-item-".concat(v)},qs(n.props,g,v)),U.createElement(xj,{width:s,height:s,viewBox:f,style:p},n.renderIcon(g)),U.createElement("span",{className:"recharts-legend-item-text",style:{color:N}},b?b(j,g,v):j))})}},{key:"render",value:function(){var n=this.props,a=n.payload,i=n.layout,s=n.align;if(!a||!a.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?s:"left"};return U.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])})(x.PureComponent);Yd(kC,"displayName","Legend");Yd(kC,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var Yb,$k;function EG(){if($k)return Yb;$k=1;var e=by();function t(){this.__data__=new e,this.size=0}return Yb=t,Yb}var Kb,Fk;function PG(){if(Fk)return Kb;Fk=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Kb=e,Kb}var Xb,Bk;function OG(){if(Bk)return Xb;Bk=1;function e(t){return this.__data__.get(t)}return Xb=e,Xb}var Jb,zk;function TG(){if(zk)return Jb;zk=1;function e(t){return this.__data__.has(t)}return Jb=e,Jb}var Qb,Uk;function kG(){if(Uk)return Qb;Uk=1;var e=by(),t=wC(),r=SC(),n=200;function a(i,s){var l=this.__data__;if(l instanceof e){var d=l.__data__;if(!t||d.lengthg))return!1;var b=h.get(s),w=h.get(l);if(b&&w)return b==l&&w==s;var j=-1,N=!0,C=d&a?new e:void 0;for(h.set(s,l),h.set(l,s);++j-1&&n%1==0&&n-1&&r%1==0&&r<=e}return bw=t,bw}var ww,fA;function VG(){if(fA)return ww;fA=1;var e=li(),t=RC(),r=ci(),n="[object Arguments]",a="[object Array]",i="[object Boolean]",s="[object Date]",l="[object Error]",d="[object Function]",u="[object Map]",f="[object Number]",h="[object Object]",p="[object RegExp]",g="[object Set]",v="[object String]",b="[object WeakMap]",w="[object ArrayBuffer]",j="[object DataView]",N="[object Float32Array]",C="[object Float64Array]",O="[object Int8Array]",P="[object Int16Array]",E="[object Int32Array]",T="[object Uint8Array]",A="[object Uint8ClampedArray]",M="[object Uint16Array]",R="[object Uint32Array]",L={};L[N]=L[C]=L[O]=L[P]=L[E]=L[T]=L[A]=L[M]=L[R]=!0,L[n]=L[a]=L[w]=L[i]=L[j]=L[s]=L[l]=L[d]=L[u]=L[f]=L[h]=L[p]=L[g]=L[v]=L[b]=!1;function V(z){return r(z)&&t(z.length)&&!!L[e(z)]}return ww=V,ww}var Sw,hA;function z4(){if(hA)return Sw;hA=1;function e(t){return function(r){return t(r)}}return Sw=e,Sw}var Rd={exports:{}};Rd.exports;var mA;function WG(){return mA||(mA=1,(function(e,t){var r=s4(),n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,s=i&&r.process,l=(function(){try{var d=a&&a.require&&a.require("util").types;return d||s&&s.binding&&s.binding("util")}catch{}})();e.exports=l})(Rd,Rd.exports)),Rd.exports}var jw,pA;function U4(){if(pA)return jw;pA=1;var e=VG(),t=z4(),r=WG(),n=r&&r.isTypedArray,a=n?t(n):e;return jw=a,jw}var Nw,gA;function HG(){if(gA)return Nw;gA=1;var e=zG(),t=IC(),r=qn(),n=B4(),a=MC(),i=U4(),s=Object.prototype,l=s.hasOwnProperty;function d(u,f){var h=r(u),p=!h&&t(u),g=!h&&!p&&n(u),v=!h&&!p&&!g&&i(u),b=h||p||g||v,w=b?e(u.length,String):[],j=w.length;for(var N in u)(f||l.call(u,N))&&!(b&&(N=="length"||g&&(N=="offset"||N=="parent")||v&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,j)))&&w.push(N);return w}return Nw=d,Nw}var Cw,yA;function GG(){if(yA)return Cw;yA=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,a=typeof n=="function"&&n.prototype||e;return r===a}return Cw=t,Cw}var _w,vA;function q4(){if(vA)return _w;vA=1;function e(t,r){return function(n){return t(r(n))}}return _w=e,_w}var Ew,xA;function YG(){if(xA)return Ew;xA=1;var e=q4(),t=e(Object.keys,Object);return Ew=t,Ew}var Pw,bA;function KG(){if(bA)return Pw;bA=1;var e=GG(),t=YG(),r=Object.prototype,n=r.hasOwnProperty;function a(i){if(!e(i))return t(i);var s=[];for(var l in Object(i))n.call(i,l)&&l!="constructor"&&s.push(l);return s}return Pw=a,Pw}var Ow,wA;function Ff(){if(wA)return Ow;wA=1;var e=xC(),t=RC();function r(n){return n!=null&&t(n.length)&&!e(n)}return Ow=r,Ow}var Tw,SA;function Ey(){if(SA)return Tw;SA=1;var e=HG(),t=KG(),r=Ff();function n(a){return r(a)?e(a):t(a)}return Tw=n,Tw}var kw,jA;function XG(){if(jA)return kw;jA=1;var e=LG(),t=BG(),r=Ey();function n(a){return e(a,r,t)}return kw=n,kw}var Aw,NA;function JG(){if(NA)return Aw;NA=1;var e=XG(),t=1,r=Object.prototype,n=r.hasOwnProperty;function a(i,s,l,d,u,f){var h=l&t,p=e(i),g=p.length,v=e(s),b=v.length;if(g!=b&&!h)return!1;for(var w=g;w--;){var j=p[w];if(!(h?j in s:n.call(s,j)))return!1}var N=f.get(i),C=f.get(s);if(N&&C)return N==s&&C==i;var O=!0;f.set(i,s),f.set(s,i);for(var P=h;++w-1}return a1=t,a1}var o1,JA;function yY(){if(JA)return o1;JA=1;function e(t,r,n){for(var a=-1,i=t==null?0:t.length;++a=s){var j=u?null:a(d);if(j)return i(j);v=!1,p=n,w=new e}else w=u?[]:b;e:for(;++h=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function AY(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function IY(e){return e.value}function MY(e,t){if(U.isValidElement(e))return U.cloneElement(e,t);if(typeof e=="function")return U.createElement(e,t);t.ref;var r=kY(t,jY);return U.createElement(kC,r)}var o2=1,pc=(function(e){function t(){var r;NY(this,t);for(var n=arguments.length,a=new Array(n),i=0;io2||Math.abs(a.height-this.lastBoundingBox.height)>o2)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,n&&n(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?qo({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,i=a.layout,s=a.align,l=a.verticalAlign,d=a.margin,u=a.chartWidth,f=a.chartHeight,h,p;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(s==="center"&&i==="vertical"){var g=this.getBBoxSnapshot();h={left:((u||0)-g.width)/2}}else h=s==="right"?{right:d&&d.right||0}:{left:d&&d.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(l==="middle"){var v=this.getBBoxSnapshot();p={top:((f||0)-v.height)/2}}else p=l==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return qo(qo({},h),p)}},{key:"render",value:function(){var n=this,a=this.props,i=a.content,s=a.width,l=a.height,d=a.wrapperStyle,u=a.payloadUniqBy,f=a.payload,h=qo(qo({position:"absolute",width:s||"auto",height:l||"auto"},this.getDefaultPosition(d)),d);return U.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(g){n.wrapperNode=g}},MY(i,qo(qo({},this.props),{},{payload:Y4(f,u,IY)})))}}],[{key:"getWithHeight",value:function(n,a){var i=qo(qo({},this.defaultProps),n.props),s=i.layout;return s==="vertical"&&Re(n.props.height)?{height:n.props.height}:s==="horizontal"?{width:n.props.width||a}:null}}])})(x.PureComponent);Py(pc,"displayName","Legend");Py(pc,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var u1,i2;function RY(){if(i2)return u1;i2=1;var e=Lf(),t=IC(),r=qn(),n=e?e.isConcatSpreadable:void 0;function a(i){return r(i)||t(i)||!!(n&&i&&i[n])}return u1=a,u1}var d1,s2;function J4(){if(s2)return d1;s2=1;var e=F4(),t=RY();function r(n,a,i,s,l){var d=-1,u=n.length;for(i||(i=t),l||(l=[]);++d0&&i(f)?a>1?r(f,a-1,i,s,l):e(l,f):s||(l[l.length]=f)}return l}return d1=r,d1}var f1,l2;function DY(){if(l2)return f1;l2=1;function e(t){return function(r,n,a){for(var i=-1,s=Object(r),l=a(r),d=l.length;d--;){var u=l[t?d:++i];if(n(s[u],u,s)===!1)break}return r}}return f1=e,f1}var h1,c2;function LY(){if(c2)return h1;c2=1;var e=DY(),t=e();return h1=t,h1}var m1,u2;function Q4(){if(u2)return m1;u2=1;var e=LY(),t=Ey();function r(n,a){return n&&e(n,a,t)}return m1=r,m1}var p1,d2;function $Y(){if(d2)return p1;d2=1;var e=Ff();function t(r,n){return function(a,i){if(a==null)return a;if(!e(a))return r(a,i);for(var s=a.length,l=n?s:-1,d=Object(a);(n?l--:++ln||l&&d&&f&&!u&&!h||i&&d&&f||!a&&f||!s)return 1;if(!i&&!l&&!h&&r=u)return f;var h=a[i];return f*(h=="desc"?-1:1)}}return r.index-n.index}return b1=t,b1}var w1,y2;function UY(){if(y2)return w1;y2=1;var e=jC(),t=NC(),r=To(),n=Z4(),a=FY(),i=z4(),s=zY(),l=mu(),d=qn();function u(f,h,p){h.length?h=e(h,function(b){return d(b)?function(w){return t(w,b.length===1?b[0]:b)}:b}):h=[l];var g=-1;h=e(h,i(r));var v=n(f,function(b,w,j){var N=e(h,function(C){return C(b)});return{criteria:N,index:++g,value:b}});return a(v,function(b,w){return s(b,w,p)})}return w1=u,w1}var S1,v2;function qY(){if(v2)return S1;v2=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return S1=e,S1}var j1,x2;function VY(){if(x2)return j1;x2=1;var e=qY(),t=Math.max;function r(n,a,i){return a=t(a===void 0?n.length-1:a,0),function(){for(var s=arguments,l=-1,d=t(s.length-a,0),u=Array(d);++l0){if(++i>=e)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return E1=n,E1}var P1,N2;function YY(){if(N2)return P1;N2=1;var e=HY(),t=GY(),r=t(e);return P1=r,P1}var O1,C2;function KY(){if(C2)return O1;C2=1;var e=mu(),t=VY(),r=YY();function n(a,i){return r(t(a,i,e),a+"")}return O1=n,O1}var T1,_2;function Oy(){if(_2)return T1;_2=1;var e=bC(),t=Ff(),r=MC(),n=Hi();function a(i,s,l){if(!n(l))return!1;var d=typeof s;return(d=="number"?t(l)&&r(s,l.length):d=="string"&&s in l)?e(l[s],i):!1}return T1=a,T1}var k1,E2;function XY(){if(E2)return k1;E2=1;var e=J4(),t=UY(),r=KY(),n=Oy(),a=r(function(i,s){if(i==null)return[];var l=s.length;return l>1&&n(i,s[0],s[1])?s=[]:l>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),t(i,e(s,1),[])});return k1=a,k1}var JY=XY();const $C=Vt(JY);function Kd(e){"@babel/helpers - typeof";return Kd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kd(e)}function Oj(){return Oj=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t.x),"".concat(md,"-left"),Re(r)&&t&&Re(t.x)&&r=t.y),"".concat(md,"-top"),Re(n)&&t&&Re(t.y)&&nb?Math.max(f,d[n]):Math.max(h,d[n])}function fK(e){var t=e.translateX,r=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function hK(e){var t=e.allowEscapeViewBox,r=e.coordinate,n=e.offsetTopLeft,a=e.position,i=e.reverseDirection,s=e.tooltipBox,l=e.useTranslate3d,d=e.viewBox,u,f,h;return s.height>0&&s.width>0&&r?(f=T2({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:i,tooltipDimension:s.width,viewBox:d,viewBoxDimension:d.width}),h=T2({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:i,tooltipDimension:s.height,viewBox:d,viewBoxDimension:d.height}),u=fK({translateX:f,translateY:h,useTranslate3d:l})):u=uK,{cssProperties:u,cssClasses:dK({translateX:f,translateY:h,coordinate:r})}}function kc(e){"@babel/helpers - typeof";return kc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kc(e)}function k2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function A2(e){for(var t=1;tI2||Math.abs(n.height-this.state.lastBoundingBox.height)>I2)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,i=a.active,s=a.allowEscapeViewBox,l=a.animationDuration,d=a.animationEasing,u=a.children,f=a.coordinate,h=a.hasPayload,p=a.isAnimationActive,g=a.offset,v=a.position,b=a.reverseDirection,w=a.useTranslate3d,j=a.viewBox,N=a.wrapperStyle,C=hK({allowEscapeViewBox:s,coordinate:f,offsetTopLeft:g,position:v,reverseDirection:b,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:j}),O=C.cssClasses,P=C.cssProperties,E=A2(A2({transition:p&&i?"transform ".concat(l,"ms ").concat(d):void 0},P),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},N);return U.createElement("div",{tabIndex:-1,className:O,style:E,ref:function(A){n.wrapperNode=A}},u)}}])})(x.PureComponent),jK=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},il={isSsr:jK()};function Ac(e){"@babel/helpers - typeof";return Ac=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ac(e)}function M2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function R2(e){for(var t=1;t0;return U.createElement(SK,{allowEscapeViewBox:s,animationDuration:l,animationEasing:d,isAnimationActive:p,active:i,coordinate:f,hasPayload:E,offset:g,position:w,reverseDirection:j,useTranslate3d:N,viewBox:C,wrapperStyle:O},IK(u,R2(R2({},this.props),{},{payload:P})))}}])})(x.PureComponent);FC(ta,"displayName","Tooltip");FC(ta,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!il.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var I1,D2;function MK(){if(D2)return I1;D2=1;var e=Oo(),t=function(){return e.Date.now()};return I1=t,I1}var M1,L2;function RK(){if(L2)return M1;L2=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return M1=t,M1}var R1,$2;function DK(){if($2)return R1;$2=1;var e=RK(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return R1=r,R1}var D1,F2;function o3(){if(F2)return D1;F2=1;var e=DK(),t=Hi(),r=du(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;function d(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var f=typeof u.valueOf=="function"?u.valueOf():u;u=t(f)?f+"":f}if(typeof u!="string")return u===0?u:+u;u=e(u);var h=i.test(u);return h||s.test(u)?l(u.slice(2),h?2:8):a.test(u)?n:+u}return D1=d,D1}var L1,B2;function LK(){if(B2)return L1;B2=1;var e=Hi(),t=MK(),r=o3(),n="Expected a function",a=Math.max,i=Math.min;function s(l,d,u){var f,h,p,g,v,b,w=0,j=!1,N=!1,C=!0;if(typeof l!="function")throw new TypeError(n);d=r(d)||0,e(u)&&(j=!!u.leading,N="maxWait"in u,p=N?a(r(u.maxWait)||0,d):p,C="trailing"in u?!!u.trailing:C);function O(z){var G=f,H=h;return f=h=void 0,w=z,g=l.apply(H,G),g}function P(z){return w=z,v=setTimeout(A,d),j?O(z):g}function E(z){var G=z-b,H=z-w,W=d-G;return N?i(W,p-H):W}function T(z){var G=z-b,H=z-w;return b===void 0||G>=d||G<0||N&&H>=p}function A(){var z=t();if(T(z))return M(z);v=setTimeout(A,E(z))}function M(z){return v=void 0,C&&f?O(z):(f=h=void 0,g)}function R(){v!==void 0&&clearTimeout(v),w=0,f=b=h=v=void 0}function L(){return v===void 0?g:M(t())}function V(){var z=t(),G=T(z);if(f=arguments,h=this,b=z,G){if(v===void 0)return P(b);if(N)return clearTimeout(v),v=setTimeout(A,d),O(b)}return v===void 0&&(v=setTimeout(A,d)),g}return V.cancel=R,V.flush=L,V}return L1=s,L1}var $1,z2;function $K(){if(z2)return $1;z2=1;var e=LK(),t=Hi(),r="Expected a function";function n(a,i,s){var l=!0,d=!0;if(typeof a!="function")throw new TypeError(r);return t(s)&&(l="leading"in s?!!s.leading:l,d="trailing"in s?!!s.trailing:d),e(a,i,{leading:l,maxWait:i,trailing:d})}return $1=n,$1}var FK=$K();const i3=Vt(FK);function Jd(e){"@babel/helpers - typeof";return Jd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jd(e)}function U2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Am(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(z=i3(z,b,{trailing:!0,leading:!1}));var G=new ResizeObserver(z),H=P.current.getBoundingClientRect(),W=H.width,q=H.height;return L(W,q),G.observe(P.current),function(){G.disconnect()}},[L,b]);var V=x.useMemo(function(){var z=M.containerWidth,G=M.containerHeight;if(z<0||G<0)return null;Ka(Is(s)||Is(d),`The width(%s) and height(%s) are both fixed numbers, - maybe you don't need to use a ResponsiveContainer.`,s,d),Ka(!r||r>0,"The aspect(%s) must be greater than zero.",r);var H=Is(s)?z:s,W=Is(d)?G:d;r&&r>0&&(H?W=H/r:W&&(H=W*r),p&&W>p&&(W=p)),Ka(H>0||W>0,`The width(%s) and height(%s) of chart should be greater than 0, - please check the style of container, or the props width(%s) and height(%s), - or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the - height and width.`,H,W,s,d,f,h,r);var q=!Array.isArray(g)&&Qo(g.type).endsWith("Chart");return U.Children.map(g,function(I){return U.isValidElement(I)?x.cloneElement(I,Am({width:H,height:W},q?{style:Am({height:"100%",width:"100%",maxHeight:W,maxWidth:H},I.props.style)}:{})):I})},[r,g,d,p,h,f,M,s]);return U.createElement("div",{id:w?"".concat(w):void 0,className:yt("recharts-responsive-container",j),style:Am(Am({},O),{},{width:s,height:d,minWidth:f,minHeight:h,maxHeight:p}),ref:P},V)}),Ty=function(t){return null};Ty.displayName="Cell";function Qd(e){"@babel/helpers - typeof";return Qd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qd(e)}function V2(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ij(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||il.isSsr)return{width:0,height:0};var n=ZK(r),a=JSON.stringify({text:t,copyStyle:n});if(Wl.widthCache[a])return Wl.widthCache[a];try{var i=document.getElementById(W2);i||(i=document.createElement("span"),i.setAttribute("id",W2),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var s=Ij(Ij({},QK),n);Object.assign(i.style,s),i.textContent="".concat(t);var l=i.getBoundingClientRect(),d={width:l.width,height:l.height};return Wl.widthCache[a]=d,++Wl.cacheCount>JK&&(Wl.cacheCount=0,Wl.widthCache={}),d}catch{return{width:0,height:0}}},eX=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function Zd(e){"@babel/helpers - typeof";return Zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zd(e)}function lg(e,t){return aX(e)||nX(e,t)||rX(e,t)||tX()}function tX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rX(e,t){if(e){if(typeof e=="string")return H2(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return H2(e,t)}}function H2(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function vX(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Q2(e,t){return SX(e)||wX(e,t)||bX(e,t)||xX()}function xX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bX(e,t){if(e){if(typeof e=="string")return Z2(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Z2(e,t)}}function Z2(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[];return H.reduce(function(W,q){var I=q.word,Y=q.width,F=W[W.length-1];if(F&&(a==null||i||F.width+Y+nq.width?W:q})};if(!f)return g;for(var b="…",w=function(H){var W=h.slice(0,H),q=u3({breakAll:u,style:d,children:W+b}).wordsWithComputedWidth,I=p(q),Y=I.length>s||v(I).width>Number(a);return[Y,I]},j=0,N=h.length-1,C=0,O;j<=N&&C<=h.length-1;){var P=Math.floor((j+N)/2),E=P-1,T=w(E),A=Q2(T,2),M=A[0],R=A[1],L=w(P),V=Q2(L,1),z=V[0];if(!M&&!z&&(j=P+1),M&&z&&(N=P-1),!M&&z){O=R;break}C++}return O||g},eI=function(t){var r=gt(t)?[]:t.toString().split(c3);return[{words:r}]},NX=function(t){var r=t.width,n=t.scaleToFit,a=t.children,i=t.style,s=t.breakAll,l=t.maxLines;if((r||n)&&!il.isSsr){var d,u,f=u3({breakAll:s,children:a,style:i});if(f){var h=f.wordsWithComputedWidth,p=f.spaceWidth;d=h,u=p}else return eI(a);return jX({breakAll:s,children:a,maxLines:l,style:i},d,u,r,n)}return eI(a)},tI="#808080",Vs=function(t){var r=t.x,n=r===void 0?0:r,a=t.y,i=a===void 0?0:a,s=t.lineHeight,l=s===void 0?"1em":s,d=t.capHeight,u=d===void 0?"0.71em":d,f=t.scaleToFit,h=f===void 0?!1:f,p=t.textAnchor,g=p===void 0?"start":p,v=t.verticalAnchor,b=v===void 0?"end":v,w=t.fill,j=w===void 0?tI:w,N=J2(t,gX),C=x.useMemo(function(){return NX({breakAll:N.breakAll,children:N.children,maxLines:N.maxLines,scaleToFit:h,style:N.style,width:N.width})},[N.breakAll,N.children,N.maxLines,h,N.style,N.width]),O=N.dx,P=N.dy,E=N.angle,T=N.className,A=N.breakAll,M=J2(N,yX);if(!Br(n)||!Br(i))return null;var R=n+(Re(O)?O:0),L=i+(Re(P)?P:0),V;switch(b){case"start":V=F1("calc(".concat(u,")"));break;case"middle":V=F1("calc(".concat((C.length-1)/2," * -").concat(l," + (").concat(u," / 2))"));break;default:V=F1("calc(".concat(C.length-1," * -").concat(l,")"));break}var z=[];if(h){var G=C[0].width,H=N.width;z.push("scale(".concat((Re(H)?H/G:1)/G,")"))}return E&&z.push("rotate(".concat(E,", ").concat(R,", ").concat(L,")")),z.length&&(M.transform=z.join(" ")),U.createElement("text",Mj({},st(M,!0),{x:R,y:L,className:yt("recharts-text",T),textAnchor:g,fill:j.includes("url")?tI:j}),C.map(function(W,q){var I=W.words.join(A?"":" ");return U.createElement("tspan",{x:R,dy:q===0?V:l,key:"".concat(I,"-").concat(q)},I)}))};function Fi(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function CX(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function BC(e){let t,r,n;e.length!==2?(t=Fi,r=(l,d)=>Fi(e(l),d),n=(l,d)=>e(l)-d):(t=e===Fi||e===CX?e:_X,r=e,n=e);function a(l,d,u=0,f=l.length){if(u>>1;r(l[h],d)<0?u=h+1:f=h}while(u>>1;r(l[h],d)<=0?u=h+1:f=h}while(uu&&n(l[h-1],d)>-n(l[h],d)?h-1:h}return{left:a,center:s,right:i}}function _X(){return 0}function d3(e){return e===null?NaN:+e}function*EX(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const PX=BC(Fi),Bf=PX.right;BC(d3).center;class rI extends Map{constructor(t,r=kX){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[n,a]of t)this.set(n,a)}get(t){return super.get(nI(this,t))}has(t){return super.has(nI(this,t))}set(t,r){return super.set(OX(this,t),r)}delete(t){return super.delete(TX(this,t))}}function nI({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):r}function OX({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function TX({_intern:e,_key:t},r){const n=t(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function kX(e){return e!==null&&typeof e=="object"?e.valueOf():e}function AX(e=Fi){if(e===Fi)return f3;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const n=e(t,r);return n||n===0?n:(e(r,r)===0)-(e(t,t)===0)}}function f3(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const IX=Math.sqrt(50),MX=Math.sqrt(10),RX=Math.sqrt(2);function cg(e,t,r){const n=(t-e)/Math.max(0,r),a=Math.floor(Math.log10(n)),i=n/Math.pow(10,a),s=i>=IX?10:i>=MX?5:i>=RX?2:1;let l,d,u;return a<0?(u=Math.pow(10,-a)/s,l=Math.round(e*u),d=Math.round(t*u),l/ut&&--d,u=-u):(u=Math.pow(10,a)*s,l=Math.round(e/u),d=Math.round(t/u),l*ut&&--d),d0))return[];if(e===t)return[e];const n=t=a))return[];const l=i-a+1,d=new Array(l);if(n)if(s<0)for(let u=0;u=n)&&(r=n);return r}function oI(e,t){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function h3(e,t,r=0,n=1/0,a){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(e.length-1,n)),!(r<=t&&t<=n))return e;for(a=a===void 0?f3:AX(a);n>r;){if(n-r>600){const d=n-r+1,u=t-r+1,f=Math.log(d),h=.5*Math.exp(2*f/3),p=.5*Math.sqrt(f*h*(d-h)/d)*(u-d/2<0?-1:1),g=Math.max(r,Math.floor(t-u*h/d+p)),v=Math.min(n,Math.floor(t+(d-u)*h/d+p));h3(e,t,g,v,a)}const i=e[t];let s=r,l=n;for(pd(e,r,t),a(e[n],i)>0&&pd(e,r,n);s0;)--l}a(e[r],i)===0?pd(e,r,l):(++l,pd(e,l,n)),l<=t&&(r=l+1),t<=l&&(n=l-1)}return e}function pd(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function DX(e,t,r){if(e=Float64Array.from(EX(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return oI(e);if(t>=1)return aI(e);var n,a=(n-1)*t,i=Math.floor(a),s=aI(h3(e,i).subarray(0,i+1)),l=oI(e.subarray(i+1));return s+(l-s)*(a-i)}}function LX(e,t,r=d3){if(!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return+r(e[0],0,e);if(t>=1)return+r(e[n-1],n-1,e);var n,a=(n-1)*t,i=Math.floor(a),s=+r(e[i],i,e),l=+r(e[i+1],i+1,e);return s+(l-s)*(a-i)}}function $X(e,t,r){e=+e,t=+t,r=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((t-e)/r))|0,i=new Array(a);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Mm(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?Mm(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=BX.exec(e))?new Ln(t[1],t[2],t[3],1):(t=zX.exec(e))?new Ln(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=UX.exec(e))?Mm(t[1],t[2],t[3],t[4]):(t=qX.exec(e))?Mm(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=VX.exec(e))?fI(t[1],t[2]/100,t[3]/100,1):(t=WX.exec(e))?fI(t[1],t[2]/100,t[3]/100,t[4]):iI.hasOwnProperty(e)?cI(iI[e]):e==="transparent"?new Ln(NaN,NaN,NaN,0):null}function cI(e){return new Ln(e>>16&255,e>>8&255,e&255,1)}function Mm(e,t,r,n){return n<=0&&(e=t=r=NaN),new Ln(e,t,r,n)}function YX(e){return e instanceof zf||(e=nf(e)),e?(e=e.rgb(),new Ln(e.r,e.g,e.b,e.opacity)):new Ln}function Fj(e,t,r,n){return arguments.length===1?YX(e):new Ln(e,t,r,n??1)}function Ln(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}UC(Ln,Fj,p3(zf,{brighter(e){return e=e==null?ug:Math.pow(ug,e),new Ln(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tf:Math.pow(tf,e),new Ln(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ln($s(this.r),$s(this.g),$s(this.b),dg(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:uI,formatHex:uI,formatHex8:KX,formatRgb:dI,toString:dI}));function uI(){return`#${Ms(this.r)}${Ms(this.g)}${Ms(this.b)}`}function KX(){return`#${Ms(this.r)}${Ms(this.g)}${Ms(this.b)}${Ms((isNaN(this.opacity)?1:this.opacity)*255)}`}function dI(){const e=dg(this.opacity);return`${e===1?"rgb(":"rgba("}${$s(this.r)}, ${$s(this.g)}, ${$s(this.b)}${e===1?")":`, ${e})`}`}function dg(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function $s(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ms(e){return e=$s(e),(e<16?"0":"")+e.toString(16)}function fI(e,t,r,n){return n<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Ya(e,t,r,n)}function g3(e){if(e instanceof Ya)return new Ya(e.h,e.s,e.l,e.opacity);if(e instanceof zf||(e=nf(e)),!e)return new Ya;if(e instanceof Ya)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,a=Math.min(t,r,n),i=Math.max(t,r,n),s=NaN,l=i-a,d=(i+a)/2;return l?(t===i?s=(r-n)/l+(r0&&d<1?0:s,new Ya(s,l,d,e.opacity)}function XX(e,t,r,n){return arguments.length===1?g3(e):new Ya(e,t,r,n??1)}function Ya(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}UC(Ya,XX,p3(zf,{brighter(e){return e=e==null?ug:Math.pow(ug,e),new Ya(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tf:Math.pow(tf,e),new Ya(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*t,a=2*r-n;return new Ln(B1(e>=240?e-240:e+120,a,n),B1(e,a,n),B1(e<120?e+240:e-120,a,n),this.opacity)},clamp(){return new Ya(hI(this.h),Rm(this.s),Rm(this.l),dg(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=dg(this.opacity);return`${e===1?"hsl(":"hsla("}${hI(this.h)}, ${Rm(this.s)*100}%, ${Rm(this.l)*100}%${e===1?")":`, ${e})`}`}}));function hI(e){return e=(e||0)%360,e<0?e+360:e}function Rm(e){return Math.max(0,Math.min(1,e||0))}function B1(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const qC=e=>()=>e;function JX(e,t){return function(r){return e+r*t}}function QX(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function ZX(e){return(e=+e)==1?y3:function(t,r){return r-t?QX(t,r,e):qC(isNaN(t)?r:t)}}function y3(e,t){var r=t-e;return r?JX(e,r):qC(isNaN(e)?t:e)}const mI=(function e(t){var r=ZX(t);function n(a,i){var s=r((a=Fj(a)).r,(i=Fj(i)).r),l=r(a.g,i.g),d=r(a.b,i.b),u=y3(a.opacity,i.opacity);return function(f){return a.r=s(f),a.g=l(f),a.b=d(f),a.opacity=u(f),a+""}}return n.gamma=e,n})(1);function eJ(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,n=t.slice(),a;return function(i){for(a=0;ar&&(i=t.slice(r,i),l[s]?l[s]+=i:l[++s]=i),(n=n[0])===(a=a[0])?l[s]?l[s]+=a:l[++s]=a:(l[++s]=null,d.push({i:s,x:fg(n,a)})),r=z1.lastIndex;return rt&&(r=e,e=t,t=r),function(n){return Math.max(e,Math.min(t,n))}}function dJ(e,t,r){var n=e[0],a=e[1],i=t[0],s=t[1];return a2?fJ:dJ,d=u=null,h}function h(p){return p==null||isNaN(p=+p)?i:(d||(d=l(e.map(n),t,r)))(n(s(p)))}return h.invert=function(p){return s(a((u||(u=l(t,e.map(n),fg)))(p)))},h.domain=function(p){return arguments.length?(e=Array.from(p,hg),f()):e.slice()},h.range=function(p){return arguments.length?(t=Array.from(p),f()):t.slice()},h.rangeRound=function(p){return t=Array.from(p),r=VC,f()},h.clamp=function(p){return arguments.length?(s=p?!0:Nn,f()):s!==Nn},h.interpolate=function(p){return arguments.length?(r=p,f()):r},h.unknown=function(p){return arguments.length?(i=p,h):i},function(p,g){return n=p,a=g,f()}}function WC(){return ky()(Nn,Nn)}function hJ(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function mg(e,t){if(!isFinite(e)||e===0)return null;var r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),n=e.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+e.slice(r+1)]}function Ic(e){return e=mg(Math.abs(e)),e?e[1]:NaN}function mJ(e,t){return function(r,n){for(var a=r.length,i=[],s=0,l=e[0],d=0;a>0&&l>0&&(d+l+1>n&&(l=Math.max(1,n-d)),i.push(r.substring(a-=l,a+l)),!((d+=l+1)>n));)l=e[s=(s+1)%e.length];return i.reverse().join(t)}}function pJ(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var gJ=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function af(e){if(!(t=gJ.exec(e)))throw new Error("invalid format: "+e);var t;return new HC({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}af.prototype=HC.prototype;function HC(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}HC.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function yJ(e){e:for(var t=e.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(a+1):e}var pg;function vJ(e,t){var r=mg(e,t);if(!r)return pg=void 0,e.toPrecision(t);var n=r[0],a=r[1],i=a-(pg=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,s=n.length;return i===s?n:i>s?n+new Array(i-s+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+mg(e,Math.max(0,t+i-1))[0]}function gI(e,t){var r=mg(e,t);if(!r)return e+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const yI={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:hJ,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>gI(e*100,t),r:gI,s:vJ,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function vI(e){return e}var xI=Array.prototype.map,bI=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function xJ(e){var t=e.grouping===void 0||e.thousands===void 0?vI:mJ(xI.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?vI:pJ(xI.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",d=e.nan===void 0?"NaN":e.nan+"";function u(h,p){h=af(h);var g=h.fill,v=h.align,b=h.sign,w=h.symbol,j=h.zero,N=h.width,C=h.comma,O=h.precision,P=h.trim,E=h.type;E==="n"?(C=!0,E="g"):yI[E]||(O===void 0&&(O=12),P=!0,E="g"),(j||g==="0"&&v==="=")&&(j=!0,g="0",v="=");var T=(p&&p.prefix!==void 0?p.prefix:"")+(w==="$"?r:w==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():""),A=(w==="$"?n:/[%p]/.test(E)?s:"")+(p&&p.suffix!==void 0?p.suffix:""),M=yI[E],R=/[defgprs%]/.test(E);O=O===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,O)):Math.max(0,Math.min(20,O));function L(V){var z=T,G=A,H,W,q;if(E==="c")G=M(V)+G,V="";else{V=+V;var I=V<0||1/V<0;if(V=isNaN(V)?d:M(Math.abs(V),O),P&&(V=yJ(V)),I&&+V==0&&b!=="+"&&(I=!1),z=(I?b==="("?b:l:b==="-"||b==="("?"":b)+z,G=(E==="s"&&!isNaN(V)&&pg!==void 0?bI[8+pg/3]:"")+G+(I&&b==="("?")":""),R){for(H=-1,W=V.length;++Hq||q>57){G=(q===46?a+V.slice(H+1):V.slice(H))+G,V=V.slice(0,H);break}}}C&&!j&&(V=t(V,1/0));var Y=z.length+V.length+G.length,F=Y>1)+z+V+G+F.slice(Y);break;default:V=F+z+V+G;break}return i(V)}return L.toString=function(){return h+""},L}function f(h,p){var g=Math.max(-8,Math.min(8,Math.floor(Ic(p)/3)))*3,v=Math.pow(10,-g),b=u((h=af(h),h.type="f",h),{suffix:bI[8+g/3]});return function(w){return b(v*w)}}return{format:u,formatPrefix:f}}var Dm,GC,v3;bJ({thousands:",",grouping:[3],currency:["$",""]});function bJ(e){return Dm=xJ(e),GC=Dm.format,v3=Dm.formatPrefix,Dm}function wJ(e){return Math.max(0,-Ic(Math.abs(e)))}function SJ(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ic(t)/3)))*3-Ic(Math.abs(e)))}function jJ(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Ic(t)-Ic(e))+1}function x3(e,t,r,n){var a=Lj(e,t,r),i;switch(n=af(n??",f"),n.type){case"s":{var s=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(i=SJ(a,s))&&(n.precision=i),v3(n,s)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=jJ(a,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=wJ(a))&&(n.precision=i-(n.type==="%")*2);break}}return GC(n)}function Gi(e){var t=e.domain;return e.ticks=function(r){var n=t();return Rj(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var a=t();return x3(a[0],a[a.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=t(),a=0,i=n.length-1,s=n[a],l=n[i],d,u,f=10;for(l0;){if(u=Dj(s,l,r),u===d)return n[a]=s,n[i]=l,t(n);if(u>0)s=Math.floor(s/u)*u,l=Math.ceil(l/u)*u;else if(u<0)s=Math.ceil(s*u)/u,l=Math.floor(l*u)/u;else break;d=u}return e},e}function gg(){var e=WC();return e.copy=function(){return Uf(e,gg())},Ra.apply(e,arguments),Gi(e)}function b3(e){var t;function r(n){return n==null||isNaN(n=+n)?t:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(e=Array.from(n,hg),r):e.slice()},r.unknown=function(n){return arguments.length?(t=n,r):t},r.copy=function(){return b3(e).unknown(t)},e=arguments.length?Array.from(e,hg):[0,1],Gi(r)}function w3(e,t){e=e.slice();var r=0,n=e.length-1,a=e[r],i=e[n],s;return iMath.pow(e,t)}function PJ(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function jI(e){return(t,r)=>-e(-t,r)}function YC(e){const t=e(wI,SI),r=t.domain;let n=10,a,i;function s(){return a=PJ(n),i=EJ(n),r()[0]<0?(a=jI(a),i=jI(i),e(NJ,CJ)):e(wI,SI),t}return t.base=function(l){return arguments.length?(n=+l,s()):n},t.domain=function(l){return arguments.length?(r(l),s()):r()},t.ticks=l=>{const d=r();let u=d[0],f=d[d.length-1];const h=f0){for(;p<=g;++p)for(v=1;vf)break;j.push(b)}}else for(;p<=g;++p)for(v=n-1;v>=1;--v)if(b=p>0?v/i(-p):v*i(p),!(bf)break;j.push(b)}j.length*2{if(l==null&&(l=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=af(d)).precision==null&&(d.trim=!0),d=GC(d)),l===1/0)return d;const u=Math.max(1,n*l/t.ticks().length);return f=>{let h=f/i(Math.round(a(f)));return h*nr(w3(r(),{floor:l=>i(Math.floor(a(l))),ceil:l=>i(Math.ceil(a(l)))})),t}function S3(){const e=YC(ky()).domain([1,10]);return e.copy=()=>Uf(e,S3()).base(e.base()),Ra.apply(e,arguments),e}function NI(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function CI(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function KC(e){var t=1,r=e(NI(t),CI(t));return r.constant=function(n){return arguments.length?e(NI(t=+n),CI(t)):t},Gi(r)}function j3(){var e=KC(ky());return e.copy=function(){return Uf(e,j3()).constant(e.constant())},Ra.apply(e,arguments)}function _I(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function OJ(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function TJ(e){return e<0?-e*e:e*e}function XC(e){var t=e(Nn,Nn),r=1;function n(){return r===1?e(Nn,Nn):r===.5?e(OJ,TJ):e(_I(r),_I(1/r))}return t.exponent=function(a){return arguments.length?(r=+a,n()):r},Gi(t)}function JC(){var e=XC(ky());return e.copy=function(){return Uf(e,JC()).exponent(e.exponent())},Ra.apply(e,arguments),e}function kJ(){return JC.apply(null,arguments).exponent(.5)}function EI(e){return Math.sign(e)*e*e}function AJ(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function N3(){var e=WC(),t=[0,1],r=!1,n;function a(i){var s=AJ(e(i));return isNaN(s)?n:r?Math.round(s):s}return a.invert=function(i){return e.invert(EI(i))},a.domain=function(i){return arguments.length?(e.domain(i),a):e.domain()},a.range=function(i){return arguments.length?(e.range((t=Array.from(i,hg)).map(EI)),a):t.slice()},a.rangeRound=function(i){return a.range(i).round(!0)},a.round=function(i){return arguments.length?(r=!!i,a):r},a.clamp=function(i){return arguments.length?(e.clamp(i),a):e.clamp()},a.unknown=function(i){return arguments.length?(n=i,a):n},a.copy=function(){return N3(e.domain(),t).round(r).clamp(e.clamp()).unknown(n)},Ra.apply(a,arguments),Gi(a)}function C3(){var e=[],t=[],r=[],n;function a(){var s=0,l=Math.max(1,t.length);for(r=new Array(l-1);++s0?r[l-1]:e[0],l=r?[n[r-1],t]:[n[u-1],n[u]]},s.unknown=function(d){return arguments.length&&(i=d),s},s.thresholds=function(){return n.slice()},s.copy=function(){return _3().domain([e,t]).range(a).unknown(i)},Ra.apply(Gi(s),arguments)}function E3(){var e=[.5],t=[0,1],r,n=1;function a(i){return i!=null&&i<=i?t[Bf(e,i,0,n)]:r}return a.domain=function(i){return arguments.length?(e=Array.from(i),n=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(i){return arguments.length?(t=Array.from(i),n=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(i){var s=t.indexOf(i);return[e[s-1],e[s]]},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return E3().domain(e).range(t).unknown(r)},Ra.apply(a,arguments)}const U1=new Date,q1=new Date;function zr(e,t,r,n){function a(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(e(i=new Date(+i)),i),a.ceil=i=>(e(i=new Date(i-1)),t(i,1),e(i),i),a.round=i=>{const s=a(i),l=a.ceil(i);return i-s(t(i=new Date(+i),s==null?1:Math.floor(s)),i),a.range=(i,s,l)=>{const d=[];if(i=a.ceil(i),l=l==null?1:Math.floor(l),!(i0))return d;let u;do d.push(u=new Date(+i)),t(i,l),e(i);while(uzr(s=>{if(s>=s)for(;e(s),!i(s);)s.setTime(s-1)},(s,l)=>{if(s>=s)if(l<0)for(;++l<=0;)for(;t(s,-1),!i(s););else for(;--l>=0;)for(;t(s,1),!i(s););}),r&&(a.count=(i,s)=>(U1.setTime(+i),q1.setTime(+s),e(U1),e(q1),Math.floor(r(U1,q1))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(n?s=>n(s)%i===0:s=>a.count(0,s)%i===0):a)),a}const yg=zr(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);yg.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?zr(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):yg);yg.range;const Go=1e3,Pa=Go*60,Yo=Pa*60,ni=Yo*24,QC=ni*7,PI=ni*30,V1=ni*365,Rs=zr(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Go)},(e,t)=>(t-e)/Go,e=>e.getUTCSeconds());Rs.range;const ZC=zr(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Go)},(e,t)=>{e.setTime(+e+t*Pa)},(e,t)=>(t-e)/Pa,e=>e.getMinutes());ZC.range;const e_=zr(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Pa)},(e,t)=>(t-e)/Pa,e=>e.getUTCMinutes());e_.range;const t_=zr(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Go-e.getMinutes()*Pa)},(e,t)=>{e.setTime(+e+t*Yo)},(e,t)=>(t-e)/Yo,e=>e.getHours());t_.range;const r_=zr(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Yo)},(e,t)=>(t-e)/Yo,e=>e.getUTCHours());r_.range;const qf=zr(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Pa)/ni,e=>e.getDate()-1);qf.range;const Ay=zr(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ni,e=>e.getUTCDate()-1);Ay.range;const P3=zr(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ni,e=>Math.floor(e/ni));P3.range;function sl(e){return zr(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*Pa)/QC)}const Iy=sl(0),vg=sl(1),IJ=sl(2),MJ=sl(3),Mc=sl(4),RJ=sl(5),DJ=sl(6);Iy.range;vg.range;IJ.range;MJ.range;Mc.range;RJ.range;DJ.range;function ll(e){return zr(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/QC)}const My=ll(0),xg=ll(1),LJ=ll(2),$J=ll(3),Rc=ll(4),FJ=ll(5),BJ=ll(6);My.range;xg.range;LJ.range;$J.range;Rc.range;FJ.range;BJ.range;const n_=zr(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());n_.range;const a_=zr(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());a_.range;const ai=zr(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());ai.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:zr(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});ai.range;const oi=zr(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());oi.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:zr(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});oi.range;function O3(e,t,r,n,a,i){const s=[[Rs,1,Go],[Rs,5,5*Go],[Rs,15,15*Go],[Rs,30,30*Go],[i,1,Pa],[i,5,5*Pa],[i,15,15*Pa],[i,30,30*Pa],[a,1,Yo],[a,3,3*Yo],[a,6,6*Yo],[a,12,12*Yo],[n,1,ni],[n,2,2*ni],[r,1,QC],[t,1,PI],[t,3,3*PI],[e,1,V1]];function l(u,f,h){const p=fw).right(s,p);if(g===s.length)return e.every(Lj(u/V1,f/V1,h));if(g===0)return yg.every(Math.max(Lj(u,f,h),1));const[v,b]=s[p/s[g-1][2]53)return null;"w"in Z||(Z.w=1),"Z"in Z?(Ce=H1(gd(Z.y,0,1)),qe=Ce.getUTCDay(),Ce=qe>4||qe===0?xg.ceil(Ce):xg(Ce),Ce=Ay.offset(Ce,(Z.V-1)*7),Z.y=Ce.getUTCFullYear(),Z.m=Ce.getUTCMonth(),Z.d=Ce.getUTCDate()+(Z.w+6)%7):(Ce=W1(gd(Z.y,0,1)),qe=Ce.getDay(),Ce=qe>4||qe===0?vg.ceil(Ce):vg(Ce),Ce=qf.offset(Ce,(Z.V-1)*7),Z.y=Ce.getFullYear(),Z.m=Ce.getMonth(),Z.d=Ce.getDate()+(Z.w+6)%7)}else("W"in Z||"U"in Z)&&("w"in Z||(Z.w="u"in Z?Z.u%7:"W"in Z?1:0),qe="Z"in Z?H1(gd(Z.y,0,1)).getUTCDay():W1(gd(Z.y,0,1)).getDay(),Z.m=0,Z.d="W"in Z?(Z.w+6)%7+Z.W*7-(qe+5)%7:Z.w+Z.U*7-(qe+6)%7);return"Z"in Z?(Z.H+=Z.Z/100|0,Z.M+=Z.Z%100,H1(Z)):W1(Z)}}function A(se,fe,we,Z){for(var je=0,Ce=fe.length,qe=we.length,De,He;je=qe)return-1;if(De=fe.charCodeAt(je++),De===37){if(De=fe.charAt(je++),He=P[De in OI?fe.charAt(je++):De],!He||(Z=He(se,we,Z))<0)return-1}else if(De!=we.charCodeAt(Z++))return-1}return Z}function M(se,fe,we){var Z=u.exec(fe.slice(we));return Z?(se.p=f.get(Z[0].toLowerCase()),we+Z[0].length):-1}function R(se,fe,we){var Z=g.exec(fe.slice(we));return Z?(se.w=v.get(Z[0].toLowerCase()),we+Z[0].length):-1}function L(se,fe,we){var Z=h.exec(fe.slice(we));return Z?(se.w=p.get(Z[0].toLowerCase()),we+Z[0].length):-1}function V(se,fe,we){var Z=j.exec(fe.slice(we));return Z?(se.m=N.get(Z[0].toLowerCase()),we+Z[0].length):-1}function z(se,fe,we){var Z=b.exec(fe.slice(we));return Z?(se.m=w.get(Z[0].toLowerCase()),we+Z[0].length):-1}function G(se,fe,we){return A(se,t,fe,we)}function H(se,fe,we){return A(se,r,fe,we)}function W(se,fe,we){return A(se,n,fe,we)}function q(se){return s[se.getDay()]}function I(se){return i[se.getDay()]}function Y(se){return d[se.getMonth()]}function F(se){return l[se.getMonth()]}function D(se){return a[+(se.getHours()>=12)]}function $(se){return 1+~~(se.getMonth()/3)}function K(se){return s[se.getUTCDay()]}function J(se){return i[se.getUTCDay()]}function oe(se){return d[se.getUTCMonth()]}function re(se){return l[se.getUTCMonth()]}function Q(se){return a[+(se.getUTCHours()>=12)]}function ue(se){return 1+~~(se.getUTCMonth()/3)}return{format:function(se){var fe=E(se+="",C);return fe.toString=function(){return se},fe},parse:function(se){var fe=T(se+="",!1);return fe.toString=function(){return se},fe},utcFormat:function(se){var fe=E(se+="",O);return fe.toString=function(){return se},fe},utcParse:function(se){var fe=T(se+="",!0);return fe.toString=function(){return se},fe}}}var OI={"-":"",_:" ",0:"0"},Xr=/^\s*\d+/,HJ=/^%/,GJ=/[\\^$*+?|[\]().{}]/g;function Ut(e,t,r){var n=e<0?"-":"",a=(n?-e:e)+"",i=a.length;return n+(i[t.toLowerCase(),r]))}function KJ(e,t,r){var n=Xr.exec(t.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function XJ(e,t,r){var n=Xr.exec(t.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function JJ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function QJ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function ZJ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function TI(e,t,r){var n=Xr.exec(t.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function kI(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function eQ(e,t,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function tQ(e,t,r){var n=Xr.exec(t.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function rQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function AI(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function nQ(e,t,r){var n=Xr.exec(t.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function II(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function aQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function oQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function iQ(e,t,r){var n=Xr.exec(t.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function sQ(e,t,r){var n=Xr.exec(t.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function lQ(e,t,r){var n=HJ.exec(t.slice(r,r+1));return n?r+n[0].length:-1}function cQ(e,t,r){var n=Xr.exec(t.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function uQ(e,t,r){var n=Xr.exec(t.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function MI(e,t){return Ut(e.getDate(),t,2)}function dQ(e,t){return Ut(e.getHours(),t,2)}function fQ(e,t){return Ut(e.getHours()%12||12,t,2)}function hQ(e,t){return Ut(1+qf.count(ai(e),e),t,3)}function T3(e,t){return Ut(e.getMilliseconds(),t,3)}function mQ(e,t){return T3(e,t)+"000"}function pQ(e,t){return Ut(e.getMonth()+1,t,2)}function gQ(e,t){return Ut(e.getMinutes(),t,2)}function yQ(e,t){return Ut(e.getSeconds(),t,2)}function vQ(e){var t=e.getDay();return t===0?7:t}function xQ(e,t){return Ut(Iy.count(ai(e)-1,e),t,2)}function k3(e){var t=e.getDay();return t>=4||t===0?Mc(e):Mc.ceil(e)}function bQ(e,t){return e=k3(e),Ut(Mc.count(ai(e),e)+(ai(e).getDay()===4),t,2)}function wQ(e){return e.getDay()}function SQ(e,t){return Ut(vg.count(ai(e)-1,e),t,2)}function jQ(e,t){return Ut(e.getFullYear()%100,t,2)}function NQ(e,t){return e=k3(e),Ut(e.getFullYear()%100,t,2)}function CQ(e,t){return Ut(e.getFullYear()%1e4,t,4)}function _Q(e,t){var r=e.getDay();return e=r>=4||r===0?Mc(e):Mc.ceil(e),Ut(e.getFullYear()%1e4,t,4)}function EQ(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Ut(t/60|0,"0",2)+Ut(t%60,"0",2)}function RI(e,t){return Ut(e.getUTCDate(),t,2)}function PQ(e,t){return Ut(e.getUTCHours(),t,2)}function OQ(e,t){return Ut(e.getUTCHours()%12||12,t,2)}function TQ(e,t){return Ut(1+Ay.count(oi(e),e),t,3)}function A3(e,t){return Ut(e.getUTCMilliseconds(),t,3)}function kQ(e,t){return A3(e,t)+"000"}function AQ(e,t){return Ut(e.getUTCMonth()+1,t,2)}function IQ(e,t){return Ut(e.getUTCMinutes(),t,2)}function MQ(e,t){return Ut(e.getUTCSeconds(),t,2)}function RQ(e){var t=e.getUTCDay();return t===0?7:t}function DQ(e,t){return Ut(My.count(oi(e)-1,e),t,2)}function I3(e){var t=e.getUTCDay();return t>=4||t===0?Rc(e):Rc.ceil(e)}function LQ(e,t){return e=I3(e),Ut(Rc.count(oi(e),e)+(oi(e).getUTCDay()===4),t,2)}function $Q(e){return e.getUTCDay()}function FQ(e,t){return Ut(xg.count(oi(e)-1,e),t,2)}function BQ(e,t){return Ut(e.getUTCFullYear()%100,t,2)}function zQ(e,t){return e=I3(e),Ut(e.getUTCFullYear()%100,t,2)}function UQ(e,t){return Ut(e.getUTCFullYear()%1e4,t,4)}function qQ(e,t){var r=e.getUTCDay();return e=r>=4||r===0?Rc(e):Rc.ceil(e),Ut(e.getUTCFullYear()%1e4,t,4)}function VQ(){return"+0000"}function DI(){return"%"}function LI(e){return+e}function $I(e){return Math.floor(+e/1e3)}var Hl,M3,R3;WQ({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function WQ(e){return Hl=WJ(e),M3=Hl.format,Hl.parse,R3=Hl.utcFormat,Hl.utcParse,Hl}function HQ(e){return new Date(e)}function GQ(e){return e instanceof Date?+e:+new Date(+e)}function o_(e,t,r,n,a,i,s,l,d,u){var f=WC(),h=f.invert,p=f.domain,g=u(".%L"),v=u(":%S"),b=u("%I:%M"),w=u("%I %p"),j=u("%a %d"),N=u("%b %d"),C=u("%B"),O=u("%Y");function P(E){return(d(E)t(a/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,i)=>DX(e,i/n))},r.copy=function(){return F3(t).domain(e)},ui.apply(r,arguments)}function Dy(){var e=0,t=.5,r=1,n=1,a,i,s,l,d,u=Nn,f,h=!1,p;function g(b){return isNaN(b=+b)?p:(b=.5+((b=+f(b))-i)*(n*br}return Y1=e,Y1}var K1,UI;function QQ(){if(UI)return K1;UI=1;var e=Ly(),t=q3(),r=mu();function n(a){return a&&a.length?e(a,r,t):void 0}return K1=n,K1}var ZQ=QQ();const $y=Vt(ZQ);var X1,qI;function V3(){if(qI)return X1;qI=1;function e(t,r){return te.e^i.s<0?1:-1;for(n=i.d.length,a=e.d.length,t=0,r=ne.d[t]^i.s<0?1:-1;return n===a?0:n>a^i.s<0?1:-1};We.decimalPlaces=We.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*dr;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};We.dividedBy=We.div=function(e){return Zo(this,new this.constructor(e))};We.dividedToIntegerBy=We.idiv=function(e){var t=this,r=t.constructor;return Zt(Zo(t,new r(e),0,1),r.precision)};We.equals=We.eq=function(e){return!this.cmp(e)};We.exponent=function(){return Tr(this)};We.greaterThan=We.gt=function(e){return this.cmp(e)>0};We.greaterThanOrEqualTo=We.gte=function(e){return this.cmp(e)>=0};We.isInteger=We.isint=function(){return this.e>this.d.length-2};We.isNegative=We.isneg=function(){return this.s<0};We.isPositive=We.ispos=function(){return this.s>0};We.isZero=function(){return this.s===0};We.lessThan=We.lt=function(e){return this.cmp(e)<0};We.lessThanOrEqualTo=We.lte=function(e){return this.cmp(e)<1};We.logarithm=We.log=function(e){var t,r=this,n=r.constructor,a=n.precision,i=a+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(aa))throw Error(Ta+"NaN");if(r.s<1)throw Error(Ta+(r.s?"NaN":"-Infinity"));return r.eq(aa)?new n(0):(pr=!1,t=Zo(of(r,i),of(e,i),i),pr=!0,Zt(t,a))};We.minus=We.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Y3(t,e):H3(t,(e.s=-e.s,e))};We.modulo=We.mod=function(e){var t,r=this,n=r.constructor,a=n.precision;if(e=new n(e),!e.s)throw Error(Ta+"NaN");return r.s?(pr=!1,t=Zo(r,e,0,1).times(e),pr=!0,r.minus(t)):Zt(new n(r),a)};We.naturalExponential=We.exp=function(){return G3(this)};We.naturalLogarithm=We.ln=function(){return of(this)};We.negated=We.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};We.plus=We.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?H3(t,e):Y3(t,(e.s=-e.s,e))};We.precision=We.sd=function(e){var t,r,n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Fs+e);if(t=Tr(a)+1,n=a.d.length-1,r=n*dr+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return e&&t>r?t:r};We.squareRoot=We.sqrt=function(){var e,t,r,n,a,i,s,l=this,d=l.constructor;if(l.s<1){if(!l.s)return new d(0);throw Error(Ta+"NaN")}for(e=Tr(l),pr=!1,a=Math.sqrt(+l),a==0||a==1/0?(t=po(l.d),(t.length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=yu((e+1)/2)-(e<0||e%2),a==1/0?t="5e"+e:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new d(t)):n=new d(a.toString()),r=d.precision,a=s=r+3;;)if(i=n,n=i.plus(Zo(l,i,s+2)).times(.5),po(i.d).slice(0,s)===(t=po(n.d)).slice(0,s)){if(t=t.slice(s-3,s+1),a==s&&t=="4999"){if(Zt(i,r+1,0),i.times(i).eq(l)){n=i;break}}else if(t!="9999")break;s+=4}return pr=!0,Zt(n,r)};We.times=We.mul=function(e){var t,r,n,a,i,s,l,d,u,f=this,h=f.constructor,p=f.d,g=(e=new h(e)).d;if(!f.s||!e.s)return new h(0);for(e.s*=f.s,r=f.e+e.e,d=p.length,u=g.length,d=0;){for(t=0,a=d+n;a>n;)l=i[a]+g[n]*p[a-n-1]+t,i[a--]=l%Hr|0,t=l/Hr|0;i[a]=(i[a]+t)%Hr|0}for(;!i[--s];)i.pop();return t?++r:i.shift(),e.d=i,e.e=r,pr?Zt(e,h.precision):e};We.toDecimalPlaces=We.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(wo(e,0,gu),t===void 0?t=n.rounding:wo(t,0,8),Zt(r,e+Tr(r)+1,t))};We.toExponential=function(e,t){var r,n=this,a=n.constructor;return e===void 0?r=Ws(n,!0):(wo(e,0,gu),t===void 0?t=a.rounding:wo(t,0,8),n=Zt(new a(n),e+1,t),r=Ws(n,!0,e+1)),r};We.toFixed=function(e,t){var r,n,a=this,i=a.constructor;return e===void 0?Ws(a):(wo(e,0,gu),t===void 0?t=i.rounding:wo(t,0,8),n=Zt(new i(a),e+Tr(a)+1,t),r=Ws(n.abs(),!1,e+Tr(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};We.toInteger=We.toint=function(){var e=this,t=e.constructor;return Zt(new t(e),Tr(e)+1,t.rounding)};We.toNumber=function(){return+this};We.toPower=We.pow=function(e){var t,r,n,a,i,s,l=this,d=l.constructor,u=12,f=+(e=new d(e));if(!e.s)return new d(aa);if(l=new d(l),!l.s){if(e.s<1)throw Error(Ta+"Infinity");return l}if(l.eq(aa))return l;if(n=d.precision,e.eq(aa))return Zt(l,n);if(t=e.e,r=e.d.length-1,s=t>=r,i=l.s,s){if((r=f<0?-f:f)<=W3){for(a=new d(aa),t=Math.ceil(n/dr+4),pr=!1;r%2&&(a=a.times(l),KI(a.d,t)),r=yu(r/2),r!==0;)l=l.times(l),KI(l.d,t);return pr=!0,e.s<0?new d(aa).div(a):Zt(a,n)}}else if(i<0)throw Error(Ta+"NaN");return i=i<0&&e.d[Math.max(t,r)]&1?-1:1,l.s=1,pr=!1,a=e.times(of(l,n+u)),pr=!0,a=G3(a),a.s=i,a};We.toPrecision=function(e,t){var r,n,a=this,i=a.constructor;return e===void 0?(r=Tr(a),n=Ws(a,r<=i.toExpNeg||r>=i.toExpPos)):(wo(e,1,gu),t===void 0?t=i.rounding:wo(t,0,8),a=Zt(new i(a),e,t),r=Tr(a),n=Ws(a,e<=r||r<=i.toExpNeg,e)),n};We.toSignificantDigits=We.tosd=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(wo(e,1,gu),t===void 0?t=n.rounding:wo(t,0,8)),Zt(new n(r),e,t)};We.toString=We.valueOf=We.val=We.toJSON=We[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Tr(e),r=e.constructor;return Ws(e,t<=r.toExpNeg||t>=r.toExpPos)};function H3(e,t){var r,n,a,i,s,l,d,u,f=e.constructor,h=f.precision;if(!e.s||!t.s)return t.s||(t=new f(e)),pr?Zt(t,h):t;if(d=e.d,u=t.d,s=e.e,a=t.e,d=d.slice(),i=s-a,i){for(i<0?(n=d,i=-i,l=u.length):(n=u,a=s,l=d.length),s=Math.ceil(h/dr),l=s>l?s+1:l+1,i>l&&(i=l,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(l=d.length,i=u.length,l-i<0&&(i=l,n=u,u=d,d=n),r=0;i;)r=(d[--i]=d[i]+u[i]+r)/Hr|0,d[i]%=Hr;for(r&&(d.unshift(r),++a),l=d.length;d[--l]==0;)d.pop();return t.d=d,t.e=a,pr?Zt(t,h):t}function wo(e,t,r){if(e!==~~e||er)throw Error(Fs+e)}function po(e){var t,r,n,a=e.length-1,i="",s=e[0];if(a>0){for(i+=s,t=1;ts?1:-1;else for(l=d=0;la[l]?1:-1;break}return d}function r(n,a,i){for(var s=0;i--;)n[i]-=s,s=n[i]1;)n.shift()}return function(n,a,i,s){var l,d,u,f,h,p,g,v,b,w,j,N,C,O,P,E,T,A,M=n.constructor,R=n.s==a.s?1:-1,L=n.d,V=a.d;if(!n.s)return new M(n);if(!a.s)throw Error(Ta+"Division by zero");for(d=n.e-a.e,T=V.length,P=L.length,g=new M(R),v=g.d=[],u=0;V[u]==(L[u]||0);)++u;if(V[u]>(L[u]||0)&&--d,i==null?N=i=M.precision:s?N=i+(Tr(n)-Tr(a))+1:N=i,N<0)return new M(0);if(N=N/dr+2|0,u=0,T==1)for(f=0,V=V[0],N++;(u1&&(V=e(V,f),L=e(L,f),T=V.length,P=L.length),O=T,b=L.slice(0,T),w=b.length;w=Hr/2&&++E;do f=0,l=t(V,b,T,w),l<0?(j=b[0],T!=w&&(j=j*Hr+(b[1]||0)),f=j/E|0,f>1?(f>=Hr&&(f=Hr-1),h=e(V,f),p=h.length,w=b.length,l=t(h,b,p,w),l==1&&(f--,r(h,T16)throw Error(l_+Tr(e));if(!e.s)return new f(aa);for(pr=!1,l=h,s=new f(.03125);e.abs().gte(.1);)e=e.times(s),u+=5;for(n=Math.log(Os(2,u))/Math.LN10*2+5|0,l+=n,r=a=i=new f(aa),f.precision=l;;){if(a=Zt(a.times(e),l),r=r.times(++d),s=i.plus(Zo(a,r,l)),po(s.d).slice(0,l)===po(i.d).slice(0,l)){for(;u--;)i=Zt(i.times(i),l);return f.precision=h,t==null?(pr=!0,Zt(i,h)):i}i=s}}function Tr(e){for(var t=e.e*dr,r=e.d[0];r>=10;r/=10)t++;return t}function tS(e,t,r){if(t>e.LN10.sd())throw pr=!0,r&&(e.precision=r),Error(Ta+"LN10 precision limit exceeded");return Zt(new e(e.LN10),t)}function Ri(e){for(var t="";e--;)t+="0";return t}function of(e,t){var r,n,a,i,s,l,d,u,f,h=1,p=10,g=e,v=g.d,b=g.constructor,w=b.precision;if(g.s<1)throw Error(Ta+(g.s?"NaN":"-Infinity"));if(g.eq(aa))return new b(0);if(t==null?(pr=!1,u=w):u=t,g.eq(10))return t==null&&(pr=!0),tS(b,u);if(u+=p,b.precision=u,r=po(v),n=r.charAt(0),i=Tr(g),Math.abs(i)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)g=g.times(e),r=po(g.d),n=r.charAt(0),h++;i=Tr(g),n>1?(g=new b("0."+r),i++):g=new b(n+"."+r.slice(1))}else return d=tS(b,u+2,w).times(i+""),g=of(new b(n+"."+r.slice(1)),u-p).plus(d),b.precision=w,t==null?(pr=!0,Zt(g,w)):g;for(l=s=g=Zo(g.minus(aa),g.plus(aa),u),f=Zt(g.times(g),u),a=3;;){if(s=Zt(s.times(f),u),d=l.plus(Zo(s,new b(a),u)),po(d.d).slice(0,u)===po(l.d).slice(0,u))return l=l.times(2),i!==0&&(l=l.plus(tS(b,u+2,w).times(i+""))),l=Zo(l,new b(h),u),b.precision=w,t==null?(pr=!0,Zt(l,w)):l;l=d,a+=2}}function YI(e,t){var r,n,a;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;)++n;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(n,a),t){if(a-=n,r=r-n-1,e.e=yu(r/dr),e.d=[],n=(r+1)%dr,r<0&&(n+=dr),nbg||e.e<-bg))throw Error(l_+r)}else e.s=0,e.e=0,e.d=[0];return e}function Zt(e,t,r){var n,a,i,s,l,d,u,f,h=e.d;for(s=1,i=h[0];i>=10;i/=10)s++;if(n=t-s,n<0)n+=dr,a=t,u=h[f=0];else{if(f=Math.ceil((n+1)/dr),i=h.length,f>=i)return e;for(u=i=h[f],s=1;i>=10;i/=10)s++;n%=dr,a=n-dr+s}if(r!==void 0&&(i=Os(10,s-a-1),l=u/i%10|0,d=t<0||h[f+1]!==void 0||u%i,d=r<4?(l||d)&&(r==0||r==(e.s<0?3:2)):l>5||l==5&&(r==4||d||r==6&&(n>0?a>0?u/Os(10,s-a):0:h[f-1])%10&1||r==(e.s<0?8:7))),t<1||!h[0])return d?(i=Tr(e),h.length=1,t=t-i-1,h[0]=Os(10,(dr-t%dr)%dr),e.e=yu(-t/dr)||0):(h.length=1,h[0]=e.e=e.s=0),e;if(n==0?(h.length=f,i=1,f--):(h.length=f+1,i=Os(10,dr-n),h[f]=a>0?(u/Os(10,s-a)%Os(10,a)|0)*i:0),d)for(;;)if(f==0){(h[0]+=i)==Hr&&(h[0]=1,++e.e);break}else{if(h[f]+=i,h[f]!=Hr)break;h[f--]=0,i=1}for(n=h.length;h[--n]===0;)h.pop();if(pr&&(e.e>bg||e.e<-bg))throw Error(l_+Tr(e));return e}function Y3(e,t){var r,n,a,i,s,l,d,u,f,h,p=e.constructor,g=p.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new p(e),pr?Zt(t,g):t;if(d=e.d,h=t.d,n=t.e,u=e.e,d=d.slice(),s=u-n,s){for(f=s<0,f?(r=d,s=-s,l=h.length):(r=h,n=u,l=d.length),a=Math.max(Math.ceil(g/dr),l)+2,s>a&&(s=a,r.length=1),r.reverse(),a=s;a--;)r.push(0);r.reverse()}else{for(a=d.length,l=h.length,f=a0;--a)d[l++]=0;for(a=h.length;a>s;){if(d[--a]0?i=i.charAt(0)+"."+i.slice(1)+Ri(n):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(a<0?"e":"e+")+a):a<0?(i="0."+Ri(-a-1)+i,r&&(n=r-s)>0&&(i+=Ri(n))):a>=s?(i+=Ri(a+1-s),r&&(n=r-a-1)>0&&(i=i+"."+Ri(n))):((n=a+1)0&&(a+1===s&&(i+="."),i+=Ri(n))),e.s<0?"-"+i:i}function KI(e,t){if(e.length>t)return e.length=t,!0}function K3(e){var t,r,n;function a(i){var s=this;if(!(s instanceof a))return new a(i);if(s.constructor=a,i instanceof a){s.s=i.s,s.e=i.e,s.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(Fs+i);if(i>0)s.s=1;else if(i<0)i=-i,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(i===~~i&&i<1e7){s.e=0,s.d=[i];return}return YI(s,i.toString())}else if(typeof i!="string")throw Error(Fs+i);if(i.charCodeAt(0)===45?(i=i.slice(1),s.s=-1):s.s=1,cZ.test(i))YI(s,i);else throw Error(Fs+i)}if(a.prototype=We,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=K3,a.config=a.set=uZ,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=a[t+1]&&n<=a[t+2])this[r]=n;else throw Error(Fs+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Fs+r+": "+n);return this}var c_=K3(lZ);aa=new c_(1);const Jt=c_;function dZ(e){return pZ(e)||mZ(e)||hZ(e)||fZ()}function fZ(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hZ(e,t){if(e){if(typeof e=="string")return Uj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Uj(e,t)}}function mZ(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function pZ(e){if(Array.isArray(e))return Uj(e)}function Uj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t?r.apply(void 0,a):e(t-s,XI(function(){for(var l=arguments.length,d=new Array(l),u=0;ue.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,a=!1,i=void 0;try{for(var s=e[Symbol.iterator](),l;!(n=(l=s.next()).done)&&(r.push(l.value),!(t&&r.length===t));n=!0);}catch(d){a=!0,i=d}finally{try{!n&&s.return!=null&&s.return()}finally{if(a)throw i}}return r}}function TZ(e){if(Array.isArray(e))return e}function e5(e){var t=sf(e,2),r=t[0],n=t[1],a=r,i=n;return r>n&&(a=n,i=r),[a,i]}function t5(e,t,r){if(e.lte(0))return new Jt(0);var n=zy.getDigitCount(e.toNumber()),a=new Jt(10).pow(n),i=e.div(a),s=n!==1?.05:.1,l=new Jt(Math.ceil(i.div(s).toNumber())).add(r).mul(s),d=l.mul(a);return t?d:new Jt(Math.ceil(d))}function kZ(e,t,r){var n=1,a=new Jt(e);if(!a.isint()&&r){var i=Math.abs(e);i<1?(n=new Jt(10).pow(zy.getDigitCount(e)-1),a=new Jt(Math.floor(a.div(n).toNumber())).mul(n)):i>1&&(a=new Jt(Math.floor(e)))}else e===0?a=new Jt(Math.floor((t-1)/2)):r||(a=new Jt(Math.floor(e)));var s=Math.floor((t-1)/2),l=xZ(vZ(function(d){return a.add(new Jt(d-s).mul(n)).toNumber()}),qj);return l(0,t)}function r5(e,t,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(r-1)))return{step:new Jt(0),tickMin:new Jt(0),tickMax:new Jt(0)};var i=t5(new Jt(t).sub(e).div(r-1),n,a),s;e<=0&&t>=0?s=new Jt(0):(s=new Jt(e).add(t).div(2),s=s.sub(new Jt(s).mod(i)));var l=Math.ceil(s.sub(e).div(i).toNumber()),d=Math.ceil(new Jt(t).sub(s).div(i).toNumber()),u=l+d+1;return u>r?r5(e,t,r,n,a+1):(u0?d+(r-u):d,l=t>0?l:l+(r-u)),{step:i,tickMin:s.sub(new Jt(l).mul(i)),tickMax:s.add(new Jt(d).mul(i))})}function AZ(e){var t=sf(e,2),r=t[0],n=t[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(a,2),l=e5([r,n]),d=sf(l,2),u=d[0],f=d[1];if(u===-1/0||f===1/0){var h=f===1/0?[u].concat(Wj(qj(0,a-1).map(function(){return 1/0}))):[].concat(Wj(qj(0,a-1).map(function(){return-1/0})),[f]);return r>n?Vj(h):h}if(u===f)return kZ(u,a,i);var p=r5(u,f,s,i),g=p.step,v=p.tickMin,b=p.tickMax,w=zy.rangeStep(v,b.add(new Jt(.1).mul(g)),g);return r>n?Vj(w):w}function IZ(e,t){var r=sf(e,2),n=r[0],a=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=e5([n,a]),l=sf(s,2),d=l[0],u=l[1];if(d===-1/0||u===1/0)return[n,a];if(d===u)return[d];var f=Math.max(t,2),h=t5(new Jt(u).sub(d).div(f-1),i,0),p=[].concat(Wj(zy.rangeStep(new Jt(d),new Jt(u).sub(new Jt(.99).mul(h)),h)),[u]);return n>a?Vj(p):p}var MZ=Q3(AZ),RZ=Q3(IZ),DZ="Invariant failed";function Hs(e,t){throw new Error(DZ)}var LZ=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function Dc(e){"@babel/helpers - typeof";return Dc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dc(e)}function wg(){return wg=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function VZ(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function WZ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function HZ(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=-1,l=(r=n?.length)!==null&&r!==void 0?r:0;if(l<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var d=i.range,u=0;u0?a[u-1].coordinate:a[l-1].coordinate,h=a[u].coordinate,p=u>=l-1?a[0].coordinate:a[u+1].coordinate,g=void 0;if(Sn(h-f)!==Sn(p-h)){var v=[];if(Sn(p-h)===Sn(d[1]-d[0])){g=p;var b=h+d[1]-d[0];v[0]=Math.min(b,(b+f)/2),v[1]=Math.max(b,(b+f)/2)}else{g=f;var w=p+d[1]-d[0];v[0]=Math.min(h,(w+h)/2),v[1]=Math.max(h,(w+h)/2)}var j=[Math.min(h,(g+h)/2),Math.max(h,(g+h)/2)];if(t>j[0]&&t<=j[1]||t>=v[0]&&t<=v[1]){s=a[u].index;break}}else{var N=Math.min(f,p),C=Math.max(f,p);if(t>(N+h)/2&&t<=(C+h)/2){s=a[u].index;break}}}else for(var O=0;O0&&O(n[O].coordinate+n[O-1].coordinate)/2&&t<=(n[O].coordinate+n[O+1].coordinate)/2||O===l-1&&t>(n[O].coordinate+n[O-1].coordinate)/2){s=n[O].index;break}return s},u_=function(t){var r,n=t,a=n.type.displayName,i=(r=t.type)!==null&&r!==void 0&&r.defaultProps?Nr(Nr({},t.type.defaultProps),t.props):t.props,s=i.stroke,l=i.fill,d;switch(a){case"Line":d=s;break;case"Area":case"Radar":d=s&&s!=="none"?s:l;break;default:d=l;break}return d},cee=function(t){var r=t.barSize,n=t.totalSize,a=t.stackGroups,i=a===void 0?{}:a;if(!i)return{};for(var s={},l=Object.keys(i),d=0,u=l.length;d=0});if(j&&j.length){var N=j[0].type.defaultProps,C=N!==void 0?Nr(Nr({},N),j[0].props):j[0].props,O=C.barSize,P=C[w];s[P]||(s[P]=[]);var E=gt(O)?r:O;s[P].push({item:j[0],stackList:j.slice(1),barSize:gt(E)?void 0:jn(E,n,0)})}}return s},uee=function(t){var r=t.barGap,n=t.barCategoryGap,a=t.bandSize,i=t.sizeList,s=i===void 0?[]:i,l=t.maxBarSize,d=s.length;if(d<1)return null;var u=jn(r,a,0,!0),f,h=[];if(s[0].barSize===+s[0].barSize){var p=!1,g=a/d,v=s.reduce(function(O,P){return O+P.barSize||0},0);v+=(d-1)*u,v>=a&&(v-=(d-1)*u,u=0),v>=a&&g>0&&(p=!0,g*=.9,v=d*g);var b=(a-v)/2>>0,w={offset:b-u,size:0};f=s.reduce(function(O,P){var E={item:P.item,position:{offset:w.offset+w.size+u,size:p?g:P.barSize}},T=[].concat(ZI(O),[E]);return w=T[T.length-1].position,P.stackList&&P.stackList.length&&P.stackList.forEach(function(A){T.push({item:A,position:w})}),T},h)}else{var j=jn(n,a,0,!0);a-2*j-(d-1)*u<=0&&(u=0);var N=(a-2*j-(d-1)*u)/d;N>1&&(N>>=0);var C=l===+l?Math.min(N,l):N;f=s.reduce(function(O,P,E){var T=[].concat(ZI(O),[{item:P.item,position:{offset:j+(N+u)*E+(N-C)/2,size:C}}]);return P.stackList&&P.stackList.length&&P.stackList.forEach(function(A){T.push({item:A,position:T[T.length-1].position})}),T},h)}return f},dee=function(t,r,n,a){var i=n.children,s=n.width,l=n.margin,d=s-(l.left||0)-(l.right||0),u=i5({children:i,legendWidth:d});if(u){var f=a||{},h=f.width,p=f.height,g=u.align,v=u.verticalAlign,b=u.layout;if((b==="vertical"||b==="horizontal"&&v==="middle")&&g!=="center"&&Re(t[g]))return Nr(Nr({},t),{},yc({},g,t[g]+(h||0)));if((b==="horizontal"||b==="vertical"&&g==="center")&&v!=="middle"&&Re(t[v]))return Nr(Nr({},t),{},yc({},v,t[v]+(p||0)))}return t},fee=function(t,r,n){return gt(r)?!0:t==="horizontal"?r==="yAxis":t==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},s5=function(t,r,n,a,i){var s=r.props.children,l=da(s,Wf).filter(function(u){return fee(a,i,u.props.direction)});if(l&&l.length){var d=l.map(function(u){return u.props.dataKey});return t.reduce(function(u,f){var h=Fr(f,n);if(gt(h))return u;var p=Array.isArray(h)?[Fy(h),$y(h)]:[h,h],g=d.reduce(function(v,b){var w=Fr(f,b,0),j=p[0]-Math.abs(Array.isArray(w)?w[0]:w),N=p[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(j,v[0]),Math.max(N,v[1])]},[1/0,-1/0]);return[Math.min(g[0],u[0]),Math.max(g[1],u[1])]},[1/0,-1/0])}return null},hee=function(t,r,n,a,i){var s=r.map(function(l){return s5(t,l,n,i,a)}).filter(function(l){return!gt(l)});return s&&s.length?s.reduce(function(l,d){return[Math.min(l[0],d[0]),Math.max(l[1],d[1])]},[1/0,-1/0]):null},l5=function(t,r,n,a,i){var s=r.map(function(d){var u=d.props.dataKey;return n==="number"&&u&&s5(t,d,u,a)||Bd(t,u,n,i)});if(n==="number")return s.reduce(function(d,u){return[Math.min(d[0],u[0]),Math.max(d[1],u[1])]},[1/0,-1/0]);var l={};return s.reduce(function(d,u){for(var f=0,h=u.length;f=2?Sn(l[0]-l[1])*2*u:u,r&&(t.ticks||t.niceTicks)){var f=(t.ticks||t.niceTicks).map(function(h){var p=i?i.indexOf(h):h;return{coordinate:a(p)+u,value:h,offset:u}});return f.filter(function(h){return!$f(h.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(h,p){return{coordinate:a(h)+u,value:h,index:p,offset:u}}):a.ticks&&!n?a.ticks(t.tickCount).map(function(h){return{coordinate:a(h)+u,value:h,offset:u}}):a.domain().map(function(h,p){return{coordinate:a(h)+u,value:i?i[h]:h,index:p,offset:u}})},rS=new WeakMap,Lm=function(t,r){if(typeof r!="function")return t;rS.has(t)||rS.set(t,new WeakMap);var n=rS.get(t);if(n.has(r))return n.get(r);var a=function(){t.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},d5=function(t,r,n){var a=t.scale,i=t.type,s=t.layout,l=t.axisType;if(a==="auto")return s==="radial"&&l==="radiusAxis"?{scale:ef(),realScaleType:"band"}:s==="radial"&&l==="angleAxis"?{scale:gg(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:Fd(),realScaleType:"point"}:i==="category"?{scale:ef(),realScaleType:"band"}:{scale:gg(),realScaleType:"linear"};if(Us(a)){var d="scale".concat(jy(a));return{scale:(FI[d]||Fd)(),realScaleType:FI[d]?d:"point"}}return ht(a)?{scale:a}:{scale:Fd(),realScaleType:"point"}},tM=1e-4,f5=function(t){var r=t.domain();if(!(!r||r.length<=2)){var n=r.length,a=t.range(),i=Math.min(a[0],a[1])-tM,s=Math.max(a[0],a[1])+tM,l=t(r[0]),d=t(r[n-1]);(ls||ds)&&t.domain([r[0],r[n-1]])}},mee=function(t,r){if(!t)return null;for(var n=0,a=t.length;na)&&(i[1]=a),i[0]>a&&(i[0]=a),i[1]=0?(t[l][n][0]=i,t[l][n][1]=i+d,i=t[l][n][1]):(t[l][n][0]=s,t[l][n][1]=s+d,s=t[l][n][1])}},yee=function(t){var r=t.length;if(!(r<=0))for(var n=0,a=t[0].length;n=0?(t[s][n][0]=i,t[s][n][1]=i+l,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},vee={sign:gee,expand:oG,none:Pc,silhouette:iG,wiggle:sG,positive:yee},xee=function(t,r,n){var a=r.map(function(l){return l.props.dataKey}),i=vee[n],s=aG().keys(a).value(function(l,d){return+Fr(l,d,0)}).order(Nj).offset(i);return s(t)},bee=function(t,r,n,a,i,s){if(!t)return null;var l=s?r.reverse():r,d={},u=l.reduce(function(h,p){var g,v=(g=p.type)!==null&&g!==void 0&&g.defaultProps?Nr(Nr({},p.type.defaultProps),p.props):p.props,b=v.stackId,w=v.hide;if(w)return h;var j=v[n],N=h[j]||{hasStack:!1,stackGroups:{}};if(Br(b)){var C=N.stackGroups[b]||{numericAxisId:n,cateAxisId:a,items:[]};C.items.push(p),N.hasStack=!0,N.stackGroups[b]=C}else N.stackGroups[hu("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[p]};return Nr(Nr({},h),{},yc({},j,N))},d),f={};return Object.keys(u).reduce(function(h,p){var g=u[p];if(g.hasStack){var v={};g.stackGroups=Object.keys(g.stackGroups).reduce(function(b,w){var j=g.stackGroups[w];return Nr(Nr({},b),{},yc({},w,{numericAxisId:n,cateAxisId:a,items:j.items,stackedData:xee(t,j.items,i)}))},v)}return Nr(Nr({},h),{},yc({},p,g))},f)},h5=function(t,r){var n=r.realScaleType,a=r.type,i=r.tickCount,s=r.originalDomain,l=r.allowDecimals,d=n||r.scale;if(d!=="auto"&&d!=="linear")return null;if(i&&a==="number"&&s&&(s[0]==="auto"||s[1]==="auto")){var u=t.domain();if(!u.length)return null;var f=MZ(u,i,l);return t.domain([Fy(f),$y(f)]),{niceTicks:f}}if(i&&a==="number"){var h=t.domain(),p=RZ(h,i,l);return{niceTicks:p}}return null};function rM(e){var t=e.axis,r=e.ticks,n=e.bandSize,a=e.entry,i=e.index,s=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!gt(a[t.dataKey])){var l=Xp(r,"value",a[t.dataKey]);if(l)return l.coordinate+n/2}return r[i]?r[i].coordinate+n/2:null}var d=Fr(a,gt(s)?t.dataKey:s);return gt(d)?null:t.scale(d)}var nM=function(t){var r=t.axis,n=t.ticks,a=t.offset,i=t.bandSize,s=t.entry,l=t.index;if(r.type==="category")return n[l]?n[l].coordinate+a:null;var d=Fr(s,r.dataKey,r.domain[l]);return gt(d)?null:r.scale(d)-i/2+a},wee=function(t){var r=t.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return a<=0&&i>=0?0:i<0?i:a}return n[0]},See=function(t,r){var n,a=(n=t.type)!==null&&n!==void 0&&n.defaultProps?Nr(Nr({},t.type.defaultProps),t.props):t.props,i=a.stackId;if(Br(i)){var s=r[i];if(s){var l=s.items.indexOf(t);return l>=0?s.stackedData[l]:null}}return null},jee=function(t){return t.reduce(function(r,n){return[Fy(n.concat([r[0]]).filter(Re)),$y(n.concat([r[1]]).filter(Re))]},[1/0,-1/0])},m5=function(t,r,n){return Object.keys(t).reduce(function(a,i){var s=t[i],l=s.stackedData,d=l.reduce(function(u,f){var h=jee(f.slice(r,n+1));return[Math.min(u[0],h[0]),Math.max(u[1],h[1])]},[1/0,-1/0]);return[Math.min(d[0],a[0]),Math.max(d[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},aM=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,oM=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Kj=function(t,r,n){if(ht(t))return t(r,n);if(!Array.isArray(t))return r;var a=[];if(Re(t[0]))a[0]=n?t[0]:Math.min(t[0],r[0]);else if(aM.test(t[0])){var i=+aM.exec(t[0])[1];a[0]=r[0]-i}else ht(t[0])?a[0]=t[0](r[0]):a[0]=r[0];if(Re(t[1]))a[1]=n?t[1]:Math.max(t[1],r[1]);else if(oM.test(t[1])){var s=+oM.exec(t[1])[1];a[1]=r[1]+s}else ht(t[1])?a[1]=t[1](r[1]):a[1]=r[1];return a},jg=function(t,r,n){if(t&&t.scale&&t.scale.bandwidth){var a=t.scale.bandwidth();if(!n||a>0)return a}if(t&&r&&r.length>=2){for(var i=$C(r,function(h){return h.coordinate}),s=1/0,l=1,d=i.length;le.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},Aee=function(t,r,n,a,i){var s=t.width,l=t.height,d=t.startAngle,u=t.endAngle,f=jn(t.cx,s,s/2),h=jn(t.cy,l,l/2),p=y5(s,l,n),g=jn(t.innerRadius,p,0),v=jn(t.outerRadius,p,p*.8),b=Object.keys(r);return b.reduce(function(w,j){var N=r[j],C=N.domain,O=N.reversed,P;if(gt(N.range))a==="angleAxis"?P=[d,u]:a==="radiusAxis"&&(P=[g,v]),O&&(P=[P[1],P[0]]);else{P=N.range;var E=P,T=_ee(E,2);d=T[0],u=T[1]}var A=d5(N,i),M=A.realScaleType,R=A.scale;R.domain(C).range(P),f5(R);var L=h5(R,Ho(Ho({},N),{},{realScaleType:M})),V=Ho(Ho(Ho({},N),L),{},{range:P,radius:v,realScaleType:M,scale:R,cx:f,cy:h,innerRadius:g,outerRadius:v,startAngle:d,endAngle:u});return Ho(Ho({},w),{},g5({},j,V))},{})},Iee=function(t,r){var n=t.x,a=t.y,i=r.x,s=r.y;return Math.sqrt(Math.pow(n-i,2)+Math.pow(a-s,2))},Mee=function(t,r){var n=t.x,a=t.y,i=r.cx,s=r.cy,l=Iee({x:n,y:a},{x:i,y:s});if(l<=0)return{radius:l};var d=(n-i)/l,u=Math.acos(d);return a>s&&(u=2*Math.PI-u),{radius:l,angle:kee(u),angleInRadian:u}},Ree=function(t){var r=t.startAngle,n=t.endAngle,a=Math.floor(r/360),i=Math.floor(n/360),s=Math.min(a,i);return{startAngle:r-s*360,endAngle:n-s*360}},Dee=function(t,r){var n=r.startAngle,a=r.endAngle,i=Math.floor(n/360),s=Math.floor(a/360),l=Math.min(i,s);return t+l*360},cM=function(t,r){var n=t.x,a=t.y,i=Mee({x:n,y:a},r),s=i.radius,l=i.angle,d=r.innerRadius,u=r.outerRadius;if(su)return!1;if(s===0)return!0;var f=Ree(r),h=f.startAngle,p=f.endAngle,g=l,v;if(h<=p){for(;g>p;)g-=360;for(;g=h&&g<=p}else{for(;g>h;)g-=360;for(;g=p&&g<=h}return v?Ho(Ho({},r),{},{radius:s,angle:Dee(g,r)}):null},v5=function(t){return!x.isValidElement(t)&&!ht(t)&&typeof t!="boolean"?t.className:""};function df(e){"@babel/helpers - typeof";return df=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},df(e)}var Lee=["offset"];function $ee(e){return Uee(e)||zee(e)||Bee(e)||Fee()}function Fee(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bee(e,t){if(e){if(typeof e=="string")return Xj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xj(e,t)}}function zee(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Uee(e){if(Array.isArray(e))return Xj(e)}function Xj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Vee(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function uM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function $r(e){for(var t=1;t=0?1:-1,C,O;a==="insideStart"?(C=g+N*s,O=b):a==="insideEnd"?(C=v-N*s,O=!b):a==="end"&&(C=v+N*s,O=b),O=j<=0?O:!O;var P=or(u,f,w,C),E=or(u,f,w,C+(O?1:-1)*359),T="M".concat(P.x,",").concat(P.y,` - A`).concat(w,",").concat(w,",0,1,").concat(O?0:1,`, - `).concat(E.x,",").concat(E.y),A=gt(t.id)?hu("recharts-radial-line-"):t.id;return U.createElement("text",ff({},n,{dominantBaseline:"central",className:yt("recharts-radial-bar-label",l)}),U.createElement("defs",null,U.createElement("path",{id:A,d:T})),U.createElement("textPath",{xlinkHref:"#".concat(A)},r))},Jee=function(t){var r=t.viewBox,n=t.offset,a=t.position,i=r,s=i.cx,l=i.cy,d=i.innerRadius,u=i.outerRadius,f=i.startAngle,h=i.endAngle,p=(f+h)/2;if(a==="outside"){var g=or(s,l,u+n,p),v=g.x,b=g.y;return{x:v,y:b,textAnchor:v>=s?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:s,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:s,y:l,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:s,y:l,textAnchor:"middle",verticalAnchor:"end"};var w=(d+u)/2,j=or(s,l,w,p),N=j.x,C=j.y;return{x:N,y:C,textAnchor:"middle",verticalAnchor:"middle"}},Qee=function(t){var r=t.viewBox,n=t.parentViewBox,a=t.offset,i=t.position,s=r,l=s.x,d=s.y,u=s.width,f=s.height,h=f>=0?1:-1,p=h*a,g=h>0?"end":"start",v=h>0?"start":"end",b=u>=0?1:-1,w=b*a,j=b>0?"end":"start",N=b>0?"start":"end";if(i==="top"){var C={x:l+u/2,y:d-h*a,textAnchor:"middle",verticalAnchor:g};return $r($r({},C),n?{height:Math.max(d-n.y,0),width:u}:{})}if(i==="bottom"){var O={x:l+u/2,y:d+f+p,textAnchor:"middle",verticalAnchor:v};return $r($r({},O),n?{height:Math.max(n.y+n.height-(d+f),0),width:u}:{})}if(i==="left"){var P={x:l-w,y:d+f/2,textAnchor:j,verticalAnchor:"middle"};return $r($r({},P),n?{width:Math.max(P.x-n.x,0),height:f}:{})}if(i==="right"){var E={x:l+u+w,y:d+f/2,textAnchor:N,verticalAnchor:"middle"};return $r($r({},E),n?{width:Math.max(n.x+n.width-E.x,0),height:f}:{})}var T=n?{width:u,height:f}:{};return i==="insideLeft"?$r({x:l+w,y:d+f/2,textAnchor:N,verticalAnchor:"middle"},T):i==="insideRight"?$r({x:l+u-w,y:d+f/2,textAnchor:j,verticalAnchor:"middle"},T):i==="insideTop"?$r({x:l+u/2,y:d+p,textAnchor:"middle",verticalAnchor:v},T):i==="insideBottom"?$r({x:l+u/2,y:d+f-p,textAnchor:"middle",verticalAnchor:g},T):i==="insideTopLeft"?$r({x:l+w,y:d+p,textAnchor:N,verticalAnchor:v},T):i==="insideTopRight"?$r({x:l+u-w,y:d+p,textAnchor:j,verticalAnchor:v},T):i==="insideBottomLeft"?$r({x:l+w,y:d+f-p,textAnchor:N,verticalAnchor:g},T):i==="insideBottomRight"?$r({x:l+u-w,y:d+f-p,textAnchor:j,verticalAnchor:g},T):fu(i)&&(Re(i.x)||Is(i.x))&&(Re(i.y)||Is(i.y))?$r({x:l+jn(i.x,u),y:d+jn(i.y,f),textAnchor:"end",verticalAnchor:"end"},T):$r({x:l+u/2,y:d+f/2,textAnchor:"middle",verticalAnchor:"middle"},T)},Zee=function(t){return"cx"in t&&Re(t.cx)};function Gr(e){var t=e.offset,r=t===void 0?5:t,n=qee(e,Lee),a=$r({offset:r},n),i=a.viewBox,s=a.position,l=a.value,d=a.children,u=a.content,f=a.className,h=f===void 0?"":f,p=a.textBreakAll;if(!i||gt(l)&>(d)&&!x.isValidElement(u)&&!ht(u))return null;if(x.isValidElement(u))return x.cloneElement(u,a);var g;if(ht(u)){if(g=x.createElement(u,a),x.isValidElement(g))return g}else g=Yee(a);var v=Zee(i),b=st(a,!0);if(v&&(s==="insideStart"||s==="insideEnd"||s==="end"))return Xee(a,g,b);var w=v?Jee(a):Qee(a);return U.createElement(Vs,ff({className:yt("recharts-label",h)},b,w,{breakAll:p}),g)}Gr.displayName="Label";var x5=function(t){var r=t.cx,n=t.cy,a=t.angle,i=t.startAngle,s=t.endAngle,l=t.r,d=t.radius,u=t.innerRadius,f=t.outerRadius,h=t.x,p=t.y,g=t.top,v=t.left,b=t.width,w=t.height,j=t.clockWise,N=t.labelViewBox;if(N)return N;if(Re(b)&&Re(w)){if(Re(h)&&Re(p))return{x:h,y:p,width:b,height:w};if(Re(g)&&Re(v))return{x:g,y:v,width:b,height:w}}return Re(h)&&Re(p)?{x:h,y:p,width:0,height:0}:Re(r)&&Re(n)?{cx:r,cy:n,startAngle:i||a||0,endAngle:s||a||0,innerRadius:u||0,outerRadius:f||d||l||0,clockWise:j}:t.viewBox?t.viewBox:{}},ete=function(t,r){return t?t===!0?U.createElement(Gr,{key:"label-implicit",viewBox:r}):Br(t)?U.createElement(Gr,{key:"label-implicit",viewBox:r,value:t}):x.isValidElement(t)?t.type===Gr?x.cloneElement(t,{key:"label-implicit",viewBox:r}):U.createElement(Gr,{key:"label-implicit",content:t,viewBox:r}):ht(t)?U.createElement(Gr,{key:"label-implicit",content:t,viewBox:r}):fu(t)?U.createElement(Gr,ff({viewBox:r},t,{key:"label-implicit"})):null:null},tte=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&n&&!t.label)return null;var a=t.children,i=x5(t),s=da(a,Gr).map(function(d,u){return x.cloneElement(d,{viewBox:r||i,key:"label-".concat(u)})});if(!n)return s;var l=ete(t.label,r||i);return[l].concat($ee(s))};Gr.parseViewBox=x5;Gr.renderCallByParent=tte;var nS,dM;function rte(){if(dM)return nS;dM=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return nS=e,nS}var nte=rte();const ate=Vt(nte);function hf(e){"@babel/helpers - typeof";return hf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hf(e)}var ote=["valueAccessor"],ite=["data","dataKey","clockWise","id","textBreakAll"];function ste(e){return dte(e)||ute(e)||cte(e)||lte()}function lte(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cte(e,t){if(e){if(typeof e=="string")return Jj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Jj(e,t)}}function ute(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function dte(e){if(Array.isArray(e))return Jj(e)}function Jj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function pte(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var gte=function(t){return Array.isArray(t.value)?ate(t.value):t.value};function ei(e){var t=e.valueAccessor,r=t===void 0?gte:t,n=mM(e,ote),a=n.data,i=n.dataKey,s=n.clockWise,l=n.id,d=n.textBreakAll,u=mM(n,ite);return!a||!a.length?null:U.createElement(Bt,{className:"recharts-label-list"},a.map(function(f,h){var p=gt(i)?r(f,h):Fr(f&&f.payload,i),g=gt(l)?{}:{id:"".concat(l,"-").concat(h)};return U.createElement(Gr,Cg({},st(f,!0),u,g,{parentViewBox:f.parentViewBox,value:p,textBreakAll:d,viewBox:Gr.parseViewBox(gt(s)?f:hM(hM({},f),{},{clockWise:s})),key:"label-".concat(h),index:h}))}))}ei.displayName="LabelList";function yte(e,t){return e?e===!0?U.createElement(ei,{key:"labelList-implicit",data:t}):U.isValidElement(e)||ht(e)?U.createElement(ei,{key:"labelList-implicit",data:t,content:e}):fu(e)?U.createElement(ei,Cg({data:t},e,{key:"labelList-implicit"})):null:null}function vte(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var n=e.children,a=da(n,ei).map(function(s,l){return x.cloneElement(s,{data:t,key:"labelList-".concat(l)})});if(!r)return a;var i=yte(e.label,t);return[i].concat(ste(a))}ei.renderCallByParent=vte;function mf(e){"@babel/helpers - typeof";return mf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mf(e)}function Qj(){return Qj=Object.assign?Object.assign.bind():function(e){for(var t=1;t180),",").concat(+(s>u),`, - `).concat(h.x,",").concat(h.y,` - `);if(a>0){var g=or(r,n,a,s),v=or(r,n,a,u);p+="L ".concat(v.x,",").concat(v.y,` - A `).concat(a,",").concat(a,`,0, - `).concat(+(Math.abs(d)>180),",").concat(+(s<=u),`, - `).concat(g.x,",").concat(g.y," Z")}else p+="L ".concat(r,",").concat(n," Z");return p},jte=function(t){var r=t.cx,n=t.cy,a=t.innerRadius,i=t.outerRadius,s=t.cornerRadius,l=t.forceCornerRadius,d=t.cornerIsExternal,u=t.startAngle,f=t.endAngle,h=Sn(f-u),p=$m({cx:r,cy:n,radius:i,angle:u,sign:h,cornerRadius:s,cornerIsExternal:d}),g=p.circleTangency,v=p.lineTangency,b=p.theta,w=$m({cx:r,cy:n,radius:i,angle:f,sign:-h,cornerRadius:s,cornerIsExternal:d}),j=w.circleTangency,N=w.lineTangency,C=w.theta,O=d?Math.abs(u-f):Math.abs(u-f)-b-C;if(O<0)return l?"M ".concat(v.x,",").concat(v.y,` - a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0 - a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0 - `):b5({cx:r,cy:n,innerRadius:a,outerRadius:i,startAngle:u,endAngle:f});var P="M ".concat(v.x,",").concat(v.y,` - A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(g.x,",").concat(g.y,` - A`).concat(i,",").concat(i,",0,").concat(+(O>180),",").concat(+(h<0),",").concat(j.x,",").concat(j.y,` - A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(N.x,",").concat(N.y,` - `);if(a>0){var E=$m({cx:r,cy:n,radius:a,angle:u,sign:h,isExternal:!0,cornerRadius:s,cornerIsExternal:d}),T=E.circleTangency,A=E.lineTangency,M=E.theta,R=$m({cx:r,cy:n,radius:a,angle:f,sign:-h,isExternal:!0,cornerRadius:s,cornerIsExternal:d}),L=R.circleTangency,V=R.lineTangency,z=R.theta,G=d?Math.abs(u-f):Math.abs(u-f)-M-z;if(G<0&&s===0)return"".concat(P,"L").concat(r,",").concat(n,"Z");P+="L".concat(V.x,",").concat(V.y,` - A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(L.x,",").concat(L.y,` - A`).concat(a,",").concat(a,",0,").concat(+(G>180),",").concat(+(h>0),",").concat(T.x,",").concat(T.y,` - A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(A.x,",").concat(A.y,"Z")}else P+="L".concat(r,",").concat(n,"Z");return P},Nte={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},w5=function(t){var r=gM(gM({},Nte),t),n=r.cx,a=r.cy,i=r.innerRadius,s=r.outerRadius,l=r.cornerRadius,d=r.forceCornerRadius,u=r.cornerIsExternal,f=r.startAngle,h=r.endAngle,p=r.className;if(s0&&Math.abs(f-h)<360?w=jte({cx:n,cy:a,innerRadius:i,outerRadius:s,cornerRadius:Math.min(b,v/2),forceCornerRadius:d,cornerIsExternal:u,startAngle:f,endAngle:h}):w=b5({cx:n,cy:a,innerRadius:i,outerRadius:s,startAngle:f,endAngle:h}),U.createElement("path",Qj({},st(r,!0),{className:g,d:w,role:"img"}))};function pf(e){"@babel/helpers - typeof";return pf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pf(e)}function Zj(){return Zj=Object.assign?Object.assign.bind():function(e){for(var t=1;tDte.call(e,t));function cl(e,t){return e===t||!e&&!t&&e!==e&&t!==t}const Fte="__v",Bte="__o",zte="_owner",{getOwnPropertyDescriptor:NM,keys:CM}=Object;function Ute(e,t){return e.byteLength===t.byteLength&&Eg(new Uint8Array(e),new Uint8Array(t))}function qte(e,t,r){let n=e.length;if(t.length!==n)return!1;for(;n-- >0;)if(!r.equals(e[n],t[n],n,n,e,t,r))return!1;return!0}function Vte(e,t){return e.byteLength===t.byteLength&&Eg(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Wte(e,t){return cl(e.getTime(),t.getTime())}function Hte(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Gte(e,t){return e===t}function _M(e,t,r){const n=e.size;if(n!==t.size)return!1;if(!n)return!0;const a=new Array(n),i=e.entries();let s,l,d=0;for(;(s=i.next())&&!s.done;){const u=t.entries();let f=!1,h=0;for(;(l=u.next())&&!l.done;){if(a[h]){h++;continue}const p=s.value,g=l.value;if(r.equals(p[0],g[0],d,h,e,t,r)&&r.equals(p[1],g[1],p[0],g[0],e,t,r)){f=a[h]=!0;break}h++}if(!f)return!1;d++}return!0}const Yte=cl;function Kte(e,t,r){const n=CM(e);let a=n.length;if(CM(t).length!==a)return!1;for(;a-- >0;)if(!S5(e,t,r,n[a]))return!1;return!0}function wd(e,t,r){const n=jM(e);let a=n.length;if(jM(t).length!==a)return!1;let i,s,l;for(;a-- >0;)if(i=n[a],!S5(e,t,r,i)||(s=NM(e,i),l=NM(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function Xte(e,t){return cl(e.valueOf(),t.valueOf())}function Jte(e,t){return e.source===t.source&&e.flags===t.flags}function EM(e,t,r){const n=e.size;if(n!==t.size)return!1;if(!n)return!0;const a=new Array(n),i=e.values();let s,l;for(;(s=i.next())&&!s.done;){const d=t.values();let u=!1,f=0;for(;(l=d.next())&&!l.done;){if(!a[f]&&r.equals(s.value,l.value,s.value,l.value,e,t,r)){u=a[f]=!0;break}f++}if(!u)return!1}return!0}function Eg(e,t){let r=e.byteLength;if(t.byteLength!==r||e.byteOffset!==t.byteOffset)return!1;for(;r-- >0;)if(e[r]!==t[r])return!1;return!0}function Qte(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function S5(e,t,r,n){return(n===zte||n===Bte||n===Fte)&&(e.$$typeof||t.$$typeof)?!0:$te(t,n)&&r.equals(e[n],t[n],n,n,e,t,r)}const Zte="[object ArrayBuffer]",ere="[object Arguments]",tre="[object Boolean]",rre="[object DataView]",nre="[object Date]",are="[object Error]",ore="[object Map]",ire="[object Number]",sre="[object Object]",lre="[object RegExp]",cre="[object Set]",ure="[object String]",dre={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},fre="[object URL]",hre=Object.prototype.toString;function mre({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:d,arePrimitiveWrappersEqual:u,areRegExpsEqual:f,areSetsEqual:h,areTypedArraysEqual:p,areUrlsEqual:g,unknownTagComparators:v}){return function(w,j,N){if(w===j)return!0;if(w==null||j==null)return!1;const C=typeof w;if(C!==typeof j)return!1;if(C!=="object")return C==="number"?l(w,j,N):C==="function"?i(w,j,N):!1;const O=w.constructor;if(O!==j.constructor)return!1;if(O===Object)return d(w,j,N);if(Array.isArray(w))return t(w,j,N);if(O===Date)return n(w,j,N);if(O===RegExp)return f(w,j,N);if(O===Map)return s(w,j,N);if(O===Set)return h(w,j,N);const P=hre.call(w);if(P===nre)return n(w,j,N);if(P===lre)return f(w,j,N);if(P===ore)return s(w,j,N);if(P===cre)return h(w,j,N);if(P===sre)return typeof w.then!="function"&&typeof j.then!="function"&&d(w,j,N);if(P===fre)return g(w,j,N);if(P===are)return a(w,j,N);if(P===ere)return d(w,j,N);if(dre[P])return p(w,j,N);if(P===Zte)return e(w,j,N);if(P===rre)return r(w,j,N);if(P===tre||P===ire||P===ure)return u(w,j,N);if(v){let E=v[P];if(!E){const T=Lte(w);T&&(E=v[T])}if(E)return E(w,j,N)}return!1}}function pre({circular:e,createCustomConfig:t,strict:r}){let n={areArrayBuffersEqual:Ute,areArraysEqual:r?wd:qte,areDataViewsEqual:Vte,areDatesEqual:Wte,areErrorsEqual:Hte,areFunctionsEqual:Gte,areMapsEqual:r?sS(_M,wd):_M,areNumbersEqual:Yte,areObjectsEqual:r?wd:Kte,arePrimitiveWrappersEqual:Xte,areRegExpsEqual:Jte,areSetsEqual:r?sS(EM,wd):EM,areTypedArraysEqual:r?sS(Eg,wd):Eg,areUrlsEqual:Qte,unknownTagComparators:void 0};if(t&&(n=Object.assign({},n,t(n))),e){const a=Bm(n.areArraysEqual),i=Bm(n.areMapsEqual),s=Bm(n.areObjectsEqual),l=Bm(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:s,areSetsEqual:l})}return n}function gre(e){return function(t,r,n,a,i,s,l){return e(t,r,l)}}function yre({circular:e,comparator:t,createState:r,equals:n,strict:a}){if(r)return function(l,d){const{cache:u=e?new WeakMap:void 0,meta:f}=r();return t(l,d,{cache:u,equals:n,meta:f,strict:a})};if(e)return function(l,d){return t(l,d,{cache:new WeakMap,equals:n,meta:void 0,strict:a})};const i={cache:void 0,equals:n,meta:void 0,strict:a};return function(l,d){return t(l,d,i)}}const vre=Ki();Ki({strict:!0});Ki({circular:!0});Ki({circular:!0,strict:!0});Ki({createInternalComparator:()=>cl});Ki({strict:!0,createInternalComparator:()=>cl});Ki({circular:!0,createInternalComparator:()=>cl});Ki({circular:!0,createInternalComparator:()=>cl,strict:!0});function Ki(e={}){const{circular:t=!1,createInternalComparator:r,createState:n,strict:a=!1}=e,i=pre(e),s=mre(i),l=r?r(s):gre(s);return yre({circular:t,comparator:s,createState:n,equals:l,strict:a})}function xre(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function PM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(i){r<0&&(r=i),i-r>t?(e(i),r=-1):xre(a)};requestAnimationFrame(n)}function eN(e){"@babel/helpers - typeof";return eN=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},eN(e)}function bre(e){return Nre(e)||jre(e)||Sre(e)||wre()}function wre(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sre(e,t){if(e){if(typeof e=="string")return OM(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return OM(e,t)}}function OM(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1?1:j<0?0:j},b=function(j){for(var N=j>1?1:j,C=N,O=0;O<8;++O){var P=h(C)-N,E=g(C);if(Math.abs(P-N)0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,n=r===void 0?100:r,a=t.damping,i=a===void 0?8:a,s=t.dt,l=s===void 0?17:s,d=function(f,h,p){var g=-(f-h)*n,v=p*i,b=p+(g-v)*l/1e3,w=p*l/1e3+f;return Math.abs(w-h)e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function tne(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,i;for(i=0;i=0)&&(r[a]=e[a]);return r}function lS(e){return one(e)||ane(e)||nne(e)||rne()}function rne(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nne(e,t){if(e){if(typeof e=="string")return oN(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return oN(e,t)}}function ane(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function one(e){if(Array.isArray(e))return oN(e)}function oN(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Tg(e){return Tg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Tg(e)}var So=(function(e){une(r,e);var t=dne(r);function r(n,a){var i;ine(this,r),i=t.call(this,n,a);var s=i.props,l=s.isActive,d=s.attributeName,u=s.from,f=s.to,h=s.steps,p=s.children,g=s.duration;if(i.handleStyleChange=i.handleStyleChange.bind(lN(i)),i.changeStyle=i.changeStyle.bind(lN(i)),!l||g<=0)return i.state={style:{}},typeof p=="function"&&(i.state={style:f}),sN(i);if(h&&h.length)i.state={style:h[0].style};else if(u){if(typeof p=="function")return i.state={style:u},sN(i);i.state={style:d?Dd({},d,u):u}}else i.state={style:{}};return i}return lne(r,[{key:"componentDidMount",value:function(){var a=this.props,i=a.isActive,s=a.canBegin;this.mounted=!0,!(!i||!s)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var i=this.props,s=i.isActive,l=i.canBegin,d=i.attributeName,u=i.shouldReAnimate,f=i.to,h=i.from,p=this.state.style;if(l){if(!s){var g={style:d?Dd({},d,f):f};this.state&&p&&(d&&p[d]!==f||!d&&p!==f)&&this.setState(g);return}if(!(vre(a.to,f)&&a.canBegin&&a.isActive)){var v=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var b=v||u?h:a.to;if(this.state&&p){var w={style:d?Dd({},d,b):b};(d&&p[d]!==b||!d&&p!==b)&&this.setState(w)}this.runAnimation(Ua(Ua({},this.props),{},{from:b,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var i=this,s=a.from,l=a.to,d=a.duration,u=a.easing,f=a.begin,h=a.onAnimationEnd,p=a.onAnimationStart,g=Qre(s,l,zre(u),d,this.changeStyle),v=function(){i.stopJSAnimation=g()};this.manager.start([p,f,v,d,h])}},{key:"runStepAnimation",value:function(a){var i=this,s=a.steps,l=a.begin,d=a.onAnimationStart,u=s[0],f=u.style,h=u.duration,p=h===void 0?0:h,g=function(b,w,j){if(j===0)return b;var N=w.duration,C=w.easing,O=C===void 0?"ease":C,P=w.style,E=w.properties,T=w.onAnimationEnd,A=j>0?s[j-1]:w,M=E||Object.keys(P);if(typeof O=="function"||O==="spring")return[].concat(lS(b),[i.runJSAnimation.bind(i,{from:A.style,to:P,duration:N,easing:O}),N]);var R=AM(M,N,O),L=Ua(Ua(Ua({},A.style),P),{},{transition:R});return[].concat(lS(b),[L,N,T]).filter(Ore)};return this.manager.start([d].concat(lS(s.reduce(g,[f,Math.max(p,l)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Cre());var i=a.begin,s=a.duration,l=a.attributeName,d=a.to,u=a.easing,f=a.onAnimationStart,h=a.onAnimationEnd,p=a.steps,g=a.children,v=this.manager;if(this.unSubscribe=v.subscribe(this.handleStyleChange),typeof u=="function"||typeof g=="function"||u==="spring"){this.runJSAnimation(a);return}if(p.length>1){this.runStepAnimation(a);return}var b=l?Dd({},l,d):d,w=AM(Object.keys(b),s,u);v.start([f,i,Ua(Ua({},b),{},{transition:w}),s,h])}},{key:"render",value:function(){var a=this.props,i=a.children;a.begin;var s=a.duration;a.attributeName,a.easing;var l=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var d=ene(a,Zre),u=x.Children.count(i),f=this.state.style;if(typeof i=="function")return i(f);if(!l||u===0||s<=0)return i;var h=function(g){var v=g.props,b=v.style,w=b===void 0?{}:b,j=v.className,N=x.cloneElement(g,Ua(Ua({},d),{},{style:Ua(Ua({},w),f),className:j}));return N};return u===1?h(x.Children.only(i)):U.createElement("div",null,x.Children.map(i,function(p){return h(p)}))}}]),r})(x.PureComponent);So.displayName="Animate";So.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};So.propTypes={from:Gt.oneOfType([Gt.object,Gt.string]),to:Gt.oneOfType([Gt.object,Gt.string]),attributeName:Gt.string,duration:Gt.number,begin:Gt.number,easing:Gt.oneOfType([Gt.string,Gt.func]),steps:Gt.arrayOf(Gt.shape({duration:Gt.number.isRequired,style:Gt.object.isRequired,easing:Gt.oneOfType([Gt.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Gt.func]),properties:Gt.arrayOf("string"),onAnimationEnd:Gt.func})),children:Gt.oneOfType([Gt.node,Gt.func]),isActive:Gt.bool,canBegin:Gt.bool,onAnimationEnd:Gt.func,shouldReAnimate:Gt.bool,onAnimationStart:Gt.func,onAnimationReStart:Gt.func};function vf(e){"@babel/helpers - typeof";return vf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vf(e)}function kg(){return kg=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0?1:-1,d=n>=0?1:-1,u=a>=0&&n>=0||a<0&&n<0?1:0,f;if(s>0&&i instanceof Array){for(var h=[0,0,0,0],p=0,g=4;ps?s:i[p];f="M".concat(t,",").concat(r+l*h[0]),h[0]>0&&(f+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(u,",").concat(t+d*h[0],",").concat(r)),f+="L ".concat(t+n-d*h[1],",").concat(r),h[1]>0&&(f+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(u,`, - `).concat(t+n,",").concat(r+l*h[1])),f+="L ".concat(t+n,",").concat(r+a-l*h[2]),h[2]>0&&(f+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(u,`, - `).concat(t+n-d*h[2],",").concat(r+a)),f+="L ".concat(t+d*h[3],",").concat(r+a),h[3]>0&&(f+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(u,`, - `).concat(t,",").concat(r+a-l*h[3])),f+="Z"}else if(s>0&&i===+i&&i>0){var v=Math.min(s,i);f="M ".concat(t,",").concat(r+l*v,` - A `).concat(v,",").concat(v,",0,0,").concat(u,",").concat(t+d*v,",").concat(r,` - L `).concat(t+n-d*v,",").concat(r,` - A `).concat(v,",").concat(v,",0,0,").concat(u,",").concat(t+n,",").concat(r+l*v,` - L `).concat(t+n,",").concat(r+a-l*v,` - A `).concat(v,",").concat(v,",0,0,").concat(u,",").concat(t+n-d*v,",").concat(r+a,` - L `).concat(t+d*v,",").concat(r+a,` - A `).concat(v,",").concat(v,",0,0,").concat(u,",").concat(t,",").concat(r+a-l*v," Z")}else f="M ".concat(t,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return f},wne=function(t,r){if(!t||!r)return!1;var n=t.x,a=t.y,i=r.x,s=r.y,l=r.width,d=r.height;if(Math.abs(l)>0&&Math.abs(d)>0){var u=Math.min(i,i+l),f=Math.max(i,i+l),h=Math.min(s,s+d),p=Math.max(s,s+d);return n>=u&&n<=f&&a>=h&&a<=p}return!1},Sne={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},d_=function(t){var r=BM(BM({},Sne),t),n=x.useRef(),a=x.useState(-1),i=hne(a,2),s=i[0],l=i[1];x.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var O=n.current.getTotalLength();O&&l(O)}catch{}},[]);var d=r.x,u=r.y,f=r.width,h=r.height,p=r.radius,g=r.className,v=r.animationEasing,b=r.animationDuration,w=r.animationBegin,j=r.isAnimationActive,N=r.isUpdateAnimationActive;if(d!==+d||u!==+u||f!==+f||h!==+h||f===0||h===0)return null;var C=yt("recharts-rectangle",g);return N?U.createElement(So,{canBegin:s>0,from:{width:f,height:h,x:d,y:u},to:{width:f,height:h,x:d,y:u},duration:b,animationEasing:v,isActive:N},function(O){var P=O.width,E=O.height,T=O.x,A=O.y;return U.createElement(So,{canBegin:s>0,from:"0px ".concat(s===-1?1:s,"px"),to:"".concat(s,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:b,isActive:j,easing:v},U.createElement("path",kg({},st(r,!0),{className:C,d:zM(T,A,P,E,p),ref:n})))}):U.createElement("path",kg({},st(r,!0),{className:C,d:zM(d,u,f,h,p)}))},jne=["points","className","baseLinePoints","connectNulls"];function lc(){return lc=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Cne(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function UM(e){return One(e)||Pne(e)||Ene(e)||_ne()}function _ne(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ene(e,t){if(e){if(typeof e=="string")return cN(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return cN(e,t)}}function Pne(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function One(e){if(Array.isArray(e))return cN(e)}function cN(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return t.forEach(function(n){qM(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),qM(t[0])&&r[r.length-1].push(t[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Ud=function(t,r){var n=Tne(t);r&&(n=[n.reduce(function(i,s){return[].concat(UM(i),UM(s))},[])]);var a=n.map(function(i){return i.reduce(function(s,l,d){return"".concat(s).concat(d===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},kne=function(t,r,n){var a=Ud(t,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(Ud(r.reverse(),n).slice(1))},Ane=function(t){var r=t.points,n=t.className,a=t.baseLinePoints,i=t.connectNulls,s=Nne(t,jne);if(!r||!r.length)return null;var l=yt("recharts-polygon",n);if(a&&a.length){var d=s.stroke&&s.stroke!=="none",u=kne(r,a,i);return U.createElement("g",{className:l},U.createElement("path",lc({},st(s,!0),{fill:u.slice(-1)==="Z"?s.fill:"none",stroke:"none",d:u})),d?U.createElement("path",lc({},st(s,!0),{fill:"none",d:Ud(r,i)})):null,d?U.createElement("path",lc({},st(s,!0),{fill:"none",d:Ud(a,i)})):null)}var f=Ud(r,i);return U.createElement("path",lc({},st(s,!0),{fill:f.slice(-1)==="Z"?s.fill:"none",className:l,d:f}))};function uN(){return uN=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Fne(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Bne=function(t,r,n,a,i,s){return"M".concat(t,",").concat(i,"v").concat(a,"M").concat(s,",").concat(r,"h").concat(n)},zne=function(t){var r=t.x,n=r===void 0?0:r,a=t.y,i=a===void 0?0:a,s=t.top,l=s===void 0?0:s,d=t.left,u=d===void 0?0:d,f=t.width,h=f===void 0?0:f,p=t.height,g=p===void 0?0:p,v=t.className,b=$ne(t,Ine),w=Mne({x:n,y:i,top:l,left:u,width:h,height:g},b);return!Re(n)||!Re(i)||!Re(h)||!Re(g)||!Re(l)||!Re(u)?null:U.createElement("path",dN({},st(w,!0),{className:yt("recharts-cross",v),d:Bne(n,i,h,g,l,u)}))},cS,WM;function Une(){if(WM)return cS;WM=1;var e=Ly(),t=q3(),r=To();function n(a,i){return a&&a.length?e(a,r(i,2),t):void 0}return cS=n,cS}var qne=Une();const Vne=Vt(qne);var uS,HM;function Wne(){if(HM)return uS;HM=1;var e=Ly(),t=To(),r=V3();function n(a,i){return a&&a.length?e(a,t(i,2),r):void 0}return uS=n,uS}var Hne=Wne();const Gne=Vt(Hne);var Yne=["cx","cy","angle","ticks","axisLine"],Kne=["ticks","tick","angle","tickFormatter","stroke"];function $c(e){"@babel/helpers - typeof";return $c=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$c(e)}function qd(){return qd=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Xne(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Jne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function KM(e,t){for(var r=0;rQM?s=a==="outer"?"start":"end":i<-QM?s=a==="outer"?"end":"start":s="middle",s}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,i=n.cy,s=n.radius,l=n.axisLine,d=n.axisLineType,u=Ss(Ss({},st(this.props,!1)),{},{fill:"none"},st(l,!1));if(d==="circle")return U.createElement(Uy,As({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:i,r:s}));var f=this.props.ticks,h=f.map(function(p){return or(a,i,s,p.coordinate)});return U.createElement(Ane,As({className:"recharts-polar-angle-axis-line"},u,{points:h}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,i=a.ticks,s=a.tick,l=a.tickLine,d=a.tickFormatter,u=a.stroke,f=st(this.props,!1),h=st(s,!1),p=Ss(Ss({},f),{},{fill:"none"},st(l,!1)),g=i.map(function(v,b){var w=n.getTickLineCoord(v),j=n.getTickTextAnchor(v),N=Ss(Ss(Ss({textAnchor:j},f),{},{stroke:"none",fill:u},h),{},{index:b,payload:v,x:w.x2,y:w.y2});return U.createElement(Bt,As({className:yt("recharts-polar-angle-axis-tick",v5(s)),key:"tick-".concat(v.coordinate)},qs(n.props,v,b)),l&&U.createElement("line",As({className:"recharts-polar-angle-axis-tick-line"},p,w)),s&&t.renderTickItem(s,N,d?d(v.value,b):v.value))});return U.createElement(Bt,{className:"recharts-polar-angle-axis-ticks"},g)}},{key:"render",value:function(){var n=this.props,a=n.ticks,i=n.radius,s=n.axisLine;return i<=0||!a||!a.length?null:U.createElement(Bt,{className:yt("recharts-polar-angle-axis",this.props.className)},s&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,i){var s;return U.isValidElement(n)?s=U.cloneElement(n,a):ht(n)?s=n(a):s=U.createElement(Vs,As({},a,{className:"recharts-polar-angle-axis-tick-value"}),i),s}}])})(x.PureComponent);Wy(Hy,"displayName","PolarAngleAxis");Wy(Hy,"axisType","angleAxis");Wy(Hy,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var dS,ZM;function fae(){if(ZM)return dS;ZM=1;var e=q4(),t=e(Object.getPrototypeOf,Object);return dS=t,dS}var fS,eR;function hae(){if(eR)return fS;eR=1;var e=li(),t=fae(),r=ci(),n="[object Object]",a=Function.prototype,i=Object.prototype,s=a.toString,l=i.hasOwnProperty,d=s.call(Object);function u(f){if(!r(f)||e(f)!=n)return!1;var h=t(f);if(h===null)return!0;var p=l.call(h,"constructor")&&h.constructor;return typeof p=="function"&&p instanceof p&&s.call(p)==d}return fS=u,fS}var mae=hae();const pae=Vt(mae);var hS,tR;function gae(){if(tR)return hS;tR=1;var e=li(),t=ci(),r="[object Boolean]";function n(a){return a===!0||a===!1||t(a)&&e(a)==r}return hS=n,hS}var yae=gae();const vae=Vt(yae);function bf(e){"@babel/helpers - typeof";return bf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bf(e)}function Mg(){return Mg=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0,from:{upperWidth:0,lowerWidth:0,height:p,x:d,y:u},to:{upperWidth:f,lowerWidth:h,height:p,x:d,y:u},duration:b,animationEasing:v,isActive:j},function(C){var O=C.upperWidth,P=C.lowerWidth,E=C.height,T=C.x,A=C.y;return U.createElement(So,{canBegin:s>0,from:"0px ".concat(s===-1?1:s,"px"),to:"".concat(s,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:b,easing:v},U.createElement("path",Mg({},st(r,!0),{className:N,d:oR(T,A,O,P,E),ref:n})))}):U.createElement("g",null,U.createElement("path",Mg({},st(r,!0),{className:N,d:oR(d,u,f,h,p)})))},Oae=["option","shapeType","propTransformer","activeClassName","isActive"];function wf(e){"@babel/helpers - typeof";return wf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wf(e)}function Tae(e,t){if(e==null)return{};var r=kae(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function kae(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function iR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Rg(e){for(var t=1;t0?ua(C,"paddingAngle",0):0;if(P){var T=ra(P.endAngle-P.startAngle,C.endAngle-C.startAngle),A=nr(nr({},C),{},{startAngle:N+E,endAngle:N+T(b)+E});w.push(A),N=A.endAngle}else{var M=C.endAngle,R=C.startAngle,L=ra(0,M-R),V=L(b),z=nr(nr({},C),{},{startAngle:N+E,endAngle:N+V+E});w.push(z),N=z.endAngle}}),U.createElement(Bt,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(i){if(!i.altKey)switch(i.key){case"ArrowLeft":{var s=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[s].focus(),a.setState({sectorToFocus:s});break}case"ArrowRight":{var l=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,i=n.isAnimationActive,s=this.state.prevSectors;return i&&a&&a.length&&(!s||!Vf(s,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,i=a.hide,s=a.sectors,l=a.className,d=a.label,u=a.cx,f=a.cy,h=a.innerRadius,p=a.outerRadius,g=a.isAnimationActive,v=this.state.isAnimationFinished;if(i||!s||!s.length||!Re(u)||!Re(f)||!Re(h)||!Re(p))return null;var b=yt("recharts-pie",l);return U.createElement(Bt,{tabIndex:this.props.rootTabIndex,className:b,ref:function(j){n.pieRef=j}},this.renderSectors(),d&&this.renderLabels(s),Gr.renderCallByParent(this.props,null,!1),(!g||v)&&ei.renderCallByParent(this.props,s,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?N:N-1)*d,O=w-N*g-C,P=a.reduce(function(A,M){var R=Fr(M,j,0);return A+(Re(R)?R:0)},0),E;if(P>0){var T;E=a.map(function(A,M){var R=Fr(A,j,0),L=Fr(A,f,M),V=(Re(R)?R:0)/P,z;M?z=T.endAngle+Sn(b)*d*(R!==0?1:0):z=s;var G=z+Sn(b)*((R!==0?g:0)+V*O),H=(z+G)/2,W=(v.innerRadius+v.outerRadius)/2,q=[{name:L,value:R,payload:A,dataKey:j,type:p}],I=or(v.cx,v.cy,W,H);return T=nr(nr(nr({percent:V,cornerRadius:i,name:L,tooltipPayload:q,midAngle:H,middleRadius:W,tooltipPosition:I},A),v),{},{value:Fr(A,j),startAngle:z,endAngle:G,payload:A,paddingAngle:Sn(b)*d}),T})}return nr(nr({},v),{},{sectors:E,data:a})});var mS,uR;function Qae(){if(uR)return mS;uR=1;var e=Math.ceil,t=Math.max;function r(n,a,i,s){for(var l=-1,d=t(e((a-n)/(i||1)),0),u=Array(d);d--;)u[s?d:++l]=n,n+=i;return u}return mS=r,mS}var pS,dR;function D5(){if(dR)return pS;dR=1;var e=o3(),t=1/0,r=17976931348623157e292;function n(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var i=a<0?-1:1;return i*r}return a===a?a:0}return pS=n,pS}var gS,fR;function Zae(){if(fR)return gS;fR=1;var e=Qae(),t=Oy(),r=D5();function n(a){return function(i,s,l){return l&&typeof l!="number"&&t(i,s,l)&&(s=l=void 0),i=r(i),s===void 0?(s=i,i=0):s=r(s),l=l===void 0?i0&&n.handleDrag(a.changedTouches[0])}),Zn(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,i=a.endIndex,s=a.onDragEnd,l=a.startIndex;s?.({endIndex:i,startIndex:l})}),n.detachDragEndListener()}),Zn(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Zn(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Zn(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Zn(n,"handleSlideDragStart",function(a){var i=vR(a)?a.changedTouches[0]:a;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return doe(t,e),soe(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,i=n.endX,s=this.state.scaleValues,l=this.props,d=l.gap,u=l.data,f=u.length-1,h=Math.min(a,i),p=Math.max(a,i),g=t.getIndexInRange(s,h),v=t.getIndexInRange(s,p);return{startIndex:g-g%d,endIndex:v===f?f:v-v%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,i=a.data,s=a.tickFormatter,l=a.dataKey,d=Fr(i[n],l,n);return ht(s)?s(d,n):d}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,i=a.slideMoveStartX,s=a.startX,l=a.endX,d=this.props,u=d.x,f=d.width,h=d.travellerWidth,p=d.startIndex,g=d.endIndex,v=d.onChange,b=n.pageX-i;b>0?b=Math.min(b,u+f-h-l,u+f-h-s):b<0&&(b=Math.max(b,u-s,u-l));var w=this.getIndex({startX:s+b,endX:l+b});(w.startIndex!==p||w.endIndex!==g)&&v&&v(w),this.setState({startX:s+b,endX:l+b,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var i=vR(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,i=a.brushMoveStartX,s=a.movingTravellerId,l=a.endX,d=a.startX,u=this.state[s],f=this.props,h=f.x,p=f.width,g=f.travellerWidth,v=f.onChange,b=f.gap,w=f.data,j={startX:this.state.startX,endX:this.state.endX},N=n.pageX-i;N>0?N=Math.min(N,h+p-g-u):N<0&&(N=Math.max(N,h-u)),j[s]=u+N;var C=this.getIndex(j),O=C.startIndex,P=C.endIndex,E=function(){var A=w.length-1;return s==="startX"&&(l>d?O%b===0:P%b===0)||ld?P%b===0:O%b===0)||l>d&&P===A};this.setState(Zn(Zn({},s,u+N),"brushMoveStartX",n.pageX),function(){v&&E()&&v(C)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var i=this,s=this.state,l=s.scaleValues,d=s.startX,u=s.endX,f=this.state[a],h=l.indexOf(f);if(h!==-1){var p=h+n;if(!(p===-1||p>=l.length)){var g=l[p];a==="startX"&&g>=u||a==="endX"&&g<=d||this.setState(Zn({},a,g),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,i=n.y,s=n.width,l=n.height,d=n.fill,u=n.stroke;return U.createElement("rect",{stroke:u,fill:d,x:a,y:i,width:s,height:l})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,i=n.y,s=n.width,l=n.height,d=n.data,u=n.children,f=n.padding,h=x.Children.only(u);return h?U.cloneElement(h,{x:a,y:i,width:s,height:l,margin:f,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var i,s,l=this,d=this.props,u=d.y,f=d.travellerWidth,h=d.height,p=d.traveller,g=d.ariaLabel,v=d.data,b=d.startIndex,w=d.endIndex,j=Math.max(n,this.props.x),N=vS(vS({},st(this.props,!1)),{},{x:j,y:u,width:f,height:h}),C=g||"Min value: ".concat((i=v[b])===null||i===void 0?void 0:i.name,", Max value: ").concat((s=v[w])===null||s===void 0?void 0:s.name);return U.createElement(Bt,{tabIndex:0,role:"slider","aria-label":C,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(P){["ArrowLeft","ArrowRight"].includes(P.key)&&(P.preventDefault(),P.stopPropagation(),l.handleTravellerMoveKeyboard(P.key==="ArrowRight"?1:-1,a))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(p,N))}},{key:"renderSlide",value:function(n,a){var i=this.props,s=i.y,l=i.height,d=i.stroke,u=i.travellerWidth,f=Math.min(n,a)+u,h=Math.max(Math.abs(a-n)-u,0);return U.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:d,fillOpacity:.2,x:f,y:s,width:h,height:l})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,i=n.endIndex,s=n.y,l=n.height,d=n.travellerWidth,u=n.stroke,f=this.state,h=f.startX,p=f.endX,g=5,v={pointerEvents:"none",fill:u};return U.createElement(Bt,{className:"recharts-brush-texts"},U.createElement(Vs,$g({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,p)-g,y:s+l/2},v),this.getTextOfTick(a)),U.createElement(Vs,$g({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,p)+d+g,y:s+l/2},v),this.getTextOfTick(i)))}},{key:"render",value:function(){var n=this.props,a=n.data,i=n.className,s=n.children,l=n.x,d=n.y,u=n.width,f=n.height,h=n.alwaysShowText,p=this.state,g=p.startX,v=p.endX,b=p.isTextActive,w=p.isSlideMoving,j=p.isTravellerMoving,N=p.isTravellerFocused;if(!a||!a.length||!Re(l)||!Re(d)||!Re(u)||!Re(f)||u<=0||f<=0)return null;var C=yt("recharts-brush",i),O=U.Children.count(s)===1,P=ooe("userSelect","none");return U.createElement(Bt,{className:C,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:P},this.renderBackground(),O&&this.renderPanorama(),this.renderSlide(g,v),this.renderTravellerLayer(g,"startX"),this.renderTravellerLayer(v,"endX"),(b||w||j||N||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,i=n.y,s=n.width,l=n.height,d=n.stroke,u=Math.floor(i+l/2)-1;return U.createElement(U.Fragment,null,U.createElement("rect",{x:a,y:i,width:s,height:l,fill:d,stroke:"none"}),U.createElement("line",{x1:a+1,y1:u,x2:a+s-1,y2:u,fill:"none",stroke:"#fff"}),U.createElement("line",{x1:a+1,y1:u+2,x2:a+s-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var i;return U.isValidElement(n)?i=U.cloneElement(n,a):ht(n)?i=n(a):i=t.renderDefaultTraveller(a),i}},{key:"getDerivedStateFromProps",value:function(n,a){var i=n.data,s=n.width,l=n.x,d=n.travellerWidth,u=n.updateId,f=n.startIndex,h=n.endIndex;if(i!==a.prevData||u!==a.prevUpdateId)return vS({prevData:i,prevTravellerWidth:d,prevUpdateId:u,prevX:l,prevWidth:s},i&&i.length?hoe({data:i,width:s,x:l,travellerWidth:d,startIndex:f,endIndex:h}):{scale:null,scaleValues:null});if(a.scale&&(s!==a.prevWidth||l!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([l,l+s-d]);var p=a.scale.domain().map(function(g){return a.scale(g)});return{prevData:i,prevTravellerWidth:d,prevUpdateId:u,prevX:l,prevWidth:s,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:p}}return null}},{key:"getIndexInRange",value:function(n,a){for(var i=n.length,s=0,l=i-1;l-s>1;){var d=Math.floor((s+l)/2);n[d]>a?l=d:s=d}return a>=n[l]?l:s}}])})(x.PureComponent);Zn(Uc,"displayName","Brush");Zn(Uc,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var xS,xR;function moe(){if(xR)return xS;xR=1;var e=LC();function t(r,n){var a;return e(r,function(i,s,l){return a=n(i,s,l),!a}),!!a}return xS=t,xS}var bS,bR;function poe(){if(bR)return bS;bR=1;var e=D4(),t=To(),r=moe(),n=qn(),a=Oy();function i(s,l,d){var u=n(s)?e:r;return d&&a(s,l,d)&&(l=void 0),u(s,t(l,3))}return bS=i,bS}var goe=poe();const yoe=Vt(goe);var xo=function(t,r){var n=t.alwaysShow,a=t.ifOverflow;return n&&(a="extendDomain"),a===r},wS,wR;function voe(){if(wR)return wS;wR=1;var e=e3();function t(r,n,a){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):r[n]=a}return wS=t,wS}var SS,SR;function xoe(){if(SR)return SS;SR=1;var e=voe(),t=Q4(),r=To();function n(a,i){var s={};return i=r(i,3),t(a,function(l,d,u){e(s,d,i(l,d,u))}),s}return SS=n,SS}var boe=xoe();const woe=Vt(boe);var jS,jR;function Soe(){if(jR)return jS;jR=1;function e(t,r){for(var n=-1,a=t==null?0:t.length;++n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function koe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Aoe(e,t){var r=e.x,n=e.y,a=Toe(e,_oe),i="".concat(r),s=parseInt(i,10),l="".concat(n),d=parseInt(l,10),u="".concat(t.height||a.height),f=parseInt(u,10),h="".concat(t.width||a.width),p=parseInt(h,10);return Sd(Sd(Sd(Sd(Sd({},t),a),s?{x:s}:{}),d?{y:d}:{}),{},{height:f,width:p,name:t.name,radius:t.radius})}function ER(e){return U.createElement(I5,gN({shapeType:"rectangle",propTransformer:Aoe,activeClassName:"recharts-active-bar"},e))}var Ioe=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof t=="number")return t;var i=Re(n)||ZW(n);return i?t(n,a):(i||Hs(),r)}},Moe=["value","background"],z5;function qc(e){"@babel/helpers - typeof";return qc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qc(e)}function Roe(e,t){if(e==null)return{};var r=Doe(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Doe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Bg(){return Bg=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&Math.abs(H)0&&Math.abs(G)0&&(z=Math.min((J||0)-(G[oe-1]||0),z))}),Number.isFinite(z)){var H=z/V,W=b.layout==="vertical"?n.height:n.width;if(b.padding==="gap"&&(T=H*W/2),b.padding==="no-gap"){var q=jn(t.barCategoryGap,H*W),I=H*W/2;T=I-q-(I-q)/W*q}}}a==="xAxis"?A=[n.left+(C.left||0)+(T||0),n.left+n.width-(C.right||0)-(T||0)]:a==="yAxis"?A=d==="horizontal"?[n.top+n.height-(C.bottom||0),n.top+(C.top||0)]:[n.top+(C.top||0)+(T||0),n.top+n.height-(C.bottom||0)-(T||0)]:A=b.range,P&&(A=[A[1],A[0]]);var Y=d5(b,i,p),F=Y.scale,D=Y.realScaleType;F.domain(j).range(A),f5(F);var $=h5(F,Ha(Ha({},b),{},{realScaleType:D}));a==="xAxis"?(L=w==="top"&&!O||w==="bottom"&&O,M=n.left,R=h[E]-L*b.height):a==="yAxis"&&(L=w==="left"&&!O||w==="right"&&O,M=h[E]-L*b.width,R=n.top);var K=Ha(Ha(Ha({},b),$),{},{realScaleType:D,x:M,y:R,scale:F,width:a==="xAxis"?n.width:b.width,height:a==="yAxis"?n.height:b.height});return K.bandSize=jg(K,$),!b.hide&&a==="xAxis"?h[E]+=(L?-1:1)*K.height:b.hide||(h[E]+=(L?-1:1)*K.width),Ha(Ha({},g),{},Ky({},v,K))},{})},H5=function(t,r){var n=t.x,a=t.y,i=r.x,s=r.y;return{x:Math.min(n,i),y:Math.min(a,s),width:Math.abs(i-n),height:Math.abs(s-a)}},Goe=function(t){var r=t.x1,n=t.y1,a=t.x2,i=t.y2;return H5({x:r,y:n},{x:a,y:i})},G5=(function(){function e(t){Voe(this,e),this.scale=t}return Woe(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,i=n.position;if(r!==void 0){if(i)switch(i){case"start":return this.scale(r);case"middle":{var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+s}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(r)+l}default:return this.scale(r)}if(a){var d=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+d}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],i=n[n.length-1];return a<=i?r>=a&&r<=i:r>=i&&r<=a}}],[{key:"create",value:function(r){return new e(r)}}])})();Ky(G5,"EPS",1e-4);var f_=function(t){var r=Object.keys(t).reduce(function(n,a){return Ha(Ha({},n),{},Ky({},a,G5.create(t[a])))},{});return Ha(Ha({},r),{},{apply:function(a){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=i.bandAware,l=i.position;return woe(a,function(d,u){return r[u].apply(d,{bandAware:s,position:l})})},isInRange:function(a){return B5(a,function(i,s){return r[s].isInRange(i)})}})};function Yoe(e){return(e%180+180)%180}var Koe=function(t){var r=t.width,n=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=Yoe(a),s=i*Math.PI/180,l=Math.atan(n/r),d=s>l&&s-1?d[u?i[f]:f]:void 0}}return _S=n,_S}var ES,IR;function Joe(){if(IR)return ES;IR=1;var e=D5();function t(r){var n=e(r),a=n%1;return n===n?a?n-a:n:0}return ES=t,ES}var PS,MR;function Qoe(){if(MR)return PS;MR=1;var e=G4(),t=To(),r=Joe(),n=Math.max;function a(i,s,l){var d=i==null?0:i.length;if(!d)return-1;var u=l==null?0:r(l);return u<0&&(u=n(d+u,0)),e(i,t(s,3),u)}return PS=a,PS}var OS,RR;function Zoe(){if(RR)return OS;RR=1;var e=Xoe(),t=Qoe(),r=e(t);return OS=r,OS}var eie=Zoe();const tie=Vt(eie);var rie=c4();const nie=Vt(rie);var aie=nie(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),h_=x.createContext(void 0),m_=x.createContext(void 0),Y5=x.createContext(void 0),K5=x.createContext({}),X5=x.createContext(void 0),J5=x.createContext(0),Q5=x.createContext(0),DR=function(t){var r=t.state,n=r.xAxisMap,a=r.yAxisMap,i=r.offset,s=t.clipPathId,l=t.children,d=t.width,u=t.height,f=aie(i);return U.createElement(h_.Provider,{value:n},U.createElement(m_.Provider,{value:a},U.createElement(K5.Provider,{value:i},U.createElement(Y5.Provider,{value:f},U.createElement(X5.Provider,{value:s},U.createElement(J5.Provider,{value:u},U.createElement(Q5.Provider,{value:d},l)))))))},oie=function(){return x.useContext(X5)},Z5=function(t){var r=x.useContext(h_);r==null&&Hs();var n=r[t];return n==null&&Hs(),n},iie=function(){var t=x.useContext(h_);return Di(t)},sie=function(){var t=x.useContext(m_),r=tie(t,function(n){return B5(n.domain,Number.isFinite)});return r||Di(t)},eF=function(t){var r=x.useContext(m_);r==null&&Hs();var n=r[t];return n==null&&Hs(),n},lie=function(){var t=x.useContext(Y5);return t},cie=function(){return x.useContext(K5)},p_=function(){return x.useContext(Q5)},g_=function(){return x.useContext(J5)};function Vc(e){"@babel/helpers - typeof";return Vc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vc(e)}function uie(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function die(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);re*a)return!1;var i=r();return e*(t-e*i/2-n)>=0&&e*(t+e*i/2-a)<=0}function Hie(e,t){return sF(e,t+1)}function Gie(e,t,r,n,a){for(var i=(n||[]).slice(),s=t.start,l=t.end,d=0,u=1,f=s,h=function(){var v=n?.[d];if(v===void 0)return{v:sF(n,u)};var b=d,w,j=function(){return w===void 0&&(w=r(v,b)),w},N=v.coordinate,C=d===0||Wg(e,N,j,f,l);C||(d=0,f=s,u+=1),C&&(f=N+e*(j()/2+a),d+=u)},p;u<=i.length;)if(p=h(),p)return p.v;return[]}function _f(e){"@babel/helpers - typeof";return _f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_f(e)}function VR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ln(e){for(var t=1;t0?g.coordinate-w*e:g.coordinate})}else i[p]=g=ln(ln({},g),{},{tickCoord:g.coordinate});var j=Wg(e,g.tickCoord,b,l,d);j&&(d=g.tickCoord-e*(b()/2+a),i[p]=ln(ln({},g),{},{isShow:!0}))},f=s-1;f>=0;f--)u(f);return i}function Qie(e,t,r,n,a,i){var s=(n||[]).slice(),l=s.length,d=t.start,u=t.end;if(i){var f=n[l-1],h=r(f,l-1),p=e*(f.coordinate+e*h/2-u);s[l-1]=f=ln(ln({},f),{},{tickCoord:p>0?f.coordinate-p*e:f.coordinate});var g=Wg(e,f.tickCoord,function(){return h},d,u);g&&(u=f.tickCoord-e*(h/2+a),s[l-1]=ln(ln({},f),{},{isShow:!0}))}for(var v=i?l-1:l,b=function(N){var C=s[N],O,P=function(){return O===void 0&&(O=r(C,N)),O};if(N===0){var E=e*(C.coordinate-e*P()/2-d);s[N]=C=ln(ln({},C),{},{tickCoord:E<0?C.coordinate-E*e:C.coordinate})}else s[N]=C=ln(ln({},C),{},{tickCoord:C.coordinate});var T=Wg(e,C.tickCoord,P,d,u);T&&(d=C.tickCoord+e*(P()/2+a),s[N]=ln(ln({},C),{},{isShow:!0}))},w=0;w=2?Sn(a[1].coordinate-a[0].coordinate):1,j=Wie(i,w,g);return d==="equidistantPreserveStart"?Gie(w,j,b,a,s):(d==="preserveStart"||d==="preserveStartEnd"?p=Qie(w,j,b,a,s,d==="preserveStartEnd"):p=Jie(w,j,b,a,s),p.filter(function(N){return N.isShow}))}var Zie=["viewBox"],ese=["viewBox"],tse=["ticks"];function Gc(e){"@babel/helpers - typeof";return Gc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gc(e)}function uc(){return uc=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function rse(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function nse(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function HR(e,t){for(var r=0;r0?d(this.props):d(g)),s<=0||l<=0||!v||!v.length?null:U.createElement(Bt,{className:yt("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},i&&this.renderAxisLine(),this.renderTicks(v,this.state.fontSize,this.state.letterSpacing),Gr.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,i){var s,l=yt(a.className,"recharts-cartesian-axis-tick-value");return U.isValidElement(n)?s=U.cloneElement(n,Lr(Lr({},a),{},{className:l})):ht(n)?s=n(Lr(Lr({},a),{},{className:l})):s=U.createElement(Vs,uc({},a,{className:"recharts-cartesian-axis-tick-value"}),i),s}}])})(x.Component);b_(vu,"displayName","CartesianAxis");b_(vu,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var use=["x1","y1","x2","y2","key"],dse=["offset"];function Gs(e){"@babel/helpers - typeof";return Gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gs(e)}function GR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function un(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function pse(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var gse=function(t){var r=t.fill;if(!r||r==="none")return null;var n=t.fillOpacity,a=t.x,i=t.y,s=t.width,l=t.height,d=t.ry;return U.createElement("rect",{x:a,y:i,ry:d,width:s,height:l,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function uF(e,t){var r;if(U.isValidElement(e))r=U.cloneElement(e,t);else if(ht(e))r=e(t);else{var n=t.x1,a=t.y1,i=t.x2,s=t.y2,l=t.key,d=YR(t,use),u=st(d,!1);u.offset;var f=YR(u,dse);r=U.createElement("line",Ds({},f,{x1:n,y1:a,x2:i,y2:s,fill:"none",key:l}))}return r}function yse(e){var t=e.x,r=e.width,n=e.horizontal,a=n===void 0?!0:n,i=e.horizontalPoints;if(!a||!i||!i.length)return null;var s=i.map(function(l,d){var u=un(un({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(d),index:d});return uF(a,u)});return U.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function vse(e){var t=e.y,r=e.height,n=e.vertical,a=n===void 0?!0:n,i=e.verticalPoints;if(!a||!i||!i.length)return null;var s=i.map(function(l,d){var u=un(un({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(d),index:d});return uF(a,u)});return U.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function xse(e){var t=e.horizontalFill,r=e.fillOpacity,n=e.x,a=e.y,i=e.width,s=e.height,l=e.horizontalPoints,d=e.horizontal,u=d===void 0?!0:d;if(!u||!t||!t.length)return null;var f=l.map(function(p){return Math.round(p+a-a)}).sort(function(p,g){return p-g});a!==f[0]&&f.unshift(0);var h=f.map(function(p,g){var v=!f[g+1],b=v?a+s-p:f[g+1]-p;if(b<=0)return null;var w=g%t.length;return U.createElement("rect",{key:"react-".concat(g),y:p,x:n,height:b,width:i,stroke:"none",fill:t[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return U.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function bse(e){var t=e.vertical,r=t===void 0?!0:t,n=e.verticalFill,a=e.fillOpacity,i=e.x,s=e.y,l=e.width,d=e.height,u=e.verticalPoints;if(!r||!n||!n.length)return null;var f=u.map(function(p){return Math.round(p+i-i)}).sort(function(p,g){return p-g});i!==f[0]&&f.unshift(0);var h=f.map(function(p,g){var v=!f[g+1],b=v?i+l-p:f[g+1]-p;if(b<=0)return null;var w=g%n.length;return U.createElement("rect",{key:"react-".concat(g),x:p,y:s,width:b,height:d,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return U.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var wse=function(t,r){var n=t.xAxis,a=t.width,i=t.height,s=t.offset;return u5(x_(un(un(un({},vu.defaultProps),n),{},{ticks:Ko(n,!0),viewBox:{x:0,y:0,width:a,height:i}})),s.left,s.left+s.width,r)},Sse=function(t,r){var n=t.yAxis,a=t.width,i=t.height,s=t.offset;return u5(x_(un(un(un({},vu.defaultProps),n),{},{ticks:Ko(n,!0),viewBox:{x:0,y:0,width:a,height:i}})),s.top,s.top+s.height,r)},Gl={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Gg(e){var t,r,n,a,i,s,l=p_(),d=g_(),u=cie(),f=un(un({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:Gl.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:Gl.fill,horizontal:(n=e.horizontal)!==null&&n!==void 0?n:Gl.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:Gl.horizontalFill,vertical:(i=e.vertical)!==null&&i!==void 0?i:Gl.vertical,verticalFill:(s=e.verticalFill)!==null&&s!==void 0?s:Gl.verticalFill,x:Re(e.x)?e.x:u.left,y:Re(e.y)?e.y:u.top,width:Re(e.width)?e.width:u.width,height:Re(e.height)?e.height:u.height}),h=f.x,p=f.y,g=f.width,v=f.height,b=f.syncWithTicks,w=f.horizontalValues,j=f.verticalValues,N=iie(),C=sie();if(!Re(g)||g<=0||!Re(v)||v<=0||!Re(h)||h!==+h||!Re(p)||p!==+p)return null;var O=f.verticalCoordinatesGenerator||wse,P=f.horizontalCoordinatesGenerator||Sse,E=f.horizontalPoints,T=f.verticalPoints;if((!E||!E.length)&&ht(P)){var A=w&&w.length,M=P({yAxis:C?un(un({},C),{},{ticks:A?w:C.ticks}):void 0,width:l,height:d,offset:u},A?!0:b);Ka(Array.isArray(M),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Gs(M),"]")),Array.isArray(M)&&(E=M)}if((!T||!T.length)&&ht(O)){var R=j&&j.length,L=O({xAxis:N?un(un({},N),{},{ticks:R?j:N.ticks}):void 0,width:l,height:d,offset:u},R?!0:b);Ka(Array.isArray(L),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Gs(L),"]")),Array.isArray(L)&&(T=L)}return U.createElement("g",{className:"recharts-cartesian-grid"},U.createElement(gse,{fill:f.fill,fillOpacity:f.fillOpacity,x:f.x,y:f.y,width:f.width,height:f.height,ry:f.ry}),U.createElement(yse,Ds({},f,{offset:u,horizontalPoints:E,xAxis:N,yAxis:C})),U.createElement(vse,Ds({},f,{offset:u,verticalPoints:T,xAxis:N,yAxis:C})),U.createElement(xse,Ds({},f,{horizontalPoints:E})),U.createElement(bse,Ds({},f,{verticalPoints:T})))}Gg.displayName="CartesianGrid";var jse=["type","layout","connectNulls","ref"],Nse=["key"];function Yc(e){"@babel/helpers - typeof";return Yc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Yc(e)}function KR(e,t){if(e==null)return{};var r=Cse(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Cse(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Vd(){return Vd=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);rh){g=[].concat(Yl(d.slice(0,v)),[h-b]);break}var w=g.length%2===0?[0,p]:[p];return[].concat(Yl(t.repeat(d,f)),Yl(g),w).map(function(j){return"".concat(j,"px")}).join(", ")}),Ga(r,"id",hu("recharts-line-")),Ga(r,"pathRef",function(s){r.mainCurve=s}),Ga(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Ga(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Rse(t,e),kse(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,s=i.points,l=i.xAxis,d=i.yAxis,u=i.layout,f=i.children,h=da(f,Wf);if(!h)return null;var p=function(b,w){return{x:b.x,y:b.y,value:b.value,errorVal:Fr(b.payload,w)}},g={clipPath:n?"url(#clipPath-".concat(a,")"):null};return U.createElement(Bt,g,h.map(function(v){return U.cloneElement(v,{key:"bar-".concat(v.props.dataKey),data:s,xAxis:l,yAxis:d,layout:u,dataPointFormatter:p})}))}},{key:"renderDots",value:function(n,a,i){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var l=this.props,d=l.dot,u=l.points,f=l.dataKey,h=st(this.props,!1),p=st(d,!0),g=u.map(function(b,w){var j=Qn(Qn(Qn({key:"dot-".concat(w),r:3},h),p),{},{index:w,cx:b.x,cy:b.y,value:b.value,dataKey:f,payload:b.payload,points:u});return t.renderDotItem(d,j)}),v={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return U.createElement(Bt,Vd({className:"recharts-line-dots",key:"dots"},v),g)}},{key:"renderCurveStatically",value:function(n,a,i,s){var l=this.props,d=l.type,u=l.layout,f=l.connectNulls;l.ref;var h=KR(l,jse),p=Qn(Qn(Qn({},st(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(i,")"):null,points:n},s),{},{type:d,layout:u,connectNulls:f});return U.createElement(_g,Vd({},p,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var i=this,s=this.props,l=s.points,d=s.strokeDasharray,u=s.isAnimationActive,f=s.animationBegin,h=s.animationDuration,p=s.animationEasing,g=s.animationId,v=s.animateNewValues,b=s.width,w=s.height,j=this.state,N=j.prevPoints,C=j.totalLength;return U.createElement(So,{begin:f,duration:h,isActive:u,easing:p,from:{t:0},to:{t:1},key:"line-".concat(g),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var P=O.t;if(N){var E=N.length/l.length,T=l.map(function(V,z){var G=Math.floor(z*E);if(N[G]){var H=N[G],W=ra(H.x,V.x),q=ra(H.y,V.y);return Qn(Qn({},V),{},{x:W(P),y:q(P)})}if(v){var I=ra(b*2,V.x),Y=ra(w/2,V.y);return Qn(Qn({},V),{},{x:I(P),y:Y(P)})}return Qn(Qn({},V),{},{x:V.x,y:V.y})});return i.renderCurveStatically(T,n,a)}var A=ra(0,C),M=A(P),R;if(d){var L="".concat(d).split(/[,\s]+/gim).map(function(V){return parseFloat(V)});R=i.getStrokeDasharray(M,C,L)}else R=i.generateSimpleStrokeDasharray(C,M);return i.renderCurveStatically(l,n,a,{strokeDasharray:R})})}},{key:"renderCurve",value:function(n,a){var i=this.props,s=i.points,l=i.isAnimationActive,d=this.state,u=d.prevPoints,f=d.totalLength;return l&&s&&s.length&&(!u&&f>0||!Vf(u,s))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(s,n,a)}},{key:"render",value:function(){var n,a=this.props,i=a.hide,s=a.dot,l=a.points,d=a.className,u=a.xAxis,f=a.yAxis,h=a.top,p=a.left,g=a.width,v=a.height,b=a.isAnimationActive,w=a.id;if(i||!l||!l.length)return null;var j=this.state.isAnimationFinished,N=l.length===1,C=yt("recharts-line",d),O=u&&u.allowDataOverflow,P=f&&f.allowDataOverflow,E=O||P,T=gt(w)?this.id:w,A=(n=st(s,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},M=A.r,R=M===void 0?3:M,L=A.strokeWidth,V=L===void 0?2:L,z=dH(s)?s:{},G=z.clipDot,H=G===void 0?!0:G,W=R*2+V;return U.createElement(Bt,{className:C},O||P?U.createElement("defs",null,U.createElement("clipPath",{id:"clipPath-".concat(T)},U.createElement("rect",{x:O?p:p-g/2,y:P?h:h-v/2,width:O?g:g*2,height:P?v:v*2})),!H&&U.createElement("clipPath",{id:"clipPath-dots-".concat(T)},U.createElement("rect",{x:p-W/2,y:h-W/2,width:g+W,height:v+W}))):null,!N&&this.renderCurve(E,T),this.renderErrorBar(E,T),(N||s)&&this.renderDots(E,H,T),(!b||j)&&ei.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var i=n.length%2!==0?[].concat(Yl(n),[0]):n,s=[],l=0;le.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Cle(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function _le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ele(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r0?s:t&&t.length&&Re(a)&&Re(i)?t.slice(a,i+1):[]};function CF(e){return e==="number"?[0,"auto"]:void 0}var RN=function(t,r,n,a){var i=t.graphicalItems,s=t.tooltipAxis,l=ev(r,t);return n<0||!i||!i.length||n>=l.length?null:i.reduce(function(d,u){var f,h=(f=u.props.data)!==null&&f!==void 0?f:r;h&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(h=h.slice(t.dataStartIndex,t.dataEndIndex+1));var p;if(s.dataKey&&!s.allowDuplicatedCategory){var g=h===void 0?l:h;p=Xp(g,s.dataKey,a)}else p=h&&h[n]||l[n];return p?[].concat(Qc(d),[p5(u,p)]):d},[])},aD=function(t,r,n,a){var i=a||{x:t.chartX,y:t.chartY},s=Fle(i,n),l=t.orderedTooltipTicks,d=t.tooltipAxis,u=t.tooltipTicks,f=lee(s,l,u,d);if(f>=0&&u){var h=u[f]&&u[f].value,p=RN(t,r,f,h),g=Ble(n,l,f,i);return{activeTooltipIndex:f,activeLabel:h,activePayload:p,activeCoordinate:g}}return null},zle=function(t,r){var n=r.axes,a=r.graphicalItems,i=r.axisType,s=r.axisIdKey,l=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,f=t.layout,h=t.children,p=t.stackOffset,g=c5(f,i);return n.reduce(function(v,b){var w,j=b.type.defaultProps!==void 0?Ne(Ne({},b.type.defaultProps),b.props):b.props,N=j.type,C=j.dataKey,O=j.allowDataOverflow,P=j.allowDuplicatedCategory,E=j.scale,T=j.ticks,A=j.includeHidden,M=j[s];if(v[M])return v;var R=ev(t.data,{graphicalItems:a.filter(function($){var K,J=s in $.props?$.props[s]:(K=$.type.defaultProps)===null||K===void 0?void 0:K[s];return J===M}),dataStartIndex:d,dataEndIndex:u}),L=R.length,V,z,G;hle(j.domain,O,N)&&(V=Kj(j.domain,null,O),g&&(N==="number"||E!=="auto")&&(G=Bd(R,C,"category")));var H=CF(N);if(!V||V.length===0){var W,q=(W=j.domain)!==null&&W!==void 0?W:H;if(C){if(V=Bd(R,C,N),N==="category"&&g){var I=tH(V);P&&I?(z=V,V=Lg(0,L)):P||(V=iM(q,V,b).reduce(function($,K){return $.indexOf(K)>=0?$:[].concat(Qc($),[K])},[]))}else if(N==="category")P?V=V.filter(function($){return $!==""&&!gt($)}):V=iM(q,V,b).reduce(function($,K){return $.indexOf(K)>=0||K===""||gt(K)?$:[].concat(Qc($),[K])},[]);else if(N==="number"){var Y=hee(R,a.filter(function($){var K,J,oe=s in $.props?$.props[s]:(K=$.type.defaultProps)===null||K===void 0?void 0:K[s],re="hide"in $.props?$.props.hide:(J=$.type.defaultProps)===null||J===void 0?void 0:J.hide;return oe===M&&(A||!re)}),C,i,f);Y&&(V=Y)}g&&(N==="number"||E!=="auto")&&(G=Bd(R,C,"category"))}else g?V=Lg(0,L):l&&l[M]&&l[M].hasStack&&N==="number"?V=p==="expand"?[0,1]:m5(l[M].stackGroups,d,u):V=l5(R,a.filter(function($){var K=s in $.props?$.props[s]:$.type.defaultProps[s],J="hide"in $.props?$.props.hide:$.type.defaultProps.hide;return K===M&&(A||!J)}),N,f,!0);if(N==="number")V=AN(h,V,M,i,T),q&&(V=Kj(q,V,O));else if(N==="category"&&q){var F=q,D=V.every(function($){return F.indexOf($)>=0});D&&(V=F)}}return Ne(Ne({},v),{},ct({},M,Ne(Ne({},j),{},{axisType:i,domain:V,categoricalDomain:G,duplicateDomain:z,originalDomain:(w=j.domain)!==null&&w!==void 0?w:H,isCategorical:g,layout:f})))},{})},Ule=function(t,r){var n=r.graphicalItems,a=r.Axis,i=r.axisType,s=r.axisIdKey,l=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,f=t.layout,h=t.children,p=ev(t.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:u}),g=p.length,v=c5(f,i),b=-1;return n.reduce(function(w,j){var N=j.type.defaultProps!==void 0?Ne(Ne({},j.type.defaultProps),j.props):j.props,C=N[s],O=CF("number");if(!w[C]){b++;var P;return v?P=Lg(0,g):l&&l[C]&&l[C].hasStack?(P=m5(l[C].stackGroups,d,u),P=AN(h,P,C,i)):(P=Kj(O,l5(p,n.filter(function(E){var T,A,M=s in E.props?E.props[s]:(T=E.type.defaultProps)===null||T===void 0?void 0:T[s],R="hide"in E.props?E.props.hide:(A=E.type.defaultProps)===null||A===void 0?void 0:A.hide;return M===C&&!R}),"number",f),a.defaultProps.allowDataOverflow),P=AN(h,P,C,i)),Ne(Ne({},w),{},ct({},C,Ne(Ne({axisType:i},a.defaultProps),{},{hide:!0,orientation:ua(Lle,"".concat(i,".").concat(b%2),null),domain:P,originalDomain:O,isCategorical:v,layout:f})))}return w},{})},qle=function(t,r){var n=r.axisType,a=n===void 0?"xAxis":n,i=r.AxisComp,s=r.graphicalItems,l=r.stackGroups,d=r.dataStartIndex,u=r.dataEndIndex,f=t.children,h="".concat(a,"Id"),p=da(f,i),g={};return p&&p.length?g=zle(t,{axes:p,graphicalItems:s,axisType:a,axisIdKey:h,stackGroups:l,dataStartIndex:d,dataEndIndex:u}):s&&s.length&&(g=Ule(t,{Axis:i,graphicalItems:s,axisType:a,axisIdKey:h,stackGroups:l,dataStartIndex:d,dataEndIndex:u})),g},Vle=function(t){var r=Di(t),n=Ko(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:$C(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:jg(r,n)}},oD=function(t){var r=t.children,n=t.defaultShowTooltip,a=ea(r,Uc),i=0,s=0;return t.data&&t.data.length!==0&&(s=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(s=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:s,activeTooltipIndex:-1,isTooltipActive:!!n}},Wle=function(t){return!t||!t.length?!1:t.some(function(r){var n=Qo(r&&r.type);return n&&n.indexOf("Bar")>=0})},iD=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Hle=function(t,r){var n=t.props,a=t.graphicalItems,i=t.xAxisMap,s=i===void 0?{}:i,l=t.yAxisMap,d=l===void 0?{}:l,u=n.width,f=n.height,h=n.children,p=n.margin||{},g=ea(h,Uc),v=ea(h,pc),b=Object.keys(d).reduce(function(P,E){var T=d[E],A=T.orientation;return!T.mirror&&!T.hide?Ne(Ne({},P),{},ct({},A,P[A]+T.width)):P},{left:p.left||0,right:p.right||0}),w=Object.keys(s).reduce(function(P,E){var T=s[E],A=T.orientation;return!T.mirror&&!T.hide?Ne(Ne({},P),{},ct({},A,ua(P,"".concat(A))+T.height)):P},{top:p.top||0,bottom:p.bottom||0}),j=Ne(Ne({},w),b),N=j.bottom;g&&(j.bottom+=g.props.height||Uc.defaultProps.height),v&&r&&(j=dee(j,a,n,r));var C=u-j.left-j.right,O=f-j.top-j.bottom;return Ne(Ne({brushBottom:N},j),{},{width:Math.max(C,0),height:Math.max(O,0)})},Gle=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},w_=function(t){var r=t.chartName,n=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,s=t.validateTooltipEventTypes,l=s===void 0?["axis"]:s,d=t.axisComponents,u=t.legendContent,f=t.formatAxisMap,h=t.defaultProps,p=function(j,N){var C=N.graphicalItems,O=N.stackGroups,P=N.offset,E=N.updateId,T=N.dataStartIndex,A=N.dataEndIndex,M=j.barSize,R=j.layout,L=j.barGap,V=j.barCategoryGap,z=j.maxBarSize,G=iD(R),H=G.numericAxisName,W=G.cateAxisName,q=Wle(C),I=[];return C.forEach(function(Y,F){var D=ev(j.data,{graphicalItems:[Y],dataStartIndex:T,dataEndIndex:A}),$=Y.type.defaultProps!==void 0?Ne(Ne({},Y.type.defaultProps),Y.props):Y.props,K=$.dataKey,J=$.maxBarSize,oe=$["".concat(H,"Id")],re=$["".concat(W,"Id")],Q={},ue=d.reduce(function(ve,ke){var Ge=N["".concat(ke.axisType,"Map")],xe=$["".concat(ke.axisType,"Id")];Ge&&Ge[xe]||ke.axisType==="zAxis"||Hs();var Je=Ge[xe];return Ne(Ne({},ve),{},ct(ct({},ke.axisType,Je),"".concat(ke.axisType,"Ticks"),Ko(Je)))},Q),se=ue[W],fe=ue["".concat(W,"Ticks")],we=O&&O[oe]&&O[oe].hasStack&&See(Y,O[oe].stackGroups),Z=Qo(Y.type).indexOf("Bar")>=0,je=jg(se,fe),Ce=[],qe=q&&cee({barSize:M,stackGroups:O,totalSize:Gle(ue,W)});if(Z){var De,He,ne=gt(J)?z:J,pe=(De=(He=jg(se,fe,!0))!==null&&He!==void 0?He:ne)!==null&&De!==void 0?De:0;Ce=uee({barGap:L,barCategoryGap:V,bandSize:pe!==je?pe:je,sizeList:qe[re],maxBarSize:ne}),pe!==je&&(Ce=Ce.map(function(ve){return Ne(Ne({},ve),{},{position:Ne(Ne({},ve.position),{},{offset:ve.position.offset-pe/2})})}))}var _e=Y&&Y.type&&Y.type.getComposedData;_e&&I.push({props:Ne(Ne({},_e(Ne(Ne({},ue),{},{displayedData:D,props:j,dataKey:K,item:Y,bandSize:je,barPosition:Ce,offset:P,stackedData:we,layout:R,dataStartIndex:T,dataEndIndex:A}))),{},ct(ct(ct({key:Y.key||"item-".concat(F)},H,ue[H]),W,ue[W]),"animationId",E)),childIndex:mH(Y,j.children),item:Y})}),I},g=function(j,N){var C=j.props,O=j.dataStartIndex,P=j.dataEndIndex,E=j.updateId;if(!bk({props:C}))return null;var T=C.children,A=C.layout,M=C.stackOffset,R=C.data,L=C.reverseStackOrder,V=iD(A),z=V.numericAxisName,G=V.cateAxisName,H=da(T,n),W=bee(R,H,"".concat(z,"Id"),"".concat(G,"Id"),M,L),q=d.reduce(function($,K){var J="".concat(K.axisType,"Map");return Ne(Ne({},$),{},ct({},J,qle(C,Ne(Ne({},K),{},{graphicalItems:H,stackGroups:K.axisType===z&&W,dataStartIndex:O,dataEndIndex:P}))))},{}),I=Hle(Ne(Ne({},q),{},{props:C,graphicalItems:H}),N?.legendBBox);Object.keys(q).forEach(function($){q[$]=f(C,q[$],I,$.replace("Map",""),r)});var Y=q["".concat(G,"Map")],F=Vle(Y),D=p(C,Ne(Ne({},q),{},{dataStartIndex:O,dataEndIndex:P,updateId:E,graphicalItems:H,stackGroups:W,offset:I}));return Ne(Ne({formattedGraphicalItems:D,graphicalItems:H,offset:I,stackGroups:W},F),q)},v=(function(w){function j(N){var C,O,P;return _le(this,j),P=Ole(this,j,[N]),ct(P,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),ct(P,"accessibilityManager",new fle),ct(P,"handleLegendBBoxUpdate",function(E){if(E){var T=P.state,A=T.dataStartIndex,M=T.dataEndIndex,R=T.updateId;P.setState(Ne({legendBBox:E},g({props:P.props,dataStartIndex:A,dataEndIndex:M,updateId:R},Ne(Ne({},P.state),{},{legendBBox:E}))))}}),ct(P,"handleReceiveSyncEvent",function(E,T,A){if(P.props.syncId===E){if(A===P.eventEmitterSymbol&&typeof P.props.syncMethod!="function")return;P.applySyncEvent(T)}}),ct(P,"handleBrushChange",function(E){var T=E.startIndex,A=E.endIndex;if(T!==P.state.dataStartIndex||A!==P.state.dataEndIndex){var M=P.state.updateId;P.setState(function(){return Ne({dataStartIndex:T,dataEndIndex:A},g({props:P.props,dataStartIndex:T,dataEndIndex:A,updateId:M},P.state))}),P.triggerSyncEvent({dataStartIndex:T,dataEndIndex:A})}}),ct(P,"handleMouseEnter",function(E){var T=P.getMouseInfo(E);if(T){var A=Ne(Ne({},T),{},{isTooltipActive:!0});P.setState(A),P.triggerSyncEvent(A);var M=P.props.onMouseEnter;ht(M)&&M(A,E)}}),ct(P,"triggeredAfterMouseMove",function(E){var T=P.getMouseInfo(E),A=T?Ne(Ne({},T),{},{isTooltipActive:!0}):{isTooltipActive:!1};P.setState(A),P.triggerSyncEvent(A);var M=P.props.onMouseMove;ht(M)&&M(A,E)}),ct(P,"handleItemMouseEnter",function(E){P.setState(function(){return{isTooltipActive:!0,activeItem:E,activePayload:E.tooltipPayload,activeCoordinate:E.tooltipPosition||{x:E.cx,y:E.cy}}})}),ct(P,"handleItemMouseLeave",function(){P.setState(function(){return{isTooltipActive:!1}})}),ct(P,"handleMouseMove",function(E){E.persist(),P.throttleTriggeredAfterMouseMove(E)}),ct(P,"handleMouseLeave",function(E){P.throttleTriggeredAfterMouseMove.cancel();var T={isTooltipActive:!1};P.setState(T),P.triggerSyncEvent(T);var A=P.props.onMouseLeave;ht(A)&&A(T,E)}),ct(P,"handleOuterEvent",function(E){var T=hH(E),A=ua(P.props,"".concat(T));if(T&&ht(A)){var M,R;/.*touch.*/i.test(T)?R=P.getMouseInfo(E.changedTouches[0]):R=P.getMouseInfo(E),A((M=R)!==null&&M!==void 0?M:{},E)}}),ct(P,"handleClick",function(E){var T=P.getMouseInfo(E);if(T){var A=Ne(Ne({},T),{},{isTooltipActive:!0});P.setState(A),P.triggerSyncEvent(A);var M=P.props.onClick;ht(M)&&M(A,E)}}),ct(P,"handleMouseDown",function(E){var T=P.props.onMouseDown;if(ht(T)){var A=P.getMouseInfo(E);T(A,E)}}),ct(P,"handleMouseUp",function(E){var T=P.props.onMouseUp;if(ht(T)){var A=P.getMouseInfo(E);T(A,E)}}),ct(P,"handleTouchMove",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&P.throttleTriggeredAfterMouseMove(E.changedTouches[0])}),ct(P,"handleTouchStart",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&P.handleMouseDown(E.changedTouches[0])}),ct(P,"handleTouchEnd",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&P.handleMouseUp(E.changedTouches[0])}),ct(P,"handleDoubleClick",function(E){var T=P.props.onDoubleClick;if(ht(T)){var A=P.getMouseInfo(E);T(A,E)}}),ct(P,"handleContextMenu",function(E){var T=P.props.onContextMenu;if(ht(T)){var A=P.getMouseInfo(E);T(A,E)}}),ct(P,"triggerSyncEvent",function(E){P.props.syncId!==void 0&&AS.emit(IS,P.props.syncId,E,P.eventEmitterSymbol)}),ct(P,"applySyncEvent",function(E){var T=P.props,A=T.layout,M=T.syncMethod,R=P.state.updateId,L=E.dataStartIndex,V=E.dataEndIndex;if(E.dataStartIndex!==void 0||E.dataEndIndex!==void 0)P.setState(Ne({dataStartIndex:L,dataEndIndex:V},g({props:P.props,dataStartIndex:L,dataEndIndex:V,updateId:R},P.state)));else if(E.activeTooltipIndex!==void 0){var z=E.chartX,G=E.chartY,H=E.activeTooltipIndex,W=P.state,q=W.offset,I=W.tooltipTicks;if(!q)return;if(typeof M=="function")H=M(I,E);else if(M==="value"){H=-1;for(var Y=0;Y=0){var we,Z;if(z.dataKey&&!z.allowDuplicatedCategory){var je=typeof z.dataKey=="function"?fe:"payload.".concat(z.dataKey.toString());we=Xp(Y,je,H),Z=F&&D&&Xp(D,je,H)}else we=Y?.[G],Z=F&&D&&D[G];if(re||oe){var Ce=E.props.activeIndex!==void 0?E.props.activeIndex:G;return[x.cloneElement(E,Ne(Ne(Ne({},M.props),ue),{},{activeIndex:Ce})),null,null]}if(!gt(we))return[se].concat(Qc(P.renderActivePoints({item:M,activePoint:we,basePoint:Z,childIndex:G,isRange:F})))}else{var qe,De=(qe=P.getItemByXY(P.state.activeCoordinate))!==null&&qe!==void 0?qe:{graphicalItem:se},He=De.graphicalItem,ne=He.item,pe=ne===void 0?E:ne,_e=He.childIndex,ve=Ne(Ne(Ne({},M.props),ue),{},{activeIndex:_e});return[x.cloneElement(pe,ve),null,null]}return F?[se,null,null]:[se,null]}),ct(P,"renderCustomized",function(E,T,A){return x.cloneElement(E,Ne(Ne({key:"recharts-customized-".concat(A)},P.props),P.state))}),ct(P,"renderMap",{CartesianGrid:{handler:Um,once:!0},ReferenceArea:{handler:P.renderReferenceElement},ReferenceLine:{handler:Um},ReferenceDot:{handler:P.renderReferenceElement},XAxis:{handler:Um},YAxis:{handler:Um},Brush:{handler:P.renderBrush,once:!0},Bar:{handler:P.renderGraphicChild},Line:{handler:P.renderGraphicChild},Area:{handler:P.renderGraphicChild},Radar:{handler:P.renderGraphicChild},RadialBar:{handler:P.renderGraphicChild},Scatter:{handler:P.renderGraphicChild},Pie:{handler:P.renderGraphicChild},Funnel:{handler:P.renderGraphicChild},Tooltip:{handler:P.renderCursor,once:!0},PolarGrid:{handler:P.renderPolarGrid,once:!0},PolarAngleAxis:{handler:P.renderPolarAxis},PolarRadiusAxis:{handler:P.renderPolarAxis},Customized:{handler:P.renderCustomized}}),P.clipPathId="".concat((C=N.id)!==null&&C!==void 0?C:hu("recharts"),"-clip"),P.throttleTriggeredAfterMouseMove=i3(P.triggeredAfterMouseMove,(O=N.throttleDelay)!==null&&O!==void 0?O:1e3/60),P.state={},P}return Ale(j,w),Ple(j,[{key:"componentDidMount",value:function(){var C,O;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(C=this.props.margin.left)!==null&&C!==void 0?C:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var C=this.props,O=C.children,P=C.data,E=C.height,T=C.layout,A=ea(O,ta);if(A){var M=A.props.defaultIndex;if(!(typeof M!="number"||M<0||M>this.state.tooltipTicks.length-1)){var R=this.state.tooltipTicks[M]&&this.state.tooltipTicks[M].value,L=RN(this.state,P,M,R),V=this.state.tooltipTicks[M].coordinate,z=(this.state.offset.top+E)/2,G=T==="horizontal",H=G?{x:V,y:z}:{y:V,x:z},W=this.state.formattedGraphicalItems.find(function(I){var Y=I.item;return Y.type.name==="Scatter"});W&&(H=Ne(Ne({},H),W.props.points[M].tooltipPosition),L=W.props.points[M].tooltipPayload);var q={activeTooltipIndex:M,isTooltipActive:!0,activeLabel:R,activePayload:L,activeCoordinate:H};this.setState(q),this.renderCursor(A),this.accessibilityManager.setIndex(M)}}}},{key:"getSnapshotBeforeUpdate",value:function(C,O){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==O.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==C.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==C.margin){var P,E;this.accessibilityManager.setDetails({offset:{left:(P=this.props.margin.left)!==null&&P!==void 0?P:0,top:(E=this.props.margin.top)!==null&&E!==void 0?E:0}})}return null}},{key:"componentDidUpdate",value:function(C){yj([ea(C.children,ta)],[ea(this.props.children,ta)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var C=ea(this.props.children,ta);if(C&&typeof C.props.shared=="boolean"){var O=C.props.shared?"axis":"item";return l.indexOf(O)>=0?O:i}return i}},{key:"getMouseInfo",value:function(C){if(!this.container)return null;var O=this.container,P=O.getBoundingClientRect(),E=eX(P),T={chartX:Math.round(C.pageX-E.left),chartY:Math.round(C.pageY-E.top)},A=P.width/O.offsetWidth||1,M=this.inRange(T.chartX,T.chartY,A);if(!M)return null;var R=this.state,L=R.xAxisMap,V=R.yAxisMap,z=this.getTooltipEventType(),G=aD(this.state,this.props.data,this.props.layout,M);if(z!=="axis"&&L&&V){var H=Di(L).scale,W=Di(V).scale,q=H&&H.invert?H.invert(T.chartX):null,I=W&&W.invert?W.invert(T.chartY):null;return Ne(Ne({},T),{},{xValue:q,yValue:I},G)}return G?Ne(Ne({},T),G):null}},{key:"inRange",value:function(C,O){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,E=this.props.layout,T=C/P,A=O/P;if(E==="horizontal"||E==="vertical"){var M=this.state.offset,R=T>=M.left&&T<=M.left+M.width&&A>=M.top&&A<=M.top+M.height;return R?{x:T,y:A}:null}var L=this.state,V=L.angleAxisMap,z=L.radiusAxisMap;if(V&&z){var G=Di(V);return cM({x:T,y:A},G)}return null}},{key:"parseEventsOfWrapper",value:function(){var C=this.props.children,O=this.getTooltipEventType(),P=ea(C,ta),E={};P&&O==="axis"&&(P.props.trigger==="click"?E={onClick:this.handleClick}:E={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var T=Jp(this.props,this.handleOuterEvent);return Ne(Ne({},T),E)}},{key:"addListener",value:function(){AS.on(IS,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){AS.removeListener(IS,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(C,O,P){for(var E=this.state.formattedGraphicalItems,T=0,A=E.length;Ttypeof r=="string"?r.trim():"").filter(Boolean);return t.length?t.join("; "):null}if(typeof e=="object"){const t=e,r=typeof t.message=="string"?t.message.trim():"";if(r)return r;const n=typeof t.details=="string"?t.details.trim():"";if(n)return n}return null}function cD(e){if(Array.isArray(e))return{items:e,totalCount:e.length};if(!e||typeof e!="object")return e;const t=e,r="TotalCount"in t||"Items"in t,n="totalCount"in t||"items"in t;if(r&&!n)return{...t,totalCount:t.TotalCount,items:t.Items};if(!("items"in t)&&Array.isArray(t.data)&&typeof t.totalCount=="number")return{...t,items:t.data};if(!("items"in t)&&Array.isArray(t.Data)&&typeof t.TotalCount=="number")return{...t,totalCount:t.TotalCount,items:t.Data};if(Array.isArray(t.items)&&typeof t.totalCount!="number"){const a=t.TotalCount;return{...t,totalCount:typeof a=="number"?a:t.items.length}}return e}function _r(e={}){const t=e.baseUrl??"http://flus-test.3ffoodsafety.com"??"http://localhost:19001",r=e.getToken;async function n(a){const i=a.prefix??"/api/app",s=Xle(t,`${i}${a.path}${Jle(a.query??{})}`),l={"Content-Type":"application/json"},d=r?.();d&&(l.Authorization=`Bearer ${d}`);const u=await fetch(s,{method:a.method,headers:l,body:a.body===void 0?void 0:JSON.stringify(a.body),signal:a.signal}),p=(u.headers.get("content-type")??"").includes("application/json")?await u.json().catch(()=>null):await u.text().catch(()=>"");if(!u.ok){const v=sD(p)??(typeof p=="string"&&p.trim()?p:"Request failed.");throw new Yr(v,u.status,p)}if(p&&typeof p=="object"&&"data"in p){const g=p,v=typeof g.statusCode=="number"?g.statusCode:u.status;if(g.succeeded===!1||v>=400){const w=g.error?.message?.trim()||lD(g.errors)||sD(p)||lD(p?.errors)||"Request failed.";throw new Yr(w,v||400,p)}return cD(g.data??null)}return cD(p)}return{requestJson:n}}const Qle=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Zle="/dashboard/overview";function Xo(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:t}function js(e){if(!e||typeof e!="object")return{key:"",title:"",value:0,previousValue:0,changeValue:0,changeRate:0};const t=e;return{key:String(t.key??t.Key??""),title:String(t.title??t.Title??""),value:Xo(t.value??t.Value,0),previousValue:Xo(t.previousValue??t.PreviousValue,0),changeValue:Xo(t.changeValue??t.ChangeValue,0),changeRate:Xo(t.changeRate??t.ChangeRate,0)}}function ece(e){if(!e||typeof e!="object")return null;const t=e,r=String(t.date??t.Date??"");return r?{date:r,value:Xo(t.value??t.Value,0)}:null}function uD(e){if(!e||typeof e!="object")return null;const t=e,r=String(t.categoryId??t.CategoryId??""),n=String(t.categoryName??t.CategoryName??"");return{categoryId:r,categoryName:n,count:Xo(t.count??t.Count,0),ratio:Xo(t.ratio??t.Ratio,0)}}function Ns(e,t,r,n=""){const a=e[t]??e[r];return a==null?n:String(a)}function tce(e){if(!e||typeof e!="object")return null;const t=e,r=Ns(t,"taskId","TaskId",""),n=Ns(t,"labelCode","LabelCode",""),a=Ns(t,"displayName","DisplayName",""),i=Ns(t,"printedAt","PrintedAt",""),s=Ns(t,"status","Status","active"),l=Ns(t,"labelTypeBadge","LabelTypeBadge",""),d=Ns(t,"printedByName","PrintedByName",""),u=t.printedByUserId??t.PrintedByUserId,f=u==null?null:String(u);return!r&&!n?null:{taskId:r||n,labelCode:n||"—",displayName:a||"—",printedByUserId:f,printedByName:d||"—",printedAt:i,status:s||"active",labelTypeBadge:l||"—"}}function rce(e){if(!e||typeof e!="object")return nce();const t=e,r=t.weeklyPrintVolume??t.WeeklyPrintVolume,n=Array.isArray(r)?r:[],a=t.byCategory??t.ByCategory,i=t.categoryDistribution??t.CategoryDistribution,s=Array.isArray(a)&&a.length?a:Array.isArray(i)?i:[],l=t.byCategoryTotal??t.ByCategoryTotal??t.categoryDistributionTotal??t.CategoryDistributionTotal,d=Xo(l,0),u=t.recentLabels??t.RecentLabels,f=Array.isArray(u)?u:[];return{labelsPrintedToday:js(t.labelsPrintedToday??t.LabelsPrintedToday),activeTemplates:js(t.activeTemplates??t.ActiveTemplates),activeUsers:js(t.activeUsers??t.ActiveUsers),locations:js(t.locations??t.Locations),people:js(t.people??t.People),products:js(t.products??t.Products),weeklyPrintVolume:n.map(ece).filter(h=>h!==null),byCategory:s.map(uD).filter(h=>h!==null),byCategoryTotal:Number.isFinite(d)?d:0,recentLabels:f.map(tce).filter(h=>h!==null),generatedAt:t.generatedAt??t.GeneratedAt??null,metricCards:Array.isArray(t.metricCards??t.MetricCards)?(t.metricCards??t.MetricCards).map(js):void 0,categoryDistribution:Array.isArray(t.categoryDistribution??t.CategoryDistribution)?(t.categoryDistribution??t.CategoryDistribution).map(uD).filter(Boolean):void 0,categoryDistributionTotal:Xo(t.categoryDistributionTotal??t.CategoryDistributionTotal,0)}}function Kl(e,t){return{key:e,title:t,value:0,previousValue:0,changeValue:0,changeRate:0}}function nce(){return{labelsPrintedToday:Kl("labelsPrintedToday","Labels Printed Today"),activeTemplates:Kl("activeTemplates","Active Templates"),activeUsers:Kl("activeUsers","Active Users"),locations:Kl("locations","Locations"),people:Kl("people","People"),products:Kl("products","Products"),weeklyPrintVolume:[],byCategory:[],byCategoryTotal:0,recentLabels:[],generatedAt:null}}async function ace(e){const t=await Qle.requestJson({path:Zle,method:"GET",signal:e});return rce(t)}const dD=["#3b82f6","#f59e0b","#6366f1","#10b981","#ec4899","#8b5cf6","#14b8a6"];function oce(e){const t=(e.labelTypeBadge||"").trim();if(t&&t!=="—")return t.length>=2?t.slice(0,2):`${t} `.slice(0,2);const r=(e.displayName||"").trim();return r&&r!=="—"?r.slice(0,2):"LB"}function ice(e){return(e.status||"").toLowerCase()==="expired"}function sce(e){const t=e?new Date(e):new Date;return Number.isFinite(t.getTime())?t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}):new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function fD(e){if(!e)return"—";const t=new Date(e).getTime();if(!Number.isFinite(t))return"—";const r=Math.max(0,Math.round((Date.now()-t)/1e3));return r<60?"Just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} hr ago`:`${Math.floor(r/86400)} day(s) ago`}function lce(e){const t=e.changeRate;return`${t>0?"+":""}${t.toFixed(1)}%`}function qm(e){const t=e.changeValue;return t===0?"No change":`${t>0?"+":""}${t} New`}function cce(e){return e.changeValue===0?"Stable":`${e.changeValue>0?"+":""}${e.changeValue} New`}function uce(e){return e.changeRate>0||e.changeRate===0&&e.changeValue>=0}function jd(e){return e.changeValue>=0}function dce(e){const t=e.weeklyPrintVolume??[];if(t.length)return t.map(n=>({date:n.date,day:new Date(`${n.date}T12:00:00`).toLocaleDateString("en-US",{weekday:"short"}),labels:n.value}));const r=[];for(let n=6;n>=0;n--){const a=new Date;a.setHours(12,0,0,0),a.setDate(a.getDate()-n);const i=a.toISOString().slice(0,10);r.push({date:i,day:a.toLocaleDateString("en-US",{weekday:"short"}),labels:0})}return r}function fce({onNewLabel:e,onViewReports:t,onViewAllRecentLabels:r}={}){const[n,a]=U.useState(null),[i,s]=U.useState(!0),l=U.useCallback(async()=>{s(!0);try{const g=await ace();a(g)}catch(g){console.error(g),ee.error(g instanceof Error?g.message:"Failed to load dashboard"),a(null)}finally{s(!1)}},[]);U.useEffect(()=>{l()},[l]);const d=U.useMemo(()=>n?dce(n):[],[n]),u=U.useMemo(()=>n?.byCategory?.length?n.byCategory.map((g,v)=>({id:g.categoryId||`cat-${v}`,name:g.categoryName||"—",value:g.count,color:dD[v%dD.length]})):[],[n]),f=n?.recentLabels??[],h=n?.byCategoryTotal??0,p=n?.generatedAt;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"bg-white border border-gray-200 p-4 rounded-xl shadow-sm flex flex-col md:flex-row justify-between items-center gap-4",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold text-gray-900",children:"Dashboard Overview"}),o.jsx("p",{className:"text-sm text-gray-500",children:"Welcome back, Admin. Here's what's happening today."}),o.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[sce(p)," | Last updated: ",i?"…":fD(p)]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ce,{type:"button",className:"bg-blue-600 text-white hover:bg-blue-700 font-medium",onClick:()=>e?.(),children:[o.jsx(Un,{className:"w-4 h-4 mr-2"})," New Label"]}),o.jsx(ce,{type:"button",variant:"outline",onClick:()=>t?.(),children:"View Reports"})]})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:i||!n?o.jsx(o.Fragment,{children:Array.from({length:6}).map((g,v)=>o.jsx(wn,{className:"border-gray-200 shadow-sm",children:o.jsxs(Dn,{className:"p-6 space-y-3",children:[o.jsx(uo,{className:"h-4 w-32"}),o.jsx(uo,{className:"h-8 w-20"}),o.jsx(uo,{className:"h-4 w-40"})]})},v))}):o.jsxs(o.Fragment,{children:[o.jsx(Xl,{title:n.labelsPrintedToday.title||"Labels Printed Today",value:String(n.labelsPrintedToday.value),trend:lce(n.labelsPrintedToday),trendUp:uce(n.labelsPrintedToday),icon:_$,color:"text-blue-600",bgColor:"bg-blue-50"}),o.jsx(Xl,{title:n.activeTemplates.title||"Active Templates",value:String(n.activeTemplates.value),trend:qm(n.activeTemplates),trendUp:jd(n.activeTemplates),icon:zs,color:"text-indigo-600",bgColor:"bg-indigo-50"}),o.jsx(Xl,{title:n.activeUsers.title||"Active Users",value:String(n.activeUsers.value),trend:cce(n.activeUsers),trendUp:jd(n.activeUsers),icon:my,color:"text-emerald-600",bgColor:"bg-emerald-50"}),o.jsx(Xl,{title:n.locations.title||"Locations",value:String(n.locations.value),trend:qm(n.locations),trendUp:jd(n.locations),icon:lu,color:"text-sky-600",bgColor:"bg-sky-50"}),o.jsx(Xl,{title:n.people.title||"People",value:String(n.people.value),trend:qm(n.people),trendUp:jd(n.people),icon:gq,color:"text-violet-600",bgColor:"bg-violet-50"}),o.jsx(Xl,{title:n.products.title||"Products",value:String(n.products.value),trend:qm(n.products),trendUp:jd(n.products),icon:jc,color:"text-amber-600",bgColor:"bg-amber-50"})]})}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[o.jsxs(wn,{className:"shadow-sm border-gray-200",children:[o.jsxs(Na,{children:[o.jsxs(Ca,{className:"text-base font-bold text-gray-800 flex items-center gap-2",children:[o.jsx(u7,{className:"w-5 h-5 text-gray-500"}),"Weekly Print Volume"]}),o.jsx(Hd,{children:"Number of labels printed over the last 7 days"})]}),o.jsx(Dn,{children:i?o.jsx("div",{className:"h-[300px] w-full flex items-center justify-center",children:o.jsx(uo,{className:"h-[240px] w-full"})}):o.jsx("div",{className:"h-[300px] w-full",children:o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(_F,{data:d,children:[o.jsx(Gg,{strokeDasharray:"3 3",vertical:!1,stroke:"#e5e7eb"}),o.jsx(Ys,{dataKey:"day",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12},dy:10}),o.jsx(Ks,{axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),o.jsx(ta,{labelFormatter:(g,v)=>v?.[0]?.payload?.date??"",contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"},cursor:{stroke:"#d1d5db",strokeWidth:1}}),o.jsx(xu,{type:"monotone",dataKey:"labels",stroke:"#2563eb",strokeWidth:3,dot:{r:4,fill:"#2563eb",strokeWidth:2,stroke:"#fff"},activeDot:{r:6}})]})})})})]}),o.jsxs(wn,{className:"shadow-sm border-gray-200",children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs(Ca,{className:"text-base font-bold text-gray-800 flex items-center gap-2",children:[o.jsx(Cc,{className:"w-5 h-5 text-gray-500"}),"Recent Labels"]}),o.jsx(Hd,{children:"Latest printed labels across all locations"})]}),o.jsx(ce,{type:"button",variant:"ghost",size:"sm",className:"text-blue-600",onClick:()=>r?.(),children:"View All"})]}),o.jsx(Dn,{children:i?o.jsx("div",{className:"space-y-4",children:Array.from({length:5}).map((g,v)=>o.jsx("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg border border-gray-100",children:o.jsxs("div",{className:"flex items-center gap-3 w-full",children:[o.jsx(uo,{className:"h-10 w-10 rounded-full shrink-0"}),o.jsxs("div",{className:"space-y-2 flex-1 min-w-0",children:[o.jsx(uo,{className:"h-4 w-2/3 max-w-xs"}),o.jsx(uo,{className:"h-3 w-1/2 max-w-sm"})]}),o.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[o.jsx(uo,{className:"h-3 w-16"}),o.jsx(uo,{className:"h-6 w-16 rounded-md"})]})]})},v))}):f.length===0?o.jsx("div",{className:"py-10 text-center text-sm text-gray-500",children:"No recent labels. Printed labels will appear here."}):o.jsx("div",{className:"space-y-4",children:f.map((g,v)=>{const b=ice(g);return o.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg border border-gray-100 hover:bg-gray-100 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 font-bold text-xs shrink-0",title:g.labelTypeBadge||void 0,children:oce(g)}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:g.displayName||"—"}),o.jsxs("p",{className:"text-xs text-gray-500 truncate",children:[g.labelCode||"—"," • ",g.printedByName||"—"]})]})]}),o.jsxs("div",{className:"flex items-center gap-4 shrink-0 ml-2",children:[o.jsx("span",{className:"text-xs text-gray-500 font-medium whitespace-nowrap",children:fD(g.printedAt||null)}),o.jsx(fn,{variant:"secondary",className:b?"bg-red-100 text-red-700":"bg-green-100 text-green-700",children:g.status||"—"})]})]},`${g.taskId}-${v}`)})})})]})]}),o.jsx("div",{className:"space-y-6",children:o.jsxs(wn,{className:"shadow-sm border-gray-200",children:[o.jsx(Na,{children:o.jsxs(Ca,{className:"text-base font-bold text-gray-800 flex items-center gap-2",children:[o.jsx(jc,{className:"w-5 h-5 text-gray-500"}),"By Category"]})}),o.jsx(Dn,{children:i?o.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:o.jsx(uo,{className:"h-[160px] w-[160px] rounded-full"})}):u.length===0?o.jsx("div",{className:"h-[200px] flex flex-col items-center justify-center text-sm text-gray-500",children:"No category distribution"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"h-[200px] relative",children:[o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(Kle,{children:[o.jsx(di,{data:u,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"value",children:u.map((g,v)=>o.jsx(Ty,{fill:g.color},`cell-${v}`))}),o.jsx(ta,{})]})}),o.jsxs("div",{className:"absolute inset-0 flex items-center justify-center flex-col pointer-events-none",children:[o.jsx("span",{className:"text-2xl font-bold text-gray-900",children:h}),o.jsx("span",{className:"text-xs text-gray-500",children:"Total"})]})]}),o.jsx("div",{className:"mt-4 space-y-2",children:u.map(g=>o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:g.color}}),o.jsx("span",{className:"text-gray-600",children:g.name})]}),o.jsx("span",{className:"font-medium text-gray-900",children:g.value})]},g.id))})]})})]})})]})]})}function Xl({title:e,value:t,trend:r,trendUp:n,icon:a,color:i,bgColor:s}){return o.jsx(wn,{className:"border-gray-200 shadow-sm hover:shadow-md transition-shadow",children:o.jsxs(Dn,{className:"p-6",children:[o.jsxs("div",{className:"flex justify-between items-start",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-gray-500 mb-1",children:e}),o.jsx("h3",{className:"text-2xl font-bold text-gray-900",children:t})]}),o.jsx("div",{className:`p-2 rounded-lg ${s}`,children:o.jsx(a,{className:`w-5 h-5 ${i}`})})]}),o.jsxs("div",{className:"mt-4 flex items-center text-sm",children:[n?o.jsx(S$,{className:"w-4 h-4 text-green-500 mr-1 shrink-0"}):o.jsx(Q9,{className:"w-4 h-4 text-red-500 mr-1 shrink-0"}),o.jsx("span",{className:n?"text-green-600 font-medium":"text-red-600 font-medium",children:r}),o.jsx("span",{className:"text-gray-400 ml-1",children:"Vs. last period"})]})]})})}function hce({title:e}){return o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[1,2,3,4].map(t=>o.jsxs(wn,{children:[o.jsx(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:o.jsxs(Ca,{className:"text-sm font-medium",children:["Metric ",t]})}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:"000"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"+0.0% from last month"})]})]},t))}),o.jsx(wn,{className:"min-h-[400px] flex items-center justify-center border-dashed",children:o.jsxs("div",{className:"text-center text-muted-foreground",children:[o.jsxs("h3",{className:"text-lg font-medium",children:[e," Module"]}),o.jsx("p",{children:"This module is currently under development."})]})})]})}function hn({className:e,...t}){return o.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:o.jsx("table",{"data-slot":"table",className:Ie("w-full caption-bottom text-sm",e),...t})})}function mn({className:e,...t}){return o.jsx("thead",{"data-slot":"table-header",className:Ie("[&_tr]:border-b",e),...t})}function pn({className:e,...t}){return o.jsx("tbody",{"data-slot":"table-body",className:Ie("[&_tr:last-child]:border-0",e),...t})}function nt({className:e,...t}){return o.jsx("tr",{"data-slot":"table-row",className:Ie("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...t})}function Ee({className:e,...t}){return o.jsx("th",{"data-slot":"table-head",className:Ie("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}function ye({className:e,...t}){return o.jsx("td",{"data-slot":"table-cell",className:Ie("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}function hD(e){const t=mce(e),r=x.forwardRef((n,a)=>{const{children:i,...s}=n,l=x.Children.toArray(i),d=l.find(gce);if(d){const u=d.props.children,f=l.map(h=>h===d?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:h);return o.jsx(t,{...s,ref:a,children:x.isValidElement(u)?x.cloneElement(u,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function mce(e){const t=x.forwardRef((r,n)=>{const{children:a,...i}=r;if(x.isValidElement(a)){const s=vce(a),l=yce(i,a.props);return a.type!==x.Fragment&&(l.ref=n?Oa(n,s):s),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pce=Symbol("radix.slottable");function gce(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pce}function yce(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function vce(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function EF(e){const t=e+"CollectionProvider",[r,n]=Eo(t),[a,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=b=>{const{scope:w,children:j}=b,N=U.useRef(null),C=U.useRef(new Map).current;return o.jsx(a,{scope:w,itemMap:C,collectionRef:N,children:j})};s.displayName=t;const l=e+"CollectionSlot",d=hD(l),u=U.forwardRef((b,w)=>{const{scope:j,children:N}=b,C=i(l,j),O=At(w,C.collectionRef);return o.jsx(d,{ref:O,children:N})});u.displayName=l;const f=e+"CollectionItemSlot",h="data-radix-collection-item",p=hD(f),g=U.forwardRef((b,w)=>{const{scope:j,children:N,...C}=b,O=U.useRef(null),P=At(w,O),E=i(f,j);return U.useEffect(()=>(E.itemMap.set(O,{ref:O,...C}),()=>void E.itemMap.delete(O))),o.jsx(p,{[h]:"",ref:P,children:N})});g.displayName=f;function v(b){const w=i(e+"CollectionConsumer",b);return U.useCallback(()=>{const N=w.collectionRef.current;if(!N)return[];const C=Array.from(N.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((E,T)=>C.indexOf(E.ref.current)-C.indexOf(T.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:s,Slot:u,ItemSlot:g},v,n]}function xce(e,t=globalThis?.document){const r=dn(e);x.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var bce="DismissableLayer",DN="dismissableLayer.update",wce="dismissableLayer.pointerDownOutside",Sce="dismissableLayer.focusOutside",mD,PF=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tv=x.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:s,onDismiss:l,...d}=e,u=x.useContext(PF),[f,h]=x.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=x.useState({}),v=At(t,T=>h(T)),b=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),j=b.indexOf(w),N=f?b.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,O=N>=j,P=Cce(T=>{const A=T.target,M=[...u.branches].some(R=>R.contains(A));!O||M||(a?.(T),s?.(T),T.defaultPrevented||l?.())},p),E=_ce(T=>{const A=T.target;[...u.branches].some(R=>R.contains(A))||(i?.(T),s?.(T),T.defaultPrevented||l?.())},p);return xce(T=>{N===u.layers.size-1&&(n?.(T),!T.defaultPrevented&&l&&(T.preventDefault(),l()))},p),x.useEffect(()=>{if(f)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(mD=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),pD(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=mD)}},[f,p,r,u]),x.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),pD())},[f,u]),x.useEffect(()=>{const T=()=>g({});return document.addEventListener(DN,T),()=>document.removeEventListener(DN,T)},[]),o.jsx(lt.div,{...d,ref:v,style:{pointerEvents:C?O?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,P.onPointerDownCapture)})});tv.displayName=bce;var jce="DismissableLayerBranch",Nce=x.forwardRef((e,t)=>{const r=x.useContext(PF),n=x.useRef(null),a=At(t,n);return x.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),o.jsx(lt.div,{...e,ref:a})});Nce.displayName=jce;function Cce(e,t=globalThis?.document){const r=dn(e),n=x.useRef(!1),a=x.useRef(()=>{});return x.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let d=function(){OF(wce,r,u,{discrete:!0})};const u={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=d,t.addEventListener("click",a.current,{once:!0})):d()}else t.removeEventListener("click",a.current);n.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function _ce(e,t=globalThis?.document){const r=dn(e),n=x.useRef(!1);return x.useEffect(()=>{const a=i=>{i.target&&!n.current&&OF(Sce,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function pD(){const e=new CustomEvent(DN);document.dispatchEvent(e)}function OF(e,t,r,{discrete:n}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),n?pV(a,i):a.dispatchEvent(i)}var RS=0;function S_(){x.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??gD()),document.body.insertAdjacentElement("beforeend",e[1]??gD()),RS++,()=>{RS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),RS--}},[])}function gD(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var DS="focusScope.autoFocusOnMount",LS="focusScope.autoFocusOnUnmount",yD={bubbles:!1,cancelable:!0},Ece="FocusScope",rv=x.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...s}=e,[l,d]=x.useState(null),u=dn(a),f=dn(i),h=x.useRef(null),p=At(t,b=>d(b)),g=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(n){let b=function(C){if(g.paused||!l)return;const O=C.target;l.contains(O)?h.current=O:Mi(h.current,{select:!0})},w=function(C){if(g.paused||!l)return;const O=C.relatedTarget;O!==null&&(l.contains(O)||Mi(h.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const P of C)P.removedNodes.length>0&&Mi(l)};document.addEventListener("focusin",b),document.addEventListener("focusout",w);const N=new MutationObserver(j);return l&&N.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",w),N.disconnect()}}},[n,l,g.paused]),x.useEffect(()=>{if(l){xD.add(g);const b=document.activeElement;if(!l.contains(b)){const j=new CustomEvent(DS,yD);l.addEventListener(DS,u),l.dispatchEvent(j),j.defaultPrevented||(Pce(Ice(TF(l)),{select:!0}),document.activeElement===b&&Mi(l))}return()=>{l.removeEventListener(DS,u),setTimeout(()=>{const j=new CustomEvent(LS,yD);l.addEventListener(LS,f),l.dispatchEvent(j),j.defaultPrevented||Mi(b??document.body,{select:!0}),l.removeEventListener(LS,f),xD.remove(g)},0)}}},[l,u,f,g]);const v=x.useCallback(b=>{if(!r&&!n||g.paused)return;const w=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,j=document.activeElement;if(w&&j){const N=b.currentTarget,[C,O]=Oce(N);C&&O?!b.shiftKey&&j===O?(b.preventDefault(),r&&Mi(C,{select:!0})):b.shiftKey&&j===C&&(b.preventDefault(),r&&Mi(O,{select:!0})):j===N&&b.preventDefault()}},[r,n,g.paused]);return o.jsx(lt.div,{tabIndex:-1,...s,ref:p,onKeyDown:v})});rv.displayName=Ece;function Pce(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(Mi(n,{select:t}),document.activeElement!==r)return}function Oce(e){const t=TF(e),r=vD(t,e),n=vD(t.reverse(),e);return[r,n]}function TF(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function vD(e,t){for(const r of e)if(!Tce(r,{upTo:t}))return r}function Tce(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function kce(e){return e instanceof HTMLInputElement&&"select"in e}function Mi(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&kce(e)&&t&&e.select()}}var xD=Ace();function Ace(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=bD(e,t),e.unshift(t)},remove(t){e=bD(e,t),e[0]?.resume()}}}function bD(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function Ice(e){return e.filter(t=>t.tagName!=="A")}var Mce=aC[" useId ".trim().toString()]||(()=>{}),Rce=0;function Bn(e){const[t,r]=x.useState(Mce());return kr(()=>{r(n=>n??String(Rce++))},[e]),e||(t?`radix-${t}`:"")}const Dce=["top","right","bottom","left"],qi=Math.min,na=Math.max,Qg=Math.round,Vm=Math.floor,bo=e=>({x:e,y:e}),Lce={left:"right",right:"left",bottom:"top",top:"bottom"},$ce={start:"end",end:"start"};function LN(e,t,r){return na(e,qi(t,r))}function ii(e,t){return typeof e=="function"?e(t):e}function si(e){return e.split("-")[0]}function bu(e){return e.split("-")[1]}function j_(e){return e==="x"?"y":"x"}function N_(e){return e==="y"?"height":"width"}const Fce=new Set(["top","bottom"]);function go(e){return Fce.has(si(e))?"y":"x"}function C_(e){return j_(go(e))}function Bce(e,t,r){r===void 0&&(r=!1);const n=bu(e),a=C_(e),i=N_(a);let s=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Zg(s)),[s,Zg(s)]}function zce(e){const t=Zg(e);return[$N(e),t,$N(t)]}function $N(e){return e.replace(/start|end/g,t=>$ce[t])}const wD=["left","right"],SD=["right","left"],Uce=["top","bottom"],qce=["bottom","top"];function Vce(e,t,r){switch(e){case"top":case"bottom":return r?t?SD:wD:t?wD:SD;case"left":case"right":return t?Uce:qce;default:return[]}}function Wce(e,t,r,n){const a=bu(e);let i=Vce(si(e),r==="start",n);return a&&(i=i.map(s=>s+"-"+a),t&&(i=i.concat(i.map($N)))),i}function Zg(e){return e.replace(/left|right|bottom|top/g,t=>Lce[t])}function Hce(e){return{top:0,right:0,bottom:0,left:0,...e}}function kF(e){return typeof e!="number"?Hce(e):{top:e,right:e,bottom:e,left:e}}function ey(e){const{x:t,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:t,right:t+n,bottom:r+a,x:t,y:r}}function jD(e,t,r){let{reference:n,floating:a}=e;const i=go(t),s=C_(t),l=N_(s),d=si(t),u=i==="y",f=n.x+n.width/2-a.width/2,h=n.y+n.height/2-a.height/2,p=n[l]/2-a[l]/2;let g;switch(d){case"top":g={x:f,y:n.y-a.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:h};break;case"left":g={x:n.x-a.width,y:h};break;default:g={x:n.x,y:n.y}}switch(bu(t)){case"start":g[s]-=p*(r&&u?-1:1);break;case"end":g[s]+=p*(r&&u?-1:1);break}return g}async function Gce(e,t){var r;t===void 0&&(t={});const{x:n,y:a,platform:i,rects:s,elements:l,strategy:d}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:p=!1,padding:g=0}=ii(t,e),v=kF(g),w=l[p?h==="floating"?"reference":"floating":h],j=ey(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(w)))==null||r?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:u,rootBoundary:f,strategy:d})),N=h==="floating"?{x:n,y:a,width:s.floating.width,height:s.floating.height}:s.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),O=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},P=ey(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:N,offsetParent:C,strategy:d}):N);return{top:(j.top-P.top+v.top)/O.y,bottom:(P.bottom-j.bottom+v.bottom)/O.y,left:(j.left-P.left+v.left)/O.x,right:(P.right-j.right+v.right)/O.x}}const Yce=async(e,t,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:i=[],platform:s}=r,l=i.filter(Boolean),d=await(s.isRTL==null?void 0:s.isRTL(t));let u=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:f,y:h}=jD(u,n,d),p=n,g={},v=0;for(let w=0;w({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:a,rects:i,platform:s,elements:l,middlewareData:d}=t,{element:u,padding:f=0}=ii(e,t)||{};if(u==null)return{};const h=kF(f),p={x:r,y:n},g=C_(a),v=N_(g),b=await s.getDimensions(u),w=g==="y",j=w?"top":"left",N=w?"bottom":"right",C=w?"clientHeight":"clientWidth",O=i.reference[v]+i.reference[g]-p[g]-i.floating[v],P=p[g]-i.reference[g],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u));let T=E?E[C]:0;(!T||!await(s.isElement==null?void 0:s.isElement(E)))&&(T=l.floating[C]||i.floating[v]);const A=O/2-P/2,M=T/2-b[v]/2-1,R=qi(h[j],M),L=qi(h[N],M),V=R,z=T-b[v]-L,G=T/2-b[v]/2+A,H=LN(V,G,z),W=!d.arrow&&bu(a)!=null&&G!==H&&i.reference[v]/2-(GG<=0)){var L,V;const G=(((L=i.flip)==null?void 0:L.index)||0)+1,H=T[G];if(H&&(!(h==="alignment"?N!==go(H):!1)||R.every(I=>go(I.placement)===N?I.overflows[0]>0:!0)))return{data:{index:G,overflows:R},reset:{placement:H}};let W=(V=R.filter(q=>q.overflows[0]<=0).sort((q,I)=>q.overflows[1]-I.overflows[1])[0])==null?void 0:V.placement;if(!W)switch(g){case"bestFit":{var z;const q=(z=R.filter(I=>{if(E){const Y=go(I.placement);return Y===N||Y==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(Y=>Y>0).reduce((Y,F)=>Y+F,0)]).sort((I,Y)=>I[1]-Y[1])[0])==null?void 0:z[0];q&&(W=q);break}case"initialPlacement":W=l;break}if(a!==W)return{reset:{placement:W}}}return{}}}};function ND(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function CD(e){return Dce.some(t=>e[t]>=0)}const Jce=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:a="referenceHidden",...i}=ii(e,t);switch(a){case"referenceHidden":{const s=await n.detectOverflow(t,{...i,elementContext:"reference"}),l=ND(s,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:CD(l)}}}case"escaped":{const s=await n.detectOverflow(t,{...i,altBoundary:!0}),l=ND(s,r.floating);return{data:{escapedOffsets:l,escaped:CD(l)}}}default:return{}}}}},AF=new Set(["left","top"]);async function Qce(e,t){const{placement:r,platform:n,elements:a}=e,i=await(n.isRTL==null?void 0:n.isRTL(a.floating)),s=si(r),l=bu(r),d=go(r)==="y",u=AF.has(s)?-1:1,f=i&&d?-1:1,h=ii(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:v}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof v=="number"&&(g=l==="end"?v*-1:v),d?{x:g*f,y:p*u}:{x:p*u,y:g*f}}const Zce=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:a,y:i,placement:s,middlewareData:l}=t,d=await Qce(t,e);return s===((r=l.offset)==null?void 0:r.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:i+d.y,data:{...d,placement:s}}}}},eue=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:a,platform:i}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:d={fn:j=>{let{x:N,y:C}=j;return{x:N,y:C}}},...u}=ii(e,t),f={x:r,y:n},h=await i.detectOverflow(t,u),p=go(si(a)),g=j_(p);let v=f[g],b=f[p];if(s){const j=g==="y"?"top":"left",N=g==="y"?"bottom":"right",C=v+h[j],O=v-h[N];v=LN(C,v,O)}if(l){const j=p==="y"?"top":"left",N=p==="y"?"bottom":"right",C=b+h[j],O=b-h[N];b=LN(C,b,O)}const w=d.fn({...t,[g]:v,[p]:b});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[g]:s,[p]:l}}}}}},tue=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:a,rects:i,middlewareData:s}=t,{offset:l=0,mainAxis:d=!0,crossAxis:u=!0}=ii(e,t),f={x:r,y:n},h=go(a),p=j_(h);let g=f[p],v=f[h];const b=ii(l,t),w=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(d){const C=p==="y"?"height":"width",O=i.reference[p]-i.floating[C]+w.mainAxis,P=i.reference[p]+i.reference[C]-w.mainAxis;gP&&(g=P)}if(u){var j,N;const C=p==="y"?"width":"height",O=AF.has(si(a)),P=i.reference[h]-i.floating[C]+(O&&((j=s.offset)==null?void 0:j[h])||0)+(O?0:w.crossAxis),E=i.reference[h]+i.reference[C]+(O?0:((N=s.offset)==null?void 0:N[h])||0)-(O?w.crossAxis:0);vE&&(v=E)}return{[p]:g,[h]:v}}}},rue=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:a,rects:i,platform:s,elements:l}=t,{apply:d=()=>{},...u}=ii(e,t),f=await s.detectOverflow(t,u),h=si(a),p=bu(a),g=go(a)==="y",{width:v,height:b}=i.floating;let w,j;h==="top"||h==="bottom"?(w=h,j=p===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(j=h,w=p==="end"?"top":"bottom");const N=b-f.top-f.bottom,C=v-f.left-f.right,O=qi(b-f[w],N),P=qi(v-f[j],C),E=!t.middlewareData.shift;let T=O,A=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(A=C),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(T=N),E&&!p){const R=na(f.left,0),L=na(f.right,0),V=na(f.top,0),z=na(f.bottom,0);g?A=v-2*(R!==0||L!==0?R+L:na(f.left,f.right)):T=b-2*(V!==0||z!==0?V+z:na(f.top,f.bottom))}await d({...t,availableWidth:A,availableHeight:T});const M=await s.getDimensions(l.floating);return v!==M.width||b!==M.height?{reset:{rects:!0}}:{}}}};function nv(){return typeof window<"u"}function wu(e){return IF(e)?(e.nodeName||"").toLowerCase():"#document"}function fa(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ko(e){var t;return(t=(IF(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function IF(e){return nv()?e instanceof Node||e instanceof fa(e).Node:!1}function Xa(e){return nv()?e instanceof Element||e instanceof fa(e).Element:!1}function jo(e){return nv()?e instanceof HTMLElement||e instanceof fa(e).HTMLElement:!1}function _D(e){return!nv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fa(e).ShadowRoot}const nue=new Set(["inline","contents"]);function Hf(e){const{overflow:t,overflowX:r,overflowY:n,display:a}=Ja(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!nue.has(a)}const aue=new Set(["table","td","th"]);function oue(e){return aue.has(wu(e))}const iue=[":popover-open",":modal"];function av(e){return iue.some(t=>{try{return e.matches(t)}catch{return!1}})}const sue=["transform","translate","scale","rotate","perspective"],lue=["transform","translate","scale","rotate","perspective","filter"],cue=["paint","layout","strict","content"];function __(e){const t=E_(),r=Xa(e)?Ja(e):e;return sue.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||lue.some(n=>(r.willChange||"").includes(n))||cue.some(n=>(r.contain||"").includes(n))}function uue(e){let t=Vi(e);for(;jo(t)&&!Zc(t);){if(__(t))return t;if(av(t))return null;t=Vi(t)}return null}function E_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const due=new Set(["html","body","#document"]);function Zc(e){return due.has(wu(e))}function Ja(e){return fa(e).getComputedStyle(e)}function ov(e){return Xa(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vi(e){if(wu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||_D(e)&&e.host||ko(e);return _D(t)?t.host:t}function MF(e){const t=Vi(e);return Zc(t)?e.ownerDocument?e.ownerDocument.body:e.body:jo(t)&&Hf(t)?t:MF(t)}function Of(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const a=MF(e),i=a===((n=e.ownerDocument)==null?void 0:n.body),s=fa(a);if(i){const l=FN(s);return t.concat(s,s.visualViewport||[],Hf(a)?a:[],l&&r?Of(l):[])}return t.concat(a,Of(a,[],r))}function FN(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function RF(e){const t=Ja(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=jo(e),i=a?e.offsetWidth:r,s=a?e.offsetHeight:n,l=Qg(r)!==i||Qg(n)!==s;return l&&(r=i,n=s),{width:r,height:n,$:l}}function P_(e){return Xa(e)?e:e.contextElement}function vc(e){const t=P_(e);if(!jo(t))return bo(1);const r=t.getBoundingClientRect(),{width:n,height:a,$:i}=RF(t);let s=(i?Qg(r.width):r.width)/n,l=(i?Qg(r.height):r.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const fue=bo(0);function DF(e){const t=fa(e);return!E_()||!t.visualViewport?fue:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function hue(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==fa(e)?!1:t}function Xs(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=P_(e);let s=bo(1);t&&(n?Xa(n)&&(s=vc(n)):s=vc(e));const l=hue(i,r,n)?DF(i):bo(0);let d=(a.left+l.x)/s.x,u=(a.top+l.y)/s.y,f=a.width/s.x,h=a.height/s.y;if(i){const p=fa(i),g=n&&Xa(n)?fa(n):n;let v=p,b=FN(v);for(;b&&n&&g!==v;){const w=vc(b),j=b.getBoundingClientRect(),N=Ja(b),C=j.left+(b.clientLeft+parseFloat(N.paddingLeft))*w.x,O=j.top+(b.clientTop+parseFloat(N.paddingTop))*w.y;d*=w.x,u*=w.y,f*=w.x,h*=w.y,d+=C,u+=O,v=fa(b),b=FN(v)}}return ey({width:f,height:h,x:d,y:u})}function iv(e,t){const r=ov(e).scrollLeft;return t?t.left+r:Xs(ko(e)).left+r}function LF(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-iv(e,r),a=r.top+t.scrollTop;return{x:n,y:a}}function mue(e){let{elements:t,rect:r,offsetParent:n,strategy:a}=e;const i=a==="fixed",s=ko(n),l=t?av(t.floating):!1;if(n===s||l&&i)return r;let d={scrollLeft:0,scrollTop:0},u=bo(1);const f=bo(0),h=jo(n);if((h||!h&&!i)&&((wu(n)!=="body"||Hf(s))&&(d=ov(n)),jo(n))){const g=Xs(n);u=vc(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=s&&!h&&!i?LF(s,d):bo(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-d.scrollLeft*u.x+f.x+p.x,y:r.y*u.y-d.scrollTop*u.y+f.y+p.y}}function pue(e){return Array.from(e.getClientRects())}function gue(e){const t=ko(e),r=ov(e),n=e.ownerDocument.body,a=na(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=na(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+iv(e);const l=-r.scrollTop;return Ja(n).direction==="rtl"&&(s+=na(t.clientWidth,n.clientWidth)-a),{width:a,height:i,x:s,y:l}}const ED=25;function yue(e,t){const r=fa(e),n=ko(e),a=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,l=0,d=0;if(a){i=a.width,s=a.height;const f=E_();(!f||f&&t==="fixed")&&(l=a.offsetLeft,d=a.offsetTop)}const u=iv(n);if(u<=0){const f=n.ownerDocument,h=f.body,p=getComputedStyle(h),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,v=Math.abs(n.clientWidth-h.clientWidth-g);v<=ED&&(i-=v)}else u<=ED&&(i+=u);return{width:i,height:s,x:l,y:d}}const vue=new Set(["absolute","fixed"]);function xue(e,t){const r=Xs(e,!0,t==="fixed"),n=r.top+e.clientTop,a=r.left+e.clientLeft,i=jo(e)?vc(e):bo(1),s=e.clientWidth*i.x,l=e.clientHeight*i.y,d=a*i.x,u=n*i.y;return{width:s,height:l,x:d,y:u}}function PD(e,t,r){let n;if(t==="viewport")n=yue(e,r);else if(t==="document")n=gue(ko(e));else if(Xa(t))n=xue(t,r);else{const a=DF(e);n={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return ey(n)}function $F(e,t){const r=Vi(e);return r===t||!Xa(r)||Zc(r)?!1:Ja(r).position==="fixed"||$F(r,t)}function bue(e,t){const r=t.get(e);if(r)return r;let n=Of(e,[],!1).filter(l=>Xa(l)&&wu(l)!=="body"),a=null;const i=Ja(e).position==="fixed";let s=i?Vi(e):e;for(;Xa(s)&&!Zc(s);){const l=Ja(s),d=__(s);!d&&l.position==="fixed"&&(a=null),(i?!d&&!a:!d&&l.position==="static"&&!!a&&vue.has(a.position)||Hf(s)&&!d&&$F(e,s))?n=n.filter(f=>f!==s):a=l,s=Vi(s)}return t.set(e,n),n}function wue(e){let{element:t,boundary:r,rootBoundary:n,strategy:a}=e;const s=[...r==="clippingAncestors"?av(t)?[]:bue(t,this._c):[].concat(r),n],l=s[0],d=s.reduce((u,f)=>{const h=PD(t,f,a);return u.top=na(h.top,u.top),u.right=qi(h.right,u.right),u.bottom=qi(h.bottom,u.bottom),u.left=na(h.left,u.left),u},PD(t,l,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Sue(e){const{width:t,height:r}=RF(e);return{width:t,height:r}}function jue(e,t,r){const n=jo(t),a=ko(t),i=r==="fixed",s=Xs(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const d=bo(0);function u(){d.x=iv(a)}if(n||!n&&!i)if((wu(t)!=="body"||Hf(a))&&(l=ov(t)),n){const g=Xs(t,!0,i,t);d.x=g.x+t.clientLeft,d.y=g.y+t.clientTop}else a&&u();i&&!n&&a&&u();const f=a&&!n&&!i?LF(a,l):bo(0),h=s.left+l.scrollLeft-d.x-f.x,p=s.top+l.scrollTop-d.y-f.y;return{x:h,y:p,width:s.width,height:s.height}}function $S(e){return Ja(e).position==="static"}function OD(e,t){if(!jo(e)||Ja(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return ko(e)===r&&(r=r.ownerDocument.body),r}function FF(e,t){const r=fa(e);if(av(e))return r;if(!jo(e)){let a=Vi(e);for(;a&&!Zc(a);){if(Xa(a)&&!$S(a))return a;a=Vi(a)}return r}let n=OD(e,t);for(;n&&oue(n)&&$S(n);)n=OD(n,t);return n&&Zc(n)&&$S(n)&&!__(n)?r:n||uue(e)||r}const Nue=async function(e){const t=this.getOffsetParent||FF,r=this.getDimensions,n=await r(e.floating);return{reference:jue(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Cue(e){return Ja(e).direction==="rtl"}const _ue={convertOffsetParentRelativeRectToViewportRelativeRect:mue,getDocumentElement:ko,getClippingRect:wue,getOffsetParent:FF,getElementRects:Nue,getClientRects:pue,getDimensions:Sue,getScale:vc,isElement:Xa,isRTL:Cue};function BF(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Eue(e,t){let r=null,n;const a=ko(e);function i(){var l;clearTimeout(n),(l=r)==null||l.disconnect(),r=null}function s(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),i();const u=e.getBoundingClientRect(),{left:f,top:h,width:p,height:g}=u;if(l||t(),!p||!g)return;const v=Vm(h),b=Vm(a.clientWidth-(f+p)),w=Vm(a.clientHeight-(h+g)),j=Vm(f),C={rootMargin:-v+"px "+-b+"px "+-w+"px "+-j+"px",threshold:na(0,qi(1,d))||1};let O=!0;function P(E){const T=E[0].intersectionRatio;if(T!==d){if(!O)return s();T?s(!1,T):n=setTimeout(()=>{s(!1,1e-7)},1e3)}T===1&&!BF(u,e.getBoundingClientRect())&&s(),O=!1}try{r=new IntersectionObserver(P,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(P,C)}r.observe(e)}return s(!0),i}function Pue(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,u=P_(e),f=a||i?[...u?Of(u):[],...Of(t)]:[];f.forEach(j=>{a&&j.addEventListener("scroll",r,{passive:!0}),i&&j.addEventListener("resize",r)});const h=u&&l?Eue(u,r):null;let p=-1,g=null;s&&(g=new ResizeObserver(j=>{let[N]=j;N&&N.target===u&&g&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=g)==null||C.observe(t)})),r()}),u&&!d&&g.observe(u),g.observe(t));let v,b=d?Xs(e):null;d&&w();function w(){const j=Xs(e);b&&!BF(b,j)&&r(),b=j,v=requestAnimationFrame(w)}return r(),()=>{var j;f.forEach(N=>{a&&N.removeEventListener("scroll",r),i&&N.removeEventListener("resize",r)}),h?.(),(j=g)==null||j.disconnect(),g=null,d&&cancelAnimationFrame(v)}}const Oue=Zce,Tue=eue,kue=Xce,Aue=rue,Iue=Jce,TD=Kce,Mue=tue,Rue=(e,t,r)=>{const n=new Map,a={platform:_ue,...r},i={...a.platform,_c:n};return Yce(e,t,{...a,platform:i})};var Due=typeof document<"u",Lue=function(){},Lp=Due?x.useLayoutEffect:Lue;function ty(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!ty(e[n],t[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,a[n]))return!1;for(n=r;n--!==0;){const i=a[n];if(!(i==="_owner"&&e.$$typeof)&&!ty(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function zF(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kD(e,t){const r=zF(e);return Math.round(t*r)/r}function FS(e){const t=x.useRef(e);return Lp(()=>{t.current=e}),t}function $ue(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:d,open:u}=e,[f,h]=x.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=x.useState(n);ty(p,n)||g(n);const[v,b]=x.useState(null),[w,j]=x.useState(null),N=x.useCallback(I=>{I!==E.current&&(E.current=I,b(I))},[]),C=x.useCallback(I=>{I!==T.current&&(T.current=I,j(I))},[]),O=i||v,P=s||w,E=x.useRef(null),T=x.useRef(null),A=x.useRef(f),M=d!=null,R=FS(d),L=FS(a),V=FS(u),z=x.useCallback(()=>{if(!E.current||!T.current)return;const I={placement:t,strategy:r,middleware:p};L.current&&(I.platform=L.current),Rue(E.current,T.current,I).then(Y=>{const F={...Y,isPositioned:V.current!==!1};G.current&&!ty(A.current,F)&&(A.current=F,Mf.flushSync(()=>{h(F)}))})},[p,t,r,L,V]);Lp(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(I=>({...I,isPositioned:!1})))},[u]);const G=x.useRef(!1);Lp(()=>(G.current=!0,()=>{G.current=!1}),[]),Lp(()=>{if(O&&(E.current=O),P&&(T.current=P),O&&P){if(R.current)return R.current(O,P,z);z()}},[O,P,z,R,M]);const H=x.useMemo(()=>({reference:E,floating:T,setReference:N,setFloating:C}),[N,C]),W=x.useMemo(()=>({reference:O,floating:P}),[O,P]),q=x.useMemo(()=>{const I={position:r,left:0,top:0};if(!W.floating)return I;const Y=kD(W.floating,f.x),F=kD(W.floating,f.y);return l?{...I,transform:"translate("+Y+"px, "+F+"px)",...zF(W.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:Y,top:F}},[r,l,W.floating,f.x,f.y]);return x.useMemo(()=>({...f,update:z,refs:H,elements:W,floatingStyles:q}),[f,z,H,W,q])}const Fue=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:a}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?TD({element:n.current,padding:a}).fn(r):{}:n?TD({element:n,padding:a}).fn(r):{}}}},Bue=(e,t)=>({...Oue(e),options:[e,t]}),zue=(e,t)=>({...Tue(e),options:[e,t]}),Uue=(e,t)=>({...Mue(e),options:[e,t]}),que=(e,t)=>({...kue(e),options:[e,t]}),Vue=(e,t)=>({...Aue(e),options:[e,t]}),Wue=(e,t)=>({...Iue(e),options:[e,t]}),Hue=(e,t)=>({...Fue(e),options:[e,t]});var Gue="Arrow",UF=x.forwardRef((e,t)=>{const{children:r,width:n=10,height:a=5,...i}=e;return o.jsx(lt.svg,{...i,ref:t,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});UF.displayName=Gue;var Yue=UF;function O_(e){const[t,r]=x.useState(void 0);return kr(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let s,l;if("borderBoxSize"in i){const d=i.borderBoxSize,u=Array.isArray(d)?d[0]:d;s=u.inlineSize,l=u.blockSize}else s=e.offsetWidth,l=e.offsetHeight;r({width:s,height:l})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var T_="Popper",[qF,sv]=Eo(T_),[Kue,VF]=qF(T_),WF=e=>{const{__scopePopper:t,children:r}=e,[n,a]=x.useState(null);return o.jsx(Kue,{scope:t,anchor:n,onAnchorChange:a,children:r})};WF.displayName=T_;var HF="PopperAnchor",GF=x.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...a}=e,i=VF(HF,r),s=x.useRef(null),l=At(t,s),d=x.useRef(null);return x.useEffect(()=>{const u=d.current;d.current=n?.current||s.current,u!==d.current&&i.onAnchorChange(d.current)}),n?null:o.jsx(lt.div,{...a,ref:l})});GF.displayName=HF;var k_="PopperContent",[Xue,Jue]=qF(k_),YF=x.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:v,...b}=e,w=VF(k_,r),[j,N]=x.useState(null),C=At(t,Q=>N(Q)),[O,P]=x.useState(null),E=O_(O),T=E?.width??0,A=E?.height??0,M=n+(i!=="center"?"-"+i:""),R=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},L=Array.isArray(u)?u:[u],V=L.length>0,z={padding:R,boundary:L.filter(Zue),altBoundary:V},{refs:G,floatingStyles:H,placement:W,isPositioned:q,middlewareData:I}=$ue({strategy:"fixed",placement:M,whileElementsMounted:(...Q)=>Pue(...Q,{animationFrame:g==="always"}),elements:{reference:w.anchor},middleware:[Bue({mainAxis:a+A,alignmentAxis:s}),d&&zue({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Uue():void 0,...z}),d&&que({...z}),Vue({...z,apply:({elements:Q,rects:ue,availableWidth:se,availableHeight:fe})=>{const{width:we,height:Z}=ue.reference,je=Q.floating.style;je.setProperty("--radix-popper-available-width",`${se}px`),je.setProperty("--radix-popper-available-height",`${fe}px`),je.setProperty("--radix-popper-anchor-width",`${we}px`),je.setProperty("--radix-popper-anchor-height",`${Z}px`)}}),O&&Hue({element:O,padding:l}),ede({arrowWidth:T,arrowHeight:A}),p&&Wue({strategy:"referenceHidden",...z})]}),[Y,F]=JF(W),D=dn(v);kr(()=>{q&&D?.()},[q,D]);const $=I.arrow?.x,K=I.arrow?.y,J=I.arrow?.centerOffset!==0,[oe,re]=x.useState();return kr(()=>{j&&re(window.getComputedStyle(j).zIndex)},[j]),o.jsx("div",{ref:G.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:q?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[I.transformOrigin?.x,I.transformOrigin?.y].join(" "),...I.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(Xue,{scope:r,placedSide:Y,onArrowChange:P,arrowX:$,arrowY:K,shouldHideArrow:J,children:o.jsx(lt.div,{"data-side":Y,"data-align":F,...b,ref:C,style:{...b.style,animation:q?void 0:"none"}})})})});YF.displayName=k_;var KF="PopperArrow",Que={top:"bottom",right:"left",bottom:"top",left:"right"},XF=x.forwardRef(function(t,r){const{__scopePopper:n,...a}=t,i=Jue(KF,n),s=Que[i.placedSide];return o.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:o.jsx(Yue,{...a,ref:r,style:{...a.style,display:"block"}})})});XF.displayName=KF;function Zue(e){return e!==null}var ede=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:a}=t,s=a.arrow?.centerOffset!==0,l=s?0:e.arrowWidth,d=s?0:e.arrowHeight,[u,f]=JF(r),h={start:"0%",center:"50%",end:"100%"}[f],p=(a.arrow?.x??0)+l/2,g=(a.arrow?.y??0)+d/2;let v="",b="";return u==="bottom"?(v=s?h:`${p}px`,b=`${-d}px`):u==="top"?(v=s?h:`${p}px`,b=`${n.floating.height+d}px`):u==="right"?(v=`${-d}px`,b=s?h:`${g}px`):u==="left"&&(v=`${n.floating.width+d}px`,b=s?h:`${g}px`),{data:{x:v,y:b}}}});function JF(e){const[t,r="center"]=e.split("-");return[t,r]}var QF=WF,A_=GF,ZF=YF,eB=XF,tde="Portal",lv=x.forwardRef((e,t)=>{const{container:r,...n}=e,[a,i]=x.useState(!1);kr(()=>i(!0),[]);const s=r||a&&globalThis?.document?.body;return s?x$.createPortal(o.jsx(lt.div,{...n,ref:t}),s):null});lv.displayName=tde;function rde(e){const t=nde(e),r=x.forwardRef((n,a)=>{const{children:i,...s}=n,l=x.Children.toArray(i),d=l.find(ode);if(d){const u=d.props.children,f=l.map(h=>h===d?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:h);return o.jsx(t,{...s,ref:a,children:x.isValidElement(u)?x.cloneElement(u,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function nde(e){const t=x.forwardRef((r,n)=>{const{children:a,...i}=r;if(x.isValidElement(a)){const s=sde(a),l=ide(i,a.props);return a.type!==x.Fragment&&(l.ref=n?Oa(n,s):s),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ade=Symbol("radix.slottable");function ode(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ade}function ide(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function sde(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var lde=aC[" useInsertionEffect ".trim().toString()]||kr;function No({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[a,i,s]=cde({defaultProp:t,onChange:r}),l=e!==void 0,d=l?e:a;{const f=x.useRef(e!==void 0);x.useEffect(()=>{const h=f.current;h!==l&&console.warn(`${n} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,n])}const u=x.useCallback(f=>{if(l){const h=ude(f)?f(e):f;h!==e&&s.current?.(h)}else i(f)},[l,e,i,s]);return[d,u]}function cde({defaultProp:e,onChange:t}){const[r,n]=x.useState(e),a=x.useRef(r),i=x.useRef(t);return lde(()=>{i.current=t},[t]),x.useEffect(()=>{a.current!==r&&(i.current?.(r),a.current=r)},[r,a]),[r,n,i]}function ude(e){return typeof e=="function"}function I_(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var tB=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),dde="VisuallyHidden",fde=x.forwardRef((e,t)=>o.jsx(lt.span,{...e,ref:t,style:{...tB,...e.style}}));fde.displayName=dde;var hde=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Jl=new WeakMap,Wm=new WeakMap,Hm={},BS=0,rB=function(e){return e&&(e.host||rB(e.parentNode))},mde=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=rB(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},pde=function(e,t,r,n){var a=mde(t,Array.isArray(e)?e:[e]);Hm[r]||(Hm[r]=new WeakMap);var i=Hm[r],s=[],l=new Set,d=new Set(a),u=function(h){!h||l.has(h)||(l.add(h),u(h.parentNode))};a.forEach(u);var f=function(h){!h||d.has(h)||Array.prototype.forEach.call(h.children,function(p){if(l.has(p))f(p);else try{var g=p.getAttribute(n),v=g!==null&&g!=="false",b=(Jl.get(p)||0)+1,w=(i.get(p)||0)+1;Jl.set(p,b),i.set(p,w),s.push(p),b===1&&v&&Wm.set(p,!0),w===1&&p.setAttribute(r,"true"),v||p.setAttribute(n,"true")}catch(j){console.error("aria-hidden: cannot operate on ",p,j)}})};return f(t),l.clear(),BS++,function(){s.forEach(function(h){var p=Jl.get(h)-1,g=i.get(h)-1;Jl.set(h,p),i.set(h,g),p||(Wm.has(h)||h.removeAttribute(n),Wm.delete(h)),g||h.removeAttribute(r)}),BS--,BS||(Jl=new WeakMap,Jl=new WeakMap,Wm=new WeakMap,Hm={})}},M_=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=hde(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live], script"))),pde(n,a,r,"aria-hidden")):function(){return null}},mo=function(){return mo=Object.assign||function(t){for(var r,n=1,a=arguments.length;n"u")return Ade;var t=Ide(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},Rde=iB(),xc="data-scroll-locked",Dde=function(e,t,r,n){var a=e.left,i=e.top,s=e.right,l=e.gap;return r===void 0&&(r="margin"),` - .`.concat(yde,` { - overflow: hidden `).concat(n,`; - padding-right: `).concat(l,"px ").concat(n,`; - } - body[`).concat(xc,`] { - overflow: hidden `).concat(n,`; - overscroll-behavior: contain; - `).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&` - padding-left: `.concat(a,`px; - padding-top: `).concat(i,`px; - padding-right: `).concat(s,`px; - margin-left:0; - margin-top:0; - margin-right: `).concat(l,"px ").concat(n,`; - `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(n,";")].filter(Boolean).join(""),` - } - - .`).concat($p,` { - right: `).concat(l,"px ").concat(n,`; - } - - .`).concat(Fp,` { - margin-right: `).concat(l,"px ").concat(n,`; - } - - .`).concat($p," .").concat($p,` { - right: 0 `).concat(n,`; - } - - .`).concat(Fp," .").concat(Fp,` { - margin-right: 0 `).concat(n,`; - } - - body[`).concat(xc,`] { - `).concat(vde,": ").concat(l,`px; - } -`)},ID=function(){var e=parseInt(document.body.getAttribute(xc)||"0",10);return isFinite(e)?e:0},Lde=function(){x.useEffect(function(){return document.body.setAttribute(xc,(ID()+1).toString()),function(){var e=ID()-1;e<=0?document.body.removeAttribute(xc):document.body.setAttribute(xc,e.toString())}},[])},$de=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;Lde();var i=x.useMemo(function(){return Mde(a)},[a]);return x.createElement(Rde,{styles:Dde(i,!t,a,r?"":"!important")})},BN=!1;if(typeof window<"u")try{var Gm=Object.defineProperty({},"passive",{get:function(){return BN=!0,!0}});window.addEventListener("test",Gm,Gm),window.removeEventListener("test",Gm,Gm)}catch{BN=!1}var Ql=BN?{passive:!1}:!1,Fde=function(e){return e.tagName==="TEXTAREA"},sB=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Fde(e)&&r[t]==="visible")},Bde=function(e){return sB(e,"overflowY")},zde=function(e){return sB(e,"overflowX")},MD=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=lB(e,n);if(a){var i=cB(e,n),s=i[1],l=i[2];if(s>l)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Ude=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},qde=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},lB=function(e,t){return e==="v"?Bde(t):zde(t)},cB=function(e,t){return e==="v"?Ude(t):qde(t)},Vde=function(e,t){return e==="h"&&t==="rtl"?-1:1},Wde=function(e,t,r,n,a){var i=Vde(e,window.getComputedStyle(t).direction),s=i*n,l=r.target,d=t.contains(l),u=!1,f=s>0,h=0,p=0;do{if(!l)break;var g=cB(e,l),v=g[0],b=g[1],w=g[2],j=b-w-i*v;(v||j)&&lB(e,l)&&(h+=j,p+=v);var N=l.parentNode;l=N&&N.nodeType===Node.DOCUMENT_FRAGMENT_NODE?N.host:N}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return(f&&Math.abs(h)<1||!f&&Math.abs(p)<1)&&(u=!0),u},Ym=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},RD=function(e){return[e.deltaX,e.deltaY]},DD=function(e){return e&&"current"in e?e.current:e},Hde=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Gde=function(e){return` - .block-interactivity-`.concat(e,` {pointer-events: none;} - .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},Yde=0,Zl=[];function Kde(e){var t=x.useRef([]),r=x.useRef([0,0]),n=x.useRef(),a=x.useState(Yde++)[0],i=x.useState(iB)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var b=gde([e.lockRef.current],(e.shards||[]).map(DD),!0).filter(Boolean);return b.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),b.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=x.useCallback(function(b,w){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!s.current.allowPinchZoom;var j=Ym(b),N=r.current,C="deltaX"in b?b.deltaX:N[0]-j[0],O="deltaY"in b?b.deltaY:N[1]-j[1],P,E=b.target,T=Math.abs(C)>Math.abs(O)?"h":"v";if("touches"in b&&T==="h"&&E.type==="range")return!1;var A=window.getSelection(),M=A&&A.anchorNode,R=M?M===E||M.contains(E):!1;if(R)return!1;var L=MD(T,E);if(!L)return!0;if(L?P=T:(P=T==="v"?"h":"v",L=MD(T,E)),!L)return!1;if(!n.current&&"changedTouches"in b&&(C||O)&&(n.current=P),!P)return!0;var V=n.current||P;return Wde(V,w,b,V==="h"?C:O)},[]),d=x.useCallback(function(b){var w=b;if(!(!Zl.length||Zl[Zl.length-1]!==i)){var j="deltaY"in w?RD(w):Ym(w),N=t.current.filter(function(P){return P.name===w.type&&(P.target===w.target||w.target===P.shadowParent)&&Hde(P.delta,j)})[0];if(N&&N.should){w.cancelable&&w.preventDefault();return}if(!N){var C=(s.current.shards||[]).map(DD).filter(Boolean).filter(function(P){return P.contains(w.target)}),O=C.length>0?l(w,C[0]):!s.current.noIsolation;O&&w.cancelable&&w.preventDefault()}}},[]),u=x.useCallback(function(b,w,j,N){var C={name:b,delta:w,target:j,should:N,shadowParent:Xde(j)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(O){return O!==C})},1)},[]),f=x.useCallback(function(b){r.current=Ym(b),n.current=void 0},[]),h=x.useCallback(function(b){u(b.type,RD(b),b.target,l(b,e.lockRef.current))},[]),p=x.useCallback(function(b){u(b.type,Ym(b),b.target,l(b,e.lockRef.current))},[]);x.useEffect(function(){return Zl.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",d,Ql),document.addEventListener("touchmove",d,Ql),document.addEventListener("touchstart",f,Ql),function(){Zl=Zl.filter(function(b){return b!==i}),document.removeEventListener("wheel",d,Ql),document.removeEventListener("touchmove",d,Ql),document.removeEventListener("touchstart",f,Ql)}},[]);var g=e.removeScrollBar,v=e.inert;return x.createElement(x.Fragment,null,v?x.createElement(i,{styles:Gde(a)}):null,g?x.createElement($de,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Xde(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Jde=Cde(oB,Kde);var uv=x.forwardRef(function(e,t){return x.createElement(cv,mo({},e,{ref:t,sideCar:Jde}))});uv.classNames=cv.classNames;var Qde=[" ","Enter","ArrowUp","ArrowDown"],Zde=[" ","Enter"],Js="Select",[dv,fv,efe]=EF(Js),[Su]=Eo(Js,[efe,sv]),hv=sv(),[tfe,Xi]=Su(Js),[rfe,nfe]=Su(Js),uB=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:a,onOpenChange:i,value:s,defaultValue:l,onValueChange:d,dir:u,name:f,autoComplete:h,disabled:p,required:g,form:v}=e,b=hv(t),[w,j]=x.useState(null),[N,C]=x.useState(null),[O,P]=x.useState(!1),E=py(u),[T,A]=No({prop:n,defaultProp:a??!1,onChange:i,caller:Js}),[M,R]=No({prop:s,defaultProp:l,onChange:d,caller:Js}),L=x.useRef(null),V=w?v||!!w.closest("form"):!0,[z,G]=x.useState(new Set),H=Array.from(z).map(W=>W.props.value).join(";");return o.jsx(QF,{...b,children:o.jsxs(tfe,{required:g,scope:t,trigger:w,onTriggerChange:j,valueNode:N,onValueNodeChange:C,valueNodeHasChildren:O,onValueNodeHasChildrenChange:P,contentId:Bn(),value:M,onValueChange:R,open:T,onOpenChange:A,dir:E,triggerPointerDownPosRef:L,disabled:p,children:[o.jsx(dv.Provider,{scope:t,children:o.jsx(rfe,{scope:e.__scopeSelect,onNativeOptionAdd:x.useCallback(W=>{G(q=>new Set(q).add(W))},[]),onNativeOptionRemove:x.useCallback(W=>{G(q=>{const I=new Set(q);return I.delete(W),I})},[]),children:r})}),V?o.jsxs(AB,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:M,onChange:W=>R(W.target.value),disabled:p,form:v,children:[M===void 0?o.jsx("option",{value:""}):null,Array.from(z)]},H):null]})})};uB.displayName=Js;var dB="SelectTrigger",fB=x.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...a}=e,i=hv(r),s=Xi(dB,r),l=s.disabled||n,d=At(t,s.onTriggerChange),u=fv(r),f=x.useRef("touch"),[h,p,g]=MB(b=>{const w=u().filter(C=>!C.disabled),j=w.find(C=>C.value===s.value),N=RB(w,b,j);N!==void 0&&s.onValueChange(N.value)}),v=b=>{l||(s.onOpenChange(!0),g()),b&&(s.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return o.jsx(A_,{asChild:!0,...i,children:o.jsx(lt.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":IB(s.value)?"":void 0,...a,ref:d,onClick:mt(a.onClick,b=>{b.currentTarget.focus(),f.current!=="mouse"&&v(b)}),onPointerDown:mt(a.onPointerDown,b=>{f.current=b.pointerType;const w=b.target;w.hasPointerCapture(b.pointerId)&&w.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(v(b),b.preventDefault())}),onKeyDown:mt(a.onKeyDown,b=>{const w=h.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&p(b.key),!(w&&b.key===" ")&&Qde.includes(b.key)&&(v(),b.preventDefault())})})})});fB.displayName=dB;var hB="SelectValue",mB=x.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:a,children:i,placeholder:s="",...l}=e,d=Xi(hB,r),{onValueNodeHasChildrenChange:u}=d,f=i!==void 0,h=At(t,d.onValueNodeChange);return kr(()=>{u(f)},[u,f]),o.jsx(lt.span,{...l,ref:h,style:{pointerEvents:"none"},children:IB(d.value)?o.jsx(o.Fragment,{children:s}):i})});mB.displayName=hB;var afe="SelectIcon",pB=x.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...a}=e;return o.jsx(lt.span,{"aria-hidden":!0,...a,ref:t,children:n||"▼"})});pB.displayName=afe;var ofe="SelectPortal",gB=e=>o.jsx(lv,{asChild:!0,...e});gB.displayName=ofe;var Qs="SelectContent",yB=x.forwardRef((e,t)=>{const r=Xi(Qs,e.__scopeSelect),[n,a]=x.useState();if(kr(()=>{a(new DocumentFragment)},[]),!r.open){const i=n;return i?Mf.createPortal(o.jsx(vB,{scope:e.__scopeSelect,children:o.jsx(dv.Slot,{scope:e.__scopeSelect,children:o.jsx("div",{children:e.children})})}),i):null}return o.jsx(xB,{...e,ref:t})});yB.displayName=Qs;var Wa=10,[vB,Ji]=Su(Qs),ife="SelectContentImpl",sfe=rde("SelectContent.RemoveScroll"),xB=x.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:s,side:l,sideOffset:d,align:u,alignOffset:f,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:b,avoidCollisions:w,...j}=e,N=Xi(Qs,r),[C,O]=x.useState(null),[P,E]=x.useState(null),T=At(t,Q=>O(Q)),[A,M]=x.useState(null),[R,L]=x.useState(null),V=fv(r),[z,G]=x.useState(!1),H=x.useRef(!1);x.useEffect(()=>{if(C)return M_(C)},[C]),S_();const W=x.useCallback(Q=>{const[ue,...se]=V().map(Z=>Z.ref.current),[fe]=se.slice(-1),we=document.activeElement;for(const Z of Q)if(Z===we||(Z?.scrollIntoView({block:"nearest"}),Z===ue&&P&&(P.scrollTop=0),Z===fe&&P&&(P.scrollTop=P.scrollHeight),Z?.focus(),document.activeElement!==we))return},[V,P]),q=x.useCallback(()=>W([A,C]),[W,A,C]);x.useEffect(()=>{z&&q()},[z,q]);const{onOpenChange:I,triggerPointerDownPosRef:Y}=N;x.useEffect(()=>{if(C){let Q={x:0,y:0};const ue=fe=>{Q={x:Math.abs(Math.round(fe.pageX)-(Y.current?.x??0)),y:Math.abs(Math.round(fe.pageY)-(Y.current?.y??0))}},se=fe=>{Q.x<=10&&Q.y<=10?fe.preventDefault():C.contains(fe.target)||I(!1),document.removeEventListener("pointermove",ue),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",se,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",se,{capture:!0})}}},[C,I,Y]),x.useEffect(()=>{const Q=()=>I(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[I]);const[F,D]=MB(Q=>{const ue=V().filter(we=>!we.disabled),se=ue.find(we=>we.ref.current===document.activeElement),fe=RB(ue,Q,se);fe&&setTimeout(()=>fe.ref.current.focus())}),$=x.useCallback((Q,ue,se)=>{const fe=!H.current&&!se;(N.value!==void 0&&N.value===ue||fe)&&(M(Q),fe&&(H.current=!0))},[N.value]),K=x.useCallback(()=>C?.focus(),[C]),J=x.useCallback((Q,ue,se)=>{const fe=!H.current&&!se;(N.value!==void 0&&N.value===ue||fe)&&L(Q)},[N.value]),oe=n==="popper"?zN:bB,re=oe===zN?{side:l,sideOffset:d,align:u,alignOffset:f,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:b,avoidCollisions:w}:{};return o.jsx(vB,{scope:r,content:C,viewport:P,onViewportChange:E,itemRefCallback:$,selectedItem:A,onItemLeave:K,itemTextRefCallback:J,focusSelectedItem:q,selectedItemText:R,position:n,isPositioned:z,searchRef:F,children:o.jsx(uv,{as:sfe,allowPinchZoom:!0,children:o.jsx(rv,{asChild:!0,trapped:N.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:mt(a,Q=>{N.trigger?.focus({preventScroll:!0}),Q.preventDefault()}),children:o.jsx(tv,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:o.jsx(oe,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:Q=>Q.preventDefault(),...j,...re,onPlaced:()=>G(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:mt(j.onKeyDown,Q=>{const ue=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!ue&&Q.key.length===1&&D(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let fe=V().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(fe=fe.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const we=Q.target,Z=fe.indexOf(we);fe=fe.slice(Z+1)}setTimeout(()=>W(fe)),Q.preventDefault()}})})})})})})});xB.displayName=ife;var lfe="SelectItemAlignedPosition",bB=x.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...a}=e,i=Xi(Qs,r),s=Ji(Qs,r),[l,d]=x.useState(null),[u,f]=x.useState(null),h=At(t,T=>f(T)),p=fv(r),g=x.useRef(!1),v=x.useRef(!0),{viewport:b,selectedItem:w,selectedItemText:j,focusSelectedItem:N}=s,C=x.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&b&&w&&j){const T=i.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),M=i.valueNode.getBoundingClientRect(),R=j.getBoundingClientRect();if(i.dir!=="rtl"){const we=R.left-A.left,Z=M.left-we,je=T.left-Z,Ce=T.width+je,qe=Math.max(Ce,A.width),De=window.innerWidth-Wa,He=dj(Z,[Wa,Math.max(Wa,De-qe)]);l.style.minWidth=Ce+"px",l.style.left=He+"px"}else{const we=A.right-R.right,Z=window.innerWidth-M.right-we,je=window.innerWidth-T.right-Z,Ce=T.width+je,qe=Math.max(Ce,A.width),De=window.innerWidth-Wa,He=dj(Z,[Wa,Math.max(Wa,De-qe)]);l.style.minWidth=Ce+"px",l.style.right=He+"px"}const L=p(),V=window.innerHeight-Wa*2,z=b.scrollHeight,G=window.getComputedStyle(u),H=parseInt(G.borderTopWidth,10),W=parseInt(G.paddingTop,10),q=parseInt(G.borderBottomWidth,10),I=parseInt(G.paddingBottom,10),Y=H+W+z+I+q,F=Math.min(w.offsetHeight*5,Y),D=window.getComputedStyle(b),$=parseInt(D.paddingTop,10),K=parseInt(D.paddingBottom,10),J=T.top+T.height/2-Wa,oe=V-J,re=w.offsetHeight/2,Q=w.offsetTop+re,ue=H+W+Q,se=Y-ue;if(ue<=J){const we=L.length>0&&w===L[L.length-1].ref.current;l.style.bottom="0px";const Z=u.clientHeight-b.offsetTop-b.offsetHeight,je=Math.max(oe,re+(we?K:0)+Z+q),Ce=ue+je;l.style.height=Ce+"px"}else{const we=L.length>0&&w===L[0].ref.current;l.style.top="0px";const je=Math.max(J,H+b.offsetTop+(we?$:0)+re)+se;l.style.height=je+"px",b.scrollTop=ue-J+b.offsetTop}l.style.margin=`${Wa}px 0`,l.style.minHeight=F+"px",l.style.maxHeight=V+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,i.trigger,i.valueNode,l,u,b,w,j,i.dir,n]);kr(()=>C(),[C]);const[O,P]=x.useState();kr(()=>{u&&P(window.getComputedStyle(u).zIndex)},[u]);const E=x.useCallback(T=>{T&&v.current===!0&&(C(),N?.(),v.current=!1)},[C,N]);return o.jsx(ufe,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:o.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:o.jsx(lt.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});bB.displayName=lfe;var cfe="SelectPopperPosition",zN=x.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Wa,...i}=e,s=hv(r);return o.jsx(ZF,{...s,...i,ref:t,align:n,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});zN.displayName=cfe;var[ufe,R_]=Su(Qs,{}),UN="SelectViewport",wB=x.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...a}=e,i=Ji(UN,r),s=R_(UN,r),l=At(t,i.onViewportChange),d=x.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),o.jsx(dv.Slot,{scope:r,children:o.jsx(lt.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:mt(a.onScroll,u=>{const f=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:p}=s;if(p?.current&&h){const g=Math.abs(d.current-f.scrollTop);if(g>0){const v=window.innerHeight-Wa*2,b=parseFloat(h.style.minHeight),w=parseFloat(h.style.height),j=Math.max(b,w);if(j0?O:0,h.style.justifyContent="flex-end")}}}d.current=f.scrollTop})})})]})});wB.displayName=UN;var SB="SelectGroup",[dfe,ffe]=Su(SB),hfe=x.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=Bn();return o.jsx(dfe,{scope:r,id:a,children:o.jsx(lt.div,{role:"group","aria-labelledby":a,...n,ref:t})})});hfe.displayName=SB;var jB="SelectLabel",mfe=x.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=ffe(jB,r);return o.jsx(lt.div,{id:a.id,...n,ref:t})});mfe.displayName=jB;var ry="SelectItem",[pfe,NB]=Su(ry),CB=x.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:i,...s}=e,l=Xi(ry,r),d=Ji(ry,r),u=l.value===n,[f,h]=x.useState(i??""),[p,g]=x.useState(!1),v=At(t,N=>d.itemRefCallback?.(N,n,a)),b=Bn(),w=x.useRef("touch"),j=()=>{a||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return o.jsx(pfe,{scope:r,value:n,disabled:a,textId:b,isSelected:u,onItemTextChange:x.useCallback(N=>{h(C=>C||(N?.textContent??"").trim())},[]),children:o.jsx(dv.ItemSlot,{scope:r,value:n,disabled:a,textValue:f,children:o.jsx(lt.div,{role:"option","aria-labelledby":b,"data-highlighted":p?"":void 0,"aria-selected":u&&p,"data-state":u?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...s,ref:v,onFocus:mt(s.onFocus,()=>g(!0)),onBlur:mt(s.onBlur,()=>g(!1)),onClick:mt(s.onClick,()=>{w.current!=="mouse"&&j()}),onPointerUp:mt(s.onPointerUp,()=>{w.current==="mouse"&&j()}),onPointerDown:mt(s.onPointerDown,N=>{w.current=N.pointerType}),onPointerMove:mt(s.onPointerMove,N=>{w.current=N.pointerType,a?d.onItemLeave?.():w.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:mt(s.onPointerLeave,N=>{N.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:mt(s.onKeyDown,N=>{d.searchRef?.current!==""&&N.key===" "||(Zde.includes(N.key)&&j(),N.key===" "&&N.preventDefault())})})})})});CB.displayName=ry;var Ld="SelectItemText",_B=x.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:a,...i}=e,s=Xi(Ld,r),l=Ji(Ld,r),d=NB(Ld,r),u=nfe(Ld,r),[f,h]=x.useState(null),p=At(t,j=>h(j),d.onItemTextChange,j=>l.itemTextRefCallback?.(j,d.value,d.disabled)),g=f?.textContent,v=x.useMemo(()=>o.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:w}=u;return kr(()=>(b(v),()=>w(v)),[b,w,v]),o.jsxs(o.Fragment,{children:[o.jsx(lt.span,{id:d.textId,...i,ref:p}),d.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Mf.createPortal(i.children,s.valueNode):null]})});_B.displayName=Ld;var EB="SelectItemIndicator",PB=x.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return NB(EB,r).isSelected?o.jsx(lt.span,{"aria-hidden":!0,...n,ref:t}):null});PB.displayName=EB;var qN="SelectScrollUpButton",OB=x.forwardRef((e,t)=>{const r=Ji(qN,e.__scopeSelect),n=R_(qN,e.__scopeSelect),[a,i]=x.useState(!1),s=At(t,n.onScrollButtonChange);return kr(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=d.scrollTop>0;i(u)};const d=r.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?o.jsx(kB,{...e,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=r;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});OB.displayName=qN;var VN="SelectScrollDownButton",TB=x.forwardRef((e,t)=>{const r=Ji(VN,e.__scopeSelect),n=R_(VN,e.__scopeSelect),[a,i]=x.useState(!1),s=At(t,n.onScrollButtonChange);return kr(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=d.scrollHeight-d.clientHeight,f=Math.ceil(d.scrollTop)d.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?o.jsx(kB,{...e,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=r;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});TB.displayName=VN;var kB=x.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=e,i=Ji("SelectScrollButton",r),s=x.useRef(null),l=fv(r),d=x.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return x.useEffect(()=>()=>d(),[d]),kr(()=>{l().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),o.jsx(lt.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:mt(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(n,50))}),onPointerMove:mt(a.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(n,50))}),onPointerLeave:mt(a.onPointerLeave,()=>{d()})})}),gfe="SelectSeparator",yfe=x.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return o.jsx(lt.div,{"aria-hidden":!0,...n,ref:t})});yfe.displayName=gfe;var WN="SelectArrow",vfe=x.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=hv(r),i=Xi(WN,r),s=Ji(WN,r);return i.open&&s.position==="popper"?o.jsx(eB,{...a,...n,ref:t}):null});vfe.displayName=WN;var xfe="SelectBubbleInput",AB=x.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const a=x.useRef(null),i=At(n,a),s=I_(t);return x.useEffect(()=>{const l=a.current;if(!l)return;const d=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(s!==t&&f){const h=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(h)}},[s,t]),o.jsx(lt.select,{...r,style:{...tB,...r.style},ref:i,defaultValue:t})});AB.displayName=xfe;function IB(e){return e===""||e===void 0}function MB(e){const t=dn(e),r=x.useRef(""),n=x.useRef(0),a=x.useCallback(s=>{const l=r.current+s;t(l),(function d(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(l)},[t]),i=x.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return x.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,i]}function RB(e,t,r){const a=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let s=bfe(e,Math.max(i,0));a.length===1&&(s=s.filter(u=>u!==r));const d=s.find(u=>u.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function bfe(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var wfe=uB,Sfe=fB,jfe=mB,Nfe=pB,Cfe=gB,_fe=yB,Efe=wB,Pfe=CB,Ofe=_B,Tfe=PB,kfe=OB,Afe=TB;function $e({...e}){return o.jsx(wfe,{"data-slot":"select",...e})}function Fe({...e}){return o.jsx(jfe,{"data-slot":"select-value",...e})}function Be({className:e,size:t="default",children:r,...n}){return o.jsxs(Sfe,{"data-slot":"select-trigger","data-size":t,className:Ie("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-input-background px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[r,o.jsx(Nfe,{asChild:!0,children:o.jsx(Bs,{className:"size-4 opacity-50"})})]})}function ze({className:e,children:t,position:r="popper",...n}){return o.jsx(Cfe,{children:o.jsxs(_fe,{"data-slot":"select-content",className:Ie("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[o.jsx(Ife,{}),o.jsx(Efe,{className:Ie("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),o.jsx(Mfe,{})]})})}function Se({className:e,children:t,...r}){return o.jsxs(Pfe,{"data-slot":"select-item",className:Ie("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[o.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o.jsx(Tfe,{children:o.jsx(j$,{className:"size-4"})})}),o.jsx(Ofe,{children:t})]})}function Ife({className:e,...t}){return o.jsx(kfe,{"data-slot":"select-scroll-up-button",className:Ie("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx(fq,{className:"size-4"})})}function Mfe({className:e,...t}){return o.jsx(Afe,{"data-slot":"select-scroll-down-button",className:Ie("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx(Bs,{className:"size-4"})})}function Rfe(e){const t=Dfe(e),r=x.forwardRef((n,a)=>{const{children:i,...s}=n,l=x.Children.toArray(i),d=l.find($fe);if(d){const u=d.props.children,f=l.map(h=>h===d?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:h);return o.jsx(t,{...s,ref:a,children:x.isValidElement(u)?x.cloneElement(u,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function Dfe(e){const t=x.forwardRef((r,n)=>{const{children:a,...i}=r;if(x.isValidElement(a)){const s=Bfe(a),l=Ffe(i,a.props);return a.type!==x.Fragment&&(l.ref=n?Oa(n,s):s),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Lfe=Symbol("radix.slottable");function $fe(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lfe}function Ffe(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function Bfe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var mv="Dialog",[DB]=Eo(mv),[zfe,no]=DB(mv),LB=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:s=!0}=e,l=x.useRef(null),d=x.useRef(null),[u,f]=No({prop:n,defaultProp:a??!1,onChange:i,caller:mv});return o.jsx(zfe,{scope:t,triggerRef:l,contentRef:d,contentId:Bn(),titleId:Bn(),descriptionId:Bn(),open:u,onOpenChange:f,onOpenToggle:x.useCallback(()=>f(h=>!h),[f]),modal:s,children:r})};LB.displayName=mv;var $B="DialogTrigger",Ufe=x.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no($B,r),i=At(t,a.triggerRef);return o.jsx(lt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$_(a.open),...n,ref:i,onClick:mt(e.onClick,a.onOpenToggle)})});Ufe.displayName=$B;var D_="DialogPortal",[qfe,FB]=DB(D_,{forceMount:void 0}),BB=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:a}=e,i=no(D_,t);return o.jsx(qfe,{scope:t,forceMount:r,children:x.Children.map(n,s=>o.jsx(to,{present:r||i.open,children:o.jsx(lv,{asChild:!0,container:a,children:s})}))})};BB.displayName=D_;var ny="DialogOverlay",zB=x.forwardRef((e,t)=>{const r=FB(ny,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=no(ny,e.__scopeDialog);return i.modal?o.jsx(to,{present:n||i.open,children:o.jsx(Wfe,{...a,ref:t})}):null});zB.displayName=ny;var Vfe=Rfe("DialogOverlay.RemoveScroll"),Wfe=x.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(ny,r);return o.jsx(uv,{as:Vfe,allowPinchZoom:!0,shards:[a.contentRef],children:o.jsx(lt.div,{"data-state":$_(a.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Zs="DialogContent",UB=x.forwardRef((e,t)=>{const r=FB(Zs,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=no(Zs,e.__scopeDialog);return o.jsx(to,{present:n||i.open,children:i.modal?o.jsx(Hfe,{...a,ref:t}):o.jsx(Gfe,{...a,ref:t})})});UB.displayName=Zs;var Hfe=x.forwardRef((e,t)=>{const r=no(Zs,e.__scopeDialog),n=x.useRef(null),a=At(t,r.contentRef,n);return x.useEffect(()=>{const i=n.current;if(i)return M_(i)},[]),o.jsx(qB,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:mt(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&i.preventDefault()}),onFocusOutside:mt(e.onFocusOutside,i=>i.preventDefault())})}),Gfe=x.forwardRef((e,t)=>{const r=no(Zs,e.__scopeDialog),n=x.useRef(!1),a=x.useRef(!1);return o.jsx(qB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),qB=x.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...s}=e,l=no(Zs,r),d=x.useRef(null),u=At(t,d);return S_(),o.jsxs(o.Fragment,{children:[o.jsx(rv,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:o.jsx(tv,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":$_(l.open),...s,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(Yfe,{titleId:l.titleId}),o.jsx(Xfe,{contentRef:d,descriptionId:l.descriptionId})]})]})}),L_="DialogTitle",VB=x.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(L_,r);return o.jsx(lt.h2,{id:a.titleId,...n,ref:t})});VB.displayName=L_;var WB="DialogDescription",HB=x.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(WB,r);return o.jsx(lt.p,{id:a.descriptionId,...n,ref:t})});HB.displayName=WB;var GB="DialogClose",YB=x.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(GB,r);return o.jsx(lt.button,{type:"button",...n,ref:t,onClick:mt(e.onClick,()=>a.onOpenChange(!1))})});YB.displayName=GB;function $_(e){return e?"open":"closed"}var KB="DialogTitleWarning",[x1e,XB]=xV(KB,{contentName:Zs,titleName:L_,docsSlug:"dialog"}),Yfe=({titleId:e})=>{const t=XB(KB),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. - -If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. - -For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return x.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Kfe="DialogDescriptionWarning",Xfe=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${XB(Kfe).contentName}}.`;return x.useEffect(()=>{const a=e.current?.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},JB=LB,QB=BB,ZB=zB,e8=UB,Jfe=VB,Qfe=HB,Zfe=YB;function _t({...e}){return o.jsx(JB,{"data-slot":"dialog",...e})}function ehe({...e}){return o.jsx(QB,{"data-slot":"dialog-portal",...e})}const t8=x.forwardRef(({className:e,...t},r)=>o.jsx(ZB,{ref:r,"data-slot":"dialog-overlay",className:Ie("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t}));t8.displayName="DialogOverlay";const Ct=x.forwardRef(({className:e,children:t,...r},n)=>o.jsxs(ehe,{"data-slot":"dialog-portal",children:[o.jsx(t8,{}),o.jsxs(e8,{ref:n,"data-slot":"dialog-content",className:Ie("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,o.jsxs(Zfe,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o.jsx($i,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ct.displayName="DialogContent";function Et({className:e,...t}){return o.jsx("div",{"data-slot":"dialog-header",className:Ie("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Dt({className:e,...t}){return o.jsx("div",{"data-slot":"dialog-footer",className:Ie("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Pt({className:e,...t}){return o.jsx(Jfe,{"data-slot":"dialog-title",className:Ie("text-lg leading-none font-semibold",e),...t})}function It({className:e,...t}){return o.jsx(Qfe,{"data-slot":"dialog-description",className:Ie("text-muted-foreground text-sm",e),...t})}var the=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],rhe=the.reduce((e,t)=>{const r=mC(`Primitive.${t}`),n=x.forwardRef((a,i)=>{const{asChild:s,...l}=a,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),nhe="Label",r8=x.forwardRef((e,t)=>o.jsx(rhe.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));r8.displayName=nhe;var ahe=r8;function de({className:e,...t}){return o.jsx(ahe,{"data-slot":"label",className:Ie("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}var pv="Switch",[ohe]=Eo(pv),[ihe,she]=ohe(pv),n8=x.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:i,required:s,disabled:l,value:d="on",onCheckedChange:u,form:f,...h}=e,[p,g]=x.useState(null),v=At(t,C=>g(C)),b=x.useRef(!1),w=p?f||!!p.closest("form"):!0,[j,N]=No({prop:a,defaultProp:i??!1,onChange:u,caller:pv});return o.jsxs(ihe,{scope:r,checked:j,disabled:l,children:[o.jsx(lt.button,{type:"button",role:"switch","aria-checked":j,"aria-required":s,"data-state":s8(j),"data-disabled":l?"":void 0,disabled:l,value:d,...h,ref:v,onClick:mt(e.onClick,C=>{N(O=>!O),w&&(b.current=C.isPropagationStopped(),b.current||C.stopPropagation())})}),w&&o.jsx(i8,{control:p,bubbles:!b.current,name:n,value:d,checked:j,required:s,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});n8.displayName=pv;var a8="SwitchThumb",o8=x.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,a=she(a8,r);return o.jsx(lt.span,{"data-state":s8(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:t})});o8.displayName=a8;var lhe="SwitchBubbleInput",i8=x.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...a},i)=>{const s=x.useRef(null),l=At(s,i),d=I_(r),u=O_(t);return x.useEffect(()=>{const f=s.current;if(!f)return;const h=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(h,"checked").set;if(d!==r&&g){const v=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(v)}},[d,r,n]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});i8.displayName=lhe;function s8(e){return e?"checked":"unchecked"}var che=n8,uhe=o8;function br({className:e,...t}){return o.jsx(che,{"data-slot":"switch",className:Ie("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-background focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:o.jsx(uhe,{"data-slot":"switch-thumb",className:Ie("bg-card dark:data-[state=unchecked]:bg-card-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Qa(e){return Math.max(1,e)}function dhe(e){const t=fhe(e),r=x.forwardRef((n,a)=>{const{children:i,...s}=n,l=x.Children.toArray(i),d=l.find(mhe);if(d){const u=d.props.children,f=l.map(h=>h===d?x.Children.count(u)>1?x.Children.only(null):x.isValidElement(u)?u.props.children:null:h);return o.jsx(t,{...s,ref:a,children:x.isValidElement(u)?x.cloneElement(u,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function fhe(e){const t=x.forwardRef((r,n)=>{const{children:a,...i}=r;if(x.isValidElement(a)){const s=ghe(a),l=phe(i,a.props);return a.type!==x.Fragment&&(l.ref=n?Oa(n,s):s),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var hhe=Symbol("radix.slottable");function mhe(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hhe}function phe(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function ghe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var gv="Popover",[l8]=Eo(gv,[sv]),Gf=sv(),[yhe,Qi]=l8(gv),c8=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:s=!1}=e,l=Gf(t),d=x.useRef(null),[u,f]=x.useState(!1),[h,p]=No({prop:n,defaultProp:a??!1,onChange:i,caller:gv});return o.jsx(QF,{...l,children:o.jsx(yhe,{scope:t,contentId:Bn(),triggerRef:d,open:h,onOpenChange:p,onOpenToggle:x.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:u,onCustomAnchorAdd:x.useCallback(()=>f(!0),[]),onCustomAnchorRemove:x.useCallback(()=>f(!1),[]),modal:s,children:r})})};c8.displayName=gv;var u8="PopoverAnchor",vhe=x.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Qi(u8,r),i=Gf(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:l}=a;return x.useEffect(()=>(s(),()=>l()),[s,l]),o.jsx(A_,{...i,...n,ref:t})});vhe.displayName=u8;var d8="PopoverTrigger",f8=x.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Qi(d8,r),i=Gf(r),s=At(t,a.triggerRef),l=o.jsx(lt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":y8(a.open),...n,ref:s,onClick:mt(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:o.jsx(A_,{asChild:!0,...i,children:l})});f8.displayName=d8;var F_="PopoverPortal",[xhe,bhe]=l8(F_,{forceMount:void 0}),h8=e=>{const{__scopePopover:t,forceMount:r,children:n,container:a}=e,i=Qi(F_,t);return o.jsx(xhe,{scope:t,forceMount:r,children:o.jsx(to,{present:r||i.open,children:o.jsx(lv,{asChild:!0,container:a,children:n})})})};h8.displayName=F_;var eu="PopoverContent",m8=x.forwardRef((e,t)=>{const r=bhe(eu,e.__scopePopover),{forceMount:n=r.forceMount,...a}=e,i=Qi(eu,e.__scopePopover);return o.jsx(to,{present:n||i.open,children:i.modal?o.jsx(She,{...a,ref:t}):o.jsx(jhe,{...a,ref:t})})});m8.displayName=eu;var whe=dhe("PopoverContent.RemoveScroll"),She=x.forwardRef((e,t)=>{const r=Qi(eu,e.__scopePopover),n=x.useRef(null),a=At(t,n),i=x.useRef(!1);return x.useEffect(()=>{const s=n.current;if(s)return M_(s)},[]),o.jsx(uv,{as:whe,allowPinchZoom:!0,children:o.jsx(p8,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:mt(e.onPointerDownOutside,s=>{const l=s.detail.originalEvent,d=l.button===0&&l.ctrlKey===!0,u=l.button===2||d;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:mt(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),jhe=x.forwardRef((e,t)=>{const r=Qi(eu,e.__scopePopover),n=x.useRef(!1),a=x.useRef(!1);return o.jsx(p8,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),p8=x.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,...h}=e,p=Qi(eu,r),g=Gf(r);return S_(),o.jsx(rv,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:o.jsx(tv,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:u,onDismiss:()=>p.onOpenChange(!1),children:o.jsx(ZF,{"data-state":y8(p.open),role:"dialog",id:p.contentId,...g,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),g8="PopoverClose",Nhe=x.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Qi(g8,r);return o.jsx(lt.button,{type:"button",...n,ref:t,onClick:mt(e.onClick,()=>a.onOpenChange(!1))})});Nhe.displayName=g8;var Che="PopoverArrow",_he=x.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Gf(r);return o.jsx(eB,{...a,...n,ref:t})});_he.displayName=Che;function y8(e){return e?"open":"closed"}var Ehe=c8,Phe=f8,Ohe=h8,The=m8;function ka({...e}){return o.jsx(Ehe,{"data-slot":"popover",...e})}function Aa({...e}){return o.jsx(Phe,{"data-slot":"popover-trigger",...e})}function Ia({className:e,align:t="center",sideOffset:r=4,...n}){return o.jsx(Ohe,{children:o.jsx(The,{"data-slot":"popover-content",align:t,sideOffset:r,className:Ie("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...n})})}var LD=1,khe=.9,Ahe=.8,Ihe=.17,VS=.1,WS=.999,Mhe=.9999,Rhe=.99,Dhe=/[\\\/_+.#"@\[\(\{&]/,Lhe=/[\\\/_+.#"@\[\(\{&]/g,$he=/[\s-]/,v8=/[\s-]/g;function HN(e,t,r,n,a,i,s){if(i===t.length)return a===e.length?LD:Rhe;var l=`${a},${i}`;if(s[l]!==void 0)return s[l];for(var d=n.charAt(i),u=r.indexOf(d,a),f=0,h,p,g,v;u>=0;)h=HN(e,t,r,n,u+1,i+1,s),h>f&&(u===a?h*=LD:Dhe.test(e.charAt(u-1))?(h*=Ahe,g=e.slice(a,u-1).match(Lhe),g&&a>0&&(h*=Math.pow(WS,g.length))):$he.test(e.charAt(u-1))?(h*=khe,v=e.slice(a,u-1).match(v8),v&&a>0&&(h*=Math.pow(WS,v.length))):(h*=Ihe,a>0&&(h*=Math.pow(WS,u-a))),e.charAt(u)!==t.charAt(i)&&(h*=Mhe)),(hh&&(h=p*VS)),h>f&&(f=h),u=r.indexOf(d,u+1);return s[l]=f,f}function $D(e){return e.toLowerCase().replace(v8," ")}function Fhe(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,HN(e,t,$D(e),$D(t),0,0,{})}var Nd='[cmdk-group=""]',HS='[cmdk-group-items=""]',Bhe='[cmdk-group-heading=""]',x8='[cmdk-item=""]',FD=`${x8}:not([aria-disabled="true"])`,GN="cmdk-item-select",oc="data-value",zhe=(e,t,r)=>Fhe(e,t,r),b8=x.createContext(void 0),Yf=()=>x.useContext(b8),w8=x.createContext(void 0),B_=()=>x.useContext(w8),S8=x.createContext(void 0),j8=x.forwardRef((e,t)=>{let r=ic(()=>{var $,K;return{search:"",value:(K=($=e.value)!=null?$:e.defaultValue)!=null?K:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=ic(()=>new Set),a=ic(()=>new Map),i=ic(()=>new Map),s=ic(()=>new Set),l=N8(e),{label:d,children:u,value:f,onValueChange:h,filter:p,shouldFilter:g,loop:v,disablePointerSelection:b=!1,vimBindings:w=!0,...j}=e,N=Bn(),C=Bn(),O=Bn(),P=x.useRef(null),E=Qhe();el(()=>{if(f!==void 0){let $=f.trim();r.current.value=$,T.emit()}},[f]),el(()=>{E(6,z)},[]);let T=x.useMemo(()=>({subscribe:$=>(s.current.add($),()=>s.current.delete($)),snapshot:()=>r.current,setState:($,K,J)=>{var oe,re,Q,ue;if(!Object.is(r.current[$],K)){if(r.current[$]=K,$==="search")V(),R(),E(1,L);else if($==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let se=document.getElementById(O);se?se.focus():(oe=document.getElementById(N))==null||oe.focus()}if(E(7,()=>{var se;r.current.selectedItemId=(se=G())==null?void 0:se.id,T.emit()}),J||E(5,z),((re=l.current)==null?void 0:re.value)!==void 0){let se=K??"";(ue=(Q=l.current).onValueChange)==null||ue.call(Q,se);return}}T.emit()}},emit:()=>{s.current.forEach($=>$())}}),[]),A=x.useMemo(()=>({value:($,K,J)=>{var oe;K!==((oe=i.current.get($))==null?void 0:oe.value)&&(i.current.set($,{value:K,keywords:J}),r.current.filtered.items.set($,M(K,J)),E(2,()=>{R(),T.emit()}))},item:($,K)=>(n.current.add($),K&&(a.current.has(K)?a.current.get(K).add($):a.current.set(K,new Set([$]))),E(3,()=>{V(),R(),r.current.value||L(),T.emit()}),()=>{i.current.delete($),n.current.delete($),r.current.filtered.items.delete($);let J=G();E(4,()=>{V(),J?.getAttribute("id")===$&&L(),T.emit()})}),group:$=>(a.current.has($)||a.current.set($,new Set),()=>{i.current.delete($),a.current.delete($)}),filter:()=>l.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:N,inputId:O,labelId:C,listInnerRef:P}),[]);function M($,K){var J,oe;let re=(oe=(J=l.current)==null?void 0:J.filter)!=null?oe:zhe;return $?re($,r.current.search,K):0}function R(){if(!r.current.search||l.current.shouldFilter===!1)return;let $=r.current.filtered.items,K=[];r.current.filtered.groups.forEach(oe=>{let re=a.current.get(oe),Q=0;re.forEach(ue=>{let se=$.get(ue);Q=Math.max(se,Q)}),K.push([oe,Q])});let J=P.current;H().sort((oe,re)=>{var Q,ue;let se=oe.getAttribute("id"),fe=re.getAttribute("id");return((Q=$.get(fe))!=null?Q:0)-((ue=$.get(se))!=null?ue:0)}).forEach(oe=>{let re=oe.closest(HS);re?re.appendChild(oe.parentElement===re?oe:oe.closest(`${HS} > *`)):J.appendChild(oe.parentElement===J?oe:oe.closest(`${HS} > *`))}),K.sort((oe,re)=>re[1]-oe[1]).forEach(oe=>{var re;let Q=(re=P.current)==null?void 0:re.querySelector(`${Nd}[${oc}="${encodeURIComponent(oe[0])}"]`);Q?.parentElement.appendChild(Q)})}function L(){let $=H().find(J=>J.getAttribute("aria-disabled")!=="true"),K=$?.getAttribute(oc);T.setState("value",K||void 0)}function V(){var $,K,J,oe;if(!r.current.search||l.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let re=0;for(let Q of n.current){let ue=(K=($=i.current.get(Q))==null?void 0:$.value)!=null?K:"",se=(oe=(J=i.current.get(Q))==null?void 0:J.keywords)!=null?oe:[],fe=M(ue,se);r.current.filtered.items.set(Q,fe),fe>0&&re++}for(let[Q,ue]of a.current)for(let se of ue)if(r.current.filtered.items.get(se)>0){r.current.filtered.groups.add(Q);break}r.current.filtered.count=re}function z(){var $,K,J;let oe=G();oe&&((($=oe.parentElement)==null?void 0:$.firstChild)===oe&&((J=(K=oe.closest(Nd))==null?void 0:K.querySelector(Bhe))==null||J.scrollIntoView({block:"nearest"})),oe.scrollIntoView({block:"nearest"}))}function G(){var $;return($=P.current)==null?void 0:$.querySelector(`${x8}[aria-selected="true"]`)}function H(){var $;return Array.from((($=P.current)==null?void 0:$.querySelectorAll(FD))||[])}function W($){let K=H()[$];K&&T.setState("value",K.getAttribute(oc))}function q($){var K;let J=G(),oe=H(),re=oe.findIndex(ue=>ue===J),Q=oe[re+$];(K=l.current)!=null&&K.loop&&(Q=re+$<0?oe[oe.length-1]:re+$===oe.length?oe[0]:oe[re+$]),Q&&T.setState("value",Q.getAttribute(oc))}function I($){let K=G(),J=K?.closest(Nd),oe;for(;J&&!oe;)J=$>0?Xhe(J,Nd):Jhe(J,Nd),oe=J?.querySelector(FD);oe?T.setState("value",oe.getAttribute(oc)):q($)}let Y=()=>W(H().length-1),F=$=>{$.preventDefault(),$.metaKey?Y():$.altKey?I(1):q(1)},D=$=>{$.preventDefault(),$.metaKey?W(0):$.altKey?I(-1):q(-1)};return x.createElement(lt.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:$=>{var K;(K=j.onKeyDown)==null||K.call(j,$);let J=$.nativeEvent.isComposing||$.keyCode===229;if(!($.defaultPrevented||J))switch($.key){case"n":case"j":{w&&$.ctrlKey&&F($);break}case"ArrowDown":{F($);break}case"p":case"k":{w&&$.ctrlKey&&D($);break}case"ArrowUp":{D($);break}case"Home":{$.preventDefault(),W(0);break}case"End":{$.preventDefault(),Y();break}case"Enter":{$.preventDefault();let oe=G();if(oe){let re=new Event(GN);oe.dispatchEvent(re)}}}}},x.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:eme},d),yv(e,$=>x.createElement(w8.Provider,{value:T},x.createElement(b8.Provider,{value:A},$))))}),Uhe=x.forwardRef((e,t)=>{var r,n;let a=Bn(),i=x.useRef(null),s=x.useContext(S8),l=Yf(),d=N8(e),u=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:s?.forceMount;el(()=>{if(!u)return l.item(a,s?.id)},[u]);let f=C8(a,i,[e.value,e.children,i],e.keywords),h=B_(),p=Wi(E=>E.value&&E.value===f.current),g=Wi(E=>u||l.filter()===!1?!0:E.search?E.filtered.items.get(a)>0:!0);x.useEffect(()=>{let E=i.current;if(!(!E||e.disabled))return E.addEventListener(GN,v),()=>E.removeEventListener(GN,v)},[g,e.onSelect,e.disabled]);function v(){var E,T;b(),(T=(E=d.current).onSelect)==null||T.call(E,f.current)}function b(){h.setState("value",f.current,!0)}if(!g)return null;let{disabled:w,value:j,onSelect:N,forceMount:C,keywords:O,...P}=e;return x.createElement(lt.div,{ref:Oa(i,t),...P,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!p,"data-disabled":!!w,"data-selected":!!p,onPointerMove:w||l.getDisablePointerSelection()?void 0:b,onClick:w?void 0:v},e.children)}),qhe=x.forwardRef((e,t)=>{let{heading:r,children:n,forceMount:a,...i}=e,s=Bn(),l=x.useRef(null),d=x.useRef(null),u=Bn(),f=Yf(),h=Wi(g=>a||f.filter()===!1?!0:g.search?g.filtered.groups.has(s):!0);el(()=>f.group(s),[]),C8(s,l,[e.value,e.heading,d]);let p=x.useMemo(()=>({id:s,forceMount:a}),[a]);return x.createElement(lt.div,{ref:Oa(l,t),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&x.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),yv(e,g=>x.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},x.createElement(S8.Provider,{value:p},g))))}),Vhe=x.forwardRef((e,t)=>{let{alwaysRender:r,...n}=e,a=x.useRef(null),i=Wi(s=>!s.search);return!r&&!i?null:x.createElement(lt.div,{ref:Oa(a,t),...n,"cmdk-separator":"",role:"separator"})}),Whe=x.forwardRef((e,t)=>{let{onValueChange:r,...n}=e,a=e.value!=null,i=B_(),s=Wi(u=>u.search),l=Wi(u=>u.selectedItemId),d=Yf();return x.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),x.createElement(lt.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":l,id:d.inputId,type:"text",value:a?e.value:s,onChange:u=>{a||i.setState("search",u.target.value),r?.(u.target.value)}})}),Hhe=x.forwardRef((e,t)=>{let{children:r,label:n="Suggestions",...a}=e,i=x.useRef(null),s=x.useRef(null),l=Wi(u=>u.selectedItemId),d=Yf();return x.useEffect(()=>{if(s.current&&i.current){let u=s.current,f=i.current,h,p=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let g=u.offsetHeight;f.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return p.observe(u),()=>{cancelAnimationFrame(h),p.unobserve(u)}}},[]),x.createElement(lt.div,{ref:Oa(i,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":n,id:d.listId},yv(e,u=>x.createElement("div",{ref:Oa(s,d.listInnerRef),"cmdk-list-sizer":""},u)))}),Ghe=x.forwardRef((e,t)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:i,container:s,...l}=e;return x.createElement(JB,{open:r,onOpenChange:n},x.createElement(QB,{container:s},x.createElement(ZB,{"cmdk-overlay":"",className:a}),x.createElement(e8,{"aria-label":e.label,"cmdk-dialog":"",className:i},x.createElement(j8,{ref:t,...l}))))}),Yhe=x.forwardRef((e,t)=>Wi(r=>r.filtered.count===0)?x.createElement(lt.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Khe=x.forwardRef((e,t)=>{let{progress:r,children:n,label:a="Loading...",...i}=e;return x.createElement(lt.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},yv(e,s=>x.createElement("div",{"aria-hidden":!0},s)))}),ju=Object.assign(j8,{List:Hhe,Item:Uhe,Input:Whe,Group:qhe,Separator:Vhe,Dialog:Ghe,Empty:Yhe,Loading:Khe});function Xhe(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function Jhe(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function N8(e){let t=x.useRef(e);return el(()=>{t.current=e}),t}var el=typeof window>"u"?x.useEffect:x.useLayoutEffect;function ic(e){let t=x.useRef();return t.current===void 0&&(t.current=e()),t}function Wi(e){let t=B_(),r=()=>e(t.snapshot());return x.useSyncExternalStore(t.subscribe,r,r)}function C8(e,t,r,n=[]){let a=x.useRef(),i=Yf();return el(()=>{var s;let l=(()=>{var u;for(let f of r){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(u=f.current.textContent)==null?void 0:u.trim():a.current}})(),d=n.map(u=>u.trim());i.value(e,l,d),(s=t.current)==null||s.setAttribute(oc,l),a.current=l}),a}var Qhe=()=>{let[e,t]=x.useState(),r=ic(()=>new Map);return el(()=>{r.current.forEach(n=>n()),r.current=new Map},[e]),(n,a)=>{r.current.set(n,a),t({})}};function Zhe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function yv({asChild:e,children:t},r){return e&&x.isValidElement(t)?x.cloneElement(Zhe(t),{ref:t.ref},r(t.props.children)):r(t)}var eme={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function tme({className:e,...t}){return o.jsx(ju,{"data-slot":"command",className:Ie("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function rme({className:e,...t}){return o.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[o.jsx(Rf,{className:"size-4 shrink-0 opacity-50"}),o.jsx(ju.Input,{"data-slot":"command-input",className:Ie("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function nme({className:e,...t}){return o.jsx(ju.List,{"data-slot":"command-list",className:Ie("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function ame({...e}){return o.jsx(ju.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function ome({className:e,...t}){return o.jsx(ju.Group,{"data-slot":"command-group",className:Ie("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function ime({className:e,...t}){return o.jsx(ju.Item,{"data-slot":"command-item",className:Ie("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function $n({value:e,onValueChange:t,options:r,placeholder:n="Select…",searchPlaceholder:a="Search…",emptyText:i="No matching results.",disabled:s,className:l}){const[d,u]=x.useState(!1),f=e?r.find(p=>p.value===e):void 0,h=e?f?.label??e:null;return o.jsxs(ka,{open:d,onOpenChange:u,children:[o.jsx(Aa,{asChild:!0,children:o.jsxs(ce,{type:"button",variant:"outline",role:"combobox","aria-expanded":d,disabled:s,className:Ie("w-full justify-between h-10 px-3 font-normal border border-gray-300 bg-white",l),children:[o.jsx("span",{className:Ie("truncate text-left text-sm",!h&&"text-gray-500"),children:h??n}),o.jsx(N$,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o.jsxs(Ia,{className:"p-0 w-[var(--radix-popover-trigger-width)] max-w-[min(100vw-2rem,400px)]",align:"start",children:[o.jsxs(tme,{children:[o.jsx(rme,{placeholder:a}),o.jsxs(nme,{children:[o.jsx(ame,{children:i}),o.jsx(ome,{children:r.map(p=>o.jsx(ime,{value:`${p.label} ${p.value}`,onSelect:()=>{t(p.value),u(!1)},className:Ie("cursor-pointer rounded-md px-2 py-2 transition-colors","hover:bg-gray-100 hover:text-gray-900","data-[selected=true]:bg-gray-100",e===p.value&&"bg-blue-50 text-gray-900 font-medium data-[selected=true]:bg-blue-100"),children:o.jsx("span",{className:"truncate",children:p.label})},p.value))})]})]}),e?o.jsx("div",{className:"border-t border-gray-100 px-2 py-1.5",children:o.jsx("button",{type:"button",className:"text-xs text-gray-500 hover:text-gray-900 underline-offset-2 hover:underline",onClick:()=>{t(""),u(!1)},children:"Clear selection"})}):null]})]})}function ia({className:e,...t}){return o.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:Ie("mx-auto flex w-full justify-center",e),...t})}function sa({className:e,...t}){return o.jsx("ul",{"data-slot":"pagination-content",className:Ie("flex flex-row items-center gap-1",e),...t})}function wt({...e}){return o.jsx("li",{"data-slot":"pagination-item",...e})}function Cn({className:e,isActive:t,size:r="icon",...n}){return o.jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:Ie(Kp({variant:t?"outline":"ghost",size:r}),e),...n})}function la({className:e,...t}){return o.jsxs(Cn,{"aria-label":"Go to previous page",size:"default",className:Ie("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[o.jsx(oC,{}),o.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function ca({className:e,...t}){return o.jsxs(Cn,{"aria-label":"Go to next page",size:"default",className:Ie("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[o.jsx("span",{className:"hidden sm:block",children:"Next"}),o.jsx(Ui,{})]})}const Kf=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Xf="/label";async function sme(e,t){return Kf.requestJson({path:Xf,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,LocationId:e.locationId,ProductId:e.productId,LabelCategoryId:e.labelCategoryId,LabelTypeId:e.labelTypeId,TemplateCode:e.templateCode,State:e.state},signal:t})}async function lme(e,t){return Kf.requestJson({path:`${Xf}/${encodeURIComponent(e)}`,method:"GET",signal:t})}async function cme(e){return Kf.requestJson({path:Xf,method:"POST",body:{labelCode:String(e.labelCode??"").trim()||null,labelName:e.labelName,templateCode:e.templateCode,locationId:e.locationId,labelCategoryId:e.labelCategoryId,labelTypeId:e.labelTypeId,productIds:e.productIds,labelInfoJson:e.labelInfoJson,state:e.state??!0}})}async function ume(e,t){return Kf.requestJson({path:`${Xf}/${encodeURIComponent(e)}`,method:"PUT",body:{labelName:t.labelName,templateCode:t.templateCode,locationId:t.locationId,labelCategoryId:t.labelCategoryId,labelTypeId:t.labelTypeId,productIds:t.productIds,labelInfoJson:t.labelInfoJson,state:t.state??!0}})}async function dme(e){await Kf.requestJson({path:`${Xf}/${encodeURIComponent(e)}`,method:"DELETE"})}const _8="/api/app";function E8(e,t){const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function fme(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))if(!(a==null||a==="")){if(typeof a=="boolean"){t.set(n,a?"true":"false");continue}t.set(n,String(a))}const r=t.toString();return r?`?${r}`:""}function P8(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}function hme(e){if(!e)return null;const t=/filename\*?=(?:UTF-8''|)([^;]+)/i.exec(e);return t?.[1]?decodeURIComponent(t[1].trim().replace(/^["']|["']$/g,"")):null}function ay(e){return!e||typeof e!="object"?null:e.error?.message?.trim()||null}function mme(e){if(!e||typeof e!="object")return e;const t=e;if("data"in t&&t.data!==void 0){if(t.succeeded===!1){const r=(typeof t.error?.message=="string"?t.error.message.trim():"")||ay(e)||"Request failed.";throw new Yr(r,typeof t.statusCode=="number"?t.statusCode:400,e)}return t.data}return e}async function dl(e){const r=E8("http://flus-test.3ffoodsafety.com",`${_8}${e.path}${fme(e.query??{})}`),n=P8(),a=await fetch(r,{method:"GET",headers:n?{Authorization:`Bearer ${n}`}:{},signal:e.signal}),i=a.headers.get("content-type")??"";if(!a.ok){if(i.includes("application/json")){const h=await a.json().catch(()=>null),p=ay(h)||"Download failed.";throw new Yr(p,a.status,h)}const f=await a.text().catch(()=>"");throw new Yr(f||"Download failed.",a.status,f)}if(i.includes("application/json")){const f=await a.json().catch(()=>null),h=ay(f)||"Download failed.";throw new Yr(h,a.status,f)}const s=await a.blob(),l=hme(a.headers.get("content-disposition"))||e.defaultFileName,d=URL.createObjectURL(s),u=document.createElement("a");u.href=d,u.download=l,u.click(),URL.revokeObjectURL(d)}async function z_(e){const r=E8("http://flus-test.3ffoodsafety.com",`${_8}${e.path}`),n=P8(),a=new FormData;a.append(e.fieldName,e.file);const i={};n&&(i.Authorization=`Bearer ${n}`);const s=await fetch(r,{method:"POST",headers:i,body:a,signal:e.signal}),d=(s.headers.get("content-type")??"").includes("application/json")?await s.json().catch(()=>null):await s.text().catch(()=>"");if(!s.ok){const u=typeof d=="object"&&d&&ay(d)||typeof d=="string"&&d.trim()||"Upload failed.";throw new Yr(u,s.status,d)}if(typeof d!="object"||d===null)throw new Yr("Invalid import response.",s.status,d);return mme(d)}const Jf=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});async function Nu(e,t){return Jf.requestJson({path:"/location",method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,Partner:e.partner,GroupName:e.groupName,State:e.state},signal:t})}async function pme(e){return Jf.requestJson({path:"/location",method:"POST",body:{partner:e.partner,groupName:e.groupName,locationCode:e.locationCode,locationName:e.locationName,street:e.street,city:e.city,stateCode:e.stateCode,country:e.country,zipCode:e.zipCode,phone:e.phone,email:e.email,latitude:e.latitude,longitude:e.longitude,state:e.state??!0}})}async function gme(e,t){return Jf.requestJson({path:`/location/${encodeURIComponent(e)}`,method:"PUT",body:{partner:t.partner,groupName:t.groupName,locationCode:t.locationCode,locationName:t.locationName,street:t.street,city:t.city,stateCode:t.stateCode,country:t.country,zipCode:t.zipCode,phone:t.phone,email:t.email,latitude:t.latitude,longitude:t.longitude,state:t.state??!0}})}async function yme(e){await Jf.requestJson({path:`/location/${encodeURIComponent(e)}`,method:"DELETE"})}async function vme(e){await dl({path:"/location/download-location-import-template",defaultFileName:"Location-Manager-template.xlsx",signal:e})}async function xme(e,t){await dl({path:"/location/export-locations-excel",query:{Sorting:e.sorting,Keyword:e.keyword,Partner:e.partner,GroupName:e.groupName,State:e.state},defaultFileName:"locations-export.xlsx",signal:t})}async function bme(e,t){return z_({path:"/location/import-locations-batch",fieldName:"file",file:e,signal:t})}async function wme(e){return Jf.requestJson({path:"/location/update-locations-bulk",method:"POST",body:e})}const Sme=["TEXT","COLOR","IMAGE"];function tl(e){if(e==null)return[];if(Array.isArray(e)){const n=new Set;for(const a of e){const i=String(a??"").trim().toUpperCase();(i==="TEXT"||i==="COLOR"||i==="IMAGE")&&n.add(i)}return Sme.filter(a=>n.has(a))}const t=String(e).trim();if(!t)return[];if(t.startsWith("["))try{const n=JSON.parse(t);if(Array.isArray(n))return tl(n)}catch{}const r=t.toUpperCase();return r==="TEXT"||r==="COLOR"||r==="IMAGE"?[r]:[]}function bc(e){return e.length===1&&e[0]==="IMAGE"?{text:!1,color:!1,image:!0}:{text:e.includes("TEXT"),color:e.includes("COLOR"),image:!1}}function U_(e){if(e.image)return["IMAGE"];const t=[];return e.text&&t.push("TEXT"),e.color&&t.push("COLOR"),t}function Ls(e){const t=String(e??"").trim();return t?/^#([0-9a-f]{6}|[0-9a-f]{3})$/i.test(t)?t:/^([0-9a-f]{6}|[0-9a-f]{3})$/i.test(t)?`#${t}`:"":""}function Bp(e){return e?!!(/^https?:\/\//i.test(e)||e.startsWith("/")||/\.(png|jpe?g|gif|webp|svg)(\?|$)/i.test(e)):!1}function q_(e){const t={v:1,appearances:e.appearances,displayText:(e.displayText??"").trim()||null,buttonBgColor:(e.buttonBgColor??"").trim()||null,buttonTextColor:(e.buttonTextColor??"").trim()||null,buttonImageUrl:(e.buttonImageUrl??"").trim()||null};return JSON.stringify(t)}function V_(e){const t=String(e??"").trim();if(!t.startsWith("["))return null;try{const r=JSON.parse(t);return Array.isArray(r)?r.map(n=>n==null?"":String(n)):null}catch{return null}}function W_(e,t,r){const n={buttonAppearance:e,categoryName:r.categoryName,name:r.name,buttonTextColor:r.buttonTextColor,categoryPhotoUrl:""},a=Math.min(e.length,t.length);for(let i=0;iString(a??"").trim()).filter(a=>a.length>0);return n.length===0?null:JSON.stringify(n)}const t=String(e).trim();if(!t)return null;if(t.startsWith("["))try{const n=JSON.parse(t);if(Array.isArray(n)){const a=n.map(i=>String(i??"").trim()).filter(i=>i.length>0);return a.length===0?null:JSON.stringify(a)}}catch{return t}const r=t.toUpperCase();return r==="TEXT"||r==="COLOR"||r==="IMAGE"?JSON.stringify([r]):t}function oy(e){const t=(e??"").trim();if(!t)return null;try{const r=JSON.parse(t);if(!r||typeof r!="object")return null;const n=tl(r.appearances??r.buttonAppearance);return n.length===0?null:{v:1,appearances:n,displayText:r.displayText!=null?String(r.displayText):null,buttonBgColor:r.buttonBgColor!=null?String(r.buttonBgColor):null,buttonTextColor:r.buttonTextColor!=null?String(r.buttonTextColor):null,buttonImageUrl:r.buttonImageUrl!=null?String(r.buttonImageUrl):null}}catch{return null}}function jme(e){const t=oy(e.buttonStyleJson);if(t)return{buttonAppearance:t.appearances,displayText:t.displayText??e.displayText,buttonBgColor:t.buttonBgColor??e.buttonBgColor,buttonTextColor:t.buttonTextColor??e.buttonTextColor,buttonImageUrl:t.buttonImageUrl??e.buttonImageUrl,categoryPhotoUrl:e.categoryPhotoUrl,categoryName:e.categoryName,name:e.name};const r=tl(e.buttonAppearance),n=V_(e.categoryPhotoUrl);return n&&r.length>0&&r.length===n.length?W_(r,n,e):{buttonAppearance:e.buttonAppearance,displayText:e.displayText,buttonBgColor:e.buttonBgColor,buttonTextColor:e.buttonTextColor,buttonImageUrl:e.buttonImageUrl,categoryPhotoUrl:e.categoryPhotoUrl,categoryName:e.categoryName,name:e.name}}function O8(e){return G_(jme(e))}function G_(e){const t=tl(e.buttonAppearance),r=(e.categoryName??e.name??"").trim(),n=(e.displayText??"").trim(),a=Ls(e.buttonBgColor),i=(e.buttonImageUrl??"").trim(),s=String(e.categoryPhotoUrl??"").trim();if(t.includes("IMAGE")){const p=i||(s&&Bp(s)?s:"");return p?{mode:"image",imageUrl:p}:{mode:"none"}}const l=t.includes("TEXT"),d=t.includes("COLOR");let u=a;!u&&d&&(u=Ls(s));let f=n;l&&!f&&s&&!Ls(s)&&!Bp(s)&&(f=s);const h=(f||r).trim();if(l&&d&&u)return{mode:"colorText",bg:u,text:h||r,textColor:(e.buttonTextColor??"").trim()||null};if(d&&u)return{mode:"color",bg:u};if(l&&h)return{mode:"text",text:h};if(t.length===0){const p=Ls(s);return p?{mode:"color",bg:p}:s&&Bp(s)?{mode:"image",imageUrl:s}:s?{mode:"text",text:s}:{mode:"none"}}return{mode:"none"}}const xv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),bv="/label-category";async function T8(e,t){return xv.requestJson({path:bv,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function Nme(e){return xv.requestJson({path:bv,method:"POST",body:{categoryCode:String(e.categoryCode??"").trim()||null,categoryName:e.categoryName,categoryPhotoUrl:e.categoryPhotoUrl,displayText:(e.displayText??"").trim()||null,buttonBgColor:(e.buttonBgColor??"").trim()||null,buttonImageUrl:(e.buttonImageUrl??"").trim()||null,buttonAppearance:vv(e.buttonAppearance),buttonStyleJson:(e.buttonStyleJson??"").trim()||null,state:e.state??!0,orderNum:e.orderNum}})}async function Cme(e,t){return xv.requestJson({path:`${bv}/${encodeURIComponent(e)}`,method:"PUT",body:{categoryCode:String(t.categoryCode??"").trim()||null,categoryName:t.categoryName,categoryPhotoUrl:t.categoryPhotoUrl,displayText:(t.displayText??"").trim()||null,buttonBgColor:(t.buttonBgColor??"").trim()||null,buttonImageUrl:(t.buttonImageUrl??"").trim()||null,buttonAppearance:vv(t.buttonAppearance),buttonStyleJson:(t.buttonStyleJson??"").trim()||null,state:t.state??!0,orderNum:t.orderNum}})}async function _me(e){await xv.requestJson({path:`${bv}/${encodeURIComponent(e)}`,method:"DELETE"})}const wv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Sv="/label-type";async function Y_(e,t){return wv.requestJson({path:Sv,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function Eme(e){return wv.requestJson({path:Sv,method:"POST",body:{typeCode:String(e.typeCode??"").trim()||null,typeName:e.typeName,state:e.state??!0,orderNum:e.orderNum}})}async function Pme(e,t){return wv.requestJson({path:`${Sv}/${encodeURIComponent(e)}`,method:"PUT",body:{typeCode:String(t.typeCode??"").trim()||null,typeName:t.typeName,state:t.state??!0,orderNum:t.orderNum}})}async function Ome(e){await wv.requestJson({path:`${Sv}/${encodeURIComponent(e)}`,method:"DELETE"})}const rl=[{key:"fat",label:"Total Fat",defaultUnit:"g"},{key:"saturatedFat",label:"Saturated Fat",defaultUnit:"g"},{key:"transFat",label:"Trans Fat",defaultUnit:"g"},{key:"cholesterol",label:"Cholesterol",defaultUnit:"mg"},{key:"sodium",label:"Sodium",defaultUnit:"mg"},{key:"carbs",label:"Total Carbohydrates",defaultUnit:"g"},{key:"dietaryFiber",label:"Dietary Fiber",defaultUnit:"g"},{key:"totalSugar",label:"Total Sugar",defaultUnit:"g"},{key:"protein",label:"Protein",defaultUnit:"g"},{key:"vitaminA",label:"Vitamin A",defaultUnit:"mcg"},{key:"vitaminC",label:"Vitamin C",defaultUnit:"mg"},{key:"calcium",label:"Calcium",defaultUnit:"mg"},{key:"iron",label:"Iron",defaultUnit:"mg"}],k8=["Template","Label","Auto-generated","Print input"],A8={模版信息:"Template",模板信息:"Template",标签信息:"Label",自动生成:"Auto-generated",打印时输入:"Print input"};function K_(e){const t=String(e??"").trim();return k8.includes(t)?t:A8[t]??"Template"}function I8(e){const t=String(e??"").trim();return k8.includes(t)||t in A8}function M8(e){const t=K_(String(e));return t==="Auto-generated"?"AUTO_DB":t==="Print input"?"PRINT_INPUT":"FIXED"}function Tme(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"")||"field"}function kme(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ame(e,t){const r=Tme(e),n=new RegExp(`^${kme(r)}(\\d+)$`,"i"),a=[];for(const s of t){const l=(s.elementName??"").trim();if(!l)continue;const d=l.match(n);d&&a.push(parseInt(d[1],10)),l.toLowerCase()===r&&a.push(1)}const i=a.length>0?Math.max(...a)+1:1;return`${r}${i}`}const Ime={Template:"template",Label:"label","Auto-generated":"auto","Print input":"print"};function X_(e,t){const r=Ime[e],n=(t??"").trim()||"Field";return`${r}_${n}`}const Mme=/^(template|label|auto|print)_/;function Rme(e){return Mme.test(e.trim())}function R8(e){const t=e.config??{},r=Kr(e.type);if(ru(e)){if(r==="TEXT_STATIC"){const n=t.inputType;return n==="number"?"Number":n==="options"?"Multiple Options":"Text"}if(r==="DATE")return"Date & Time";if(r==="WEIGHT")return"Weight"}switch(r){case"TEXT_PRODUCT":return"Label Name";case"TEXT_PRICE":return"Price";case"NUTRITION":return"Nutrition Facts";case"DURATION":return"Duration";case"DATE":return"Current Date";case"TIME":return"Current Time";case"BARCODE":return"Barcode";case"QRCODE":return"QR Code";case"BLANK":return"Blank Space";case"IMAGE":return"Image";case"WEIGHT_PRICE":return"Weight Price";case"TEXT_STATIC":return"Text";default:return r.replace(/_/g," ")}}function Dme(){return`template-${Date.now()}`}function Lme(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function $me(e){return{id:e??Dme(),name:"Unnamed template",labelType:"PRICE",unit:"cm",width:6,height:4,appliedLocation:"ALL",appliedLocationIds:[],showRuler:!0,showGrid:!0,elements:[]}}const wc=[{name:'2"×1"',width:2,height:1,unit:"inch"},{name:'2"×2"',width:2,height:2,unit:"inch"},{name:'3"×1"',width:3,height:1,unit:"inch"},{name:'3"×2"',width:3,height:2,unit:"inch"},{name:'4"×2"',width:4,height:2,unit:"inch"},{name:'4"×6"',width:4,height:6,unit:"inch"},{name:"6cm×4cm",width:6,height:4,unit:"cm"},{name:"10cm×6cm",width:10,height:6,unit:"cm"},{name:"A4",width:21,height:29.7,unit:"cm"},{name:"A5",width:14.8,height:21,unit:"cm"}];function Fme(e,t=20,r=20){const n=Lme(),i={TEXT_STATIC:{width:120,height:24,config:{text:"Text",fontFamily:"Arial",fontSize:14,fontWeight:"normal",textAlign:"left"}},TEXT_PRODUCT:{width:120,height:24,config:{text:"Product name",fontFamily:"Arial",fontSize:14,fontWeight:"normal",textAlign:"left"}},TEXT_PRICE:{width:80,height:24,config:{text:"0.00",decimal:2,fontFamily:"Arial",fontSize:14,fontWeight:"bold",textAlign:"right"}},BARCODE:{width:160,height:48,config:{barcodeType:"CODE128",data:"123456789",showText:!0,orientation:"horizontal"}},QRCODE:{width:80,height:80,config:{data:"https://example.com",errorLevel:"M"}},IMAGE:{width:60,height:60,config:{src:"",scaleMode:"contain"}},DATE:{width:120,height:24,config:{format:"DD/MM/YYYY",offsetDays:0,fontSize:14,textAlign:"left"}},TIME:{width:100,height:24,config:{format:"HH:mm",offsetDays:0}},DURATION:{width:120,height:24,config:{format:"Days",durationValue:3,fontSize:14,textAlign:"left"}},WEIGHT:{width:80,height:24,config:{unit:"g",value:500,fontSize:14,textAlign:"left"}},WEIGHT_PRICE:{width:100,height:24,config:{unitPrice:10,weight:.5,currency:"$"}},BLANK:{width:40,height:24,config:{}},NUTRITION:{width:200,height:120,config:{nutritionTitleFontSize:16,servingsPerContainer:"",servingSize:"",calories:"120",fat:"5",protein:"3",carbs:"10",layout:"standard",fixedNutrients:rl.map(s=>({key:s.key,label:s.label,value:s.key==="fat"?"5":s.key==="protein"?"3":s.key==="carbs"?"10":"",unit:s.defaultUnit??""})),extraNutrients:[]}}}[e];return{id:n,type:e,x:t,y:r,width:i.width,height:i.height,rotation:"horizontal",border:"none",config:{...i.config}}}function J_(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};return delete t.prefix,delete t.Prefix,t}function Q_(e){return e.map((t,r)=>({id:t.id,elementName:(t.elementName??"").trim(),type:Kr(t.type),typeAdd:Qf(t),x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,border:t.border,zIndex:t.zIndex??r+1,orderNum:t.orderNum??r+1,valueSourceType:B8(t),...t.inputKey!=null&&String(t.inputKey).trim()!==""?{inputKey:String(t.inputKey).trim()}:{},isRequiredInput:t.isRequiredInput??!1,config:J_(t.config??{})}))}function tu(e){const t=String(e.appliedLocation??"").trim().toUpperCase();return t==="ALL"?"ALL":t==="SPECIFIED"||(e.appliedLocationIds?.length??0)>0?"SPECIFIED":"ALL"}function ru(e){const t=Kr(e.type);if(String(e.valueSourceType??"").trim().toUpperCase()==="PRINT_INPUT")return!0;const n=e.config??{};return t==="TEXT_STATIC"&&n.inputType!=null&&String(n.inputType).trim()!==""||t==="DATE"&&(n.inputType==="datetime"||n.inputType==="date")||t==="WEIGHT"}function Bme(e){const t=e.config??{},r=Kr(e.type),n=typeof t.text=="string"?t.text.trim():"";if(n)return n;const a=t.inputType;return a==="number"?"Number":a==="text"?"Text":a==="options"?"Multiple Options":a==="datetime"||a==="date"?"Date & Time":r==="WEIGHT"?"Weight":r.replace(/_/g," ")}function D8(e){const t=e,r=e.inputKey??t.InputKey;return typeof r=="string"?r.trim():""}function nu(e){const t=Kr(e.type),r=e.config??{};if(t==="TIME"||t==="DURATION")return!0;if(t==="DATE"){const n=String(r.inputType??r.InputType??"").toLowerCase();if(n==="datetime"||n==="date")return!0;const a=Qf(e).trim().toLowerCase().replace(/\s+/g," ");if(a==="label_duration date"||a.includes("duration date"))return!0;const i=`${e.elementName??""} ${D8(e)}`.toLowerCase();if(/(durationdate|duration_date|duration\s*date)/.test(i))return!0}return!1}function L8(e){return Kr(e.type)==="BLANK"}function $8(e){return Qf(e).trim().toLowerCase().startsWith("template_")}function Z_(e){const t=Qf(e).trim().toLowerCase();if($8(e))return!1;const r=new Set(["label_label name","label_text","label_qr code","label_barcode","label_price","label_duration date","label_duration time","label_duration","label_image","label_label type","label_how-to","label_expiration alert"]),n=F8(e);return L8(e)||!r.has(t)?!1:n==="FIXED"||n==="PRINT_INPUT"}function YN(e){const t=Kr(e.type),r=(e.elementName??"").trim();if(r)return r;const n=D8(e);if(n)return n;const a=e.config??{};return t==="TEXT_PRODUCT"?(typeof a.text=="string"?a.text.trim():"")||"Product name":t==="TEXT_PRICE"?(typeof a.text=="string"?a.text.trim():"")||"Price":t==="IMAGE"?"Image":Bme(e)}function iy(e){return[...e].sort((t,r)=>{const n=t.orderNum??0,a=r.orderNum??0;if(n!==a)return n-a;const i=t.zIndex??0,s=r.zIndex??0;return i!==s?i-s:0})}function F8(e){const t=String(e.valueSourceType??"").trim().toUpperCase();if(t==="FIXED"&&ru({...e,valueSourceType:""}))return"PRINT_INPUT";if(t==="FIXED"||t==="AUTO_DB"||t==="PRINT_INPUT")return t;const r=(e.libraryCategory??"").trim();if(r.startsWith("print_"))return"PRINT_INPUT";if(r.startsWith("auto_"))return"AUTO_DB";if(r.startsWith("template_")||r.startsWith("label_"))return"FIXED";const n=e.libraryCategory??"";return I8(n)?M8(K_(n)):ru({...e,valueSourceType:""})?"PRINT_INPUT":"FIXED"}function B8(e){return F8(e)}function z8(e){const t=Kr(e.type);if(ru(e))return"Print input";switch(t){case"TEXT_PRODUCT":case"NUTRITION":case"DURATION":case"TEXT_PRICE":case"WEIGHT_PRICE":return"Label";case"DATE":case"TIME":return"Auto-generated";case"TEXT_STATIC":case"BARCODE":case"QRCODE":case"IMAGE":case"BLANK":default:return"Template"}}const zme=new Set(["TEXT_STATIC","TEXT_PRODUCT","TEXT_PRICE","BARCODE","QRCODE","IMAGE","DATE","TIME","DURATION","WEIGHT","WEIGHT_PRICE","BLANK","NUTRITION"]),eE=/^(template|label|auto|print)_(.+)$/i,Ume={"template|text":"TEXT_STATIC","template|qr code":"QRCODE","template|barcode":"BARCODE","template|blank space":"BLANK","template|price":"TEXT_PRICE","template|image":"IMAGE","template|logo":"IMAGE","label|label name":"TEXT_PRODUCT","label|text":"TEXT_STATIC","label|qr code":"QRCODE","label|barcode":"BARCODE","label|nutrition facts":"NUTRITION","label|price":"TEXT_PRICE","label|duration date":"DATE","label|duration time":"TIME","label|duration":"DURATION","label|image":"IMAGE","label|label type":"TEXT_STATIC","label|how-to":"TEXT_STATIC","label|expiration alert":"TEXT_STATIC","auto|company":"TEXT_STATIC","auto|employee":"TEXT_STATIC","auto|current date":"DATE","auto|current time":"TIME","auto|label id":"TEXT_STATIC","print|text":"TEXT_STATIC","print|weight":"WEIGHT","print|number":"TEXT_STATIC","print|date & time":"DATE","print|multiple options":"TEXT_STATIC"};function qme(e){return String(e??"").trim().toLowerCase().replace(/\s+/g," ")}function Kr(e){const t=String(e??"").trim();if(zme.has(t))return t;const r=t.match(eE);if(r){const n=r[1].toLowerCase(),a=qme(r[2]),i=Ume[`${n}|${a}`];if(i)return i}return"TEXT_STATIC"}function U8(e,t){return X_(e,t)}function Vme(e){const t=String(e.type??"").trim();if(eE.test(t))return t;const r=z8(e),n=R8(e);return U8(r,n)}function Qf(e){const t=String(e.typeAdd??"").trim();if(t)return t;const r=String(e.type??"").trim();return eE.test(r)?r:Vme(e)}function Wme(e){const t=e.libraryCategory?.trim();if(t&&Rme(t))return t;const r=t&&I8(t)?K_(t):z8(e),n=R8(e);return X_(r,n)}const Zf=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),eh="/label-template";function Hme(e){const t=e;if(!t||typeof t!="object")return"";const r=t.id??t.templateCode??t.TemplateCode;return typeof r=="string"?r.trim():String(r??"").trim()}function Gme(e){return Array.isArray(e)?e.map(t=>{const r=t,n=r.inputKey??r.InputKey,a=r.elementName??r.ElementName,i=r.typeAdd??r.TypeAdd,s=r.libraryCategory??r.LibraryCategory;let l;if(typeof s=="string"){const u=s.trim();u&&(l=u)}const d=r.config&&typeof r.config=="object"&&!Array.isArray(r.config)?r.config:{};return{...r,elementName:typeof a=="string"?a.trim():void 0,typeAdd:typeof i=="string"?i.trim():void 0,inputKey:typeof n=="string"?n:r.inputKey??null,libraryCategory:l,config:J_(d)}}):[]}function Yme(e){if(e==null||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[r,n]of Object.entries(e))n==null?t[r]="":typeof n=="string"?t[r]=n:typeof n=="number"||typeof n=="boolean"?t[r]=String(n):t[r]=JSON.stringify(n);return t}function Kme(e){return Array.isArray(e)?e.map((t,r)=>{const n=t,a=n.defaultValues??n.DefaultValues??n.defaultValuesJson??n.DefaultValuesJson;return{productId:String(n.productId??n.ProductId??"").trim(),labelTypeId:String(n.labelTypeId??n.LabelTypeId??"").trim(),defaultValues:Yme(a),orderNum:Number(n.orderNum??n.OrderNum??r+1)||r+1}}):[]}function jv(e){const t=e,n=((Array.isArray(t.appliedLocationIds)?t.appliedLocationIds:null)??(Array.isArray(t.AppliedLocationIds)?t.AppliedLocationIds:null)??[]).map(g=>String(g)),a=Hme(e),i=t.templateName??t.TemplateName,s=t.templateCode??t.TemplateCode,l=t.locationText??t.LocationText,d=t.sizeText??t.SizeText,u=t.contentsCount??t.ContentsCount,f=typeof u=="number"?u:void 0,h=t.lastEdited??t.LastEdited,p=(typeof t.name=="string"&&t.name.trim()?t.name:null)??(typeof i=="string"&&String(i).trim()?String(i):null);return{...t,id:a,name:p??t.name,templateName:(typeof i=="string"?i:null)??t.templateName,templateCode:(typeof s=="string"?s:null)??t.templateCode,locationText:(typeof l=="string"?l:null)??t.locationText,sizeText:(typeof d=="string"?d:null)??t.sizeText,contentsCount:f??t.contentsCount,lastEdited:(typeof h=="string"?h:null)??t.lastEdited,appliedLocationIds:n,elements:Gme(t.elements),templateProductDefaults:Kme(t.templateProductDefaults??t.TemplateProductDefaults)}}async function Nv(e,t){const r=await Zf.requestJson({path:eh,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,LocationId:e.locationId,LabelType:e.labelType,State:e.state},signal:t}),n=(r.items??[]).map(a=>jv(a));return{...r,items:n}}async function au(e,t){const r=await Zf.requestJson({path:`${eh}/${encodeURIComponent(e)}`,method:"GET",signal:t});return jv(r)}async function Xme(e){const t=await Zf.requestJson({path:eh,method:"POST",body:{id:e.id,name:e.name,labelType:e.labelType,unit:e.unit,width:e.width,height:e.height,appliedLocation:e.appliedLocation,showRuler:e.showRuler??!0,showGrid:e.showGrid??!0,state:e.state??!0,elements:e.elements,appliedLocationIds:e.appliedLocationIds??[]}});return jv(t)}async function tE(e,t){const r={id:t.id,name:t.name,labelType:t.labelType,unit:t.unit,width:t.width,height:t.height,appliedLocation:t.appliedLocation,showRuler:t.showRuler??!0,showGrid:t.showGrid??!0,state:t.state??!0,elements:t.elements,appliedLocationIds:t.appliedLocationIds??[]};t.templateProductDefaults!==void 0&&(r.templateProductDefaults=t.templateProductDefaults.map((a,i)=>({productId:a.productId,labelTypeId:a.labelTypeId,defaultValues:a.defaultValues,orderNum:a.orderNum??i+1})));const n=await Zf.requestJson({path:`${eh}/${encodeURIComponent(e)}`,method:"PUT",body:r});return jv(n)}async function Jme(e){await Zf.requestJson({path:`${eh}/${encodeURIComponent(e)}`,method:"DELETE"})}const Cu=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),fi="/product";function Cv(e){const t=e,r=String(t?.id??t?.Id??"").trim(),n=t?.locationIds??t?.LocationIds,a=Array.isArray(n)?n.map(i=>String(i).trim()).filter(Boolean):void 0;return{...t,id:r,productCode:t?.productCode??t?.ProductCode,productName:t?.productName??t?.ProductName,categoryId:t?.categoryId??t?.CategoryId,categoryName:t?.categoryName??t?.CategoryName,productImageUrl:t?.productImageUrl??t?.ProductImageUrl,state:typeof t?.state=="boolean"?t.state:typeof t?.State=="boolean"?t.State:null,...Array.isArray(n)?{locationIds:a??[]}:{}}}async function sy(e,t){const r=await Cu.requestJson({path:fi,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t});return{...r,items:(r.items??[]).map(n=>Cv(n))}}async function q8(e,t){const r=await Cu.requestJson({path:`${fi}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Cv(r)}async function Qme(e){const t={productCode:String(e.productCode??"").trim()||null,productName:e.productName,categoryId:e.categoryId?.trim()?e.categoryId.trim():null,productImageUrl:e.productImageUrl??null,state:e.state??!0};e.locationIds!==void 0&&(t.locationIds=e.locationIds);const r=await Cu.requestJson({path:fi,method:"POST",body:t});return Cv(r)}async function Zme(e,t){const r={productCode:String(t.productCode??"").trim()||null,productName:t.productName,categoryId:t.categoryId?.trim()?t.categoryId.trim():null,productImageUrl:t.productImageUrl??null,state:t.state??!0};t.locationIds!==void 0&&(r.locationIds=t.locationIds);const n=await Cu.requestJson({path:`${fi}/${encodeURIComponent(e)}`,method:"PUT",body:r});return Cv(n)}async function epe(e){await Cu.requestJson({path:`${fi}/${encodeURIComponent(e)}`,method:"DELETE"})}async function tpe(e){await dl({path:`${fi}/download-product-import-template`,defaultFileName:"Product-Manager-template.xlsx",signal:e})}async function rpe(e,t){await dl({path:`${fi}/export-products-excel`,query:{Keyword:e.keyword,State:e.state,Sorting:e.sorting},defaultFileName:"products-export.xlsx",signal:t})}async function npe(e,t){return z_({path:`${fi}/import-products-batch`,fieldName:"file",file:e,signal:t})}async function ape(e){return Cu.requestJson({path:`${fi}/update-products-bulk`,method:"POST",body:e})}const th=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),rh="/product-category";async function KN(e,t){return th.requestJson({path:rh,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function ope(e,t){return th.requestJson({path:`${rh}/${encodeURIComponent(e)}`,method:"GET",signal:t})}async function ipe(e){return th.requestJson({path:rh,method:"POST",body:{categoryCode:String(e.categoryCode??"").trim()||null,categoryName:e.categoryName,categoryPhotoUrl:e.categoryPhotoUrl??null,displayText:(e.displayText??"").trim()||null,buttonAppearance:vv(e.buttonAppearance),buttonTextColor:(e.buttonTextColor??"").trim()||null,buttonBgColor:(e.buttonBgColor??"").trim()||null,buttonImageUrl:(e.buttonImageUrl??"").trim()||null,buttonStyleJson:(e.buttonStyleJson??"").trim()||null,availabilityType:e.availabilityType??"ALL",locationIds:e.locationIds??[],state:e.state??!0,orderNum:e.orderNum??0}})}async function spe(e,t){return th.requestJson({path:`${rh}/${encodeURIComponent(e)}`,method:"PUT",body:{categoryCode:String(t.categoryCode??"").trim()||null,categoryName:t.categoryName,categoryPhotoUrl:t.categoryPhotoUrl??null,displayText:(t.displayText??"").trim()||null,buttonAppearance:vv(t.buttonAppearance),buttonTextColor:(t.buttonTextColor??"").trim()||null,buttonBgColor:(t.buttonBgColor??"").trim()||null,buttonImageUrl:(t.buttonImageUrl??"").trim()||null,buttonStyleJson:(t.buttonStyleJson??"").trim()||null,availabilityType:t.availabilityType??"ALL",locationIds:t.locationIds??[],state:t.state??!0,orderNum:t.orderNum??0}})}async function lpe(e){await th.requestJson({path:`${rh}/${encodeURIComponent(e)}`,method:"DELETE"})}const cpe="/api/app/picture/category/upload";function upe(e,t){const r=e.replace(/\/$/,""),n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}const V8=5*1024*1024;function W8(){return"http://flus-test.3ffoodsafety.com".replace(/\/$/,"")??"http://localhost:19001"}function dpe(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")}catch{return null}}function BD(e){if(typeof e=="string"&&e.trim()){const r=e.trim();if(/^https?:\/\//i.test(r)||r.startsWith("/")||r.startsWith("data:"))return r}if(!e||typeof e!="object")return null;const t=e;for(const r of["url","Url","fileUrl","FileUrl","imageUrl","ImageUrl","path","Path"]){const n=t[r];if(typeof n=="string"&&n.trim())return n.trim()}return null}function fpe(e){if(!e||typeof e!="object")return e;const t=e;return"data"in t&&t.data!==void 0?t.data:"result"in t&&t.result!==void 0?t.result:e}function hpe(e,t){if(e&&typeof e=="object"){const r=e,n=r.errors??r.Errors;if(typeof n=="string"&&n.trim())return n.trim();const a=r.error;if(a&&typeof a.message=="string"&&a.message.trim())return a.message.trim()}return`Upload failed (${t})`}function Tf(e){const t=(e??"").trim();if(!t)return"";if(t.startsWith("data:")||/^https?:\/\//i.test(t))return t;const r=W8();return t.startsWith("/")?`${r}${t}`:`${r}/${t}`}function mpe(e){if(e.size>V8)throw new Error("Image must be 5 MB or smaller.");const t=/^(image\/(jpeg|png|webp|gif))$/i.test(e.type),r=/\.(jpe?g|png|webp|gif)$/i.test(e.name);if(!t&&!r)throw new Error("Only JPG, PNG, WebP, and GIF are allowed.")}async function ppe(e,t){mpe(e);const r=t?.subDir?.trim();if(r&&r.includes(".."))throw new Error("Invalid subDir.");const n=upe(W8(),cpe),a=new FormData;a.append("file",e),r&&a.append("subDir",r);const i={},s=dpe();s&&(i.Authorization=`Bearer ${s}`);const l=await fetch(n,{method:"POST",body:a,headers:i,signal:t?.signal}),d=await l.text();let u=d;try{u=d?JSON.parse(d):null}catch{u=d}if(!l.ok)throw new Error(hpe(u,l.status));const f=fpe(u),h=BD(f)??BD(u);if(!h)throw new Error("Upload response did not contain a usable image URL.");return h}function _u({value:e,onChange:t,disabled:r,hint:n,emptyLabel:a="",accept:i="image/jpeg,image/png,image/webp,image/gif",maxSizeMb:s=V8/(1024*1024),className:l,boxClassName:d,uploadSubDir:u,oneImageOnly:f}){const h=x.useRef(null),[p,g]=x.useState(!1),v=async C=>{const O=C.target.files?.[0];if(C.target.value="",!!O){if(!O.type.startsWith("image/")){ee.error("Please select an image file.");return}if(O.size>s*1024*1024){ee.error(`Image must be ${s} MB or smaller.`);return}g(!0);try{const P=await ppe(O,{subDir:u});t(P),ee.success("Image uploaded.")}catch(P){const E=P instanceof Error?P.message:String(P);ee.error("Upload failed",{description:E||void 0})}finally{g(!1)}}},b=r||p,w=()=>{b||h.current?.click()},j=!!d?.trim(),N=j?"rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2":"w-full max-w-[200px] aspect-square rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2";return o.jsxs("div",{className:Ie("space-y-2",l),children:[o.jsx("input",{ref:h,type:"file",accept:i,className:"sr-only",disabled:b,multiple:!1,onChange:v}),e?o.jsxs("div",{className:Ie("group relative overflow-hidden border-2 border-dashed border-gray-300 bg-gray-50/80",N,j?d:null),children:[o.jsxs("button",{type:"button",disabled:b,onClick:w,className:"relative h-full w-full p-0","aria-label":"Replace image",children:[o.jsx("img",{src:Tf(e),alt:"",className:"h-full w-full object-contain",onError:C=>{C.target.style.opacity="0.2"}}),o.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/0 text-sm font-medium text-white opacity-0 transition group-hover:bg-black/45 group-hover:opacity-100",children:"Click to replace"})]}),o.jsx("button",{type:"button",disabled:b,onClick:C=>{C.stopPropagation(),t("")},className:"absolute right-1.5 top-1.5 flex h-7 w-7 items-center justify-center rounded-full bg-white/95 text-gray-600 shadow-sm ring-1 ring-gray-200 transition hover:bg-white hover:text-gray-900 disabled:opacity-50","aria-label":"Remove image",children:o.jsx($i,{className:"h-4 w-4"})})]}):o.jsx("button",{type:"button",disabled:b,onClick:w,"aria-label":a||"Upload image",className:Ie(N,j?d:null,"flex border-2 border-dashed border-gray-300 bg-gray-50/80 text-gray-400",a&&!p?"flex-col items-center justify-center gap-2":"items-center justify-center","hover:border-gray-400 hover:bg-gray-100/90 hover:text-gray-500","disabled:pointer-events-none disabled:opacity-50"),children:p?o.jsx("span",{className:"px-3 text-center text-sm font-normal text-gray-500",children:"Uploading…"}):o.jsxs(o.Fragment,{children:[o.jsx(Un,{className:"h-10 w-10 shrink-0 stroke-[1.25]","aria-hidden":!0}),a?o.jsx("span",{className:"px-3 text-center text-sm font-normal leading-tight text-gray-400",children:a}):null]})}),f?o.jsx("p",{className:"text-xs text-muted-foreground",children:"One image only. Replace or clear to change."}):null,n?o.jsx("p",{className:"text-xs text-muted-foreground",children:n}):null]})}const rE=["Minutes","Hours","Days","Weeks","Months (30 Day)","Years"];function gpe(e,t,r){const n=new Date(e.getTime());switch(String(r??"").trim()){case"Minutes":n.setMinutes(n.getMinutes()+t);break;case"Hours":n.setHours(n.getHours()+t);break;case"Days":n.setDate(n.getDate()+t);break;case"Weeks":n.setDate(n.getDate()+t*7);break;case"Months (30 Day)":n.setDate(n.getDate()+t*30);break;case"Years":n.setFullYear(n.getFullYear()+t);break;default:n.setDate(n.getDate()+t)}return n}function zD(e,t){const r=String(t.getFullYear()),n=r.slice(-2),a=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),d=t.toLocaleString("en-US",{month:"long"}).toUpperCase(),u=t.toLocaleString("en-US",{weekday:"long"}).toUpperCase(),f=t.toLocaleString("en-US",{weekday:"short"}).toUpperCase();switch(t.toLocaleString("en-US",{month:"short"}).toUpperCase(),e){case"DD/MM/YYYY":return`${i}/${a}/${r}`;case"MM/DD/YYYY":return`${a}/${i}/${r}`;case"DD/MM/YY":return`${i}/${a}/${n}`;case"MM/DD/YY":return`${a}/${i}/${n}`;case"MM/YY":return`${a}/${n}`;case"MM/DD":return`${a}/${i}`;case"MM":return a;case"DD":return i;case"YY":return n;case"FULLY DAY(WEDNESDAY)":return u;case"DAY (WED)":return f;case"MONTH (DECEMBER)":return d;case"YEAR (2025)":return r;case"DD MONTH YEAR (25 DECEMBER 2025)":return`${i} ${d} ${r}`;default:return e.replace(/YYYY/g,r).replace(/YY/g,n).replace(/MM/g,a).replace(/DD/g,i).replace(/HH/g,s).replace(/mm/g,l)}}const ype=new Set(rE);function H8(e){const t=String(e??"").trim();if(t==="")return{kind:"zero"};const r=Number(t);return Number.isFinite(r)?r===0?{kind:"zero"}:{kind:"amount",amount:r,storeValue:t}:{kind:"invalid"}}function kf(e,t){const r=String(e??"").trim()||"Days";return JSON.stringify({unit:r,value:String(t??"")})}function G8(e){const t=String(e??"").trim();if(!t.startsWith("{"))return null;try{const r=JSON.parse(t);if(r==null||typeof r!="object"||Array.isArray(r))return null;const n=r,a=String(n.unit??n.Unit??"").trim(),i=String(n.value??n.Value??"");return!a||!ype.has(a)?null:{unit:a,value:i}}catch{return null}}function Y8(e){const t=G8(e);if(t)return t;const r=String(e??"").trim();return/^\d+$/.test(r)?{unit:"Days",value:r}:{unit:"Days",value:""}}const K8="###nut###";function fc(e,t){return`${e}${K8}${t}`}function _v(e){const t=e.extraNutrients;return Array.isArray(t)?t.map((r,n)=>{const a=r;return{id:String(a.id??`extra-${n}`),name:String(a.name??""),value:String(a.value??""),unit:String(a.unit??"")}}):[]}function X8(e){return rl.find(r=>r.key===e)?.label??e}function ou(e,t){const r=e[t];if(r!=null&&String(r).trim()!=="")return String(r).trim();const a=(Array.isArray(e.fixedNutrients)?e.fixedNutrients:[]).find(i=>String(i.key??"").trim()===t);return String(a?.value??"").trim()}function vpe(e){return String(e.calories??e.Calories??ou(e,"calories")??"").trim()}function xpe(e){return String(e.servingsPerContainer??e.ServingsPerContainer??"").trim()}function bpe(e){return String(e.servingSize??e.ServingSize??"").trim()}function wpe(e){return{id:"__nutrition_cfg__",type:"NUTRITION",x:0,y:0,width:1,height:1,rotation:"horizontal",border:"none",config:e}}function Eu(e){if(Kr(e.type)!=="NUTRITION")return[];const t=e.config??{},r=[];vpe(t)&&r.push({subKey:"calories",columnLabel:"Calories"}),xpe(t)&&r.push({subKey:"servingsPerContainer",columnLabel:"Servings Per Container"}),bpe(t)&&r.push({subKey:"servingSize",columnLabel:"Serving Size"});const n=Array.isArray(t.fixedNutrients)?t.fixedNutrients:[],a=new Set;if(n.length>0)for(const i of n){const s=String(i.key??"").trim();if(!s||a.has(s)||!String(i.value??"").trim())continue;a.add(s);const d=String(i.label??"").trim()||X8(s);r.push({subKey:s,columnLabel:d})}else for(const i of rl)ou(t,i.key).trim()&&r.push({subKey:i.key,columnLabel:i.label});for(const i of _v(t)){const s=String(i.id??"").trim();if(!s||!String(i.value??"").trim())continue;const d=i.name.trim()||"Other";r.push({subKey:`extra:${s}:value`,columnLabel:d})}return r}function Sc(e){return(e??[]).filter(t=>Kr(t.type)==="NUTRITION")}function Spe(e){const t=e.config??{},r={},n=Eu(e);for(const a of n){if(a.subKey==="calories"){r.calories=String(t.calories??t.Calories??ou(t,"calories")??"").trim();continue}if(a.subKey==="servingsPerContainer"){r.servingsPerContainer=String(t.servingsPerContainer??t.ServingsPerContainer??"").trim();continue}if(a.subKey==="servingSize"){r.servingSize=String(t.servingSize??t.ServingSize??"").trim();continue}if(a.subKey.startsWith("extra:")&&a.subKey.endsWith(":value")){const i=a.subKey.slice(6,-6),s=_v(t).find(l=>l.id===i);r[a.subKey]=(s?.value??"").trim();continue}r[a.subKey]=ou(t,a.subKey)}return r}function Cd(e,t,r){const n=String(e[t]??"").trim();if(n!=="")return n;if(t==="calories")return String(r.calories??r.Calories??ou(r,"calories")??"").trim();if(t==="servingsPerContainer")return String(r.servingsPerContainer??r.ServingsPerContainer??"").trim();if(t==="servingSize")return String(r.servingSize??r.ServingSize??"").trim();if(t.startsWith("extra:")&&t.endsWith(":value")){const a=t.slice(6,-6);return(_v(r).find(s=>s.id===a)?.value??"").trim()}return ou(r,t)}function jpe(e,t){const r={...e},n=Eu(wpe(e)),a=new Set(n.map(d=>d.subKey));if(a.has("calories")){const d=Cd(t,"calories",e);d?r.calories=d:(delete r.calories,delete r.Calories)}else delete r.calories,delete r.Calories;a.has("servingsPerContainer")?r.servingsPerContainer=Cd(t,"servingsPerContainer",e):(r.servingsPerContainer="",delete r.ServingsPerContainer),a.has("servingSize")?r.servingSize=Cd(t,"servingSize",e):(r.servingSize="",delete r.ServingSize);const i=Array.isArray(e.fixedNutrients)?e.fixedNutrients:[],s=[];for(const d of n){if(["calories","servingsPerContainer","servingSize"].includes(d.subKey)||d.subKey.startsWith("extra:"))continue;const u=Cd(t,d.subKey,e),f=i.find(g=>String(g.key??"").trim()===d.subKey),h=String(f?.unit??rl.find(g=>g.key===d.subKey)?.defaultUnit??""),p=String(f?.label??X8(d.subKey));s.push({key:d.subKey,label:p,value:u,unit:h})}r.fixedNutrients=s;const l=[];for(const d of n){if(!d.subKey.startsWith("extra:")||!d.subKey.endsWith(":value"))continue;const u=d.subKey.slice(6,-6),f=_v(e).find(h=>h.id===u);l.push({id:u,name:(f?.name??d.columnLabel).trim()||"Other",value:Cd(t,d.subKey,e),unit:String(f?.unit??"").trim()})}return r.extraNutrients=l,r}function Npe(e){const t={};for(const[r,n]of Object.entries(e)){const a=String(n??"").trim();a!==""&&(t[r]=a)}return JSON.stringify(t)}function Cpe(e){const t=String(e??"").trim();if(!t.startsWith("{"))return{};try{const r=JSON.parse(t);if(r==null||typeof r!="object"||Array.isArray(r))return{};const n={};for(const[a,i]of Object.entries(r))n[a]=String(i??"");return n}catch{return{}}}function J8(e){const t=Npe(e);return t==="{}"?null:t}function _pe(e,t){const r={...e};for(const n of Sc(t)){const a=r[n.id];if(typeof a!="string"||!a.trim().startsWith("{"))continue;const i=Cpe(a);delete r[n.id];const s=new Set(Eu(n).map(l=>l.subKey));for(const[l,d]of Object.entries(i))s.has(l)&&(r[fc(n.id,l)]=d)}return r}function Epe(e,t){const r={...e};for(const n of Sc(t)){const a=Eu(n),i={};for(const d of a){const u=fc(n.id,d.subKey);Object.prototype.hasOwnProperty.call(e,u)&&(i[d.subKey]=e[u]??"")}const s=`${n.id}${K8}`;for(const d of Object.keys(r))d.startsWith(s)&&delete r[d];const l=J8(i);l?r[n.id]=l:delete r[n.id]}return r}function GS(){try{return crypto.randomUUID()}catch{return`row-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}}function Ppe(e,t){if(!nu(e))return t??"";const r=String(t??"").trim();if(!r)return"";if(G8(r))return r;const{unit:n,value:a}=Y8(r);if(!String(a).trim())return r;const i=Number(String(a).trim());return Number.isFinite(i)?kf(n,String(a).trim()):r}const Ope="h-[100px] w-[100px] min-h-[100px] min-w-[100px] max-h-[100px] max-w-[100px] shrink-0 aspect-auto";function Tpe(e){const t=Kr(e.type);return t==="IMAGE"||t==="QRCODE"?!0:(e.elementName??"").trim().toLowerCase().includes("qrcode")}function kpe({value:e,onValueChange:t}){const{unit:r,value:n}=Y8(e);return o.jsxs("div",{className:"flex flex-wrap items-center gap-2 min-w-0 max-w-[220px]",children:[o.jsxs($e,{value:r,onValueChange:a=>t(kf(a,n)),children:[o.jsx(Be,{className:"h-10 min-w-0 flex-1 bg-white text-sm border-gray-300",children:o.jsx(Fe,{})}),o.jsx(ze,{children:rE.map(a=>o.jsx(Se,{value:a,className:"text-xs",children:a},a))})]}),o.jsx(me,{type:"number",className:"h-10 w-20 shrink-0 border-gray-300 bg-white",value:n,onChange:a=>t(kf(r,a.target.value)),placeholder:"Val"})]})}function Ape({element:e,value:t,onValueChange:r}){return Tpe(e)?o.jsx(_u,{value:t,onChange:r,uploadSubDir:"label-template-data",oneImageOnly:!0,boxClassName:Ope,hint:"Upload stores full URL/path for save."}):nu(e)?o.jsx(kpe,{value:t,onValueChange:r}):o.jsx(me,{value:t,onChange:n=>r(n.target.value),placeholder:"—",className:"h-10 border-gray-300 max-w-[220px]"})}function Ipe({templateCode:e,onBack:t,contextHint:r}){const[n,a]=x.useState(!0),[i,s]=x.useState(!1),[l,d]=x.useState(""),[u,f]=x.useState(null),[h,p]=x.useState([]),[g,v]=x.useState([]),[b,w]=x.useState([]),j=x.useMemo(()=>iy(u?.elements??[]),[u]),N=x.useMemo(()=>{const R=[];for(const L of j)if(Z_(L)&&R.push({kind:"element",el:L}),Kr(L.type)==="NUTRITION")for(const V of Eu(L))R.push({kind:"nutrition",parent:L,spec:V});return R},[j]),C=x.useMemo(()=>h.map(R=>{const L=(R.productName??R.productCode??"").trim()||R.id;return{value:R.id,label:L}}),[h]),O=x.useMemo(()=>g.map(R=>{const L=(R.typeName??R.typeCode??"").trim()||R.id;return{value:R.id,label:L}}),[g]);x.useEffect(()=>{let R=!1;return(async()=>{a(!0);try{const[L,V,z]=await Promise.all([au(e),sy({skipCount:Qa(1),maxResultCount:500}),Y_({skipCount:Qa(1),maxResultCount:500})]);if(R)return;const G=(L.templateName??L.name??"").trim()||(L.templateCode??L.id??"").trim()||e;d(G),p(V.items??[]),v(z.items??[]),f(L);const H=L.templateProductDefaults??[],W=H.length>0?[...H].sort((q,I)=>(q.orderNum??0)-(I.orderNum??0)):[];W.length>0?w(W.map(q=>({id:GS(),productId:q.productId,labelTypeId:q.labelTypeId,fieldValues:_pe({...q.defaultValues},L.elements??[])}))):w([{id:GS(),productId:"",labelTypeId:"",fieldValues:{}}])}catch(L){R||(ee.error("Failed to load template or options.",{description:L instanceof Error?L.message:"Please try again."}),d(e),w([]),f(null))}finally{R||a(!1)}})(),()=>{R=!0}},[e]);const P=x.useCallback(()=>{w(R=>[...R,{id:GS(),productId:"",labelTypeId:"",fieldValues:{}}])},[]),E=x.useCallback(R=>{w(L=>L.length<=1?L:L.filter(V=>V.id!==R))},[]),T=x.useCallback((R,L)=>{w(V=>V.map(z=>z.id===R?{...z,...L}:z))},[]),A=x.useCallback((R,L,V)=>{w(z=>z.map(G=>G.id!==R?G:{...G,fieldValues:{...G.fieldValues,[L]:V}}))},[]),M=x.useCallback(async()=>{if(!u){ee.error("Template not loaded",{description:"Please reload the page and try again."});return}if(b.filter(W=>W.productId.trim()||W.labelTypeId.trim()).some(W=>!W.productId.trim()||!W.labelTypeId.trim())){ee.error("Product and label type required",{description:"Each row that you started must have both Product and Label type selected."});return}const V=b.filter(W=>W.productId.trim()&&W.labelTypeId.trim()),z=iy(u.elements??[]),G=V.map((W,q)=>{const I=Epe(W.fieldValues,z),Y={};for(const F of N)F.kind==="element"&&(Y[F.el.id]=Ppe(F.el,I[F.el.id]??""));for(const F of z)if(Kr(F.type)==="NUTRITION"){const D=I[F.id];D&&(Y[F.id]=D)}return{productId:W.productId.trim(),labelTypeId:W.labelTypeId.trim(),defaultValues:Y,orderNum:q+1}});if(z.length===0){ee.error("Template has no elements",{description:"Cannot save this template."});return}const H=tu(u);s(!0);try{const W=await tE(e,{id:u.id,name:(u.name??u.templateName??"").trim()||e,labelType:u.labelType??"PRICE",unit:u.unit??"inch",width:Number(u.width??2),height:Number(u.height??2),appliedLocation:H,showRuler:u.showRuler??!0,showGrid:u.showGrid??!0,state:u.state??!0,elements:Q_(z),appliedLocationIds:H==="ALL"?[]:u.appliedLocationIds??[],templateProductDefaults:G});f(W),ee.success("Saved",{description:"Template product defaults were updated on the server."})}catch(W){ee.error("Save failed",{description:W instanceof Error?W.message:"Please try again."})}finally{s(!1)}},[e,u,b,N]);return o.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pb-4 border-b border-gray-200 shrink-0",children:[o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 gap-2",onClick:t,children:[o.jsx(w$,{className:"h-4 w-4"}),"Back"]}),o.jsxs("div",{className:"flex-1 min-w-[200px]",children:[o.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Label template"}),o.jsx("h2",{className:"text-lg font-semibold text-gray-900 truncate",title:l,children:l}),r?o.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",title:r,children:r}):null]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 gap-1",onClick:P,children:[o.jsx(Un,{className:"h-4 w-4"}),"Add row"]}),o.jsx(ce,{type:"button",className:"h-10 bg-blue-600 hover:bg-blue-700",onClick:()=>void M(),disabled:i||n||!u,children:i?"Saving…":"Save"})]})]}),o.jsxs("p",{className:"text-sm text-gray-600 py-3 shrink-0",children:["Bind product and label type per row. Values are saved with the template (edit API) as"," ",o.jsx("span",{className:"font-medium",children:"templateProductDefaults"})," (interface doc section 4.4). Columns cover"," ",o.jsx("span",{className:"font-medium",children:"Label"})," group defaults, ",o.jsx("span",{className:"font-medium",children:"PRINT_INPUT"})," / Duration fields, and (when present) ",o.jsx("span",{className:"font-medium",children:"Nutrition Facts"})," manual cells."," ",o.jsx("span",{className:"font-medium",children:"Template"})," panel elements are edited only in the label template editor (not here). Date / time / duration columns use ",o.jsx("span",{className:"font-medium",children:"unit + value"}),"; stored as JSON with ",o.jsx("span",{className:"font-medium",children:"unit"})," and ",o.jsx("span",{className:"font-medium",children:"value"})," keys. Nutrition values are stored as JSON under the nutrition element id for App print preview."]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-auto rounded-md border bg-white shadow-sm",children:n?o.jsx("div",{className:"p-10 text-center text-sm text-gray-500",children:"Loading…"}):N.length===0?o.jsx("div",{className:"p-10 text-center text-sm text-gray-600",children:"No manual input or nutrition columns in this template."}):o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px] min-w-[160px]",children:"Product"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[180px] min-w-[140px]",children:"Label type"}),N.map(R=>o.jsx(Ee,{className:"font-bold text-gray-900 min-w-[120px] whitespace-nowrap",title:R.kind==="element"?R.el.id:`${R.parent.id} · ${R.spec.subKey}`,children:R.kind==="element"?YN(R.el):R.spec.columnLabel},R.kind==="element"?R.el.id:fc(R.parent.id,R.spec.subKey))),o.jsx(Ee,{className:"w-[72px] text-center font-bold text-gray-900",children:" "})]})}),o.jsx(pn,{children:b.map(R=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"align-top py-2",children:o.jsx($n,{value:R.productId,onValueChange:L=>T(R.id,{productId:L}),options:C,placeholder:"Select product",searchPlaceholder:"Search product…"})}),o.jsx(ye,{className:"align-top py-2",children:o.jsx($n,{value:R.labelTypeId,onValueChange:L=>T(R.id,{labelTypeId:L}),options:O,placeholder:"Select label type",searchPlaceholder:"Search type…"})}),N.map(L=>o.jsx(ye,{className:"align-top py-2",children:L.kind==="element"?o.jsx(Ape,{element:L.el,value:R.fieldValues[L.el.id]??"",onValueChange:V=>A(R.id,L.el.id,V)}):o.jsx(me,{value:R.fieldValues[fc(L.parent.id,L.spec.subKey)]??"",onChange:V=>A(R.id,fc(L.parent.id,L.spec.subKey),V.target.value),placeholder:"—",className:"h-10 border-gray-300 max-w-[220px]"})},L.kind==="element"?L.el.id:fc(L.parent.id,L.spec.subKey))),o.jsx(ye,{className:"text-center align-top py-2",children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 text-red-600 hover:text-red-700 hover:bg-red-50","aria-label":"Remove row",onClick:()=>E(R.id),disabled:b.length<=1,children:o.jsx(zt,{className:"h-4 w-4"})})})]},R.id))})]})})]})}var Km={},_d={},Xm={},UD;function ma(){if(UD)return Xm;UD=1,Object.defineProperty(Xm,"__esModule",{value:!0});function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}var t=function r(n,a){e(this,r),this.data=n,this.text=a.text||n,this.options=a};return Xm.default=t,Xm}var qD;function Mpe(){if(qD)return _d;qD=1,Object.defineProperty(_d,"__esModule",{value:!0}),_d.CODE39=void 0;var e=(function(){function b(w,j){for(var N=0;N=200){w=p.shift()-105;var j=n.SWAP[w];j!==void 0?b=f.next(p,g+1,j):((v===n.SET_A||v===n.SET_B)&&w===n.SHIFT&&(p[0]=v===n.SET_A?p[0]>95?p[0]-96:p[0]:p[0]<32?p[0]+96:p[0]),b=f.next(p,g+1,v))}else w=f.correctIndex(p,v),b=f.next(p,g+1,v);var N=f.getBar(w),C=w*g;return{result:N+b.result,checksum:C+b.checksum}}}]),f})(r.default);return Qm.default=d,Qm}var Zm={},HD;function Rpe(){if(HD)return Zm;HD=1,Object.defineProperty(Zm,"__esModule",{value:!0});var e=nh(),t=function(l){return l.match(new RegExp("^"+e.A_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+e.B_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+e.C_CHARS+"*"))[0]};function a(s,l){var d=l?e.A_CHARS:e.B_CHARS,u=s.match(new RegExp("^("+d+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(u)return u[1]+"Ì"+i(s.substring(u[1].length));var f=s.match(new RegExp("^"+d+"+"))[0];return f.length===s.length?s:f+String.fromCharCode(l?205:206)+a(s.substring(f.length),!l)}function i(s){var l=n(s),d=l.length;if(d===s.length)return s;s=s.substring(d);var u=t(s)>=r(s);return l+String.fromCharCode(u?206:205)+a(s,u)}return Zm.default=function(s){var l=void 0,d=n(s).length;if(d>=2)l=e.C_START_CHAR+i(s);else{var u=t(s)>r(s);l=(u?e.A_START_CHAR:e.B_START_CHAR)+a(s,u)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(f,h){return"Ë"+h})},Zm}var GD;function Dpe(){if(GD)return Jm;GD=1,Object.defineProperty(Jm,"__esModule",{value:!0});var e=Ev(),t=a(e),r=Rpe(),n=a(r);function a(u){return u&&u.__esModule?u:{default:u}}function i(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function s(u,f){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f&&(typeof f=="object"||typeof f=="function")?f:u}function l(u,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(u,f):u.__proto__=f)}var d=(function(u){l(f,u);function f(h,p){if(i(this,f),/^[\x00-\x7F\xC8-\xD3]+$/.test(h))var g=s(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,(0,n.default)(h),p));else var g=s(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,h,p));return s(g)}return f})(t.default);return Jm.default=d,Jm}var ep={},YD;function Lpe(){if(YD)return ep;YD=1,Object.defineProperty(ep,"__esModule",{value:!0});var e=(function(){function u(f,h){for(var p=0;pv.width*10?v.width*10:v.fontSize,b.guardHeight=v.height+b.fontSize/2+v.textMargin,b}return e(p,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(v,b){return this.text.substr(v,b)}},{key:"leftEncode",value:function(v,b){return(0,n.default)(v,b)}},{key:"rightText",value:function(v,b){return this.text.substr(v,b)}},{key:"rightEncode",value:function(v,b){return(0,n.default)(v,b)}},{key:"encodeGuarded",value:function(){var v={fontSize:this.fontSize},b={height:this.guardHeight};return[{data:t.SIDE_BIN,options:b},{data:this.leftEncode(),text:this.leftText(),options:v},{data:t.MIDDLE_BIN,options:b},{data:this.rightEncode(),text:this.rightText(),options:v},{data:t.SIDE_BIN,options:b}]}},{key:"encodeFlat",value:function(){var v=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:v.join(""),text:this.text}}}]),p})(i.default);return ap.default=f,ap}var tL;function zpe(){if(tL)return np;tL=1,Object.defineProperty(np,"__esModule",{value:!0});var e=(function(){function h(p,g){for(var v=0;vv.width*10?b.fontSize=v.width*10:b.fontSize=v.fontSize,b.guardHeight=v.height+b.fontSize/2+v.textMargin,b}return e(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==f(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=(0,r.default)(this.data.substr(0,6),"LLLLLL"),v+="01010",v+=(0,r.default)(this.data.substr(6,6),"RRRRRR"),v+="101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101"+(0,r.default)(this.data[0],"L"),options:{height:this.guardHeight}}),v.push({data:(0,r.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),v.push({data:"01010",options:{height:this.guardHeight}}),v.push({data:(0,r.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),v.push({data:(0,r.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),v}}]),p})(a.default);function f(h){var p=0,g;for(g=1;g<11;g+=2)p+=parseInt(h[g]);for(g=0;g<11;g+=2)p+=parseInt(h[g])*3;return(10-p%10)%10}return Ed.default=u,Ed}var cp={},iL;function Wpe(){if(iL)return cp;iL=1,Object.defineProperty(cp,"__esModule",{value:!0});var e=(function(){function v(b,w){for(var j=0;jj.width*10?N.fontSize=j.width*10:N.fontSize=j.fontSize,N.guardHeight=j.height+N.fontSize/2+j.textMargin,N}return e(b,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var j="";return j+="101",j+=this.encodeMiddleDigits(),j+="010101",{data:j,text:this.text}}},{key:"guardedEncoding",value:function(){var j=[];return this.displayValue&&j.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),j.push({data:"101",options:{height:this.guardHeight}}),j.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),j.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&j.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),j}},{key:"encodeMiddleDigits",value:function(){var j=this.upcA[0],N=this.upcA[this.upcA.length-1],C=h[parseInt(N)][parseInt(j)];return(0,r.default)(this.middleDigits,C)}}]),b})(a.default);function g(v,b){for(var w=parseInt(v[v.length-1]),j=f[w],N="",C=0,O=0;O=3&&this.number<=131070}}]),u})(r.default);return Od.pharmacode=l,Od}var Td={},bL;function rge(){if(bL)return Td;bL=1,Object.defineProperty(Td,"__esModule",{value:!0}),Td.codabar=void 0;var e=(function(){function d(u,f){for(var h=0;h":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),tc}var SL;function t6(){if(SL)return yp;SL=1,Object.defineProperty(yp,"__esModule",{value:!0});var e=(function(){function u(f,h){for(var p=0;p0?f.fontSize+f.textMargin:0)+f.marginTop+f.marginBottom}function a(u,f,h){if(h.displayValue&&ff&&(f=u[h].height);return f}function d(u,f,h){var p;if(h)p=h;else if(typeof document<"u")p=document.createElement("canvas").getContext("2d");else return 0;p.font=f.fontOptions+" "+f.fontSize+"px "+f.font;var g=p.measureText(u);if(!g)return 0;var v=g.width;return v}return Jn.getMaximumHeightOfEncodings=l,Jn.getEncodingHeight=n,Jn.getBarcodePadding=a,Jn.calculateEncodingAttributes=i,Jn.getTotalWidthOfEncodings=s,Jn}var ML;function dge(){if(ML)return Ep;ML=1,Object.defineProperty(Ep,"__esModule",{value:!0});var e=(function(){function l(d,u){for(var f=0;f0?(g=0,h.textAlign="left"):u.textAlign=="right"?(g=f.width-1,h.textAlign="right"):(g=f.width/2,h.textAlign="center"),h.fillText(f.text,g,v)}}},{key:"moveCanvasDrawing",value:function(u){var f=this.canvas.getContext("2d");f.translate(u.width,0)}},{key:"restoreCanvas",value:function(){var u=this.canvas.getContext("2d");u.restore()}}]),l})();return Ep.default=s,Ep}var Pp={},RL;function fge(){if(RL)return Pp;RL=1,Object.defineProperty(Pp,"__esModule",{value:!0});var e=(function(){function d(u,f){for(var h=0;h0&&(this.drawRect(w-h.width*b,v,h.width*b,h.height,f),b=0);b>0&&this.drawRect(w-h.width*(b-1),v,h.width*b,h.height,f)}},{key:"drawSVGText",value:function(f,h,p){var g=this.document.createElementNS(s,"text");if(h.displayValue){var v,b;g.setAttribute("font-family",h.font),g.setAttribute("font-size",h.fontSize),h.fontOptions.includes("bold")&&g.setAttribute("font-weight","bold"),h.fontOptions.includes("italic")&&g.setAttribute("font-style","italic"),h.textPosition=="top"?b=h.fontSize-h.textMargin:b=h.height+h.textMargin+h.fontSize,h.textAlign=="left"||p.barcodePadding>0?(v=0,g.setAttribute("text-anchor","start")):h.textAlign=="right"?(v=p.width-1,g.setAttribute("text-anchor","end")):(v=p.width/2,g.setAttribute("text-anchor","middle")),g.setAttribute("x",v),g.setAttribute("y",b),g.appendChild(this.document.createTextNode(p.text)),f.appendChild(g)}}},{key:"setSvgAttributes",value:function(f,h){var p=this.svg;p.setAttribute("width",f+"px"),p.setAttribute("height",h+"px"),p.setAttribute("x","0px"),p.setAttribute("y","0px"),p.setAttribute("viewBox","0 0 "+f+" "+h),p.setAttribute("xmlns",s),p.setAttribute("version","1.1")}},{key:"createGroup",value:function(f,h,p){var g=this.document.createElementNS(s,"g");return g.setAttribute("transform","translate("+f+", "+h+")"),p.appendChild(g),g}},{key:"setGroupOptions",value:function(f,h){f.setAttribute("fill",h.lineColor)}},{key:"drawRect",value:function(f,h,p,g,v){var b=this.document.createElementNS(s,"rect");return b.setAttribute("x",f),b.setAttribute("y",h),b.setAttribute("width",p),b.setAttribute("height",g),v.appendChild(b),b}}]),d})();return Pp.default=l,Pp}var Op={},DL;function hge(){if(DL)return Op;DL=1,Object.defineProperty(Op,"__esModule",{value:!0});var e=(function(){function n(a,i){for(var s=0;s"u"?"undefined":e(f))==="object"&&!f.nodeName)return{element:f,renderer:a.default.ObjectRenderer};throw new i.InvalidElementException}}function d(f){var h=document.querySelectorAll(f);if(h.length!==0){for(var p=[],g=0;g"u")throw Error("No element to render on was provided.");return z._renderProperties=(0,u.default)(R),z._encodings=[],z._options=w.default,z._errorHandler=new g.default(z),typeof L<"u"&&(V=V||{},V.format||(V.format=T()),z.options(V)[V.format](L,V).render()),z};C.getModule=function(M){return t.default[M]};for(var O in t.default)t.default.hasOwnProperty(O)&&P(t.default,O);function P(M,R){N.prototype[R]=N.prototype[R.toUpperCase()]=N.prototype[R.toLowerCase()]=function(L,V){var z=this;return z._errorHandler.wrapBarcodeCall(function(){V.text=typeof V.text>"u"?void 0:""+V.text;var G=(0,n.default)(z._options,V);G=(0,h.default)(G);var H=M[R],W=E(L,H,G);return z._encodings.push(W),z})}}function E(M,R,L){M=""+M;var V=new R(M,L);if(!V.valid())throw new v.InvalidInputException(V.constructor.name,M);var z=V.encode();z=(0,i.default)(z);for(var G=0;Gt in e?bge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,XN=(e,t)=>{for(var r in t||(t={}))i6.call(t,r)&&UL(e,r,t[r]);if(ly)for(var r of ly(t))s6.call(t,r)&&UL(e,r,t[r]);return e},JN=(e,t)=>{var r={};for(var n in e)i6.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&ly)for(var n of ly(e))t.indexOf(n)<0&&s6.call(e,n)&&(r[n]=e[n]);return r};/** - * @license QR Code generator library (TypeScript) - * Copyright (c) Project Nayuki. - * SPDX-License-Identifier: MIT - */var nl;(e=>{const t=class Nt{constructor(d,u,f,h){if(this.version=d,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],dNt.MAX_VERSION)throw new RangeError("Version value out of range");if(h<-1||h>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let p=[];for(let v=0;v7)throw new RangeError("Invalid value");let v,b;for(v=f;;v++){const C=Nt.getNumDataCodewords(v,u)*8,O=s.getTotalBits(d,v);if(O<=C){b=O;break}if(v>=h)throw new RangeError("Data too long")}for(const C of[Nt.Ecc.MEDIUM,Nt.Ecc.QUARTILE,Nt.Ecc.HIGH])g&&b<=Nt.getNumDataCodewords(v,C)*8&&(u=C);let w=[];for(const C of d){r(C.mode.modeBits,4,w),r(C.numChars,C.mode.numCharCountBits(v),w);for(const O of C.getData())w.push(O)}a(w.length==b);const j=Nt.getNumDataCodewords(v,u)*8;a(w.length<=j),r(0,Math.min(4,j-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let C=236;w.lengthN[O>>>3]|=C<<7-(O&7)),new Nt(v,u,N,p)}getModule(d,u){return 0<=d&&d>>9)*1335;const h=(u<<10|f)^21522;a(h>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,n(h,p));this.setFunctionModule(8,7,n(h,6)),this.setFunctionModule(8,8,n(h,7)),this.setFunctionModule(7,8,n(h,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,n(h,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,n(h,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,n(h,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let f=0;f<12;f++)d=d<<1^(d>>>11)*7973;const u=this.version<<12|d;a(u>>>18==0);for(let f=0;f<18;f++){const h=n(u,f),p=this.size-11+f%3,g=Math.floor(f/3);this.setFunctionModule(p,g,h),this.setFunctionModule(g,p,h)}}drawFinderPattern(d,u){for(let f=-4;f<=4;f++)for(let h=-4;h<=4;h++){const p=Math.max(Math.abs(h),Math.abs(f)),g=d+h,v=u+f;0<=g&&g{(C!=b-p||P>=v)&&N.push(O[C])});return a(N.length==g),N}drawCodewords(d){if(d.length!=Math.floor(Nt.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let h=0;h>>3],7-(u&7)),u++)}}a(u==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let u=0;u5&&d++):(this.finderPenaltyAddHistory(v,b),g||(d+=this.finderPenaltyCountPatterns(b)*Nt.PENALTY_N3),g=this.modules[p][w],v=1);d+=this.finderPenaltyTerminateAndCount(g,v,b)*Nt.PENALTY_N3}for(let p=0;p5&&d++):(this.finderPenaltyAddHistory(v,b),g||(d+=this.finderPenaltyCountPatterns(b)*Nt.PENALTY_N3),g=this.modules[w][p],v=1);d+=this.finderPenaltyTerminateAndCount(g,v,b)*Nt.PENALTY_N3}for(let p=0;pg+(v?1:0),u);const f=this.size*this.size,h=Math.ceil(Math.abs(u*20-f*10)/f)-1;return a(0<=h&&h<=9),d+=h*Nt.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let f=[6];for(let h=this.size-7;f.lengthNt.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*d+128)*d+64;if(d>=2){const f=Math.floor(d/7)+2;u-=(25*f-10)*f-55,d>=7&&(u-=36)}return a(208<=u&&u<=29648),u}static getNumDataCodewords(d,u){return Math.floor(Nt.getNumRawDataModules(d)/8)-Nt.ECC_CODEWORDS_PER_BLOCK[u.ordinal][d]*Nt.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let u=[];for(let h=0;h0);for(const h of d){const p=h^f.shift();f.push(0),u.forEach((g,v)=>f[v]^=Nt.reedSolomonMultiply(g,p))}return f}static reedSolomonMultiply(d,u){if(d>>>8||u>>>8)throw new RangeError("Byte out of range");let f=0;for(let h=7;h>=0;h--)f=f<<1^(f>>>7)*285,f^=(u>>>h&1)*d;return a(f>>>8==0),f}finderPenaltyCountPatterns(d){const u=d[1];a(u<=this.size*3);const f=u>0&&d[2]==u&&d[3]==u*3&&d[4]==u&&d[5]==u;return(f&&d[0]>=u*4&&d[6]>=u?1:0)+(f&&d[6]>=u*4&&d[0]>=u?1:0)}finderPenaltyTerminateAndCount(d,u,f){return d&&(this.finderPenaltyAddHistory(u,f),u=0),u+=this.size,this.finderPenaltyAddHistory(u,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(d,u){u[0]==0&&(d+=this.size),u.pop(),u.unshift(d)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function r(l,d,u){if(d<0||d>31||l>>>d)throw new RangeError("Value out of range");for(let f=d-1;f>=0;f--)u.push(l>>>f&1)}function n(l,d){return(l>>>d&1)!=0}function a(l){if(!l)throw new Error("Assertion error")}const i=class jr{constructor(d,u,f){if(this.mode=d,this.numChars=u,this.bitData=f,u<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(d){let u=[];for(const f of d)r(f,8,u);return new jr(jr.Mode.BYTE,d.length,u)}static makeNumeric(d){if(!jr.isNumeric(d))throw new RangeError("String contains non-numeric characters");let u=[];for(let f=0;f=1<{(t=>{const r=class{constructor(a,i){this.ordinal=a,this.formatBits=i}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(nl||(nl={}));(e=>{(t=>{const r=class{constructor(a,i){this.modeBits=a,this.numBitsCharCount=i}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(nl||(nl={}));var hc=nl;/** - * @license qrcode.react - * Copyright (c) Paul O'Shannessy - * SPDX-License-Identifier: ISC - */var wge={L:hc.QrCode.Ecc.LOW,M:hc.QrCode.Ecc.MEDIUM,Q:hc.QrCode.Ecc.QUARTILE,H:hc.QrCode.Ecc.HIGH},l6=128,c6="L",u6="#FFFFFF",d6="#000000",f6=!1,h6=1,Sge=4,jge=0,Nge=.1;function m6(e,t=0){const r=[];return e.forEach(function(n,a){let i=null;n.forEach(function(s,l){if(!s&&i!==null){r.push(`M${i+t} ${a+t}h${l-i}v1H${i+t}z`),i=null;return}if(l===n.length-1){if(!s)return;i===null?r.push(`M${l+t},${a+t} h1v1H${l+t}z`):r.push(`M${i+t},${a+t} h${l+1-i}v1H${i+t}z`);return}s&&i===null&&(i=l)})}),r.join("")}function p6(e,t){return e.slice().map((r,n)=>n=t.y+t.h?r:r.map((a,i)=>i=t.x+t.w?a:!1))}function Cge(e,t,r,n){if(n==null)return null;const a=e.length+r*2,i=Math.floor(t*Nge),s=a/t,l=(n.width||i)*s,d=(n.height||i)*s,u=n.x==null?e.length/2-l/2:n.x*s,f=n.y==null?e.length/2-d/2:n.y*s,h=n.opacity==null?1:n.opacity;let p=null;if(n.excavate){let v=Math.floor(u),b=Math.floor(f),w=Math.ceil(l+u-v),j=Math.ceil(d+f-b);p={x:v,y:b,w,h:j}}const g=n.crossOrigin;return{x:u,y:f,h:d,w:l,excavation:p,opacity:h,crossOrigin:g}}function _ge(e,t){return t!=null?Math.max(Math.floor(t),0):e?Sge:jge}function g6({value:e,level:t,minVersion:r,includeMargin:n,marginSize:a,imageSettings:i,size:s,boostLevel:l}){let d=U.useMemo(()=>{const v=(Array.isArray(e)?e:[e]).reduce((b,w)=>(b.push(...hc.QrSegment.makeSegments(w)),b),[]);return hc.QrCode.encodeSegments(v,wge[t],r,void 0,void 0,l)},[e,t,r,l]);const{cells:u,margin:f,numCells:h,calculatedImageSettings:p}=U.useMemo(()=>{let g=d.getModules();const v=_ge(n,a),b=g.length+v*2,w=Cge(g,s,v,i);return{cells:g,margin:v,numCells:b,calculatedImageSettings:w}},[d,s,i,n,a]);return{qrcode:d,margin:f,cells:u,numCells:h,calculatedImageSettings:p}}var Ege=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Pge=U.forwardRef(function(t,r){const n=t,{value:a,size:i=l6,level:s=c6,bgColor:l=u6,fgColor:d=d6,includeMargin:u=f6,minVersion:f=h6,boostLevel:h,marginSize:p,imageSettings:g}=n,b=JN(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=b,j=JN(b,["style"]),N=g?.src,C=U.useRef(null),O=U.useRef(null),P=U.useCallback(G=>{C.current=G,typeof r=="function"?r(G):r&&(r.current=G)},[r]),[E,T]=U.useState(!1),{margin:A,cells:M,numCells:R,calculatedImageSettings:L}=g6({value:a,level:s,minVersion:f,boostLevel:h,includeMargin:u,marginSize:p,imageSettings:g,size:i});U.useEffect(()=>{if(C.current!=null){const G=C.current,H=G.getContext("2d");if(!H)return;let W=M;const q=O.current,I=L!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;I&&L.excavation!=null&&(W=p6(M,L.excavation));const Y=window.devicePixelRatio||1;G.height=G.width=i*Y;const F=i/R*Y;H.scale(F,F),H.fillStyle=l,H.fillRect(0,0,R,R),H.fillStyle=d,Ege?H.fill(new Path2D(m6(W,A))):M.forEach(function(D,$){D.forEach(function(K,J){K&&H.fillRect(J+A,$+A,1,1)})}),L&&(H.globalAlpha=L.opacity),I&&H.drawImage(q,L.x+A,L.y+A,L.w,L.h)}}),U.useEffect(()=>{T(!1)},[N]);const V=XN({height:i,width:i},w);let z=null;return N!=null&&(z=U.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{T(!0)},ref:O,crossOrigin:L?.crossOrigin})),U.createElement(U.Fragment,null,U.createElement("canvas",XN({style:V,height:i,width:i,ref:P,role:"img"},j)),z)});Pge.displayName="QRCodeCanvas";var y6=U.forwardRef(function(t,r){const n=t,{value:a,size:i=l6,level:s=c6,bgColor:l=u6,fgColor:d=d6,includeMargin:u=f6,minVersion:f=h6,boostLevel:h,title:p,marginSize:g,imageSettings:v}=n,b=JN(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:j,numCells:N,calculatedImageSettings:C}=g6({value:a,level:s,minVersion:f,boostLevel:h,includeMargin:u,marginSize:g,imageSettings:v,size:i});let O=j,P=null;v!=null&&C!=null&&(C.excavation!=null&&(O=p6(j,C.excavation)),P=U.createElement("image",{href:v.src,height:C.h,width:C.w,x:C.x+w,y:C.y+w,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const E=m6(O,w);return U.createElement("svg",XN({height:i,width:i,viewBox:`0 0 ${N} ${N}`,ref:r,role:"img"},b),!!p&&U.createElement("title",null,p),U.createElement("path",{fill:l,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),U.createElement("path",{fill:d,d:E,shapeRendering:"crispEdges"}),P)});y6.displayName="QRCodeSVG";function Oge({data:e,width:t,height:r,showText:n,orientation:a="horizontal"}){const i=x.useRef(null),s=a==="vertical",l=Math.max(20,(s?t:r)-(n?14:4));x.useEffect(()=>{if(i.current&&e)try{xge(i.current,e,{format:"CODE128",width:1,height:l,displayValue:n!==!1,margin:2,fontOptions:"",fontSize:10})}catch{}},[e,l,n]);const d=o.jsx("svg",{ref:i,className:"w-full h-full min-h-0",style:{maxHeight:s?t:r}});return s?o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx("div",{style:{transform:"rotate(-90deg)",transformOrigin:"center center",width:r,height:t,display:"flex",alignItems:"center",justifyContent:"center"},children:d})}):d}const Jo=8;function cn(e){return Math.round(e/Jo)*Jo}const Ts=16;function zp(e,t,r,n,a,i,s=Ts){const l=s,d=s,u=a-s,f=i-s;let h=Math.max(20,cn(r)),p=Math.max(12,cn(n));const g=u-l,v=f-d;if(gh+T*f,g=[];let v=1;i==="mm"&&(d>120?v=20:d>60?v=10:d>25&&(v=5));const b=i==="inch"?8:10,w=Math.floor((0-h)/f)-2,j=Math.ceil((e-h)/f)+2,N=Math.max(-5e3,Math.min(5e3,w)),C=Math.max(-5e3,Math.min(5e3,j));for(let T=N;T<=C;T++){const A=p(T);if(A<-8||A>e+8)continue;const M=T===0||T%v===0;g.push(o.jsxs("g",{children:[o.jsx("line",{x1:A,y1:u,x2:A,y2:4,stroke:"#9ca3af",strokeWidth:1}),M?o.jsx("text",{x:A,y:12,fontSize:8,fill:"#4b5563",className:"select-none font-mono",textAnchor:"middle",children:T}):null]},`maj-${T}`));const R=Math.floor(b/2);for(let L=1;Le+4)continue;const G=L===R?10:12;g.push(o.jsx("line",{x1:z,y1:u,x2:z,y2:G,stroke:"#d1d5db",strokeWidth:.5},`min-${T}-${L}`))}}let O=0,P=0;l&&Number.isFinite(s)&&s>0&&(O=r+l.x/s*t,P=l.width/s*t);const E=l?kge(l.width,s,n,a,i):null;return o.jsxs("svg",{width:"100%",height:u,viewBox:`0 0 ${e} ${u}`,preserveAspectRatio:"none",className:"block bg-slate-100/90 border-b border-slate-300 pointer-events-none select-none shrink-0","aria-hidden":!0,children:[o.jsx("line",{x1:0,y1:u-.5,x2:e,y2:u-.5,stroke:"#e5e7eb"}),g,l&&Number.isFinite(P)&&P>.5&&o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:O,y:1,width:Math.max(1,Math.min(P,e-O+1)),height:u-4,fill:"rgb(59 130 246 / 0.22)",stroke:"rgb(37 99 235 / 0.85)",strokeWidth:1,rx:2}),E&&o.jsx("text",{x:O+Math.max(2,Math.min(P,e-O)/2),y:u-6,textAnchor:"middle",fontSize:8,fill:"#1d4ed8",className:"select-none font-mono",children:E})]})]})}function VL(e,t,r){const n=String(e.prefix??"").trim(),a=String(e.multipleOptionName??e.MultipleOptionName??"").trim(),i=r.filter(Boolean).join(", "),s=t||"…";return n?i?`${n}${i}`:`${n}${s}`:a?`${a}: ${i||s}`:i||s}function Ige(e){const t=e.extraNutrients;return Array.isArray(t)?t.map((r,n)=>{const a=r;return{id:String(a.id??`extra-${n}`),name:String(a.name??""),value:String(a.value??""),unit:String(a.unit??"")}}):[]}function KS(e,t,r){const n=r==="value"?t:`${t}Unit`,a=e[n];if(a!=null&&String(a).trim()!=="")return String(a).trim();const s=(Array.isArray(e.fixedNutrients)?e.fixedNutrients:[]).find(l=>String(l.key??"").trim()===t);return String(s?.[r]??"").trim()}function Mge(e,t){const r=String(t.getFullYear()),n=r.slice(-2),a=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),d=t.toLocaleString("en-US",{month:"long"}).toUpperCase(),u=t.toLocaleString("en-US",{weekday:"long"}).toUpperCase(),f=t.toLocaleString("en-US",{weekday:"short"}).toUpperCase();switch(t.toLocaleString("en-US",{month:"short"}).toUpperCase(),e){case"DD/MM/YYYY":return`${i}/${a}/${r}`;case"MM/DD/YYYY":return`${a}/${i}/${r}`;case"DD/MM/YY":return`${i}/${a}/${n}`;case"MM/DD/YY":return`${a}/${i}/${n}`;case"MM/YY":return`${a}/${n}`;case"MM/DD":return`${a}/${i}`;case"MM":return a;case"DD":return i;case"YY":return n;case"FULLY DAY(WEDNESDAY)":return u;case"DAY (WED)":return f;case"MONTH (DECEMBER)":return d;case"YEAR (2025)":return r;case"DD MONTH YEAR (25 DECEMBER 2025)":return`${i} ${d} ${r}`;default:return e.replace("YYYY",r).replace("YY",n).replace("MM",a).replace("DD",i).replace("HH",s).replace("mm",l)}}const Rge=new Set(["Minutes","Hours","Days","Weeks","Months (30 Day)","Years"]);function Dge(e){const t=String(e??"").trim().toLowerCase();return t==="milligrams"?"mg":t==="grams"?"g":t==="ounces"?"oz":t==="pounds"?"lb":t==="kilograms"?"kg":t==="lb"||t==="kg"||t==="mg"||t==="g"||t==="oz"?t:"g"}function x6({el:e,isAppPrintField:t}){const r=e.config,n=Kr(e.type),a=e.rotation==="vertical",i={fontSize:r?.fontSize??14,fontFamily:r?.fontFamily??"Arial",fontWeight:r?.fontWeight??"normal",textAlign:r?.textAlign??"left",color:r?.color??"#000"},l=a&&(n==="TEXT_STATIC"||n==="TEXT_PRODUCT"||n==="TEXT_PRICE")?{writingMode:"vertical-rl",textOrientation:"mixed"}:{},d=a?{transform:"rotate(-90deg)",transformOrigin:"center center"}:{},u=r?.inputType;if(n==="TEXT_STATIC"){const f=r?.text??"Text";if(t){if(u==="options"){const p=Array.isArray(r?.selectedOptionValues)?r.selectedOptionValues:[],g=VL(r,f,p);return o.jsx("div",{className:"w-full h-full px-1 flex flex-col justify-center overflow-hidden pointer-events-none text-gray-600 italic text-[11px] leading-tight break-all",style:{...i,...l},title:"Filled in mobile app when printing",children:g})}const h=u==="number"?r?.text??"0":f;return o.jsx("div",{className:"w-full h-full px-1 flex items-center overflow-hidden pointer-events-none text-gray-600 italic text-[11px]",style:{...i,...l},title:"Filled in mobile app when printing",children:h})}if(u==="number")return o.jsx("input",{type:"number",readOnly:!0,value:r?.text??"0",className:"w-full h-full min-w-0 border border-gray-300 bg-white rounded px-1 pointer-events-none",style:{...i,...l,textAlign:"right"}});if(u==="options"){const h=Array.isArray(r?.selectedOptionValues)?r.selectedOptionValues:[],p=VL(r,f,h),g=h.length===0;return o.jsx("div",{className:Ie("w-full h-full px-1 overflow-hidden whitespace-pre-wrap break-all leading-tight",g&&"text-gray-400"),style:{...i,...l},title:p,children:p})}return u==="text"?o.jsx("input",{type:"text",readOnly:!0,value:f,className:"w-full h-full min-w-0 border border-gray-300 bg-white rounded px-1 pointer-events-none",style:{...i,...l}}):o.jsx("div",{className:"w-full h-full px-1 overflow-hidden whitespace-pre-wrap break-all leading-tight",style:{...i,...l},children:f})}if(n==="TEXT_PRODUCT"){const f=r?.text??"Product name";return o.jsx("div",{className:"w-full h-full px-1 overflow-hidden whitespace-pre-wrap break-all leading-tight",style:{...i,...l},children:f})}if(n==="TEXT_PRICE"){const f=r?.text??"0.00";return o.jsx("div",{className:"w-full h-full px-1 overflow-hidden flex items-center",style:{...i,...l,justifyContent:i.textAlign==="center"?"center":i.textAlign==="right"?"flex-end":"flex-start"},children:o.jsx("span",{children:f})})}if(n==="BARCODE"){const f=r?.data??"123456789",h=r?.showText!==!1,p=r?.orientation==="vertical"?"vertical":"horizontal";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full overflow-hidden p-0.5",children:o.jsx("div",{className:"flex-1 w-full min-h-0 flex items-center justify-center",children:o.jsx(Oge,{data:f,width:e.width,height:e.height,showText:h,orientation:p})})})}if(n==="QRCODE"){const f=r?.data??"https://example.com",h=Math.min(e.width,e.height)-4;return o.jsx("div",{className:"w-full h-full flex items-center justify-center p-0.5",children:o.jsx(y6,{value:f,size:Math.max(20,h),level:"M",includeMargin:!1})})}if(n==="IMAGE"){const f=r?.src,h=a?{transform:"rotate(-90deg)"}:{};return f?o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("img",{src:Tf(f),alt:"",className:"max-w-full max-h-full object-contain",style:h})}):o.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center bg-gray-100 text-gray-500 text-[10px] border border-dashed border-gray-300",style:h,children:o.jsx("span",{className:"font-medium",children:"Logo"})})}if(n==="DATE"){const f=r?.__previewFormatted;if(typeof f=="string"){const j=f.trim();return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:j||"—"})})}const h=String(r?.inputType??r?.InputType??"").toLowerCase(),p=(typeof r?.format=="string"&&r.format.trim()?r.format:typeof r?.Format=="string"&&r.Format.trim()?r.Format:h==="datetime"?"YYYY-MM-DD HH:mm":"DD/MM/YYYY")??(h==="datetime"?"YYYY-MM-DD HH:mm":"DD/MM/YYYY"),g=Number(r?.offsetDays??r?.OffsetDays??0)||0,v=new Date;v.setDate(v.getDate()+g);const b=Mge(p,v);return h==="datetime"||h==="date"?t?o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 flex items-center justify-center overflow-hidden pointer-events-none text-[10px] text-center whitespace-nowrap",style:{...i,...d},title:`Format: ${p}`,children:p})}):o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("input",{type:"date",readOnly:!0,value:"2025-02-01",className:"w-full h-full min-w-0 border border-gray-300 bg-white rounded px-1 pointer-events-none text-[10px]",style:{...i,...d}})}):o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:b})})}if(n==="TIME"){const f=r?.__previewFormatted;if(typeof f=="string")return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:f.trim()||"—"})});const p="HH:mm".replace("HH","12").replace("mm","30");return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:p})})}if(n==="DURATION"){const f=r?.__previewFormatted;if(typeof f=="string")return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:f.trim()||"—"})});const h=(typeof r?.format=="string"&&r.format.trim()?r.format:typeof r?.Format=="string"&&r.Format.trim()?r.Format:"Days")??"Days",p=Rge.has(h)?h:"Days",g=r?.durationValue??r?.value??r?.offsetDays??r?.DurationValue??r?.Value??r?.OffsetDays,b=`${Number.isFinite(Number(g))?Number(g):3} ${p}`;return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:b})})}if(n==="WEIGHT"){const f=r?.value??r?.Value,h=f==null||f===""?500:typeof f=="number"?f:Number(f),p=Number.isFinite(h)?h:500,g=Dge((typeof r?.unit=="string"&&r.unit.trim()?r.unit:typeof r?.Unit=="string"&&r.Unit.trim()?r.Unit:"g")??"g"),v=r?.fontSize??r?.FontSize,b=Number.isFinite(Number(v))?Number(v):14,w=String(r?.textAlign??r?.TextAlign??"left").toLowerCase(),j=w==="center"||w==="right"?w:"left";return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsxs("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d,fontSize:b,textAlign:j},children:[p,g]})})}if(n==="WEIGHT_PRICE"){const f=r?.unitPrice??10,h=r?.weight??.5,p=r?.currency??"$";return o.jsxs("div",{className:"w-full h-full px-1 overflow-hidden whitespace-nowrap",style:i,children:[p,(f*h).toFixed(2)]})}if(n==="NUTRITION"){const f=String(r.servingsPerContainer??r.ServingsPerContainer??"").trim(),h=String(r.servingSize??r.ServingSize??"").trim(),p=String(r.calories??r.Calories??KS(r,"calories","value")??"").trim(),g=Number(r.nutritionTitleFontSize??r.NutritionTitleFontSize??16)||16,v=rl.map(C=>{const O=KS(r,C.key,"value"),P=KS(r,C.key,"unit");return O?{id:C.key,label:C.label,value:O,unit:P}:null}).filter(Boolean),b=Ige(r).filter(C=>C.value.trim()).map(C=>({id:C.id,label:C.name.trim()||"Other",value:C.value.trim(),unit:C.unit.trim()})),w=[...v,...b],j=(C,O)=>{const P=String(C??"").trim(),E=String(O??"").trim();return!P&&!E?"":`<${P}${E?` ${E}`:""}`},N=o.jsxs("div",{className:"text-[10px] p-1 w-full h-full overflow-hidden flex flex-col leading-tight bg-white",children:[o.jsx("div",{className:"font-bold border-b border-black pb-0.5",style:{fontSize:`${g}px`},children:"Nutrition Facts"}),p?o.jsxs("div",{className:"flex items-center justify-between py-0.5 mt-0.5",children:[o.jsx("span",{className:"font-semibold text-[10px]",children:"Calories"}),o.jsx("span",{className:"font-semibold text-[10px]",children:j(p,"")})]}):null,f?o.jsxs("div",{className:"flex items-center justify-between py-0.5 text-[10px]",children:[o.jsx("span",{children:"Servings Per Container"}),o.jsx("span",{children:f})]}):null,h?o.jsxs("div",{className:"flex items-center justify-between pb-0.5 text-[10px]",children:[o.jsx("span",{children:"Serving Size"}),o.jsx("span",{children:h})]}):null,o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden pt-0.5",children:w.length===0?o.jsx("div",{className:"text-[7px] text-gray-500",children:"No nutrients"}):w.slice(0,18).map(C=>o.jsxs("div",{className:"flex items-center justify-between py-[1px] text-[10px]",children:[o.jsx("span",{className:"truncate font-medium",children:C.label}),o.jsx("span",{className:"shrink-0 font-medium",children:j(C.value,C.unit)})]},C.id))})]});return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"shrink-0",style:a?{width:e.height,height:e.width,transform:"rotate(-90deg)",transformOrigin:"center center"}:{width:"100%",height:"100%"},children:N})})}return n==="BLANK"?o.jsx("div",{className:"w-full h-full border border-dashed border-gray-200"}):o.jsx("div",{className:"text-gray-500 text-[10px] px-1 truncate w-full flex items-center justify-center",children:e.type.replace(/_/g," ")})}function Lge(e){return e==="top"||e==="bottom"?"ns-resize":e==="left"||e==="right"?"ew-resize":e==="top-left"||e==="bottom-right"?"nwse-resize":"nesw-resize"}function $ge({template:e,canvasBorder:t="none",selectedId:r,onSelect:n,onUpdateElement:a,onDeleteElement:i,onTemplateChange:s,scale:l=1,onZoomIn:d,onZoomOut:u,onResetZoom:f,onPreview:h,hideToolbarPresetSize:p=!1}){const g=x.useRef(null),v=x.useRef(null),b=x.useRef(null),w=x.useRef(null),j=x.useRef(null),N=x.useRef(null),C=x.useRef(null),[O,P]=U.useState(!1),[E,T]=U.useState(!1),[A,M]=U.useState(null),R=x.useRef(null),[L,V]=U.useState({x:0,y:0}),z=x.useRef(null),[G,H]=x.useState("cm"),W=ho(e.width,e.unit),q=ho(e.height,e.unit),I=W*l,Y=q*l,F=e.showGrid!==!1,D=t==="line"?"border border-gray-500":t==="dotted"?"border border-dotted border-gray-500":"border border-transparent",$=x.useRef(null),[K,J]=x.useState(0);x.useLayoutEffect(()=>{const ne=$.current;if(!ne)return;const pe=new ResizeObserver(_e=>{for(const ve of _e)J(ve.contentRect.width)});return pe.observe(ne),J(ne.getBoundingClientRect().width),()=>pe.disconnect()},[]);const oe=Math.max(1,K,I),re=Math.max(0,(oe-I)/2),Q=x.useMemo(()=>{if(!r)return null;const ne=e.elements.find(pe=>pe.id===r);return ne?{x:ne.x,width:ne.width}:null},[r,e.elements]),ue=x.useCallback((ne,pe)=>{if(O||ne.button===1)return;ne.stopPropagation(),n(pe),v.current?.focus();const _e=e.elements.find(ke=>ke.id===pe);if(!_e)return;const ve=document.getElementById(`element-${pe}`);ve&&(ve.classList.add("z-50","opacity-90","shadow-xl","ring-2","ring-blue-400","ring-offset-2"),ve.style.cursor="grabbing"),b.current={id:pe,startX:ne.clientX,startY:ne.clientY,elX:_e.x,elY:_e.y,w:_e.width,h:_e.height},N.current={id:pe,x:_e.x,y:_e.y},ne.currentTarget.setPointerCapture?.(ne.pointerId)},[e.elements,n,O]),se=x.useCallback(ne=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{ne(),C.current=null})},[]),fe=x.useCallback((ne,pe)=>{ne.stopPropagation(),j.current={edge:pe,startX:ne.clientX,startY:ne.clientY,startW:e.width,startH:e.height,startElements:e.elements.map(ve=>({id:ve.id,x:ve.x,y:ve.y}))};const _e=Lge(pe);M(_e),document.body.style.cursor=_e,ne.currentTarget.setPointerCapture?.(ne.pointerId)},[e.width,e.height,e.elements]),we=x.useCallback(ne=>{if(E&&z.current){const pe=ne.clientX-z.current.startX,_e=ne.clientY-z.current.startY;V({x:z.current.x+pe,y:z.current.y+_e});return}if(E&&R.current&&g.current){const pe=ne.clientX-R.current.x,_e=ne.clientY-R.current.y;g.current.scrollLeft=R.current.scrollLeft-pe,g.current.scrollTop=R.current.scrollTop-_e;return}if(b.current){const{id:pe,startX:_e,startY:ve,elX:ke,elY:Ge,w:xe,h:Je}=b.current,dt=ne.clientX,jt=ne.clientY;se(()=>{const Wt=(dt-_e)/l,er=(jt-ve)/l,Ae=ke+Wt,pt=Ge+er,{x:Ot,y:Qt}=qL(Ae,pt,xe,Je,W,q,Ts),Ar=document.getElementById(`element-${pe}`);Ar&&(Ar.style.left=`${Ot}px`,Ar.style.top=`${Qt}px`),N.current={id:pe,x:Ot,y:Qt}})}if(w.current){const{id:pe,corner:_e,startX:ve,startY:ke,w:Ge,h:xe,elX:Je,elY:dt}=w.current,jt=ne.clientX,Wt=ne.clientY;se(()=>{const er=(jt-ve)/l,Ae=(Wt-ke)/l;let pt=Ge,Ot=xe,Qt=Je,Ar=dt;_e.includes("e")&&(pt=Math.max(20,Ge+er)),_e.includes("w")&&(pt=Math.max(20,Ge-er),Qt=Je+(Ge-pt)),_e.includes("s")&&(Ot=Math.max(12,xe+Ae)),_e.includes("n")&&(Ot=Math.max(12,xe-Ae),Ar=dt+(xe-Ot));const Vn=cn(pt),Jr=cn(Ot),Ur=cn(Qt),Er=cn(Ar),qt=zp(Ur,Er,Vn,Jr,W,q,Ts),gr=document.getElementById(`element-${pe}`);gr&&(gr.style.width=`${qt.w}px`,gr.style.height=`${qt.h}px`,gr.style.left=`${qt.x}px`,gr.style.top=`${qt.y}px`),N.current={id:pe,width:qt.w,height:qt.h,x:qt.x,y:qt.y}})}if(j.current&&s){const{edge:pe,startX:_e,startY:ve,startW:ke,startH:Ge,startElements:xe}=j.current,Je=ne.clientX,dt=ne.clientY;se(()=>{const jt=(Je-_e)/l,Wt=(dt-ve)/l,er=1,Ae=ho(ke,e.unit),pt=ho(Ge,e.unit),Ot=ho(er,e.unit),Qt=ho(er,e.unit),Ar=pe==="top"||pe==="top-left"||pe==="top-right",Vn=pe==="bottom"||pe==="bottom-left"||pe==="bottom-right",Jr=pe==="left"||pe==="top-left"||pe==="bottom-left",Ur=pe==="right"||pe==="top-right"||pe==="bottom-right";let Er=ke,qt=Ge,gr=0,Kt=0;if(Ur){const tr=Math.max(Ot,Ae+jt);Er=Math.max(er,Math.round(kp(tr,e.unit)))}if(Vn){const tr=Math.max(Qt,pt+Wt);qt=Math.max(er,Math.round(kp(tr,e.unit)))}if(Jr){const tr=Math.max(Ot,Ae-jt);Er=Math.max(er,Math.round(kp(tr,e.unit)));const Qe=ho(Er,e.unit);gr=Ae-Qe}if(Ar){const tr=Math.max(Qt,pt-Wt);qt=Math.max(er,Math.round(kp(tr,e.unit)));const Qe=ho(qt,e.unit);Kt=pt-Qe}const fr={};if((Jr||Ur)&&(fr.width=Er),(Ar||Vn)&&(fr.height=qt),(gr!==0||Kt!==0)&&xe.length>0){const tr=new Map(xe.map(Qe=>[Qe.id,Qe]));fr.elements=e.elements.map(Qe=>{const Tt=tr.get(Qe.id);if(!Tt)return Qe;const Lt=Math.max(0,Tt.x-gr),sr=Math.max(0,Tt.y-Kt);return Lt===Qe.x&&sr===Qe.y?Qe:{...Qe,x:Lt,y:sr}})}s(fr)})}},[E,s,l,e.unit,se,W,q]),Z=x.useCallback(()=>{E&&(T(!1),R.current=null,z.current=null),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null);const ne=b.current?.id||w.current?.id;if(ne){const pe=document.getElementById(`element-${ne}`);pe&&(pe.classList.remove("z-50","opacity-90","shadow-xl","ring-2","ring-blue-400","ring-offset-2"),pe.style.cursor="")}if(N.current){const{id:pe,..._e}=N.current;a(pe,_e),N.current=null}b.current=null,w.current=null,j.current=null,M(null),document.body.style.cursor=""},[a]);x.useEffect(()=>{const ne=_e=>{_e.code==="Space"&&!_e.repeat&&P(!0)},pe=_e=>{_e.code==="Space"&&(P(!1),T(!1),R.current=null,z.current=null)};return window.addEventListener("keydown",ne),window.addEventListener("keyup",pe),()=>{window.removeEventListener("keydown",ne),window.removeEventListener("keyup",pe)}},[]),x.useEffect(()=>{if(A)return document.body.style.cursor=A,()=>{document.body.style.cursor=""}},[A]);const je=x.useCallback(()=>{const ne=g.current;if(!ne)return;const pe=()=>{ne.scrollLeft=Math.max(0,(ne.scrollWidth-ne.clientWidth)/2),ne.scrollTop=Math.max(0,(ne.scrollHeight-ne.clientHeight)/2)};requestAnimationFrame(()=>requestAnimationFrame(pe))},[]);x.useEffect(()=>{V({x:0,y:0}),je();const ne=window.setTimeout(je,80);return()=>window.clearTimeout(ne)},[l,W,q,K,je]);const Ce=x.useCallback(ne=>{if(!r)return;if(ne.key==="Delete"||ne.key==="Backspace"){ne.preventDefault();const jt=e.elements.findIndex(Wt=>Wt.id===r);if(jt>=0){const Wt=e.elements.filter(er=>er.id!==r);i(r),n(Wt[jt]?.id??Wt[jt-1]?.id??null)}return}const pe=e.elements.find(jt=>jt.id===r);if(!pe)return;const _e=ne.shiftKey?1:Jo;let ve=0,ke=0;switch(ne.key){case"ArrowLeft":ve=-_e;break;case"ArrowRight":ve=_e;break;case"ArrowUp":ke=-_e;break;case"ArrowDown":ke=_e;break;default:return}ne.preventDefault();const Ge=pe.x+ve,xe=pe.y+ke,{x:Je,y:dt}=qL(Ge,xe,pe.width,pe.height,W,q,Ts);a(pe.id,{x:Je,y:dt})},[r,e.elements,a,i,n,W,q]),qe=ne=>{(O||ne.button===1)&&(ne.preventDefault(),T(!0),R.current={x:ne.clientX,y:ne.clientY,scrollLeft:g.current?.scrollLeft||0,scrollTop:g.current?.scrollTop||0},ne.currentTarget.setPointerCapture(ne.pointerId))},De=ne=>{if(E&&R.current&&g.current){const pe=ne.clientX-R.current.x,_e=ne.clientY-R.current.y;g.current.scrollLeft=R.current.scrollLeft-pe,g.current.scrollTop=R.current.scrollTop-_e}},He=ne=>{E&&(T(!1),R.current=null)};return o.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden bg-gray-100",children:[o.jsxs("div",{className:"shrink-0 px-4 py-2 border-b border-gray-200 bg-white flex flex-nowrap items-center justify-between gap-3 z-10 min-h-[44px]",children:[o.jsx("span",{className:"text-sm font-medium text-gray-700 shrink-0 min-w-0 truncate",children:"Label Preview"}),o.jsxs("div",{className:"flex flex-nowrap items-center justify-end gap-2 shrink-0 min-w-0",children:[h&&o.jsx("button",{type:"button",onClick:h,className:"h-8 px-3 rounded border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 text-xs font-medium shadow-sm transition-all active:scale-95 shrink-0",children:"Preview"}),s&&!p?o.jsxs($e,{value:(()=>{const ne=wc.findIndex(pe=>pe.width===e.width&&pe.height===e.height&&pe.unit===e.unit);return ne>=0?String(ne):"custom"})(),onValueChange:ne=>{if(ne==="custom")return;const pe=wc[Number(ne)];pe&&s({width:pe.width,height:pe.height,unit:pe.unit})},children:[o.jsx(Be,{className:"h-8 w-[130px] max-w-[130px] text-xs shrink-0",children:o.jsx(Fe,{placeholder:"Canvas size"})}),o.jsxs(ze,{children:[wc.map((ne,pe)=>o.jsx(Se,{value:String(pe),className:"text-xs",children:ne.name},pe)),o.jsx(Se,{value:"custom",className:"text-xs text-gray-500",children:"Custom"})]})]}):null,s?o.jsx("button",{type:"button",onClick:()=>s({showGrid:!F}),className:Ie("h-8 px-3 rounded border text-xs font-medium shadow-sm transition-colors shrink-0",F?"border-gray-300 bg-white text-gray-700 hover:bg-gray-50":"border-gray-300 bg-gray-100 text-gray-500"),children:F?"Hide grid":"Show grid"}):null,o.jsxs("div",{className:"flex items-center gap-1 bg-white rounded border border-gray-300 p-0.5 shadow-sm h-8 shrink-0",children:[o.jsx("button",{type:"button",onClick:u,disabled:!u,className:"h-6 w-6 rounded hover:bg-gray-100 text-gray-600 disabled:opacity-50 disabled:pointer-events-none flex items-center justify-center text-sm font-medium active:scale-90 transition-transform",title:"Zoom out",children:"−"}),o.jsxs("span",{className:"min-w-[3rem] text-center text-xs text-gray-600 font-medium",children:[Math.round(l*100),"%"]}),o.jsx("button",{type:"button",onClick:d,disabled:!d,className:"h-6 w-6 rounded hover:bg-gray-100 text-gray-600 disabled:opacity-50 disabled:pointer-events-none flex items-center justify-center text-sm font-medium active:scale-90 transition-transform",title:"Zoom in",children:"+"})]}),f?o.jsx("button",{type:"button",onClick:f,className:"h-8 px-3 rounded border border-blue-200 bg-blue-50 text-blue-800 hover:bg-blue-100 text-xs font-medium shadow-sm transition-all active:scale-95 shrink-0",title:"Reset zoom to 100% (match ruler canvas size, e.g. 3×2 inch)",children:"Restore size"}):null,o.jsxs($e,{value:G,onValueChange:ne=>H(ne),children:[o.jsx(Be,{className:Ie("h-8 w-auto min-w-[4.25rem] max-w-[5.5rem] px-3 text-xs font-medium shrink-0 rounded border border-gray-300 bg-white text-gray-700 shadow-sm","hover:bg-gray-50 transition-all active:scale-95","focus:ring-0 focus:ring-offset-0 data-[state=open]:bg-gray-50"),title:"Preview ruler unit (does not change canvas size)",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"cm",className:"text-xs",children:"cm"}),o.jsx(Se,{value:"mm",className:"text-xs",children:"mm"}),o.jsx(Se,{value:"inch",className:"text-xs",children:"inch"})]})]})]})]}),o.jsxs("div",{ref:g,className:Ie("flex-1 min-h-0 overflow-auto relative",O?"cursor-grab active:cursor-grabbing":""),onPointerDown:qe,onPointerMove:De,onPointerUp:He,onPointerLeave:He,children:[o.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 bg-gray-100","aria-hidden":!0}),o.jsx("div",{className:"relative z-[1] flex min-w-full w-max min-h-full flex-col box-border p-[50px]",style:{transform:`translate(${L.x}px, ${L.y}px)`},children:o.jsxs("div",{ref:$,className:"flex w-full min-w-full flex-col",children:[o.jsx("div",{className:"mb-2 w-full min-w-0",children:o.jsx(Age,{rulerTotalWidthPx:oe,paperWidthPx:I,paperOffsetLeftPx:re,paperWidthTemplate:e.width,templateUnit:e.unit,displayUnit:G,baseW:W,selection:Q})}),o.jsx("div",{className:"flex w-full min-w-0 justify-center",children:o.jsx("div",{className:"shrink-0 relative overflow-visible",style:{width:I,height:Y},children:o.jsxs("div",{ref:v,tabIndex:0,className:Ie("absolute left-0 top-0 bg-white shadow-lg outline-none",D,E?"cursor-grabbing":"cursor-grab"),style:{width:W,height:q,transform:`scale(${l})`,transformOrigin:"top left",backgroundImage:F?`linear-gradient(to right, rgba(0,0,0,0.06) 1px, transparent 1px), - linear-gradient(to bottom, rgba(0,0,0,0.06) 1px, transparent 1px)`:void 0,backgroundSize:F?`${Jo}px ${Jo}px`:void 0,pointerEvents:O?"none":"auto",cursor:A??void 0},onClick:ne=>{const pe=ne.target,_e=pe.closest('[id^="element-"]'),ve=pe.closest('[data-paper-resize-handle="true"]')||pe.closest('[title*="Drag to resize paper"]')||pe.closest('[title*="Drag to increase paper height"]')||pe.closest('[title*="Drag to increase paper width"]');!_e&&!ve&&n(null)},onPointerDown:ne=>{const pe=ne.target,_e=pe.closest('[id^="element-"]'),ve=pe.closest('[data-paper-resize-handle="true"]')||pe.closest('[title*="Drag to resize paper"]')||pe.closest('[title*="Drag to increase paper height"]')||pe.closest('[title*="Drag to increase paper width"]');v.current?.contains(pe)&&!_e&&!ve&&!b.current&&!w.current&&(O||ne.button===1)&&(ne.preventDefault(),ne.stopPropagation(),T(!0),z.current={x:L.x,y:L.y,startX:ne.clientX,startY:ne.clientY},R.current={x:ne.clientX,y:ne.clientY,scrollLeft:g.current?.scrollLeft??0,scrollTop:g.current?.scrollTop??0},ne.currentTarget.setPointerCapture?.(ne.pointerId))},onPointerMove:we,onPointerUp:Z,onKeyDown:Ce,children:[r?(()=>{const ne=e.elements.find(_e=>_e.id===r);if(!ne)return null;const pe="pointer-events-none absolute z-[2] border-blue-600";return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:Ie(pe,"left-0 right-0 border-t border-dashed"),style:{top:ne.y},"aria-hidden":!0}),o.jsx("div",{className:Ie(pe,"left-0 right-0 border-t border-dashed"),style:{top:ne.y+ne.height},"aria-hidden":!0}),o.jsx("div",{className:Ie(pe,"top-0 bottom-0 border-l border-dashed"),style:{left:ne.x},"aria-hidden":!0}),o.jsx("div",{className:Ie(pe,"top-0 bottom-0 border-l border-dashed"),style:{left:ne.x+ne.width},"aria-hidden":!0})]})})():null,s&&o.jsx("div",{className:"absolute left-0 right-0 h-3 cursor-ns-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-b border-gray-300 text-[10px] text-gray-500 transition-colors",style:{top:0},title:"Drag to resize paper (top edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"top"),children:"⋮"}),s&&o.jsx("div",{className:"absolute top-0 bottom-0 w-3 cursor-ew-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-r border-gray-300 text-[10px] text-gray-500 transition-colors",style:{top:0},title:"Drag to resize paper (left edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"left"),children:"⋮"}),s&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-3 cursor-ns-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-t border-gray-300 text-[10px] text-gray-500 transition-colors",title:"Drag to resize paper (bottom edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"bottom"),children:"⋮"}),s&&o.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-3 cursor-ew-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-l border-gray-300 text-[10px] text-gray-500 transition-colors",title:"Drag to resize paper (right edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"right"),children:"⋮"}),e.elements.map(ne=>{const pe=ru(ne);return o.jsxs("div",{id:`element-${ne.id}`,className:Ie("absolute box-border cursor-move overflow-hidden transition-shadow",ne.border==="line"&&"border border-gray-400",ne.border==="dotted"&&"border border-dotted border-gray-400",r===ne.id&&"ring-2 ring-blue-500 ring-offset-1 z-10"),style:{left:ne.x,top:ne.y,width:ne.width,height:ne.height},onClick:_e=>{_e.stopPropagation(),n(ne.id)},onPointerDown:_e=>ue(_e,ne.id),children:[o.jsx("div",{className:Ie("w-full h-full min-h-0 relative",pe&&"rounded-sm border-2 border-dashed border-amber-500/85 bg-amber-50/35"),children:o.jsx(x6,{el:ne,isAppPrintField:pe})}),r===ne.id&&o.jsxs(o.Fragment,{children:[["nw","ne","sw","se"].map(_e=>o.jsx("div",{className:"absolute w-3.5 h-3.5 bg-white border-2 border-blue-600 rounded-none z-20 shadow-sm hover:scale-110 transition-transform",style:{cursor:"nwse-resize",top:_e.startsWith("n")?-6:void 0,bottom:_e.startsWith("s")?-6:void 0,left:_e.endsWith("w")?-6:void 0,right:_e.endsWith("e")?-6:void 0},onPointerDown:ve=>{ve.stopPropagation();const ke=e.elements.find(Ge=>Ge.id===ne.id);w.current={id:ne.id,corner:_e,startX:ve.clientX,startY:ve.clientY,w:ke.width,h:ke.height,elX:ke.x,elY:ke.y},ve.currentTarget.setPointerCapture?.(ve.pointerId)}},_e)),["n","s","w","e"].map(_e=>o.jsx("div",{className:"absolute bg-white border-2 border-blue-600 rounded-none z-10 shadow-sm hover:bg-blue-50",style:{cursor:_e==="n"||_e==="s"?"ns-resize":"ew-resize",width:_e==="n"||_e==="s"?"20px":"6px",height:_e==="n"||_e==="s"?"6px":"20px",top:_e==="n"?-3:_e==="s"?void 0:"50%",bottom:_e==="s"?-3:void 0,left:_e==="w"?-3:_e==="e"?void 0:"50%",right:_e==="e"?-3:void 0,transform:_e==="n"||_e==="s"?"translateX(-50%)":"translateY(-50%)"},onPointerDown:ve=>{ve.stopPropagation();const ke=e.elements.find(xe=>xe.id===ne.id),Ge=document.getElementById(`element-${ne.id}`);Ge&&Ge.classList.add("z-50","opacity-90"),w.current={id:ne.id,corner:_e,startX:ve.clientX,startY:ve.clientY,w:ke.width,h:ke.height,elX:ke.x,elY:ke.y},ve.currentTarget.setPointerCapture?.(ve.pointerId)}},_e))]})]},ne.id)}),W>Ts*2&&q>Ts*2?o.jsx("svg",{className:"pointer-events-none absolute left-0 top-0 z-[12]",width:W,height:q,style:{overflow:"visible"},"aria-hidden":!0,children:(()=>{const ne=Ts,pe="#2563eb",_e=2,ve="10 6";return o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:0,y1:ne,x2:W,y2:ne,stroke:pe,strokeWidth:_e,strokeDasharray:ve}),o.jsx("line",{x1:0,y1:q-ne,x2:W,y2:q-ne,stroke:pe,strokeWidth:_e,strokeDasharray:ve}),o.jsx("line",{x1:ne,y1:0,x2:ne,y2:q,stroke:pe,strokeWidth:_e,strokeDasharray:ve}),o.jsx("line",{x1:W-ne,y1:0,x2:W-ne,y2:q,stroke:pe,strokeWidth:_e,strokeDasharray:ve})]})})()}):null]})})})]})})]})]})}function nE({template:e,canvasBorder:t="none",maxWidth:r=480}){const n=ho(e.width,e.unit),a=ho(e.height,e.unit),i=Math.min(0,...e.elements.map(b=>b.x)),s=Math.min(0,...e.elements.map(b=>b.y)),l=Math.max(n,...e.elements.map(b=>b.x+b.width)),d=Math.max(a,...e.elements.map(b=>b.y+b.height)),u=Math.max(1,l-i),f=Math.max(1,d-s),h=r?Math.min(r/u,r/f,2):1,p=u*h,g=f*h,v=t==="line"?"border border-gray-500":t==="dotted"?"border border-dotted border-gray-500":"border border-transparent";return o.jsx("div",{className:"inline-flex items-center justify-center p-4 bg-gray-100 rounded",style:{minWidth:p+32},children:o.jsx("div",{style:{width:p,height:g},className:Ie("relative bg-white shadow-lg overflow-hidden",v),children:o.jsx("div",{className:"origin-top-left",style:{position:"absolute",left:0,top:0,width:u,height:f,transform:`scale(${h})`,transformOrigin:"0 0"},children:e.elements.map(b=>{const w=ru(b);return o.jsx("div",{className:"absolute box-border overflow-hidden pointer-events-none flex items-center justify-center text-xs",style:{left:b.x-i,top:b.y-s,width:b.width,height:b.height,border:b.border==="line"?"1px solid #999":b.border==="dotted"?"1px dotted #999":void 0},children:o.jsx("div",{className:Ie("w-full h-full min-h-0 relative",w&&"rounded-sm border-2 border-dashed border-amber-500/85 bg-amber-50/35"),children:o.jsx(x6,{el:b,isAppPrintField:w})})},b.id)})})})})}function Ea(e){const t=(e??"").trim();return t||"None"}function Fge(e){return(e.labelCode??e.id??"").trim()||"None"}function Bge(e){const t=(e.products??"").trim();if(t)return t;const r=(e.productName??"").trim();if(r)return r;const n=e.productIds?.length??0;return n>0?`${n} product(s)`:"None"}function zge(e){const t=(e.lastEdited??"").trim();if(t)return t;const r=e.creationTime;if(r)try{return new Date(r).toLocaleString()}catch{return String(r)}return"None"}function WL(e){const t=e.productIds,r=Array.isArray(t)?t.map(n=>String(n).trim()).filter(Boolean):[];return{labelName:e.labelName??"",templateCode:e.templateCode??"",locationId:e.locationId??"",labelCategoryId:e.labelCategoryId??"",labelTypeId:e.labelTypeId??"",productIds:r.length?[r[0]]:[],labelInfoJson:e.labelInfoJson??null,state:e.state??!0}}function Up(e){return e?iy(e.elements??[]).filter(Z_):[]}function Uge(e,t,r,n){if(!e)return null;const a=b6(e),i=new Date;for(const s of a.elements){if(!Z_(s))continue;const l={...s.config};delete l.__previewFormatted;const d=s.id,u=Kr(s.type);if(nu(s)){const f=r[d]??{unit:"Days",value:""},h=f.unit||"Days",p=H8(f.value);if(p.kind==="invalid")l.__previewFormatted="";else{const g=p.kind==="zero"?0:p.amount,v=gpe(i,g,h);if(u==="DATE"){const b=String(l.inputType??l.InputType??"").toLowerCase(),w=(typeof l.format=="string"&&l.format.trim()?l.format:typeof l.Format=="string"&&l.Format.trim()?l.Format:b==="datetime"?"YYYY-MM-DD HH:mm":"DD/MM/YYYY")??"DD/MM/YYYY";l.__previewFormatted=zD(w,v)}else u==="TIME"?l.__previewFormatted=zD("HH:mm",v):l.__previewFormatted=`${g} ${h}`}}else{const f=t[d]??"";u==="BARCODE"||u==="QRCODE"?l.data=f:u==="IMAGE"?l.src=f:l.text=f}s.config=l}for(const s of a.elements){if(Kr(s.type)!=="NUTRITION")continue;const l=n[s.id]??{},d=jpe({...s.config},l);s.config=d}return a}function qge(e,t,r,n){const a={};for(const i of Up(e)){const s=i.id;if(nu(i)){const l=r[s]??{unit:"Days",value:""},d=l.unit||"Days",u=H8(l.value);u.kind==="invalid"?a[s]="":u.kind==="zero"?a[s]=kf(d,"0"):a[s]=kf(d,u.storeValue)}else a[s]=String(t[s]??"")}for(const i of Sc(e.elements??[])){const s=n[i.id];if(!s)continue;const l=J8(s);l&&(a[i.id]=l)}return a}function Bi(e){return(e.templateCode??e.id??"").trim()}function cy(e){const t=(e.templateName??e.name??"").trim()||"None",r=Bi(e)||"None";return`${t} (${r})`}function b6(e){return{id:e.id,name:(e.name??e.templateName??"").trim()||"Unnamed template",labelType:e.labelType??"PRICE",unit:e.unit??"cm",width:e.width??6,height:e.height??4,appliedLocation:tu(e),appliedLocationIds:[...e.appliedLocationIds??[]],showRuler:e.showRuler??!0,showGrid:e.showGrid??!0,elements:(e.elements??[]).map((t,r)=>{const n=t,a=(n.elementName??"").trim();return{...n,elementName:a||`element${r+1}`}})}}function Vge(e){const t=new Map;for(const r of e.templateProductDefaults??[]){const n=`${r.productId}::${r.labelTypeId}`;t.set(n,r)}return t}function w6(e){const[t,r]=x.useState(!1),[n,a]=x.useState([]),[i,s]=x.useState([]),[l,d]=x.useState([]),[u,f]=x.useState([]),[h,p]=x.useState([]),[g,v]=x.useState([]);return x.useEffect(()=>{if(!e)return;let b=!1;return(async()=>{r(!0);try{const[w,j,N,C,O,P]=await Promise.all([Nv({skipCount:1,maxResultCount:500}),Nu({skipCount:1,maxResultCount:500}),T8({skipCount:1,maxResultCount:500}),Y_({skipCount:1,maxResultCount:500}),sy({skipCount:1,maxResultCount:500}),KN({skipCount:1,maxResultCount:500,sorting:"OrderNum desc"})]);if(b)return;a(w.items??[]),s(j.items??[]),d(N.items??[]),f(C.items??[]),p(O.items??[]),v(P.items??[])}catch(w){b||(ee.error("Failed to load options",{description:w?.message?String(w.message):"Check network or sign-in."}),a([]),s([]),d([]),f([]),p([]),v([]))}finally{b||r(!1)}})(),()=>{b=!0}},[e]),{loading:t,templates:n,locations:i,categories:l,types:u,products:h,productCategories:g}}function S6({productCatalogCategoryId:e,onProductCatalogCategoryIdChange:t,productId:r,onProductIdChange:n,products:a,productCategories:i,disabled:s}){const l=x.useMemo(()=>i.map(h=>({value:(h.id??"").trim(),label:Ea(h.categoryName??h.categoryCode??h.id)})).filter(h=>h.value),[i]),d=x.useMemo(()=>{const h=e.trim();return h?a.filter(p=>(p.categoryId??"").trim()===h):[]},[a,e]),u=x.useMemo(()=>{const h=d.map(g=>{const v=(g.productName??g.productCode??"").trim()||g.id;return{value:g.id,label:`${v}`}}),p=r.trim();if(p&&!h.some(g=>g.value===p)){const g=a.find(b=>b.id===p),v=(g?.productName??g?.productCode??"").trim()||p;return[{value:p,label:`${v} (current)`},...h]}return h},[d,r,a]),f=x.useMemo(()=>u.map(h=>({value:h.value,label:h.label})),[u]);return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Product category *"}),o.jsx($n,{value:e,onValueChange:h=>{t(h),n("")},options:l,placeholder:"Select product category first",searchPlaceholder:"Search product category…",emptyText:"No product categories.",disabled:s})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Product *"}),o.jsx($n,{value:r,onValueChange:n,options:f,placeholder:e.trim()?"Select one product":"Select category first",searchPlaceholder:"Search products…",emptyText:e.trim()?"No products in this category.":"Select a product category.",disabled:s||!e.trim()}),r.trim()?o.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate",title:r,children:["Id: ",r]}):null]})]})}function Wge({openCreateSeq:e=0,onOpenCreateIntentConsumed:t}={}){const[r,n]=x.useState(null),[a,i]=x.useState(void 0),[s,l]=x.useState(!1),[d,u]=x.useState(!1),[f,h]=x.useState(!1),[p,g]=x.useState([]),[v,b]=x.useState(""),[w,j]=x.useState(null),[N,C]=x.useState(!1),[O,P]=x.useState(!1),[E,T]=x.useState(!1),[A,M]=x.useState(null),[R,L]=x.useState(null),[V,z]=x.useState([]),[G,H]=x.useState(!1),[W,q]=x.useState(0),[I,Y]=x.useState(0),[F,D]=x.useState(null),[$,K]=x.useState(""),[J,oe]=x.useState("all"),[re,Q]=x.useState("all"),[ue,se]=x.useState("all"),[fe,we]=x.useState("all"),[Z,je]=x.useState("all"),[Ce,qe]=x.useState(1),[De,He]=x.useState(10);x.useEffect(()=>{e<=0||(C(!0),t?.())},[e,t]);const ne=x.useRef(null),pe=x.useRef(null),[_e,ve]=x.useState("");x.useEffect(()=>(pe.current&&window.clearTimeout(pe.current),pe.current=window.setTimeout(()=>ve($.trim()),300),()=>{pe.current&&window.clearTimeout(pe.current)}),[$]);const ke=Math.max(1,Math.ceil(W/De));x.useEffect(()=>{qe(1)},[_e,J,re,ue,fe,Z,De]),x.useEffect(()=>((async()=>{ne.current?.abort();const pt=new AbortController;ne.current=pt,H(!0);try{const Ot=Qa(Ce),Qt=await sme({skipCount:Ot,maxResultCount:De,keyword:_e||void 0,locationId:J!=="all"?J:void 0,labelCategoryId:re!=="all"?re:void 0,labelTypeId:ue!=="all"?ue:void 0,templateCode:fe!=="all"?fe:void 0,state:Z==="all"?void 0:Z==="true"},pt.signal);z(Qt.items??[]),q(Qt.totalCount??0)}catch(Ot){if(Ot?.name==="AbortError")return;ee.error("Failed to load labels.",{description:Ot?.message?String(Ot.message):"Please try again."}),z([]),q(0)}finally{H(!1)}})(),()=>ne.current?.abort()),[_e,J,re,ue,fe,Z,Ce,De,I]);const Ge=()=>Y(Ae=>Ae+1),xe=Ae=>{D(null),M(Ae),P(!0)},Je=Ae=>{D(null),L(Ae),T(!0)};x.useEffect(()=>{if(!s)return;let Ae=!1;return(async()=>{u(!0);try{const pt=await Nv({skipCount:1,maxResultCount:500});if(Ae)return;const Ot=(pt.items??[]).filter(Qt=>Bi(Qt));g(Ot)}catch(pt){if(Ae)return;g([]),ee.error("Failed to load templates.",{description:pt instanceof Error?pt.message:"Please try again."})}finally{Ae||u(!1)}})(),()=>{Ae=!0}},[s]),x.useEffect(()=>{if(!s||!v){j(null);return}let Ae=!1;return(async()=>{h(!0);try{const pt=await au(v);if(Ae)return;j(b6(pt))}catch(pt){if(Ae)return;j(null),ee.error("Failed to load template preview.",{description:pt instanceof Error?pt.message:"Please try again."})}finally{Ae||h(!1)}})(),()=>{Ae=!0}},[s,v]);const dt=x.useMemo(()=>p.map(Ae=>({value:Bi(Ae),label:cy(Ae)})),[p]),jt=()=>{if(!v.trim()){ee.error("Template required",{description:"Please select a template first."});return}const Ae=p.find(Ot=>Bi(Ot)===v),pt=Ae?cy(Ae):v;i(`Bulk Add template: ${pt}`),n(v),l(!1)},Wt=Ae=>{l(Ae),Ae||(b(""),j(null))},er=()=>{n(null),i(void 0),Ge()};return r?o.jsx("div",{className:"h-[calc(100vh-8rem)] min-h-[500px] flex flex-col pt-2",children:o.jsx(Ipe,{templateCode:r,onBack:er,contextHint:a})}):o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:$,onChange:Ae=>K(Ae.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:J,onValueChange:oe,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsx(ze,{children:o.jsx(Se,{value:"all",children:"All Locations"})})]}),o.jsxs($e,{value:re,onValueChange:Q,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Category"})}),o.jsx(ze,{children:o.jsx(Se,{value:"all",children:"All Categories"})})]}),o.jsxs($e,{value:ue,onValueChange:se,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Type"})}),o.jsx(ze,{children:o.jsx(Se,{value:"all",children:"All Types"})})]}),o.jsxs($e,{value:Z,onValueChange:je,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All States"}),o.jsx(Se,{value:"true",children:"Active"}),o.jsx(Se,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsx(ce,{variant:"outline",className:"h-10 px-6 shrink-0 font-semibold border",style:{backgroundColor:"#16a34a",color:"#ffffff",borderColor:"#16a34a"},onClick:()=>l(!0),children:"Bulk Add"}),o.jsxs(ce,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>C(!0),children:["New Label ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Label Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[140px]",children:"Label Name"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Location"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[140px]",children:"Category"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[140px]",children:"Type"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Template"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Products"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Last Edited"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:G?o.jsx(nt,{children:o.jsx(ye,{colSpan:10,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):V.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:10,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):V.map(Ae=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"font-medium whitespace-nowrap",children:Fge(Ae)}),o.jsx(ye,{className:"whitespace-nowrap",children:Ea(Ae.labelName)}),o.jsx(ye,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ae.locationName??Ae.locationId)}),o.jsx(ye,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ae.labelCategoryName??Ae.labelCategoryId)}),o.jsx(ye,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ae.labelTypeName??Ae.labelTypeId)}),o.jsx(ye,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ae.templateName??Ae.templateCode)}),o.jsx(ye,{className:"text-gray-600 whitespace-nowrap",children:Bge(Ae)}),o.jsx(ye,{children:o.jsx(fn,{className:Ae.state===!0?"bg-green-600":"bg-gray-400",children:Ae.state===!0?"Active":"Inactive"})}),o.jsx(ye,{className:"text-gray-500 tabular-nums font-numeric whitespace-nowrap",children:zge(Ae)}),o.jsx(ye,{className:"text-center",children:o.jsxs(ka,{open:F===Ae.id,onOpenChange:pt=>D(pt?Ae.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-48 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>xe(Ae),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Je(Ae),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},Ae.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",W===0?0:(Ce-1)*De+1,"-",Math.min(Ce*De,W)," of ",W]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(De),onValueChange:Ae=>He(Number(Ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(Ae=>o.jsxs(Se,{value:String(Ae),children:[Ae," / page"]},Ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:Ae=>{Ae.preventDefault(),qe(pt=>Math.max(1,pt-1))},"aria-disabled":Ce<=1,className:Ce<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:Ae=>Ae.preventDefault(),children:["Page ",Ce," / ",ke]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:Ae=>{Ae.preventDefault(),qe(pt=>Math.min(ke,pt+1))},"aria-disabled":Ce>=ke,className:Ce>=ke?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(Hge,{open:N,onOpenChange:C,onCreated:()=>{qe(1),Ge()}}),o.jsx(Gge,{open:O,label:A,onOpenChange:Ae=>{P(Ae),Ae||M(null)},onUpdated:Ge}),o.jsx(Yge,{open:E,label:R,onOpenChange:Ae=>{T(Ae),Ae||L(null)},onDeleted:Ge}),o.jsx(_t,{open:s,onOpenChange:Wt,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsx(Et,{children:o.jsx(Pt,{children:"Select a Template to Bulk Add"})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 py-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Template"}),o.jsx($n,{value:v,onValueChange:b,options:dt,placeholder:d?"Loading templates…":"Select template",searchPlaceholder:"Search template…",emptyText:"No templates found.",disabled:d})]}),o.jsx("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-4 flex items-center justify-center min-h-[320px]",children:f?o.jsx("div",{className:"text-sm text-gray-500",children:"Loading preview…"}):w?o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-auto",children:o.jsx(nE,{template:w,maxWidth:360})}):o.jsx("div",{className:"text-sm text-gray-500",children:"Select a template to preview."})})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>Wt(!1),children:"Cancel"}),o.jsx(ce,{variant:"outline",className:"min-w-24 font-semibold border",style:{backgroundColor:"#16a34a",color:"#ffffff",borderColor:"#16a34a"},disabled:!v.trim()||f,onClick:jt,children:"Bulk Add"})]})]})})]})}function Hge({open:e,onOpenChange:t,onCreated:r}){const{loading:n,templates:a,locations:i,categories:s,types:l,products:d,productCategories:u}=w6(e),[f,h]=x.useState(""),[p,g]=x.useState(!1),[v,b]=x.useState(!1),[w,j]=x.useState(null),[N,C]=x.useState({}),[O,P]=x.useState({}),[E,T]=x.useState({}),[A,M]=x.useState({labelCode:"",labelName:"",templateCode:"",locationId:"",labelCategoryId:"",labelTypeId:"",productIds:[],labelInfoJson:null,state:!0}),R=()=>{M({labelCode:"",labelName:"",templateCode:"",locationId:"",labelCategoryId:"",labelTypeId:"",productIds:[],labelInfoJson:null,state:!0}),j(null),C({}),P({}),T({}),h("")};x.useEffect(()=>{e||R()},[e]),x.useEffect(()=>{if(!e)return;const D=A.templateCode.trim();if(!D){j(null),C({}),P({}),T({});return}let $=!1;return(async()=>{b(!0);try{const K=await au(D);if($)return;j(K);const J=Up(K),oe={},re={};for(const se of J)oe[se.id]="",nu(se)&&(re[se.id]={unit:"Days",value:""});C(oe),P(re);const Q=Sc(K.elements??[]),ue={};for(const se of Q)ue[se.id]=Spe(se);T(ue)}catch(K){if($)return;j(null),C({}),P({}),T({}),ee.error("Failed to load template fields.",{description:K?.message?String(K.message):"Please select another template."})}finally{$||b(!1)}})(),()=>{$=!0}},[e,A.templateCode]);const L=async()=>{if(!A.labelName.trim()||!A.templateCode.trim()||!A.locationId.trim()||!A.labelCategoryId.trim()||!A.labelTypeId.trim()){ee.error("Validation failed",{description:"Fill all required fields and select template, location, category, and type."});return}if(!f.trim()||A.productIds.length===0){ee.error("Validation failed",{description:"Select a product category and one product."});return}const D=async()=>{const $=A.templateCode.trim();if(!$||!w)return;const K=A.labelTypeId.trim();if(!K)return;const J=await au($),oe=Up(J),re=Sc(J.elements??[]).length>0;if(oe.length===0&&!re)return;const Q=qge(J,N,O,E),ue=Vge(J);for(const we of A.productIds){const Z=`${we}::${K}`;ue.set(Z,{productId:we,labelTypeId:K,defaultValues:{...Q},orderNum:ue.size+1})}const se=Array.from(ue.values()).map((we,Z)=>({...we,orderNum:Z+1})),fe=iy(J.elements??[]);await tE($,{id:J.id,name:(J.name??J.templateName??"").trim()||J.id,labelType:J.labelType??"PRICE",unit:J.unit??"inch",width:Number(J.width??2),height:Number(J.height??2),appliedLocation:tu(J),showRuler:J.showRuler??!0,showGrid:J.showGrid??!0,state:J.state??!0,elements:Q_(fe),appliedLocationIds:tu(J)==="ALL"?[]:J.appliedLocationIds??[],templateProductDefaults:se})};g(!0);try{await cme(A);try{await D()}catch($){ee.warning("Label created, template data failed.",{description:$?.message?String($.message):"Please edit template data manually."})}ee.success("Label created.",{description:"The label has been created successfully."}),t(!1),r()}catch($){ee.error("Failed to create label.",{description:$?.message?String($.message):"Please try again."})}finally{g(!1)}},V=x.useMemo(()=>a.filter(D=>Bi(D)).map(D=>({value:Bi(D),label:cy(D)})),[a]),z=x.useMemo(()=>i.map(D=>({value:D.id,label:Ea(D.locationName??D.locationCode??D.id)})),[i]),G=x.useMemo(()=>s.map(D=>({value:D.id,label:Ea(D.categoryName??D.categoryCode??D.id)})),[s]),H=x.useMemo(()=>l.map(D=>({value:D.id,label:Ea(D.typeName??D.typeCode??D.id)})),[l]),W=x.useMemo(()=>Up(w),[w]),q=x.useMemo(()=>{if(!w)return[];const D=[];for(const $ of Sc(w.elements??[]))for(const K of Eu($))D.push({el:$,spec:K});return D},[w]),I=W.length>0||q.length>0,Y=x.useMemo(()=>Uge(w,N,O,E),[w,N,O,E]),F=A.templateCode.trim().length>0;return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"flex max-h-[calc(100dvh-2rem)] flex-col overflow-hidden max-w-none gap-4 !top-5 !translate-y-0",style:{width:F?"calc(100vw - 3rem)":"min(96vw, 780px)",maxWidth:F?"calc(100vw - 3rem)":"min(96vw, 780px)"},children:[o.jsxs(Et,{className:"shrink-0",children:[o.jsx(Pt,{children:"Add New Label"}),o.jsx(It,{children:"Enter the details for the new label."})]}),o.jsx("div",{className:F?"min-h-0 flex-none overflow-hidden py-2":"min-h-0 flex-1 overflow-hidden py-2",style:F?{height:"min(72vh, calc(100dvh - 10.5rem))",maxHeight:"min(72vh, calc(100dvh - 10.5rem))"}:void 0,children:o.jsxs("div",{className:"grid h-full min-h-0 min-w-0 gap-3 items-stretch",style:F?I?{gridTemplateColumns:"minmax(0, 1fr) minmax(0, 12.5rem) minmax(0, 1.55fr)",gridTemplateRows:"minmax(0, 1fr)"}:{gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1.55fr)",gridTemplateRows:"minmax(0, 1fr)"}:{gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)"},children:[o.jsxs("div",{className:"min-h-0 min-w-0 w-full overflow-y-auto overflow-x-hidden overscroll-contain rounded-lg border bg-gray-50 p-4 [scrollbar-gutter:stable]",children:[o.jsx("div",{className:"text-sm font-semibold text-gray-900",children:"General Settings"}),o.jsx("div",{className:"space-y-2 mt-3 mb-2",children:o.jsx(S6,{productCatalogCategoryId:f,onProductCatalogCategoryIdChange:h,productId:A.productIds[0]??"",onProductIdChange:D=>M($=>({...$,productIds:D.trim()?[D.trim()]:[]})),products:d,productCategories:u,disabled:n})}),o.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Code"}),o.jsx(me,{className:"h-10",placeholder:"e.g. LBL_TEST_001",value:A.labelCode??"",onChange:D=>M($=>({...$,labelCode:D.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Name *"}),o.jsx(me,{className:"h-10",placeholder:"e.g. Breakfast label",value:A.labelName,onChange:D=>M($=>({...$,labelName:D.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Template *"}),o.jsx($n,{value:A.templateCode,onValueChange:D=>M($=>({...$,templateCode:D})),options:V,placeholder:"Select template",searchPlaceholder:"Search template…",emptyText:"No templates found.",disabled:n})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Location *"}),o.jsx($n,{value:A.locationId,onValueChange:D=>M($=>({...$,locationId:D})),options:z,placeholder:"Select location",searchPlaceholder:"Search location…",emptyText:"No locations found.",disabled:n})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Category *"}),o.jsx($n,{value:A.labelCategoryId,onValueChange:D=>M($=>({...$,labelCategoryId:D})),options:G,placeholder:"Select category",searchPlaceholder:"Search category…",emptyText:"No categories found.",disabled:n})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Type *"}),o.jsx($n,{value:A.labelTypeId,onValueChange:D=>M($=>({...$,labelTypeId:D})),options:H,placeholder:"Select type",searchPlaceholder:"Search type…",emptyText:"No types found.",disabled:n})]})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white mt-4",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:A.state,onCheckedChange:D=>M($=>({...$,state:D}))})]})]}),F&&I?o.jsxs("div",{className:"box-border min-h-0 min-w-0 w-full max-w-full overflow-y-auto overflow-x-hidden overscroll-contain rounded-lg border bg-gray-50 p-4 [scrollbar-gutter:stable]",children:[o.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Template Input Data"}),v?o.jsx("div",{className:"text-sm text-gray-500",children:"Loading template fields..."}):A.templateCode.trim()?o.jsxs("div",{className:"space-y-3",children:[W.map(D=>o.jsxs("div",{className:"space-y-1.5 w-full min-w-0",children:[o.jsx(de,{className:"block",children:YN(D)}),nu(D)?o.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full min-w-0",children:[o.jsxs($e,{value:O[D.id]?.unit??"Days",onValueChange:$=>P(K=>({...K,[D.id]:{unit:$,value:K[D.id]?.value??""}})),children:[o.jsx(Be,{className:"h-10 min-w-0 flex-1 bg-white text-sm",children:o.jsx(Fe,{})}),o.jsx(ze,{children:rE.map($=>o.jsx(Se,{value:$,className:"text-xs",children:$},$))})]}),o.jsx(me,{type:"number",className:"h-10 w-20 shrink-0 bg-white",value:O[D.id]?.value??"",onChange:$=>P(K=>({...K,[D.id]:{unit:K[D.id]?.unit??"Days",value:$.target.value}})),placeholder:"Value"})]}):o.jsx(me,{className:"h-10 w-full min-w-0 box-border",value:N[D.id]??"",onChange:$=>C(K=>({...K,[D.id]:$.target.value})),placeholder:`Enter ${YN(D)}`})]},D.id)),q.length>0?o.jsxs("div",{className:"pt-2 mt-2 border-t border-gray-200 space-y-3",children:[o.jsx("div",{className:"text-xs font-semibold text-gray-700",children:"Nutrition Facts (manual)"}),q.map(({el:D,spec:$})=>o.jsxs("div",{className:"space-y-1.5 w-full min-w-0",children:[o.jsx(de,{className:"block",children:$.columnLabel}),o.jsx(me,{className:"h-10 w-full min-w-0 box-border",value:E[D.id]?.[$.subKey]??"",onChange:K=>T(J=>({...J,[D.id]:{...J[D.id]??{},[$.subKey]:K.target.value}})),placeholder:`Enter ${$.columnLabel}`})]},`${D.id}-${$.subKey}`))]}):null,o.jsx("div",{className:"text-xs text-gray-500 pt-1 w-full min-w-0 break-words",children:`Date/time fields: preview uses the current time as base; leave empty or enter 0 for "now"; other numbers add that offset. Format follows each field's template setting. On save, values are written for the selected product. Nutrition columns follow the template's nutrient list; values are saved with the template defaults JSON for printing.`})]}):o.jsx("div",{className:"text-sm text-gray-500",children:"Select template first to load input fields."})]}):null,F?o.jsxs("div",{className:"min-h-0 min-w-0 w-full overflow-y-auto overflow-x-hidden overscroll-contain rounded-lg border bg-gray-50 p-4 [scrollbar-gutter:stable]",children:[o.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Label Preview"}),Y?o.jsx("div",{className:"flex justify-center w-full min-w-0 overflow-hidden",children:o.jsx(nE,{template:Y,maxWidth:480})}):o.jsx("div",{className:"text-sm text-gray-500",children:"Select template to preview."})]}):null]})}),o.jsxs(Dt,{className:"shrink-0",children:[o.jsx(ce,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(ce,{disabled:p||n,onClick:L,children:p?"Creating…":"Create"})]})]})})}function Gge({open:e,label:t,onOpenChange:r,onUpdated:n}){const{loading:a,templates:i,locations:s,categories:l,types:d,products:u,productCategories:f}=w6(e),[h,p]=x.useState(""),[g,v]=x.useState(!1),[b,w]=x.useState(!1),[j,N]=x.useState({labelName:"",templateCode:"",locationId:"",labelCategoryId:"",labelTypeId:"",productIds:[],labelInfoJson:null,state:!0});x.useEffect(()=>{if(!e||!t?.id)return;const A=t.id;N(WL(t));const M=new AbortController;let R=!1;return w(!0),(async()=>{try{const L=await lme(A,M.signal);if(R)return;N(WL(L))}catch(L){if(R||L?.name==="AbortError")return;ee.error("Failed to load label details.",{description:L?.message?String(L.message):"Form shows list data only; check network."})}finally{R||w(!1)}})(),()=>{R=!0,M.abort()}},[e,t]),x.useEffect(()=>{if(!e){p("");return}const A=(j.productIds[0]??"").trim();if(!A){p("");return}const M=u.find(L=>L.id===A);if(M?.categoryId){p(String(M.categoryId).trim());return}let R=!1;return(async()=>{try{const L=await q8(A);if(R)return;p((L.categoryId??"").trim())}catch{R||p("")}})(),()=>{R=!0}},[e,j.productIds,u]);const C=async()=>{if(t?.id){if(!j.labelName.trim()||!j.templateCode.trim()||!j.locationId.trim()||!j.labelCategoryId.trim()||!j.labelTypeId.trim()){ee.error("Validation failed",{description:"Fill all required fields and select template, location, category, and type."});return}if(!h.trim()||j.productIds.length===0){ee.error("Validation failed",{description:"Select a product category and one product."});return}v(!0);try{await ume(t.id,j),ee.success("Label updated.",{description:"The label has been updated successfully."}),r(!1),n()}catch(A){ee.error("Failed to update label.",{description:A?.message?String(A.message):"Please try again."})}finally{v(!1)}}},O=x.useMemo(()=>{const A=i.filter(R=>Bi(R)).map(R=>({value:Bi(R),label:cy(R)})),M=j.templateCode;return M&&!A.some(R=>R.value===M)?[{value:M,label:`${M} (current)`},...A]:A},[i,j.templateCode]),P=x.useMemo(()=>{const A=s.map(R=>({value:R.id,label:Ea(R.locationName??R.locationCode??R.id)})),M=j.locationId;return M&&!A.some(R=>R.value===M)?[{value:M,label:`${M} (current)`},...A]:A},[s,j.locationId]),E=x.useMemo(()=>{const A=l.map(R=>({value:R.id,label:Ea(R.categoryName??R.categoryCode??R.id)})),M=j.labelCategoryId;return M&&!A.some(R=>R.value===M)?[{value:M,label:`${M} (current)`},...A]:A},[l,j.labelCategoryId]),T=x.useMemo(()=>{const A=d.map(R=>({value:R.id,label:Ea(R.typeName??R.typeCode??R.id)})),M=j.labelTypeId;return M&&!A.some(R=>R.value===M)?[{value:M,label:`${M} (current)`},...A]:A},[d,j.labelTypeId]);return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Edit Label"}),o.jsx(It,{children:b?"Loading label details…":"Update the label details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Name *"}),o.jsx(me,{className:"h-10",placeholder:"e.g. Breakfast label",value:j.labelName,onChange:A=>N(M=>({...M,labelName:A.target.value})),disabled:b})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Template *"}),o.jsx($n,{value:j.templateCode,onValueChange:A=>N(M=>({...M,templateCode:A})),options:O,placeholder:"Select template",searchPlaceholder:"Search template…",emptyText:"No templates found.",disabled:a||b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Location *"}),o.jsx($n,{value:j.locationId,onValueChange:A=>N(M=>({...M,locationId:A})),options:P,placeholder:"Select location",searchPlaceholder:"Search location…",emptyText:"No locations found.",disabled:a||b})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Category *"}),o.jsx($n,{value:j.labelCategoryId,onValueChange:A=>N(M=>({...M,labelCategoryId:A})),options:E,placeholder:"Select category",searchPlaceholder:"Search category…",emptyText:"No categories found.",disabled:a||b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Label Type *"}),o.jsx($n,{value:j.labelTypeId,onValueChange:A=>N(M=>({...M,labelTypeId:A})),options:T,placeholder:"Select type",searchPlaceholder:"Search type…",emptyText:"No types found.",disabled:a||b})]})]}),o.jsx("div",{className:"space-y-2",children:o.jsx(S6,{productCatalogCategoryId:h,onProductCatalogCategoryIdChange:p,productId:j.productIds[0]??"",onProductIdChange:A=>N(M=>({...M,productIds:A.trim()?[A.trim()]:[]})),products:u,productCategories:f,disabled:a||b})}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:j.state,onCheckedChange:A=>N(M=>({...M,state:A})),disabled:b})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:g||a||b,onClick:C,children:g?"Updating…":"Update"})]})]})})}function Yge({open:e,label:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>(t?.labelName??"").trim()||t?.labelCode||t?.id||"this label",[t]),l=async()=>{if(t?.id){i(!0);try{await dme(t.id),ee.success("Label deleted.",{description:"The label has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Label"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}var XS="rovingFocusGroup.onEntryFocus",Kge={bubbles:!1,cancelable:!0},sh="RovingFocusGroup",[QN,j6,Xge]=EF(sh),[Jge,N6]=Eo(sh,[Xge]),[Qge,Zge]=Jge(sh),C6=x.forwardRef((e,t)=>o.jsx(QN.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(QN.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(eye,{...e,ref:t})})}));C6.displayName=sh;var eye=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:u,preventScrollOnEntryFocus:f=!1,...h}=e,p=x.useRef(null),g=At(t,p),v=py(i),[b,w]=No({prop:s,defaultProp:l??null,onChange:d,caller:sh}),[j,N]=x.useState(!1),C=dn(u),O=j6(r),P=x.useRef(!1),[E,T]=x.useState(0);return x.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(XS,C),()=>A.removeEventListener(XS,C)},[C]),o.jsx(Qge,{scope:r,orientation:n,dir:v,loop:a,currentTabStopId:b,onItemFocus:x.useCallback(A=>w(A),[w]),onItemShiftTab:x.useCallback(()=>N(!0),[]),onFocusableItemAdd:x.useCallback(()=>T(A=>A+1),[]),onFocusableItemRemove:x.useCallback(()=>T(A=>A-1),[]),children:o.jsx(lt.div,{tabIndex:j||E===0?-1:0,"data-orientation":n,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:mt(e.onMouseDown,()=>{P.current=!0}),onFocus:mt(e.onFocus,A=>{const M=!P.current;if(A.target===A.currentTarget&&M&&!j){const R=new CustomEvent(XS,Kge);if(A.currentTarget.dispatchEvent(R),!R.defaultPrevented){const L=O().filter(W=>W.focusable),V=L.find(W=>W.active),z=L.find(W=>W.id===b),H=[V,z,...L].filter(Boolean).map(W=>W.ref.current);P6(H,f)}}P.current=!1}),onBlur:mt(e.onBlur,()=>N(!1))})})}),_6="RovingFocusGroupItem",E6=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:i,children:s,...l}=e,d=Bn(),u=i||d,f=Zge(_6,r),h=f.currentTabStopId===u,p=j6(r),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:b}=f;return x.useEffect(()=>{if(n)return g(),()=>v()},[n,g,v]),o.jsx(QN.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:o.jsx(lt.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:mt(e.onMouseDown,w=>{n?f.onItemFocus(u):w.preventDefault()}),onFocus:mt(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:mt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const j=nye(w,f.orientation,f.dir);if(j!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=p().filter(O=>O.focusable).map(O=>O.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const O=C.indexOf(w.currentTarget);C=f.loop?aye(C,O+1):C.slice(O+1)}setTimeout(()=>P6(C))}}),children:typeof s=="function"?s({isCurrentTabStop:h,hasTabStop:b!=null}):s})})});E6.displayName=_6;var tye={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rye(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function nye(e,t,r){const n=rye(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return tye[n]}function P6(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function aye(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var oye=C6,iye=E6,O6="Toggle",T6=x.forwardRef((e,t)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...i}=e,[s,l]=No({prop:r,onChange:a,defaultProp:n??!1,caller:O6});return o.jsx(lt.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:mt(e.onClick,()=>{e.disabled||l(!s)})})});T6.displayName=O6;var Zi="ToggleGroup",[k6]=Eo(Zi,[N6]),A6=N6(),aE=U.forwardRef((e,t)=>{const{type:r,...n}=e;if(r==="single"){const a=n;return o.jsx(sye,{...a,ref:t})}if(r==="multiple"){const a=n;return o.jsx(lye,{...a,ref:t})}throw new Error(`Missing prop \`type\` expected on \`${Zi}\``)});aE.displayName=Zi;var[I6,M6]=k6(Zi),sye=U.forwardRef((e,t)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...i}=e,[s,l]=No({prop:r,defaultProp:n??"",onChange:a,caller:Zi});return o.jsx(I6,{scope:e.__scopeToggleGroup,type:"single",value:U.useMemo(()=>s?[s]:[],[s]),onItemActivate:l,onItemDeactivate:U.useCallback(()=>l(""),[l]),children:o.jsx(R6,{...i,ref:t})})}),lye=U.forwardRef((e,t)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...i}=e,[s,l]=No({prop:r,defaultProp:n??[],onChange:a,caller:Zi}),d=U.useCallback(f=>l((h=[])=>[...h,f]),[l]),u=U.useCallback(f=>l((h=[])=>h.filter(p=>p!==f)),[l]);return o.jsx(I6,{scope:e.__scopeToggleGroup,type:"multiple",value:s,onItemActivate:d,onItemDeactivate:u,children:o.jsx(R6,{...i,ref:t})})});aE.displayName=Zi;var[cye,uye]=k6(Zi),R6=U.forwardRef((e,t)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:i,dir:s,loop:l=!0,...d}=e,u=A6(r),f=py(s),h={role:"group",dir:f,...d};return o.jsx(cye,{scope:r,rovingFocus:a,disabled:n,children:a?o.jsx(oye,{asChild:!0,...u,orientation:i,dir:f,loop:l,children:o.jsx(lt.div,{...h,ref:t})}):o.jsx(lt.div,{...h,ref:t})})}),uy="ToggleGroupItem",D6=U.forwardRef((e,t)=>{const r=M6(uy,e.__scopeToggleGroup),n=uye(uy,e.__scopeToggleGroup),a=A6(e.__scopeToggleGroup),i=r.value.includes(e.value),s=n.disabled||e.disabled,l={...e,pressed:i,disabled:s},d=U.useRef(null);return n.rovingFocus?o.jsx(iye,{asChild:!0,...a,focusable:!s,active:i,ref:d,children:o.jsx(HL,{...l,ref:t})}):o.jsx(HL,{...l,ref:t})});D6.displayName=uy;var HL=U.forwardRef((e,t)=>{const{__scopeToggleGroup:r,value:n,...a}=e,i=M6(uy,r),s={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},l=i.type==="single"?s:void 0;return o.jsx(T6,{...l,...a,ref:t,onPressedChange:d=>{d?i.onItemActivate(n):i.onItemDeactivate(n)}})}),dye=aE,fye=D6;const hye=pC("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),L6=x.createContext({size:"default",variant:"default"});function iu({className:e,variant:t,size:r,children:n,...a}){return o.jsx(dye,{"data-slot":"toggle-group","data-variant":t,"data-size":r,className:Ie("group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs",e),...a,children:o.jsx(L6.Provider,{value:{variant:t,size:r},children:n})})}function ti({className:e,children:t,variant:r,size:n,...a}){const i=x.useContext(L6);return o.jsx(fye,{"data-slot":"toggle-group-item","data-variant":i.variant||r,"data-size":i.size||n,className:Ie(hye({variant:i.variant||r,size:i.size||n}),"min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",e),...a,children:t})}function GL(e){const t=(e??"").trim();return t||"None"}const $6=["#111827","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899"];function mye(e){const t=O8({buttonStyleJson:e.buttonStyleJson??e.ButtonStyleJson,buttonAppearance:e.buttonAppearance??e.ButtonAppearance,displayText:e.displayText,buttonBgColor:e.buttonBgColor,buttonImageUrl:e.buttonImageUrl,categoryPhotoUrl:e.categoryPhotoUrl,categoryName:e.categoryName}),r="w-10 h-10 rounded border border-gray-200 shadow-sm overflow-hidden";if(t.mode==="image"){const n=t.imageUrl?Tf(t.imageUrl):"";return n?o.jsx("img",{src:n,alt:"",className:[r,"object-cover"].join(" ")}):o.jsx("span",{className:"text-gray-400 text-sm",children:"—"})}return t.mode==="colorText"?o.jsx("div",{className:[r,"flex items-center justify-center px-1"].join(" "),style:{backgroundColor:t.bg,color:t.textColor||"#ffffff"},title:t.text,children:o.jsx("span",{className:"text-[11px] font-semibold truncate w-full text-center leading-tight line-clamp-2 break-all",children:t.text})}):t.mode==="color"?o.jsx("div",{className:r,style:{backgroundColor:t.bg},title:t.bg}):t.mode==="text"?o.jsx("div",{className:[r,"bg-gray-50 flex items-center justify-center px-1"].join(" "),title:t.text,children:o.jsx("span",{className:"text-[11px] font-semibold text-gray-800 truncate w-full text-center leading-tight line-clamp-2 break-all",children:t.text})}):o.jsx("span",{className:"text-gray-400 text-sm",children:"—"})}function pye(){const[e,t]=x.useState(!1),[r,n]=x.useState(!1),[a,i]=x.useState(!1),[s,l]=x.useState(null),[d,u]=x.useState(null),[f,h]=x.useState([]),[p,g]=x.useState(!1),[v,b]=x.useState(0),[w,j]=x.useState(0),[N,C]=x.useState(null),[O,P]=x.useState(""),[E,T]=x.useState("all"),[A,M]=x.useState(1),[R,L]=x.useState(10),V=x.useRef(null),z=x.useRef(null),[G,H]=x.useState("");x.useEffect(()=>(z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>H(O.trim()),300),()=>{z.current&&window.clearTimeout(z.current)}),[O]);const W=Math.max(1,Math.ceil(v/R));x.useEffect(()=>{M(1)},[G,E,R]),x.useEffect(()=>((async()=>{V.current?.abort();const D=new AbortController;V.current=D,g(!0);try{const $=Qa(A),K=await T8({skipCount:$,maxResultCount:R,keyword:G||void 0,state:E==="all"?void 0:E==="true"},D.signal);h(K.items??[]),b(K.totalCount??0)}catch($){if($?.name==="AbortError")return;ee.error("Failed to load label categories.",{description:$?.message?String($.message):"Please try again."}),h([]),b(0)}finally{g(!1)}})(),()=>V.current?.abort()),[G,E,A,R,w]);const q=()=>j(F=>F+1),I=F=>{C(null),l(F),n(!0)},Y=F=>{C(null),u(F),i(!0)};return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:O,onChange:F=>P(F.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:E,onValueChange:T,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All States"}),o.jsx(Se,{value:"true",children:"Active"}),o.jsx(Se,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ce,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>t(!0),children:["New Label Category ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[250px]",children:"Label Category"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Category Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Category Photo"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Order"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Last Edited"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:p?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):f.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):f.map(F=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"font-medium",children:GL(F.categoryName)}),o.jsx(ye,{className:"text-gray-600",children:GL(F.categoryCode)}),o.jsx(ye,{children:mye(F)}),o.jsx(ye,{children:o.jsx(fn,{className:F.state?"bg-green-600":"bg-gray-400",children:F.state?"Active":"Inactive"})}),o.jsx(ye,{className:"font-numeric",children:F.orderNum??"None"}),o.jsx(ye,{className:"text-gray-500 tabular-nums font-numeric",children:F.creationTime?new Date(F.creationTime).toLocaleString():"None"}),o.jsx(ye,{className:"text-center",children:o.jsxs(ka,{open:N===F.id,onOpenChange:D=>C(D?F.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>I(F),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Y(F),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},F.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",v===0?0:(A-1)*R+1,"-",Math.min(A*R,v)," of ",v]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(R),onValueChange:F=>L(Number(F)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(F=>o.jsxs(Se,{value:String(F),children:[F," / page"]},F))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:F=>{F.preventDefault(),M(D=>Math.max(1,D-1))},"aria-disabled":A<=1,className:A<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:F=>F.preventDefault(),children:["Page ",A," / ",W]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:F=>{F.preventDefault(),M(D=>Math.min(W,D+1))},"aria-disabled":A>=W,className:A>=W?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(gye,{open:e,onOpenChange:t,onCreated:()=>{M(1),q()}}),o.jsx(yye,{open:r,category:s,onOpenChange:F=>{n(F),F||l(null)},onUpdated:q}),o.jsx(vye,{open:a,category:d,onOpenChange:F=>{i(F),F||u(null)},onDeleted:q})]})}function gye({open:e,onOpenChange:t,onCreated:r}){const[n,a]=x.useState(!1),[i,s]=x.useState({text:!0,color:!1,image:!1}),[l,d]=x.useState(""),[u,f]=x.useState("#3B82F6"),[h,p]=x.useState({categoryCode:"",categoryName:"",categoryPhotoUrl:null,state:!0,orderNum:null}),g=x.useMemo(()=>{const w=[];return i.text&&w.push("TEXT"),i.color&&w.push("COLOR"),w},[i.text,i.color]),v=()=>{s({text:!0,color:!1,image:!1}),d(""),f("#3B82F6"),p({categoryCode:"",categoryName:"",categoryPhotoUrl:null,state:!0,orderNum:null})};x.useEffect(()=>{e||v()},[e]);const b=async()=>{if(!h.categoryName.trim()){ee.error("Validation failed",{description:"Category Name is required."});return}if(h.orderNum===null||h.orderNum===void 0||!Number.isFinite(h.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}const w=U_(i);if(w.length===0){ee.error("Validation failed",{description:"Select at least one button appearance (Text, Color, or Image)."});return}if(w[0]==="IMAGE"){if(!String(h.categoryPhotoUrl??"").trim()){ee.error("Validation failed",{description:"Please upload or select an image for Image appearance."});return}}else{if(i.text&&!l.trim()){ee.error("Validation failed",{description:"Please enter display text for Text appearance."});return}if(i.color&&!u.trim()){ee.error("Validation failed",{description:"Please select a background color for Color appearance."});return}}const j=H_(w,{displayText:l.trim(),buttonBgColor:u.trim(),buttonImageUrl:i.image?String(h.categoryPhotoUrl??"").trim():""}),N=q_({appearances:w,displayText:i.image?null:l.trim()||null,buttonBgColor:i.image?null:u.trim()||null,buttonTextColor:null,buttonImageUrl:i.image&&String(h.categoryPhotoUrl??"").trim()||null});a(!0);try{await Nme({...h,categoryPhotoUrl:j,displayText:l.trim()||null,buttonBgColor:u.trim()||null,buttonImageUrl:i.image&&String(h.categoryPhotoUrl??"").trim()||null,buttonAppearance:w,buttonStyleJson:N}),ee.success("Label category created.",{description:"The label category has been created successfully."}),t(!1),r()}catch(C){ee.error("Failed to create label category.",{description:C?.message?String(C.message):"Please try again."})}finally{a(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Add New Label Category"}),o.jsx(It,{children:"Enter the details for the new label category."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category Code"}),o.jsx(me,{placeholder:"e.g. CAT_PREP",value:h.categoryCode,onChange:w=>p(j=>({...j,categoryCode:w.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category Name *"}),o.jsx(me,{placeholder:"e.g. Prep",value:h.categoryName,onChange:w=>p(j=>({...j,categoryName:w.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Button Appearance"}),o.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-100 p-3 space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Text & Color — can combine"}),o.jsxs(iu,{type:"multiple",value:g,onValueChange:w=>{const j=w??[];s(N=>({...N,text:j.includes("TEXT"),color:j.includes("COLOR"),image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent gap-1 flex-wrap justify-stretch",children:[o.jsx(ti,{value:"TEXT",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",i.text&&!i.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(Df,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Text"]})}),o.jsx(ti,{value:"COLOR",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",i.color&&!i.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(C$,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Color"]})})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Image — exclusive"}),o.jsx(iu,{type:"single",value:i.image?"IMAGE":"",onValueChange:w=>{const j=String(w||"").toUpperCase();s(j==="IMAGE"?{text:!1,color:!1,image:!0}:N=>({...N,image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent",children:o.jsx(ti,{value:"IMAGE",className:["w-full gap-2 h-10 rounded-full","border border-transparent",i.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(lC,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Image"]})})})]})]})]}),i.text&&!i.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Display Text"}),o.jsx(me,{placeholder:"Category Name",value:l,onChange:w=>d(w.target.value)}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"DisplayText"})," when supported."]})]}):null,i.color&&!i.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Select Color"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[$6.map(w=>o.jsx("button",{type:"button",className:["h-10 w-10 rounded-full border border-gray-200 shadow-sm",u.toLowerCase()===w.toLowerCase()?"ring-2 ring-blue-500 ring-offset-2":""].join(" "),style:{backgroundColor:w},onClick:()=>f(w),"aria-label":`Select ${w}`},w)),o.jsx("button",{type:"button",className:"h-10 w-10 rounded-full border border-dashed border-gray-300 bg-white text-gray-500 hover:text-gray-700 hover:border-gray-400 flex items-center justify-center",onClick:()=>{document.getElementById("label-category-custom-color-create")?.click()},"aria-label":"Custom color",children:"+"}),o.jsx("input",{id:"label-category-custom-color-create",type:"color",value:u||"#3B82F6",onChange:w=>f(w.target.value),className:"h-0 w-0 opacity-0 pointer-events-none","aria-label":"Custom color picker"})]}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"ButtonBgColor"})," when supported."]})]}):null,i.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category photo"}),o.jsx(_u,{value:h.categoryPhotoUrl??"",onChange:w=>p(j=>({...j,categoryPhotoUrl:w||null})),uploadSubDir:"category",oneImageOnly:!0,hint:"One image only. Replace or clear to change. JPG, PNG, WebP, or GIF — max 5 MB. Saved as CategoryPhotoUrl."})]}):null,o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:h.orderNum??"",onChange:w=>p(j=>({...j,orderNum:w.target.value?Number(w.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:h.state,onCheckedChange:w=>p(j=>({...j,state:w}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(ce,{disabled:n,onClick:b,children:n?"Creating...":"Create"})]})]})})}function yye({open:e,category:t,onOpenChange:r,onUpdated:n}){const[a,i]=x.useState(!1),[s,l]=x.useState({text:!0,color:!1,image:!1}),[d,u]=x.useState(""),[f,h]=x.useState("#3B82F6"),[p,g]=x.useState({categoryCode:"",categoryName:"",categoryPhotoUrl:null,state:!0,orderNum:null}),v=x.useMemo(()=>{const w=[];return s.text&&w.push("TEXT"),s.color&&w.push("COLOR"),w},[s.text,s.color]);x.useEffect(()=>{if(e&&t){const w=oy(t.buttonStyleJson??t.ButtonStyleJson);if(w){const M=bc(w.appearances);l(M),u(w.displayText??""),h(w.buttonBgColor||"#3B82F6"),g({categoryCode:t.categoryCode??"",categoryName:t.categoryName??"",categoryPhotoUrl:M.image?t.categoryPhotoUrl??null:null,state:t.state??!0,orderNum:t.orderNum??null});return}const j=t.buttonAppearance??t.ButtonAppearance??void 0,N=tl(j),C=V_(t.categoryPhotoUrl);if(C&&N.length>0&&N.length===C.length){const M=W_(N,C,{categoryName:t.categoryName,name:void 0,buttonTextColor:t.buttonTextColor??null}),R=bc(N);l(R),u(M.displayText??""),h(M.buttonBgColor?.trim()?M.buttonBgColor:"#3B82F6"),g({categoryCode:t.categoryCode??"",categoryName:t.categoryName??"",categoryPhotoUrl:R.image&&(M.buttonImageUrl??"").trim()||null,state:t.state??!0,orderNum:t.orderNum??null});return}let O=bc(N);if(N.length===0){const M=G_({buttonAppearance:j,displayText:t.displayText,buttonBgColor:t.buttonBgColor,buttonImageUrl:t.buttonImageUrl,categoryPhotoUrl:t.categoryPhotoUrl,categoryName:t.categoryName});M.mode==="image"?O={text:!1,color:!1,image:!0}:M.mode==="colorText"?O={text:!0,color:!0,image:!1}:M.mode==="color"?O={text:!1,color:!0,image:!1}:M.mode==="text"?O={text:!0,color:!1,image:!1}:O={text:!0,color:!1,image:!1}}l(O);const P=String(t.categoryPhotoUrl??"").trim(),E=String(t.displayText??"").trim(),T=Ls(t.buttonBgColor),A=Ls(P);u(E||(!O.image&&O.text&&P&&!A&&!Bp(P)?P:"")||(!O.image&&O.text&&!O.color?(t.categoryName??"").trim():"")),h(T||(O.color&&A?A:"")||"#3B82F6"),g({categoryCode:t.categoryCode??"",categoryName:t.categoryName??"",categoryPhotoUrl:O.image?t.categoryPhotoUrl??null:null,state:t.state??!0,orderNum:t.orderNum??null})}},[e,t]);const b=async()=>{if(!t?.id)return;if(!p.categoryName.trim()){ee.error("Validation failed",{description:"Category Name is required."});return}if(p.orderNum===null||p.orderNum===void 0||!Number.isFinite(p.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}const w=U_(s);if(w.length===0){ee.error("Validation failed",{description:"Select at least one button appearance (Text, Color, or Image)."});return}if(w[0]==="IMAGE"){if(!String(p.categoryPhotoUrl??"").trim()){ee.error("Validation failed",{description:"Please upload or select an image for Image appearance."});return}}else{if(s.text&&!d.trim()){ee.error("Validation failed",{description:"Please enter display text for Text appearance."});return}if(s.color&&!f.trim()){ee.error("Validation failed",{description:"Please select a background color for Color appearance."});return}}const j=H_(w,{displayText:d.trim(),buttonBgColor:f.trim(),buttonImageUrl:s.image?String(p.categoryPhotoUrl??"").trim():""}),N=q_({appearances:w,displayText:s.image?null:d.trim()||null,buttonBgColor:s.image?null:f.trim()||null,buttonTextColor:null,buttonImageUrl:s.image&&String(p.categoryPhotoUrl??"").trim()||null});i(!0);try{await Cme(t.id,{...p,categoryPhotoUrl:j,displayText:d.trim()||null,buttonBgColor:f.trim()||null,buttonImageUrl:s.image&&String(p.categoryPhotoUrl??"").trim()||null,buttonAppearance:w,buttonStyleJson:N}),ee.success("Label category updated.",{description:"The label category has been updated successfully."}),r(!1),n()}catch(C){ee.error("Failed to update label category.",{description:C?.message?String(C.message):"Please try again."})}finally{i(!1)}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Edit Label Category"}),o.jsx(It,{children:"Update the label category details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category Code"}),o.jsx(me,{placeholder:"e.g. CAT_PREP",value:p.categoryCode,onChange:w=>g(j=>({...j,categoryCode:w.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category Name *"}),o.jsx(me,{placeholder:"e.g. Prep",value:p.categoryName,onChange:w=>g(j=>({...j,categoryName:w.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Button Appearance"}),o.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-100 p-3 space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Text & Color — can combine"}),o.jsxs(iu,{type:"multiple",value:v,onValueChange:w=>{const j=w??[];l(N=>({...N,text:j.includes("TEXT"),color:j.includes("COLOR"),image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent gap-1 flex-wrap justify-stretch",children:[o.jsx(ti,{value:"TEXT",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",s.text&&!s.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(Df,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Text"]})}),o.jsx(ti,{value:"COLOR",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",s.color&&!s.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(C$,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Color"]})})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Image — exclusive"}),o.jsx(iu,{type:"single",value:s.image?"IMAGE":"",onValueChange:w=>{const j=String(w||"").toUpperCase();l(j==="IMAGE"?{text:!1,color:!1,image:!0}:N=>({...N,image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent",children:o.jsx(ti,{value:"IMAGE",className:["w-full gap-2 h-10 rounded-full","border border-transparent",s.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(lC,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Image"]})})})]})]})]}),s.text&&!s.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Display Text"}),o.jsx(me,{placeholder:"Category Name",value:d,onChange:w=>u(w.target.value)}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"DisplayText"})," when supported."]})]}):null,s.color&&!s.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Select Color"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[$6.map(w=>o.jsx("button",{type:"button",className:["h-10 w-10 rounded-full border border-gray-200 shadow-sm",f.toLowerCase()===w.toLowerCase()?"ring-2 ring-blue-500 ring-offset-2":""].join(" "),style:{backgroundColor:w},onClick:()=>h(w),"aria-label":`Select ${w}`},w)),o.jsx("button",{type:"button",className:"h-10 w-10 rounded-full border border-dashed border-gray-300 bg-white text-gray-500 hover:text-gray-700 hover:border-gray-400 flex items-center justify-center",onClick:()=>{document.getElementById("label-category-custom-color-edit")?.click()},"aria-label":"Custom color",children:"+"}),o.jsx("input",{id:"label-category-custom-color-edit",type:"color",value:f||"#3B82F6",onChange:w=>h(w.target.value),className:"h-0 w-0 opacity-0 pointer-events-none","aria-label":"Custom color picker"})]}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"ButtonBgColor"})," when supported."]})]}):null,s.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category photo"}),o.jsx(_u,{value:p.categoryPhotoUrl??"",onChange:w=>g(j=>({...j,categoryPhotoUrl:w||null})),uploadSubDir:"category",oneImageOnly:!0,hint:"One image only. Replace or clear to change. JPG, PNG, WebP, or GIF — max 5 MB. Saved as CategoryPhotoUrl."})]}):null,o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:p.orderNum??"",onChange:w=>g(j=>({...j,orderNum:w.target.value?Number(w.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:p.state,onCheckedChange:w=>g(j=>({...j,state:w}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:a,onClick:b,children:a?"Updating...":"Update"})]})]})})}function vye({open:e,category:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>(t?.categoryName??"").trim()||t?.categoryCode||"this category",[t]),l=async()=>{if(t?.id){i(!0);try{await _me(t.id),ee.success("Label category deleted.",{description:"The label category has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label category.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Label Category"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function YL(e){const t=(e??"").trim();return t||"None"}function xye(){const[e,t]=x.useState(!1),[r,n]=x.useState(!1),[a,i]=x.useState(!1),[s,l]=x.useState(null),[d,u]=x.useState(null),[f,h]=x.useState([]),[p,g]=x.useState(!1),[v,b]=x.useState(0),[w,j]=x.useState(0),[N,C]=x.useState(null),[O,P]=x.useState(""),[E,T]=x.useState("all"),[A,M]=x.useState(1),[R,L]=x.useState(10),V=x.useRef(null),z=x.useRef(null),[G,H]=x.useState("");x.useEffect(()=>(z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>H(O.trim()),300),()=>{z.current&&window.clearTimeout(z.current)}),[O]);const W=Math.max(1,Math.ceil(v/R));x.useEffect(()=>{M(1)},[G,E,R]),x.useEffect(()=>((async()=>{V.current?.abort();const D=new AbortController;V.current=D,g(!0);try{const $=Qa(A),K=await Y_({skipCount:$,maxResultCount:R,keyword:G||void 0,state:E==="all"?void 0:E==="true"},D.signal);h(K.items??[]),b(K.totalCount??0)}catch($){if($?.name==="AbortError")return;ee.error("Failed to load label types.",{description:$?.message?String($.message):"Please try again."}),h([]),b(0)}finally{g(!1)}})(),()=>V.current?.abort()),[G,E,A,R,w]);const q=()=>j(F=>F+1),I=F=>{C(null),l(F),n(!0)},Y=F=>{C(null),u(F),i(!0)};return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:O,onChange:F=>P(F.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:E,onValueChange:T,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All States"}),o.jsx(Se,{value:"true",children:"Active"}),o.jsx(Se,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ce,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>t(!0),children:["New Label Type ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[250px]",children:"Label Types"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Type Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Order"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Last Edited"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:p?o.jsx(nt,{children:o.jsx(ye,{colSpan:6,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):f.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:6,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):f.map(F=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"font-medium",children:YL(F.typeName)}),o.jsx(ye,{className:"text-gray-600",children:YL(F.typeCode)}),o.jsx(ye,{children:o.jsx(fn,{className:F.state?"bg-green-600":"bg-gray-400",children:F.state?"Active":"Inactive"})}),o.jsx(ye,{className:"font-numeric",children:F.orderNum??"None"}),o.jsx(ye,{className:"text-gray-500 tabular-nums font-numeric",children:F.creationTime?new Date(F.creationTime).toLocaleString():"None"}),o.jsx(ye,{className:"text-center",children:o.jsxs(ka,{open:N===F.id,onOpenChange:D=>C(D?F.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>I(F),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Y(F),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},F.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",v===0?0:(A-1)*R+1,"-",Math.min(A*R,v)," of ",v]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(R),onValueChange:F=>L(Number(F)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(F=>o.jsxs(Se,{value:String(F),children:[F," / page"]},F))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:F=>{F.preventDefault(),M(D=>Math.max(1,D-1))},"aria-disabled":A<=1,className:A<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:F=>F.preventDefault(),children:["Page ",A," / ",W]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:F=>{F.preventDefault(),M(D=>Math.min(W,D+1))},"aria-disabled":A>=W,className:A>=W?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(bye,{open:e,onOpenChange:t,onCreated:()=>{M(1),q()}}),o.jsx(wye,{open:r,type:s,onOpenChange:F=>{n(F),F||l(null)},onUpdated:q}),o.jsx(Sye,{open:a,type:d,onOpenChange:F=>{i(F),F||u(null)},onDeleted:q})]})}function bye({open:e,onOpenChange:t,onCreated:r}){const[n,a]=x.useState(!1),[i,s]=x.useState({typeCode:"",typeName:"",state:!0,orderNum:null}),l=()=>{s({typeCode:"",typeName:"",state:!0,orderNum:null})};x.useEffect(()=>{e||l()},[e]);const d=async()=>{if(!i.typeName.trim()){ee.error("Validation failed",{description:"Type Name is required."});return}if(i.orderNum===null||i.orderNum===void 0||!Number.isFinite(i.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}a(!0);try{await Eme(i),ee.success("Label type created.",{description:"The label type has been created successfully."}),t(!1),r()}catch(u){ee.error("Failed to create label type.",{description:u?.message?String(u.message):"Please try again."})}finally{a(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Add New Label Type"}),o.jsx(It,{children:"Enter the details for the new label type."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Type Code"}),o.jsx(me,{placeholder:"e.g. TYPE_DEFROST",value:i.typeCode,onChange:u=>s(f=>({...f,typeCode:u.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Type Name *"}),o.jsx(me,{placeholder:"e.g. Defrost",value:i.typeName,onChange:u=>s(f=>({...f,typeName:u.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:i.orderNum??"",onChange:u=>s(f=>({...f,orderNum:u.target.value?Number(u.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:i.state,onCheckedChange:u=>s(f=>({...f,state:u}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(ce,{disabled:n,onClick:d,children:n?"Creating...":"Create"})]})]})})}function wye({open:e,type:t,onOpenChange:r,onUpdated:n}){const[a,i]=x.useState(!1),[s,l]=x.useState({typeCode:"",typeName:"",state:!0,orderNum:null});x.useEffect(()=>{e&&t&&l({typeCode:t.typeCode??"",typeName:t.typeName??"",state:t.state??!0,orderNum:t.orderNum??null})},[e,t]);const d=async()=>{if(t?.id){if(!s.typeName.trim()){ee.error("Validation failed",{description:"Type Name is required."});return}if(s.orderNum===null||s.orderNum===void 0||!Number.isFinite(s.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}i(!0);try{await Pme(t.id,s),ee.success("Label type updated.",{description:"The label type has been updated successfully."}),r(!1),n()}catch(u){ee.error("Failed to update label type.",{description:u?.message?String(u.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Edit Label Type"}),o.jsx(It,{children:"Update the label type details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Type Code"}),o.jsx(me,{placeholder:"e.g. TYPE_DEFROST",value:s.typeCode,onChange:u=>l(f=>({...f,typeCode:u.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Type Name *"}),o.jsx(me,{placeholder:"e.g. Defrost",value:s.typeName,onChange:u=>l(f=>({...f,typeName:u.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:s.orderNum??"",onChange:u=>l(f=>({...f,orderNum:u.target.value?Number(u.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:s.state,onCheckedChange:u=>l(f=>({...f,state:u}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:a,onClick:d,children:a?"Updating...":"Update"})]})]})})}function Sye({open:e,type:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>(t?.typeName??"").trim()||t?.typeCode||"this type",[t]),l=async()=>{if(t?.id){i(!0);try{await Ome(t.id),ee.success("Label type deleted.",{description:"The label type has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label type.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Label Type"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}const jye=[{title:"Template",items:[{label:"Text",type:"TEXT_STATIC"},{label:"QR Code",type:"QRCODE"},{label:"Barcode",type:"BARCODE"},{label:"Blank Space",type:"BLANK"},{label:"Price",type:"TEXT_PRICE"},{label:"Image",type:"IMAGE"},{label:"Logo",type:"IMAGE"}]},{title:"Label",items:[{label:"Label Name",type:"TEXT_PRODUCT"},{label:"Text",type:"TEXT_STATIC"},{label:"QR Code",type:"QRCODE"},{label:"Barcode",type:"BARCODE"},{label:"Nutrition Facts",type:"NUTRITION"},{label:"Price",type:"TEXT_PRICE"},{label:"Duration Date",type:"DATE"},{label:"Duration Time",type:"TIME"},{label:"Duration",type:"DURATION"},{label:"Image",type:"IMAGE"},{label:"Label Type",type:"TEXT_STATIC"},{label:"How-to",type:"TEXT_STATIC"},{label:"Expiration Alert",type:"TEXT_STATIC"}]},{title:"Auto-generated",items:[{label:"Company",type:"TEXT_STATIC"},{label:"Employee",type:"TEXT_STATIC"},{label:"Current Date",type:"DATE"},{label:"Current Time",type:"TIME"},{label:"Label ID",type:"TEXT_STATIC"}]},{title:"Print input",subtitle:"Click to add to canvas",items:[{label:"Text",type:"TEXT_STATIC",config:{inputType:"text"}},{label:"Weight",type:"WEIGHT"},{label:"Number",type:"TEXT_STATIC",config:{inputType:"number",text:"0"}},{label:"Date & Time",type:"DATE",config:{inputType:"datetime",format:"YYYY-MM-DD HH:mm"}},{label:"Multiple Options",type:"TEXT_STATIC",config:{inputType:"options",multipleOptionId:"",selectedOptionValues:[],text:"Text",fontFamily:"Arial",fontSize:14,fontWeight:"normal",textAlign:"left"}}]}];function Nye(e){const t=e.trim().toLowerCase();return t==="template"?{backgroundColor:"#dbeafe",border:"1px solid #93c5fd",borderRadius:8,padding:8}:t==="label"?{backgroundColor:"#e0f2fe",border:"1px solid #7dd3fc",borderRadius:8,padding:8}:t==="auto-generated"?{backgroundColor:"#ede9fe",border:"1px solid #c4b5fd",borderRadius:8,padding:8}:t==="print input"?{backgroundColor:"#ffedd5",border:"1px solid #fdba74",borderRadius:8,padding:8}:{backgroundColor:"#f1f5f9",border:"1px solid #cbd5e1",borderRadius:8,padding:8}}function Cye({onAddElement:e}){return o.jsxs("div",{className:"w-44 shrink-0 border-r border-slate-200 bg-slate-50 flex flex-col h-full min-h-0",children:[o.jsx("div",{className:"px-2 py-2 border-b border-slate-200 font-semibold text-slate-800 text-sm shrink-0",style:{backgroundColor:"#eff6ff",borderBottomColor:"#93c5fd"},children:"Elements"}),o.jsx(Ec,{className:"flex-1 min-h-0 [&_[data-slot=scroll-area-viewport]]:bg-transparent",children:o.jsx("div",{className:"p-2 space-y-3",children:jye.map(t=>o.jsxs("div",{style:Nye(t.title),children:[o.jsx("div",{className:"px-2 py-1 text-xs font-medium text-gray-600 uppercase tracking-wide",children:t.title}),t.subtitle&&o.jsx("div",{className:"px-2 py-0.5 text-[10px] text-gray-400",children:t.subtitle}),o.jsx("div",{className:"grid grid-cols-2 gap-1 mt-0.5",children:t.items.map((r,n)=>o.jsx("button",{type:"button",onClick:()=>e(r.type,r.config,t.title,r.label),className:"text-left px-2 py-1 text-xs rounded hover:bg-gray-100 border border-transparent hover:border-gray-200 truncate",children:r.label},`${t.title}-${r.label}-${n}`))})]},t.title))})})]})}const Tv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),kv="/label-multiple-option";function _ye(e){if(e==null)return[];if(Array.isArray(e))return e.map(t=>String(t));if(typeof e=="string"){const t=e.trim();if(!t)return[];try{const r=JSON.parse(t);return Array.isArray(r)?r.map(n=>String(n)):[]}catch{return[]}}return[]}function oE(e){return{...e,optionValuesJson:_ye(e.optionValuesJson)}}function Eye(e){return{totalCount:e.totalCount??0,items:(e.items??[]).map(oE)}}function F6(e){return JSON.stringify(e)}async function B6(e,t){const r=await Tv.requestJson({path:kv,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t});return Eye(r)}async function Pye(e){const t=await Tv.requestJson({path:kv,method:"POST",body:{optionCode:String(e.optionCode??"").trim()||null,optionName:e.optionName,optionValuesJson:F6(e.optionValuesJson),state:e.state??!0,orderNum:e.orderNum}});return oE(t)}async function Oye(e,t){const r=await Tv.requestJson({path:`${kv}/${encodeURIComponent(e)}`,method:"PUT",body:{optionCode:String(t.optionCode??"").trim()||null,optionName:t.optionName,optionValuesJson:F6(t.optionValuesJson),state:t.state??!0,orderNum:t.orderNum}});return oE(r)}async function Tye(e){await Tv.requestJson({path:`${kv}/${encodeURIComponent(e)}`,method:"DELETE"})}var Av="Checkbox",[kye]=Eo(Av),[Aye,iE]=kye(Av);function Iye(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:a,disabled:i,form:s,name:l,onCheckedChange:d,required:u,value:f="on",internal_do_not_use_render:h}=e,[p,g]=No({prop:r,defaultProp:a??!1,onChange:d,caller:Av}),[v,b]=x.useState(null),[w,j]=x.useState(null),N=x.useRef(!1),C=v?!!s||!!v.closest("form"):!0,O={checked:p,disabled:i,setChecked:g,control:v,setControl:b,name:l,form:s,value:f,hasConsumerStoppedPropagationRef:N,required:u,defaultChecked:zi(a)?!1:a,isFormControl:C,bubbleInput:w,setBubbleInput:j};return o.jsx(Aye,{scope:t,...O,children:Mye(h)?h(O):n})}var z6="CheckboxTrigger",U6=x.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},a)=>{const{control:i,value:s,disabled:l,checked:d,required:u,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:v}=iE(z6,e),b=At(a,f),w=x.useRef(d);return x.useEffect(()=>{const j=i?.form;if(j){const N=()=>h(w.current);return j.addEventListener("reset",N),()=>j.removeEventListener("reset",N)}},[i,h]),o.jsx(lt.button,{type:"button",role:"checkbox","aria-checked":zi(d)?"mixed":d,"aria-required":u,"data-state":Y6(d),"data-disabled":l?"":void 0,disabled:l,value:s,...n,ref:b,onKeyDown:mt(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:mt(r,j=>{h(N=>zi(N)?!0:!N),v&&g&&(p.current=j.isPropagationStopped(),p.current||j.stopPropagation())})})});U6.displayName=z6;var q6=x.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:i,required:s,disabled:l,value:d,onCheckedChange:u,form:f,...h}=e;return o.jsx(Iye,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:l,required:s,onCheckedChange:u,name:n,form:f,value:d,internal_do_not_use_render:({isFormControl:p})=>o.jsxs(o.Fragment,{children:[o.jsx(U6,{...h,ref:t,__scopeCheckbox:r}),p&&o.jsx(G6,{__scopeCheckbox:r})]})})});q6.displayName=Av;var V6="CheckboxIndicator",W6=x.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...a}=e,i=iE(V6,r);return o.jsx(to,{present:n||zi(i.checked)||i.checked===!0,children:o.jsx(lt.span,{"data-state":Y6(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});W6.displayName=V6;var H6="CheckboxBubbleInput",G6=x.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:s,required:l,disabled:d,name:u,value:f,form:h,bubbleInput:p,setBubbleInput:g}=iE(H6,e),v=At(r,g),b=I_(i),w=O_(n);x.useEffect(()=>{const N=p;if(!N)return;const C=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(C,"checked").set,E=!a.current;if(b!==i&&P){const T=new Event("click",{bubbles:E});N.indeterminate=zi(i),P.call(N,zi(i)?!1:i),N.dispatchEvent(T)}},[p,b,i,a]);const j=x.useRef(zi(i)?!1:i);return o.jsx(lt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??j.current,required:l,disabled:d,name:u,value:f,form:h,...t,tabIndex:-1,ref:v,style:{...t.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});G6.displayName=H6;function Mye(e){return typeof e=="function"}function zi(e){return e==="indeterminate"}function Y6(e){return zi(e)?"indeterminate":e?"checked":"unchecked"}function Co({className:e,...t}){return o.jsx(q6,{"data-slot":"checkbox",className:Ie("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:o.jsx(W6,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:o.jsx(j$,{className:"size-3.5"})})})}const KL=["DD/MM/YYYY","MM/DD/YYYY","DD/MM/YY","MM/DD/YY","MM/YY","MM/DD","MM","DD","YY","FULLY DAY(WEDNESDAY)","DAY (WED)","MONTH (DECEMBER)","YEAR (2025)","DD MONTH YEAR (25 DECEMBER 2025)"],XL="YYYY-MM-DD HH:mm",Rye=["Minutes","Hours","Days","Weeks","Months (30 Day)","Years"];function Dye({template:e,selectedElement:t,onTemplateChange:r,onElementChange:n,onDeleteElement:a,readOnlyTemplateCode:i=!1}){if(t){const s=L8(t);return o.jsxs("div",{className:"w-72 shrink-0 border-l border-gray-200 bg-white flex flex-col h-full",children:[o.jsx("div",{className:"px-3 py-2 border-b border-gray-200 font-semibold text-gray-800",children:"Properties (Element)"}),o.jsx(Ec,{className:"flex-1",children:o.jsxs("div",{className:"p-3 space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"X"}),o.jsx(me,{type:"number",value:t.x,onChange:l=>n(t.id,{x:Number(l.target.value)||0}),className:"h-8 text-sm"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Y"}),o.jsx(me,{type:"number",value:t.y,onChange:l=>n(t.id,{y:Number(l.target.value)||0}),className:"h-8 text-sm"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Width"}),o.jsx(me,{type:"number",value:t.width,onChange:l=>n(t.id,{width:Math.max(1,Number(l.target.value)||0)}),className:"h-8 text-sm"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Height"}),o.jsx(me,{type:"number",value:t.height,onChange:l=>n(t.id,{height:Math.max(1,Number(l.target.value)||0)}),className:"h-8 text-sm"})]})]}),s?null:o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Rotation"}),o.jsxs($e,{value:t.rotation,onValueChange:l=>n(t.id,{rotation:l}),children:[o.jsx(Be,{className:"h-8 text-sm",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"horizontal",children:"horizontal"}),o.jsx(Se,{value:"vertical",children:"vertical"})]})]})]}),s?null:o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Border"}),o.jsxs($e,{value:t.border,onValueChange:l=>n(t.id,{border:l}),children:[o.jsx(Be,{className:"h-8 text-sm",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"none",children:"none"}),o.jsx(Se,{value:"line",children:"line"}),o.jsx(Se,{value:"dotted",children:"dotted"})]})]})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Element name"}),o.jsx(me,{value:(t.elementName??"").trim(),onChange:l=>n(t.id,{elementName:l.target.value}),className:"h-8 text-sm mt-1",placeholder:"e.g. text1"}),o.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Required for save; used as data-entry column header (elementName)."})]}),o.jsx(zye,{element:t,onChange:l=>n(t.id,{config:{...t.config,...l}})}),a&&o.jsx("div",{className:"pt-4 border-t border-gray-100",children:o.jsxs(ce,{variant:"destructive",className:"w-full gap-2",onClick:()=>a(t.id),children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),"Delete Element"]})})]})})]})}return o.jsxs("div",{className:"w-72 shrink-0 border-l border-gray-200 bg-white flex flex-col h-full",children:[o.jsx("div",{className:"px-3 py-2 border-b border-gray-200 font-semibold text-gray-800",children:"Properties (Element)"}),o.jsx(Ec,{className:"flex-1",children:o.jsx("div",{className:"p-3",children:o.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50/50 p-3 text-xs text-blue-900",children:"Select an element on the canvas to edit its properties."})})})]})}const JS="__none__";function Lye({cfg:e,onPatch:t}){const[r,n]=x.useState([]),[a,i]=x.useState(!1);x.useEffect(()=>{let h=!1;return i(!0),B6({skipCount:1,maxResultCount:500}).then(p=>{h||n(p.items??[])}).catch(()=>{h||n([])}).finally(()=>{h||i(!1)}),()=>{h=!0}},[]);const s=(e.multipleOptionId??"").trim(),l=Array.isArray(e.selectedOptionValues)?e.selectedOptionValues:[],d=r.find(h=>h.id===s),u=d?.optionValuesJson??[];x.useEffect(()=>{if(!s||r.length===0)return;const h=r.find(v=>v.id===s),p=String(h?.optionName??"").trim();if(!h||!p)return;const g=String(e.multipleOptionName??"").trim();p!==g&&t({multipleOptionName:p})},[s,r,e.multipleOptionName,t]);const f=s||JS;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Option dictionary"}),o.jsxs($e,{value:f,onValueChange:h=>{if(h===JS){t({multipleOptionId:"",multipleOptionName:"",selectedOptionValues:[]});return}const p=r.find(w=>w.id===h),g=new Set(p?.optionValuesJson??[]),v=l.filter(w=>g.has(w)),b=String(p?.optionName??p?.optionCode??"").trim();t({multipleOptionId:h,multipleOptionName:b,selectedOptionValues:v})},disabled:a,children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{placeholder:a?"Loading…":"Select from Multiple Options"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:JS,children:"— None —"}),r.map(h=>o.jsx(Se,{value:h.id,children:h.optionName??h.optionCode??h.id},h.id))]})]}),o.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Data comes from the Multiple Options tab (label-multiple-option list)."})]}),d&&u.length>0?o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Values (multi-select)"}),o.jsx("div",{className:"mt-1 max-h-44 overflow-y-auto border border-gray-200 rounded-md p-2 space-y-2 bg-gray-50/50",children:u.map(h=>o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(Co,{className:"shrink-0",checked:l.includes(h),onCheckedChange:p=>{const g=new Set(l);p?g.add(h):g.delete(h),t({selectedOptionValues:Array.from(g)})}}),o.jsx("span",{className:"text-xs truncate",title:h,children:h})]},h))})]}):s?o.jsx("p",{className:"text-[10px] text-amber-600",children:"No values in this dictionary or still loading."}):null]})}const $ye="box-border h-[150px] w-[150px] min-h-[150px] min-w-[150px] max-h-[150px] max-w-[150px] shrink-0";function QS({cfg:e,update:t,textAlignDefault:r,primaryTextLabel:n}){const a=n??"Text";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:a}),o.jsx(me,{value:e.text??"0.00",onChange:i=>t("text",i.target.value),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:e.fontSize??14,onChange:i=>t("fontSize",Number(i.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:e.textAlign??r,onValueChange:i=>t("textAlign",i),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"left",children:"Left"}),o.jsx(Se,{value:"center",children:"Center"}),o.jsx(Se,{value:"right",children:"Right"})]})]})]})]})}function fo(e,t,r){for(const n of t){const a=e[n];if(a!=null&&String(a).trim()!=="")return String(a).trim()}return r}function nc(e,t,r){for(const n of t){const a=e[n];if(a==null||a==="")continue;const i=typeof a=="number"?a:Number(a);if(Number.isFinite(i))return i}return r}const K6=[{value:"lb",label:"Lb"},{value:"kg",label:"Kg"},{value:"mg",label:"Milligrams"},{value:"g",label:"Grams"},{value:"oz",label:"Ounces"}];function Fye(e){const t=String(e??"").trim().toLowerCase();return t==="milligrams"?"mg":t==="grams"?"g":t==="ounces"?"oz":t==="pounds"?"lb":t==="kilograms"?"kg":K6.some(r=>r.value===t)?t:"g"}function Bye(e){const t=e.extraNutrients;return Array.isArray(t)?t.map((r,n)=>{const a=r;return{id:String(a.id??`extra-${n}`),name:String(a.name??""),value:String(a.value??""),unit:String(a.unit??"")}}):[]}function Ap(e,t,r){const n=r==="value"?t:`${t}Unit`,a=e[n];if(a!=null&&String(a).trim()!=="")return String(a).trim();const s=(Array.isArray(e.fixedNutrients)?e.fixedNutrients:[]).find(l=>String(l.key??"").trim()===t);return String(s?.[r]??"").trim()}function zye({element:e,onChange:t}){const r=e.config,n=Kr(e.type),a=(l,d)=>t({[l]:d}),i=$8(e),s=i?"Value":"Text";switch(n){case"TEXT_STATIC":return r.inputType==="options"?o.jsxs(o.Fragment,{children:[o.jsx(Lye,{cfg:r,onPatch:t}),o.jsx(QS,{cfg:r,update:a,textAlignDefault:"left",primaryTextLabel:s})]}):o.jsx(QS,{cfg:r,update:a,textAlignDefault:"right",primaryTextLabel:s});case"TEXT_PRODUCT":case"TEXT_PRICE":return o.jsx(QS,{cfg:r,update:a,textAlignDefault:"right"});case"BARCODE":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Data"}),o.jsx(me,{value:r.data??"123456789",onChange:l=>a("data",l.target.value),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Orientation"}),o.jsxs($e,{value:r.orientation??"horizontal",onValueChange:l=>a("orientation",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"horizontal",children:"Horizontal"}),o.jsx(Se,{value:"vertical",children:"Vertical"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(br,{checked:r.showText!==!1,onCheckedChange:l=>a("showText",l)}),o.jsx(de,{className:"text-xs",children:"Show Text"})]})]});case"QRCODE":return o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Data (URL)"}),o.jsx(me,{value:r.data??"https://example.com",onChange:l=>a("data",l.target.value),className:"h-8 text-sm mt-1"})]});case"IMAGE":{if(i){const l=String(r.src??"").trim();return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Image"}),o.jsx(_u,{value:l,onChange:d=>a("src",d),uploadSubDir:"label-template-editor",oneImageOnly:!0,boxClassName:$ye,hint:"Stored in template; print uses this URL (empty if cleared)."})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Scale Mode"}),o.jsxs($e,{value:r.scaleMode??"contain",onValueChange:d=>a("scaleMode",d),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"contain",children:"Contain"}),o.jsx(Se,{value:"cover",children:"Cover"}),o.jsx(Se,{value:"fill",children:"Fill"})]})]})]})]})}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Image URL / path"}),o.jsx(me,{value:r.src??"",onChange:l=>a("src",l.target.value),className:"h-8 text-sm mt-1",placeholder:"https://... or /picture/..."})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Scale Mode"}),o.jsxs($e,{value:r.scaleMode??"contain",onValueChange:l=>a("scaleMode",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"contain",children:"Contain"}),o.jsx(Se,{value:"cover",children:"Cover"}),o.jsx(Se,{value:"fill",children:"Fill"})]})]})]})]})}case"DATE":{const l=String(r.inputType??r.InputType??"").toLowerCase(),d=l==="datetime"||l==="date",u=fo(r,["format","Format"],l==="datetime"?XL:"DD/MM/YYYY"),f=l==="datetime"?[XL,...KL]:[...KL];return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Format"}),o.jsxs($e,{value:u,onValueChange:h=>a("format",h),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsx(ze,{children:f.map(h=>o.jsx(Se,{value:h,children:h},h))})]}),d?o.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Shown as placeholder on the label until the app fills the date at print time."}):null]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:nc(r,["fontSize","FontSize"],14),onChange:h=>a("fontSize",Number(h.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:fo(r,["textAlign","TextAlign"],"left"),onValueChange:h=>a("textAlign",h),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"left",children:"Left"}),o.jsx(Se,{value:"center",children:"Center"}),o.jsx(Se,{value:"right",children:"Right"})]})]})]})]})}case"TIME":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Format"}),o.jsx(me,{value:"HH:mm",className:"h-8 text-sm mt-1",readOnly:!0})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:nc(r,["fontSize","FontSize"],14),onChange:l=>a("fontSize",Number(l.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:fo(r,["textAlign","TextAlign"],"left"),onValueChange:l=>a("textAlign",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"left",children:"Left"}),o.jsx(Se,{value:"center",children:"Center"}),o.jsx(Se,{value:"right",children:"Right"})]})]})]})]});case"DURATION":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Format"}),o.jsxs($e,{value:fo(r,["format","Format"],"Days"),onValueChange:l=>a("format",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsx(ze,{children:Rye.map(l=>o.jsx(Se,{value:l,children:l},l))})]})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:nc(r,["fontSize","FontSize"],14),onChange:l=>a("fontSize",Number(l.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:fo(r,["textAlign","TextAlign"],"left"),onValueChange:l=>a("textAlign",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"left",children:"Left"}),o.jsx(Se,{value:"center",children:"Center"}),o.jsx(Se,{value:"right",children:"Right"})]})]})]})]});case"WEIGHT":{const l=Fye(fo(r,["unit","Unit"],"g")),d=fo(r,["textAlign","TextAlign"],"left"),u=nc(r,["fontSize","FontSize"],14);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Value"}),o.jsx(me,{type:"number",value:nc(r,["value","Value"],500),onChange:f=>a("value",Number(f.target.value)||0),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Unit"}),o.jsxs($e,{value:l,onValueChange:f=>a("unit",f),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsx(ze,{children:K6.map(f=>o.jsx(Se,{value:f.value,children:f.label},f.value))})]})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:u,onChange:f=>a("fontSize",Math.max(1,Number(f.target.value)||14)),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:d,onValueChange:f=>a("textAlign",f),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"left",children:"Left"}),o.jsx(Se,{value:"center",children:"Center"}),o.jsx(Se,{value:"right",children:"Right"})]})]})]})]})}case"WEIGHT_PRICE":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Unit Price"}),o.jsx(me,{type:"number",value:r.unitPrice??10,onChange:l=>a("unitPrice",Number(l.target.value)||0),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Weight"}),o.jsx(me,{type:"number",step:"0.1",value:r.weight??.5,onChange:l=>a("weight",Number(l.target.value)||0),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Currency"}),o.jsx(me,{value:r.currency??"$",onChange:l=>a("currency",l.target.value),className:"h-8 text-sm mt-1"})]})]});case"NUTRITION":{const l=Bye(r),d=(p,g,v)=>{const b=rl.map(N=>{const C={key:N.key,label:N.label,value:Ap(r,N.key,"value"),unit:Ap(r,N.key,"unit")};return N.key!==p?C:{...C,[g]:v}}),w={fixedNutrients:b},j=b.find(N=>N.key===p);j&&(w[p]=j.value,w[`${p}Unit`]=j.unit),t(w)},u=()=>{const p=[...l,{id:`extra-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,name:"",value:"",unit:""}];a("extraNutrients",p)},f=(p,g,v)=>{const b=l.map(w=>w.id===p?{...w,[g]:v}:w);a("extraNutrients",b)},h=p=>{a("extraNutrients",l.filter(g=>g.id!==p))};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(de,{className:"text-xs",children:"Nutrition summary"}),o.jsxs("div",{className:"space-y-2 mt-1",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Nutrition Facts title (px)"}),o.jsx(me,{type:"number",value:nc(r,["nutritionTitleFontSize","NutritionTitleFontSize"],16),onChange:p=>a("nutritionTitleFontSize",Math.max(10,Number(p.target.value)||16)),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Servings Per Container"}),o.jsx(me,{value:fo(r,["servingsPerContainer","ServingsPerContainer"],""),onChange:p=>a("servingsPerContainer",p.target.value),className:"h-8 text-sm",placeholder:"e.g. 8"})]}),o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Serving Size"}),o.jsx(me,{value:fo(r,["servingSize","ServingSize"],""),onChange:p=>a("servingSize",p.target.value),className:"h-8 text-sm",placeholder:"e.g. 1 cup"})]}),o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Calories"}),o.jsx(me,{value:fo(r,["calories","Calories"],""),onChange:p=>a("calories",p.target.value),className:"h-8 text-sm",placeholder:"e.g. 120"})]})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx(de,{className:"text-xs",children:"Nutrition table"}),o.jsx(ce,{type:"button",variant:"outline",className:"h-7 px-2 text-xs",onClick:u,children:"Add nutrient"})]}),o.jsxs("div",{className:"space-y-1.5 mt-1",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_78px_58px_26px] gap-1.5 items-center text-[10px] text-gray-500 px-0.5",children:[o.jsx("span",{children:"Name"}),o.jsx("span",{children:"Value"}),o.jsx("span",{children:"Unit"}),o.jsx("span",{})]}),rl.map(p=>o.jsxs("div",{className:"grid grid-cols-[1fr_78px_58px_26px] gap-1.5 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:p.label}),o.jsx(me,{value:Ap(r,p.key,"value"),onChange:g=>d(p.key,"value",g.target.value),className:"h-8 text-sm",placeholder:"Value"}),o.jsx(me,{value:Ap(r,p.key,"unit")||(p.defaultUnit??""),onChange:g=>d(p.key,"unit",g.target.value),className:"h-8 text-sm",placeholder:"Unit"}),o.jsx("span",{})]},p.key))]})]}),o.jsxs("div",{className:"space-y-2",children:[l.length===0?o.jsx("p",{className:"text-[10px] text-gray-400",children:"No custom nutrients yet."}):l.map(p=>o.jsxs("div",{className:"grid grid-cols-[1fr_78px_58px_26px] gap-1.5 items-center",children:[o.jsx(me,{value:p.name,onChange:g=>f(p.id,"name",g.target.value),className:"h-8 text-sm",placeholder:"Name"}),o.jsx(me,{value:p.value,onChange:g=>f(p.id,"value",g.target.value),className:"h-8 text-sm",placeholder:"Value"}),o.jsx(me,{value:p.unit,onChange:g=>f(p.id,"unit",g.target.value),className:"h-8 text-sm",placeholder:"Unit"}),o.jsx(ce,{type:"button",variant:"ghost",className:"h-8 w-8 p-0 text-gray-500 hover:text-red-600",onClick:()=>h(p.id),"aria-label":"Delete nutrient",children:o.jsx(zt,{className:"h-3.5 w-3.5"})})]},p.id)),o.jsx("div",{className:"text-[10px] text-gray-400",children:"Unit is appended after value in template preview."})]})]})}case"BLANK":return o.jsx("div",{className:"text-xs text-gray-500",children:"Blank spacer; no configuration needed."});default:return o.jsxs("div",{className:"text-xs text-gray-500",children:["Config for ",n," (edit in code if needed)"]})}}const Uye=.5,qye=2,JL=.25,QL=1;function X6(e){return`tpl_${Math.random().toString(36).slice(2,8)}_${Date.now().toString(36)}`}function Vye(e){return{...e,id:X6(e.id),name:`${(e.name||"Unnamed template").trim()} Copy`,elements:e.elements.map(t=>({...t,config:{...t.config??{}}}))}}function Wye({templateId:e,initialTemplate:t,onClose:r,onSaved:n}){const[a,i]=x.useState(()=>t?{...t}:{...$me(e??void 0),id:X6()}),[s,l]=x.useState(null),[d,u]=x.useState(QL),[f,h]=x.useState(!1),[p,g]=x.useState("none"),[v,b]=x.useState("horizontal"),[w,j]=x.useState([]),[N,C]=x.useState(""),[O,P]=x.useState(!1),E=a.elements.find(I=>I.id===s)??null;x.useEffect(()=>{if(e)return;let I=!1;return(async()=>{try{const Y=await Nv({skipCount:1,maxResultCount:200});if(I)return;const F=(Y.items??[]).map(D=>{const $=(D.templateCode??D.id??"").trim(),K=(D.templateName??D.name??$).trim();return $?{code:$,name:K}:null}).filter(D=>!!D);j(F),!N&&F.length>0&&C(F[0].code)}catch{I||j([])}})(),()=>{I=!0}},[e,N]),x.useEffect(()=>{if(e||!N)return;let I=!1;return(async()=>{P(!0);try{const Y=await au(N);if(I)return;const F=Vye({id:Y.id,name:(Y.name??Y.templateName??"").trim()||"Unnamed template",labelType:Y.labelType??"PRICE",unit:Y.unit??"cm",width:Y.width??6,height:Y.height??4,appliedLocation:Y.appliedLocation==="SPECIFIED"?"SPECIFIED":"ALL",appliedLocationIds:[...Y.appliedLocationIds??[]],showRuler:!0,showGrid:Y.showGrid??!0,elements:(Y.elements??[]).map((D,$)=>{const K=D,J=(K.elementName??"").trim();return{...K,elementName:J||`element${$+1}`}})});i(F),l(null)}catch(Y){if(I)return;ee.error("Failed to copy starter template.",{description:Y?.message?String(Y.message):"Please try again."})}finally{I||P(!1)}})(),()=>{I=!0}},[e,N]),x.useEffect(()=>{i(I=>{const Y=(J,oe)=>oe==="cm"?J*37.8:J*96,F=Y(I.width,I.unit),D=Y(I.height,I.unit);let $=!1;const K=I.elements.map(J=>{const oe=zp(J.x,J.y,J.width,J.height,F,D);return J.x!==oe.x||J.y!==oe.y||J.width!==oe.w||J.height!==oe.h?($=!0,{...J,x:oe.x,y:oe.y,width:oe.w,height:oe.h}):J});return $?{...I,elements:K}:I})},[a.width,a.height,a.unit,a.id]);const T=p,A="space-y-1",M="!h-7 px-2 py-1 text-xs leading-tight bg-white",R="!h-7 gap-1 px-2 py-0 text-xs leading-tight bg-white [&_svg]:!size-3 *:data-[slot=select-value]:line-clamp-1",L="text-[11px] font-semibold leading-tight text-[#1d3c8f]",V=x.useCallback((I,Y,F,D)=>{let $="";i(K=>{const J=(De,He)=>He==="cm"?De*37.8:De*96,oe=J(K.width,K.unit),re=J(K.height,K.unit);let Q=Fme(I,0,0);const ue=8,se=De=>Math.round(De/ue)*ue;let fe=(oe-Q.width)/2,we=(re-Q.height)/2;const Z=(De,He,ne,pe)=>K.elements.some(_e=>{const ve=_e.x+_e.width,ke=_e.y+_e.height,Ge=De+ne,xe=He+pe;return!(De>=ve||Ge<=_e.x||He>=ke||xe<=_e.y)});if(Z(fe,we,Q.width,Q.height)){const De=ue*2;let He=!1;for(let ne=we;ne=0&&!He;ne-=De)for(let pe=fe;pe>=0&&!He;pe-=De)Z(pe,ne,Q.width,Q.height)||(fe=pe,we=ne,He=!0)}Q={...Q,x:Math.max(0,se(fe)),y:Math.max(0,se(we))};const je=zp(Q.x,Q.y,Q.width,Q.height,oe,re);Q={...Q,x:je.x,y:je.y,width:je.w,height:je.h},Y&&Object.keys(Y).length>0&&(Q.config={...Q.config,...Y});const Ce=Ame(D,K.elements),qe=M8(F);return Q={...Q,type:Q.type,typeAdd:U8(F,D),libraryCategory:X_(F,D),valueSourceType:qe,elementName:Ce},$=Q.id,{...K,elements:[...K.elements,Q]}}),l($)},[a.width,a.height,a.unit]),z=x.useCallback((I,Y)=>{i(F=>{const D=(J,oe)=>oe==="cm"?J*37.8:J*96,$=D(F.width,F.unit),K=D(F.height,F.unit);return{...F,elements:F.elements.map(J=>{if(J.id!==I)return J;const oe={...J,...Y};if(!(Y.x!==void 0||Y.y!==void 0||Y.width!==void 0||Y.height!==void 0))return oe;const Q=zp(oe.x,oe.y,oe.width,oe.height,$,K);return{...oe,x:Q.x,y:Q.y,width:Q.w,height:Q.h}})}})},[]),G=x.useCallback(I=>{i(Y=>({...Y,elements:Y.elements.filter(F=>F.id!==I)})),l(null)},[]),H=x.useCallback(I=>{i(Y=>({...Y,...I}))},[]),W=x.useCallback(async()=>{try{const I=(a.id??"").trim();if(!I){ee.error("Template code is required.",{description:"Please enter a template code (e.g. TPL_TEST_001)."});return}if(a.elements.find($=>!($.elementName??"").trim())){ee.error("Component name required.",{description:"Each element must have a non-empty element name."});return}if(a.elements.find($=>{if($.type!=="TEXT_STATIC")return!1;const K=$.config;return String(K?.inputType??"").toLowerCase()!=="options"?!1:!String(K?.multipleOptionId??K?.MultipleOptionId??"").trim()})){ee.error("Option dictionary required.",{description:"Each Multiple Options element must have an Option dictionary selected in the properties panel."});return}const D={id:I,name:a.name,labelType:a.labelType,unit:a.unit,width:a.width,height:a.height,appliedLocation:"ALL",showRuler:!0,showGrid:a.showGrid??!0,state:!0,elements:Q_(a.elements),appliedLocationIds:[]};e?(await tE(I,D),ee.success("Template updated.",{description:"The template has been updated successfully."})):(await Xme(D),ee.success("Template created.",{description:"The template has been created successfully."})),n(),r()}catch(I){ee.error("Failed to save template.",{description:I?.message?String(I.message):"Please try again."})}},[a,e,n,r]),q=x.useCallback(()=>{const I={...a,elements:a.elements.map($=>({...$,type:Kr($.type),typeAdd:Qf($),elementName:($.elementName??"").trim(),valueSourceType:B8($),libraryCategory:Wme($),config:J_($.config??{})}))},Y=new Blob([JSON.stringify(I,null,2)],{type:"application/json"}),F=URL.createObjectURL(Y),D=document.createElement("a");D.href=F,D.download=`label-template-${a.id}.json`,D.click(),URL.revokeObjectURL(F)},[a]);return o.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200 bg-white shrink-0",children:[o.jsxs(ce,{variant:"outline",size:"sm",onClick:r,children:[o.jsx(w$,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx("span",{className:"text-sm font-medium text-gray-700 truncate flex-1",children:a.name}),o.jsxs(ce,{size:"sm",onClick:q,variant:"outline",children:[o.jsx(iC,{className:"w-4 h-4 mr-1"}),"Export JSON"]}),o.jsxs(ce,{size:"sm",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:W,children:[o.jsx(Yq,{className:"w-4 h-4 mr-1"}),"Save"]})]}),o.jsx("div",{className:"shrink-0 border-b border-[#cfd9ea] bg-[#dde7f5] px-4 py-2",children:o.jsx("div",{className:"rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsxs("div",{className:A,children:[o.jsx(de,{className:L,children:"Label Template Name"}),o.jsx(me,{value:a.name,onChange:I=>H({name:I.target.value}),className:M})]}),o.jsxs("div",{className:`${A} col-span-2`,children:[o.jsx(de,{className:L,children:"Ruler"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs($e,{value:a.unit,onValueChange:I=>H({unit:I,showRuler:!0}),children:[o.jsx(Be,{className:`w-[72px] shrink-0 ${R}`,children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"inch",className:"text-xs",children:"Inch"}),o.jsx(Se,{value:"cm",className:"text-xs",children:"cm"})]})]}),o.jsx("span",{className:"shrink-0 text-center text-[11px] font-semibold text-[#1d3c8f]",children:"W"}),o.jsx(me,{type:"number",value:a.width,onChange:I=>H({width:Math.max(.1,Number(I.target.value)||0),showRuler:!0}),className:`w-[72px] shrink-0 ${M}`,placeholder:"Width"}),o.jsx("span",{className:"shrink-0 text-center text-[11px] font-semibold text-[#1d3c8f]",children:"H"}),o.jsx(me,{type:"number",value:a.height,onChange:I=>H({height:Math.max(.1,Number(I.target.value)||0),showRuler:!0}),className:`w-[72px] shrink-0 ${M}`,placeholder:"Height"}),o.jsxs($e,{value:(()=>{const I=wc.findIndex(Y=>Y.width===a.width&&Y.height===a.height&&Y.unit===a.unit);return I>=0?String(I):"custom"})(),onValueChange:I=>{if(I==="custom")return;const Y=wc[Number(I)];Y&&H({width:Y.width,height:Y.height,unit:Y.unit,showRuler:!0})},children:[o.jsx(Be,{className:`w-[118px] shrink-0 ${R}`,children:o.jsx(Fe,{placeholder:"Canvas size"})}),o.jsxs(ze,{children:[wc.map((I,Y)=>o.jsx(Se,{value:String(Y),className:"text-xs",children:I.name},Y)),o.jsx(Se,{value:"custom",className:"text-xs text-gray-500",children:"Custom"})]})]})]})]}),o.jsxs("div",{className:A,children:[o.jsx(de,{className:L,children:"Starter Template"}),e?o.jsx(me,{value:"Current template",disabled:!0,className:M}):o.jsxs($e,{value:N,onValueChange:C,children:[o.jsx(Be,{className:R,children:o.jsx(Fe,{placeholder:"Select starter template"})}),o.jsx(ze,{children:w.map(I=>o.jsx(Se,{value:I.code,className:"text-xs",children:I.name},I.code))})]})]}),o.jsxs("div",{className:A,children:[o.jsx(de,{className:L,children:"Border"}),o.jsxs($e,{value:T,onValueChange:I=>g(I),children:[o.jsx(Be,{className:R,children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"none",className:"text-xs",children:"none"}),o.jsx(Se,{value:"line",className:"text-xs",children:"line"}),o.jsx(Se,{value:"dotted",className:"text-xs",children:"dotted"})]})]})]}),o.jsxs("div",{className:A,children:[o.jsx(de,{className:L,children:"Rotation"}),o.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:o.jsx("div",{className:"col-span-2",children:o.jsxs($e,{value:v,onValueChange:I=>{b(I),a.height>a.width!==(I==="vertical")&&H({width:a.height,height:a.width})},children:[o.jsx(Be,{className:R,children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"horizontal",className:"text-xs",children:"horizontal"}),o.jsx(Se,{value:"vertical",className:"text-xs",children:"vertical"})]})]})})})]}),O?o.jsx("div",{className:"col-span-3 text-[11px] leading-tight text-[#1d3c8f]",children:"Copying starter template…"}):null]})})}),o.jsxs("div",{className:"flex flex-1 min-h-0 gap-2 p-2 bg-[#dde7f5]",children:[o.jsx("div",{className:"shrink-0 rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-1 overflow-hidden",children:o.jsx(Cye,{onAddElement:V})}),o.jsx("div",{className:"flex flex-1 min-w-0 min-h-0 flex-col rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-1 overflow-hidden",children:o.jsx($ge,{template:a,canvasBorder:p,selectedId:s,onSelect:l,onUpdateElement:z,onDeleteElement:G,onTemplateChange:H,scale:d,onZoomIn:()=>u(I=>Math.min(qye,I+JL)),onZoomOut:()=>u(I=>Math.max(Uye,I-JL)),onResetZoom:()=>u(QL),onPreview:()=>h(!0),hideToolbarPresetSize:!0})}),o.jsx(_t,{open:f,onOpenChange:h,children:o.jsxs(Ct,{className:"max-w-[90vw] max-h-[90vh] p-0 overflow-hidden flex flex-col",children:[o.jsx(Et,{className:"shrink-0 px-6 py-4 border-b bg-white",children:o.jsx(Pt,{children:"Label preview"})}),o.jsx("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-auto p-4 bg-gray-50",children:o.jsx("div",{className:"min-w-max",children:o.jsx(nE,{template:a,canvasBorder:p,maxWidth:0})})})]})}),o.jsx("div",{className:"shrink-0 rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-1 overflow-hidden",children:o.jsx(Dye,{template:a,selectedElement:E,onTemplateChange:H,onElementChange:z,onDeleteElement:G,readOnlyTemplateCode:!!e})})]})]})}function ZS(e){const t=(e??"").trim();return t||"None"}function Hye(e,t){if(tu(e)==="ALL")return"All";const n=e.appliedLocationIds??[];if(n.length===0)return"Specified (0)";const a=n.map(i=>t.find(s=>s.id===i)?.locationName?.trim()||i);return a.length<=2?a.join(", "):`${a.slice(0,2).join(", ")} +${a.length-2}`}function Gye(e){const t=(e.templateName??e.name??"").trim();return t||"None"}function Yye(e){const t=(e.templateCode??e.id??"").trim();return t||"None"}function Kye(e,t){const r=(e.locationText??"").trim();return r||Hye(e,t)}function Xye(e){return typeof e.contentsCount=="number"?e.contentsCount:e.elements?.length??0}function Jye(e){const t=(e.sizeText??"").trim();if(t)return t;const r=e.width,n=e.height,a=e.unit;return r!=null&&n!=null&&a?`${r}×${n} ${a}`:"None"}function Qye({onTemplateEditorOverlayChange:e}){const[t,r]=x.useState([]),[n,a]=x.useState("list"),[i,s]=x.useState(null),[l,d]=x.useState(null),[u,f]=x.useState(!1),[h,p]=x.useState(0),[g,v]=x.useState(0),[b,w]=x.useState(null),[j,N]=x.useState(!1),[C,O]=x.useState(null),[P,E]=x.useState(""),[T,A]=x.useState("all"),[M,R]=x.useState("all"),[L,V]=x.useState("all"),[z,G]=x.useState(1),[H,W]=x.useState(10),[q,I]=x.useState([]),Y=x.useRef(null),F=x.useRef(null),[D,$]=x.useState("");x.useEffect(()=>(F.current&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>$(P.trim()),300),()=>{F.current&&window.clearTimeout(F.current)}),[P]);const K=Math.max(1,Math.ceil(h/H));x.useEffect(()=>{let je=!1;return(async()=>{try{const Ce=await Nu({skipCount:1,maxResultCount:500});je||I(Ce.items??[])}catch{je||I([])}})(),()=>{je=!0}},[]),x.useEffect(()=>{G(1)},[D,T,M,L,H]),x.useEffect(()=>n!=="list"?void 0:((async()=>{Y.current?.abort();const Ce=new AbortController;Y.current=Ce,f(!0);try{const qe=Qa(z),De=await Nv({skipCount:qe,maxResultCount:H,keyword:D||void 0,locationId:T!=="all"?T:void 0,labelType:M!=="all"?M:void 0,state:L==="all"?void 0:L==="true"},Ce.signal);r(De.items??[]),p(De.totalCount??0)}catch(qe){if(qe?.name==="AbortError")return;ee.error("Failed to load label templates.",{description:qe?.message?String(qe.message):"Please try again."}),r([]),p(0)}finally{f(!1)}})(),()=>Y.current?.abort()),[D,T,M,L,z,H,g,n]),x.useEffect(()=>(e?.(n==="editor"),()=>{e?.(!1)}),[n,e]);const J=()=>v(je=>je+1),oe=()=>{s(null),d(null),a("editor")},re=async je=>{w(null),s(je),f(!0);try{const Ce=await au(je),qe={id:Ce.id,name:(Ce.name??Ce.templateName??"").trim()||"Unnamed template",labelType:Ce.labelType??"PRICE",unit:Ce.unit??"cm",width:Ce.width??6,height:Ce.height??4,appliedLocation:tu(Ce),appliedLocationIds:[...Ce.appliedLocationIds??[]],showRuler:Ce.showRuler??!0,showGrid:Ce.showGrid??!0,elements:(Ce.elements??[]).map((De,He)=>{const ne=De,pe=(ne.elementName??"").trim();return{...ne,elementName:pe||`element${He+1}`}})};d(qe),a("editor")}catch(Ce){ee.error("Failed to load template.",{description:Ce?.message?String(Ce.message):"Please try again."})}finally{f(!1)}},Q=()=>{a("list"),s(null),d(null)},ue=je=>{w(null),O(je),N(!0)},se=o.jsx("div",{className:"shrink-0 pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:P,onChange:je=>E(je.target.value),style:{height:40,boxSizing:"border-box"},className:"w-40 shrink-0 rounded-md border border-gray-300 bg-white placeholder:text-gray-500"}),o.jsxs($e,{value:T,onValueChange:A,children:[o.jsx(Be,{className:"w-[150px] shrink-0 rounded-md border border-gray-300 bg-white",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All Locations"}),q.map(je=>o.jsx(Se,{value:je.id,children:ZS(je.locationName??je.locationCode??je.id)},je.id))]})]}),o.jsxs($e,{value:M,onValueChange:R,children:[o.jsx(Be,{className:"w-[150px] shrink-0 rounded-md border border-gray-300 bg-white",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Label Type"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All Types"}),o.jsx(Se,{value:"PRICE",children:"PRICE"}),o.jsx(Se,{value:"NUTRITION",children:"NUTRITION"}),o.jsx(Se,{value:"SHIPPING",children:"SHIPPING"})]})]}),o.jsxs($e,{value:L,onValueChange:V,children:[o.jsx(Be,{className:"w-[150px] shrink-0 rounded-md border border-gray-300 bg-white",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All States"}),o.jsx(Se,{value:"true",children:"Active"}),o.jsx(Se,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ce,{className:"h-10 shrink-0 rounded-md bg-blue-600 px-6 font-medium text-white hover:bg-blue-700",onClick:oe,children:["New Label Template ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),fe=o.jsx("div",{className:"min-h-0 flex-1 overflow-auto pt-2",children:o.jsx("div",{className:"rounded-md border border-gray-200 bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[180px]",children:"Label Template"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Template Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Location"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Label Type"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Contents"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[150px]",children:"Size"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:u?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):t.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:'No templates yet. Click "New Label Template" to create one.'})}):t.map(je=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"font-medium whitespace-nowrap overflow-hidden text-ellipsis max-w-[180px]",children:Gye(je)}),o.jsx(ye,{className:"text-gray-600 whitespace-nowrap overflow-hidden text-ellipsis max-w-[140px]",children:Yye(je)}),o.jsx(ye,{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[140px]",children:ZS(Kye(je,q))}),o.jsx(ye,{className:"whitespace-nowrap",children:ZS(je.labelType)}),o.jsxs(ye,{className:"text-sm text-gray-600 whitespace-nowrap",children:[Xye(je)," element(s)"]}),o.jsx(ye,{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[160px]",children:Jye(je)}),o.jsx(ye,{className:"text-center",children:o.jsxs(ka,{open:b===je.id,onOpenChange:Ce=>w(Ce?je.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>re(je.id),children:[o.jsx(Rp,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>ue(je),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},je.id))})]})})}),we=o.jsx("div",{className:"shrink-0 pt-3",children:o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",h===0?0:(z-1)*H+1,"-",Math.min(z*H,h)," of ",h]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsxs($e,{value:String(H),onValueChange:je=>W(Number(je)),children:[o.jsx(Be,{className:"h-9 w-[110px] rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(je=>o.jsxs(Se,{value:String(je),children:[je," / page"]},je))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:je=>{je.preventDefault(),G(Ce=>Math.max(1,Ce-1))},"aria-disabled":z<=1,className:z<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:je=>je.preventDefault(),children:["Page ",z," / ",K]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:je=>{je.preventDefault(),G(Ce=>Math.min(K,Ce+1))},"aria-disabled":z>=K,className:z>=K?"pointer-events-none opacity-50":""})})]})})]})]})}),Z=o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[se,fe,we]});return o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[n==="editor"?o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:o.jsx(Wye,{templateId:i,initialTemplate:l,onClose:Q,onSaved:J})}):o.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:Z}),o.jsx(Zye,{open:j,template:C,onOpenChange:je=>{N(je),je||O(null)},onDeleted:J})]})}function Zye({open:e,template:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>(t?.templateName??t?.name??"").trim()||(t?.templateCode??t?.id??"").trim()||"this template",[t]),l=async()=>{if(t?.id){i(!0);try{await Jme(t.id),ee.success("Label template deleted.",{description:"The label template has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label template.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Label Template"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function ZL(e){const t=(e??"").trim();return t||"None"}function eve(){const[e,t]=x.useState(!1),[r,n]=x.useState(!1),[a,i]=x.useState(!1),[s,l]=x.useState(null),[d,u]=x.useState(null),[f,h]=x.useState([]),[p,g]=x.useState(!1),[v,b]=x.useState(0),[w,j]=x.useState(0),[N,C]=x.useState(null),[O,P]=x.useState(""),[E,T]=x.useState("all"),[A,M]=x.useState(1),[R,L]=x.useState(10),V=x.useRef(null),z=x.useRef(null),[G,H]=x.useState("");x.useEffect(()=>(z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>H(O.trim()),300),()=>{z.current&&window.clearTimeout(z.current)}),[O]);const W=Math.max(1,Math.ceil(v/R));x.useEffect(()=>{M(1)},[G,E,R]),x.useEffect(()=>((async()=>{V.current?.abort();const D=new AbortController;V.current=D,g(!0);try{const $=Qa(A),K=await B6({skipCount:$,maxResultCount:R,keyword:G||void 0,state:E==="all"?void 0:E==="true"},D.signal);h(K.items??[]),b(K.totalCount??0)}catch($){if($?.name==="AbortError")return;ee.error("Failed to load multiple options.",{description:$?.message?String($.message):"Please try again."}),h([]),b(0)}finally{g(!1)}})(),()=>V.current?.abort()),[G,E,A,R,w]);const q=()=>j(F=>F+1),I=F=>{C(null),l(F),n(!0)},Y=F=>{C(null),u(F),i(!0)};return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:O,onChange:F=>P(F.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:E,onValueChange:T,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All States"}),o.jsx(Se,{value:"true",children:"Active"}),o.jsx(Se,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(ce,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>t(!0),children:["New Multiple Options ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Multiple Option Name"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Option Code"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Contents"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Order"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[180px]",children:"Last Edited"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:p?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):f.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):f.map(F=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"font-medium",children:ZL(F.optionName)}),o.jsx(ye,{className:"text-gray-600",children:ZL(F.optionCode)}),o.jsx(ye,{className:"text-gray-600",children:F.optionValuesJson&&F.optionValuesJson.length>0?F.optionValuesJson.join("; "):"None"}),o.jsx(ye,{children:o.jsx(fn,{className:F.state?"bg-green-600":"bg-gray-400",children:F.state?"Active":"Inactive"})}),o.jsx(ye,{className:"font-numeric",children:F.orderNum??"None"}),o.jsx(ye,{className:"text-gray-500 tabular-nums font-numeric",children:F.creationTime?new Date(F.creationTime).toLocaleString():"None"}),o.jsx(ye,{className:"text-center",children:o.jsxs(ka,{open:N===F.id,onOpenChange:D=>C(D?F.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>I(F),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Y(F),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},F.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",v===0?0:(A-1)*R+1,"-",Math.min(A*R,v)," of ",v]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(R),onValueChange:F=>L(Number(F)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(F=>o.jsxs(Se,{value:String(F),children:[F," / page"]},F))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:F=>{F.preventDefault(),M(D=>Math.max(1,D-1))},"aria-disabled":A<=1,className:A<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:F=>F.preventDefault(),children:["Page ",A," / ",W]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:F=>{F.preventDefault(),M(D=>Math.min(W,D+1))},"aria-disabled":A>=W,className:A>=W?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(tve,{open:e,onOpenChange:t,onCreated:()=>{M(1),q()}}),o.jsx(rve,{open:r,option:s,onOpenChange:F=>{n(F),F||l(null)},onUpdated:q}),o.jsx(nve,{open:a,option:d,onOpenChange:F=>{i(F),F||u(null)},onDeleted:q})]})}function tve({open:e,onOpenChange:t,onCreated:r}){const[n,a]=x.useState(!1),[i,s]=x.useState({optionCode:"",optionName:"",optionValuesJson:[],state:!0,orderNum:null}),[l,d]=x.useState(""),u=()=>{s({optionCode:"",optionName:"",optionValuesJson:[],state:!0,orderNum:null}),d("")};x.useEffect(()=>{e||u()},[e]);const f=()=>{const g=l.trim();if(g){if(i.optionValuesJson.includes(g)){ee.error("Duplicate value",{description:"This value already exists."});return}s(v=>({...v,optionValuesJson:[...v.optionValuesJson,g]})),d("")}},h=g=>{s(v=>({...v,optionValuesJson:v.optionValuesJson.filter((b,w)=>w!==g)}))},p=async()=>{if(!i.optionName.trim()){ee.error("Validation failed",{description:"Option Name is required."});return}if(i.optionValuesJson.length===0){ee.error("Validation failed",{description:"At least one option value is required."});return}if(i.orderNum===null||i.orderNum===void 0||!Number.isFinite(i.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}a(!0);try{await Pye(i),ee.success("Multiple option created.",{description:"The multiple option has been created successfully."}),t(!1),r()}catch(g){ee.error("Failed to create multiple option.",{description:g?.message?String(g.message):"Please try again."})}finally{a(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Add New Multiple Option"}),o.jsx(It,{children:"Enter the details for the new multiple option."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Option Code"}),o.jsx(me,{placeholder:"e.g. OPT_ALLERGENS",value:i.optionCode,onChange:g=>s(v=>({...v,optionCode:g.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Option Name *"}),o.jsx(me,{placeholder:"e.g. Allergens",value:i.optionName,onChange:g=>s(v=>({...v,optionName:g.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Option Values *"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{placeholder:"Enter a value and press Add",value:l,onChange:g=>d(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),f())}}),o.jsx(ce,{type:"button",onClick:f,variant:"outline",children:"Add"})]}),i.optionValuesJson.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:i.optionValuesJson.map((g,v)=>o.jsxs(fn,{variant:"secondary",className:"flex items-center gap-1",children:[g,o.jsx("button",{type:"button",onClick:()=>h(v),className:"ml-1 hover:text-red-600",children:o.jsx($i,{className:"h-3 w-3"})})]},v))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:i.orderNum??"",onChange:g=>s(v=>({...v,orderNum:g.target.value?Number(g.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:i.state,onCheckedChange:g=>s(v=>({...v,state:g}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(ce,{disabled:n,onClick:p,children:n?"Creating...":"Create"})]})]})})}function rve({open:e,option:t,onOpenChange:r,onUpdated:n}){const[a,i]=x.useState(!1),[s,l]=x.useState({optionCode:"",optionName:"",optionValuesJson:[],state:!0,orderNum:null}),[d,u]=x.useState("");x.useEffect(()=>{e&&t&&(l({optionCode:t.optionCode??"",optionName:t.optionName??"",optionValuesJson:t.optionValuesJson??[],state:t.state??!0,orderNum:t.orderNum??null}),u(""))},[e,t]);const f=()=>{const g=d.trim();if(g){if(s.optionValuesJson.includes(g)){ee.error("Duplicate value",{description:"This value already exists."});return}l(v=>({...v,optionValuesJson:[...v.optionValuesJson,g]})),u("")}},h=g=>{l(v=>({...v,optionValuesJson:v.optionValuesJson.filter((b,w)=>w!==g)}))},p=async()=>{if(t?.id){if(!s.optionName.trim()){ee.error("Validation failed",{description:"Option Name is required."});return}if(s.optionValuesJson.length===0){ee.error("Validation failed",{description:"At least one option value is required."});return}if(s.orderNum===null||s.orderNum===void 0||!Number.isFinite(s.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}i(!0);try{await Oye(t.id,s),ee.success("Multiple option updated.",{description:"The multiple option has been updated successfully."}),r(!1),n()}catch(g){ee.error("Failed to update multiple option.",{description:g?.message?String(g.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Edit Multiple Option"}),o.jsx(It,{children:"Update the multiple option details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Option Code"}),o.jsx(me,{placeholder:"e.g. OPT_ALLERGENS",value:s.optionCode,onChange:g=>l(v=>({...v,optionCode:g.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Option Name *"}),o.jsx(me,{placeholder:"e.g. Allergens",value:s.optionName,onChange:g=>l(v=>({...v,optionName:g.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Option Values *"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{placeholder:"Enter a value and press Add",value:d,onChange:g=>u(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),f())}}),o.jsx(ce,{type:"button",onClick:f,variant:"outline",children:"Add"})]}),s.optionValuesJson.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:s.optionValuesJson.map((g,v)=>o.jsxs(fn,{variant:"secondary",className:"flex items-center gap-1",children:[g,o.jsx("button",{type:"button",onClick:()=>h(v),className:"ml-1 hover:text-red-600",children:o.jsx($i,{className:"h-3 w-3"})})]},v))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:s.orderNum??"",onChange:g=>l(v=>({...v,orderNum:g.target.value?Number(g.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:s.state,onCheckedChange:g=>l(v=>({...v,state:g}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:a,onClick:p,children:a?"Updating...":"Update"})]})]})})}function nve({open:e,option:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>(t?.optionName??"").trim()||t?.optionCode||"this option",[t]),l=async()=>{if(t?.id){i(!0);try{await Tye(t.id),ee.success("Multiple option deleted.",{description:"The multiple option has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete multiple option.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Multiple Option"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function ave({currentView:e="Labels",onViewChange:t,labelCreateOpenSeq:r=0,onLabelCreateIntentConsumed:n,onLabelTemplateEditorLayoutOverlay:a}){const[i,s]=x.useState(!1),l=x.useCallback(f=>{s(f),a?.(f)},[a]),d=["Labels","Label Categories","Label Types","Label Templates","Multiple Options"],u=f=>{t&&t(f)};return o.jsxs("div",{className:`flex h-full min-h-0 flex-col ${i?"gap-0":"gap-6"}`,children:[!i&&o.jsx("div",{className:"w-full shrink-0 border-b border-gray-200",children:o.jsx("div",{className:"flex overflow-x-auto bg-white",children:d.map(f=>o.jsx("div",{onClick:()=>u(f),style:e===f?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:`px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px ${e===f?"text-blue-600":"border-b-2 border-b-transparent text-gray-600 hover:text-gray-800"}`,children:f},f))})}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e==="Labels"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(Wge,{openCreateSeq:r,onOpenCreateIntentConsumed:n})}),e==="Label Categories"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(pye,{})}),e==="Label Types"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(xye,{})}),e==="Label Templates"&&o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:o.jsx(Qye,{onTemplateEditorOverlayChange:l})}),e==="Multiple Options"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(eve,{})}),!["Labels","Label Categories","Label Types","Label Templates","Multiple Options"].includes(e)&&o.jsxs("div",{className:"flex h-64 items-center justify-center text-gray-400",children:[e," content coming soon..."]})]})]})}function ove(){const[e,t]=x.useState([{id:"1",name:"Pop",isOpen:!0,subcategories:[{id:"1-1",name:"2024",isOpen:!0,files:[{id:"f1",name:"uuuuu",date:"10/23/24, 12:21 AM",type:"image"},{id:"f2",name:"664EF167-DFCE-49C1-A417-DC09FEDF78D7.jpg",date:"11/24/25, 8:40 PM",type:"image"}]}]},{id:"2",name:"Training",isOpen:!0,subcategories:[{id:"2-1",name:"BOH",isOpen:!1,files:[]},{id:"2-2",name:"FOH",isOpen:!0,files:[]}]},{id:"3",name:"ww",isOpen:!1,subcategories:[]}]),r=a=>{t(i=>i.map(s=>s.id===a?{...s,isOpen:!s.isOpen}:s))},n=(a,i)=>{t(s=>s.map(l=>l.id!==a?l:{...l,subcategories:l.subcategories.map(d=>d.id===i?{...d,isOpen:!d.isOpen}:d)}))};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(me,{className:"bg-white border border-black rounded-md h-10 w-[150px]"}),o.jsx("span",{className:"text-sm text-black whitespace-nowrap",children:"Search"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs($e,{defaultValue:"all",children:[o.jsx(Be,{className:"bg-white border border-black rounded-md h-10 w-[100px]",children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"all"}),o.jsx(Se,{value:"loc-a",children:"Location A"})]})]}),o.jsx("span",{className:"text-sm text-black whitespace-nowrap",children:"Location"})]})]}),o.jsxs("div",{className:"bg-gray-100 p-2 flex justify-between items-center border-b border-gray-200",children:[o.jsx("h1",{className:"text-xl font-medium text-gray-700",children:"Information"}),o.jsxs("div",{className:"flex items-center gap-4 text-gray-600",children:[o.jsx("div",{className:"flex items-center gap-1 bg-gray-700 text-white text-[10px] px-1 py-0.5 rounded-sm font-bold",children:"NEW"}),o.jsx(t7,{className:"h-5 w-5"}),o.jsx("span",{className:"font-medium",children:"55789"})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("button",{className:"w-full bg-[#2c7bb6] hover:bg-[#256b9e] text-white py-2 px-4 flex items-center gap-2 text-sm font-medium rounded-sm",children:[o.jsx(Un,{className:"h-4 w-4"}),"New Category",o.jsx(Wd,{className:"h-4 w-4 opacity-70"})]}),o.jsx("div",{className:"space-y-4",children:e.map(a=>o.jsxs("div",{className:"border border-gray-300 rounded-sm overflow-hidden",children:[o.jsxs("div",{className:"bg-gradient-to-b from-gray-50 to-gray-100 border-b border-gray-200 p-2 flex items-center justify-between",children:[o.jsxs("button",{onClick:()=>r(a.id),className:"flex items-center gap-2 text-gray-700 font-medium text-sm flex-1 text-left",children:[a.isOpen?o.jsx(Bs,{className:"h-4 w-4 text-[#2c7bb6]"}):o.jsx(Ui,{className:"h-4 w-4 text-[#2c7bb6]"}),a.name]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:o.jsx(Rp,{className:"h-4 w-4"})}),o.jsx("button",{className:"text-red-400 hover:text-red-600",children:o.jsx($i,{className:"h-4 w-4"})})]})]}),a.isOpen&&o.jsxs("div",{className:"p-2 space-y-3 bg-white",children:[o.jsxs("button",{className:"w-full bg-[#2c7bb6] hover:bg-[#256b9e] text-white py-2 px-4 flex items-center gap-2 text-sm font-medium rounded-sm",children:[o.jsx(Un,{className:"h-4 w-4"}),"New Subcategory",o.jsx(Wd,{className:"h-4 w-4 opacity-70"})]}),o.jsxs("div",{className:"space-y-3",children:[a.subcategories.map(i=>o.jsxs("div",{className:"border border-gray-200 rounded-sm",children:[o.jsxs("div",{className:"bg-white border-b border-gray-200 p-2 flex items-center justify-between",children:[o.jsxs("button",{onClick:()=>n(a.id,i.id),className:"flex items-center gap-2 text-gray-700 font-medium text-sm flex-1 text-left",children:[i.isOpen?o.jsx(Bs,{className:"h-4 w-4 text-[#2c7bb6]"}):o.jsx(Ui,{className:"h-4 w-4 text-[#2c7bb6]"}),i.name]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:o.jsx(Rp,{className:"h-4 w-4"})}),o.jsx("button",{className:"text-red-400 hover:text-red-600",children:o.jsx($i,{className:"h-4 w-4"})})]})]}),i.isOpen&&o.jsxs("div",{className:"p-3 bg-gray-50/50",children:[o.jsx("div",{className:"mb-2 text-xs font-bold text-gray-500 uppercase tracking-wide",children:"Files"}),o.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 justify-end",children:[o.jsx(ce,{size:"sm",className:"h-8 bg-[#4CAF50] hover:bg-[#43a047] text-white text-xs border-none rounded-sm",children:"Upload Your Own File(s)"}),o.jsx(ce,{size:"sm",className:"h-8 bg-[#4CAF50] hover:bg-[#43a047] text-white text-xs border-none rounded-sm",children:"Create A Custom File"}),o.jsx(ce,{size:"sm",className:"h-8 bg-[#2c7bb6] hover:bg-[#256b9e] text-white text-xs border-none rounded-sm",children:"Edit File Permissions"}),o.jsxs(ce,{size:"sm",className:"h-8 bg-[#2c7bb6] hover:bg-[#256b9e] text-white text-xs border-none rounded-sm gap-1",children:["Sort (A-Z) ",o.jsx(tq,{className:"h-3 w-3"})]})]}),o.jsx("div",{className:"space-y-1",children:i.files.length>0?i.files.map(s=>o.jsxs("div",{className:"flex items-center bg-gray-200/50 p-2 border border-gray-200 rounded-sm text-sm hover:bg-gray-200 transition-colors",children:[o.jsx("div",{className:"flex-shrink-0 mr-3",children:s.type==="image"?o.jsx(lC,{className:"h-5 w-5 text-[#2c7bb6]"}):o.jsx(zs,{className:"h-5 w-5 text-[#2c7bb6]"})}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"font-medium text-gray-700 truncate",children:s.name})}),o.jsx("div",{className:"text-xs text-gray-500 mr-4 whitespace-nowrap",children:s.date}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{className:"p-1 text-gray-400 hover:text-gray-600 bg-white border border-gray-300 rounded-sm",children:o.jsx(zs,{className:"h-3 w-3"})}),o.jsx("button",{className:"p-1 text-gray-400 hover:text-gray-600 bg-white border border-gray-300 rounded-sm",children:o.jsx(Rp,{className:"h-3 w-3"})}),o.jsx("button",{className:"p-1 text-red-400 hover:text-red-600 bg-white border border-gray-300 rounded-sm",children:o.jsx($i,{className:"h-3 w-3"})})]})]},s.id)):o.jsx("div",{className:"p-4 border-2 border-dashed border-gray-300 rounded-sm text-center text-gray-400 text-sm",children:"No files in this subcategory"})})]})]},i.id)),a.subcategories.length===0&&o.jsx("div",{className:"p-2 text-sm text-gray-400 italic",children:"No subcategories"})]})]})]},a.id))})]})]})}const ive=[{id:1,title:"Coffee - 2 hrs",subtitle:"1 min - Completes at 12:05 PM",totalTime:7200,remainingTime:0,status:"expired",icon:vq},{id:2,title:"Clean Tablet",subtitle:"1 hrs - Completes at 12:37 PM",totalTime:3600,remainingTime:237,status:"running",icon:a7},{id:3,title:"Replace Sanitizer Towels",subtitle:"1 hrs - Completes at 12:37 PM",totalTime:3600,remainingTime:238,status:"running",icon:zt},{id:4,title:"Take Out Trash",subtitle:"1 hrs - Completes at 01:03 PM",totalTime:3600,remainingTime:58,status:"running",icon:zt},{id:5,title:"Change Utensils",subtitle:"1 hrs - Completes at 01:03 PM",totalTime:3600,remainingTime:58,status:"running",icon:v7},{id:6,title:"Sanitize Surfaces",subtitle:"1 hrs - Completes at 02:00 PM",totalTime:3600,remainingTime:2157,status:"running",icon:Px},{id:7,title:"Check Temperatures",subtitle:"1 hrs - Completes at 02:00 PM",totalTime:3600,remainingTime:2158,status:"running",icon:Px},{id:8,title:"Ranch 4 hrs",subtitle:"4 hrs - Completes at 04:04 PM",totalTime:14400,remainingTime:2158,status:"running",icon:Px}];function sve({timer:e}){const t=(e.totalTime-e.remainingTime)/e.totalTime*100,r=e.remainingTime===0,n=a=>{if(a<=0)return"0s";const i=Math.floor(a/60),s=a%60;return`${i.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`};return o.jsxs("div",{className:"bg-gray-200 rounded-xl p-4 flex flex-col items-center relative shadow-sm h-[280px]",children:[o.jsxs("div",{className:"text-center mb-2",children:[o.jsx("h3",{className:"text-lg font-medium text-gray-800 leading-tight",children:e.title}),o.jsx("p",{className:"text-xs text-gray-500 mt-1",children:e.subtitle})]}),o.jsxs("div",{className:"relative w-32 h-32 my-auto flex items-center justify-center",children:[o.jsxs("svg",{className:"w-full h-full transform -rotate-90",children:[o.jsx("circle",{cx:"64",cy:"64",r:"56",stroke:"white",strokeWidth:"12",fill:"transparent"}),o.jsx("circle",{cx:"64",cy:"64",r:"56",stroke:r?"#ef4444":"#3b82f6",strokeWidth:"12",fill:"transparent",strokeDasharray:351.86,strokeDashoffset:r?0:351.86*(t/100),className:"transition-all duration-1000 ease-linear"})]}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsx("span",{className:Ie("text-3xl font-bold",r?"text-red-500":"text-gray-800"),children:r?"0s":n(e.remainingTime)}),o.jsx("span",{className:Ie("text-[10px] font-medium uppercase mt-1",r?"text-red-400":"text-gray-400"),children:"Remaining"})]})]}),o.jsxs("div",{className:"w-full flex justify-between items-end mt-2",children:[o.jsx(Uq,{className:"w-5 h-5 text-blue-700 fill-current"}),o.jsx("div",{className:"flex flex-col items-center",children:o.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-gray-300 flex items-center justify-center text-gray-400 mb-1",children:o.jsx(e.icon,{className:"w-5 h-5"})})}),o.jsx("div",{className:"flex flex-col items-end",children:o.jsx("span",{className:"text-xs text-blue-600 font-bold mb-2 cursor-pointer",children:"EDIT"})})]}),o.jsx("button",{className:"absolute bottom-12 right-4 bg-blue-600 rounded-full p-1 text-white hover:bg-blue-700 shadow-md",children:o.jsx($i,{className:"w-4 h-4"})})]})}function lve(){const[e,t]=x.useState(!0);return o.jsxs("div",{className:"h-full flex flex-col bg-gray-50 relative",children:[o.jsxs("div",{className:"bg-white border-b border-gray-200 px-4 py-3 flex items-center justify-between shadow-sm z-10",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("button",{className:"flex items-center text-blue-500 text-lg font-medium",children:[o.jsx(oC,{className:"w-6 h-6"}),"Back"]}),o.jsx(Rq,{className:"w-6 h-6 text-gray-500"})]}),o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"bg-blue-600 p-1.5 rounded-md",children:o.jsx(s7,{className:"w-5 h-5 text-white"})}),o.jsx("h1",{className:"text-xl font-bold text-blue-900",children:"Timers"})]}),o.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 font-medium",children:[o.jsx("span",{children:"86016"}),o.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"})]})]}),o.jsxs("div",{className:"flex items-center gap-4 text-blue-500 font-medium",children:[o.jsx(p7,{className:"w-6 h-6 text-gray-400"}),o.jsxs("button",{className:"flex items-center gap-1",children:[o.jsx(Un,{className:"w-5 h-5"}),"Add Timer"]})]})]}),o.jsxs("div",{className:"bg-gray-700 text-white px-6 py-2 flex items-center justify-between",children:[o.jsx("div",{className:"flex-1"})," ",o.jsx("div",{className:"font-medium",children:"Today, December 15"}),o.jsxs("div",{className:"flex-1 flex justify-end items-center gap-4",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Nq,{className:"w-5 h-5 text-gray-300"}),o.jsx(Oq,{className:"w-5 h-5 text-gray-500"})]}),o.jsx(X9,{className:"w-5 h-5 text-blue-400"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:ive.map(r=>o.jsx(sve,{timer:r},r.id))})}),e&&o.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[1px]",children:o.jsx("div",{className:"bg-black text-white rounded-xl shadow-2xl w-[600px] max-w-full overflow-hidden border border-gray-800",children:o.jsxs("div",{className:"p-8 text-center space-y-6",children:[o.jsx("h2",{className:"text-3xl font-medium text-blue-500",children:"Coffee - 2 hrs"}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("p",{className:"text-2xl font-light",children:"Timer expired at 12:05 PM"}),o.jsx("p",{className:"text-2xl font-light",children:"Please discard the coffee"})]}),o.jsx("div",{className:"flex justify-end",children:o.jsx("span",{className:"bg-gray-200 text-black text-[10px] px-1 rounded-sm opacity-50",children:"TACT_Img_Timer-Notification@2x"})}),o.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-8",children:[o.jsx(ce,{onClick:()=>t(!1),className:"bg-blue-700 hover:bg-blue-600 text-white h-14 text-xl font-medium rounded-lg",children:"Mute"}),o.jsx(ce,{onClick:()=>t(!1),className:"bg-blue-600 hover:bg-blue-500 text-white h-14 text-xl font-medium rounded-lg",children:"Restart"}),o.jsx(ce,{onClick:()=>t(!1),className:"bg-blue-800 hover:bg-blue-700 text-white h-14 text-xl font-medium rounded-lg",children:"Acknowledge"})]})]})})})]})}const J6=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Q6="/product-location";function cve(e){const t=e;return{id:t?.id??t?.Id,locationId:t?.locationId??t?.LocationId,productId:t?.productId??t?.ProductId}}async function uve(e,t){const r=await J6.requestJson({path:Q6,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,LocationId:e.locationId,ProductId:e.productId},signal:t});return{...r,items:(r.items??[]).map(n=>cve(n))}}async function dve(e,t){const r=await J6.requestJson({path:`${Q6}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Array.isArray(r?.productIds)?r.productIds.map(String):Array.isArray(r?.items)?(r.items??[]).map(n=>n?.productId).filter(n=>typeof n=="string"&&n.length>0):[]}function fve(e){const t=new Set,r=[];for(const n of e){const a=n.trim();!a||t.has(a)||(t.add(a),r.push(a))}return r}function hve({values:e,onValuesChange:t,options:r,placeholder:n="Select…",searchPlaceholder:a="Search…",emptyText:i="No matching results.",disabled:s,className:l}){const[d,u]=x.useState(!1),[f,h]=x.useState(""),p=x.useMemo(()=>fve(e),[e]),g=x.useMemo(()=>{const j=f.trim().toLowerCase();return j?r.filter(N=>N.label.toLowerCase().includes(j)||N.value.toLowerCase().includes(j)):r},[r,f]),v=x.useMemo(()=>{const j=new Map;for(const N of r)j.set(N.value,N.label);return j},[r]),b=x.useMemo(()=>{if(p.length===0)return null;if(p.length===1)return v.get(p[0])??p[0];const j=v.get(p[0])??p[0],N=v.get(p[1])??p[1];return p.length===2?`${j}, ${N}`:`${j}, ${N} +${p.length-2}`},[p,v]),w=j=>{const N=j.trim();N&&(p.includes(N)?t(p.filter(C=>C!==N)):t([...p,N]))};return o.jsxs(ka,{open:d,onOpenChange:j=>{u(j),j||h("")},children:[o.jsx(Aa,{asChild:!0,children:o.jsxs(ce,{type:"button",variant:"outline",role:"combobox","aria-expanded":d,disabled:s,className:Ie("h-auto min-h-10 w-full justify-between px-3 py-2 font-normal border border-gray-300 bg-white",l),children:[o.jsx("span",{className:Ie("line-clamp-2 text-left text-sm",!b&&"text-gray-500"),children:b??n}),o.jsx(N$,{className:"ml-2 h-4 w-4 shrink-0 self-center opacity-50"})]})}),o.jsxs(Ia,{className:"w-[var(--radix-popover-trigger-width)] max-w-[min(100vw-2rem,400px)] p-0",align:"start",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-100 px-2 py-2",children:[o.jsx(Rf,{className:"h-4 w-4 shrink-0 text-gray-400"}),o.jsx(me,{value:f,onChange:j=>h(j.target.value),placeholder:a,className:"h-8 border-0 bg-transparent px-0 text-sm shadow-none focus-visible:ring-0"})]}),o.jsx("div",{className:"max-h-[min(240px,50vh)] overflow-y-auto p-1",children:g.length===0?o.jsx("div",{className:"px-2 py-6 text-center text-sm text-gray-500",children:i}):g.map(j=>o.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-sm hover:bg-gray-100",children:[o.jsx(Co,{checked:p.includes(j.value),onCheckedChange:()=>w(j.value),onClick:N=>N.stopPropagation()}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label})]},j.value))}),p.length>0?o.jsx("div",{className:"border-t border-gray-100 px-2 py-1.5",children:o.jsxs("button",{type:"button",className:"text-xs text-gray-500 underline-offset-2 hover:text-gray-900 hover:underline",onClick:()=>{t([]),h("")},children:["Clear all (",p.length,")"]})}):null]})]})}function sE({open:e,onOpenChange:t,title:r,description:n,onDownloadTemplate:a,onImportFile:i,downloadingTemplate:s=!1}){const l=x.useRef(null),[d,u]=x.useState(null),[f,h]=x.useState(!1),p=()=>{u(null),l.current&&(l.current.value="")};return o.jsx(_t,{open:e,onOpenChange:g=>{g||p(),t(g)},children:o.jsxs(Ct,{className:"sm:max-w-md",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:r}),n?o.jsx(It,{children:n}):null]}),o.jsx("div",{className:"flex flex-col gap-4 py-2",children:o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{htmlFor:"batch-import-file",children:"Excel file (.xlsx)"}),o.jsx("input",{id:"batch-import-file",ref:l,type:"file",accept:".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",className:"block w-full text-sm text-gray-700 file:mr-3 file:rounded-md file:border file:border-gray-300 file:bg-white file:px-3 file:py-2 file:text-sm file:font-medium file:text-gray-900 hover:file:bg-gray-50",onChange:g=>{const v=g.target.files?.[0]??null;u(v)}})]})}),o.jsx("div",{className:"flex justify-center pb-2",children:o.jsx(ce,{type:"button",variant:"outline",className:"w-full sm:w-auto",disabled:s,onClick:()=>void a(),children:s?"Downloading…":"Download template"})}),o.jsxs(Dt,{className:"gap-2 sm:gap-0",children:[o.jsx(ce,{type:"button",variant:"outline",onClick:()=>{p(),t(!1)},children:"Cancel"}),o.jsx(ce,{type:"button",disabled:!d||f,onClick:async()=>{if(d){h(!0);try{const g=await i(d);ee.success("Import finished",{description:`Success: ${g.successCount}, failed: ${g.failCount}`}),p(),t(!1)}catch(g){const v=g instanceof Yr||g instanceof Error?g.message:"Import failed.";ee.error("Import failed",{description:v})}finally{h(!1)}}},children:f?"Importing…":"Import"})]})]})})}function mve(e){return!!(e??"").trim()}function pve(e,t){return{id:e.id,productCode:e.productCode??"",productName:(e.productName??"").trim(),categoryId:(e.categoryId??"").trim()||null,productImageUrl:e.productImageUrl??null,state:e.state!==!1,locationIds:[...t]}}function gve(){return{id:"",productCode:"",productName:"",categoryId:null,productImageUrl:null,state:!0,locationIds:[]}}function e$(e){return e.split(/[,;|\s]+/).map(t=>t.trim()).filter(Boolean)}function yve({open:e,onOpenChange:t,seed:r,categories:n,onSaved:a}){const[i,s]=x.useState([]),[l,d]=x.useState(!1),[u,f]=x.useState([]),h=x.useMemo(()=>Math.max(r.length+10,10),[r.length]);x.useEffect(()=>{if(!e)return;const w=r.map(C=>pve(C,C.locationIds??[])),j=Math.max(0,h-w.length),N=[...w,...Array.from({length:j},()=>gve())];s(N),f(N.map(C=>C.locationIds&&C.locationIds.length?C.locationIds.join(","):""))},[e,r,h]);const p=(w,j)=>{s(N=>{const C=[...N];return C[w]={...C[w],...j},C})},g=w=>{s(j=>j.length<=1?j:j.filter((N,C)=>C!==w)),f(j=>j.length<=1?j:j.filter((N,C)=>C!==w))},v=(w,j)=>{const N=[...u];N[w]=j,f(N),p(w,{locationIds:e$(j)})},b=async()=>{const w=i.filter(j=>mve(j.id)).map((j,N)=>({id:j.id.trim(),productCode:String(j.productCode??"").trim()||null,productName:j.productName.trim(),categoryId:j.categoryId?.trim()?j.categoryId.trim():null,productImageUrl:j.productImageUrl?.trim()?j.productImageUrl.trim():null,state:j.state!==!1,locationIds:e$(u[N]??"")}));if(w.length===0){ee.error("No valid rows",{description:"Select products in the list first."});return}d(!0);try{const j=await ape({items:w});ee.success("Bulk update finished",{description:`Success: ${j.successCount}, failed: ${j.failCount}`}),a(),t(!1)}catch(j){const N=j instanceof Yr||j instanceof Error?j.message:"Save failed.";ee.error("Bulk save failed",{description:N})}finally{d(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"max-w-[min(96vw,1100px)] w-full max-h-[90vh] flex flex-col gap-0 p-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-gray-200 shrink-0",children:[o.jsx(ce,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Back"}),o.jsxs(Et,{className:"flex-1 text-center space-y-0 py-0",children:[o.jsx(Pt,{className:"text-base",children:"Product bulk edit"}),o.jsx(It,{className:"sr-only",children:"Edit products in a grid and save all."})]}),o.jsx(ce,{type:"button",className:"bg-green-600 hover:bg-green-700 text-white shrink-0",disabled:l,onClick:()=>void b(),children:l?"Saving…":"Save All"})]}),o.jsx("div",{className:"overflow-auto flex-1 min-h-0 px-2 py-3",children:o.jsxs("table",{className:"w-full text-xs border-collapse border border-gray-200",children:[o.jsx("thead",{className:"bg-gray-100 sticky top-0 z-10",children:o.jsxs("tr",{children:[o.jsx("th",{className:"border p-1 w-8"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Product Code"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Product *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Category"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Image URL"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location IDs"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Active"})]})}),o.jsx("tbody",{children:i.map((w,j)=>o.jsxs("tr",{children:[o.jsx("td",{className:"border p-0 text-center align-top",children:o.jsxs("div",{className:"flex flex-col items-center gap-1 py-1",children:[o.jsx("span",{className:"text-[10px] text-gray-500",children:j+1}),o.jsx(ce,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1",onClick:()=>g(j),children:"×"})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs",value:w.productCode??"",onChange:N=>p(j,{productCode:N.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[120px]",value:w.productName,onChange:N=>p(j,{productName:N.target.value})})}),o.jsx("td",{className:"border p-1 align-top min-w-[140px]",children:o.jsxs($e,{value:w.categoryId??"__none__",onValueChange:N=>p(j,{categoryId:N==="__none__"?null:N}),children:[o.jsx(Be,{className:"h-7 text-xs",children:o.jsx(Fe,{placeholder:"Category"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"__none__",children:"(none)"}),n.map(N=>o.jsx(Se,{value:N.id,children:N.categoryName??N.id},N.id))]})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[140px]",value:w.productImageUrl??"",onChange:N=>p(j,{productImageUrl:N.target.value||null})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[160px]",value:u[j]??"",onChange:N=>v(j,N.target.value),placeholder:"id1,id2"})}),o.jsx("td",{className:"border p-1 text-center align-middle",children:o.jsx(br,{checked:w.state!==!1,onCheckedChange:N=>p(j,{state:!!N})})})]},`${w.id||"e"}-${j}`))})]})}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 text-center text-xs text-gray-500 shrink-0 space-y-1",children:[o.jsx("p",{children:"Columns with * are required for saved rows."}),o.jsx("p",{children:"Location IDs: comma-separated location primary keys (GUID)."})]})]})})}function Mn(e){const t=(e??"").trim();return t||"—"}async function vve(e){const t=new Map;try{const r=await uve({skipCount:1,maxResultCount:2e3},e);for(const n of r.items??[]){const a=(n.productId??"").trim(),i=(n.locationId??"").trim();if(!a||!i)continue;t.has(a)||t.set(a,[]);const s=t.get(a);s.includes(i)||s.push(i)}}catch{}return t}function t$(e,t){const r=new Map(e);for(const n of t)Array.isArray(n.locationIds)&&r.set(n.id,[...new Set(n.locationIds.map(a=>String(a).trim()).filter(Boolean))]);return r}function xve(){const[e,t]=x.useState("products"),[r,n]=x.useState([]),[a,i]=x.useState(0),[s,l]=x.useState(!1),[d,u]=x.useState(new Map),[f,h]=x.useState([]),[p,g]=x.useState([]),[v,b]=x.useState(0),[w,j]=x.useState([]),[N,C]=x.useState(0),[O,P]=x.useState(!1),[E,T]=x.useState(1),[A,M]=x.useState(10),[R,L]=x.useState(0),V=x.useRef(null),[z,G]=x.useState(""),[H,W]=x.useState(""),q=x.useRef(null),[I,Y]=x.useState("all"),[F,D]=x.useState("all"),[$,K]=x.useState("all"),[J,oe]=x.useState(1),[re,Q]=x.useState(10),[ue,se]=x.useState(0),fe=x.useRef(null),[we,Z]=x.useState(!1),[je,Ce]=x.useState(!1),[qe,De]=x.useState(null),[He,ne]=x.useState(null),[pe,_e]=x.useState(null),[ve,ke]=x.useState(null),[Ge,xe]=x.useState(null),[Je,dt]=x.useState(null),[jt,Wt]=x.useState(()=>new Set),[er,Ae]=x.useState(!1),[pt,Ot]=x.useState(!1),[Qt,Ar]=x.useState([]),[Vn,Jr]=x.useState(!1),[Ur,Er]=x.useState(!1);x.useEffect(()=>(q.current&&window.clearTimeout(q.current),q.current=window.setTimeout(()=>W(z.trim()),300),()=>{q.current&&window.clearTimeout(q.current)}),[z]),x.useEffect(()=>{let be=!1;return(async()=>{try{const[Le,rt]=await Promise.all([Nu({skipCount:1,maxResultCount:500}),KN({skipCount:1,maxResultCount:500,sorting:"OrderNum desc"})]);if(be)return;h(Le.items??[]),g(rt.items??[])}catch{be||(h([]),g([]))}})(),()=>{be=!0}},[v]);const qt=()=>b(be=>be+1);x.useEffect(()=>{oe(1)},[H,I,F,$,re]),x.useEffect(()=>{T(1)},[H,$,A]);const gr=I!=="all"||F!=="all";x.useEffect(()=>e!=="products"?void 0:((async()=>{fe.current?.abort();const Le=new AbortController;fe.current=Le,l(!0);try{const rt=await vve(Le.signal);if(Le.signal.aborted)return;if(gr){const Xt=await sy({skipCount:1,maxResultCount:500,keyword:H||void 0,state:$==="all"?void 0:$==="true"},Le.signal);if(Le.signal.aborted)return;let vt=Xt.items??[];if(I!=="all"){const Ir=new Set(await dve(I));vt=vt.filter(Ao=>Ir.has(Ao.id))}F!=="all"&&(vt=vt.filter(Ir=>(Ir.categoryId??"").trim()===F));const hr=vt.length;i(hr);const Qr=(J-1)*re;n(vt.slice(Qr,Qr+re)),u(t$(rt,vt))}else{const Xt=Qa(J),vt=await sy({skipCount:Xt,maxResultCount:re,keyword:H||void 0,state:$==="all"?void 0:$==="true"},Le.signal);if(Le.signal.aborted)return;const hr=vt.items??[];n(hr),i(vt.totalCount??0),u(t$(rt,hr))}}catch(rt){if(rt?.name==="AbortError")return;ee.error("Failed to load products",{description:rt?.message?String(rt.message):"Please try again."}),n([]),i(0)}finally{Le.signal.aborted||l(!1)}})(),()=>fe.current?.abort()),[e,H,I,F,$,J,re,ue,gr]);const Kt=Math.max(1,Math.ceil(N/A)||1);x.useEffect(()=>{T(be=>{const Le=Math.max(1,Math.ceil(N/A)||1);return be>Le?Le:be})},[N,A]),x.useEffect(()=>e!=="categories"?void 0:((async()=>{V.current?.abort();const Le=new AbortController;V.current=Le,P(!0);try{const rt=Qa(E),Xt=await KN({skipCount:rt,maxResultCount:A,sorting:"OrderNum desc",keyword:H||void 0,state:$==="all"?void 0:$==="true"},Le.signal);if(Le.signal.aborted)return;j(Xt.items??[]),C(Xt.totalCount??0)}catch(rt){if(rt?.name==="AbortError")return;ee.error("Failed to load categories",{description:rt?.message?String(rt.message):"Please try again."}),j([]),C(0)}finally{Le.signal.aborted||P(!1)}})(),()=>V.current?.abort()),[e,H,$,E,A,R]);const fr=()=>se(be=>be+1);x.useEffect(()=>{Wt(new Set)},[H,I,F,$,J]);const tr=()=>{L(be=>be+1),qt()},Qe=x.useMemo(()=>f.map(be=>({value:be.id,label:Mn(be.locationName??be.locationCode??be.id)})),[f]),Tt=x.useMemo(()=>p.map(be=>({value:(be.id??"").trim(),label:Mn(be.categoryName??be.categoryCode??be.id)})).filter(be=>be.value),[p]),Lt=Math.max(1,Math.ceil(a/re)),sr=x.useCallback(be=>{const Le=f.find(rt=>rt.id===be);return Mn(Le?.locationName??Le?.locationCode??be)},[f]);return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"pb-4",children:[o.jsx("div",{className:"flex flex-col gap-3",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsxs("div",{className:"flex items-center w-40 shrink-0 rounded-md border border-gray-300 bg-white overflow-hidden",style:{height:40},children:[o.jsx(Rf,{className:"h-4 w-4 text-gray-400 shrink-0 ml-2.5 pointer-events-none"}),o.jsx(me,{placeholder:"Search...",value:z,onChange:be=>G(be.target.value),className:"flex-1 min-w-0 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 py-2 px-2 h-full placeholder:text-gray-500"})]}),o.jsxs($e,{value:"all",disabled:!0,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0 opacity-70",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Partner"})}),o.jsx(ze,{children:o.jsx(Se,{value:"all",children:"All partners"})})]}),o.jsxs($e,{value:"all",disabled:!0,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0 opacity-70",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Group"})}),o.jsx(ze,{children:o.jsx(Se,{value:"all",children:"All groups"})})]}),o.jsxs($e,{value:I,onValueChange:Y,children:[o.jsx(Be,{className:"w-[160px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All Locations"}),f.map(be=>o.jsx(Se,{value:be.id,children:Mn(be.locationName??be.locationCode??be.id)},be.id))]})]}),o.jsxs($e,{value:F,onValueChange:D,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Category"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All Categories"}),Tt.map(be=>o.jsx(Se,{value:be.value,children:be.label},be.value))]})]}),o.jsxs($e,{value:$,onValueChange:K,children:[o.jsx(Be,{className:"w-[120px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All states"}),o.jsx(Se,{value:"true",children:"Active"}),o.jsx(Se,{value:"false",children:"Inactive"})]})]})]})}),o.jsx("div",{className:"w-full border-b border-gray-200 mt-4",children:o.jsxs("div",{className:"flex overflow-x-auto w-fit",children:[o.jsx("button",{type:"button",onClick:()=>t("products"),style:e==="products"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:`px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2 ${e==="products"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"}`,children:"Products"}),o.jsx("button",{type:"button",onClick:()=>t("categories"),style:e==="categories"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:`px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2 ${e==="categories"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"}`,children:"Categories"})]})})]}),o.jsxs("div",{className:"flex-1 overflow-auto pt-6 flex flex-col min-h-0",children:[o.jsxs("div",{className:"flex flex-nowrap items-center justify-end gap-3 min-w-0 overflow-x-auto pb-0.5 mb-3 shrink-0 [scrollbar-width:thin]",children:[e==="products"&&o.jsxs(o.Fragment,{children:[o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",onClick:()=>Ae(!0),children:[o.jsx(h7,{className:"w-4 h-4"})," Bulk Import"]}),o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",disabled:Ur,onClick:async()=>{Er(!0);try{await rpe({keyword:H||void 0,state:$==="all"?void 0:$==="true"}),ee.success("Export started",{description:"Your browser should download the Excel file."})}catch(be){const Le=be instanceof Error?be.message:"Please try again.";ee.error("Export failed",{description:Le})}finally{Er(!1)}},children:[o.jsx(iC,{className:"w-4 h-4"})," ",Ur?"Exporting…":"Bulk Export"]}),o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",onClick:()=>{const be=r.filter(Le=>jt.has(Le.id)).map(Le=>({...Le,locationIds:d.get(Le.id)??Le.locationIds??[]}));if(be.length===0){ee.error("No rows selected",{description:"Use the checkboxes on the left, then open Bulk Edit."});return}Ar(be),Ot(!0)},children:[o.jsx(oa,{className:"w-4 h-4"})," Bulk Edit"]})]}),e==="products"?o.jsxs(ce,{className:"h-10 rounded-md bg-blue-600 text-white hover:bg-blue-700 font-medium gap-1 shrink-0",onClick:()=>{ke(null),Z(!0)},children:["New Product ",o.jsx(Un,{className:"w-4 h-4"})]}):o.jsxs(ce,{className:"h-10 rounded-md bg-blue-600 text-white hover:bg-blue-700 font-medium gap-1 shrink-0",onClick:()=>{De(null),Ce(!0)},children:["New Category ",o.jsx(Un,{className:"w-4 h-4"})]})]}),e==="products"?o.jsxs("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r w-10 text-center whitespace-nowrap",children:o.jsx(Co,{checked:r.length>0&&r.every(be=>jt.has(be.id)),onCheckedChange:be=>{Wt(be===!0?new Set(r.map(Le=>Le.id)):new Set)},"aria-label":"Select all on page"})}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Location"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product Category"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product ID"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product Code"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Status"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center whitespace-nowrap",children:"Actions"})]})}),o.jsx(pn,{children:s?o.jsx(nt,{children:o.jsx(ye,{colSpan:8,className:"text-center text-gray-500 py-10",children:"Loading..."})}):r.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:8,className:"text-center text-gray-500 py-10",children:"No products found."})}):r.map(be=>{const Le=d.get(be.id)??[],rt=Le.length===0?"—":Le.map(vt=>sr(vt)).join(", "),Xt=be.state!==!1;return o.jsxs(nt,{children:[o.jsx(ye,{className:"border-r w-10 text-center",children:o.jsx(Co,{checked:jt.has(be.id),onCheckedChange:vt=>{Wt(hr=>{const Qr=new Set(hr);return vt===!0?Qr.add(be.id):Qr.delete(be.id),Qr})},"aria-label":"Select row"})}),o.jsx(ye,{className:"border-r text-sm max-w-[200px] truncate",title:rt,children:rt}),o.jsx(ye,{className:"border-r text-gray-900 font-medium whitespace-nowrap",children:Mn(be.categoryName)}),o.jsx(ye,{className:"border-r text-gray-900 font-medium",children:o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[be.productImageUrl?o.jsx("img",{src:Tf(be.productImageUrl),alt:"",className:"w-8 h-8 rounded object-cover border border-gray-200 shrink-0"}):o.jsx(jc,{className:"w-4 h-4 text-gray-400 shrink-0"}),o.jsx("span",{className:"truncate",children:Mn(be.productName)})]})}),o.jsx(ye,{className:"border-r font-mono text-sm text-gray-600 whitespace-nowrap",children:be.id}),o.jsx(ye,{className:"border-r font-mono text-sm text-gray-600 whitespace-nowrap",children:Mn(be.productCode)}),o.jsx(ye,{className:"border-r whitespace-nowrap",children:o.jsx(fn,{variant:Xt?"default":"secondary",className:Xt?"bg-green-600":"bg-gray-400",children:Xt?"active":"inactive"})}),o.jsx(ye,{className:"text-center whitespace-nowrap",children:o.jsxs(ka,{open:Je===be.id,onOpenChange:vt=>dt(vt?be.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",children:o.jsx(ri,{className:"h-4 w-4"})})}),o.jsxs(Ia,{align:"end",className:"w-36 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start h-9 px-2 font-normal",onClick:async()=>{dt(null);try{const vt=await q8(be.id);ke(vt),Z(!0)}catch(vt){ee.error("Failed to load product",{description:vt?.message?String(vt.message):""})}},children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>{dt(null),xe(be)},children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},be.id)})})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-2 text-sm text-gray-600 border-t border-gray-100",children:[o.jsx("span",{children:a===0?"Showing 0 of 0":`Showing ${(J-1)*re+1}–${Math.min(J*re,a)} of ${a}`}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs($e,{value:String(re),onValueChange:be=>Q(Number(be)),children:[o.jsx(Be,{className:"w-[100px] h-9",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(be=>o.jsxs(Se,{value:String(be),children:[be," / page"]},be))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{className:J<=1?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>J>1&&oe(be=>Math.max(1,be-1)),"aria-disabled":J<=1})}),o.jsx(wt,{children:o.jsxs(Cn,{className:"cursor-default",size:"default",isActive:!0,onClick:be=>be.preventDefault(),children:["Page ",J," / ",Lt]})}),o.jsx(wt,{children:o.jsx(ca,{className:J>=Lt?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>JMath.min(Lt,be+1)),"aria-disabled":J>=Lt})})]})})]})]})]}):o.jsxs("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Category Name"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Code"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Photo"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Order"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Status"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Last edited"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center whitespace-nowrap w-[72px]",children:"Actions"})]})}),o.jsx(pn,{children:O?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-gray-500 py-10",children:"Loading..."})}):w.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:7,className:"text-center text-gray-500 py-10",children:"No categories found."})}):w.map(be=>{const Le=be.state!==!1,rt=O8({buttonStyleJson:be.buttonStyleJson,buttonAppearance:be.buttonAppearance,displayText:be.displayText,buttonBgColor:be.buttonBgColor,buttonImageUrl:be.buttonImageUrl,buttonTextColor:be.buttonTextColor,categoryPhotoUrl:be.categoryPhotoUrl,categoryName:be.categoryName});return o.jsxs(nt,{children:[o.jsx(ye,{className:"border-r font-medium text-gray-900",children:Mn(be.categoryName)}),o.jsx(ye,{className:"border-r text-gray-600 font-mono text-sm",children:Mn(be.categoryCode)}),o.jsx(ye,{className:"border-r",children:rt.mode==="image"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 overflow-hidden shadow-sm bg-gray-50",children:o.jsx("img",{src:Tf(rt.imageUrl),alt:"",className:"w-full h-full object-cover"})}):rt.mode==="colorText"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 shadow-sm flex items-center justify-center px-1 overflow-hidden",style:{backgroundColor:rt.bg,color:rt.textColor||"#ffffff"},title:`${rt.text}`,children:o.jsx("span",{className:"text-[10px] font-bold leading-tight text-center line-clamp-2 break-all",children:rt.text})}):rt.mode==="color"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 shadow-sm",style:{backgroundColor:rt.bg},title:rt.bg}):rt.mode==="text"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 shadow-sm bg-gray-50 flex items-center justify-center px-1 overflow-hidden",title:rt.text,children:o.jsx("span",{className:"text-[10px] font-bold text-gray-800 text-center line-clamp-2 break-all",children:rt.text})}):o.jsx("span",{className:"text-gray-400 text-sm",children:"—"})}),o.jsx(ye,{className:"border-r text-gray-700",children:be.orderNum??"—"}),o.jsx(ye,{className:"border-r whitespace-nowrap",children:o.jsx(fn,{variant:Le?"default":"secondary",className:Le?"bg-green-600":"bg-gray-400",children:Le?"active":"inactive"})}),o.jsx(ye,{className:"border-r text-gray-600 text-sm",children:Mn(be.lastEdited)}),o.jsx(ye,{className:"text-center whitespace-nowrap",children:o.jsxs(ka,{open:pe===be.id,onOpenChange:Xt=>_e(Xt?be.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",children:o.jsx(ri,{className:"h-4 w-4"})})}),o.jsxs(Ia,{align:"end",className:"w-36 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start h-9 px-2 font-normal",onClick:async()=>{_e(null);try{const Xt=await ope(be.id);De(Xt),Ce(!0)}catch(Xt){ee.error("Failed to load category",{description:Xt?.message?String(Xt.message):""})}},children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>{_e(null),ne(be)},children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},be.id)})})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3 shrink-0",children:[o.jsx("div",{className:"text-sm text-gray-600",children:N===0?"Showing 0 of 0":`Showing ${(E-1)*A+1}–${Math.min(E*A,N)} of ${N}`}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(A),onValueChange:be=>M(Number(be)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(be=>o.jsxs(Se,{value:String(be),children:[be," / page"]},be))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:be=>{be.preventDefault(),T(Le=>Math.max(1,Le-1))},"aria-disabled":E<=1,className:E<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:be=>be.preventDefault(),children:["Page ",E," / ",Kt]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:be=>{be.preventDefault(),T(Le=>Math.min(Kt,Le+1))},"aria-disabled":E>=Kt,className:E>=Kt?"pointer-events-none opacity-50":""})})]})})]})]})]})]}),o.jsx(bve,{open:we,onOpenChange:be=>{Z(be),be||ke(null)},editing:ve,locationOptions:Qe,categoryOptions:Tt,locationMap:d,onSaved:()=>{fr(),Z(!1),ke(null)}}),o.jsx(wve,{open:!!Ge,product:Ge,onOpenChange:be=>{be||xe(null)},onDeleted:fr}),o.jsx(sE,{open:er,onOpenChange:Ae,title:"Bulk import products",description:"Upload an .xlsx file. Use the official template for column headers.",downloadingTemplate:Vn,onDownloadTemplate:async()=>{Jr(!0);try{await tpe(),ee.success("Template downloaded.")}catch(be){const Le=be instanceof Error?be.message:"Download failed.";ee.error("Template download failed",{description:Le})}finally{Jr(!1)}},onImportFile:async be=>{const Le=await npe(be);return fr(),qt(),{successCount:Le.successCount,failCount:Le.failCount}}}),o.jsx(yve,{open:pt,onOpenChange:Ot,seed:Qt,categories:p,onSaved:()=>{Wt(new Set),fr()}}),o.jsx(Sve,{open:je,category:qe,locations:f,onOpenChange:be=>{Ce(be),be||De(null)},onSaved:()=>{tr(),Ce(!1),De(null)}}),o.jsx(jve,{open:!!He,category:He,onOpenChange:be=>{be||ne(null)},onDeleted:tr})]})}function bve({open:e,onOpenChange:t,editing:r,locationOptions:n,categoryOptions:a,locationMap:i,onSaved:s}){const[l,d]=x.useState(!1),[u,f]=x.useState(""),[h,p]=x.useState(""),[g,v]=x.useState(""),[b,w]=x.useState(""),[j,N]=x.useState(!0),[C,O]=x.useState([]);x.useEffect(()=>{if(e)if(r){f(r.productCode??""),p(r.productName??""),v((r.categoryId??"").trim()),w(r.productImageUrl??""),N(r.state!==!1);const E=r.locationIds,T=i.get(r.id)??[],A=Array.isArray(E)?[...new Set(E.map(M=>String(M).trim()).filter(Boolean))]:[...new Set(T.map(M=>String(M).trim()).filter(Boolean))];O(A)}else f(""),p(""),v(""),w(""),N(!0),O([])},[e,r,i]);const P=async()=>{if(!h.trim()){ee.error("Validation",{description:"Product name is required."});return}const E=[...new Set(C.map(A=>String(A).trim()).filter(Boolean))];if(E.length===0){ee.error("Validation",{description:"Select at least one store to bind this product."});return}const T={productCode:u.trim()||null,productName:h.trim(),categoryId:g.trim()||null,productImageUrl:b.trim()||null,state:j,locationIds:E};d(!0);try{r?await Zme(r.id,T):await Qme(T),ee.success(r?"Product updated.":"Product created."),s()}catch(A){ee.error(r?"Update failed":"Create failed",{description:A?.message?String(A.message):""})}finally{d(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"w-[min(50%,calc(100vw-2rem))] max-w-none sm:max-w-none max-h-[90vh] overflow-y-auto",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:r?"Edit Product":"Add New Product"}),o.jsx(It,{children:r?"Update product and store bindings.":"Create a product and bind it to one or more stores."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Product code"}),o.jsx(me,{className:"h-10",value:u,onChange:E=>f(E.target.value),placeholder:"e.g. PRD_TEST_001"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Product name *"}),o.jsx(me,{className:"h-10",value:h,onChange:E=>p(E.target.value),placeholder:"e.g. Chicken"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category"}),o.jsx($n,{value:g,onValueChange:v,options:a,placeholder:"Select category (optional)",searchPlaceholder:"Search category…",emptyText:"No categories."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Product image"}),o.jsx(_u,{value:b,onChange:w,uploadSubDir:"product",oneImageOnly:!0,hint:"POST /api/app/picture/category/upload (subDir: product). JPG/PNG/WebP/GIF, max 5 MB."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Bind to stores *"}),o.jsx(hve,{values:C,onValuesChange:O,options:n,placeholder:"Select one or more locations",searchPlaceholder:"Search location…",emptyText:"No locations."})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 h-10 bg-white",children:[o.jsx("span",{className:"text-sm font-medium",children:"Enabled"}),o.jsx(br,{checked:j,onCheckedChange:N})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(ce,{type:"button",disabled:l,onClick:P,className:"bg-blue-600 hover:bg-blue-700 text-white",children:l?"Saving…":r?"Save":"Create"})]})]})})}function wve({open:e,product:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=async()=>{if(t?.id){i(!0);try{await epe(t.id),ee.success("Product deleted."),r(!1),n()}catch(l){ee.error("Delete failed",{description:l?.message?String(l.message):""})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-md",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete product"}),o.jsx(It,{children:"This cannot be undone."})]}),o.jsxs("p",{className:"text-sm text-gray-700 py-2",children:["Delete ",o.jsx("span",{className:"font-medium",children:Mn(t?.productName)})," (",Mn(t?.productCode),")?"]}),o.jsxs(Dt,{children:[o.jsx(ce,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{type:"button",variant:"destructive",className:"gap-2",disabled:a,onClick:s,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting…":"Delete"]})]})]})})}function Sve({open:e,category:t,locations:r,onOpenChange:n,onSaved:a}){const i=!!t?.id,[s,l]=x.useState(!1),[d,u]=x.useState(""),[f,h]=x.useState(""),[p,g]=x.useState(""),[v,b]=x.useState(""),[w,j]=x.useState({text:!0,color:!1,image:!1}),[N,C]=x.useState(""),[O,P]=x.useState(""),[E,T]=x.useState("0"),[A,M]=x.useState(!0),R=x.useMemo(()=>{const z=[];return w.text&&z.push("TEXT"),w.color&&z.push("COLOR"),z},[w.text,w.color]);x.useEffect(()=>{if(e)if(t){u(t.categoryCode??""),h(t.categoryName??""),g(t.categoryPhotoUrl??"");{const z=oy(t.buttonStyleJson);if(z)j(bc(z.appearances)),b(z.displayText??""),C(z.buttonBgColor??""),P(z.buttonImageUrl??"");else{const G=tl(t.buttonAppearance),H=V_(t.categoryPhotoUrl);if(H&&G.length>0&&G.length===H.length){const W=W_(G,H,{categoryName:t.categoryName,name:void 0,buttonTextColor:t.buttonTextColor});j(bc(G)),b(W.displayText??""),C(W.buttonBgColor??""),P(W.buttonImageUrl??"")}else{b(t.displayText??"");const W=tl(t.buttonAppearance);if(W.length===0){const q=G_({buttonAppearance:t.buttonAppearance,displayText:t.displayText,buttonBgColor:t.buttonBgColor,buttonImageUrl:t.buttonImageUrl,buttonTextColor:t.buttonTextColor,categoryPhotoUrl:t.categoryPhotoUrl,categoryName:t.categoryName});q.mode==="image"?j({text:!1,color:!1,image:!0}):q.mode==="colorText"?j({text:!0,color:!0,image:!1}):q.mode==="color"?j({text:!1,color:!0,image:!1}):q.mode==="text"?j({text:!0,color:!1,image:!1}):j({text:!0,color:!1,image:!1})}else j(bc(W));C(t.buttonBgColor??""),P(t.buttonImageUrl??"")}}}T(t.orderNum===null||t.orderNum===void 0?"0":String(t.orderNum)),M(t.state!==!1)}else u(""),h(""),g(""),b(""),j({text:!0,color:!1,image:!1}),C(""),P(""),T("0"),M(!0)},[e,t]);const L=x.useMemo(()=>["#111827","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899"],[]),V=async()=>{if(!f.trim()){ee.error("Validation",{description:"Category name is required."});return}const z=Number(E);if(!Number.isFinite(z)){ee.error("Validation",{description:"Order must be a number."});return}const G=U_(w);if(G.length===0){ee.error("Validation",{description:"Select at least one button appearance (Text, Color, or Image)."});return}if(G[0]==="IMAGE"){if(!O.trim()){ee.error("Validation",{description:"Please upload/select an image for Image appearance."});return}}else{if(w.text&&!v.trim()){ee.error("Validation",{description:"Please enter display text for Text appearance."});return}if(w.color&&!N.trim()){ee.error("Validation",{description:"Please select a background color for Color appearance."});return}}const H=H_(G,{displayText:v.trim(),buttonBgColor:N.trim(),buttonImageUrl:O.trim()}),W=w.image?null:(()=>{const Y=(t?.buttonTextColor??"").trim();return Y||(oy(t?.buttonStyleJson??null)?.buttonTextColor??"").trim()||null})(),q=q_({appearances:G,displayText:v.trim()||null,buttonBgColor:w.image?null:N.trim()||null,buttonTextColor:W,buttonImageUrl:w.image&&O.trim()||null}),I={categoryCode:d.trim()||null,categoryName:f.trim(),categoryPhotoUrl:H,displayText:v.trim()||null,buttonAppearance:G,buttonTextColor:W,buttonBgColor:N.trim()||null,buttonImageUrl:O.trim()||null,buttonStyleJson:q,availabilityType:"ALL",locationIds:[],state:A,orderNum:z};l(!0);try{i&&t?.id?(await spe(t.id,I),ee.success("Category updated.")):(await ipe(I),ee.success("Category created.")),a()}catch(Y){ee.error(i?"Update failed":"Create failed",{description:Y?.message?String(Y.message):""})}finally{l(!1)}};return o.jsx(_t,{open:e,onOpenChange:n,children:o.jsxs(Ct,{className:"w-[min(50%,calc(100vw-2rem))] max-w-none sm:max-w-none max-h-[90vh] overflow-y-auto",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:i?"Edit Category":"New Category"}),o.jsx(It,{children:i?"Update product category (API: /api/app/product-category).":"Create a product category."})]}),o.jsxs("div",{className:"grid gap-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category code"}),o.jsx(me,{className:"h-10",value:d,onChange:z=>u(z.target.value),placeholder:"e.g. CAT_PREP"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Category name *"}),o.jsx(me,{className:"h-10",value:f,onChange:z=>h(z.target.value),placeholder:"e.g. Prep"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Button Appearance"}),o.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-100 p-3 space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Text & Color — can combine"}),o.jsxs(iu,{type:"multiple",value:R,onValueChange:z=>{const G=z??[];j(H=>({...H,text:G.includes("TEXT"),color:G.includes("COLOR"),image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent gap-1 flex-wrap justify-stretch",children:[o.jsx(ti,{value:"TEXT",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",w.text&&!w.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"text-lg leading-none",children:"T"}),"Text"]})}),o.jsx(ti,{value:"COLOR",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",w.color&&!w.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"text-lg leading-none",children:"🎨"}),"Color"]})})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Image — exclusive (clears Text & Color)"}),o.jsx(iu,{type:"single",value:w.image?"IMAGE":"",onValueChange:z=>{const G=String(z||"").toUpperCase();j(G==="IMAGE"?{text:!1,color:!1,image:!0}:H=>({...H,image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent",children:o.jsx(ti,{value:"IMAGE",className:["w-full gap-2 h-10 rounded-full","border border-transparent",w.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx("span",{className:"text-lg leading-none",children:"🖼"}),"Image"]})})})]})]})]}),w.text&&!w.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Display Text"}),o.jsx(me,{className:"h-10",value:v,onChange:z=>b(z.target.value),placeholder:"Category Name"}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Saved to ",o.jsx("span",{className:"font-mono",children:"photo"})," as this text."]})]}):null,w.color&&!w.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Select Color"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[L.map(z=>o.jsx("button",{type:"button",className:["h-10 w-10 rounded-full border border-gray-200 shadow-sm",N.toLowerCase()===z.toLowerCase()?"ring-2 ring-blue-500 ring-offset-2":""].join(" "),style:{backgroundColor:z},onClick:()=>C(z),"aria-label":`Select ${z}`},z)),o.jsx("button",{type:"button",className:"h-10 w-10 rounded-full border border-dashed border-gray-300 bg-white text-gray-500 hover:text-gray-700 hover:border-gray-400 flex items-center justify-center",onClick:()=>{document.getElementById("product-category-custom-color")?.click()},"aria-label":"Custom color",children:"+"}),o.jsx("input",{id:"product-category-custom-color",type:"color",value:N||"#3B82F6",onChange:z=>C(z.target.value),className:"h-0 w-0 opacity-0 pointer-events-none","aria-label":"Custom color picker"})]})]}):null,w.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Button Image"}),o.jsx(_u,{value:O,onChange:P,uploadSubDir:"category",oneImageOnly:!0,hint:"One image only. Replace or clear to change. JPG, PNG, WebP, or GIF — max 5 MB. Saved as CategoryPhotoUrl."})]}):null,o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{className:"h-10",type:"number",value:E,onChange:z=>T(z.target.value),placeholder:"0"})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 h-10 bg-white",children:[o.jsx("span",{className:"text-sm font-medium",children:"Enabled"}),o.jsx(br,{checked:A,onCheckedChange:M})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),o.jsx(ce,{type:"button",disabled:s,onClick:V,className:"bg-blue-600 hover:bg-blue-700 text-white",children:s?"Saving…":i?"Save":"Create"})]})]})})}function jve({open:e,category:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=async()=>{if(t?.id){i(!0);try{await lpe(t.id),ee.success("Category deleted."),r(!1),n()}catch(l){ee.error("Delete failed",{description:l?.message?String(l.message):""})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-md",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete category"}),o.jsx(It,{children:"This cannot be undone."})]}),o.jsxs("p",{className:"text-sm text-gray-700 py-2",children:["Delete ",o.jsx("span",{className:"font-medium",children:Mn(t?.categoryName)})," (",Mn(t?.categoryCode),")?"]}),o.jsxs(Dt,{children:[o.jsx(ce,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{type:"button",variant:"destructive",className:"gap-2",disabled:a,onClick:s,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting…":"Delete"]})]})]})})}const lh=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),ch="/rbac-menu";function Af(e){if(!e||typeof e!="object")return{id:""};const t=e,r=t.router??t.Router,n=t.routeUrl??t.RouteUrl??r;return{id:String(t.id??t.Id??""),orderNum:t.orderNum??t.OrderNum,state:t.state??t.State,menuName:t.menuName??t.MenuName,routerName:t.routerName??t.RouterName,router:r,menuType:t.menuType??t.MenuType,permissionCode:t.permissionCode??t.PermissionCode,parentId:t.parentId??t.ParentId,menuIcon:t.menuIcon??t.MenuIcon,routeUrl:n,link:t.link??t.Link,isCache:t.isCache??t.IsCache,isShow:t.isShow??t.IsShow,remark:t.remark??t.Remark,component:t.component??t.Component,menuSource:t.menuSource??t.MenuSource,query:t.query??t.Query,concurrencyStamp:t.concurrencyStamp??t.ConcurrencyStamp}}function Nve(e){if(Array.isArray(e))return{items:e.map(Af),totalCount:e.length};const t=e,r=t.items??t.Items??[],n=typeof t.totalCount=="number"?t.totalCount:typeof t.TotalCount=="number"?t.TotalCount:r.length;return{items:r.map(Af),totalCount:n}}async function Z6(e,t){const r=await lh.requestJson({path:ch,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword},signal:t});return Nve(r)}function ZN(e){const t=Af(e),r=e,n=r?.children??r?.Children,a=Array.isArray(n)?n.map(ZN):void 0;return{...t,children:a}}function Cve(e){if(Array.isArray(e))return e.map(ZN);if(!e||typeof e!="object")return[];const t=e,r=t.items??t.Items??t.data??t.Data;return Array.isArray(r)?r.map(ZN):[]}async function _ve(e){const t=await lh.requestJson({path:`${ch}/tree`,method:"GET",signal:e});return Cve(t)}async function Eve(e){const t=new Map;let r=1;const n=500;for(;;){const i=(await Z6({skipCount:r,maxResultCount:n},e)).items??[];for(const s of i)s.menuType!==0||!s.id||t.has(s.id)||t.set(s.id,s);if(i.length100))break}return Array.from(t.values()).sort((a,i)=>(a.orderNum??0)-(i.orderNum??0))}async function Pve(e){const t=await lh.requestJson({path:ch,method:"POST",body:e});return Af(t)}async function Ove(e,t){const r=await lh.requestJson({path:`${ch}/${encodeURIComponent(e)}`,method:"PUT",body:t});return Af(r)}async function Tve(e){e.length&&await lh.requestJson({path:ch,method:"DELETE",body:e})}async function kve(e){await Tve([e])}const ez=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),tz="/rbac-role-menu";async function Ave(e){await ez.requestJson({path:`${tz}/set`,method:"POST",body:e})}async function Ive(e){await ez.requestJson({path:tz,method:"DELETE",body:e})}const Mve=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Rve="/role";async function lE(e,t){return Mve.requestJson({path:Rve,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,RoleName:e.roleName,RoleCode:e.roleCode,State:e.state},signal:t})}const Iv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Mv="/rbac-role";async function Dve(e){return Iv.requestJson({path:Mv,method:"POST",body:e})}async function Lve(e,t){return Iv.requestJson({path:`${Mv}/${encodeURIComponent(e)}`,method:"PUT",body:t})}function $ve(e){if(!e||typeof e!="object")return[];const t=e,r=Array.isArray(t.menuIds)?t.menuIds:Array.isArray(t.MenuIds)?t.MenuIds:void 0;if(r)return r.map(String);const n=t.data??t.Data;if(n&&typeof n=="object"){const i=n,s=Array.isArray(i.menuIds)?i.menuIds:Array.isArray(i.MenuIds)?i.MenuIds:void 0;if(s)return s.map(String)}const a=Array.isArray(t.roleMenus)?t.roleMenus:Array.isArray(t.RoleMenus)?t.RoleMenus:void 0;if(Array.isArray(a)){const i=[];for(const s of a){if(!s||typeof s!="object")continue;const l=s,d=l.menuId??l.MenuId??l.id??l.Id;d&&i.push(String(d))}return i}return[]}async function Fve(e){e.length&&await Iv.requestJson({path:Mv,method:"DELETE",body:e})}async function Bve(e){await Fve([e])}async function zve(e,t){const r=await Iv.requestJson({path:`${Mv}/${encodeURIComponent(e)}`,method:"GET",signal:t});return $ve(r)}const Pu=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),hi="/team-member";function Uve(e){if(!Array.isArray(e))return[];const t=[];for(const r of e)if(r!=null){if(typeof r=="string"||typeof r=="number"){t.push(String(r));continue}if(typeof r=="object"){const n=r,a=n.id??n.Id??n.locationId??n.LocationId??n.location_id??n.locationID;a!=null&&t.push(String(a))}}return t}function qve(e){if(!Array.isArray(e))return[];const t=[];for(const r of e)if(r!=null){if(typeof r=="string"||typeof r=="number"){t.push(String(r));continue}if(typeof r=="object"){const n=r,a=n.locationCode??n.LocationCode??n.code??n.Code??n.location_code??n.locationCodeId,i=n.locationName??n.LocationName??n.name??n.Name??n.location_name,s=n.id??n.Id??n.locationId??n.LocationId,l=a==null?"":String(a).trim(),d=i==null?"":String(i).trim(),u=s==null?"":String(s).trim();l&&d?t.push(`${l} - ${d}`):d?t.push(d):l?t.push(l):u&&t.push(u)}}return t}function Rv(e){if(!e||typeof e!="object")return{id:""};const t=e,r=String(t.id??t.Id??t.userId??t.UserId??t.user_id??t.UserID??t.memberId??t.MemberId??""),n=t.fullName??t.FullName??t.name??t.Name,a=t.userName??t.UserName??t.username??t.UserName,i=t.email??t.Email,s=t.phone??t.Phone;let l=t.roleId??t.RoleId,d=t.roleName??t.RoleName??t.roleName??t.Role;const u=t.role??t.Role;if((!l||!d)&&u&&typeof u=="object"){const w=u;l=w.id??w.Id??w.roleId??w.RoleId??l,d=w.roleName??w.RoleName??w.name??w.Name??w.role??w.Role??d}const f=t.state??t.State,h=typeof f=="boolean"?f:f==="true"?!0:f==="false"?!1:void 0,p=t.locationIds??t.LocationIds??t.assignedLocationIds??t.AssignedLocationIds??t.location_id_list??t.LocationIdList;let g=Uve(p);const v=t.locations??t.Locations??t.assignedLocations??t.AssignedLocations??t.locationNames??t.LocationNames;let b=qve(v);if(g.length===0&&Array.isArray(v)){const w=[];for(const j of v){if(typeof j!="object"||!j)continue;const N=j,C=N.id??N.Id??N.locationId??N.LocationId;C!=null&&w.push(String(C))}w.length&&(g=w)}return{id:r,fullName:n,userName:a,email:i,phone:s,roleId:l,roleName:d,locationIds:g,locations:b,state:h??(t.status?String(t.status).toLowerCase()==="active":void 0)}}async function Vve(e,t){const r=await Pu.requestJson({path:hi,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Keyword:e.keyword,RoleId:e.roleId,LocationId:e.locationId,State:e.state,Sorting:e.sorting},signal:t}),n=r.items??[];return{totalCount:r.totalCount??0,items:n.map(Rv)}}async function Wve(e,t){const r=await Pu.requestJson({path:`${hi}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Rv(r)}function rz(e){if(e==null||e==="")return null;const t=String(e).trim();return t?Number(t.replace(/\D/g,""))||0:null}function Hve(e){const t=e.phone!=null&&e.phone!==""?rz(String(e.phone)):null;return{fullName:e.fullName,userName:e.userName,password:e.password,email:e.email??null,phone:t,roleId:e.roleId,locationIds:e.locationIds,locations:e.locationIds,state:e.state}}function Gve(e){const t=e.phone!=null&&e.phone!==""?rz(String(e.phone)):null,r={fullName:e.fullName,userName:e.userName,email:e.email??null,phone:t,roleId:e.roleId,locationIds:e.locationIds,locations:e.locationIds,state:e.state};return e.password&&(r.password=e.password),r}async function Yve(e){const t=await Pu.requestJson({path:hi,method:"POST",body:Hve(e)});return Rv(t)}async function Kve(e,t){const r=await Pu.requestJson({path:`${hi}/${encodeURIComponent(e)}`,method:"PUT",body:Gve(t)});return Rv(r)}async function Xve(e){await Pu.requestJson({path:`${hi}/${encodeURIComponent(e)}`,method:"DELETE"})}async function Jve(e){await dl({path:`${hi}/download-team-member-import-template`,defaultFileName:"Team-Member-template.xlsx",signal:e})}async function Qve(e,t){await dl({path:`${hi}/export-team-members-pdf`,query:{Keyword:e.keyword,RoleId:e.roleId,LocationId:e.locationId,State:e.state,Sorting:e.sorting},defaultFileName:"team-members.pdf",signal:t})}async function Zve(e,t){return z_({path:`${hi}/import-team-members-batch`,fieldName:"file",file:e,signal:t})}async function e0e(e){return Pu.requestJson({path:`${hi}/update-team-members-bulk`,method:"POST",body:e})}const Dv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});function t0e(){return"http://flus-test.3ffoodsafety.com"}function r0e(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}function n0e(e,t){const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function a0e(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))if(!(a==null||a==="")){if(typeof a=="boolean"){t.set(n,a?"true":"false");continue}t.set(n,String(a))}const r=t.toString();return r?`?${r}`:""}async function uh(e,t){return Dv.requestJson({path:"/partner",method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function o0e(e,t){return Dv.requestJson({path:"/partner",method:"POST",body:{partnerName:e.partnerName.trim(),contactEmail:e.contactEmail?.trim()?e.contactEmail.trim():null,phoneNumber:e.phoneNumber?.trim()?e.phoneNumber.trim():null,state:e.state??!0},signal:t})}async function i0e(e,t,r){return Dv.requestJson({path:`/partner/${encodeURIComponent(e)}`,method:"PUT",body:{partnerName:t.partnerName.trim(),contactEmail:t.contactEmail?.trim()?t.contactEmail.trim():null,phoneNumber:t.phoneNumber?.trim()?t.phoneNumber.trim():null,state:t.state??!0},signal:r})}async function s0e(e,t){await Dv.requestJson({path:`/partner/${encodeURIComponent(e)}`,method:"DELETE",signal:t})}async function l0e(e,t){const r=t0e(),n=r0e(),a=n0e(r,`/api/app/partner/export-pdf${a0e({Keyword:e.keyword,State:e.state,Sorting:e.sorting})}`),i={};n&&(i.Authorization=`Bearer ${n}`);const s=await fetch(a,{method:"GET",headers:i,signal:t});if(!s.ok){const l=s.headers.get("content-type")??"";let d="Export failed.";if(l.includes("application/json")){const u=await s.json().catch(()=>null),f=u?.error?.message?.trim()||u?.message?.trim();f&&(d=f)}else{const u=await s.text().catch(()=>"");u.trim()&&(d=u.trim())}throw new Yr(d,s.status,null)}return s.blob()}const Lv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});function c0e(){return"http://flus-test.3ffoodsafety.com"}function u0e(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}function d0e(e,t){const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function f0e(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))if(!(a==null||a==="")){if(typeof a=="boolean"){t.set(n,a?"true":"false");continue}t.set(n,String(a))}const r=t.toString();return r?`?${r}`:""}async function cE(e,t){return Lv.requestJson({path:"/group",method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,PartnerId:e.partnerId,State:e.state},signal:t})}async function h0e(e,t){return Lv.requestJson({path:"/group",method:"POST",body:{groupName:e.groupName.trim(),partnerId:e.partnerId.trim(),state:e.state??!0},signal:t})}async function m0e(e,t,r){return Lv.requestJson({path:`/group/${encodeURIComponent(e)}`,method:"PUT",body:{groupName:t.groupName.trim(),partnerId:t.partnerId.trim(),state:t.state??!0},signal:r})}async function p0e(e,t){await Lv.requestJson({path:`/group/${encodeURIComponent(e)}`,method:"DELETE",signal:t})}async function g0e(e,t){const r=c0e(),n=u0e(),a=d0e(r,`/api/app/group/export-pdf${f0e({Keyword:e.keyword,PartnerId:e.partnerId,State:e.state,Sorting:e.sorting})}`),i={};n&&(i.Authorization=`Bearer ${n}`);const s=await fetch(a,{method:"GET",headers:i,signal:t});if(!s.ok){const l=s.headers.get("content-type")??"";let d="Export failed.";if(l.includes("application/json")){const u=await s.json().catch(()=>null),f=u?.error?.message?.trim()||u?.message?.trim();f&&(d=f)}else{const u=await s.text().catch(()=>"");u.trim()&&(d=u.trim())}throw new Yr(d,s.status,null)}return s.blob()}const y0e="00000000-0000-0000-0000-000000000000";function v0e(e){const t=(e??"").trim();return t?t.toLowerCase()!==y0e:!1}function x0e(e){return{id:e.id,locationCodeReadonly:(e.locationCode??e.id??"").trim(),partner:e.partner??"",groupName:e.groupName??"",locationName:(e.locationName??"").trim()||"",street:e.street??"",city:e.city??"",stateCode:e.stateCode??"",country:e.country??"",zipCode:e.zipCode??"",phone:e.phone??"",email:e.email??"",latitude:e.latitude??null,longitude:e.longitude??null,state:e.state!==!1}}function b0e(){return{id:"",locationCodeReadonly:"",partner:"",groupName:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}}function w0e({open:e,onOpenChange:t,seed:r,onSaved:n}){const[a,i]=x.useState([]),[s,l]=x.useState(!1),d=x.useMemo(()=>Math.max(r.length+10,10),[r.length]);x.useEffect(()=>{if(!e)return;const p=r.map(x0e),g=Math.max(0,d-p.length);i([...p,...Array.from({length:g},()=>b0e())])},[e,r,d]);const u=(p,g)=>{i(v=>{const b=[...v];return b[p]={...b[p],...g},b})},f=p=>{i(g=>g.length<=1?g:g.filter((v,b)=>b!==p))},h=async()=>{const p=a.filter(g=>v0e(g.id)).map(g=>({id:g.id.trim(),partner:g.partner?.trim()||null,groupName:g.groupName?.trim()||null,locationName:g.locationName.trim(),street:g.street?.trim()||null,city:g.city?.trim()||null,stateCode:g.stateCode?.trim()||null,country:g.country?.trim()||null,zipCode:g.zipCode?.trim()||null,phone:g.phone?.trim()||null,email:g.email?.trim()||null,latitude:g.latitude,longitude:g.longitude,state:g.state!==!1}));if(p.length===0){ee.error("No valid rows",{description:"Select locations in the list or keep rows with valid IDs."});return}l(!0);try{const g=await wme({items:p});if(ee.success("Bulk update finished",{description:`Success: ${g.successCount}, failed: ${g.failCount}`}),g.errors?.length){const v=g.errors.slice(0,5).map(b=>`Row ${b.rowNumber??"?"}: ${b.message??""}`).join(` -`);ee.message("Errors (first 5)",{description:v})}n(),t(!1)}catch(g){const v=g instanceof Yr||g instanceof Error?g.message:"Save failed.";ee.error("Bulk save failed",{description:v})}finally{l(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"max-w-[min(96vw,1200px)] w-full max-h-[90vh] flex flex-col gap-0 p-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-gray-200 shrink-0",children:[o.jsx(ce,{type:"button",variant:"outline",className:"shrink-0",onClick:()=>t(!1),children:"Back"}),o.jsxs(Et,{className:"flex-1 text-center space-y-0 py-0",children:[o.jsx(Pt,{className:"text-base",children:"Location bulk edit"}),o.jsx(It,{className:"sr-only",children:"Edit multiple locations and save all."})]}),o.jsx(ce,{type:"button",className:"bg-green-600 hover:bg-green-700 text-white shrink-0",disabled:s,onClick:()=>void h(),children:s?"Saving…":"Save All"})]}),o.jsx("div",{className:"overflow-auto flex-1 min-h-0 px-2 py-3",children:o.jsxs("table",{className:"w-full text-xs border-collapse border border-gray-200",children:[o.jsx("thead",{className:"bg-gray-100 sticky top-0 z-10",children:o.jsxs("tr",{children:[o.jsx("th",{className:"border p-1 w-8"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location ID"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Company"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Region"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location Name *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Street"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"City"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"State"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Country"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Zip"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Phone"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Email"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Lat"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Lng"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Active"})]})}),o.jsx("tbody",{children:a.map((p,g)=>o.jsxs("tr",{className:"bg-white",children:[o.jsx("td",{className:"border p-0 align-middle text-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-1 py-1",children:[o.jsx("span",{className:"text-[10px] text-gray-500",children:g+1}),o.jsx(ce,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1",onClick:()=>f(g),children:"×"})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:p.locationCodeReadonly,readOnly:!0,title:"Location ID is not changed in bulk edit"})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",value:p.partner??"",onChange:v=>u(g,{partner:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",value:p.groupName??"",onChange:v=>u(g,{groupName:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:p.locationName,onChange:v=>u(g,{locationName:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",value:p.street??"",onChange:v=>u(g,{street:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[72px]",value:p.city??"",onChange:v=>u(g,{city:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[48px]",value:p.stateCode??"",onChange:v=>u(g,{stateCode:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[56px]",value:p.country??"",onChange:v=>u(g,{country:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[56px]",value:p.zipCode??"",onChange:v=>u(g,{zipCode:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[88px]",value:p.phone??"",onChange:v=>u(g,{phone:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[120px]",value:p.email??"",onChange:v=>u(g,{email:v.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[64px]",value:p.latitude===null||p.latitude===void 0?"":String(p.latitude),onChange:v=>{const b=v.target.value.trim();u(g,{latitude:b===""?null:Number(b)})}})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[64px]",value:p.longitude===null||p.longitude===void 0?"":String(p.longitude),onChange:v=>{const b=v.target.value.trim();u(g,{longitude:b===""?null:Number(b)})}})}),o.jsx("td",{className:"border p-1 align-middle text-center",children:o.jsx("div",{className:"flex justify-center",children:o.jsx(br,{checked:p.state!==!1,onCheckedChange:v=>u(g,{state:!!v})})})})]},`${p.id||"new"}-${g}`))})]})}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 text-center text-xs text-gray-500 shrink-0 space-y-1",children:[o.jsx("p",{children:"You can copy and paste from Excel or Google Sheets."}),o.jsx("p",{children:"Columns marked * are required for rows that have a valid Location row id."}),o.jsx("p",{children:"Use the × on each row to remove a row (keep at least one row)."})]})]})})}const kt="__none__";async function nz(e){const t=[];let r=1;const n=100;for(;;){const i=await uh({skipCount:r,maxResultCount:n,state:!0},e);if(t.push(...i.items??[]),!i.items||i.items.length200))break}const a=new Map;for(const i of t)i.id&&!a.has(i.id)&&a.set(i.id,i);return Array.from(a.values())}async function az(e,t){const r=[];let n=1;const a=100;for(;;){const s=await cE({skipCount:n,maxResultCount:a,partnerId:e,state:!0},t);if(r.push(...s.items??[]),!s.items||s.items.length200))break}const i=new Map;for(const s of r)s.id&&!i.has(s.id)&&i.set(s.id,s);return Array.from(i.values())}function Va(e){const t=(e??"").trim();return t||"N/A"}function S0e(e,t){return e==null||t===null||t===void 0||!Number.isFinite(e)||!Number.isFinite(t)?"N/A":`${e}, ${t}`}function oz(e){const t=[];e.locationCode.trim()||t.push("Location ID"),e.locationName.trim()||t.push("Location Name"),(e.street??"").trim()||t.push("Street"),(e.city??"").trim()||t.push("City"),(e.stateCode??"").trim()||t.push("State"),(e.country??"").trim()||t.push("Country"),(e.zipCode??"").trim()||t.push("Zip Code"),(e.phone??"").trim()||t.push("Phone Number"),(e.email??"").trim()||t.push("Email");const r=e.latitude,n=e.longitude;return(r==null||!Number.isFinite(r))&&t.push("Latitude"),(n==null||!Number.isFinite(n))&&t.push("Longitude"),t}function j0e({renderBeforeTabs:e}={}){const[t,r]=x.useState(!1),[n,a]=x.useState(!1),[i,s]=x.useState(!1),[l,d]=x.useState(null),[u,f]=x.useState(null),[h,p]=x.useState([]),[g,v]=x.useState(!1),[b,w]=x.useState(0),[j,N]=x.useState(0),[C,O]=x.useState(null),[P,E]=x.useState(()=>new Set),[T,A]=x.useState(!1),[M,R]=x.useState(!1),[L,V]=x.useState([]),[z,G]=x.useState(!1),[H,W]=x.useState(!1),[q,I]=x.useState(""),[Y,F]=x.useState("all"),[D,$]=x.useState("all"),[K,J]=x.useState("all"),[oe,re]=x.useState(1),[Q,ue]=x.useState(10),se=x.useRef(null),fe=x.useRef(null),[we,Z]=x.useState("");x.useEffect(()=>(fe.current&&window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>Z(q.trim()),300),()=>{fe.current&&window.clearTimeout(fe.current)}),[q]);const je=x.useMemo(()=>K!=="all"?K:we.trim(),[K,we]),Ce=x.useMemo(()=>{const xe=new Set;for(const Je of h){const dt=(Je.partner??"").trim();dt&&xe.add(dt)}return["all",...Array.from(xe).sort((Je,dt)=>Je.localeCompare(dt))]},[h]),qe=x.useMemo(()=>{const xe=new Set;for(const Je of h){const dt=(Je.groupName??"").trim();dt&&xe.add(dt)}return["all",...Array.from(xe).sort((Je,dt)=>Je.localeCompare(dt))]},[h]),De=x.useMemo(()=>{const xe=new Set;for(const Je of h){const dt=(Je.locationCode??"").trim();dt&&xe.add(dt)}return["all",...Array.from(xe).sort((Je,dt)=>Je.localeCompare(dt))]},[h]),He=Math.max(1,Math.ceil(b/Q));x.useEffect(()=>{re(1)},[we,Y,D,K,Q]),x.useEffect(()=>((async()=>{se.current?.abort();const Je=new AbortController;se.current=Je,v(!0);try{const dt=Qa(oe),jt=await Nu({skipCount:dt,maxResultCount:Q,keyword:je||void 0,partner:Y!=="all"?Y:void 0,groupName:D!=="all"?D:void 0},Je.signal);p(jt.items??[]),w(jt.totalCount??0)}catch(dt){if(dt?.name==="AbortError")return;ee.error("Failed to load locations.",{description:dt?.message?String(dt.message):"Please try again."}),p([]),w(0)}finally{v(!1)}})(),()=>se.current?.abort()),[je,Y,D,K,oe,Q,j]),x.useEffect(()=>{E(new Set)},[we,Y,D,K,oe]);const ne=()=>N(xe=>xe+1),pe=xe=>{O(null),d(xe),a(!0)},_e=xe=>{O(null),f(xe),s(!0)},ve=o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:q,onChange:xe=>I(xe.target.value),style:{height:40,boxSizing:"border-box"},className:"border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"}),o.jsxs($e,{value:Y,onValueChange:F,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Company"})}),o.jsx(ze,{children:Ce.map(xe=>o.jsx(Se,{value:xe,children:xe==="all"?"Company (All)":xe},xe))})]}),o.jsxs($e,{value:D,onValueChange:$,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Region"})}),o.jsx(ze,{children:qe.map(xe=>o.jsx(Se,{value:xe,children:xe==="all"?"Region (All)":xe},xe))})]}),o.jsxs($e,{value:K,onValueChange:J,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsx(ze,{children:De.map(xe=>o.jsx(Se,{value:xe,children:xe==="all"?"All Locations":xe},xe))})]}),o.jsx("div",{className:"flex-1"}),o.jsx(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>A(!0),children:"Bulk Import"}),o.jsx(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",disabled:H,onClick:async()=>{W(!0);try{await xme({keyword:je||void 0,partner:Y!=="all"?Y:void 0,groupName:D!=="all"?D:void 0}),ee.success("Export started",{description:"Your browser should download the Excel file."})}catch(xe){const Je=xe instanceof Error?xe.message:"Please try again.";ee.error("Export failed",{description:Je})}finally{W(!1)}},children:H?"Exporting…":"Bulk Export"}),o.jsx(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>{const xe=h.filter(Je=>P.has(Je.id));if(xe.length===0){ee.error("No rows selected",{description:"Use the checkboxes on the left, then open Bulk Edit."});return}V(xe),R(!0)},children:"Bulk Edit"}),o.jsx(ce,{className:"h-10 bg-blue-600 hover:bg-blue-700 text-white rounded-md px-6 font-medium shrink-0",onClick:()=>r(!0),children:"New"})]})})}),ke=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex-1 overflow-auto pt-6 min-h-0",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r w-12 shrink-0 text-center pl-2 pr-4",children:o.jsx(Co,{checked:h.length>0&&h.every(xe=>P.has(xe.id)),onCheckedChange:xe=>{E(xe===!0?new Set(h.map(Je=>Je.id)):new Set)},"aria-label":"Select all on page"})}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Company"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Region"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Location ID"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Location Name"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Street"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"City"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"State"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Country"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Zip Code"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Phone"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Email"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"GPS"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Active"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center",children:"Actions"})]})}),o.jsx(pn,{children:g?o.jsx(nt,{children:o.jsx(ye,{colSpan:15,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):h.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:15,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):h.map(xe=>o.jsxs(nt,{children:[o.jsx(ye,{className:"border-r w-12 shrink-0 text-center pl-2 pr-4",children:o.jsx(Co,{checked:P.has(xe.id),onCheckedChange:Je=>{E(dt=>{const jt=new Set(dt);return Je===!0?jt.add(xe.id):jt.delete(xe.id),jt})},"aria-label":"Select row"})}),o.jsx(ye,{className:"border-r text-gray-600 max-w-[140px] truncate",children:Va(xe.partner)}),o.jsx(ye,{className:"border-r text-gray-600 max-w-[140px] truncate",children:Va(xe.groupName)}),o.jsx(ye,{className:"border-r font-numeric text-gray-600",children:Va(xe.locationCode??xe.id)}),o.jsx(ye,{className:"border-r font-medium text-black",children:Va(xe.locationName)}),o.jsx(ye,{className:"border-r text-gray-600 max-w-[140px] truncate",children:Va(xe.street)}),o.jsx(ye,{className:"border-r text-gray-600",children:Va(xe.city)}),o.jsx(ye,{className:"border-r text-gray-600",children:Va(xe.stateCode)}),o.jsx(ye,{className:"border-r text-gray-600",children:Va(xe.country)}),o.jsx(ye,{className:"border-r text-gray-600 font-numeric",children:Va(xe.zipCode)}),o.jsx(ye,{className:"border-r text-gray-600 whitespace-nowrap",children:Va(xe.phone)}),o.jsx(ye,{className:"border-r text-gray-600 text-sm max-w-[180px] truncate",children:Va(xe.email)}),o.jsx(ye,{className:"border-r text-gray-500 font-numeric text-xs",children:S0e(xe.latitude,xe.longitude)}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{className:xe.state?"bg-green-600":"bg-gray-400",children:xe.state?"Yes":"No"})}),o.jsx(ye,{className:"text-center",children:o.jsxs(ka,{open:C===xe.id,onOpenChange:Je=>O(Je?xe.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>pe(xe),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(ce,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>_e(xe),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},xe.id))})]})})}),o.jsx("div",{className:"pt-4 shrink-0",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",b===0?0:(oe-1)*Q+1,"-",Math.min(oe*Q,b)," of ",b]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(Q),onValueChange:xe=>ue(Number(xe)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(xe=>o.jsxs(Se,{value:String(xe),children:[xe," / page"]},xe))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:xe=>{xe.preventDefault(),re(Je=>Math.max(1,Je-1))},"aria-disabled":oe<=1,className:oe<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:xe=>xe.preventDefault(),children:["Page ",oe," / ",He]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:xe=>{xe.preventDefault(),re(Je=>Math.min(He,Je+1))},"aria-disabled":oe>=He,className:oe>=He?"pointer-events-none opacity-50":""})})]})})]})]})})]}),Ge=o.jsxs(o.Fragment,{children:[o.jsx(N0e,{open:t,onOpenChange:r,onCreated:()=>{re(1),ne()}}),o.jsx(_0e,{open:n,location:l,onOpenChange:xe=>{a(xe),xe||d(null)},onUpdated:()=>{ne()}}),o.jsx(E0e,{open:i,location:u,onOpenChange:xe=>{s(xe),xe||f(null)},onDeleted:()=>{ne()}}),o.jsx(sE,{open:T,onOpenChange:A,title:"Bulk import locations",description:"Upload an .xlsx file. Use the official template for correct column headers.",downloadingTemplate:z,onDownloadTemplate:async()=>{G(!0);try{await vme(),ee.success("Template downloaded.")}catch(xe){const Je=xe instanceof Error?xe.message:"Download failed.";ee.error("Template download failed",{description:Je})}finally{G(!1)}},onImportFile:async xe=>{const Je=await bme(xe);return ne(),{successCount:Je.successCount,failCount:Je.failCount}}}),o.jsx(w0e,{open:M,onOpenChange:R,seed:L,onSaved:()=>{E(new Set),ne()}})]});return e?o.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[e(ve),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:ke}),Ge]}):o.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[ve,o.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:ke}),Ge]})}function N0e({open:e,onOpenChange:t,onCreated:r}){const[n,a]=x.useState(!1),[i,s]=x.useState({partner:"",groupName:"",locationCode:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}),[l,d]=x.useState(kt),[u,f]=x.useState(kt),[h,p]=x.useState([]),[g,v]=x.useState([]),[b,w]=x.useState(!1),[j,N]=x.useState(!1),C=x.useRef(null),O=()=>{s({partner:"",groupName:"",locationCode:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}),d(kt),f(kt),p([]),v([])};x.useEffect(()=>{e||(C.current?.abort(),O(),a(!1))},[e]),x.useEffect(()=>{if(!e)return;C.current?.abort();const E=new AbortController;return C.current=E,w(!0),(async()=>{try{const T=await nz(E.signal);p(T)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load companies.",{description:T?.message?String(T.message):"Please try again."}),p([])}finally{w(!1)}})(),()=>E.abort()},[e]),x.useEffect(()=>{if(!e||l===kt){v([]),f(kt),N(!1);return}const E=new AbortController;return N(!0),(async()=>{try{const T=await az(l,E.signal);v(T),f(kt)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load regions.",{description:T?.message?String(T.message):"Please try again."}),v([])}finally{N(!1)}})(),()=>E.abort()},[e,l]);const P=async()=>{const E=oz(i);if(E.length){ee.error("Please fill in required fields.",{description:`Missing: ${E.join(", ")}.`});return}const T=l!==kt?h.find(M=>M.id===l):void 0,A=u!==kt?g.find(M=>M.id===u):void 0;a(!0);try{await pme({...i,locationCode:i.locationCode.trim(),locationName:i.locationName.trim(),partner:T?.partnerName?.trim()?T.partnerName.trim():null,groupName:A?.groupName?.trim()?A.groupName.trim():null,street:(i.street??"").trim(),city:(i.city??"").trim(),stateCode:(i.stateCode??"").trim(),country:(i.country??"").trim(),zipCode:(i.zipCode??"").trim(),phone:(i.phone??"").trim(),email:(i.email??"").trim(),latitude:i.latitude,longitude:i.longitude}),ee.success("Location created.",{description:"The location has been added successfully."}),t(!1),r()}catch(M){ee.error("Failed to create location.",{description:M?.message?String(M.message):"Please try again."})}finally{a(!1)}};return o.jsx(_t,{open:e,onOpenChange:t,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Add New Location"}),o.jsx(It,{children:"Enter the details for the new store location."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Company"}),o.jsxs($e,{value:l,onValueChange:E=>{d(E),f(kt)},disabled:b,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:b?"Loading...":"e.g. Global Foods Inc."})}),o.jsxs(ze,{children:[o.jsx(Se,{value:kt,children:"None"}),h.map(E=>o.jsx(Se,{value:E.id,children:E.partnerName??E.id},E.id))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Region"}),o.jsxs($e,{value:u,onValueChange:f,disabled:j||l===kt,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:l===kt?"Select a company first":j?"Loading...":"e.g. East Coast Region"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:kt,children:"None"}),g.map(E=>o.jsx(Se,{value:E.id,children:E.groupName??E.id},E.id))]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2 col-span-1",children:[o.jsx(de,{children:"Location ID *"}),o.jsx(me,{placeholder:"e.g. 12345",value:i.locationCode,onChange:E=>s(T=>({...T,locationCode:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2 col-span-2",children:[o.jsx(de,{children:"Location Name *"}),o.jsx(me,{placeholder:"e.g. Downtown Store",value:i.locationName,onChange:E=>s(T=>({...T,locationName:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Street *"}),o.jsx(me,{placeholder:"e.g. 123 Main St",value:i.street??"",onChange:E=>s(T=>({...T,street:E.target.value}))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"City *"}),o.jsx(me,{placeholder:"e.g. New York",value:i.city??"",onChange:E=>s(T=>({...T,city:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"State *"}),o.jsx(me,{placeholder:"e.g. NY",value:i.stateCode??"",onChange:E=>s(T=>({...T,stateCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Country *"}),o.jsx(me,{placeholder:"e.g. USA",value:i.country??"",onChange:E=>s(T=>({...T,country:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Zip Code *"}),o.jsx(me,{placeholder:"e.g. 10001",value:i.zipCode??"",onChange:E=>s(T=>({...T,zipCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Phone Number *"}),o.jsx(me,{placeholder:"+1 (555) 000-0000",value:i.phone??"",onChange:E=>s(T=>({...T,phone:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Email *"}),o.jsx(me,{placeholder:"store@example.com",value:i.email??"",onChange:E=>s(T=>({...T,email:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(de,{className:"flex items-center gap-2",children:[o.jsx(lu,{className:"w-4 h-4"})," GPS Coordinates *"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(me,{placeholder:"Latitude (e.g. 40.7128)",value:i.latitude===null||i.latitude===void 0?"":String(i.latitude),onChange:E=>{const T=E.target.value.trim();s(A=>({...A,latitude:T?Number(T):null}))}}),o.jsx(me,{placeholder:"Longitude (e.g. -74.0060)",value:i.longitude===null||i.longitude===void 0?"":String(i.longitude),onChange:E=>{const T=E.target.value.trim();s(A=>({...A,longitude:T?Number(T):null}))}})]})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx(br,{id:"loc-status",checked:!!i.state,onCheckedChange:E=>s(T=>({...T,state:E}))}),o.jsx(de,{htmlFor:"loc-status",children:"Active Location"})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(ce,{disabled:n,onClick:P,className:"bg-blue-600 text-white hover:bg-blue-700",children:n?"Creating...":"Create Location"})]})]})})}function C0e(e){return{partner:e.partner??"",groupName:e.groupName??"",locationCode:e.locationCode??"",locationName:e.locationName??"",street:e.street??"",city:e.city??"",stateCode:e.stateCode??"",country:e.country??"",zipCode:e.zipCode??"",phone:e.phone??"",email:e.email??"",latitude:e.latitude??null,longitude:e.longitude??null,state:!!e.state}}function _0e({open:e,location:t,onOpenChange:r,onUpdated:n}){const[a,i]=x.useState(!1),[s,l]=x.useState({partner:"",groupName:"",locationCode:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}),[d,u]=x.useState(kt),[f,h]=x.useState(kt),[p,g]=x.useState([]),[v,b]=x.useState([]),[w,j]=x.useState(!1),[N,C]=x.useState(!1),O=x.useRef(kt);x.useEffect(()=>{if(!e){i(!1),u(kt),h(kt),g([]),b([]),O.current=kt;return}if(!t)return;l(C0e(t)),i(!1),O.current=kt,u(kt),h(kt);const E=new AbortController;return j(!0),(async()=>{try{const T=await nz(E.signal);g(T);const A=(t.partner??"").trim().toLowerCase();let M=kt;if(A){const R=T.find(L=>(L.partnerName??"").trim().toLowerCase()===A);R&&(M=R.id)}O.current=M,u(M)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load companies.",{description:T?.message?String(T.message):"Please try again."}),g([])}finally{j(!1)}})(),()=>E.abort()},[e,t?.id]),x.useEffect(()=>{if(!e||d===kt){b([]),h(kt),C(!1);return}const E=new AbortController;return C(!0),(async()=>{try{const T=await az(d,E.signal);b(T);let A=kt;const M=O.current;if(!!t&&M!=="__user__"&&M!==kt&&d===M){const L=(t.groupName??"").trim().toLowerCase();if(L){const V=T.find(z=>(z.groupName??"").trim().toLowerCase()===L);V&&(A=V.id)}}h(A)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load regions.",{description:T?.message?String(T.message):"Please try again."}),b([])}finally{C(!1)}})(),()=>E.abort()},[e,d,t?.groupName,t?.id]);const P=async()=>{if(!t?.id)return;const E=oz(s);if(E.length){ee.error("Please fill in required fields.",{description:`Missing: ${E.join(", ")}.`});return}const T=d!==kt?p.find(M=>M.id===d):void 0,A=f!==kt?v.find(M=>M.id===f):void 0;i(!0);try{await gme(t.id,{...s,locationCode:s.locationCode.trim(),locationName:s.locationName.trim(),partner:T?.partnerName?.trim()?T.partnerName.trim():null,groupName:A?.groupName?.trim()?A.groupName.trim():null,street:(s.street??"").trim(),city:(s.city??"").trim(),stateCode:(s.stateCode??"").trim(),country:(s.country??"").trim(),zipCode:(s.zipCode??"").trim(),phone:(s.phone??"").trim(),email:(s.email??"").trim(),latitude:s.latitude,longitude:s.longitude}),ee.success("Location updated.",{description:"The changes have been saved successfully."}),r(!1),n()}catch(M){ee.error("Failed to update location.",{description:M?.message?String(M.message):"Please try again."})}finally{i(!1)}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Edit Location"}),o.jsx(It,{children:"Update the details for this store location."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Company"}),o.jsxs($e,{value:d,onValueChange:E=>{O.current="__user__",u(E),h(kt)},disabled:w,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:w?"Loading...":"e.g. Global Foods Inc."})}),o.jsxs(ze,{children:[o.jsx(Se,{value:kt,children:"None"}),p.map(E=>o.jsx(Se,{value:E.id,children:E.partnerName??E.id},E.id))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Region"}),o.jsxs($e,{value:f,onValueChange:h,disabled:N||d===kt,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:d===kt?"Select a company first":N?"Loading...":"e.g. East Coast Region"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:kt,children:"None"}),v.map(E=>o.jsx(Se,{value:E.id,children:E.groupName??E.id},E.id))]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2 col-span-1",children:[o.jsx(de,{children:"Location ID *"}),o.jsx(me,{placeholder:"e.g. 12345",value:s.locationCode,onChange:E=>l(T=>({...T,locationCode:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2 col-span-2",children:[o.jsx(de,{children:"Location Name *"}),o.jsx(me,{placeholder:"e.g. Downtown Store",value:s.locationName,onChange:E=>l(T=>({...T,locationName:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Street *"}),o.jsx(me,{placeholder:"e.g. 123 Main St",value:s.street??"",onChange:E=>l(T=>({...T,street:E.target.value}))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"City *"}),o.jsx(me,{placeholder:"e.g. New York",value:s.city??"",onChange:E=>l(T=>({...T,city:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"State *"}),o.jsx(me,{placeholder:"e.g. NY",value:s.stateCode??"",onChange:E=>l(T=>({...T,stateCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Country *"}),o.jsx(me,{placeholder:"e.g. USA",value:s.country??"",onChange:E=>l(T=>({...T,country:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Zip Code *"}),o.jsx(me,{placeholder:"e.g. 10001",value:s.zipCode??"",onChange:E=>l(T=>({...T,zipCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Phone Number *"}),o.jsx(me,{placeholder:"+1 (555) 000-0000",value:s.phone??"",onChange:E=>l(T=>({...T,phone:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Email *"}),o.jsx(me,{placeholder:"store@example.com",value:s.email??"",onChange:E=>l(T=>({...T,email:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(de,{className:"flex items-center gap-2",children:[o.jsx(lu,{className:"w-4 h-4"})," GPS Coordinates *"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(me,{placeholder:"Latitude (e.g. 40.7128)",value:s.latitude===null||s.latitude===void 0?"":String(s.latitude),onChange:E=>{const T=E.target.value.trim();l(A=>({...A,latitude:T?Number(T):null}))}}),o.jsx(me,{placeholder:"Longitude (e.g. -74.0060)",value:s.longitude===null||s.longitude===void 0?"":String(s.longitude),onChange:E=>{const T=E.target.value.trim();l(A=>({...A,longitude:T?Number(T):null}))}})]})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx(br,{id:"loc-status-edit",checked:!!s.state,onCheckedChange:E=>l(T=>({...T,state:E}))}),o.jsx(de,{htmlFor:"loc-status-edit",children:"Active Location"})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:a,onClick:P,className:"bg-blue-600 text-white hover:bg-blue-700",children:a?"Saving...":"Save Changes"})]})]})})}function E0e({open:e,location:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>{const d=(t?.locationCode??"").trim(),u=(t?.locationName??"").trim();return d&&u?`${d} - ${u}`:d||u||"this location"},[t?.locationCode,t?.locationName]),l=async()=>{if(t?.id){i(!0);try{await yme(t.id),ee.success("Location deleted.",{description:"The location has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete location.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Location"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}const P0e="00000000-0000-0000-0000-000000000000";function Es(e){return e==null?"":String(e).trim()}function O0e(e){const t=(e??"").trim();return t?t.toLowerCase()!==P0e:!1}function T0e(e){const t=e.trim();return t?Number(t.replace(/\D/g,""))||0:null}function k0e(e){const t=Array.isArray(e.locationIds)?e.locationIds:[];return{id:Es(e.id),fullName:Es(e.fullName),userName:Es(e.userName),password:"",email:Es(e.email),phone:Es(e.phone),roleId:Es(e.roleId),locationIdsCsv:t.map(r=>Es(r)).filter(Boolean).join(","),state:e.state!==!1}}function A0e(){return{id:"",fullName:"",userName:"",password:"",email:"",phone:"",roleId:"",locationIdsCsv:"",state:!0}}function I0e(e){return e.split(/[,;|\s]+/).map(t=>t.trim()).filter(Boolean)}function M0e({seed:e,onBack:t,onSaved:r}){const[n,a]=x.useState([]),[i,s]=x.useState([]),[l,d]=x.useState(!1),u=x.useMemo(()=>Math.max(e.length+10,10),[e.length]);x.useEffect(()=>{let g=!1;return(async()=>{try{const v=[];let b=1;const w=100;for(;;){const j=await lE({skipCount:b,maxResultCount:w});if(v.push(...j.items??[]),!j.items||j.items.length50))break}g||s(v)}catch{g||s([])}})(),()=>{g=!0}},[]),x.useEffect(()=>{const g=e.map(k0e),v=Math.max(0,u-g.length);a([...g,...Array.from({length:v},()=>A0e())])},[e,u]);const f=(g,v)=>{a(b=>{const w=[...b];return w[g]={...w[g],...v},w})},h=g=>{a(v=>v.length<=1?v:v.filter((b,w)=>w!==g))},p=async()=>{const g=n.filter(v=>O0e(v.id)).map(v=>{const b={id:v.id.trim(),fullName:v.fullName.trim(),userName:v.userName.trim(),email:v.email.trim()||null,phone:T0e(v.phone),roleId:v.roleId.trim(),locationIds:I0e(v.locationIdsCsv),state:v.state!==!1},w=v.password.trim();return w&&(b.password=w),b});if(g.length===0){ee.error("No valid rows",{description:"Select team members in the list first."});return}d(!0);try{const v=await e0e({items:g});ee.success("Bulk update finished",{description:`Success: ${v.successCount}, failed: ${v.failCount}`}),r(),t()}catch(v){const b=v instanceof Yr||v instanceof Error?v.message:"Save failed.";ee.error("Bulk save failed",{description:b})}finally{d(!1)}};return o.jsxs("div",{className:"flex flex-col h-full min-h-0 bg-white",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-gray-200 shrink-0",children:[o.jsx(ce,{type:"button",variant:"outline",onClick:t,children:"Back"}),o.jsx("h1",{className:"text-base font-semibold text-gray-900 flex-1 text-center truncate px-2",children:"Team member bulk edit"}),o.jsx(ce,{type:"button",className:"bg-green-600 hover:bg-green-700 text-white shrink-0",disabled:l,onClick:()=>void p(),children:l?"Saving…":"Save All"})]}),o.jsx("div",{className:"overflow-auto flex-1 min-h-0 px-2 py-3",children:o.jsxs("table",{className:"w-full text-xs border-collapse border border-gray-200",children:[o.jsx("thead",{className:"bg-gray-100 sticky top-0 z-10",children:o.jsxs("tr",{children:[o.jsx("th",{className:"border p-1 w-8"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Full name *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"User name *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Password"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Email"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Phone"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Role *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location IDs"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Active"})]})}),o.jsx("tbody",{children:n.map((g,v)=>o.jsxs("tr",{children:[o.jsx("td",{className:"border p-0 text-center align-top",children:o.jsxs("div",{className:"flex flex-col items-center gap-1 py-1",children:[o.jsx("span",{className:"text-[10px] text-gray-500",children:v+1}),o.jsx(ce,{type:"button",variant:"ghost",size:"sm",className:"h-6 text-[10px] px-1",onClick:()=>h(v),children:"×"})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:g.fullName,onChange:b=>f(v,{fullName:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:g.userName,onChange:b=>f(v,{userName:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",type:"password",placeholder:"(unchanged)",value:g.password,onChange:b=>f(v,{password:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[120px]",value:g.email,onChange:b=>f(v,{email:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[88px]",value:g.phone,onChange:b=>f(v,{phone:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top min-w-[140px]",children:o.jsxs($e,{value:g.roleId||"__none__",onValueChange:b=>f(v,{roleId:b==="__none__"?"":b}),children:[o.jsx(Be,{className:"h-7 text-xs",children:o.jsx(Fe,{placeholder:"Role"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"__none__",children:"(select)"}),i.map(b=>o.jsx(Se,{value:b.id,children:b.roleName??b.id},b.id))]})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[140px]",value:g.locationIdsCsv,onChange:b=>f(v,{locationIdsCsv:b.target.value}),placeholder:"guid1,guid2"})}),o.jsx("td",{className:"border p-1 text-center align-middle",children:o.jsx(br,{checked:g.state!==!1,onCheckedChange:b=>f(v,{state:!!b})})})]},`${g.id||"e"}-${v}`))})]})}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 text-center text-xs text-gray-500 shrink-0 space-y-1",children:[o.jsx("p",{children:"Leave password empty to keep the current password."}),o.jsx("p",{children:"Location IDs: comma-separated location primary keys."})]})]})}function r$(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.click(),URL.revokeObjectURL(r)}function Ip(e){if(e!=="all")return e==="active"}async function R0e(e){const t=[];let r=1;const n=100;for(;;){const i=await uh({skipCount:r,maxResultCount:n},e);if(t.push(...i.items??[]),!i.items||i.items.length200))break}const a=new Map;for(const i of t)i.id&&!a.has(i.id)&&a.set(i.id,i);return Array.from(a.values())}async function D0e(e){const t=[];let r=1;const n=100;for(;;){const i=await uh({skipCount:r,maxResultCount:n,state:!0},e);if(t.push(...i.items??[]),!i.items||i.items.length200))break}const a=new Map;for(const i of t)i.id&&!a.has(i.id)&&a.set(i.id,i);return Array.from(a.values())}const L0e=[{id:"Roles",label:"Roles"},{id:"Partner",label:"Company"},{id:"Group",label:"Region"},{id:"Location Manager",label:"Location Manager"},{id:"Team Member",label:"Team Member"}];function eC(e,t){const r=(e??"").trim();return r?/^partner admin$/i.test(r)?"Company Admin":r:(t??"").trim()||"N/A"}function $0e({initialSubTab:e,onInitialSubTabConsumed:t}={}){const[r,n]=x.useState("Roles");x.useEffect(()=>{e==="Location Manager"&&(n("Location Manager"),t?.())},[e,t]),x.useEffect(()=>{r!=="Team Member"&&(ml(!1),pl([]))},[r]);const[a,i]=x.useState([]),[s,l]=x.useState(0),[d,u]=x.useState(!1),[f,h]=x.useState(0),[p,g]=x.useState(1),[v,b]=x.useState(10),w=Math.max(1,Math.ceil(s/v)),j=x.useRef(null),[N,C]=x.useState(""),O=x.useRef(null),[P,E]=x.useState(""),[T,A]=x.useState([]),[M,R]=x.useState(0),[L,V]=x.useState(!1),[z,G]=x.useState(1),[H,W]=x.useState(10),q=Math.max(1,Math.ceil(M/H)),I=x.useRef(null),[Y,F]=x.useState(""),D=x.useRef(null),[$,K]=x.useState(""),[J,oe]=x.useState("all"),[re,Q]=x.useState(0),[ue,se]=x.useState([]),[fe,we]=x.useState(0),[Z,je]=x.useState(!1),[Ce,qe]=x.useState(1),[De,He]=x.useState(10),ne=Math.max(1,Math.ceil(fe/De)),pe=x.useRef(null),[_e,ve]=x.useState(""),ke=x.useRef(null),[Ge,xe]=x.useState(""),[Je,dt]=x.useState("all"),[jt,Wt]=x.useState("all"),[er,Ae]=x.useState(0),[pt,Ot]=x.useState([]),[Qt,Ar]=x.useState([]),[Vn,Jr]=x.useState(!1),[Ur,Er]=x.useState(0),[qt,gr]=x.useState(0),[Kt,fr]=x.useState(1),[tr,Qe]=x.useState(10),Tt=Math.max(1,Math.ceil(Ur/tr)),Lt=x.useRef(null),[sr,be]=x.useState(""),Le=x.useRef(null),[rt,Xt]=x.useState(""),[vt,hr]=x.useState(null),[Qr,Ir]=x.useState(!1),[Ao,hl]=x.useState(null),[Ou,es]=x.useState(()=>new Set),[Bv,ao]=x.useState(!1),[ph,ml]=x.useState(!1),[zv,pl]=x.useState([]),[gh,Tu]=x.useState(!1),[ku,yh]=x.useState(!1),[Uv,lr]=x.useState(!1),[qv,ts]=x.useState(null),[vh,rs]=x.useState(!1),[Vv,Au]=x.useState(null),[gl,Wn]=x.useState(!1),[Wv,_n]=x.useState(null),[Hv,Iu]=x.useState(!1),[Gv,mi]=x.useState(null),[yl,pi]=x.useState(!1),[vl,xh]=x.useState(null),[Yv,ns]=x.useState(!1),[bh,as]=x.useState(null),[os,wh]=x.useState(!1),[Mu,$t]=x.useState(null),[Sh,xl]=x.useState(!1),Ru=async()=>{try{if(r==="Partner"){const ae=Ip(J),Ze=await l0e({keyword:$||void 0,state:ae,sorting:"CreationTime desc"});r$(Ze,`companies_${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.pdf`),ee.success("Export started.",{description:"Company PDF downloaded."});return}if(r==="Group"){const ae=Ip(jt),Ze=await g0e({keyword:Ge||void 0,partnerId:Je!=="all"?Je:void 0,state:ae,sorting:"CreationTime desc"});r$(Ze,`regions_${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.pdf`),ee.success("Export started.",{description:"Region PDF downloaded."});return}ee.message("Export not available for this tab.",{description:"Use Company or Region tab."})}catch(ae){ee.error("Export failed.",{description:ae?.message?String(ae.message):"Please try again."})}};x.useEffect(()=>(O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>E(N.trim()),300),()=>{O.current&&window.clearTimeout(O.current)}),[N]),x.useEffect(()=>(Le.current&&window.clearTimeout(Le.current),Le.current=window.setTimeout(()=>Xt(sr.trim()),300),()=>{Le.current&&window.clearTimeout(Le.current)}),[sr]),x.useEffect(()=>{es(new Set)},[rt,Kt]),x.useEffect(()=>(D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>K(Y.trim()),300),()=>{D.current&&window.clearTimeout(D.current)}),[Y]),x.useEffect(()=>(ke.current&&window.clearTimeout(ke.current),ke.current=window.setTimeout(()=>xe(_e.trim()),300),()=>{ke.current&&window.clearTimeout(ke.current)}),[_e]),x.useEffect(()=>{g(1)},[P,v]),x.useEffect(()=>{fr(1)},[rt,tr]),x.useEffect(()=>{G(1)},[$,H,J]),x.useEffect(()=>{qe(1)},[Ge,De,Je,jt]),x.useEffect(()=>{if(r!=="Group")return;const ae=new AbortController;return(async()=>{try{const Ze=await R0e(ae.signal);Ot(Ze)}catch(Ze){if(Ze?.name==="AbortError")return;Ot([])}})(),()=>ae.abort()},[r,re]),x.useEffect(()=>r!=="Partner"?void 0:((async()=>{I.current?.abort();const Ze=new AbortController;I.current=Ze,V(!0);try{const xt=await uh({skipCount:Math.max(1,z),maxResultCount:H,keyword:$||void 0,state:Ip(J),sorting:"CreationTime desc"},Ze.signal);A(xt.items??[]),R(xt.totalCount??0)}catch(xt){if(xt?.name==="AbortError")return;ee.error("Failed to load companies.",{description:xt?.message?String(xt.message):"Please try again."}),A([]),R(0)}finally{V(!1)}})(),()=>I.current?.abort()),[r,$,z,H,J,re]),x.useEffect(()=>r!=="Group"?void 0:((async()=>{pe.current?.abort();const Ze=new AbortController;pe.current=Ze,je(!0);try{const xt=await cE({skipCount:Math.max(1,Ce),maxResultCount:De,keyword:Ge||void 0,partnerId:Je!=="all"?Je:void 0,state:Ip(jt),sorting:"CreationTime desc"},Ze.signal);se(xt.items??[]),we(xt.totalCount??0)}catch(xt){if(xt?.name==="AbortError")return;ee.error("Failed to load regions.",{description:xt?.message?String(xt.message):"Please try again."}),se([]),we(0)}finally{je(!1)}})(),()=>pe.current?.abort()),[r,Ge,Ce,De,Je,jt,er]),x.useEffect(()=>r!=="Roles"?void 0:((async()=>{j.current?.abort();const Ze=new AbortController;j.current=Ze,u(!0);try{const xt=await lE({skipCount:Math.max(1,p),maxResultCount:v,roleName:P||void 0},Ze.signal);i(xt.items??[]),l(xt.totalCount??0)}catch(xt){if(xt?.name==="AbortError")return;ee.error("Failed to load roles.",{description:xt?.message?String(xt.message):"Please try again."}),i([]),l(0)}finally{u(!1)}})(),()=>j.current?.abort()),[r,P,p,v,f]),x.useEffect(()=>r!=="Team Member"?void 0:((async()=>{Lt.current?.abort();const Ze=new AbortController;Lt.current=Ze,Jr(!0);try{const xt=await Vve({skipCount:Math.max(1,Kt),maxResultCount:tr,keyword:rt||void 0},Ze.signal);Ar(xt.items??[]),Er(xt.totalCount??0)}catch(xt){if(xt?.name==="AbortError")return;ee.error("Failed to load team members.",{description:xt?.message?String(xt.message):"Please try again."}),Ar([]),Er(0)}finally{Jr(!1)}})(),()=>Lt.current?.abort()),[r,rt,Kt,tr,qt]);const jh=()=>{switch(r){case"Roles":ts(null),lr(!0);break;case"Partner":mi(null),Iu(!0);break;case"Group":as(null),ns(!0);break;case"Team Member":hr(null),xl(!0);break}},bl=()=>o.jsx("div",{className:"w-full border-b border-gray-200",children:o.jsx("div",{className:"flex overflow-x-auto w-fit",children:L0e.map(({id:ae,label:Ze})=>o.jsx("button",{type:"button",onClick:()=>n(ae),style:r===ae?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:Ie("px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2",r===ae?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"),children:Ze},ae))})}),Nh=()=>o.jsxs("div",{className:"flex flex-col gap-4 pb-4",children:[o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:r==="Roles"?N:r==="Team Member"?sr:r==="Partner"?Y:r==="Group"?_e:"",onChange:ae=>{r==="Roles"&&C(ae.target.value),r==="Team Member"&&be(ae.target.value),r==="Partner"&&F(ae.target.value),r==="Group"&&ve(ae.target.value)},style:{height:40,boxSizing:"border-box"},className:"border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"}),r==="Partner"&&o.jsxs($e,{value:J,onValueChange:ae=>oe(ae),children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Status"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All statuses"}),o.jsx(Se,{value:"active",children:"Active"}),o.jsx(Se,{value:"inactive",children:"Inactive"})]})]}),r==="Group"&&o.jsxs(o.Fragment,{children:[o.jsxs($e,{value:Je,onValueChange:dt,children:[o.jsx(Be,{className:"w-[180px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Parent company"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"Company (All)"}),pt.map(ae=>o.jsx(Se,{value:ae.id,children:ae.partnerName??ae.id},ae.id))]})]}),o.jsxs($e,{value:jt,onValueChange:ae=>Wt(ae),children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Status"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"all",children:"All statuses"}),o.jsx(Se,{value:"active",children:"Active"}),o.jsx(Se,{value:"inactive",children:"Inactive"})]})]})]}),o.jsx("div",{className:"flex-1"}),r==="Team Member"&&o.jsxs(o.Fragment,{children:[o.jsx(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>ao(!0),children:"Bulk Import"}),o.jsx(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",disabled:ku,onClick:async()=>{yh(!0);try{await Qve({keyword:rt||void 0}),ee.success("Export started.",{description:"Team member PDF download should begin shortly."})}catch(ae){const Ze=ae instanceof Error?ae.message:"Please try again.";ee.error("Export failed.",{description:Ze})}finally{yh(!1)}},children:ku?"Exporting…":"Bulk Export (PDF)"}),o.jsx(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>{const ae=Qt.filter(Ze=>Ou.has(Ze.id));if(ae.length===0){ee.error("No rows selected",{description:"Use the checkboxes on the left, then open Bulk Edit."});return}pl(ae),ml(!0)},children:"Bulk Edit"})]}),(r==="Partner"||r==="Group")&&o.jsx(ce,{variant:"outline",onClick:Ru,className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",children:"Bulk Export (PDF)"}),o.jsx(ce,{className:"h-10 bg-blue-600 hover:bg-blue-700 text-white rounded-md px-6 font-medium shrink-0",onClick:jh,children:"New+"})]}),bl()]}),wl=()=>{switch(r){case"Roles":return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r",children:"Role Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Role Code"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Order"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:a.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:d?"Loading...":"No data"})}):a.map(ae=>o.jsxs(nt,{children:[o.jsx(ye,{className:"font-medium border-r",children:eC(ae.roleName)}),o.jsx(ye,{className:"border-r text-gray-600",children:ae.roleCode??"N/A"}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"Active":"Inactive"})}),o.jsx(ye,{className:"border-r text-gray-600",children:ae.orderNum??"N/A"}),o.jsxs(ye,{className:"text-center",children:[o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{Au(ae),rs(!0)},title:"Menu Permissions",children:o.jsx(Qq,{className:"w-4 h-4 text-blue-600"})}),o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{ts(ae),lr(!0)},children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(ce,{variant:"ghost",size:"sm",onClick:async()=>{_n(ae),Wn(!0)},title:"Delete role",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",s===0?0:(p-1)*v+1,"-",Math.min(p*v,s)," of ",s]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(v),onValueChange:ae=>b(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(Se,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),g(Ze=>Math.max(1,Ze-1))},"aria-disabled":p<=1,className:p<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",p," / ",w]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),g(Ze=>Math.min(w,Ze+1))},"aria-disabled":p>=w,className:p>=w?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Partner":return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r",children:"Company Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Contact"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Phone"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:L?o.jsx(nt,{children:o.jsx(ye,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):T.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):T.map(ae=>o.jsxs(nt,{children:[o.jsx(ye,{className:"font-medium border-r",children:ae.partnerName??"N/A"}),o.jsx(ye,{className:"border-r",children:(ae.contactEmail??"").trim()?ae.contactEmail:"N/A"}),o.jsx(ye,{className:"border-r text-gray-600",children:(ae.phoneNumber??"").trim()?ae.phoneNumber:"N/A"}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"active":"inactive"})}),o.jsx(ye,{className:"text-center",children:o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{mi(ae),Iu(!0)},title:"Edit",children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{xh(ae),pi(!0)},title:"Delete",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",M===0?0:(z-1)*H+1,"-",Math.min(z*H,M)," of ",M]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(H),onValueChange:ae=>W(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(Se,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),G(Ze=>Math.max(1,Ze-1))},"aria-disabled":z<=1,className:z<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",z," / ",q]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),G(Ze=>Math.min(q,Ze+1))},"aria-disabled":z>=q,className:z>=q?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Group":return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r",children:"Region Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Parent company"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:Z?o.jsx(nt,{children:o.jsx(ye,{colSpan:4,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):ue.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:4,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):ue.map(ae=>o.jsxs(nt,{children:[o.jsx(ye,{className:"font-medium border-r",children:ae.groupName??"N/A"}),o.jsx(ye,{className:"border-r",children:(ae.partnerName??"").trim()?ae.partnerName:"N/A"}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"active":"inactive"})}),o.jsx(ye,{className:"text-center",children:o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{as(ae),ns(!0)},title:"Edit",children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{$t(ae),wh(!0)},title:"Delete",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",fe===0?0:(Ce-1)*De+1,"-",Math.min(Ce*De,fe)," of ",fe]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(De),onValueChange:ae=>He(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(Se,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),qe(Ze=>Math.max(1,Ze-1))},"aria-disabled":Ce<=1,className:Ce<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",Ce," / ",ne]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),qe(Ze=>Math.min(ne,Ze+1))},"aria-disabled":Ce>=ne,className:Ce>=ne?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Team Member":return o.jsxs(o.Fragment,{children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r w-10 text-center",children:o.jsx(Co,{checked:Qt.length>0&&Qt.every(ae=>Ou.has(ae.id)),onCheckedChange:ae=>{es(ae===!0?new Set(Qt.map(Ze=>Ze.id)):new Set)},"aria-label":"Select all on page"})}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Email"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Phone"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Role"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Assigned Locations"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:Vn?o.jsx(nt,{children:o.jsx(ye,{colSpan:8,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):Qt.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:8,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):Qt.map(ae=>o.jsxs(nt,{children:[o.jsx(ye,{className:"border-r w-10 text-center",children:o.jsx(Co,{checked:Ou.has(ae.id),onCheckedChange:Ze=>{es(xt=>{const Io=new Set(xt);return Ze===!0?Io.add(ae.id):Io.delete(ae.id),Io})},"aria-label":"Select row"})}),o.jsx(ye,{className:"font-medium border-r",children:ae.fullName??ae.userName??"N/A"}),o.jsx(ye,{className:"border-r text-gray-600",children:ae.email??"N/A"}),o.jsx(ye,{className:"border-r text-gray-600",children:ae.phone??"N/A"}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{variant:"outline",className:"font-normal",children:eC(ae.roleName,ae.roleId)})}),o.jsx(ye,{className:"border-r",children:o.jsxs("div",{className:"flex flex-col gap-1",children:[(ae.locations?.length?ae.locations:ae.locationIds??[]).map(Ze=>o.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-600",children:[o.jsx(lu,{className:"w-3 h-3"})," ",Ze]},Ze)),!ae.locations?.length&&!(ae.locationIds?.length??0)&&o.jsx("div",{className:"text-xs text-gray-500",children:"None"})]})}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"Active":"Inactive"})}),o.jsx(ye,{className:"text-center",children:o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{hr(ae),xl(!0)},title:"Edit",children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(ce,{variant:"ghost",size:"sm",onClick:()=>{hl(ae),Ir(!0)},title:"Delete",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",Ur===0?0:(Kt-1)*tr+1,"-",Math.min(Kt*tr,Ur)," of ",Ur]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(tr),onValueChange:ae=>Qe(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(Se,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),fr(Ze=>Math.max(1,Ze-1))},"aria-disabled":Kt<=1,className:Kt<=1?"pointer-events-none opacity-50":""})}),o.jsx(wt,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",Kt," / ",Tt]})}),o.jsx(wt,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),fr(Ze=>Math.min(Tt,Ze+1))},"aria-disabled":Kt>=Tt,className:Kt>=Tt?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Location Manager":return o.jsx(j0e,{renderBeforeTabs:ae=>o.jsxs("div",{className:"flex flex-col gap-4 pb-4 shrink-0",children:[ae,bl()]})})}},is=r==="Team Member"&&ph;return o.jsxs("div",{className:"h-full flex flex-col",children:[r!=="Location Manager"&&!is?Nh():null,r==="Location Manager"?o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:wl()}):is?o.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden pt-6",children:[o.jsx("div",{className:"shrink-0 pb-4",children:bl()}),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md flex-1 flex flex-col min-h-0 overflow-hidden",children:o.jsx(M0e,{seed:zv,onBack:()=>{ml(!1),pl([])},onSaved:()=>{es(new Set),gr(ae=>ae+1)}})})})]}):o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md",children:wl()})}),o.jsx(F0e,{open:Uv,role:qv,onOpenChange:ae=>{lr(ae),ae||ts(null)},onSaved:()=>{g(1),h(ae=>ae+1)}}),o.jsx(B0e,{open:vh,role:Vv,onOpenChange:ae=>{rs(ae),ae||Au(null)}}),o.jsx(z0e,{open:gl,role:Wv,onOpenChange:ae=>{Wn(ae),ae||_n(null)},onDeleted:()=>h(ae=>ae+1)}),o.jsx(U0e,{open:Hv,partner:Gv,onOpenChange:ae=>{Iu(ae),ae||mi(null)},onSaved:()=>{G(1),Q(ae=>ae+1)}}),o.jsx(q0e,{open:yl,partner:vl,onOpenChange:ae=>{pi(ae),ae||xh(null)},onDeleted:()=>{Q(ae=>ae+1)}}),o.jsx(V0e,{open:Yv,group:bh,onOpenChange:ae=>{ns(ae),ae||as(null)},onSaved:()=>{qe(1),Ae(ae=>ae+1)}}),o.jsx(W0e,{open:os,group:Mu,onOpenChange:ae=>{wh(ae),ae||$t(null)},onDeleted:()=>{Ae(ae=>ae+1)}}),o.jsx(H0e,{open:Sh,member:vt,onOpenChange:ae=>{xl(ae),ae||hr(null)},onSaved:()=>{fr(1),gr(ae=>ae+1)}}),o.jsx(sE,{open:Bv,onOpenChange:ao,title:"Bulk import team members",description:"Upload an .xlsx file. Use the official template for column headers.",downloadingTemplate:gh,onDownloadTemplate:async()=>{Tu(!0);try{await Jve(),ee.success("Template downloaded.")}catch(ae){const Ze=ae instanceof Error?ae.message:"Download failed.";ee.error("Template download failed",{description:Ze})}finally{Tu(!1)}},onImportFile:async ae=>{const Ze=await Zve(ae);return gr(xt=>xt+1),{successCount:Ze.successCount,failCount:Ze.failCount}}}),o.jsx(G0e,{open:Qr,member:Ao,onOpenChange:ae=>{Ir(ae),ae||hl(null)},onDeleted:()=>{gr(ae=>ae+1)}})]})}function F0e({open:e,role:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=x.useState(!1),[l,d]=x.useState(""),[u,f]=x.useState(""),[h,p]=x.useState(""),[g,v]=x.useState(""),[b,w]=x.useState(!0);x.useEffect(()=>{e&&(s(!1),d(t?.roleName??""),f(t?.roleCode??""),p(t?.remark??""),v(t?.orderNum===null||t?.orderNum===void 0?"":String(t.orderNum)),w(t?.state??!0))},[e,t]);const j=x.useMemo(()=>!!(l.trim()&&u.trim()&&g.trim()),[l,u,g]),N=O=>{const P=O.trim();if(!P)return null;const E=Number.parseInt(P,10);return Number.isFinite(E)?E:null},C=async()=>{if(console.log("submit",t),!j){ee.error("Please fill in required fields.",{description:"Role Name, Role Code, and Order are required."});return}s(!0);try{const O={roleName:l.trim(),roleCode:u.trim(),remark:h.trim()?h.trim():null,state:!!b,orderNum:N(g)};a&&t?.id?(await Lve(t.id,O),ee.success("Role updated.",{description:"Role fields have been saved successfully."})):(await Dve(O),ee.success("Role created.",{description:"A new role has been created successfully."})),r(!1),n()}catch(O){ee.error(a?"Failed to update role.":"Failed to create role.",{description:O?.message?String(O.message):"Please try again."})}finally{s(!1)}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:a?"Edit Role":"Create Role"}),o.jsx(It,{children:a?"Update role fields and save changes.":"Fill out the form to create a new role."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Role Name *"}),o.jsx(me,{value:l,onChange:O=>d(O.target.value),placeholder:"e.g. Inventory Specialist"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Role Code *"}),o.jsx(me,{value:u,onChange:O=>f(O.target.value),placeholder:"e.g. inventory_specialist"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Remark"}),o.jsx(me,{value:h,onChange:O=>p(O.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{value:g,onChange:O=>v(O.target.value),placeholder:"e.g. 10"})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:b,onCheckedChange:w})]})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:i,onClick:C,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function B0e({open:e,role:t,onOpenChange:r}){const n=t?.id??"",a=t?.roleName??"",[i,s]=x.useState(!1),[l,d]=x.useState([]),[u,f]=x.useState(new Set),[h,p]=x.useState(new Set),[g,v]=x.useState(!1),b=x.useRef(null),[w,j]=x.useState(""),N=x.useRef(null),[C,O]=x.useState("");x.useEffect(()=>(N.current&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>O(w.trim()),300),()=>{N.current&&window.clearTimeout(N.current)}),[w]),x.useEffect(()=>e?(s(!1),p(new Set),f(new Set),(async()=>{b.current?.abort();const W=new AbortController;b.current=W,v(!0);try{const q=await _ve(W.signal);if(d(q??[]),n){const I=await zve(n,W.signal);p(new Set(I))}}catch(q){if(q?.name==="AbortError")return;ee.error("Failed to load menus.",{description:q?.message?String(q.message):"Please try again."}),d([]),p(new Set)}finally{v(!1)}})(),()=>b.current?.abort()):void 0,[e,n]);const P=x.useMemo(()=>{const H=W=>W.reduce((q,I)=>q+1+(I.children?H(I.children):0),0);return H(l)},[l]),E=x.useMemo(()=>{const H=C.trim().toLowerCase();if(!H)return l;const W=I=>{const Y=(I.menuName??"").toLowerCase(),F=(I.routeUrl??"").toLowerCase();return Y.includes(H)||F.includes(H)},q=I=>{const Y=[];for(const F of I){const D=F.children?q(F.children):[];(W(F)||D.length)&&Y.push({...F,children:D.length?D:void 0})}return Y};return q(l)},[l,C]);x.useEffect(()=>{if(!C.trim())return;const W=new Set,q=I=>{for(const Y of I)Y.children?.length&&W.add(Y.id),Y.children?.length&&q(Y.children)};q(E),f(W)},[C,E]);const T=H=>{const W=[],q=I=>{I.id&&W.push(I.id),I.children?.length&&I.children.forEach(q)};return q(H),W},A=H=>{const W=T(H);if(!W.length)return{checked:!1,indeterminate:!1};let q=0;for(const I of W)h.has(I)&&(q+=1);return q===0?{checked:!1,indeterminate:!1}:q===W.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},M=(H,W)=>{p(q=>{const I=new Set(q),Y=T(H);return W?Y.forEach(F=>I.add(F)):Y.forEach(F=>I.delete(F)),I})},R=H=>{f(W=>{const q=new Set(W);return q.has(H)?q.delete(H):q.add(H),q})},L=H=>{const W=C.trim(),q=H??"";if(!W)return q||"N/A";const I=q.toLowerCase().indexOf(W.toLowerCase());if(I<0)return q||"N/A";const Y=q.slice(0,I),F=q.slice(I,I+W.length),D=q.slice(I+W.length);return o.jsxs("span",{children:[Y,o.jsx("span",{className:"bg-yellow-200 rounded px-0.5",children:F}),D]})},V=({node:H,depth:W})=>{const q=!!H.children?.length,I=u.has(H.id),{checked:Y,indeterminate:F}=A(H);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 py-1",style:{paddingLeft:W*16},children:[o.jsx("button",{type:"button",className:Ie("h-6 w-6 flex items-center justify-center rounded hover:bg-gray-100",!q&&"opacity-0 pointer-events-none"),onClick:()=>q&&R(H.id),"aria-label":q?I?"Collapse":"Expand":"No children",children:q?I?o.jsx(Bs,{className:"h-4 w-4"}):o.jsx(Ui,{className:"h-4 w-4"}):null}),o.jsx(Co,{id:`perm-menu-${H.id}`,checked:F?"indeterminate":Y,onCheckedChange:D=>M(H,!!D)}),o.jsx("label",{htmlFor:`perm-menu-${H.id}`,className:"text-sm leading-none cursor-pointer select-none",children:L(H.menuName??H.routeUrl??H.id)})]}),q&&I&&o.jsx("div",{children:H.children.map(D=>o.jsx(V,{node:D,depth:W+1},D.id))})]})},z=async()=>{if(console.log("submit",t),!!n){s(!0);try{await Ave({roleId:n,menuIds:Array.from(h)}),ee.success("Role menu permissions saved.",{description:"Menu permissions have been updated successfully."}),r(!1)}catch(H){ee.error("Failed to save menu permissions.",{description:H?.message?String(H.message):"Please try again."})}finally{s(!1)}}},G=async()=>{if(!(!n||h.size===0)){s(!0);try{await Ive({roleId:n,menuIds:Array.from(h)}),p(new Set),ee.success("Role menu permissions cleared.",{description:"Selected permissions have been removed."})}catch(H){ee.error("Failed to delete menu permissions.",{description:H?.message?String(H.message):"Please try again."})}finally{s(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"50%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Menu Permissions"}),o.jsx(It,{children:a?`Set menu permissions for role: ${a}`:"Set menu permissions for this role."})]}),o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"rounded border border-gray-200 bg-white",children:[o.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 border-b border-gray-200",children:o.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[o.jsx("div",{children:g?"Loading menus...":`Total ${P} menus`}),o.jsx(me,{value:w,onChange:H=>j(H.target.value),placeholder:"Search menus",className:"h-8 w-44 bg-white"})]})}),o.jsx(Ec,{className:"h-72",children:o.jsxs("div",{className:"p-3 space-y-2",children:[E.map(H=>o.jsx(V,{node:H,depth:0},H.id)),!g&&E.length===0&&o.jsx("div",{className:"text-sm text-gray-500 py-6 text-center",children:"No menus."})]})})]})}),o.jsxs(Dt,{className:"flex flex-row justify-end gap-2",children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{variant:"destructive",className:"gap-2",disabled:i||h.size===0||!n,onClick:G,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),"Delete Selected"]}),o.jsx(ce,{disabled:i||!n,onClick:z,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function z0e({open:e,role:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>(t?.roleName??"").trim()||t?.roleCode||t?.id||"this role",[t]),l=async()=>{if(console.log("submit",t),!!t?.id){i(!0);try{await Bve(t.id),ee.success("Role deleted.",{description:"The role has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete role.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Role"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function U0e({open:e,partner:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=x.useState(!1),[l,d]=x.useState(""),[u,f]=x.useState(""),[h,p]=x.useState(""),[g,v]=x.useState(!0);x.useEffect(()=>{e&&(s(!1),d(t?.partnerName??""),f(t?.contactEmail??""),p(t?.phoneNumber??""),v(t?.state??!0))},[e,t]);const b=async()=>{if(!l.trim()){ee.error("Company name is required.");return}s(!0);try{a&&t?.id?(await i0e(t.id,{partnerName:l.trim(),contactEmail:u.trim()?u.trim():null,phoneNumber:h.trim()?h.trim():null,state:g}),ee.success("Company updated.")):(await o0e({partnerName:l.trim(),contactEmail:u.trim()?u.trim():null,phoneNumber:h.trim()?h.trim():null,state:g}),ee.success("Company created.")),r(!1),n()}catch(w){ee.error(a?"Failed to update company.":"Failed to create company.",{description:w?.message?String(w.message):"Please try again."})}finally{s(!1)}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:a?"Edit Company":"Create New Company"}),o.jsx(It,{children:a?"Update company details and save.":"Add a new company record."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Company Name *"}),o.jsx(me,{placeholder:"Company Name",value:l,onChange:w=>d(w.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Contact Email"}),o.jsx(me,{placeholder:"admin@company.com",value:u,onChange:w=>f(w.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Phone Number"}),o.jsx(me,{type:"tel",placeholder:"+1 (555) 000-0000",value:h,onChange:w=>p(w.target.value)})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(br,{id:"partner-status",checked:g,onCheckedChange:v}),o.jsx(de,{htmlFor:"partner-status",children:"Active"})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:i,onClick:b,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function q0e({open:e,partner:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=(t?.partnerName??"").trim()||t?.id||"this company",l=async()=>{if(t?.id){i(!0);try{await s0e(t.id),ee.success("Company deleted."),r(!1),n()}catch(d){ee.error("Failed to delete company.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Company"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function V0e({open:e,group:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=x.useState(!1),[l,d]=x.useState(""),[u,f]=x.useState(""),[h,p]=x.useState(!0),[g,v]=x.useState([]),[b,w]=x.useState(!1);x.useEffect(()=>{if(!e)return;const N=new AbortController;return(async()=>{w(!0);try{const C=await D0e(N.signal);v(C)}catch(C){C?.name!=="AbortError"&&(ee.error("Failed to load companies.",{description:C?.message?String(C.message):"Please try again."}),v([]))}finally{w(!1)}})(),()=>N.abort()},[e]),x.useEffect(()=>{e&&(s(!1),d(t?.groupName??""),f(t?.partnerId??""),p(t?.state??!0))},[e,t]);const j=async()=>{if(!l.trim()||!u.trim()){ee.error("Region name and company are required.");return}s(!0);try{a&&t?.id?(await m0e(t.id,{groupName:l.trim(),partnerId:u.trim(),state:h}),ee.success("Region updated.")):(await h0e({groupName:l.trim(),partnerId:u.trim(),state:h}),ee.success("Region created.")),r(!1),n()}catch(N){ee.error(a?"Failed to update region.":"Failed to create region.",{description:N?.message?String(N.message):"Please try again."})}finally{s(!1)}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-[600px]",children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:a?"Edit Region":"Create New Region"}),o.jsx(It,{children:a?"Update region and parent company.":"Create a region under an active company."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Region Name *"}),o.jsx(me,{placeholder:"e.g. West Coast Region",value:l,onChange:N=>d(N.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Assign to Company *"}),o.jsxs($e,{value:u||void 0,onValueChange:f,disabled:b,children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:b?"Loading companies...":"Select Company"})}),o.jsx(ze,{children:g.map(N=>o.jsx(Se,{value:N.id,children:N.partnerName??N.id},N.id))})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(br,{id:"group-status",checked:h,onCheckedChange:p}),o.jsx(de,{htmlFor:"group-status",children:"Active"})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:i||b,onClick:j,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function W0e({open:e,group:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=(t?.groupName??"").trim()||t?.id||"this region",l=async()=>{if(t?.id){i(!0);try{await p0e(t.id),ee.success("Region deleted."),r(!1),n()}catch(d){ee.error("Failed to delete region.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete Region"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function H0e({open:e,member:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=x.useState(!1),[l,d]=x.useState(""),[u,f]=x.useState(""),[h,p]=x.useState(""),[g,v]=x.useState(""),[b,w]=x.useState(""),[j,N]=x.useState(""),[C,O]=x.useState(!0),[P,E]=x.useState(new Set),[T,A]=x.useState([]),[M,R]=x.useState(!1),[L,V]=x.useState([]),[z,G]=x.useState(!1),[H,W]=x.useState(""),q=x.useRef(null),I=()=>{d(""),f(""),p(""),v(""),w(""),N(""),O(!0),E(new Set)},Y=async re=>{const Q=[];let ue=1;const se=100;for(;;){const we=await lE({skipCount:ue,maxResultCount:se},re);if(Q.push(...we.items??[]),!we.items||we.items.length200))break}const fe=new Map;for(const we of Q)we.id&&!fe.has(we.id)&&fe.set(we.id,we);return Array.from(fe.values())},F=async re=>{const Q=[];let ue=1;const se=200;for(;;){const we=await Nu({skipCount:ue,maxResultCount:se},re);if(Q.push(...we.items??[]),!we.items||we.items.length200))break}const fe=new Map;for(const we of Q)we.id&&!fe.has(we.id)&&fe.set(we.id,we);return Array.from(fe.values())};x.useEffect(()=>{if(!e)return;q.current?.abort();const re=new AbortController;return q.current=re,s(!1),I(),R(!0),G(!0),(async()=>{try{const[ue,se]=await Promise.all([Y(re.signal),F(re.signal)]);if(A(ue),V(se),t?.id){const fe=await Wve(t.id,re.signal);d(fe.fullName??""),f(fe.userName??""),v(fe.email??""),w(fe.phone!=null?String(fe.phone):"");let we=(fe.roleId??"").toString().trim();if(!we&&fe.roleName){const je=String(fe.roleName).trim().toLowerCase(),Ce=ue.find(qe=>{const De=String(qe.roleName??"").trim().toLowerCase(),He=String(qe.roleCode??"").trim().toLowerCase(),ne=String(qe.id??"").trim().toLowerCase();return De===je||He===je||ne===je});Ce?.id&&(we=Ce.id)}N(we),O(!!fe.state);const Z=fe.locationIds&&fe.locationIds.length?fe.locationIds:[];if(Z.length)E(new Set(Z));else if(fe.locations?.length){const je=new Set(fe.locations),Ce=new Set;for(const qe of se){const De=`${(qe.locationCode??"").trim()} - ${(qe.locationName??"").trim()}`.trim(),He=(qe.locationName??"").trim(),ne=(qe.locationCode??"").trim();(je.has(De)||je.has(He)||je.has(ne))&&Ce.add(qe.id)}E(Ce)}}}catch(ue){ue?.name!=="AbortError"&&ee.error("Failed to load user form.",{description:ue?.message?String(ue.message):"Please try again."})}finally{R(!1),G(!1)}})(),()=>re.abort()},[e,t?.id]);const D=x.useMemo(()=>!(!l.trim()||!u.trim()||!g.trim()||!String(b??"").trim()||!j.trim()||P.size===0||!a&&!h.trim()),[l,u,g,b,j,P,a,h]),$=(re,Q)=>{E(ue=>{const se=new Set(ue);return Q?se.add(re):se.delete(re),se})},K=async re=>{if(re?.preventDefault(),re?.stopPropagation(),console.log("[MemberDialog] submit called",{isEdit:a,memberId:t?.id,canSubmit:D,roleId:j,fullName:l,userName:u,selectedLocationIds:P.size}),!D){const Q=[];l.trim()||Q.push("Full Name"),u.trim()||Q.push("User Name"),g.trim()||Q.push("Email"),String(b??"").trim()||Q.push("Phone"),j.trim()||Q.push("Role"),P.size===0&&Q.push("Locations"),!a&&!h.trim()&&Q.push("Password"),ee.error("Missing required fields.",{description:`Please fill: ${Q.join(", ")}.`});return}if(!a&&!t?.id){s(!0);try{const Q=Array.from(P);console.log("[MemberDialog] Creating user",{fullName:l,userName:u,roleId:j,locationIds:Q}),await Yve({fullName:l.trim(),userName:u.trim(),password:h.trim(),email:g.trim(),phone:String(b).trim(),roleId:j.trim(),locationIds:Q,state:C}),ee.success("User created.",{description:"A new user has been created successfully."}),r(!1),n()}catch(Q){console.error("[MemberDialog] Create error",Q),ee.error("Failed to create user.",{description:Q?.message?String(Q.message):"Please try again."})}finally{s(!1)}}else if(a&&t?.id){s(!0);try{const Q=Array.from(P);console.log("[MemberDialog] Updating user",{id:t.id,fullName:l,userName:u,roleId:j,locationIds:Q}),await Kve(t.id,{fullName:l.trim(),userName:u.trim(),password:h.trim()?h.trim():null,email:g.trim(),phone:String(b).trim(),roleId:j.trim(),locationIds:Q,state:C}),ee.success("User updated.",{description:"Changes have been saved successfully."}),r(!1),n()}catch(Q){console.error("[MemberDialog] Update error",Q),ee.error("Failed to update user.",{description:Q?.message?String(Q.message):"Please try again."})}finally{s(!1)}}else console.error("[MemberDialog] Invalid state",{isEdit:a,memberId:t?.id}),ee.error("Invalid form state.",{description:"Please refresh and try again."})},J=re=>{const Q=(re.locationCode??"").trim(),ue=(re.locationName??"").trim();return Q&&ue?`${Q} - ${ue}`:ue||Q||re.id},oe=x.useMemo(()=>{const re=H.trim().toLowerCase();return re?L.filter(Q=>J(Q).toLowerCase().includes(re)):L},[L,H]);return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"50%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:a?"Edit User":"New User"}),o.jsx(It,{children:"Role is single-select; Locations is multi-select."})]}),o.jsxs("div",{className:"space-y-4 py-4 max-h-[70vh] overflow-y-auto pr-1",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Full Name *"}),o.jsx(me,{value:l,onChange:re=>d(re.target.value),placeholder:"John Doe"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"User Name *"}),o.jsx(me,{value:u,onChange:re=>f(re.target.value),placeholder:"username"})]})]}),!a&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Password *"}),o.jsx(me,{type:"password",value:h,onChange:re=>p(re.target.value),placeholder:"Enter password",autoComplete:"new-password",className:"w-full"})]}),a&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Password (Optional)"}),o.jsx(me,{type:"password",value:h,onChange:re=>p(re.target.value),placeholder:"Enter new password (optional)",autoComplete:"new-password",className:"w-full"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Email *"}),o.jsx(me,{value:g,onChange:re=>v(re.target.value),placeholder:"john@example.com"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Phone *"}),o.jsx(me,{value:b,onChange:re=>w(re.target.value),placeholder:"+1 (555) 000-0000"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Role *"}),o.jsxs($e,{value:j||"",onValueChange:re=>{const Q=re&&re.trim()?re.trim():"";console.log("[MemberDialog] Role changed",{old:j,new:Q,v:re}),N(Q)},disabled:M,children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:M?"Loading roles...":"Select role"})}),o.jsx(ze,{children:T.map(re=>o.jsx(Se,{value:re.id,children:eC(re.roleName,re.roleCode??re.id)},re.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Locations *"}),o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx(me,{value:H,onChange:re=>W(re.target.value),placeholder:"Search locations",className:"h-9"}),o.jsxs("div",{className:"text-xs text-gray-500 shrink-0",children:[P.size," selected"]})]}),o.jsx(Ec,{className:"h-[180px] w-full border rounded-md p-2",children:o.jsx("div",{className:"space-y-2",children:z?o.jsx("div",{className:"text-sm text-gray-500 py-2",children:"Loading..."}):oe.map(re=>o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Co,{id:`loc-${re.id}`,checked:P.has(re.id),onCheckedChange:Q=>$(re.id,!!Q)}),o.jsx("label",{htmlFor:`loc-${re.id}`,className:"text-sm cursor-pointer w-full hover:bg-gray-50 p-1 rounded",children:J(re)})]},re.id))})}),o.jsx("p",{className:"text-xs text-gray-500",children:"* Users must be assigned to at least one location."})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx(br,{id:"member-status",checked:C,onCheckedChange:O}),o.jsx(de,{htmlFor:"member-status",children:C?"Active":"Inactive"})]})]}),o.jsxs(Dt,{children:[o.jsx(ce,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(ce,{disabled:i||!D,onClick:re=>{re.preventDefault(),re.stopPropagation(),K(re)},className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":a?"Save":"Create"})]})]})})}function G0e({open:e,member:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>{const d=(t?.fullName??"").trim(),u=(t?.userName??"").trim();return d||u||"this user"},[t?.fullName,t?.userName]),l=async()=>{if(console.log("submit",t),!!t?.id){i(!0);try{await Xve(t.id),ee.success("User deleted.",{description:"The user has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete user.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete User"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{variant:"outline",className:"min-w-24",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{variant:"destructive",className:"min-w-24 gap-2",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function Rt(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function ha(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function bn(e,t){const r=Rt(e);return isNaN(t)?ha(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Za(e,t){const r=Rt(e);if(isNaN(t))return ha(e,NaN);if(!t)return r;const n=r.getDate(),a=ha(e,r.getTime());a.setMonth(r.getMonth()+t+1,0);const i=a.getDate();return n>=i?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}const uE=6048e5,Y0e=864e5;let K0e={};function dh(){return K0e}function _o(e,t){const r=dh(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Rt(e),i=a.getDay(),s=(i=a.getTime()?r+1:t.getTime()>=s.getTime()?r:r-1}function su(e){const t=Rt(e);return t.setHours(0,0,0,0),t}function dy(e){const t=Rt(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function yo(e,t){const r=su(e),n=su(t),a=+r-dy(r),i=+n-dy(n);return Math.round((a-i)/Y0e)}function X0e(e){const t=iz(e),r=ha(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),al(r)}function tC(e,t){const r=t*7;return bn(e,r)}function J0e(e,t){return Za(e,t*12)}function Q0e(e){let t;return e.forEach(function(r){const n=Rt(r);(t===void 0||t{const n=Rt(r);(!t||t>n||isNaN(+n))&&(t=n)}),t||new Date(NaN)}function Fn(e,t){const r=su(e),n=su(t);return+r==+n}function dE(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function exe(e){if(!dE(e)&&typeof e!="number")return!1;const t=Rt(e);return!isNaN(Number(t))}function If(e,t){const r=Rt(e),n=Rt(t),a=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return a*12+i}function txe(e,t,r){const n=_o(e,r),a=_o(t,r),i=+n-dy(n),s=+a-dy(a);return Math.round((i-s)/uE)}function fE(e){const t=Rt(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function zn(e){const t=Rt(e);return t.setDate(1),t.setHours(0,0,0,0),t}function sz(e){const t=Rt(e),r=ha(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}function hE(e,t){const r=dh(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Rt(e),i=a.getDay(),s=(i{let n;const a=rxe[e];return typeof a=="string"?n=a:t===1?n=a.one:n=a.other.replace("{{count}}",t.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function ej(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const axe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},oxe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ixe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},sxe={date:ej({formats:axe,defaultWidth:"full"}),time:ej({formats:oxe,defaultWidth:"full"}),dateTime:ej({formats:ixe,defaultWidth:"full"})},lxe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},cxe=(e,t,r,n)=>lxe[e];function Ad(e){return(t,r)=>{const n=r?.context?String(r.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const s=e.defaultFormattingWidth||e.defaultWidth,l=r?.width?String(r.width):s;a=e.formattingValues[l]||e.formattingValues[s]}else{const s=e.defaultWidth,l=r?.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[s]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const uxe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},dxe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},fxe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},hxe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},mxe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},pxe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},gxe=(e,t)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},yxe={ordinalNumber:gxe,era:Ad({values:uxe,defaultWidth:"wide"}),quarter:Ad({values:dxe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ad({values:fxe,defaultWidth:"wide"}),day:Ad({values:hxe,defaultWidth:"wide"}),dayPeriod:Ad({values:mxe,defaultWidth:"wide",formattingValues:pxe,defaultFormattingWidth:"wide"})};function Id(e){return(t,r={})=>{const n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const s=i[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(l)?xxe(l,h=>h.test(s)):vxe(l,h=>h.test(s));let u;u=e.valueCallback?e.valueCallback(d):d,u=r.valueCallback?r.valueCallback(u):u;const f=t.slice(s.length);return{value:u,rest:f}}}function vxe(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function xxe(e,t){for(let r=0;r{const n=t.match(e.matchPattern);if(!n)return null;const a=n[0],i=t.match(e.parsePattern);if(!i)return null;let s=e.valueCallback?e.valueCallback(i[0]):i[0];s=r.valueCallback?r.valueCallback(s):s;const l=t.slice(a.length);return{value:s,rest:l}}}const wxe=/^(\d+)(th|st|nd|rd)?/i,Sxe=/\d+/i,jxe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Nxe={any:[/^b/i,/^(a|c)/i]},Cxe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},_xe={any:[/1/i,/2/i,/3/i,/4/i]},Exe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Pxe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Oxe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Txe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},kxe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Axe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ixe={ordinalNumber:bxe({matchPattern:wxe,parsePattern:Sxe,valueCallback:e=>parseInt(e,10)}),era:Id({matchPatterns:jxe,defaultMatchWidth:"wide",parsePatterns:Nxe,defaultParseWidth:"any"}),quarter:Id({matchPatterns:Cxe,defaultMatchWidth:"wide",parsePatterns:_xe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Id({matchPatterns:Exe,defaultMatchWidth:"wide",parsePatterns:Pxe,defaultParseWidth:"any"}),day:Id({matchPatterns:Oxe,defaultMatchWidth:"wide",parsePatterns:Txe,defaultParseWidth:"any"}),dayPeriod:Id({matchPatterns:kxe,defaultMatchWidth:"any",parsePatterns:Axe,defaultParseWidth:"any"})},cz={code:"en-US",formatDistance:nxe,formatLong:sxe,formatRelative:cxe,localize:yxe,match:Ixe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Mxe(e){const t=Rt(e);return yo(t,sz(t))+1}function uz(e){const t=Rt(e),r=+al(t)-+X0e(t);return Math.round(r/uE)+1}function dz(e,t){const r=Rt(e),n=r.getFullYear(),a=dh(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=ha(e,0);s.setFullYear(n+1,0,i),s.setHours(0,0,0,0);const l=_o(s,t),d=ha(e,0);d.setFullYear(n,0,i),d.setHours(0,0,0,0);const u=_o(d,t);return r.getTime()>=l.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function Rxe(e,t){const r=dh(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=dz(e,t),i=ha(e,0);return i.setFullYear(a,0,n),i.setHours(0,0,0,0),_o(i,t)}function fz(e,t){const r=Rt(e),n=+_o(r,t)-+Rxe(r,t);return Math.round(n/uE)+1}function Yt(e,t){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}const Ii={y(e,t){const r=e.getFullYear(),n=r>0?r:1-r;return Yt(t==="yy"?n%100:n,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):Yt(r+1,2)},d(e,t){return Yt(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return Yt(e.getHours()%12||12,t.length)},H(e,t){return Yt(e.getHours(),t.length)},m(e,t){return Yt(e.getMinutes(),t.length)},s(e,t){return Yt(e.getSeconds(),t.length)},S(e,t){const r=t.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Yt(a,t.length)}},ac={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},n$={G:function(e,t,r){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return Ii.y(e,t)},Y:function(e,t,r,n){const a=dz(e,n),i=a>0?a:1-a;if(t==="YY"){const s=i%100;return Yt(s,2)}return t==="Yo"?r.ordinalNumber(i,{unit:"year"}):Yt(i,t.length)},R:function(e,t){const r=iz(e);return Yt(r,t.length)},u:function(e,t){const r=e.getFullYear();return Yt(r,t.length)},Q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return Yt(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return Yt(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){const n=e.getMonth();switch(t){case"M":case"MM":return Ii.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return Yt(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){const a=fz(e,n);return t==="wo"?r.ordinalNumber(a,{unit:"week"}):Yt(a,t.length)},I:function(e,t,r){const n=uz(e);return t==="Io"?r.ordinalNumber(n,{unit:"week"}):Yt(n,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):Ii.d(e,t)},D:function(e,t,r){const n=Mxe(e);return t==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Yt(n,t.length)},E:function(e,t,r){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return Yt(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return Yt(i,t.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const n=e.getDay(),a=n===0?7:n;switch(t){case"i":return String(a);case"ii":return Yt(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const n=e.getHours();let a;switch(n===12?a=ac.noon:n===0?a=ac.midnight:a=n/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const n=e.getHours();let a;switch(n>=17?a=ac.evening:n>=12?a=ac.afternoon:n>=4?a=ac.morning:a=ac.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Ii.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):Ii.H(e,t)},K:function(e,t,r){const n=e.getHours()%12;return t==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Yt(n,t.length)},k:function(e,t,r){let n=e.getHours();return n===0&&(n=24),t==="ko"?r.ordinalNumber(n,{unit:"hour"}):Yt(n,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ii.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):Ii.s(e,t)},S:function(e,t){return Ii.S(e,t)},X:function(e,t,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return o$(n);case"XXXX":case"XX":return ks(n);case"XXXXX":case"XXX":default:return ks(n,":")}},x:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"x":return o$(n);case"xxxx":case"xx":return ks(n);case"xxxxx":case"xxx":default:return ks(n,":")}},O:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+a$(n,":");case"OOOO":default:return"GMT"+ks(n,":")}},z:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+a$(n,":");case"zzzz":default:return"GMT"+ks(n,":")}},t:function(e,t,r){const n=Math.trunc(e.getTime()/1e3);return Yt(n,t.length)},T:function(e,t,r){const n=e.getTime();return Yt(n,t.length)}};function a$(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),i=n%60;return i===0?r+String(a):r+String(a)+t+Yt(i,2)}function o$(e,t){return e%60===0?(e>0?"-":"+")+Yt(Math.abs(e)/60,2):ks(e,t)}function ks(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Yt(Math.trunc(n/60),2),i=Yt(n%60,2);return r+a+t+i}const i$=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},hz=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Dxe=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return i$(e,t);let i;switch(n){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",i$(n,t)).replace("{{time}}",hz(a,t))},Lxe={p:hz,P:Dxe},$xe=/^D+$/,Fxe=/^Y+$/,Bxe=["D","DD","YY","YYYY"];function zxe(e){return $xe.test(e)}function Uxe(e){return Fxe.test(e)}function qxe(e,t,r){const n=Vxe(e,t,r);if(console.warn(n),Bxe.includes(e))throw new RangeError(n)}function Vxe(e,t,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Wxe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Hxe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Gxe=/^'([^]*?)'?$/,Yxe=/''/g,Kxe=/[a-zA-Z]/;function fl(e,t,r){const n=dh(),a=r?.locale??n.locale??cz,i=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=Rt(e);if(!exe(l))throw new RangeError("Invalid time value");let d=t.match(Hxe).map(f=>{const h=f[0];if(h==="p"||h==="P"){const p=Lxe[h];return p(f,a.formatLong)}return f}).join("").match(Wxe).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const h=f[0];if(h==="'")return{isToken:!1,value:Xxe(f)};if(n$[h])return{isToken:!0,value:f};if(h.match(Kxe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:f}});a.localize.preprocessor&&(d=a.localize.preprocessor(l,d));const u={firstWeekContainsDate:i,weekStartsOn:s,locale:a};return d.map(f=>{if(!f.isToken)return f.value;const h=f.value;(!r?.useAdditionalWeekYearTokens&&Uxe(h)||!r?.useAdditionalDayOfYearTokens&&zxe(h))&&qxe(h,t,String(e));const p=n$[h[0]];return p(l,h,a.localize,u)}).join("")}function Xxe(e){const t=e.match(Gxe);return t?t[1].replace(Yxe,"'"):e}function Jxe(e){const t=Rt(e),r=t.getFullYear(),n=t.getMonth(),a=ha(e,0);return a.setFullYear(r,n+1,0),a.setHours(0,0,0,0),a.getDate()}function Qxe(e){return Math.trunc(+Rt(e)/1e3)}function Zxe(e){const t=Rt(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}function ebe(e,t){return txe(Zxe(e),zn(e),t)+1}function rC(e,t){const r=Rt(e),n=Rt(t);return r.getTime()>n.getTime()}function mz(e,t){const r=Rt(e),n=Rt(t);return+r<+n}function mE(e,t){const r=Rt(e),n=Rt(t);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function tbe(e,t){const r=Rt(e),n=Rt(t);return r.getFullYear()===n.getFullYear()}function tj(e,t){return bn(e,-t)}function rj(e,t){const r=Rt(e),n=r.getFullYear(),a=r.getDate(),i=ha(e,0);i.setFullYear(n,t,15),i.setHours(0,0,0,0);const s=Jxe(i);return r.setMonth(t,Math.min(a,s)),r}function s$(e,t){const r=Rt(e);return isNaN(+r)?ha(e,NaN):(r.setFullYear(t),r)}var ut=function(){return ut=Object.assign||function(t){for(var r,n=1,a=arguments.length;n1&&(d||!u),h=t>1&&(u||!d),p=function(){n&&i(n)},g=function(){a&&i(a)};return o.jsx(Mbe,{displayMonth:e.displayMonth,hideNext:f,hidePrevious:h,nextMonth:a,previousMonth:n,onPreviousClick:p,onNextClick:g})}function Rbe(e){var t,r=ir(),n=r.classNames,a=r.disableNavigation,i=r.styles,s=r.captionLayout,l=r.components,d=(t=l?.CaptionLabel)!==null&&t!==void 0?t:yz,u;return a?u=o.jsx(d,{id:e.id,displayMonth:e.displayMonth}):s==="dropdown"?u=o.jsx(l$,{displayMonth:e.displayMonth,id:e.id}):s==="dropdown-buttons"?u=o.jsxs(o.Fragment,{children:[o.jsx(l$,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),o.jsx(c$,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):u=o.jsxs(o.Fragment,{children:[o.jsx(d,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),o.jsx(c$,{displayMonth:e.displayMonth,id:e.id})]}),o.jsx("div",{className:n.caption,style:i.caption,children:u})}function Dbe(e){var t=ir(),r=t.footer,n=t.styles,a=t.classNames.tfoot;return r?o.jsx("tfoot",{className:a,style:n.tfoot,children:o.jsx("tr",{children:o.jsx("td",{colSpan:8,children:r})})}):o.jsx(o.Fragment,{})}function Lbe(e,t,r){for(var n=r?al(new Date):_o(new Date,{locale:e,weekStartsOn:t}),a=[],i=0;i<7;i++){var s=bn(n,i);a.push(s)}return a}function $be(){var e=ir(),t=e.classNames,r=e.styles,n=e.showWeekNumber,a=e.locale,i=e.weekStartsOn,s=e.ISOWeek,l=e.formatters.formatWeekdayName,d=e.labels.labelWeekday,u=Lbe(a,i,s);return o.jsxs("tr",{style:r.head_row,className:t.head_row,children:[n&&o.jsx("td",{style:r.head_cell,className:t.head_cell}),u.map(function(f,h){return o.jsx("th",{scope:"col",className:t.head_cell,style:r.head_cell,"aria-label":d(f,{locale:a}),children:l(f,{locale:a})},h)})]})}function Fbe(){var e,t=ir(),r=t.classNames,n=t.styles,a=t.components,i=(e=a?.HeadRow)!==null&&e!==void 0?e:$be;return o.jsx("thead",{style:n.head,className:r.head,children:o.jsx(i,{})})}function Bbe(e){var t=ir(),r=t.locale,n=t.formatters.formatDay;return o.jsx(o.Fragment,{children:n(e.date,{locale:r})})}var pE=x.createContext(void 0);function zbe(e){if(!fh(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return o.jsx(pE.Provider,{value:t,children:e.children})}return o.jsx(Ube,{initialProps:e.initialProps,children:e.children})}function Ube(e){var t=e.initialProps,r=e.children,n=t.selected,a=t.min,i=t.max,s=function(u,f,h){var p,g;(p=t.onDayClick)===null||p===void 0||p.call(t,u,f,h);var v=!!(f.selected&&a&&n?.length===a);if(!v){var b=!!(!f.selected&&i&&n?.length===i);if(!b){var w=n?pz([],n):[];if(f.selected){var j=w.findIndex(function(N){return Fn(u,N)});w.splice(j,1)}else w.push(u);(g=t.onSelect)===null||g===void 0||g.call(t,w,u,f,h)}}},l={disabled:[]};n&&l.disabled.push(function(u){var f=i&&n.length>i-1,h=n.some(function(p){return Fn(p,u)});return!!(f&&!h)});var d={selected:n,onDayClick:s,modifiers:l};return o.jsx(pE.Provider,{value:d,children:r})}function gE(){var e=x.useContext(pE);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function qbe(e,t){var r=t||{},n=r.from,a=r.to;return n&&a?Fn(a,e)&&Fn(n,e)?void 0:Fn(a,e)?{from:a,to:void 0}:Fn(n,e)?void 0:rC(n,e)?{from:e,to:a}:{from:n,to:e}:a?rC(e,a)?{from:a,to:e}:{from:e,to:a}:n?mz(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var yE=x.createContext(void 0);function Vbe(e){if(!hh(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return o.jsx(yE.Provider,{value:t,children:e.children})}return o.jsx(Wbe,{initialProps:e.initialProps,children:e.children})}function Wbe(e){var t=e.initialProps,r=e.children,n=t.selected,a=n||{},i=a.from,s=a.to,l=t.min,d=t.max,u=function(g,v,b){var w,j;(w=t.onDayClick)===null||w===void 0||w.call(t,g,v,b);var N=qbe(g,n);(j=t.onSelect)===null||j===void 0||j.call(t,N,g,v,b)},f={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(f.range_start=[i],s?(f.range_end=[s],Fn(i,s)||(f.range_middle=[{after:i,before:s}])):f.range_end=[i]):s&&(f.range_start=[s],f.range_end=[s]),l&&(i&&!s&&f.disabled.push({after:tj(i,l-1),before:bn(i,l-1)}),i&&s&&f.disabled.push({after:i,before:bn(i,l-1)}),!i&&s&&f.disabled.push({after:tj(s,l-1),before:bn(s,l-1)})),d){if(i&&!s&&(f.disabled.push({before:bn(i,-d+1)}),f.disabled.push({after:bn(i,d-1)})),i&&s){var h=yo(s,i)+1,p=d-h;f.disabled.push({before:tj(i,p)}),f.disabled.push({after:bn(s,p)})}!i&&s&&(f.disabled.push({before:bn(s,-d+1)}),f.disabled.push({after:bn(s,d-1)}))}return o.jsx(yE.Provider,{value:{selected:n,onDayClick:u,modifiers:f},children:r})}function vE(){var e=x.useContext(yE);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function qp(e){return Array.isArray(e)?pz([],e):e!==void 0?[e]:[]}function Hbe(e){var t={};return Object.entries(e).forEach(function(r){var n=r[0],a=r[1];t[n]=qp(a)}),t}var eo;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(eo||(eo={}));var Gbe=eo.Selected,Wo=eo.Disabled,Ybe=eo.Hidden,Kbe=eo.Today,nj=eo.RangeEnd,aj=eo.RangeMiddle,oj=eo.RangeStart,Xbe=eo.Outside;function Jbe(e,t,r){var n,a=(n={},n[Gbe]=qp(e.selected),n[Wo]=qp(e.disabled),n[Ybe]=qp(e.hidden),n[Kbe]=[e.today],n[nj]=[],n[aj]=[],n[oj]=[],n[Xbe]=[],n);return e.fromDate&&a[Wo].push({before:e.fromDate}),e.toDate&&a[Wo].push({after:e.toDate}),fh(e)?a[Wo]=a[Wo].concat(t.modifiers[Wo]):hh(e)&&(a[Wo]=a[Wo].concat(r.modifiers[Wo]),a[oj]=r.modifiers[oj],a[aj]=r.modifiers[aj],a[nj]=r.modifiers[nj]),a}var bz=x.createContext(void 0);function Qbe(e){var t=ir(),r=gE(),n=vE(),a=Jbe(t,r,n),i=Hbe(t.modifiers),s=ut(ut({},a),i);return o.jsx(bz.Provider,{value:s,children:e.children})}function wz(){var e=x.useContext(bz);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function Zbe(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function ewe(e){return!!(e&&typeof e=="object"&&"from"in e)}function twe(e){return!!(e&&typeof e=="object"&&"after"in e)}function rwe(e){return!!(e&&typeof e=="object"&&"before"in e)}function nwe(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function awe(e,t){var r,n=t.from,a=t.to;if(n&&a){var i=yo(a,n)<0;i&&(r=[a,n],n=r[0],a=r[1]);var s=yo(e,n)>=0&&yo(a,e)>=0;return s}return a?Fn(a,e):n?Fn(n,e):!1}function owe(e){return dE(e)}function iwe(e){return Array.isArray(e)&&e.every(dE)}function swe(e,t){return t.some(function(r){if(typeof r=="boolean")return r;if(owe(r))return Fn(e,r);if(iwe(r))return r.includes(e);if(ewe(r))return awe(e,r);if(nwe(r))return r.dayOfWeek.includes(e.getDay());if(Zbe(r)){var n=yo(r.before,e),a=yo(r.after,e),i=n>0,s=a<0,l=rC(r.before,r.after);return l?s&&i:i||s}return twe(r)?yo(e,r.after)>0:rwe(r)?yo(r.before,e)>0:typeof r=="function"?r(e):!1})}function xE(e,t,r){var n=Object.keys(t).reduce(function(i,s){var l=t[s];return swe(e,l)&&i.push(s),i},[]),a={};return n.forEach(function(i){return a[i]=!0}),r&&!mE(e,r)&&(a.outside=!0),a}function lwe(e,t){for(var r=zn(e[0]),n=fE(e[e.length-1]),a,i,s=r;s<=n;){var l=xE(s,t),d=!l.disabled&&!l.hidden;if(!d){s=bn(s,1);continue}if(l.selected)return s;l.today&&!i&&(i=s),a||(a=s),s=bn(s,1)}return i||a}var cwe=365;function Sz(e,t){var r=t.moveBy,n=t.direction,a=t.context,i=t.modifiers,s=t.retry,l=s===void 0?{count:0,lastFocused:e}:s,d=a.weekStartsOn,u=a.fromDate,f=a.toDate,h=a.locale,p={day:bn,week:tC,month:Za,year:J0e,startOfWeek:function(w){return a.ISOWeek?al(w):_o(w,{locale:h,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?lz(w):hE(w,{locale:h,weekStartsOn:d})}},g=p[r](e,n==="after"?1:-1);n==="before"&&u?g=Q0e([u,g]):n==="after"&&f&&(g=Z0e([f,g]));var v=!0;if(i){var b=xE(g,i);v=!b.disabled&&!b.hidden}return v?g:l.count>cwe?l.lastFocused:Sz(g,{moveBy:r,direction:n,context:a,modifiers:i,retry:ut(ut({},l),{count:l.count+1})})}var jz=x.createContext(void 0);function uwe(e){var t=mh(),r=wz(),n=x.useState(),a=n[0],i=n[1],s=x.useState(),l=s[0],d=s[1],u=lwe(t.displayMonths,r),f=a??(l&&t.isDateDisplayed(l))?l:u,h=function(){d(a),i(void 0)},p=function(w){i(w)},g=ir(),v=function(w,j){if(a){var N=Sz(a,{moveBy:w,direction:j,context:g,modifiers:r});Fn(a,N)||(t.goToDate(N,a),p(N))}},b={focusedDay:a,focusTarget:f,blur:h,focus:p,focusDayAfter:function(){return v("day","after")},focusDayBefore:function(){return v("day","before")},focusWeekAfter:function(){return v("week","after")},focusWeekBefore:function(){return v("week","before")},focusMonthBefore:function(){return v("month","before")},focusMonthAfter:function(){return v("month","after")},focusYearBefore:function(){return v("year","before")},focusYearAfter:function(){return v("year","after")},focusStartOfWeek:function(){return v("startOfWeek","before")},focusEndOfWeek:function(){return v("endOfWeek","after")}};return o.jsx(jz.Provider,{value:b,children:e.children})}function bE(){var e=x.useContext(jz);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function dwe(e,t){var r=wz(),n=xE(e,r,t);return n}var wE=x.createContext(void 0);function fwe(e){if(!$v(e.initialProps)){var t={selected:void 0};return o.jsx(wE.Provider,{value:t,children:e.children})}return o.jsx(hwe,{initialProps:e.initialProps,children:e.children})}function hwe(e){var t=e.initialProps,r=e.children,n=function(i,s,l){var d,u,f;if((d=t.onDayClick)===null||d===void 0||d.call(t,i,s,l),s.selected&&!t.required){(u=t.onSelect)===null||u===void 0||u.call(t,void 0,i,s,l);return}(f=t.onSelect)===null||f===void 0||f.call(t,i,i,s,l)},a={selected:t.selected,onDayClick:n};return o.jsx(wE.Provider,{value:a,children:r})}function Nz(){var e=x.useContext(wE);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function mwe(e,t){var r=ir(),n=Nz(),a=gE(),i=vE(),s=bE(),l=s.focusDayAfter,d=s.focusDayBefore,u=s.focusWeekAfter,f=s.focusWeekBefore,h=s.blur,p=s.focus,g=s.focusMonthBefore,v=s.focusMonthAfter,b=s.focusYearBefore,w=s.focusYearAfter,j=s.focusStartOfWeek,N=s.focusEndOfWeek,C=function(q){var I,Y,F,D;$v(r)?(I=n.onDayClick)===null||I===void 0||I.call(n,e,t,q):fh(r)?(Y=a.onDayClick)===null||Y===void 0||Y.call(a,e,t,q):hh(r)?(F=i.onDayClick)===null||F===void 0||F.call(i,e,t,q):(D=r.onDayClick)===null||D===void 0||D.call(r,e,t,q)},O=function(q){var I;p(e),(I=r.onDayFocus)===null||I===void 0||I.call(r,e,t,q)},P=function(q){var I;h(),(I=r.onDayBlur)===null||I===void 0||I.call(r,e,t,q)},E=function(q){var I;(I=r.onDayMouseEnter)===null||I===void 0||I.call(r,e,t,q)},T=function(q){var I;(I=r.onDayMouseLeave)===null||I===void 0||I.call(r,e,t,q)},A=function(q){var I;(I=r.onDayPointerEnter)===null||I===void 0||I.call(r,e,t,q)},M=function(q){var I;(I=r.onDayPointerLeave)===null||I===void 0||I.call(r,e,t,q)},R=function(q){var I;(I=r.onDayTouchCancel)===null||I===void 0||I.call(r,e,t,q)},L=function(q){var I;(I=r.onDayTouchEnd)===null||I===void 0||I.call(r,e,t,q)},V=function(q){var I;(I=r.onDayTouchMove)===null||I===void 0||I.call(r,e,t,q)},z=function(q){var I;(I=r.onDayTouchStart)===null||I===void 0||I.call(r,e,t,q)},G=function(q){var I;(I=r.onDayKeyUp)===null||I===void 0||I.call(r,e,t,q)},H=function(q){var I;switch(q.key){case"ArrowLeft":q.preventDefault(),q.stopPropagation(),r.dir==="rtl"?l():d();break;case"ArrowRight":q.preventDefault(),q.stopPropagation(),r.dir==="rtl"?d():l();break;case"ArrowDown":q.preventDefault(),q.stopPropagation(),u();break;case"ArrowUp":q.preventDefault(),q.stopPropagation(),f();break;case"PageUp":q.preventDefault(),q.stopPropagation(),q.shiftKey?b():g();break;case"PageDown":q.preventDefault(),q.stopPropagation(),q.shiftKey?w():v();break;case"Home":q.preventDefault(),q.stopPropagation(),j();break;case"End":q.preventDefault(),q.stopPropagation(),N();break}(I=r.onDayKeyDown)===null||I===void 0||I.call(r,e,t,q)},W={onClick:C,onFocus:O,onBlur:P,onKeyDown:H,onKeyUp:G,onMouseEnter:E,onMouseLeave:T,onPointerEnter:A,onPointerLeave:M,onTouchCancel:R,onTouchEnd:L,onTouchMove:V,onTouchStart:z};return W}function pwe(){var e=ir(),t=Nz(),r=gE(),n=vE(),a=$v(e)?t.selected:fh(e)?r.selected:hh(e)?n.selected:void 0;return a}function gwe(e){return Object.values(eo).includes(e)}function ywe(e,t){var r=[e.classNames.day];return Object.keys(t).forEach(function(n){var a=e.modifiersClassNames[n];if(a)r.push(a);else if(gwe(n)){var i=e.classNames["day_".concat(n)];i&&r.push(i)}}),r}function vwe(e,t){var r=ut({},e.styles.day);return Object.keys(t).forEach(function(n){var a;r=ut(ut({},r),(a=e.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function xwe(e,t,r){var n,a,i,s=ir(),l=bE(),d=dwe(e,t),u=mwe(e,d),f=pwe(),h=!!(s.onDayClick||s.mode!=="default");x.useEffect(function(){var E;d.outside||l.focusedDay&&h&&Fn(l.focusedDay,e)&&((E=r.current)===null||E===void 0||E.focus())},[l.focusedDay,e,r,h,d.outside]);var p=ywe(s,d).join(" "),g=vwe(s,d),v=!!(d.outside&&!s.showOutsideDays||d.hidden),b=(i=(a=s.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:Bbe,w=o.jsx(b,{date:e,displayMonth:t,activeModifiers:d}),j={style:g,className:p,children:w,role:"gridcell"},N=l.focusTarget&&Fn(l.focusTarget,e)&&!d.outside,C=l.focusedDay&&Fn(l.focusedDay,e),O=ut(ut(ut({},j),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=C||N?0:-1,n)),u),P={isButton:h,isHidden:v,activeModifiers:d,selectedDays:f,buttonProps:O,divProps:j};return P}function bwe(e){var t=x.useRef(null),r=xwe(e.date,e.displayMonth,t);return r.isHidden?o.jsx("div",{role:"gridcell"}):r.isButton?o.jsx(fy,ut({name:"day",ref:t},r.buttonProps)):o.jsx("div",ut({},r.divProps))}function wwe(e){var t=e.number,r=e.dates,n=ir(),a=n.onWeekNumberClick,i=n.styles,s=n.classNames,l=n.locale,d=n.labels.labelWeekNumber,u=n.formatters.formatWeekNumber,f=u(Number(t),{locale:l});if(!a)return o.jsx("span",{className:s.weeknumber,style:i.weeknumber,children:f});var h=d(Number(t),{locale:l}),p=function(g){a(t,r,g)};return o.jsx(fy,{name:"week-number","aria-label":h,className:s.weeknumber,style:i.weeknumber,onClick:p,children:f})}function Swe(e){var t,r,n=ir(),a=n.styles,i=n.classNames,s=n.showWeekNumber,l=n.components,d=(t=l?.Day)!==null&&t!==void 0?t:bwe,u=(r=l?.WeekNumber)!==null&&r!==void 0?r:wwe,f;return s&&(f=o.jsx("td",{className:i.cell,style:a.cell,children:o.jsx(u,{number:e.weekNumber,dates:e.dates})})),o.jsxs("tr",{className:i.row,style:a.row,children:[f,e.dates.map(function(h){return o.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:o.jsx(d,{displayMonth:e.displayMonth,date:h})},Qxe(h))})]})}function u$(e,t,r){for(var n=r?.ISOWeek?lz(t):hE(t,r),a=r?.ISOWeek?al(e):_o(e,r),i=yo(n,a),s=[],l=0;l<=i;l++)s.push(bn(a,l));var d=s.reduce(function(u,f){var h=r?.ISOWeek?uz(f):fz(f,r),p=u.find(function(g){return g.weekNumber===h});return p?(p.dates.push(f),u):(u.push({weekNumber:h,dates:[f]}),u)},[]);return d}function jwe(e,t){var r=u$(zn(e),fE(e),t);if(t?.useFixedWeeks){var n=ebe(e,t);if(n<6){var a=r[r.length-1],i=a.dates[a.dates.length-1],s=tC(i,6-n),l=u$(tC(i,1),s,t);r.push.apply(r,l)}}return r}function Nwe(e){var t,r,n,a=ir(),i=a.locale,s=a.classNames,l=a.styles,d=a.hideHead,u=a.fixedWeeks,f=a.components,h=a.weekStartsOn,p=a.firstWeekContainsDate,g=a.ISOWeek,v=jwe(e.displayMonth,{useFixedWeeks:!!u,ISOWeek:g,locale:i,weekStartsOn:h,firstWeekContainsDate:p}),b=(t=f?.Head)!==null&&t!==void 0?t:Fbe,w=(r=f?.Row)!==null&&r!==void 0?r:Swe,j=(n=f?.Footer)!==null&&n!==void 0?n:Dbe;return o.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!d&&o.jsx(b,{}),o.jsx("tbody",{className:s.tbody,style:l.tbody,children:v.map(function(N){return o.jsx(w,{displayMonth:e.displayMonth,dates:N.dates,weekNumber:N.weekNumber},N.weekNumber)})}),o.jsx(j,{displayMonth:e.displayMonth})]})}function Cwe(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var _we=Cwe()?x.useLayoutEffect:x.useEffect,ij=!1,Ewe=0;function d$(){return"react-day-picker-".concat(++Ewe)}function Pwe(e){var t,r=e??(ij?d$():null),n=x.useState(r),a=n[0],i=n[1];return _we(function(){a===null&&i(d$())},[]),x.useEffect(function(){ij===!1&&(ij=!0)},[]),(t=e??a)!==null&&t!==void 0?t:void 0}function Owe(e){var t,r,n=ir(),a=n.dir,i=n.classNames,s=n.styles,l=n.components,d=mh().displayMonths,u=Pwe(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),f=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,h=[i.month],p=s.month,g=e.displayIndex===0,v=e.displayIndex===d.length-1,b=!g&&!v;a==="rtl"&&(t=[g,v],v=t[0],g=t[1]),g&&(h.push(i.caption_start),p=ut(ut({},p),s.caption_start)),v&&(h.push(i.caption_end),p=ut(ut({},p),s.caption_end)),b&&(h.push(i.caption_between),p=ut(ut({},p),s.caption_between));var w=(r=l?.Caption)!==null&&r!==void 0?r:Rbe;return o.jsxs("div",{className:h.join(" "),style:p,children:[o.jsx(w,{id:u,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),o.jsx(Nwe,{id:f,"aria-labelledby":u,displayMonth:e.displayMonth})]},e.displayIndex)}function Twe(e){var t=ir(),r=t.classNames,n=t.styles;return o.jsx("div",{className:r.months,style:n.months,children:e.children})}function kwe(e){var t,r,n=e.initialProps,a=ir(),i=bE(),s=mh(),l=x.useState(!1),d=l[0],u=l[1];x.useEffect(function(){a.initialFocus&&i.focusTarget&&(d||(i.focus(i.focusTarget),u(!0)))},[a.initialFocus,d,i.focus,i.focusTarget,i]);var f=[a.classNames.root,a.className];a.numberOfMonths>1&&f.push(a.classNames.multiple_months),a.showWeekNumber&&f.push(a.classNames.with_weeknumber);var h=ut(ut({},a.styles.root),a.style),p=Object.keys(n).filter(function(v){return v.startsWith("data-")}).reduce(function(v,b){var w;return ut(ut({},v),(w={},w[b]=n[b],w))},{}),g=(r=(t=n.components)===null||t===void 0?void 0:t.Months)!==null&&r!==void 0?r:Twe;return o.jsx("div",ut({className:f.join(" "),style:h,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},p,{children:o.jsx(g,{children:s.displayMonths.map(function(v,b){return o.jsx(Owe,{displayIndex:b,displayMonth:v},b)})})}))}function Awe(e){var t=e.children,r=rbe(e,["children"]);return o.jsx(wbe,{initialProps:r,children:o.jsx(kbe,{children:o.jsx(fwe,{initialProps:r,children:o.jsx(zbe,{initialProps:r,children:o.jsx(Vbe,{initialProps:r,children:o.jsx(Qbe,{children:o.jsx(uwe,{children:t})})})})})})})}function Iwe(e){return o.jsx(Awe,ut({},e,{children:o.jsx(kwe,{initialProps:e})}))}function Mwe({className:e,classNames:t,showOutsideDays:r=!0,...n}){return o.jsx(Iwe,{showOutsideDays:r,className:Ie("p-3",e),classNames:{months:"flex flex-col gap-4 sm:flex-row sm:gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:Ie(Kp({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse",head_row:"",head_cell:"text-muted-foreground w-9 text-center text-[0.8rem] font-normal p-0 align-middle",row:"mt-2",cell:Ie("relative p-0 text-center text-sm align-middle focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",n.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:Ie(Kp({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({className:a,...i})=>o.jsx(oC,{className:Ie("size-4",a),...i}),IconRight:({className:a,...i})=>o.jsx(Ui,{className:Ie("size-4",a),...i})},...n})}const Cz=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),SE="/reports";function xr(e,t,r,n=""){if(!e||typeof e!="object")return n;const a=e,i=a[t]??a[r];return i==null?n:String(i)}function rn(e,t,r,n=0){if(!e||typeof e!="object")return n;const a=e,i=a[t]??a[r],s=typeof i=="number"?i:Number(i);return Number.isFinite(s)?s:n}function Rwe(e){if(!e||typeof e!="object")return{taskId:"",labelCode:"",productName:"None",categoryName:"None",templateText:"",printedAt:"",printedByName:"None",locationText:"None",locationId:"",expiryDateText:"None"};const t=e;return{taskId:xr(t,"taskId","TaskId"),labelCode:xr(t,"labelCode","LabelCode")||"None",productName:xr(t,"productName","ProductName","None")||"None",categoryName:xr(t,"categoryName","CategoryName","None")||"None",templateText:xr(t,"templateText","TemplateText",""),printedAt:xr(t,"printedAt","PrintedAt",""),printedByName:xr(t,"printedByName","PrintedByName","None")||"None",locationText:xr(t,"locationText","LocationText","None")||"None",locationId:xr(t,"locationId","LocationId",""),expiryDateText:xr(t,"expiryDateText","ExpiryDateText","None")||"None"}}function Dwe(e,t={includePaging:!0}){const r={Sorting:e.sorting,PartnerId:e.partnerId,GroupId:e.groupId,LocationId:e.locationId,StartDate:e.startDate,EndDate:e.endDate,Keyword:e.keyword};return t.includePaging&&(r.SkipCount=e.skipCount,r.MaxResultCount=e.maxResultCount),r}async function Lwe(e,t){const r=await Cz.requestJson({path:`${SE}/print-log-list`,method:"GET",query:Dwe(e,{includePaging:!0}),signal:t}),n=r&&typeof r=="object"?r:{},a=n.items??n.Items,i=Array.isArray(a)?a.map(Rwe):[],s=rn(n,"totalCount","TotalCount",i.length);return{items:i,totalCount:s}}function $we(e){if(!e||typeof e!="object")return null;const t=e,r=xr(t,"categoryName","CategoryName",xr(t,"name","Name",xr(t,"labelCategoryName","LabelCategoryName","Category")));if(!r.trim())return null;const n=rn(t,"count","Count",rn(t,"printCount","PrintCount",rn(t,"totalPrinted","TotalPrinted",0)));return{name:r.trim(),count:n}}function Fwe(e){if(!e||typeof e!="object")return null;const t=e,r=xr(t,"date","Date",xr(t,"day","Day",xr(t,"printDate","PrintDate","")));if(!r.trim())return null;const n=rn(t,"count","Count",rn(t,"volume","Volume",0));return{date:r.trim(),count:n}}function Bwe(e){if(!e||typeof e!="object")return null;const t=e,r=xr(t,"productName","ProductName","");return r.trim()?{productName:r.trim(),categoryName:xr(t,"categoryName","CategoryName","None")||"None",totalPrinted:rn(t,"totalPrinted","TotalPrinted",rn(t,"printCount","PrintCount",0)),usagePercent:rn(t,"usagePercent","UsagePercent",0)}:null}function zwe(e){if(!e||typeof e!="object")return{summary:{totalLabelsPrinted:0,totalLabelsPrintedPrevPeriod:0,totalLabelsPrintedChangeRate:0,hottestCategoryName:"None",hottestCategoryCount:0,topProductName:"None",topProductCount:0,avgDailyPrints:0,avgDailyPrintsChangeRate:0},labelsByCategory:[],printVolumeTrend:[],mostUsedProducts:[]};const t=e,r=t.summary??t.Summary,n=r&&typeof r=="object"?r:{},a=t.labelsByCategory??t.LabelsByCategory,i=t.printVolumeTrend??t.PrintVolumeTrend,s=t.mostUsedProducts??t.MostUsedProducts,l=[];if(Array.isArray(a))for(const f of a){const h=$we(f);h&&l.push(h)}const d=[];if(Array.isArray(i))for(const f of i){const h=Fwe(f);h&&d.push(h)}const u=[];if(Array.isArray(s))for(const f of s){const h=Bwe(f);h&&u.push(h)}return{summary:{totalLabelsPrinted:rn(n,"totalLabelsPrinted","TotalLabelsPrinted",0),totalLabelsPrintedPrevPeriod:rn(n,"totalLabelsPrintedPrevPeriod","TotalLabelsPrintedPrevPeriod",0),totalLabelsPrintedChangeRate:rn(n,"totalLabelsPrintedChangeRate","TotalLabelsPrintedChangeRate",0),hottestCategoryName:xr(n,"hottestLabelCategoryName","HottestLabelCategoryName",xr(n,"mostPopularLabelCategoryName","MostPopularLabelCategoryName",xr(n,"hottestCategoryName","HottestCategoryName","None")))||"None",hottestCategoryCount:rn(n,"hottestLabelCategoryCount","HottestLabelCategoryCount",rn(n,"hottestCategoryCount","HottestCategoryCount",0)),topProductName:xr(n,"topProductName","TopProductName",xr(n,"mostUsedProductName","MostUsedProductName","None"))||"None",topProductCount:rn(n,"topProductCount","TopProductCount",0),avgDailyPrints:rn(n,"avgDailyPrints","AvgDailyPrints",0),avgDailyPrintsChangeRate:rn(n,"avgDailyPrintsChangeRate","AvgDailyPrintsChangeRate",0)},labelsByCategory:l,printVolumeTrend:d,mostUsedProducts:u}}function Uwe(e){return{PartnerId:e.partnerId,GroupId:e.groupId,LocationId:e.locationId,StartDate:e.startDate,EndDate:e.endDate,Keyword:e.keyword}}async function qwe(e,t){const r=await Cz.requestJson({path:`${SE}/label-report`,method:"GET",query:Uwe(e),signal:t});return zwe(r)}async function Vwe(e,t){await dl({path:`${SE}/export-print-log-excel`,query:{Sorting:e.sorting,PartnerId:e.partnerId,GroupId:e.groupId,LocationId:e.locationId,StartDate:e.startDate,EndDate:e.endDate,Keyword:e.keyword},defaultFileName:"print-log-export.xlsx",signal:t})}const xn="all";function Wwe(){const e=new Date,t=new Date(e);return t.setDate(t.getDate()-29),{start:t.toISOString().slice(0,10),end:e.toISOString().slice(0,10)}}function Mp(e){const t=(e??"").trim();if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return;const r=new Date(`${t}T00:00:00`);if(!Number.isNaN(r.getTime()))return r}function f$(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function Hwe(e){const t=(e??"").trim();if(!t)return"None";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})}function In(e){const t=(e??"").trim();return t||"None"}function h$(e){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(1)}%`:"0%"}function Gwe(e){const t=(e??"").trim();if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t.length>10?t.slice(0,10):t:r.toLocaleDateString("en-US",{month:"numeric",day:"numeric"})}function Ywe({startDate:e,endDate:t,onRangeChange:r}){const[n,a]=x.useState(!1),i=x.useMemo(()=>{const l=Mp(e),d=Mp(t);if(l&&d)return{from:l,to:d};if(l)return{from:l,to:void 0}},[e,t]),s=`${e||"YYYY-MM-DD"} — ${t||"YYYY-MM-DD"}`;return o.jsxs("div",{className:"flex items-center gap-2 shrink-0",lang:"en-US",children:[o.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Period Search:"}),o.jsxs(ka,{open:n,onOpenChange:a,children:[o.jsx(Aa,{asChild:!0,children:o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 min-w-[17rem] justify-start gap-2 border border-gray-300 bg-white px-3 text-sm font-mono tabular-nums text-gray-900 hover:bg-gray-50",children:[o.jsx(aq,{className:"h-4 w-4 shrink-0 text-gray-500","aria-hidden":!0}),s]})}),o.jsx(Ia,{className:"w-auto p-0",align:"start",children:o.jsx(Mwe,{mode:"range",numberOfMonths:1,defaultMonth:Mp(e)??Mp(t)??new Date,selected:i,onSelect:l=>{if(!l?.from)return;const d=f$(l.from),u=l.to?f$(l.to):d;r(d,u),l.from&&l.to&&a(!1)},initialFocus:!0})})]})]})}function Kwe(e){const t=e??"";if(!t.trim())return o.jsx("span",{className:"text-gray-500",children:"None"});const r=t.endsWith(" !!!"),n=r?t.slice(0,-4):t,a=n.lastIndexOf(" "),i=a<0?"":n.slice(0,a+1),s=a<0?n:n.slice(a+1);return o.jsxs(o.Fragment,{children:[i,o.jsx("span",{className:"font-bold text-gray-900",children:s}),r&&o.jsx("span",{className:"text-red-600",children:" !!!"})]})}const m$={summary:{totalLabelsPrinted:0,totalLabelsPrintedPrevPeriod:0,totalLabelsPrintedChangeRate:0,hottestCategoryName:"None",hottestCategoryCount:0,topProductName:"None",topProductCount:0,avgDailyPrints:0,avgDailyPrintsChangeRate:0},labelsByCategory:[],printVolumeTrend:[],mostUsedProducts:[]};function Xwe({layoutReportsOpenKey:e=0,layoutReportsTargetTab:t="label-report"}={}){const[r,n]=x.useState("print-log"),a=x.useRef(0),[i,s]=x.useState([]),[l,d]=x.useState([]),[u,f]=x.useState([]),[h,p]=x.useState(xn),[g,v]=x.useState(xn),[b,w]=x.useState(xn),{start:j,end:N}=Wwe(),[C,O]=x.useState(j),[P,E]=x.useState(N),[T,A]=x.useState(""),[M,R]=x.useState(""),L=x.useRef(null),[V,z]=x.useState([]),[G,H]=x.useState(0),[W,q]=x.useState(!1),[I,Y]=x.useState(1),[F]=x.useState(10),[D,$]=x.useState(null),[K,J]=x.useState(!1),[oe,re]=x.useState(!1),[Q,ue]=x.useState(!0),se=x.useRef(null),fe=x.useRef(null);x.useEffect(()=>(L.current&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>R(T.trim()),300),()=>{L.current&&window.clearTimeout(L.current)}),[T]),x.useEffect(()=>{e>0&&e>a.current&&(a.current=e,n(t))},[e,t]);const we=Math.max(1,Math.ceil(G/F)),Z=x.useCallback(()=>h===xn?void 0:i.find(ke=>ke.id===h)?.partnerName?.trim()||void 0,[h,i]),je=x.useCallback(()=>g===xn?void 0:l.find(ke=>ke.id===g)?.groupName?.trim()||void 0,[g,l]),Ce=x.useCallback(()=>({partnerId:h===xn?void 0:h,groupId:g===xn?void 0:g,locationId:b===xn?void 0:b,startDate:C.trim()||void 0,endDate:P.trim()||void 0,keyword:M||void 0}),[M,P,g,b,h,C]);x.useEffect(()=>{Y(1)},[M,h,g,b,C,P,r,F]),x.useEffect(()=>{let ve=!1;return(async()=>{ue(!0);try{const[Ge,xe]=await Promise.all([uh({skipCount:1,maxResultCount:500,state:!0}),cE({skipCount:1,maxResultCount:500,state:!0})]);if(ve)return;s(Ge.items??[]),d(xe.items??[])}catch(Ge){ve||(s([]),d([]),ee.error("Failed to load companies / regions.",{description:Ge instanceof Error?Ge.message:"Please try again."}))}finally{ve||ue(!1)}})(),()=>{ve=!0}},[]),x.useEffect(()=>{let ve=!1;return(async()=>{try{const Ge=await Nu({skipCount:1,maxResultCount:2e3,partner:Z(),groupName:je(),state:!0});if(ve)return;f(Ge.items??[])}catch(Ge){ve||(f([]),ee.error("Failed to load locations.",{description:Ge instanceof Error?Ge.message:"Please try again."}))}})(),()=>{ve=!0}},[je,Z,h,g]),x.useEffect(()=>r!=="print-log"?void 0:((async()=>{se.current?.abort();const ke=new AbortController;se.current=ke,q(!0);const Ge=Ce();try{const xe=await Lwe({skipCount:Qa(I),maxResultCount:F,sorting:"PrintedAt desc",...Ge},ke.signal);z(xe.items??[]),H(xe.totalCount??0)}catch(xe){if(xe instanceof Error&&xe.name==="AbortError")return;ee.error("Failed to load print log.",{description:xe instanceof Error?xe.message:"Please try again."}),z([]),H(0)}finally{ke.signal.aborted||q(!1)}})(),()=>se.current?.abort()),[r,Ce,I,F]),x.useEffect(()=>r!=="label-report"?void 0:((async()=>{fe.current?.abort();const ke=new AbortController;fe.current=ke,J(!0);const Ge=Ce();try{const xe=await qwe(Ge,ke.signal);$(xe)}catch(xe){if(xe instanceof Error&&xe.name==="AbortError")return;ee.error("Failed to load label report.",{description:xe instanceof Error?xe.message:"Please try again."}),$(m$)}finally{ke.signal.aborted||J(!1)}})(),()=>fe.current?.abort()),[r,Ce]);const qe=ve=>{p(ve),v(xn),w(xn)},De=ve=>{v(ve),w(xn)},He=async()=>{const ve=Ce();re(!0);try{await Vwe({...ve,skipCount:1,maxResultCount:10,sorting:"PrintedAt desc"}),ee.success("Export ready",{description:"The Excel download should start shortly."})}catch(ke){const Ge=ke instanceof Yr||ke instanceof Error?ke.message:"Please try again.";ee.error("Export failed",{description:Ge})}finally{re(!1)}},ne=D??m$,pe=(ne.printVolumeTrend??[]).map(ve=>({date:Gwe(ve.date),count:ve.count})),_e=(ne.labelsByCategory??[]).map(ve=>({name:ve.name,count:ve.count}));return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"pb-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsxs($e,{value:h,onValueChange:qe,disabled:Q,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Company"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:xn,children:"All companies"}),i.map(ve=>o.jsx(Se,{value:ve.id,children:In(ve.partnerName)},ve.id))]})]}),o.jsxs($e,{value:g,onValueChange:De,disabled:Q,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Region"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:xn,children:"All regions"}),l.filter(ve=>h===xn?!0:ve.partnerId===h).map(ve=>o.jsx(Se,{value:ve.id,children:In(ve.groupName)},ve.id))]})]}),o.jsxs($e,{value:b,onValueChange:w,disabled:Q,children:[o.jsx(Be,{className:"w-[160px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:xn,children:"All locations"}),u.map(ve=>o.jsx(Se,{value:ve.id??"",children:In(ve.locationName)||In(ve.locationCode)},ve.id))]})]}),o.jsx(Ywe,{startDate:C,endDate:P,onRangeChange:(ve,ke)=>{O(ve),E(ke)}}),o.jsxs("div",{className:"flex items-center w-64 rounded-md border border-gray-300 bg-white overflow-hidden shrink-0",style:{height:40},children:[o.jsx(Rf,{className:"h-4 w-4 text-gray-400 shrink-0 ml-3 pointer-events-none"}),o.jsx(me,{value:T,onChange:ve=>A(ve.target.value),placeholder:"Search Product or Category...",className:"flex-1 min-w-0 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 py-2 px-2 h-full placeholder:text-gray-500"})]}),o.jsx("div",{className:"flex-1 min-w-2"}),r==="print-log"&&o.jsxs(ce,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",disabled:oe,onClick:()=>void He(),children:[o.jsx(iC,{className:"w-4 h-4"})," ",oe?"Exporting…":"Export Report"]})]}),o.jsx("div",{className:"w-full border-b border-gray-200 mt-4",children:o.jsxs("div",{className:"flex overflow-x-auto w-fit",children:[o.jsx("button",{type:"button",onClick:()=>n("print-log"),style:r==="print-log"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:Ie("px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2",r==="print-log"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"),children:"Print Log"}),o.jsx("button",{type:"button",onClick:()=>n("label-report"),style:r==="label-report"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:Ie("px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2",r==="label-report"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"),children:"Label Report"})]})})]}),o.jsxs("div",{className:"flex-1 overflow-auto pt-6",children:[r==="print-log"&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden min-h-[200px]",children:[W&&o.jsx("div",{className:"p-6 text-sm text-gray-500",children:"Loading print log…"}),!W&&o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Label ID"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Product Name"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Category"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Template"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Printed At"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Printed By"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Location"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Expiry Date"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center",children:"Action"})]})}),o.jsxs(pn,{children:[V.length===0&&o.jsx(nt,{children:o.jsx(ye,{colSpan:9,className:"text-center text-sm text-gray-500 py-10",children:"No print records"})}),V.map(ve=>o.jsxs(nt,{children:[o.jsx(ye,{className:"border-r font-mono text-gray-600",children:In(ve.labelCode)}),o.jsx(ye,{className:"border-r font-medium",children:In(ve.productName)}),o.jsx(ye,{className:"border-r",children:o.jsx(fn,{variant:"secondary",className:"bg-blue-50 text-blue-700 hover:bg-blue-50 border-blue-200",children:In(ve.categoryName)})}),o.jsx(ye,{className:"border-r text-gray-600 text-sm",children:Kwe(ve.templateText)}),o.jsx(ye,{className:"border-r text-gray-600 text-sm font-numeric",children:Hwe(ve.printedAt)}),o.jsx(ye,{className:"border-r text-gray-600 text-sm",children:In(ve.printedByName)}),o.jsx(ye,{className:"border-r text-gray-600 text-sm font-numeric",children:In(ve.locationText)}),o.jsx(ye,{className:"border-r text-sm font-mono text-gray-800",children:In(ve.expiryDateText)}),o.jsx(ye,{className:"text-center",children:o.jsxs("div",{className:"inline-flex h-8 items-center justify-center gap-1 rounded-md border border-gray-300 bg-white px-4 text-sm font-medium text-gray-900 shadow-sm select-none pointer-events-none","aria-label":"Reprint",children:[o.jsx(_$,{className:"w-3 h-3 shrink-0 text-gray-700","aria-hidden":!0}),o.jsx("span",{children:"Reprint"})]})})]},ve.taskId+ve.labelCode))]})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-end gap-2 text-sm text-gray-600",children:[o.jsx("span",{children:G===0?"Showing 0 of 0":`Showing ${(I-1)*F+1}–${Math.min(I*F,G)} of ${G}`}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(wt,{children:o.jsx(la,{className:I<=1?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>I>1&&Y(ve=>Math.max(1,ve-1)),"aria-disabled":I<=1})}),o.jsx(wt,{children:o.jsxs(Cn,{className:"cursor-default",size:"default",isActive:!0,onClick:ve=>ve.preventDefault(),children:["Page ",I," / ",we]})}),o.jsx(wt,{children:o.jsx(ca,{className:I>=we?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>IMath.min(we,ve+1)),"aria-disabled":I>=we})})]})})]})]}),r==="label-report"&&o.jsxs("div",{className:"space-y-6",children:[K&&o.jsx("div",{className:"text-sm text-gray-500",children:"Loading label report…"}),!K&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Total Labels Printed"}),o.jsx(zs,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:ne.summary.totalLabelsPrinted.toLocaleString("en-US")}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[h$(ne.summary.totalLabelsPrintedChangeRate)," vs previous period"]})]})]}),o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Most Printed Category"}),o.jsx(iq,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:In(ne.summary.hottestCategoryName)}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[ne.summary.hottestCategoryCount.toLocaleString("en-US")," label(s) in range"]})]})]}),o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Top Product"}),o.jsx(S$,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:In(ne.summary.topProductName)}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[ne.summary.topProductCount.toLocaleString("en-US")," label(s) in range"]})]})]}),o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Avg. Daily Prints"}),o.jsx(Hq,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:Number.isFinite(ne.summary.avgDailyPrints)?ne.summary.avgDailyPrints.toLocaleString("en-US",{maximumFractionDigits:1}):"0"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[h$(ne.summary.avgDailyPrintsChangeRate)," vs previous period"]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(wn,{className:"col-span-1",children:[o.jsxs(Na,{children:[o.jsx(Ca,{children:"Labels by Category"}),o.jsx(Hd,{children:"Distribution of printed labels by label category in the selected range."})]}),o.jsx(Dn,{className:"h-[300px]",children:_e.length===0?o.jsx("div",{className:"h-full flex items-center justify-center text-sm text-gray-500",children:"No data"}):o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(Yle,{data:_e,children:[o.jsx(Gg,{strokeDasharray:"3 3",vertical:!1}),o.jsx(Ys,{dataKey:"name",fontSize:12,tickLine:!1,axisLine:!1}),o.jsx(Ks,{fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:ve=>`${ve}`}),o.jsx(ta,{}),o.jsx(ul,{dataKey:"count",fill:"#facc15",radius:[4,4,0,0]})]})})})]}),o.jsxs(wn,{className:"col-span-1",children:[o.jsxs(Na,{children:[o.jsx(Ca,{children:"Print Volume Trends"}),o.jsx(Hd,{children:"Daily print volume in the current filter window (up to 7 days)."})]}),o.jsx(Dn,{className:"h-[300px]",children:pe.length===0?o.jsx("div",{className:"h-full flex items-center justify-center text-sm text-gray-500",children:"No data"}):o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(_F,{data:pe,children:[o.jsx(Gg,{strokeDasharray:"3 3",vertical:!1}),o.jsx(Ys,{dataKey:"date",fontSize:12,tickLine:!1,axisLine:!1}),o.jsx(Ks,{fontSize:12,tickLine:!1,axisLine:!1}),o.jsx(ta,{}),o.jsx(xu,{type:"monotone",dataKey:"count",stroke:"#dc2626",strokeWidth:2,dot:{r:4},activeDot:{r:6}})]})})})]})]}),o.jsxs(wn,{children:[o.jsx(Na,{children:o.jsx(Ca,{children:"Most Used Products"})}),o.jsx(Dn,{children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{children:[o.jsx(Ee,{children:"Product Name"}),o.jsx(Ee,{children:"Category"}),o.jsx(Ee,{className:"text-right",children:"Total Printed"}),o.jsx(Ee,{className:"text-right",children:"Usage %"})]})}),o.jsxs(pn,{children:[ne.mostUsedProducts.length===0&&o.jsx(nt,{children:o.jsx(ye,{colSpan:4,className:"text-center text-sm text-gray-500",children:"No data"})}),ne.mostUsedProducts.map((ve,ke)=>o.jsxs(nt,{children:[o.jsx(ye,{className:"font-medium",children:In(ve.productName)}),o.jsx(ye,{children:In(ve.categoryName)}),o.jsx(ye,{className:"text-right font-numeric",children:ve.totalPrinted.toLocaleString("en-US")}),o.jsx(ye,{className:"text-right font-numeric",children:Number.isFinite(ve.usagePercent)?`${ve.usagePercent.toFixed(1)}%`:"—"})]},`${ve.productName}-${ke}`))]})]})})]})]})]})]})]})}function Jwe({className:e,...t}){return o.jsx("textarea",{"data-slot":"textarea",className:Ie("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}const p$={Settings:Nc,LayoutDashboard:Vp,Tag:Cc,MapPin:lu,Users:my,Package:jc,FileText:zs,HelpCircle:Wd,Layers:cC,Type:Df,FileBox:sC};function sj(e){const t=(e??"").trim();return t||"N/A"}function Qwe(e){const t=e.trim();if(!t)return null;const r=Number.parseInt(t,10);return Number.isFinite(r)?r:null}function Zwe(){const[e,t]=x.useState([]),[r,n]=x.useState(!1),[a,i]=x.useState(0),[s,l]=x.useState(null),[d,u]=x.useState(""),f=x.useRef(null),[h,p]=x.useState(""),[g,v]=x.useState(!1),[b,w]=x.useState(!1),[j,N]=x.useState(!1),[C,O]=x.useState(null),[P,E]=x.useState(null),T=x.useRef(null);x.useEffect(()=>(f.current&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>p(d.trim()),300),()=>{f.current&&window.clearTimeout(f.current)}),[d]),x.useEffect(()=>((async()=>{T.current?.abort();const V=new AbortController;T.current=V,n(!0);try{const z=await Z6({skipCount:1,maxResultCount:5e3,keyword:h||void 0},V.signal);t(z.items??[])}catch(z){if(z?.name==="AbortError")return;ee.error("Failed to load system menus.",{description:z?.message?String(z.message):"Please try again."}),t([])}finally{n(!1)}})(),()=>T.current?.abort()),[h,a]);const A=()=>i(L=>L+1),M=L=>{l(null),O(L),w(!0)},R=L=>{l(null),E(L),N(!0)};return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:d,onChange:L=>u(L.target.value),style:{height:40,boxSizing:"border-box"},className:"border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"}),o.jsx("div",{className:"flex-1"}),o.jsxs(ce,{className:"bg-blue-600 text-white hover:bg-blue-700",onClick:()=>v(!0),children:[o.jsx(Un,{className:"w-4 h-4 mr-2"}),"New Menu"]})]})}),o.jsx("div",{className:"flex-1 flex flex-col min-h-0 bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden",children:o.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o.jsxs(hn,{children:[o.jsx(mn,{className:"bg-gray-50 sticky top-0 z-10",children:o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Menu Name"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Route URL"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Router Name"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Type"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Order"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Visible"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Enabled"}),o.jsx(Ee,{className:"font-semibold text-gray-900 w-16 text-right",children:"Actions"})]})}),o.jsx(pn,{children:e.length===0?o.jsx(nt,{children:o.jsx(ye,{colSpan:8,className:"text-center py-10 text-gray-500",children:r?"Loading...":"No data"})}):e.map(L=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(ye,{className:"font-medium text-gray-900",children:sj(L.menuName)}),o.jsx(ye,{className:"text-gray-700",children:sj(L.routeUrl)}),o.jsx(ye,{className:"text-gray-700",children:sj(L.routerName)}),o.jsx(ye,{className:"text-gray-700",children:L.menuType??"N/A"}),o.jsx(ye,{className:"text-gray-700",children:L.orderNum??"N/A"}),o.jsx(ye,{className:"text-gray-700",children:L.isShow?"Yes":"No"}),o.jsx(ye,{className:"text-gray-700",children:L.state?"Yes":"No"}),o.jsx(ye,{className:"text-right",children:o.jsxs(ka,{open:s===L.id,onOpenChange:V=>l(V?L.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(ce,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ri,{className:"h-4 w-4"})})}),o.jsx(Ia,{className:"w-44 p-2",align:"end",children:o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(ce,{variant:"ghost",className:"justify-start",onClick:()=>M(L),children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Edit"]}),o.jsxs(ce,{variant:"ghost",className:"justify-start text-red-600 hover:text-red-700",onClick:()=>R(L),children:[o.jsx(zt,{className:"w-4 h-4 mr-2"}),"Delete"]})]})})]})})]},L.id))})]})})}),o.jsx(g$,{mode:"create",open:g,menu:null,onOpenChange:v,onSaved:A}),o.jsx(g$,{mode:"edit",open:b,menu:C,onOpenChange:w,onSaved:A}),o.jsx(e1e,{open:j,menu:P,onOpenChange:N,onDeleted:A})]})}function g$({mode:e,open:t,menu:r,onOpenChange:n,onSaved:a}){const i=e==="edit",[s,l]=x.useState(!1),[d,u]=x.useState(""),[f,h]=x.useState(""),[p,g]=x.useState(""),[v,b]=x.useState("menu"),[w,j]=x.useState(""),[N,C]=x.useState(""),[O,P]=x.useState([]),[E,T]=x.useState(!1),[A,M]=x.useState(""),[R,L]=x.useState(""),[V,z]=x.useState(""),[G,H]=x.useState(""),[W,q]=x.useState(""),[I,Y]=x.useState(""),[F,D]=x.useState(!1),[$,K]=x.useState(!0),[J,oe]=x.useState(!0);x.useEffect(()=>{if(!t)return;l(!1),u(r?.menuName??""),h(r?.routerName??""),g(r?.routeUrl??""),b(r?.menuType===0?"directory":"menu"),j(r?.permissionCode??"");const Z=String(r?.parentId??"").trim();C(!Z||Z==="00000000-0000-0000-0000-000000000000"?"":Z),M(r?.menuIcon??""),L(r?.orderNum===null||r?.orderNum===void 0?"":String(r.orderNum)),z(r?.link??""),H(r?.component??""),q(r?.query??""),Y(r?.remark??""),D(!!r?.isCache),K(r?.isShow??!0),oe(r?.state??!0)},[t,r]);const re="__parent_root__";x.useEffect(()=>{if(!t)return;let Z=!1;return T(!0),Eve().then(je=>{Z||P(je)}).catch(()=>{Z||P([])}).finally(()=>{Z||T(!1)}),()=>{Z=!0}},[t]);const Q=Z=>!Z.trim()||Z==="00000000-0000-0000-0000-000000000000",ue=x.useMemo(()=>{const Z=O.filter(Ce=>Ce.id&&Ce.id!==r?.id),je=(N||"").trim();return je&&!Q(je)&&!Z.some(Ce=>Ce.id===je)?[...Z,{id:je,menuName:`(Current parent) ${je}`}]:Z},[O,N,r?.id]),se=Q(N)?re:N,fe=x.useMemo(()=>!!(d.trim()&&p.trim()&&R.trim()),[d,p,R]),we=async()=>{if(!fe){ee.error("Please fill in required fields.",{description:"Menu Name, Route URL, and Order are required."});return}l(!0);try{const Z={menuName:d.trim(),routerName:f.trim()?f.trim():null,routeUrl:p.trim(),menuType:v==="directory"?0:1,permissionCode:w.trim()?w.trim():null,parentId:Q(N)?null:N.trim(),menuIcon:A||null,orderNum:Qwe(R),link:V.trim()?V.trim():null,component:G.trim()?G.trim():null,query:W.trim()?W.trim():null,remark:I.trim()?I.trim():null,isCache:F,isShow:$,state:J};if(i){if(!r?.id)throw new Error("Missing id.");await Ove(r.id,Z),ee.success("Menu updated.",{description:"Changes have been saved successfully."})}else await Pve(Z),ee.success("Menu created.",{description:"A new menu has been created successfully."});n(!1),a()}catch(Z){ee.error(i?"Failed to update menu.":"Failed to create menu.",{description:Z?.message?String(Z.message):"Please try again."})}finally{l(!1)}};return o.jsx(_t,{open:t,onOpenChange:n,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"70%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:i?"Edit System Menu":"New System Menu"}),o.jsx(It,{children:i?"Update system menu fields and save changes.":"Fill out the form to create a new system menu."})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-6 py-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Menu Name *"}),o.jsx(me,{value:d,onChange:Z=>u(Z.target.value),placeholder:"e.g. Location Manager"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Route URL *"}),o.jsx(me,{value:p,onChange:Z=>g(Z.target.value),placeholder:"e.g. /location"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Router Name"}),o.jsx(me,{value:f,onChange:Z=>h(Z.target.value),placeholder:"e.g. location"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Menu Type"}),o.jsxs($e,{value:v,onValueChange:Z=>b(Z),children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"directory",children:"Directory"}),o.jsx(Se,{value:"menu",children:"Menu"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Permission Code"}),o.jsx(me,{value:w,onChange:Z=>j(Z.target.value),placeholder:"e.g. sys:menu"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Parent"}),o.jsxs($e,{value:se,disabled:E,onValueChange:Z=>C(Z===re?"":Z),children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:E?"Loading…":"Select parent directory"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:re,children:"Root (no parent)"}),ue.map(Z=>o.jsx(Se,{value:Z.id,children:Z.menuName?.trim()||Z.id},Z.id))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Menu Icon"}),o.jsxs($e,{value:A||"none",onValueChange:Z=>M(Z==="none"?"":Z),children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:"Select an icon"})}),o.jsxs(ze,{children:[o.jsx(Se,{value:"none",children:"None"}),Object.keys(p$).map(Z=>{const je=p$[Z];return o.jsx(Se,{value:Z,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(je,{className:"h-4 w-4"}),Z]})},Z)})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Order *"}),o.jsx(me,{value:R,onChange:Z=>L(Z.target.value),placeholder:"e.g. 10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Link"}),o.jsx(me,{value:V,onChange:Z=>z(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Component"}),o.jsx(me,{value:G,onChange:Z=>H(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Query"}),o.jsx(me,{value:W,onChange:Z=>q(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Remark"}),o.jsx(Jwe,{value:I,onChange:Z=>Y(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Cache"}),o.jsx(br,{checked:F,onCheckedChange:D})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Visible"}),o.jsx(br,{checked:$,onCheckedChange:K})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:J,onCheckedChange:oe})]})]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),o.jsx(ce,{className:"min-w-24 bg-blue-600 text-white hover:bg-blue-700",disabled:s,onClick:we,children:s?"Saving...":i?"Save Changes":"Create"})]})]})})}function e1e({open:e,menu:t,onOpenChange:r,onDeleted:n}){const[a,i]=x.useState(!1),s=x.useMemo(()=>{const d=(t?.menuName??"").trim(),u=(t?.routeUrl??"").trim();return d&&u?`${d} (${u})`:d||u||"this menu"},[t?.menuName,t?.routeUrl]),l=async()=>{if(t?.id){i(!0);try{await kve(t.id),ee.success("Menu deleted.",{description:"The menu has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete menu.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(_t,{open:e,onOpenChange:r,children:o.jsxs(Ct,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(Et,{children:[o.jsx(Pt,{children:"Delete System Menu"}),o.jsx(It,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(ce,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(ce,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}const Fv=_r({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});function jE(e){if(e==null||typeof e!="object")return null;const t=e,r=t.id!=null?String(t.id).trim():"",n=String(t.supportPhone??"").trim(),a=String(t.supportEmail??"").trim();return!r&&!n&&!a?null:{id:r,locationId:t.locationId!=null?String(t.locationId):null,locationName:t.locationName!=null?String(t.locationName):null,supportPhone:n,supportEmail:a}}function t1e(e){if(!e)return null;if(Array.isArray(e))return e[0]??null;if(typeof e=="object"){const t=e;if(Array.isArray(t.items))return t.items[0]??null;if("supportPhone"in t||"supportEmail"in t)return t}return null}async function r1e(e){const t=await Fv.requestJson({path:"/location-support",method:"GET",query:{SkipCount:1,MaxResultCount:1},signal:e});return t1e(t)}async function n1e(e){try{const t=await Fv.requestJson({path:"/location-support/support",method:"GET",signal:e});return jE(t)}catch(t){if(t instanceof Yr&&t.status===404)try{return await r1e(e)}catch(r){if(r instanceof Yr&&r.status===404)return null;throw r}throw t}}async function a1e(e){const t=await Fv.requestJson({path:"/location-support",method:"POST",body:{supportPhone:e.supportPhone,supportEmail:e.supportEmail}}),r=jE(t);return r||t}async function o1e(e,t){const r=await Fv.requestJson({path:`/location-support/${encodeURIComponent(e)}`,method:"PUT",body:{supportPhone:t.supportPhone,supportEmail:t.supportEmail}}),n=jE(r);return n||r}function i1e(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function s1e(){const[e,t]=x.useState(null),[r,n]=x.useState(""),[a,i]=x.useState(""),[s,l]=x.useState(!0),[d,u]=x.useState(!1);x.useEffect(()=>{let h=!1;return(async()=>{l(!0);try{const g=await n1e();if(h)return;if(!g){t(null),n(""),i("");return}const v=(g.id??"").trim();t(v||null),n((g.supportPhone??"").trim()),i((g.supportEmail??"").trim())}catch(g){if(h)return;t(null),n(""),i(""),ee.error("Failed to load support settings.",{description:g instanceof Error?g.message:"Please try again."})}finally{h||l(!1)}})(),()=>{h=!0}},[]);const f=async()=>{const h=r.trim(),p=a.trim();if(!h){ee.error("Support phone is required.");return}if(!p){ee.error("Support email is required.");return}if(!i1e(p)){ee.error("Support email format is invalid.");return}u(!0);try{const g={supportPhone:h,supportEmail:p},v=e?await o1e(e,g):await a1e(g),b=(v.id??"").trim();t(b||null),n((v.supportPhone??"").trim()),i((v.supportEmail??"").trim()),ee.success("Support settings saved.")}catch(g){ee.error("Failed to save support settings.",{description:g instanceof Error?g.message:"Please try again."})}finally{u(!1)}};return o.jsx("div",{className:"max-w-4xl space-y-6",children:o.jsxs(wn,{children:[o.jsxs(Na,{children:[o.jsx(Ca,{children:"Support Contact Settings"}),o.jsx(Hd,{children:"Configure the global support phone and email used by the app support page."})]}),o.jsxs(Dn,{className:"space-y-4",children:[o.jsx("div",{className:"text-xs text-gray-500",children:e?"Existing global support record found. You can update phone and email.":"No global support record found. Saving will create a new record."}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Support Phone *"}),o.jsxs("div",{className:"flex h-10 rounded-md border border-input bg-transparent overflow-hidden",children:[o.jsx("div",{className:"w-10 shrink-0 flex items-center justify-center border-r border-input bg-gray-50",children:o.jsx(Bq,{className:"w-4 h-4 text-gray-400"})}),o.jsx(me,{className:"h-10 border-0 rounded-none shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",value:r,onChange:h=>n(h.target.value),placeholder:"e.g. 1-800-SUPPORT",disabled:s||d})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Support Email *"}),o.jsxs("div",{className:"flex h-10 rounded-md border border-input bg-transparent overflow-hidden",children:[o.jsx("div",{className:"w-10 shrink-0 flex items-center justify-center border-r border-input bg-gray-50",children:o.jsx(Aq,{className:"w-4 h-4 text-gray-400"})}),o.jsx(me,{className:"h-10 border-0 rounded-none shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",value:a,onChange:h=>i(h.target.value),placeholder:"support@medvantage.com",disabled:s||d})]})]})]}),o.jsx("div",{className:"flex justify-end pt-2",children:o.jsx(ce,{onClick:()=>void f(),className:"bg-blue-600 text-white hover:bg-blue-700",disabled:s||d,children:d?"Saving...":e?"Update":"Create"})})]})]})})}const NE="access_token",_z="refresh_token";function nC(){try{return localStorage.getItem(NE)??localStorage.getItem("token")??null}catch{return null}}function l1e(e){try{localStorage.setItem(NE,e.token),e.refreshToken&&localStorage.setItem(_z,e.refreshToken)}catch{}}function y$(){try{localStorage.removeItem(NE),localStorage.removeItem("token"),localStorage.removeItem(_z)}catch{}}const Ez=_r({getToken:()=>nC()});async function c1e(e){return await Ez.requestJson({path:"/auth-session/my-menus",method:"GET",signal:e})}async function u1e(e){return await Ez.requestJson({path:"/auth-session/logout",method:"POST",signal:e})}const Pz=U.createContext(null);function Oz(){const e=U.useContext(Pz);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function d1e(e){return String(e?.id??e?.Id??"")}function Tz(e){const t=e?.children??e?.Children,r=Array.isArray(t)?t.map(Tz):void 0;return{id:d1e(e),parentId:e?.parentId??e?.ParentId??null,menuName:e?.menuName??e?.MenuName??null,routerName:e?.routerName??e?.RouterName??null,routeUrl:e?.routeUrl??e?.RouteUrl??e?.router??e?.Router??null,menuIcon:e?.menuIcon??e?.MenuIcon??null,menuType:e?.menuType??e?.MenuType??null,permissionCode:e?.permissionCode??e?.PermissionCode??null,orderNum:e?.orderNum??e?.OrderNum??null,state:e?.state??e?.State??null,component:e?.component??e?.Component??null,isCache:e?.isCache??e?.IsCache??null,isShow:e?.isShow??e?.IsShow??null,query:e?.query??e?.Query??null,remark:e?.remark??e?.Remark??null,link:e?.link??e?.Link??null,menuSource:e?.menuSource??e?.MenuSource??null,concurrencyStamp:e?.concurrencyStamp??e?.ConcurrencyStamp??null,children:r}}function f1e({children:e}){const[t,r]=U.useState(()=>({token:nC(),user:null,menus:[],permissionCodes:[],roleCodes:[],loading:!1})),n=U.useCallback(async()=>{const l=nC();if(!l){r(d=>({...d,token:null,user:null,menus:[],permissionCodes:[],roleCodes:[],loading:!1}));return}r(d=>({...d,token:l,loading:!0}));try{const d=await c1e(),u=Array.isArray(d?.menus)?d.menus.map(Tz):[],f=Array.isArray(d?.permissionCodes)?d.permissionCodes:[],h=Array.isArray(d?.roleCodes)?d.roleCodes:[],p=d?.user??null,g=p?{id:String(p.id??p.Id??""),userName:String(p.userName??p.UserName??""),nick:p.nick??p.Nick??null,email:p.email??p.Email??null,icon:p.icon??p.Icon??null}:null;r(v=>({...v,token:l,user:g,menus:u,permissionCodes:f,roleCodes:h,loading:!1}))}catch(d){const u=d instanceof Yr,f=u?d.status:0,h=u&&(f===401||f===403),p=d instanceof Error?d.message:typeof d=="string"?d:"请稍后重试。";ee.error("加载菜单权限失败",{description:p}),h?(y$(),r(g=>({...g,loading:!1,token:null,user:null,menus:[],permissionCodes:[],roleCodes:[]}))):r(g=>({...g,loading:!1}))}},[]);U.useEffect(()=>{n()},[n]);const a=U.useCallback(()=>{y$(),r(l=>({...l,token:null,user:null,menus:[],permissionCodes:[],roleCodes:[]}))},[]),i=U.useCallback(async()=>{try{await u1e()}catch{}finally{a(),ee.success("已退出登录")}},[a]),s=U.useMemo(()=>({...t,refresh:n,clearLocalAuth:a,logout:i}),[t,n,a,i]);return o.jsx(Pz.Provider,{value:s,children:e})}const h1e=_r();async function m1e(e){const t=await h1e.requestJson({path:"/account/login",method:"POST",body:{userName:e.userName,password:e.password,uuid:e.uuid??null,code:e.code??null}}),r=String(t?.token??t?.Token??"");if(!r)throw new Error("登录失败:未返回 token。");const n=t?.refreshToken??t?.RefreshToken??null;return l1e({token:r,refreshToken:n}),{token:r,refreshToken:n}}function p1e(){const e=Oz(),[t,r]=U.useState(""),[n,a]=U.useState(""),[i,s]=U.useState(!1),l=!!(t.trim()&&n.trim()&&!i),d=async()=>{if(!l)return;const u=t.trim();s(!0);try{await m1e({userName:u,password:n.trim()}),await e.refresh(),ee.success("Signed in")}catch(f){ee.error("Sign-in failed",{description:f?.message?String(f.message):"Please check your email/password and try again."})}finally{s(!1)}};return o.jsx("div",{className:"w-screen h-screen grid items-center justify-center bg-[#f6f7fb] p-4",children:o.jsxs("div",{className:"w-full max-w-md bg-white border border-gray-200 rounded-2xl shadow-sm p-8",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xl font-semibold text-gray-900",children:"Platform Sign In"}),o.jsx("div",{className:"text-sm text-gray-500 mt-1",children:"Your sidebar menu and permissions will load after sign-in."})]}),o.jsxs("div",{className:"mt-6 space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Email"}),o.jsx(me,{type:"email",value:t,onChange:u=>r(u.target.value),placeholder:"Enter your email",autoComplete:"username",onKeyDown:u=>{u.key==="Enter"&&d()}})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(de,{children:"Password"}),o.jsx(me,{type:"password",value:n,onChange:u=>a(u.target.value),placeholder:"Enter your password",autoComplete:"current-password",onKeyDown:u=>{u.key==="Enter"&&d()}})]}),o.jsx(ce,{className:"w-full bg-blue-600 text-white hover:bg-blue-700",disabled:!l,onClick:d,children:i?"Signing in...":"Sign In"})]})]})})}const g1e=new Set(["Labels","Label Categories","Label Types","Label Templates","Multiple Options"]);function y1e(){const e=Oz(),[t,r]=x.useState("Dashboard"),[n,a]=x.useState(null),[i,s]=x.useState(0),[l,d]=x.useState(0),[u,f]=x.useState("print-log"),[h,p]=x.useState(!1),g=N=>{const C=(N??"").trim();return C?C==="System Management"?"System Menu":C==="Location Management"?"Location Manager":C==="Account Manager"?"Account Management":C:"Dashboard"},v=g(t),b=x.useCallback(N=>{const C=g(N);if(C==="Location Manager"){a("Location Manager"),r("Account Management");return}r(C)},[]),w=x.useCallback(()=>{s(0)},[]);if(x.useEffect(()=>{g1e.has(v)||s(0),v!=="Reports"&&d(0),v!=="Label Templates"&&p(!1)},[v]),!e.token)return o.jsx(p1e,{});const j=()=>{const N=v;switch(N){case"Dashboard":return o.jsx(fce,{onNewLabel:()=>{s(C=>C+1),r("Labels")},onViewReports:()=>{f("label-report"),d(C=>C+1),r("Reports")},onViewAllRecentLabels:()=>{f("print-log"),d(C=>C+1),r("Reports")}});case"Training":return o.jsx(ove,{});case"Alerts":return o.jsx(lve,{});case"Menu Management":return o.jsx(xve,{});case"System Menu":return o.jsx(Zwe,{});case"Account Management":return o.jsx($0e,{initialSubTab:n,onInitialSubTabConsumed:()=>a(null)});case"Reports":return o.jsx(Xwe,{layoutReportsOpenKey:l,layoutReportsTargetTab:u});case"Support":return o.jsx(s1e,{});case"Labels":case"Label Categories":case"Label Types":case"Label Templates":case"Multiple Options":return o.jsx(ave,{currentView:N,onViewChange:r,labelCreateOpenSeq:i,onLabelCreateIntentConsumed:w,onLabelTemplateEditorLayoutOverlay:p});default:return o.jsx(hce,{title:N})}};return o.jsx(o.Fragment,{children:o.jsx(dW,{currentView:v,setCurrentView:b,menus:e.menus,onLogout:e.logout,hideAppChrome:h,children:j()})})}function v1e(){return o.jsxs(o.Fragment,{children:[o.jsx(f1e,{children:o.jsx(y1e,{})}),o.jsx(V9,{position:"top-center",richColors:!0,closeButton:!0,expand:!1})]})}y9.createRoot(document.getElementById("root")).render(o.jsx(v1e,{})); diff --git a/美国版/Food Labeling Management Platform/build/assets/index-D3QH2BRm.js b/美国版/Food Labeling Management Platform/build/assets/index-D3QH2BRm.js new file mode 100644 index 0000000..f5cdb00 --- /dev/null +++ b/美国版/Food Labeling Management Platform/build/assets/index-D3QH2BRm.js @@ -0,0 +1,474 @@ +function h9(e,t){for(var r=0;rn[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))n(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();var Nm=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sx={exports:{}},fd={},jx={exports:{}},jt={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var WO;function m9(){if(WO)return jt;WO=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),s=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.iterator;function p(D){return D===null||typeof D!="object"?null:(D=h&&D[h]||D["@@iterator"],typeof D=="function"?D:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,b={};function w(D,$,K){this.props=D,this.context=$,this.refs=b,this.updater=K||g}w.prototype.isReactComponent={},w.prototype.setState=function(D,$){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,$,"setState")},w.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function j(){}j.prototype=w.prototype;function N(D,$,K){this.props=D,this.context=$,this.refs=b,this.updater=K||g}var C=N.prototype=new j;C.constructor=N,x(C,w.prototype),C.isPureReactComponent=!0;var O=Array.isArray,P=Object.prototype.hasOwnProperty,E={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function A(D,$,K){var J,oe={},re=null,Q=null;if($!=null)for(J in $.ref!==void 0&&(Q=$.ref),$.key!==void 0&&(re=""+$.key),$)P.call($,J)&&!T.hasOwnProperty(J)&&(oe[J]=$[J]);var ce=arguments.length-2;if(ce===1)oe.children=K;else if(1>>1,$=M[D];if(0>>1;Da(oe,F))re<$&&0>a(Q,oe)?(M[D]=Q,M[re]=F,D=re):(M[D]=oe,M[J]=F,D=J);else if(re<$&&0>a(Q,F))M[D]=Q,M[re]=F,D=re;else break e}}return Y}function a(M,Y){var F=M.sortIndex-Y.sortIndex;return F!==0?F:M.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,l=s.now();e.unstable_now=function(){return s.now()-l}}var d=[],c=[],f=1,h=null,p=3,g=!1,x=!1,b=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(M){for(var Y=r(c);Y!==null;){if(Y.callback===null)n(c);else if(Y.startTime<=M)n(c),Y.sortIndex=Y.expirationTime,t(d,Y);else break;Y=r(c)}}function O(M){if(b=!1,C(M),!x)if(r(d)!==null)x=!0,W(P);else{var Y=r(c);Y!==null&&q(O,Y.startTime-M)}}function P(M,Y){x=!1,b&&(b=!1,j(A),A=-1),g=!0;var F=p;try{for(C(Y),h=r(d);h!==null&&(!(h.expirationTime>Y)||M&&!L());){var D=h.callback;if(typeof D=="function"){h.callback=null,p=h.priorityLevel;var $=D(h.expirationTime<=Y);Y=e.unstable_now(),typeof $=="function"?h.callback=$:h===r(d)&&n(d),C(Y)}else n(d);h=r(d)}if(h!==null)var K=!0;else{var J=r(c);J!==null&&q(O,J.startTime-Y),K=!1}return K}finally{h=null,p=F,g=!1}}var E=!1,T=null,A=-1,I=5,R=-1;function L(){return!(e.unstable_now()-RM||125D?(M.sortIndex=F,t(c,M),r(d)===null&&M===r(c)&&(b?(j(A),A=-1):b=!0,q(O,F-D))):(M.sortIndex=$,t(d,M),x||g||(x=!0,W(P))),M},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(M){var Y=p;return function(){var F=p;p=Y;try{return M.apply(this,arguments)}finally{p=F}}}})(_x)),_x}var XO;function v9(){return XO||(XO=1,Cx.exports=y9()),Cx.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var JO;function x9(){if(JO)return An;JO=1;var e=fy(),t=v9();function r(u){for(var m="https://reactjs.org/docs/error-decoder.html?invariant="+u,y=1;y"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,c=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},h={};function p(u){return d.call(h,u)?!0:d.call(f,u)?!1:c.test(u)?h[u]=!0:(f[u]=!0,!1)}function g(u,m,y,S){if(y!==null&&y.type===0)return!1;switch(typeof m){case"function":case"symbol":return!0;case"boolean":return S?!1:y!==null?!y.acceptsBooleans:(u=u.toLowerCase().slice(0,5),u!=="data-"&&u!=="aria-");default:return!1}}function x(u,m,y,S){if(m===null||typeof m>"u"||g(u,m,y,S))return!0;if(S)return!1;if(y!==null)switch(y.type){case 3:return!m;case 4:return m===!1;case 5:return isNaN(m);case 6:return isNaN(m)||1>m}return!1}function b(u,m,y,S,_,k,B){this.acceptsBooleans=m===2||m===3||m===4,this.attributeName=S,this.attributeNamespace=_,this.mustUseProperty=y,this.propertyName=u,this.type=m,this.sanitizeURL=k,this.removeEmptyString=B}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(u){w[u]=new b(u,0,!1,u,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(u){var m=u[0];w[m]=new b(m,1,!1,u[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(u){w[u]=new b(u,2,!1,u.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(u){w[u]=new b(u,2,!1,u,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(u){w[u]=new b(u,3,!1,u.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(u){w[u]=new b(u,3,!0,u,null,!1,!1)}),["capture","download"].forEach(function(u){w[u]=new b(u,4,!1,u,null,!1,!1)}),["cols","rows","size","span"].forEach(function(u){w[u]=new b(u,6,!1,u,null,!1,!1)}),["rowSpan","start"].forEach(function(u){w[u]=new b(u,5,!1,u.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(u){return u[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(u){var m=u.replace(j,N);w[m]=new b(m,1,!1,u,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(u){var m=u.replace(j,N);w[m]=new b(m,1,!1,u,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(u){var m=u.replace(j,N);w[m]=new b(m,1,!1,u,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(u){w[u]=new b(u,1,!1,u.toLowerCase(),null,!1,!1)}),w.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(u){w[u]=new b(u,1,!1,u.toLowerCase(),null,!0,!0)});function C(u,m,y,S){var _=w.hasOwnProperty(m)?w[m]:null;(_!==null?_.type!==0:S||!(2X||_[B]!==k[X]){var te=` +`+_[B].replace(" at new "," at ");return u.displayName&&te.includes("")&&(te=te.replace("",u.displayName)),te}while(1<=B&&0<=X);break}}}finally{K=!1,Error.prepareStackTrace=y}return(u=u?u.displayName||u.name:"")?$(u):""}function oe(u){switch(u.tag){case 5:return $(u.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return u=J(u.type,!1),u;case 11:return u=J(u.type.render,!1),u;case 1:return u=J(u.type,!0),u;default:return""}}function re(u){if(u==null)return null;if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case T:return"Fragment";case E:return"Portal";case I:return"Profiler";case A:return"StrictMode";case z:return"Suspense";case G:return"SuspenseList"}if(typeof u=="object")switch(u.$$typeof){case L:return(u.displayName||"Context")+".Consumer";case R:return(u._context.displayName||"Context")+".Provider";case V:var m=u.render;return u=u.displayName,u||(u=m.displayName||m.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case H:return m=u.displayName||null,m!==null?m:re(u.type)||"Memo";case W:m=u._payload,u=u._init;try{return re(u(m))}catch{}}return null}function Q(u){var m=u.type;switch(u.tag){case 24:return"Cache";case 9:return(m.displayName||"Context")+".Consumer";case 10:return(m._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return u=m.render,u=u.displayName||u.name||"",m.displayName||(u!==""?"ForwardRef("+u+")":"ForwardRef");case 7:return"Fragment";case 5:return m;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return re(m);case 8:return m===A?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof m=="function")return m.displayName||m.name||null;if(typeof m=="string")return m}return null}function ce(u){switch(typeof u){case"boolean":case"number":case"string":case"undefined":return u;case"object":return u;default:return""}}function se(u){var m=u.type;return(u=u.nodeName)&&u.toLowerCase()==="input"&&(m==="checkbox"||m==="radio")}function fe(u){var m=se(u)?"checked":"value",y=Object.getOwnPropertyDescriptor(u.constructor.prototype,m),S=""+u[m];if(!u.hasOwnProperty(m)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var _=y.get,k=y.set;return Object.defineProperty(u,m,{configurable:!0,get:function(){return _.call(this)},set:function(B){S=""+B,k.call(this,B)}}),Object.defineProperty(u,m,{enumerable:y.enumerable}),{getValue:function(){return S},setValue:function(B){S=""+B},stopTracking:function(){u._valueTracker=null,delete u[m]}}}}function be(u){u._valueTracker||(u._valueTracker=fe(u))}function Z(u){if(!u)return!1;var m=u._valueTracker;if(!m)return!0;var y=m.getValue(),S="";return u&&(S=se(u)?u.checked?"true":"false":u.value),u=S,u!==y?(m.setValue(u),!0):!1}function Se(u){if(u=u||(typeof document<"u"?document:void 0),typeof u>"u")return null;try{return u.activeElement||u.body}catch{return u.body}}function Ne(u,m){var y=m.checked;return F({},m,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??u._wrapperState.initialChecked})}function qe(u,m){var y=m.defaultValue==null?"":m.defaultValue,S=m.checked!=null?m.checked:m.defaultChecked;y=ce(m.value!=null?m.value:y),u._wrapperState={initialChecked:S,initialValue:y,controlled:m.type==="checkbox"||m.type==="radio"?m.checked!=null:m.value!=null}}function De(u,m){m=m.checked,m!=null&&C(u,"checked",m,!1)}function He(u,m){De(u,m);var y=ce(m.value),S=m.type;if(y!=null)S==="number"?(y===0&&u.value===""||u.value!=y)&&(u.value=""+y):u.value!==""+y&&(u.value=""+y);else if(S==="submit"||S==="reset"){u.removeAttribute("value");return}m.hasOwnProperty("value")?pe(u,m.type,y):m.hasOwnProperty("defaultValue")&&pe(u,m.type,ce(m.defaultValue)),m.checked==null&&m.defaultChecked!=null&&(u.defaultChecked=!!m.defaultChecked)}function ne(u,m,y){if(m.hasOwnProperty("value")||m.hasOwnProperty("defaultValue")){var S=m.type;if(!(S!=="submit"&&S!=="reset"||m.value!==void 0&&m.value!==null))return;m=""+u._wrapperState.initialValue,y||m===u.value||(u.value=m),u.defaultValue=m}y=u.name,y!==""&&(u.name=""),u.defaultChecked=!!u._wrapperState.initialChecked,y!==""&&(u.name=y)}function pe(u,m,y){(m!=="number"||Se(u.ownerDocument)!==u)&&(y==null?u.defaultValue=""+u._wrapperState.initialValue:u.defaultValue!==""+y&&(u.defaultValue=""+y))}var _e=Array.isArray;function ye(u,m,y,S){if(u=u.options,m){m={};for(var _=0;_"+m.valueOf().toString()+"",m=Nt.firstChild;u.firstChild;)u.removeChild(u.firstChild);for(;m.firstChild;)u.appendChild(m.firstChild)}});function Ie(u,m){if(m){var y=u.firstChild;if(y&&y===u.lastChild&&y.nodeType===3){y.nodeValue=m;return}}u.textContent=m}var gt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_t=["Webkit","ms","Moz","O"];Object.keys(gt).forEach(function(u){_t.forEach(function(m){m=m+u.charAt(0).toUpperCase()+u.substring(1),gt[m]=gt[u]})});function Qt(u,m,y){return m==null||typeof m=="boolean"||m===""?"":y||typeof m!="number"||m===0||gt.hasOwnProperty(u)&>[u]?(""+m).trim():m+"px"}function Pr(u,m){u=u.style;for(var y in m)if(m.hasOwnProperty(y)){var S=y.indexOf("--")===0,_=Qt(y,m[y],S);y==="float"&&(y="cssFloat"),S?u.setProperty(y,_):u[y]=_}}var Vn=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Jr(u,m){if(m){if(Vn[u]&&(m.children!=null||m.dangerouslySetInnerHTML!=null))throw Error(r(137,u));if(m.dangerouslySetInnerHTML!=null){if(m.children!=null)throw Error(r(60));if(typeof m.dangerouslySetInnerHTML!="object"||!("__html"in m.dangerouslySetInnerHTML))throw Error(r(61))}if(m.style!=null&&typeof m.style!="object")throw Error(r(62))}}function qr(u,m){if(u.indexOf("-")===-1)return typeof m.is=="string";switch(u){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Or=null;function Vt(u){return u=u.target||u.srcElement||window,u.correspondingUseElement&&(u=u.correspondingUseElement),u.nodeType===3?u.parentNode:u}var gr=null,Kt=null,fr=null;function tr(u){if(u=Ju(u)){if(typeof gr!="function")throw Error(r(280));var m=u.stateNode;m&&(m=Fh(m),gr(u.stateNode,u.type,m))}}function Je(u){Kt?fr?fr.push(u):fr=[u]:Kt=u}function Et(){if(Kt){var u=Kt,m=fr;if(fr=Kt=null,tr(u),m)for(u=0;u>>=0,u===0?32:31-(Wv(u)/Iu|0)|0}var pi=64,gl=4194304;function gi(u){switch(u&-u){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return u&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return u}}function yl(u,m){var y=u.pendingLanes;if(y===0)return 0;var S=0,_=u.suspendedLanes,k=u.pingedLanes,B=y&268435455;if(B!==0){var X=B&~_;X!==0?S=gi(X):(k&=B,k!==0&&(S=gi(k)))}else B=y&~_,B!==0?S=gi(B):k!==0&&(S=gi(k));if(S===0)return 0;if(m!==0&&m!==S&&(m&_)===0&&(_=S&-S,k=m&-m,_>=k||_===16&&(k&4194240)!==0))return m;if((S&4)!==0&&(S|=y&16),m=u.entangledLanes,m!==0)for(u=u.entanglements,m&=S;0y;y++)m.push(u);return m}function os(u,m,y){u.pendingLanes|=m,m!==536870912&&(u.suspendedLanes=0,u.pingedLanes=0),u=u.eventTimes,m=31-_n(m),u[m]=y}function wh(u,m){var y=u.pendingLanes&~m;u.pendingLanes=m,u.suspendedLanes=0,u.pingedLanes=0,u.expiredLanes&=m,u.mutableReadLanes&=m,u.entangledLanes&=m,m=u.entanglements;var S=u.eventTimes;for(u=u.expirationTimes;0=Uu),$E=" ",FE=!1;function BE(u,m){switch(u){case"keyup":return lU.indexOf(m.keyCode)!==-1;case"keydown":return m.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zE(u){return u=u.detail,typeof u=="object"&&"data"in u?u.data:null}var jl=!1;function uU(u,m){switch(u){case"compositionend":return zE(m);case"keypress":return m.which!==32?null:(FE=!0,$E);case"textInput":return u=m.data,u===$E&&FE?null:u;default:return null}}function dU(u,m){if(jl)return u==="compositionend"||!r0&&BE(u,m)?(u=AE(),Ph=Xv=vi=null,jl=!1,u):null;switch(u){case"paste":return null;case"keypress":if(!(m.ctrlKey||m.altKey||m.metaKey)||m.ctrlKey&&m.altKey){if(m.char&&1=m)return{node:y,offset:m-u};u=S}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=YE(y)}}function XE(u,m){return u&&m?u===m?!0:u&&u.nodeType===3?!1:m&&m.nodeType===3?XE(u,m.parentNode):"contains"in u?u.contains(m):u.compareDocumentPosition?!!(u.compareDocumentPosition(m)&16):!1:!1}function JE(){for(var u=window,m=Se();m instanceof u.HTMLIFrameElement;){try{var y=typeof m.contentWindow.location.href=="string"}catch{y=!1}if(y)u=m.contentWindow;else break;m=Se(u.document)}return m}function o0(u){var m=u&&u.nodeName&&u.nodeName.toLowerCase();return m&&(m==="input"&&(u.type==="text"||u.type==="search"||u.type==="tel"||u.type==="url"||u.type==="password")||m==="textarea"||u.contentEditable==="true")}function bU(u){var m=JE(),y=u.focusedElem,S=u.selectionRange;if(m!==y&&y&&y.ownerDocument&&XE(y.ownerDocument.documentElement,y)){if(S!==null&&o0(y)){if(m=S.start,u=S.end,u===void 0&&(u=m),"selectionStart"in y)y.selectionStart=m,y.selectionEnd=Math.min(u,y.value.length);else if(u=(m=y.ownerDocument||document)&&m.defaultView||window,u.getSelection){u=u.getSelection();var _=y.textContent.length,k=Math.min(S.start,_);S=S.end===void 0?k:Math.min(S.end,_),!u.extend&&k>S&&(_=S,S=k,k=_),_=KE(y,k);var B=KE(y,S);_&&B&&(u.rangeCount!==1||u.anchorNode!==_.node||u.anchorOffset!==_.offset||u.focusNode!==B.node||u.focusOffset!==B.offset)&&(m=m.createRange(),m.setStart(_.node,_.offset),u.removeAllRanges(),k>S?(u.addRange(m),u.extend(B.node,B.offset)):(m.setEnd(B.node,B.offset),u.addRange(m)))}}for(m=[],u=y;u=u.parentNode;)u.nodeType===1&&m.push({element:u,left:u.scrollLeft,top:u.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y=document.documentMode,Nl=null,i0=null,Hu=null,s0=!1;function QE(u,m,y){var S=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;s0||Nl==null||Nl!==Se(S)||(S=Nl,"selectionStart"in S&&o0(S)?S={start:S.selectionStart,end:S.selectionEnd}:(S=(S.ownerDocument&&S.ownerDocument.defaultView||window).getSelection(),S={anchorNode:S.anchorNode,anchorOffset:S.anchorOffset,focusNode:S.focusNode,focusOffset:S.focusOffset}),Hu&&Wu(Hu,S)||(Hu=S,S=Dh(i0,"onSelect"),0Ol||(u.current=x0[Ol],x0[Ol]=null,Ol--)}function rr(u,m){Ol++,x0[Ol]=u.current,u.current=m}var Si={},nn=wi(Si),En=wi(!1),ls=Si;function Tl(u,m){var y=u.type.contextTypes;if(!y)return Si;var S=u.stateNode;if(S&&S.__reactInternalMemoizedUnmaskedChildContext===m)return S.__reactInternalMemoizedMaskedChildContext;var _={},k;for(k in y)_[k]=m[k];return S&&(u=u.stateNode,u.__reactInternalMemoizedUnmaskedChildContext=m,u.__reactInternalMemoizedMaskedChildContext=_),_}function Pn(u){return u=u.childContextTypes,u!=null}function Bh(){ur(En),ur(nn)}function hP(u,m,y){if(nn.current!==Si)throw Error(r(168));rr(nn,m),rr(En,y)}function mP(u,m,y){var S=u.stateNode;if(m=m.childContextTypes,typeof S.getChildContext!="function")return y;S=S.getChildContext();for(var _ in S)if(!(_ in m))throw Error(r(108,Q(u)||"Unknown",_));return F({},y,S)}function zh(u){return u=(u=u.stateNode)&&u.__reactInternalMemoizedMergedChildContext||Si,ls=nn.current,rr(nn,u),rr(En,En.current),!0}function pP(u,m,y){var S=u.stateNode;if(!S)throw Error(r(169));y?(u=mP(u,m,ls),S.__reactInternalMemoizedMergedChildContext=u,ur(En),ur(nn),rr(nn,u)):ur(En),rr(En,y)}var Ro=null,Uh=!1,b0=!1;function gP(u){Ro===null?Ro=[u]:Ro.push(u)}function AU(u){Uh=!0,gP(u)}function ji(){if(!b0&&Ro!==null){b0=!0;var u=0,m=$t;try{var y=Ro;for($t=1;u>=B,_-=B,Do=1<<32-_n(m)+_|y<<_|S,Lo=k+u}else Do=1<ht?(Hr=st,st=null):Hr=st.sibling;var Ft=Pe(le,st,he[ht],Me);if(Ft===null){st===null&&(st=Hr);break}u&&st&&Ft.alternate===null&&m(le,st),ie=k(Ft,ie,ht),it===null?et=Ft:it.sibling=Ft,it=Ft,st=Hr}if(ht===he.length)return y(le,st),mr&&us(le,ht),et;if(st===null){for(;htht?(Hr=st,st=null):Hr=st.sibling;var Ai=Pe(le,st,Ft.value,Me);if(Ai===null){st===null&&(st=Hr);break}u&&st&&Ai.alternate===null&&m(le,st),ie=k(Ai,ie,ht),it===null?et=Ai:it.sibling=Ai,it=Ai,st=Hr}if(Ft.done)return y(le,st),mr&&us(le,ht),et;if(st===null){for(;!Ft.done;ht++,Ft=he.next())Ft=Te(le,Ft.value,Me),Ft!==null&&(ie=k(Ft,ie,ht),it===null?et=Ft:it.sibling=Ft,it=Ft);return mr&&us(le,ht),et}for(st=S(le,st);!Ft.done;ht++,Ft=he.next())Ft=Ue(st,le,ht,Ft.value,Me),Ft!==null&&(u&&Ft.alternate!==null&&st.delete(Ft.key===null?ht:Ft.key),ie=k(Ft,ie,ht),it===null?et=Ft:it.sibling=Ft,it=Ft);return u&&st.forEach(function(f9){return m(le,f9)}),mr&&us(le,ht),et}function Cr(le,ie,he,Me){if(typeof he=="object"&&he!==null&&he.type===T&&he.key===null&&(he=he.props.children),typeof he=="object"&&he!==null){switch(he.$$typeof){case P:e:{for(var et=he.key,it=ie;it!==null;){if(it.key===et){if(et=he.type,et===T){if(it.tag===7){y(le,it.sibling),ie=_(it,he.props.children),ie.return=le,le=ie;break e}}else if(it.elementType===et||typeof et=="object"&&et!==null&&et.$$typeof===W&&SP(et)===it.type){y(le,it.sibling),ie=_(it,he.props),ie.ref=Qu(le,it,he),ie.return=le,le=ie;break e}y(le,it);break}else m(le,it);it=it.sibling}he.type===T?(ie=vs(he.props.children,le.mode,Me,he.key),ie.return=le,le=ie):(Me=gm(he.type,he.key,he.props,null,le.mode,Me),Me.ref=Qu(le,ie,he),Me.return=le,le=Me)}return B(le);case E:e:{for(it=he.key;ie!==null;){if(ie.key===it)if(ie.tag===4&&ie.stateNode.containerInfo===he.containerInfo&&ie.stateNode.implementation===he.implementation){y(le,ie.sibling),ie=_(ie,he.children||[]),ie.return=le,le=ie;break e}else{y(le,ie);break}else m(le,ie);ie=ie.sibling}ie=yx(he,le.mode,Me),ie.return=le,le=ie}return B(le);case W:return it=he._init,Cr(le,ie,it(he._payload),Me)}if(_e(he))return Ye(le,ie,he,Me);if(Y(he))return Ze(le,ie,he,Me);Hh(le,he)}return typeof he=="string"&&he!==""||typeof he=="number"?(he=""+he,ie!==null&&ie.tag===6?(y(le,ie.sibling),ie=_(ie,he),ie.return=le,le=ie):(y(le,ie),ie=gx(he,le.mode,Me),ie.return=le,le=ie),B(le)):y(le,ie)}return Cr}var Ml=jP(!0),NP=jP(!1),Gh=wi(null),Yh=null,Rl=null,_0=null;function E0(){_0=Rl=Yh=null}function P0(u){var m=Gh.current;ur(Gh),u._currentValue=m}function O0(u,m,y){for(;u!==null;){var S=u.alternate;if((u.childLanes&m)!==m?(u.childLanes|=m,S!==null&&(S.childLanes|=m)):S!==null&&(S.childLanes&m)!==m&&(S.childLanes|=m),u===y)break;u=u.return}}function Dl(u,m){Yh=u,_0=Rl=null,u=u.dependencies,u!==null&&u.firstContext!==null&&((u.lanes&m)!==0&&(On=!0),u.firstContext=null)}function ya(u){var m=u._currentValue;if(_0!==u)if(u={context:u,memoizedValue:m,next:null},Rl===null){if(Yh===null)throw Error(r(308));Rl=u,Yh.dependencies={lanes:0,firstContext:u}}else Rl=Rl.next=u;return m}var ds=null;function T0(u){ds===null?ds=[u]:ds.push(u)}function CP(u,m,y,S){var _=m.interleaved;return _===null?(y.next=y,T0(m)):(y.next=_.next,_.next=y),m.interleaved=y,$o(u,S)}function $o(u,m){u.lanes|=m;var y=u.alternate;for(y!==null&&(y.lanes|=m),y=u,u=u.return;u!==null;)u.childLanes|=m,y=u.alternate,y!==null&&(y.childLanes|=m),y=u,u=u.return;return y.tag===3?y.stateNode:null}var Ni=!1;function k0(u){u.updateQueue={baseState:u.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _P(u,m){u=u.updateQueue,m.updateQueue===u&&(m.updateQueue={baseState:u.baseState,firstBaseUpdate:u.firstBaseUpdate,lastBaseUpdate:u.lastBaseUpdate,shared:u.shared,effects:u.effects})}function Fo(u,m){return{eventTime:u,lane:m,tag:0,payload:null,callback:null,next:null}}function Ci(u,m,y){var S=u.updateQueue;if(S===null)return null;if(S=S.shared,(Mt&2)!==0){var _=S.pending;return _===null?m.next=m:(m.next=_.next,_.next=m),S.pending=m,$o(u,y)}return _=S.interleaved,_===null?(m.next=m,T0(S)):(m.next=_.next,_.next=m),S.interleaved=m,$o(u,y)}function Kh(u,m,y){if(m=m.updateQueue,m!==null&&(m=m.shared,(y&4194240)!==0)){var S=m.lanes;S&=u.pendingLanes,y|=S,m.lanes=y,Mu(u,y)}}function EP(u,m){var y=u.updateQueue,S=u.alternate;if(S!==null&&(S=S.updateQueue,y===S)){var _=null,k=null;if(y=y.firstBaseUpdate,y!==null){do{var B={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};k===null?_=k=B:k=k.next=B,y=y.next}while(y!==null);k===null?_=k=m:k=k.next=m}else _=k=m;y={baseState:S.baseState,firstBaseUpdate:_,lastBaseUpdate:k,shared:S.shared,effects:S.effects},u.updateQueue=y;return}u=y.lastBaseUpdate,u===null?y.firstBaseUpdate=m:u.next=m,y.lastBaseUpdate=m}function Xh(u,m,y,S){var _=u.updateQueue;Ni=!1;var k=_.firstBaseUpdate,B=_.lastBaseUpdate,X=_.shared.pending;if(X!==null){_.shared.pending=null;var te=X,ge=te.next;te.next=null,B===null?k=ge:B.next=ge,B=te;var Oe=u.alternate;Oe!==null&&(Oe=Oe.updateQueue,X=Oe.lastBaseUpdate,X!==B&&(X===null?Oe.firstBaseUpdate=ge:X.next=ge,Oe.lastBaseUpdate=te))}if(k!==null){var Te=_.baseState;B=0,Oe=ge=te=null,X=k;do{var Pe=X.lane,Ue=X.eventTime;if((S&Pe)===Pe){Oe!==null&&(Oe=Oe.next={eventTime:Ue,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Ye=u,Ze=X;switch(Pe=m,Ue=y,Ze.tag){case 1:if(Ye=Ze.payload,typeof Ye=="function"){Te=Ye.call(Ue,Te,Pe);break e}Te=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=Ze.payload,Pe=typeof Ye=="function"?Ye.call(Ue,Te,Pe):Ye,Pe==null)break e;Te=F({},Te,Pe);break e;case 2:Ni=!0}}X.callback!==null&&X.lane!==0&&(u.flags|=64,Pe=_.effects,Pe===null?_.effects=[X]:Pe.push(X))}else Ue={eventTime:Ue,lane:Pe,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Oe===null?(ge=Oe=Ue,te=Te):Oe=Oe.next=Ue,B|=Pe;if(X=X.next,X===null){if(X=_.shared.pending,X===null)break;Pe=X,X=Pe.next,Pe.next=null,_.lastBaseUpdate=Pe,_.shared.pending=null}}while(!0);if(Oe===null&&(te=Te),_.baseState=te,_.firstBaseUpdate=ge,_.lastBaseUpdate=Oe,m=_.shared.interleaved,m!==null){_=m;do B|=_.lane,_=_.next;while(_!==m)}else k===null&&(_.shared.lanes=0);ms|=B,u.lanes=B,u.memoizedState=Te}}function PP(u,m,y){if(u=m.effects,m.effects=null,u!==null)for(m=0;my?y:4,u(!0);var S=D0.transition;D0.transition={};try{u(!1),m()}finally{$t=y,D0.transition=S}}function GP(){return va().memoizedState}function DU(u,m,y){var S=Oi(u);if(y={lane:S,action:y,hasEagerState:!1,eagerState:null,next:null},YP(u))KP(m,y);else if(y=CP(u,m,y,S),y!==null){var _=yn();za(y,u,S,_),XP(y,m,S)}}function LU(u,m,y){var S=Oi(u),_={lane:S,action:y,hasEagerState:!1,eagerState:null,next:null};if(YP(u))KP(m,_);else{var k=u.alternate;if(u.lanes===0&&(k===null||k.lanes===0)&&(k=m.lastRenderedReducer,k!==null))try{var B=m.lastRenderedState,X=k(B,y);if(_.hasEagerState=!0,_.eagerState=X,Da(X,B)){var te=m.interleaved;te===null?(_.next=_,T0(m)):(_.next=te.next,te.next=_),m.interleaved=_;return}}catch{}finally{}y=CP(u,m,_,S),y!==null&&(_=yn(),za(y,u,S,_),XP(y,m,S))}}function YP(u){var m=u.alternate;return u===vr||m!==null&&m===vr}function KP(u,m){rd=Zh=!0;var y=u.pending;y===null?m.next=m:(m.next=y.next,y.next=m),u.pending=m}function XP(u,m,y){if((y&4194240)!==0){var S=m.lanes;S&=u.pendingLanes,y|=S,m.lanes=y,Mu(u,y)}}var rm={readContext:ya,useCallback:an,useContext:an,useEffect:an,useImperativeHandle:an,useInsertionEffect:an,useLayoutEffect:an,useMemo:an,useReducer:an,useRef:an,useState:an,useDebugValue:an,useDeferredValue:an,useTransition:an,useMutableSource:an,useSyncExternalStore:an,useId:an,unstable_isNewReconciler:!1},$U={readContext:ya,useCallback:function(u,m){return so().memoizedState=[u,m===void 0?null:m],u},useContext:ya,useEffect:FP,useImperativeHandle:function(u,m,y){return y=y!=null?y.concat([u]):null,em(4194308,4,UP.bind(null,m,u),y)},useLayoutEffect:function(u,m){return em(4194308,4,u,m)},useInsertionEffect:function(u,m){return em(4,2,u,m)},useMemo:function(u,m){var y=so();return m=m===void 0?null:m,u=u(),y.memoizedState=[u,m],u},useReducer:function(u,m,y){var S=so();return m=y!==void 0?y(m):m,S.memoizedState=S.baseState=m,u={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:u,lastRenderedState:m},S.queue=u,u=u.dispatch=DU.bind(null,vr,u),[S.memoizedState,u]},useRef:function(u){var m=so();return u={current:u},m.memoizedState=u},useState:LP,useDebugValue:q0,useDeferredValue:function(u){return so().memoizedState=u},useTransition:function(){var u=LP(!1),m=u[0];return u=RU.bind(null,u[1]),so().memoizedState=u,[m,u]},useMutableSource:function(){},useSyncExternalStore:function(u,m,y){var S=vr,_=so();if(mr){if(y===void 0)throw Error(r(407));y=y()}else{if(y=m(),Wr===null)throw Error(r(349));(hs&30)!==0||AP(S,m,y)}_.memoizedState=y;var k={value:y,getSnapshot:m};return _.queue=k,FP(MP.bind(null,S,k,u),[u]),S.flags|=2048,od(9,IP.bind(null,S,k,y,m),void 0,null),y},useId:function(){var u=so(),m=Wr.identifierPrefix;if(mr){var y=Lo,S=Do;y=(S&~(1<<32-_n(S)-1)).toString(32)+y,m=":"+m+"R"+y,y=nd++,0<\/script>",u=u.removeChild(u.firstChild)):typeof S.is=="string"?u=B.createElement(y,{is:S.is}):(u=B.createElement(y),y==="select"&&(B=u,S.multiple?B.multiple=!0:S.size&&(B.size=S.size))):u=B.createElementNS(u,y),u[oo]=m,u[Xu]=S,gO(u,m,!1,!1),m.stateNode=u;e:{switch(B=qr(y,S),y){case"dialog":cr("cancel",u),cr("close",u),_=S;break;case"iframe":case"object":case"embed":cr("load",u),_=S;break;case"video":case"audio":for(_=0;_zl&&(m.flags|=128,S=!0,id(k,!1),m.lanes=4194304)}else{if(!S)if(u=Jh(B),u!==null){if(m.flags|=128,S=!0,y=u.updateQueue,y!==null&&(m.updateQueue=y,m.flags|=4),id(k,!0),k.tail===null&&k.tailMode==="hidden"&&!B.alternate&&!mr)return on(m),null}else 2*lr()-k.renderingStartTime>zl&&y!==1073741824&&(m.flags|=128,S=!0,id(k,!1),m.lanes=4194304);k.isBackwards?(B.sibling=m.child,m.child=B):(y=k.last,y!==null?y.sibling=B:m.child=B,k.last=B)}return k.tail!==null?(m=k.tail,k.rendering=m,k.tail=m.sibling,k.renderingStartTime=lr(),m.sibling=null,y=yr.current,rr(yr,S?y&1|2:y&1),m):(on(m),null);case 22:case 23:return hx(),S=m.memoizedState!==null,u!==null&&u.memoizedState!==null!==S&&(m.flags|=8192),S&&(m.mode&1)!==0?(Kn&1073741824)!==0&&(on(m),m.subtreeFlags&6&&(m.flags|=8192)):on(m),null;case 24:return null;case 25:return null}throw Error(r(156,m.tag))}function HU(u,m){switch(S0(m),m.tag){case 1:return Pn(m.type)&&Bh(),u=m.flags,u&65536?(m.flags=u&-65537|128,m):null;case 3:return Ll(),ur(En),ur(nn),R0(),u=m.flags,(u&65536)!==0&&(u&128)===0?(m.flags=u&-65537|128,m):null;case 5:return I0(m),null;case 13:if(ur(yr),u=m.memoizedState,u!==null&&u.dehydrated!==null){if(m.alternate===null)throw Error(r(340));Il()}return u=m.flags,u&65536?(m.flags=u&-65537|128,m):null;case 19:return ur(yr),null;case 4:return Ll(),null;case 10:return P0(m.type._context),null;case 22:case 23:return hx(),null;case 24:return null;default:return null}}var im=!1,sn=!1,GU=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function Fl(u,m){var y=u.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(S){wr(u,m,S)}else y.current=null}function tx(u,m,y){try{y()}catch(S){wr(u,m,S)}}var xO=!1;function YU(u,m){if(h0=_h,u=JE(),o0(u)){if("selectionStart"in u)var y={start:u.selectionStart,end:u.selectionEnd};else e:{y=(y=u.ownerDocument)&&y.defaultView||window;var S=y.getSelection&&y.getSelection();if(S&&S.rangeCount!==0){y=S.anchorNode;var _=S.anchorOffset,k=S.focusNode;S=S.focusOffset;try{y.nodeType,k.nodeType}catch{y=null;break e}var B=0,X=-1,te=-1,ge=0,Oe=0,Te=u,Pe=null;t:for(;;){for(var Ue;Te!==y||_!==0&&Te.nodeType!==3||(X=B+_),Te!==k||S!==0&&Te.nodeType!==3||(te=B+S),Te.nodeType===3&&(B+=Te.nodeValue.length),(Ue=Te.firstChild)!==null;)Pe=Te,Te=Ue;for(;;){if(Te===u)break t;if(Pe===y&&++ge===_&&(X=B),Pe===k&&++Oe===S&&(te=B),(Ue=Te.nextSibling)!==null)break;Te=Pe,Pe=Te.parentNode}Te=Ue}y=X===-1||te===-1?null:{start:X,end:te}}else y=null}y=y||{start:0,end:0}}else y=null;for(m0={focusedElem:u,selectionRange:y},_h=!1,Ve=m;Ve!==null;)if(m=Ve,u=m.child,(m.subtreeFlags&1028)!==0&&u!==null)u.return=m,Ve=u;else for(;Ve!==null;){m=Ve;try{var Ye=m.alternate;if((m.flags&1024)!==0)switch(m.tag){case 0:case 11:case 15:break;case 1:if(Ye!==null){var Ze=Ye.memoizedProps,Cr=Ye.memoizedState,le=m.stateNode,ie=le.getSnapshotBeforeUpdate(m.elementType===m.type?Ze:$a(m.type,Ze),Cr);le.__reactInternalSnapshotBeforeUpdate=ie}break;case 3:var he=m.stateNode.containerInfo;he.nodeType===1?he.textContent="":he.nodeType===9&&he.documentElement&&he.removeChild(he.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Me){wr(m,m.return,Me)}if(u=m.sibling,u!==null){u.return=m.return,Ve=u;break}Ve=m.return}return Ye=xO,xO=!1,Ye}function sd(u,m,y){var S=m.updateQueue;if(S=S!==null?S.lastEffect:null,S!==null){var _=S=S.next;do{if((_.tag&u)===u){var k=_.destroy;_.destroy=void 0,k!==void 0&&tx(m,y,k)}_=_.next}while(_!==S)}}function sm(u,m){if(m=m.updateQueue,m=m!==null?m.lastEffect:null,m!==null){var y=m=m.next;do{if((y.tag&u)===u){var S=y.create;y.destroy=S()}y=y.next}while(y!==m)}}function rx(u){var m=u.ref;if(m!==null){var y=u.stateNode;switch(u.tag){case 5:u=y;break;default:u=y}typeof m=="function"?m(u):m.current=u}}function bO(u){var m=u.alternate;m!==null&&(u.alternate=null,bO(m)),u.child=null,u.deletions=null,u.sibling=null,u.tag===5&&(m=u.stateNode,m!==null&&(delete m[oo],delete m[Xu],delete m[v0],delete m[TU],delete m[kU])),u.stateNode=null,u.return=null,u.dependencies=null,u.memoizedProps=null,u.memoizedState=null,u.pendingProps=null,u.stateNode=null,u.updateQueue=null}function wO(u){return u.tag===5||u.tag===3||u.tag===4}function SO(u){e:for(;;){for(;u.sibling===null;){if(u.return===null||wO(u.return))return null;u=u.return}for(u.sibling.return=u.return,u=u.sibling;u.tag!==5&&u.tag!==6&&u.tag!==18;){if(u.flags&2||u.child===null||u.tag===4)continue e;u.child.return=u,u=u.child}if(!(u.flags&2))return u.stateNode}}function nx(u,m,y){var S=u.tag;if(S===5||S===6)u=u.stateNode,m?y.nodeType===8?y.parentNode.insertBefore(u,m):y.insertBefore(u,m):(y.nodeType===8?(m=y.parentNode,m.insertBefore(u,y)):(m=y,m.appendChild(u)),y=y._reactRootContainer,y!=null||m.onclick!==null||(m.onclick=$h));else if(S!==4&&(u=u.child,u!==null))for(nx(u,m,y),u=u.sibling;u!==null;)nx(u,m,y),u=u.sibling}function ax(u,m,y){var S=u.tag;if(S===5||S===6)u=u.stateNode,m?y.insertBefore(u,m):y.appendChild(u);else if(S!==4&&(u=u.child,u!==null))for(ax(u,m,y),u=u.sibling;u!==null;)ax(u,m,y),u=u.sibling}var Zr=null,Fa=!1;function _i(u,m,y){for(y=y.child;y!==null;)jO(u,m,y),y=y.sibling}function jO(u,m,y){if(Wn&&typeof Wn.onCommitFiberUnmount=="function")try{Wn.onCommitFiberUnmount(pl,y)}catch{}switch(y.tag){case 5:sn||Fl(y,m);case 6:var S=Zr,_=Fa;Zr=null,_i(u,m,y),Zr=S,Fa=_,Zr!==null&&(Fa?(u=Zr,y=y.stateNode,u.nodeType===8?u.parentNode.removeChild(y):u.removeChild(y)):Zr.removeChild(y.stateNode));break;case 18:Zr!==null&&(Fa?(u=Zr,y=y.stateNode,u.nodeType===8?y0(u.parentNode,y):u.nodeType===1&&y0(u,y),Fu(u)):y0(Zr,y.stateNode));break;case 4:S=Zr,_=Fa,Zr=y.stateNode.containerInfo,Fa=!0,_i(u,m,y),Zr=S,Fa=_;break;case 0:case 11:case 14:case 15:if(!sn&&(S=y.updateQueue,S!==null&&(S=S.lastEffect,S!==null))){_=S=S.next;do{var k=_,B=k.destroy;k=k.tag,B!==void 0&&((k&2)!==0||(k&4)!==0)&&tx(y,m,B),_=_.next}while(_!==S)}_i(u,m,y);break;case 1:if(!sn&&(Fl(y,m),S=y.stateNode,typeof S.componentWillUnmount=="function"))try{S.props=y.memoizedProps,S.state=y.memoizedState,S.componentWillUnmount()}catch(X){wr(y,m,X)}_i(u,m,y);break;case 21:_i(u,m,y);break;case 22:y.mode&1?(sn=(S=sn)||y.memoizedState!==null,_i(u,m,y),sn=S):_i(u,m,y);break;default:_i(u,m,y)}}function NO(u){var m=u.updateQueue;if(m!==null){u.updateQueue=null;var y=u.stateNode;y===null&&(y=u.stateNode=new GU),m.forEach(function(S){var _=n9.bind(null,u,S);y.has(S)||(y.add(S),S.then(_,_))})}}function Ba(u,m){var y=m.deletions;if(y!==null)for(var S=0;S_&&(_=B),S&=~k}if(S=_,S=lr()-S,S=(120>S?120:480>S?480:1080>S?1080:1920>S?1920:3e3>S?3e3:4320>S?4320:1960*XU(S/1960))-S,10u?16:u,Pi===null)var S=!1;else{if(u=Pi,Pi=null,fm=0,(Mt&6)!==0)throw Error(r(331));var _=Mt;for(Mt|=4,Ve=u.current;Ve!==null;){var k=Ve,B=k.child;if((Ve.flags&16)!==0){var X=k.deletions;if(X!==null){for(var te=0;telr()-sx?gs(u,0):ix|=y),kn(u,m)}function LO(u,m){m===0&&((u.mode&1)===0?m=1:(m=gl,gl<<=1,(gl&130023424)===0&&(gl=4194304)));var y=yn();u=$o(u,m),u!==null&&(os(u,m,y),kn(u,y))}function r9(u){var m=u.memoizedState,y=0;m!==null&&(y=m.retryLane),LO(u,y)}function n9(u,m){var y=0;switch(u.tag){case 13:var S=u.stateNode,_=u.memoizedState;_!==null&&(y=_.retryLane);break;case 19:S=u.stateNode;break;default:throw Error(r(314))}S!==null&&S.delete(m),LO(u,y)}var $O;$O=function(u,m,y){if(u!==null)if(u.memoizedProps!==m.pendingProps||En.current)On=!0;else{if((u.lanes&y)===0&&(m.flags&128)===0)return On=!1,VU(u,m,y);On=(u.flags&131072)!==0}else On=!1,mr&&(m.flags&1048576)!==0&&yP(m,Vh,m.index);switch(m.lanes=0,m.tag){case 2:var S=m.type;om(u,m),u=m.pendingProps;var _=Tl(m,nn.current);Dl(m,y),_=$0(null,m,S,u,_,y);var k=F0();return m.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(m.tag=1,m.memoizedState=null,m.updateQueue=null,Pn(S)?(k=!0,zh(m)):k=!1,m.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,k0(m),_.updater=nm,m.stateNode=_,_._reactInternals=m,W0(m,S,u,y),m=K0(null,m,S,!0,k,y)):(m.tag=0,mr&&k&&w0(m),gn(null,m,_,y),m=m.child),m;case 16:S=m.elementType;e:{switch(om(u,m),u=m.pendingProps,_=S._init,S=_(S._payload),m.type=S,_=m.tag=o9(S),u=$a(S,u),_){case 0:m=Y0(null,m,S,u,y);break e;case 1:m=uO(null,m,S,u,y);break e;case 11:m=oO(null,m,S,u,y);break e;case 14:m=iO(null,m,S,$a(S.type,u),y);break e}throw Error(r(306,S,""))}return m;case 0:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),Y0(u,m,S,_,y);case 1:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),uO(u,m,S,_,y);case 3:e:{if(dO(m),u===null)throw Error(r(387));S=m.pendingProps,k=m.memoizedState,_=k.element,_P(u,m),Xh(m,S,null,y);var B=m.memoizedState;if(S=B.element,k.isDehydrated)if(k={element:S,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},m.updateQueue.baseState=k,m.memoizedState=k,m.flags&256){_=$l(Error(r(423)),m),m=fO(u,m,S,y,_);break e}else if(S!==_){_=$l(Error(r(424)),m),m=fO(u,m,S,y,_);break e}else for(Yn=bi(m.stateNode.containerInfo.firstChild),Gn=m,mr=!0,La=null,y=NP(m,null,S,y),m.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Il(),S===_){m=Bo(u,m,y);break e}gn(u,m,S,y)}m=m.child}return m;case 5:return OP(m),u===null&&N0(m),S=m.type,_=m.pendingProps,k=u!==null?u.memoizedProps:null,B=_.children,p0(S,_)?B=null:k!==null&&p0(S,k)&&(m.flags|=32),cO(u,m),gn(u,m,B,y),m.child;case 6:return u===null&&N0(m),null;case 13:return hO(u,m,y);case 4:return A0(m,m.stateNode.containerInfo),S=m.pendingProps,u===null?m.child=Ml(m,null,S,y):gn(u,m,S,y),m.child;case 11:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),oO(u,m,S,_,y);case 7:return gn(u,m,m.pendingProps,y),m.child;case 8:return gn(u,m,m.pendingProps.children,y),m.child;case 12:return gn(u,m,m.pendingProps.children,y),m.child;case 10:e:{if(S=m.type._context,_=m.pendingProps,k=m.memoizedProps,B=_.value,rr(Gh,S._currentValue),S._currentValue=B,k!==null)if(Da(k.value,B)){if(k.children===_.children&&!En.current){m=Bo(u,m,y);break e}}else for(k=m.child,k!==null&&(k.return=m);k!==null;){var X=k.dependencies;if(X!==null){B=k.child;for(var te=X.firstContext;te!==null;){if(te.context===S){if(k.tag===1){te=Fo(-1,y&-y),te.tag=2;var ge=k.updateQueue;if(ge!==null){ge=ge.shared;var Oe=ge.pending;Oe===null?te.next=te:(te.next=Oe.next,Oe.next=te),ge.pending=te}}k.lanes|=y,te=k.alternate,te!==null&&(te.lanes|=y),O0(k.return,y,m),X.lanes|=y;break}te=te.next}}else if(k.tag===10)B=k.type===m.type?null:k.child;else if(k.tag===18){if(B=k.return,B===null)throw Error(r(341));B.lanes|=y,X=B.alternate,X!==null&&(X.lanes|=y),O0(B,y,m),B=k.sibling}else B=k.child;if(B!==null)B.return=k;else for(B=k;B!==null;){if(B===m){B=null;break}if(k=B.sibling,k!==null){k.return=B.return,B=k;break}B=B.return}k=B}gn(u,m,_.children,y),m=m.child}return m;case 9:return _=m.type,S=m.pendingProps.children,Dl(m,y),_=ya(_),S=S(_),m.flags|=1,gn(u,m,S,y),m.child;case 14:return S=m.type,_=$a(S,m.pendingProps),_=$a(S.type,_),iO(u,m,S,_,y);case 15:return sO(u,m,m.type,m.pendingProps,y);case 17:return S=m.type,_=m.pendingProps,_=m.elementType===S?_:$a(S,_),om(u,m),m.tag=1,Pn(S)?(u=!0,zh(m)):u=!1,Dl(m,y),QP(m,S,_),W0(m,S,_,y),K0(null,m,S,!0,u,y);case 19:return pO(u,m,y);case 22:return lO(u,m,y)}throw Error(r(156,m.tag))};function FO(u,m){return Tu(u,m)}function a9(u,m,y,S){this.tag=u,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=m,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=S,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ba(u,m,y,S){return new a9(u,m,y,S)}function px(u){return u=u.prototype,!(!u||!u.isReactComponent)}function o9(u){if(typeof u=="function")return px(u)?1:0;if(u!=null){if(u=u.$$typeof,u===V)return 11;if(u===H)return 14}return 2}function ki(u,m){var y=u.alternate;return y===null?(y=ba(u.tag,m,u.key,u.mode),y.elementType=u.elementType,y.type=u.type,y.stateNode=u.stateNode,y.alternate=u,u.alternate=y):(y.pendingProps=m,y.type=u.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=u.flags&14680064,y.childLanes=u.childLanes,y.lanes=u.lanes,y.child=u.child,y.memoizedProps=u.memoizedProps,y.memoizedState=u.memoizedState,y.updateQueue=u.updateQueue,m=u.dependencies,y.dependencies=m===null?null:{lanes:m.lanes,firstContext:m.firstContext},y.sibling=u.sibling,y.index=u.index,y.ref=u.ref,y}function gm(u,m,y,S,_,k){var B=2;if(S=u,typeof u=="function")px(u)&&(B=1);else if(typeof u=="string")B=5;else e:switch(u){case T:return vs(y.children,_,k,m);case A:B=8,_|=8;break;case I:return u=ba(12,y,m,_|2),u.elementType=I,u.lanes=k,u;case z:return u=ba(13,y,m,_),u.elementType=z,u.lanes=k,u;case G:return u=ba(19,y,m,_),u.elementType=G,u.lanes=k,u;case q:return ym(y,_,k,m);default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case R:B=10;break e;case L:B=9;break e;case V:B=11;break e;case H:B=14;break e;case W:B=16,S=null;break e}throw Error(r(130,u==null?u:typeof u,""))}return m=ba(B,y,m,_),m.elementType=u,m.type=S,m.lanes=k,m}function vs(u,m,y,S){return u=ba(7,u,S,m),u.lanes=y,u}function ym(u,m,y,S){return u=ba(22,u,S,m),u.elementType=q,u.lanes=y,u.stateNode={isHidden:!1},u}function gx(u,m,y){return u=ba(6,u,null,m),u.lanes=y,u}function yx(u,m,y){return m=ba(4,u.children!==null?u.children:[],u.key,m),m.lanes=y,m.stateNode={containerInfo:u.containerInfo,pendingChildren:null,implementation:u.implementation},m}function i9(u,m,y,S,_){this.tag=m,this.containerInfo=u,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=as(0),this.expirationTimes=as(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=as(0),this.identifierPrefix=S,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function vx(u,m,y,S,_,k,B,X,te){return u=new i9(u,m,y,X,te),m===1?(m=1,k===!0&&(m|=8)):m=0,k=ba(3,null,null,m),u.current=k,k.stateNode=u,k.memoizedState={element:S,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},k0(k),u}function s9(u,m,y){var S=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Nx.exports=x9(),Nx.exports}var ZO;function b9(){if(ZO)return Cm;ZO=1;var e=S$();return Cm.createRoot=e.createRoot,Cm.hydrateRoot=e.hydrateRoot,Cm}var w9=b9(),v=fy();const U=Wt(v),nC=h9({__proto__:null,default:U},[v]);var Mf=S$();const j$=Wt(Mf);function S9(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}const j9=e=>{switch(e){case"success":return _9;case"info":return P9;case"warning":return E9;case"error":return O9;default:return null}},N9=Array(12).fill(0),C9=({visible:e,className:t})=>U.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},U.createElement("div",{className:"sonner-spinner"},N9.map((r,n)=>U.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),_9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),E9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),P9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),O9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},U.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),T9=U.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},U.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),U.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),k9=()=>{const[e,t]=U.useState(document.hidden);return U.useEffect(()=>{const r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e};let sj=1;class A9{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const r=this.subscribers.indexOf(t);this.subscribers.splice(r,1)}),this.publish=t=>{this.subscribers.forEach(r=>r(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var r;const{message:n,...a}=t,i=typeof t?.id=="number"||((r=t.id)==null?void 0:r.length)>0?t.id:sj++,s=this.toasts.find(d=>d.id===i),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(d=>d.id===i?(this.publish({...d,...t,id:i,title:n}),{...d,...t,id:i,dismissible:l,title:n}):d):this.addToast({title:n,...a,dismissible:l,id:i}),i},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(r=>r({id:t,dismiss:!0})))):this.toasts.forEach(r=>{this.subscribers.forEach(n=>n({id:r.id,dismiss:!0}))}),t),this.message=(t,r)=>this.create({...r,message:t}),this.error=(t,r)=>this.create({...r,message:t,type:"error"}),this.success=(t,r)=>this.create({...r,type:"success",message:t}),this.info=(t,r)=>this.create({...r,type:"info",message:t}),this.warning=(t,r)=>this.create({...r,type:"warning",message:t}),this.loading=(t,r)=>this.create({...r,type:"loading",message:t}),this.promise=(t,r)=>{if(!r)return;let n;r.loading!==void 0&&(n=this.create({...r,promise:t,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));const a=Promise.resolve(t instanceof Function?t():t);let i=n!==void 0,s;const l=a.then(async c=>{if(s=["resolve",c],U.isValidElement(c))i=!1,this.create({id:n,type:"default",message:c});else if(M9(c)&&!c.ok){i=!1;const h=typeof r.error=="function"?await r.error(`HTTP error! status: ${c.status}`):r.error,p=typeof r.description=="function"?await r.description(`HTTP error! status: ${c.status}`):r.description,x=typeof h=="object"&&!U.isValidElement(h)?h:{message:h};this.create({id:n,type:"error",description:p,...x})}else if(c instanceof Error){i=!1;const h=typeof r.error=="function"?await r.error(c):r.error,p=typeof r.description=="function"?await r.description(c):r.description,x=typeof h=="object"&&!U.isValidElement(h)?h:{message:h};this.create({id:n,type:"error",description:p,...x})}else if(r.success!==void 0){i=!1;const h=typeof r.success=="function"?await r.success(c):r.success,p=typeof r.description=="function"?await r.description(c):r.description,x=typeof h=="object"&&!U.isValidElement(h)?h:{message:h};this.create({id:n,type:"success",description:p,...x})}}).catch(async c=>{if(s=["reject",c],r.error!==void 0){i=!1;const f=typeof r.error=="function"?await r.error(c):r.error,h=typeof r.description=="function"?await r.description(c):r.description,g=typeof f=="object"&&!U.isValidElement(f)?f:{message:f};this.create({id:n,type:"error",description:h,...g})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),r.finally==null||r.finally.call(r)}),d=()=>new Promise((c,f)=>l.then(()=>s[0]==="reject"?f(s[1]):c(s[1])).catch(f));return typeof n!="string"&&typeof n!="number"?{unwrap:d}:Object.assign(n,{unwrap:d})},this.custom=(t,r)=>{const n=r?.id||sj++;return this.create({jsx:t(n),id:n,...r}),n},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Rn=new A9,I9=(e,t)=>{const r=t?.id||sj++;return Rn.addToast({title:e,...t,id:r}),r},M9=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",R9=I9,D9=()=>Rn.toasts,L9=()=>Rn.getActiveToasts(),ee=Object.assign(R9,{success:Rn.success,info:Rn.info,warning:Rn.warning,error:Rn.error,custom:Rn.custom,message:Rn.message,promise:Rn.promise,dismiss:Rn.dismiss,loading:Rn.loading},{getHistory:D9,getToasts:L9});S9("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function _m(e){return e.label!==void 0}const $9=3,F9="24px",B9="16px",eT=4e3,z9=356,U9=14,q9=45,V9=200;function co(...e){return e.filter(Boolean).join(" ")}function W9(e){const[t,r]=e.split("-"),n=[];return t&&n.push(t),r&&n.push(r),n}const H9=e=>{var t,r,n,a,i,s,l,d,c;const{invert:f,toast:h,unstyled:p,interacting:g,setHeights:x,visibleToasts:b,heights:w,index:j,toasts:N,expanded:C,removeToast:O,defaultRichColors:P,closeButton:E,style:T,cancelButtonStyle:A,actionButtonStyle:I,className:R="",descriptionClassName:L="",duration:V,position:z,gap:G,expandByDefault:H,classNames:W,icons:q,closeButtonAriaLabel:M="Close toast"}=e,[Y,F]=U.useState(null),[D,$]=U.useState(null),[K,J]=U.useState(!1),[oe,re]=U.useState(!1),[Q,ce]=U.useState(!1),[se,fe]=U.useState(!1),[be,Z]=U.useState(!1),[Se,Ne]=U.useState(0),[qe,De]=U.useState(0),He=U.useRef(h.duration||V||eT),ne=U.useRef(null),pe=U.useRef(null),_e=j===0,ye=j+1<=b,Ae=h.type,Ge=h.dismissible!==!1,ut=h.className||"",Ce=h.descriptionClassName||"",tt=U.useMemo(()=>w.findIndex(Je=>Je.toastId===h.id)||0,[w,h.id]),ot=U.useMemo(()=>{var Je;return(Je=h.closeButton)!=null?Je:E},[h.closeButton,E]),Nt=U.useMemo(()=>h.duration||V||eT,[h.duration,V]),er=U.useRef(0),Ie=U.useRef(0),gt=U.useRef(0),_t=U.useRef(null),[Qt,Pr]=z.split("-"),Vn=U.useMemo(()=>w.reduce((Je,Et,Lt)=>Lt>=tt?Je:Je+Et.height,0),[w,tt]),Jr=k9(),qr=h.invert||f,Or=Ae==="loading";Ie.current=U.useMemo(()=>tt*G+Vn,[tt,Vn]),U.useEffect(()=>{He.current=Nt},[Nt]),U.useEffect(()=>{J(!0)},[]),U.useEffect(()=>{const Je=pe.current;if(Je){const Et=Je.getBoundingClientRect().height;return De(Et),x(Lt=>[{toastId:h.id,height:Et,position:h.position},...Lt]),()=>x(Lt=>Lt.filter(sr=>sr.toastId!==h.id))}},[x,h.id]),U.useLayoutEffect(()=>{if(!K)return;const Je=pe.current,Et=Je.style.height;Je.style.height="auto";const Lt=Je.getBoundingClientRect().height;Je.style.height=Et,De(Lt),x(sr=>sr.find(Le=>Le.toastId===h.id)?sr.map(Le=>Le.toastId===h.id?{...Le,height:Lt}:Le):[{toastId:h.id,height:Lt,position:h.position},...sr])},[K,h.title,h.description,x,h.id,h.jsx,h.action,h.cancel]);const Vt=U.useCallback(()=>{re(!0),Ne(Ie.current),x(Je=>Je.filter(Et=>Et.toastId!==h.id)),setTimeout(()=>{O(h)},V9)},[h,O,x,Ie]);U.useEffect(()=>{if(h.promise&&Ae==="loading"||h.duration===1/0||h.type==="loading")return;let Je;return C||g||Jr?(()=>{if(gt.current{He.current!==1/0&&(er.current=new Date().getTime(),Je=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),Vt()},He.current))})(),()=>clearTimeout(Je)},[C,g,h,Ae,Jr,Vt]),U.useEffect(()=>{h.delete&&(Vt(),h.onDismiss==null||h.onDismiss.call(h,h))},[Vt,h.delete]);function gr(){var Je;if(q?.loading){var Et;return U.createElement("div",{className:co(W?.loader,h==null||(Et=h.classNames)==null?void 0:Et.loader,"sonner-loader"),"data-visible":Ae==="loading"},q.loading)}return U.createElement(C9,{className:co(W?.loader,h==null||(Je=h.classNames)==null?void 0:Je.loader),visible:Ae==="loading"})}const Kt=h.icon||q?.[Ae]||j9(Ae);var fr,tr;return U.createElement("li",{tabIndex:0,ref:pe,className:co(R,ut,W?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,W?.default,W?.[Ae],h==null||(r=h.classNames)==null?void 0:r[Ae]),"data-sonner-toast":"","data-rich-colors":(fr=h.richColors)!=null?fr:P,"data-styled":!(h.jsx||h.unstyled||p),"data-mounted":K,"data-promise":!!h.promise,"data-swiped":be,"data-removed":oe,"data-visible":ye,"data-y-position":Qt,"data-x-position":Pr,"data-index":j,"data-front":_e,"data-swiping":Q,"data-dismissible":Ge,"data-type":Ae,"data-invert":qr,"data-swipe-out":se,"data-swipe-direction":D,"data-expanded":!!(C||H&&K),"data-testid":h.testId,style:{"--index":j,"--toasts-before":j,"--z-index":N.length-j,"--offset":`${oe?Se:Ie.current}px`,"--initial-height":H?"auto":`${qe}px`,...T,...h.style},onDragEnd:()=>{ce(!1),F(null),_t.current=null},onPointerDown:Je=>{Je.button!==2&&(Or||!Ge||(ne.current=new Date,Ne(Ie.current),Je.target.setPointerCapture(Je.pointerId),Je.target.tagName!=="BUTTON"&&(ce(!0),_t.current={x:Je.clientX,y:Je.clientY})))},onPointerUp:()=>{var Je,Et,Lt;if(se||!Ge)return;_t.current=null;const sr=Number(((Je=pe.current)==null?void 0:Je.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ve=Number(((Et=pe.current)==null?void 0:Et.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Le=new Date().getTime()-((Lt=ne.current)==null?void 0:Lt.getTime()),rt=Y==="x"?sr:ve,Xt=Math.abs(rt)/Le;if(Math.abs(rt)>=q9||Xt>.11){Ne(Ie.current),h.onDismiss==null||h.onDismiss.call(h,h),$(Y==="x"?sr>0?"right":"left":ve>0?"down":"up"),Vt(),fe(!0);return}else{var xt,hr;(xt=pe.current)==null||xt.style.setProperty("--swipe-amount-x","0px"),(hr=pe.current)==null||hr.style.setProperty("--swipe-amount-y","0px")}Z(!1),ce(!1),F(null)},onPointerMove:Je=>{var Et,Lt,sr;if(!_t.current||!Ge||((Et=window.getSelection())==null?void 0:Et.toString().length)>0)return;const Le=Je.clientY-_t.current.y,rt=Je.clientX-_t.current.x;var Xt;const xt=(Xt=e.swipeDirections)!=null?Xt:W9(z);!Y&&(Math.abs(rt)>1||Math.abs(Le)>1)&&F(Math.abs(rt)>Math.abs(Le)?"x":"y");let hr={x:0,y:0};const Qr=Mr=>1/(1.5+Math.abs(Mr)/20);if(Y==="y"){if(xt.includes("top")||xt.includes("bottom"))if(xt.includes("top")&&Le<0||xt.includes("bottom")&&Le>0)hr.y=Le;else{const Mr=Le*Qr(Le);hr.y=Math.abs(Mr)0)hr.x=rt;else{const Mr=rt*Qr(rt);hr.x=Math.abs(Mr)0||Math.abs(hr.y)>0)&&Z(!0),(Lt=pe.current)==null||Lt.style.setProperty("--swipe-amount-x",`${hr.x}px`),(sr=pe.current)==null||sr.style.setProperty("--swipe-amount-y",`${hr.y}px`)}},ot&&!h.jsx&&Ae!=="loading"?U.createElement("button",{"aria-label":M,"data-disabled":Or,"data-close-button":!0,onClick:Or||!Ge?()=>{}:()=>{Vt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:co(W?.closeButton,h==null||(n=h.classNames)==null?void 0:n.closeButton)},(tr=q?.close)!=null?tr:T9):null,(Ae||h.icon||h.promise)&&h.icon!==null&&(q?.[Ae]!==null||h.icon)?U.createElement("div",{"data-icon":"",className:co(W?.icon,h==null||(a=h.classNames)==null?void 0:a.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||gr():null,h.type!=="loading"?Kt:null):null,U.createElement("div",{"data-content":"",className:co(W?.content,h==null||(i=h.classNames)==null?void 0:i.content)},U.createElement("div",{"data-title":"",className:co(W?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?U.createElement("div",{"data-description":"",className:co(L,Ce,W?.description,h==null||(l=h.classNames)==null?void 0:l.description)},typeof h.description=="function"?h.description():h.description):null),U.isValidElement(h.cancel)?h.cancel:h.cancel&&_m(h.cancel)?U.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||A,onClick:Je=>{_m(h.cancel)&&Ge&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Je),Vt())},className:co(W?.cancelButton,h==null||(d=h.classNames)==null?void 0:d.cancelButton)},h.cancel.label):null,U.isValidElement(h.action)?h.action:h.action&&_m(h.action)?U.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||I,onClick:Je=>{_m(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Je),!Je.defaultPrevented&&Vt())},className:co(W?.actionButton,h==null||(c=h.classNames)==null?void 0:c.actionButton)},h.action.label):null)};function tT(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function G9(e,t){const r={};return[e,t].forEach((n,a)=>{const i=a===1,s=i?"--mobile-offset":"--offset",l=i?B9:F9;function d(c){["top","right","bottom","left"].forEach(f=>{r[`${s}-${f}`]=typeof c=="number"?`${c}px`:c})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(c=>{n[c]===void 0?r[`${s}-${c}`]=l:r[`${s}-${c}`]=typeof n[c]=="number"?`${n[c]}px`:n[c]}):d(l)}),r}const Y9=U.forwardRef(function(t,r){const{id:n,invert:a,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:l,closeButton:d,className:c,offset:f,mobileOffset:h,theme:p="light",richColors:g,duration:x,style:b,visibleToasts:w=$9,toastOptions:j,dir:N=tT(),gap:C=U9,icons:O,containerAriaLabel:P="Notifications"}=t,[E,T]=U.useState([]),A=U.useMemo(()=>n?E.filter(K=>K.toasterId===n):E.filter(K=>!K.toasterId),[E,n]),I=U.useMemo(()=>Array.from(new Set([i].concat(A.filter(K=>K.position).map(K=>K.position)))),[A,i]),[R,L]=U.useState([]),[V,z]=U.useState(!1),[G,H]=U.useState(!1),[W,q]=U.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),M=U.useRef(null),Y=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=U.useRef(null),D=U.useRef(!1),$=U.useCallback(K=>{T(J=>{var oe;return(oe=J.find(re=>re.id===K.id))!=null&&oe.delete||Rn.dismiss(K.id),J.filter(({id:re})=>re!==K.id)})},[]);return U.useEffect(()=>Rn.subscribe(K=>{if(K.dismiss){requestAnimationFrame(()=>{T(J=>J.map(oe=>oe.id===K.id?{...oe,delete:!0}:oe))});return}setTimeout(()=>{j$.flushSync(()=>{T(J=>{const oe=J.findIndex(re=>re.id===K.id);return oe!==-1?[...J.slice(0,oe),{...J[oe],...K},...J.slice(oe+1)]:[K,...J]})})})}),[E]),U.useEffect(()=>{if(p!=="system"){q(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?q("dark"):q("light")),typeof window>"u")return;const K=window.matchMedia("(prefers-color-scheme: dark)");try{K.addEventListener("change",({matches:J})=>{q(J?"dark":"light")})}catch{K.addListener(({matches:oe})=>{try{q(oe?"dark":"light")}catch(re){console.error(re)}})}},[p]),U.useEffect(()=>{E.length<=1&&z(!1)},[E]),U.useEffect(()=>{const K=J=>{var oe;if(s.every(ce=>J[ce]||J.code===ce)){var Q;z(!0),(Q=M.current)==null||Q.focus()}J.code==="Escape"&&(document.activeElement===M.current||(oe=M.current)!=null&&oe.contains(document.activeElement))&&z(!1)};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[s]),U.useEffect(()=>{if(M.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,D.current=!1)}},[M.current]),U.createElement("section",{ref:r,"aria-label":`${P} ${Y}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},I.map((K,J)=>{var oe;const[re,Q]=K.split("-");return A.length?U.createElement("ol",{key:K,dir:N==="auto"?tT():N,tabIndex:-1,ref:M,className:c,"data-sonner-toaster":!0,"data-sonner-theme":W,"data-y-position":re,"data-x-position":Q,style:{"--front-toast-height":`${((oe=R[0])==null?void 0:oe.height)||0}px`,"--width":`${z9}px`,"--gap":`${C}px`,...b,...G9(f,h)},onBlur:ce=>{D.current&&!ce.currentTarget.contains(ce.relatedTarget)&&(D.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||D.current||(D.current=!0,F.current=ce.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{G||z(!1)},onDragEnd:()=>z(!1),onPointerDown:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||H(!0)},onPointerUp:()=>H(!1)},A.filter(ce=>!ce.position&&J===0||ce.position===K).map((ce,se)=>{var fe,be;return U.createElement(H9,{key:ce.id,icons:O,index:se,toast:ce,defaultRichColors:g,duration:(fe=j?.duration)!=null?fe:x,className:j?.className,descriptionClassName:j?.descriptionClassName,invert:a,visibleToasts:w,closeButton:(be=j?.closeButton)!=null?be:d,interacting:G,position:K,style:j?.style,unstyled:j?.unstyled,classNames:j?.classNames,cancelButtonStyle:j?.cancelButtonStyle,actionButtonStyle:j?.actionButtonStyle,closeButtonAriaLabel:j?.closeButtonAriaLabel,removeToast:$,toasts:A.filter(Z=>Z.position==ce.position),heights:R.filter(Z=>Z.position==ce.position),setHeights:L,expandByDefault:l,gap:C,expanded:V,swipeDirections:t.swipeDirections})})):null}))});/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const K9=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),X9=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),rT=e=>{const t=X9(e);return t.charAt(0).toUpperCase()+t.slice(1)},N$=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim();/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var J9={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Q9=v.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:i,iconNode:s,...l},d)=>v.createElement("svg",{ref:d,...J9,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:N$("lucide",a),...l},[...s.map(([c,f])=>v.createElement(c,f)),...Array.isArray(i)?i:[i]]));/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const at=(e,t)=>{const r=v.forwardRef(({className:n,...a},i)=>v.createElement(Q9,{ref:i,iconNode:t,className:N$(`lucide-${K9(rT(e))}`,`lucide-${e}`,n),...a}));return r.displayName=rT(e),r};/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Z9=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]],eq=at("arrow-down-a-z",Z9);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tq=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],rq=at("arrow-down-right",tq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const nq=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],C$=at("arrow-left",nq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aq=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],oq=at("arrow-up-down",aq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iq=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],_$=at("arrow-up-right",iq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sq=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],lq=at("calendar",sq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cq=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],uq=at("chart-column",cq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],E$=at("check",dq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bs=at("chevron-down",fq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hq=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],aC=at("chevron-left",hq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mq=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ui=at("chevron-right",mq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pq=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],gq=at("chevron-up",pq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yq=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],P$=at("chevrons-up-down",yq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Wd=at("circle-help",vq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],bq=at("circle-user",xq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wq=[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]],Sq=at("coffee",wq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jq=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],oC=at("download",jq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Nq=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ni=at("ellipsis",Nq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cq=[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]],iC=at("file-box",Cq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _q=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],Eq=at("file-spreadsheet",_q);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pq=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],zs=at("file-text",Pq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Oq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Tq=at("grid-3x3",Oq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kq=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],sC=at("image",kq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Aq=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],lC=at("layers",Aq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Iq=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Vp=at("layout-dashboard",Iq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mq=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],Rq=at("list",Mq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dq=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],lj=at("log-out",Dq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lq=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],$q=at("mail",Lq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fq=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],su=at("map-pin",Fq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bq=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],zq=at("menu",Bq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uq=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Sc=at("package",Uq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qq=[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]],O$=at("palette",qq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vq=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Rp=at("pencil",Vq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wq=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],Hq=at("phone",Wq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gq=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Yq=at("pin",Gq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kq=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Un=at("plus",Kq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xq=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],T$=at("printer",Xq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jq=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Qq=at("refresh-cw",Jq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zq=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],e7=at("save",Zq);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const t7=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Rf=at("search",t7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const r7=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],jc=at("settings",r7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const n7=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],a7=at("shield",n7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const o7=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],oa=at("square-pen",o7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const i7=[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]],s7=at("store",i7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const l7=[["path",{d:"m18 2 4 4",key:"22kx64"}],["path",{d:"m17 7 3-3",key:"1w1zoj"}],["path",{d:"M19 9 8.7 19.3c-1 1-2.5 1-3.4 0l-.6-.6c-1-1-1-2.5 0-3.4L15 5",key:"1exhtz"}],["path",{d:"m9 11 4 4",key:"rovt3i"}],["path",{d:"m5 19-3 3",key:"59f2uf"}],["path",{d:"m14 4 6 6",key:"yqp9t2"}]],Ex=at("syringe",l7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c7=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],u7=at("tablet",c7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const d7=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Nc=at("tag",d7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const f7=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],h7=at("timer",f7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m7=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],zt=at("trash-2",m7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const p7=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],g7=at("trending-up",p7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const y7=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],Df=at("type",y7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const v7=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],k$=at("upload",v7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const x7=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],b7=at("user",x7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const w7=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],hy=at("users",w7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S7=[["path",{d:"M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2",key:"cjf0a3"}],["path",{d:"M7 2v20",key:"1473qp"}],["path",{d:"M21 15V2a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7",key:"j28e5"}]],j7=at("utensils",S7);/** + * @license lucide-react v0.487.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const N7=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qo=at("x",N7);function A$(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t{const r=new Array(e.length+t.length);for(let n=0;n({classGroupId:e,validator:t}),I$=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Wp="-",nT=[],E7="arbitrary..",P7=e=>{const t=T7(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:s=>{if(s.startsWith("[")&&s.endsWith("]"))return O7(s);const l=s.split(Wp),d=l[0]===""&&l.length>1?1:0;return M$(l,d,t)},getConflictingClassGroupIds:(s,l)=>{if(l){const d=n[s],c=r[s];return d?c?C7(c,d):d:c||nT}return r[s]||nT}}},M$=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const a=e[t],i=r.nextPart.get(a);if(i){const c=M$(e,t+1,i);if(c)return c}const s=r.validators;if(s===null)return;const l=t===0?e.join(Wp):e.slice(t).join(Wp),d=s.length;for(let c=0;ce.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?E7+n:void 0})(),T7=e=>{const{theme:t,classGroups:r}=e;return k7(r,t)},k7=(e,t)=>{const r=I$();for(const n in e){const a=e[n];cC(a,r,n,t)}return r},cC=(e,t,r,n)=>{const a=e.length;for(let i=0;i{if(typeof e=="string"){I7(e,t,r);return}if(typeof e=="function"){M7(e,t,r,n);return}R7(e,t,r,n)},I7=(e,t,r)=>{const n=e===""?t:R$(t,e);n.classGroupId=r},M7=(e,t,r,n)=>{if(D7(e)){cC(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(_7(r,e))},R7=(e,t,r,n)=>{const a=Object.entries(e),i=a.length;for(let s=0;s{let r=e;const n=t.split(Wp),a=n.length;for(let i=0;i"isThemeGetter"in e&&e.isThemeGetter===!0,L7=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const a=(i,s)=>{r[i]=s,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(i){let s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return a(i,s),s},set(i,s){i in r?r[i]=s:a(i,s)}}},cj="!",aT=":",$7=[],oT=(e,t,r,n,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:a}),F7=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=a=>{const i=[];let s=0,l=0,d=0,c;const f=a.length;for(let b=0;bd?c-d:void 0;return oT(i,g,p,x)};if(t){const a=t+aT,i=n;n=s=>s.startsWith(a)?i(s.slice(a.length)):oT($7,!1,s,void 0,!0)}if(r){const a=n;n=i=>r({className:i,parseClassName:a})}return n},B7=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let a=[];for(let i=0;i0&&(a.sort(),n.push(...a),a=[]),n.push(s)):a.push(s)}return a.length>0&&(a.sort(),n.push(...a)),n}},z7=e=>({cache:L7(e.cacheSize),parseClassName:F7(e),sortModifiers:B7(e),...P7(e)}),U7=/\s+/,q7=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a,sortModifiers:i}=t,s=[],l=e.trim().split(U7);let d="";for(let c=l.length-1;c>=0;c-=1){const f=l[c],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:b}=r(f);if(h){d=f+(d.length>0?" "+d:d);continue}let w=!!b,j=n(w?x.substring(0,b):x);if(!j){if(!w){d=f+(d.length>0?" "+d:d);continue}if(j=n(x),!j){d=f+(d.length>0?" "+d:d);continue}w=!1}const N=p.length===0?"":p.length===1?p[0]:i(p).join(":"),C=g?N+cj:N,O=C+j;if(s.indexOf(O)>-1)continue;s.push(O);const P=a(j,w);for(let E=0;E0?" "+d:d)}return d},V7=(...e)=>{let t=0,r,n,a="";for(;t{if(typeof e=="string")return e;let t,r="";for(let n=0;n{let r,n,a,i;const s=d=>{const c=t.reduce((f,h)=>h(f),e());return r=z7(c),n=r.cache.get,a=r.cache.set,i=l,l(d)},l=d=>{const c=n(d);if(c)return c;const f=q7(d,r);return a(d,f),f};return i=s,(...d)=>i(V7(...d))},H7=[],Lr=e=>{const t=r=>r[e]||H7;return t.isThemeGetter=!0,t},L$=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$$=/^\((?:(\w[\w-]*):)?(.+)\)$/i,G7=/^\d+\/\d+$/,Y7=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,K7=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,X7=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,J7=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Q7=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ql=e=>G7.test(e),wt=e=>!!e&&!Number.isNaN(Number(e)),Ii=e=>!!e&&Number.isInteger(Number(e)),Px=e=>e.endsWith("%")&&wt(e.slice(0,-1)),Uo=e=>Y7.test(e),Z7=()=>!0,eV=e=>K7.test(e)&&!X7.test(e),F$=()=>!1,tV=e=>J7.test(e),rV=e=>Q7.test(e),nV=e=>!Ke(e)&&!Xe(e),aV=e=>lu(e,U$,F$),Ke=e=>L$.test(e),xs=e=>lu(e,q$,eV),Ox=e=>lu(e,cV,wt),iT=e=>lu(e,B$,F$),oV=e=>lu(e,z$,rV),Em=e=>lu(e,V$,tV),Xe=e=>$$.test(e),hd=e=>cu(e,q$),iV=e=>cu(e,uV),sT=e=>cu(e,B$),sV=e=>cu(e,U$),lV=e=>cu(e,z$),Pm=e=>cu(e,V$,!0),lu=(e,t,r)=>{const n=L$.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},cu=(e,t,r=!1)=>{const n=$$.exec(e);return n?n[1]?t(n[1]):r:!1},B$=e=>e==="position"||e==="percentage",z$=e=>e==="image"||e==="url",U$=e=>e==="length"||e==="size"||e==="bg-size",q$=e=>e==="length",cV=e=>e==="number",uV=e=>e==="family-name",V$=e=>e==="shadow",dV=()=>{const e=Lr("color"),t=Lr("font"),r=Lr("text"),n=Lr("font-weight"),a=Lr("tracking"),i=Lr("leading"),s=Lr("breakpoint"),l=Lr("container"),d=Lr("spacing"),c=Lr("radius"),f=Lr("shadow"),h=Lr("inset-shadow"),p=Lr("text-shadow"),g=Lr("drop-shadow"),x=Lr("blur"),b=Lr("perspective"),w=Lr("aspect"),j=Lr("ease"),N=Lr("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],P=()=>[...O(),Xe,Ke],E=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],A=()=>[Xe,Ke,d],I=()=>[ql,"full","auto",...A()],R=()=>[Ii,"none","subgrid",Xe,Ke],L=()=>["auto",{span:["full",Ii,Xe,Ke]},Ii,Xe,Ke],V=()=>[Ii,"auto",Xe,Ke],z=()=>["auto","min","max","fr",Xe,Ke],G=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],W=()=>["auto",...A()],q=()=>[ql,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],M=()=>[e,Xe,Ke],Y=()=>[...O(),sT,iT,{position:[Xe,Ke]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],D=()=>["auto","cover","contain",sV,aV,{size:[Xe,Ke]}],$=()=>[Px,hd,xs],K=()=>["","none","full",c,Xe,Ke],J=()=>["",wt,hd,xs],oe=()=>["solid","dashed","dotted","double"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[wt,Px,sT,iT],ce=()=>["","none",x,Xe,Ke],se=()=>["none",wt,Xe,Ke],fe=()=>["none",wt,Xe,Ke],be=()=>[wt,Xe,Ke],Z=()=>[ql,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Uo],breakpoint:[Uo],color:[Z7],container:[Uo],"drop-shadow":[Uo],ease:["in","out","in-out"],font:[nV],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Uo],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Uo],shadow:[Uo],spacing:["px",wt],text:[Uo],"text-shadow":[Uo],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ql,Ke,Xe,w]}],container:["container"],columns:[{columns:[wt,Ke,Xe,l]}],"break-after":[{"break-after":C()}],"break-before":[{"break-before":C()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:P()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{start:I()}],end:[{end:I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[Ii,"auto",Xe,Ke]}],basis:[{basis:[ql,"full","auto",l,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[wt,ql,"auto","initial","none",Ke]}],grow:[{grow:["",wt,Xe,Ke]}],shrink:[{shrink:["",wt,Xe,Ke]}],order:[{order:[Ii,"first","last","none",Xe,Ke]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":V()}],"col-end":[{"col-end":V()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":V()}],"row-end":[{"row-end":V()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...G(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...G()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":G()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:W()}],mx:[{mx:W()}],my:[{my:W()}],ms:[{ms:W()}],me:[{me:W()}],mt:[{mt:W()}],mr:[{mr:W()}],mb:[{mb:W()}],ml:[{ml:W()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],w:[{w:[l,"screen",...q()]}],"min-w":[{"min-w":[l,"screen","none",...q()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[s]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh",...q()]}],"font-size":[{text:["base",r,hd,xs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,Xe,Ox]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Px,Ke]}],"font-family":[{font:[iV,Ke,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Xe,Ke]}],"line-clamp":[{"line-clamp":[wt,"none",Xe,Ox]}],leading:[{leading:[i,...A()]}],"list-image":[{"list-image":["none",Xe,Ke]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Xe,Ke]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[wt,"from-font","auto",Xe,xs]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[wt,"auto",Xe,Ke]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Xe,Ke]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Xe,Ke]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:D()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ii,Xe,Ke],radial:["",Xe,Ke],conic:[Ii,Xe,Ke]},lV,oV]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:$()}],"gradient-via-pos":[{via:$()}],"gradient-to-pos":[{to:$()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:K()}],"rounded-s":[{"rounded-s":K()}],"rounded-e":[{"rounded-e":K()}],"rounded-t":[{"rounded-t":K()}],"rounded-r":[{"rounded-r":K()}],"rounded-b":[{"rounded-b":K()}],"rounded-l":[{"rounded-l":K()}],"rounded-ss":[{"rounded-ss":K()}],"rounded-se":[{"rounded-se":K()}],"rounded-ee":[{"rounded-ee":K()}],"rounded-es":[{"rounded-es":K()}],"rounded-tl":[{"rounded-tl":K()}],"rounded-tr":[{"rounded-tr":K()}],"rounded-br":[{"rounded-br":K()}],"rounded-bl":[{"rounded-bl":K()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[wt,Xe,Ke]}],"outline-w":[{outline:["",wt,hd,xs]}],"outline-color":[{outline:M()}],shadow:[{shadow:["","none",f,Pm,Em]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":["none",h,Pm,Em]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[wt,xs]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":["none",p,Pm,Em]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[wt,Xe,Ke]}],"mix-blend":[{"mix-blend":[...re(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":re()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[wt]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[Xe,Ke]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":O()}],"mask-image-conic-pos":[{"mask-conic":[wt]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:D()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Xe,Ke]}],filter:[{filter:["","none",Xe,Ke]}],blur:[{blur:ce()}],brightness:[{brightness:[wt,Xe,Ke]}],contrast:[{contrast:[wt,Xe,Ke]}],"drop-shadow":[{"drop-shadow":["","none",g,Pm,Em]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:["",wt,Xe,Ke]}],"hue-rotate":[{"hue-rotate":[wt,Xe,Ke]}],invert:[{invert:["",wt,Xe,Ke]}],saturate:[{saturate:[wt,Xe,Ke]}],sepia:[{sepia:["",wt,Xe,Ke]}],"backdrop-filter":[{"backdrop-filter":["","none",Xe,Ke]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[wt,Xe,Ke]}],"backdrop-contrast":[{"backdrop-contrast":[wt,Xe,Ke]}],"backdrop-grayscale":[{"backdrop-grayscale":["",wt,Xe,Ke]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[wt,Xe,Ke]}],"backdrop-invert":[{"backdrop-invert":["",wt,Xe,Ke]}],"backdrop-opacity":[{"backdrop-opacity":[wt,Xe,Ke]}],"backdrop-saturate":[{"backdrop-saturate":[wt,Xe,Ke]}],"backdrop-sepia":[{"backdrop-sepia":["",wt,Xe,Ke]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Xe,Ke]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[wt,"initial",Xe,Ke]}],ease:[{ease:["linear","initial",j,Xe,Ke]}],delay:[{delay:[wt,Xe,Ke]}],animate:[{animate:["none",N,Xe,Ke]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,Xe,Ke]}],"perspective-origin":[{"perspective-origin":P()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:fe()}],"scale-x":[{"scale-x":fe()}],"scale-y":[{"scale-y":fe()}],"scale-z":[{"scale-z":fe()}],"scale-3d":["scale-3d"],skew:[{skew:be()}],"skew-x":[{"skew-x":be()}],"skew-y":[{"skew-y":be()}],transform:[{transform:[Xe,Ke,"","none","gpu","cpu"]}],"transform-origin":[{origin:P()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Z()}],"translate-x":[{"translate-x":Z()}],"translate-y":[{"translate-y":Z()}],"translate-z":[{"translate-z":Z()}],"translate-none":["translate-none"],accent:[{accent:M()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Xe,Ke]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Xe,Ke]}],fill:[{fill:["none",...M()]}],"stroke-w":[{stroke:[wt,hd,xs,Ox]}],stroke:[{stroke:["none",...M()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},fV=W7(dV);function ke(...e){return fV(vt(e))}function lT(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Oa(...e){return t=>{let r=!1;const n=e.map(a=>{const i=lT(a,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let a=0;a{const{children:i,...s}=n,l=v.Children.toArray(i),d=l.find(gV);if(d){const c=d.props.children,f=l.map(h=>h===d?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:h);return o.jsx(t,{...s,ref:a,children:v.isValidElement(c)?v.cloneElement(c,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function mV(e){const t=v.forwardRef((r,n)=>{const{children:a,...i}=r;if(v.isValidElement(a)){const s=vV(a),l=yV(i,a.props);return a.type!==v.Fragment&&(l.ref=n?Oa(n,s):s),v.cloneElement(a,l)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pV=Symbol("radix.slottable");function gV(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pV}function yV(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function vV(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var xV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ct=xV.reduce((e,t)=>{const r=hV(`Primitive.${t}`),n=v.forwardRef((a,i)=>{const{asChild:s,...l}=a,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function bV(e,t){e&&Mf.flushSync(()=>e.dispatchEvent(t))}var Ir=globalThis?.document?v.useLayoutEffect:()=>{};function wV(e,t){return v.useReducer((r,n)=>t[r][n]??r,e)}var to=e=>{const{present:t,children:r}=e,n=SV(t),a=typeof r=="function"?r({present:n.isPresent}):v.Children.only(r),i=Tt(n.ref,jV(a));return typeof r=="function"||n.isPresent?v.cloneElement(a,{ref:i}):null};to.displayName="Presence";function SV(e){const[t,r]=v.useState(),n=v.useRef(null),a=v.useRef(e),i=v.useRef("none"),s=e?"mounted":"unmounted",[l,d]=wV(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const c=Om(n.current);i.current=l==="mounted"?c:"none"},[l]),Ir(()=>{const c=n.current,f=a.current;if(f!==e){const p=i.current,g=Om(c);e?d("MOUNT"):g==="none"||c?.display==="none"?d("UNMOUNT"):d(f&&p!==g?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,d]),Ir(()=>{if(t){let c;const f=t.ownerDocument.defaultView??window,h=g=>{const b=Om(n.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(d("ANIMATION_END"),!a.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",c=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},p=g=>{g.target===t&&(i.current=Om(n.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{f.clearTimeout(c),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:v.useCallback(c=>{n.current=c?getComputedStyle(c):null,r(c)},[])}}function Om(e){return e?.animationName||"none"}function jV(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function NV(e,t){const r=v.createContext(t),n=i=>{const{children:s,...l}=i,d=v.useMemo(()=>l,Object.values(l));return o.jsx(r.Provider,{value:d,children:s})};n.displayName=e+"Provider";function a(i){const s=v.useContext(r);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[n,a]}function Eo(e,t=[]){let r=[];function n(i,s){const l=v.createContext(s),d=r.length;r=[...r,s];const c=h=>{const{scope:p,children:g,...x}=h,b=p?.[e]?.[d]||l,w=v.useMemo(()=>x,Object.values(x));return o.jsx(b.Provider,{value:w,children:g})};c.displayName=i+"Provider";function f(h,p){const g=p?.[e]?.[d]||l,x=v.useContext(g);if(x)return x;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[c,f]}const a=()=>{const i=r.map(s=>v.createContext(s));return function(l){const d=l?.[e]||i;return v.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return a.scopeName=e,[n,CV(a,...t)]}function CV(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const s=n.reduce((l,{useScope:d,scopeName:c})=>{const h=d(i)[`__scope${c}`];return{...l,...h}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}function dn(e){const t=v.useRef(e);return v.useEffect(()=>{t.current=e}),v.useMemo(()=>(...r)=>t.current?.(...r),[])}var _V=v.createContext(void 0);function my(e){const t=v.useContext(_V);return e||t||"ltr"}function uj(e,[t,r]){return Math.min(r,Math.max(t,e))}function pt(e,t,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e?.(a),r===!1||!a.defaultPrevented)return t?.(a)}}function EV(e,t){return v.useReducer((r,n)=>t[r][n]??r,e)}var uC="ScrollArea",[W$]=Eo(uC),[PV,Ma]=W$(uC),H$=v.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:i=600,...s}=e,[l,d]=v.useState(null),[c,f]=v.useState(null),[h,p]=v.useState(null),[g,x]=v.useState(null),[b,w]=v.useState(null),[j,N]=v.useState(0),[C,O]=v.useState(0),[P,E]=v.useState(!1),[T,A]=v.useState(!1),I=Tt(t,L=>d(L)),R=my(a);return o.jsx(PV,{scope:r,type:n,dir:R,scrollHideDelay:i,scrollArea:l,viewport:c,onViewportChange:f,content:h,onContentChange:p,scrollbarX:g,onScrollbarXChange:x,scrollbarXEnabled:P,onScrollbarXEnabledChange:E,scrollbarY:b,onScrollbarYChange:w,scrollbarYEnabled:T,onScrollbarYEnabledChange:A,onCornerWidthChange:N,onCornerHeightChange:O,children:o.jsx(ct.div,{dir:R,...s,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});H$.displayName=uC;var G$="ScrollAreaViewport",Y$=v.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:n,nonce:a,...i}=e,s=Ma(G$,r),l=v.useRef(null),d=Tt(t,l,s.onViewportChange);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),o.jsx(ct.div,{"data-radix-scroll-area-viewport":"",...i,ref:d,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:o.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Y$.displayName=G$;var Po="ScrollAreaScrollbar",K$=v.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Ma(Po,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=a,l=e.orientation==="horizontal";return v.useEffect(()=>(l?i(!0):s(!0),()=>{l?i(!1):s(!1)}),[l,i,s]),a.type==="hover"?o.jsx(OV,{...n,ref:t,forceMount:r}):a.type==="scroll"?o.jsx(TV,{...n,ref:t,forceMount:r}):a.type==="auto"?o.jsx(X$,{...n,ref:t,forceMount:r}):a.type==="always"?o.jsx(dC,{...n,ref:t}):null});K$.displayName=Po;var OV=v.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Ma(Po,e.__scopeScrollArea),[i,s]=v.useState(!1);return v.useEffect(()=>{const l=a.scrollArea;let d=0;if(l){const c=()=>{window.clearTimeout(d),s(!0)},f=()=>{d=window.setTimeout(()=>s(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",c),l.addEventListener("pointerleave",f),()=>{window.clearTimeout(d),l.removeEventListener("pointerenter",c),l.removeEventListener("pointerleave",f)}}},[a.scrollArea,a.scrollHideDelay]),o.jsx(to,{present:r||i,children:o.jsx(X$,{"data-state":i?"visible":"hidden",...n,ref:t})})}),TV=v.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=Ma(Po,e.__scopeScrollArea),i=e.orientation==="horizontal",s=gy(()=>d("SCROLL_END"),100),[l,d]=EV("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return v.useEffect(()=>{if(l==="idle"){const c=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(c)}},[l,a.scrollHideDelay,d]),v.useEffect(()=>{const c=a.viewport,f=i?"scrollLeft":"scrollTop";if(c){let h=c[f];const p=()=>{const g=c[f];h!==g&&(d("SCROLL"),s()),h=g};return c.addEventListener("scroll",p),()=>c.removeEventListener("scroll",p)}},[a.viewport,i,d,s]),o.jsx(to,{present:r||l!=="hidden",children:o.jsx(dC,{"data-state":l==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:pt(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:pt(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),X$=v.forwardRef((e,t)=>{const r=Ma(Po,e.__scopeScrollArea),{forceMount:n,...a}=e,[i,s]=v.useState(!1),l=e.orientation==="horizontal",d=gy(()=>{if(r.viewport){const c=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=e,a=Ma(Po,e.__scopeScrollArea),i=v.useRef(null),s=v.useRef(0),[l,d]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=t4(l.viewport,l.content),f={...n,sizes:l,onSizesChange:d,hasThumb:c>0&&c<1,onThumbChange:p=>i.current=p,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:p=>s.current=p};function h(p,g){return DV(p,s.current,l,g)}return r==="horizontal"?o.jsx(kV,{...f,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const p=a.viewport.scrollLeft,g=cT(p,l,a.dir);i.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollLeft=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollLeft=h(p,a.dir))}}):r==="vertical"?o.jsx(AV,{...f,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const p=a.viewport.scrollTop,g=cT(p,l);i.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:p=>{a.viewport&&(a.viewport.scrollTop=p)},onDragScroll:p=>{a.viewport&&(a.viewport.scrollTop=h(p))}}):null}),kV=v.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...a}=e,i=Ma(Po,e.__scopeScrollArea),[s,l]=v.useState(),d=v.useRef(null),c=Tt(t,d,i.onScrollbarXChange);return v.useEffect(()=>{d.current&&l(getComputedStyle(d.current))},[d]),o.jsx(Q$,{"data-orientation":"horizontal",...a,ref:c,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":py(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,h)=>{if(i.viewport){const p=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(p),n4(p,h)&&f.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Gp(s.paddingLeft),paddingEnd:Gp(s.paddingRight)}})}})}),AV=v.forwardRef((e,t)=>{const{sizes:r,onSizesChange:n,...a}=e,i=Ma(Po,e.__scopeScrollArea),[s,l]=v.useState(),d=v.useRef(null),c=Tt(t,d,i.onScrollbarYChange);return v.useEffect(()=>{d.current&&l(getComputedStyle(d.current))},[d]),o.jsx(Q$,{"data-orientation":"vertical",...a,ref:c,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":py(r)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,h)=>{if(i.viewport){const p=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(p),n4(p,h)&&f.preventDefault()}},onResize:()=>{d.current&&i.viewport&&s&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Gp(s.paddingTop),paddingEnd:Gp(s.paddingBottom)}})}})}),[IV,J$]=W$(Po),Q$=v.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:a,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:l,onThumbPositionChange:d,onDragScroll:c,onWheelScroll:f,onResize:h,...p}=e,g=Ma(Po,r),[x,b]=v.useState(null),w=Tt(t,I=>b(I)),j=v.useRef(null),N=v.useRef(""),C=g.viewport,O=n.content-n.viewport,P=dn(f),E=dn(d),T=gy(h,10);function A(I){if(j.current){const R=I.clientX-j.current.left,L=I.clientY-j.current.top;c({x:R,y:L})}}return v.useEffect(()=>{const I=R=>{const L=R.target;x?.contains(L)&&P(R,O)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[C,x,O,P]),v.useEffect(E,[n,E]),Cc(x,T),Cc(g.content,T),o.jsx(IV,{scope:r,scrollbar:x,hasThumb:a,onThumbChange:dn(i),onThumbPointerUp:dn(s),onThumbPositionChange:E,onThumbPointerDown:dn(l),children:o.jsx(ct.div,{...p,ref:w,style:{position:"absolute",...p.style},onPointerDown:pt(e.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),j.current=x.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),A(I))}),onPointerMove:pt(e.onPointerMove,A),onPointerUp:pt(e.onPointerUp,I=>{const R=I.target;R.hasPointerCapture(I.pointerId)&&R.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=N.current,g.viewport&&(g.viewport.style.scrollBehavior=""),j.current=null})})})}),Hp="ScrollAreaThumb",Z$=v.forwardRef((e,t)=>{const{forceMount:r,...n}=e,a=J$(Hp,e.__scopeScrollArea);return o.jsx(to,{present:r||a.hasThumb,children:o.jsx(MV,{ref:t,...n})})}),MV=v.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:n,...a}=e,i=Ma(Hp,r),s=J$(Hp,r),{onThumbPositionChange:l}=s,d=Tt(t,h=>s.onThumbChange(h)),c=v.useRef(void 0),f=gy(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const h=i.viewport;if(h){const p=()=>{if(f(),!c.current){const g=LV(h,l);c.current=g,l()}};return l(),h.addEventListener("scroll",p),()=>h.removeEventListener("scroll",p)}},[i.viewport,f,l]),o.jsx(ct.div,{"data-state":s.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:pt(e.onPointerDownCapture,h=>{const g=h.target.getBoundingClientRect(),x=h.clientX-g.left,b=h.clientY-g.top;s.onThumbPointerDown({x,y:b})}),onPointerUp:pt(e.onPointerUp,s.onThumbPointerUp)})});Z$.displayName=Hp;var fC="ScrollAreaCorner",e4=v.forwardRef((e,t)=>{const r=Ma(fC,e.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?o.jsx(RV,{...e,ref:t}):null});e4.displayName=fC;var RV=v.forwardRef((e,t)=>{const{__scopeScrollArea:r,...n}=e,a=Ma(fC,r),[i,s]=v.useState(0),[l,d]=v.useState(0),c=!!(i&&l);return Cc(a.scrollbarX,()=>{const f=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(f),d(f)}),Cc(a.scrollbarY,()=>{const f=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(f),s(f)}),c?o.jsx(ct.div,{...n,ref:t,style:{width:i,height:l,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Gp(e){return e?parseInt(e,10):0}function t4(e,t){const r=e/t;return isNaN(r)?0:r}function py(e){const t=t4(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-r)*t;return Math.max(n,18)}function DV(e,t,r,n="ltr"){const a=py(r),i=a/2,s=t||i,l=a-s,d=r.scrollbar.paddingStart+s,c=r.scrollbar.size-r.scrollbar.paddingEnd-l,f=r.content-r.viewport,h=n==="ltr"?[0,f]:[f*-1,0];return r4([d,c],h)(e)}function cT(e,t,r="ltr"){const n=py(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-a,s=t.content-t.viewport,l=i-n,d=r==="ltr"?[0,s]:[s*-1,0],c=uj(e,d);return r4([0,s],[0,l])(c)}function r4(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(r-e[0])}}function n4(e,t){return e>0&&e{})=>{let r={left:e.scrollLeft,top:e.scrollTop},n=0;return(function a(){const i={left:e.scrollLeft,top:e.scrollTop},s=r.left!==i.left,l=r.top!==i.top;(s||l)&&t(),r=i,n=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(n)};function gy(e,t){const r=dn(e),n=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(n.current),[]),v.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,t)},[r,t])}function Cc(e,t){const r=dn(t);Ir(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,r])}var $V=H$,FV=Y$,BV=e4;function hC({className:e,children:t,...r}){return o.jsxs($V,{"data-slot":"scroll-area",className:ke("relative",e),...r,children:[o.jsx(FV,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),o.jsx(zV,{}),o.jsx(BV,{})]})}function zV({className:e,orientation:t="vertical",...r}){return o.jsx(K$,{"data-slot":"scroll-area-scrollbar",orientation:t,className:ke("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:o.jsx(Z$,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const UV="/assets/773f0c39e1986271e9144596caac519f934a6ae6-Cou8J2R8.png",dj={Dashboard:Vp,Labeling:Nc,Labels:Nc,"Label Categories":lC,"Label Types":Df,"Label Templates":iC,"Multiple Options":jc,"Location Manager":su,"Account Management":hy,"Menu Management":Sc,"System Menu":jc,Reports:zs,Support:Wd,"Log Out":lj};function fj(e){return e.trim()||"N/A"}function qV(e,t){const r=String(e?.menuIcon??e?.MenuIcon??"").trim();return r&&r in dj?r:t in dj?t:null}function hj({node:e,level:t,currentKey:r,onSelect:n}){const[a,i]=U.useState(!0),s=e.children??[],l=(e.menuType??0)===0||s.length>0,d=fj(String(e.menuName??e.routerName??e.routeUrl??e.id??"")),c=r===d,f=qV(e,d),h=f?dj[f]:null;return l?o.jsxs("div",{className:"space-y-1",children:[o.jsxs("button",{onClick:()=>i(p=>!p),className:ke("w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium rounded-lg transition-colors","hover:bg-blue-800/50 text-blue-100",t>0&&"ml-1"),style:{paddingLeft:16+t*12},children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t===0&&h?o.jsx(h,{className:"w-4 h-4 shrink-0"}):o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-200 shrink-0"}),o.jsx("span",{className:"truncate",children:d})]}),a?o.jsx(Bs,{className:"w-4 h-4"}):o.jsx(Ui,{className:"w-4 h-4"})]}),a&&s.length>0&&o.jsx("div",{className:"space-y-1",children:s.map(p=>o.jsx(hj,{node:p,level:t+1,currentKey:r,onSelect:n},String(p.id??Math.random())))})]}):o.jsxs("button",{onClick:()=>n(d),className:ke("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors",c?"bg-blue-700 text-white shadow-md shadow-blue-900/20":"text-blue-100 hover:bg-blue-800 hover:text-white"),style:{paddingLeft:16+t*12},children:[t===0&&h?o.jsx(h,{className:"w-4 h-4 shrink-0"}):o.jsx("div",{className:"w-1 h-1 rounded-full bg-current"}),o.jsx("span",{className:"truncate",children:d})]})}function VV({currentView:e,setCurrentView:t,menus:r,onLogout:n}){const[a,i]=v.useState(!0),s=[{name:"Dashboard",icon:Vp,type:"item"},{type:"header",name:"MODULES"},{name:"Labeling",icon:Nc,type:"sub",isOpen:a,toggle:()=>i(!a),children:[{name:"Labels",icon:Nc},{name:"Label Categories",icon:lC},{name:"Label Types",icon:Df},{name:"Label Templates",icon:iC},{name:"Multiple Options",icon:jc}]},{type:"header",name:"MANAGEMENT"},{name:"Account Management",icon:hy,type:"item"},{name:"Menu Management",icon:Sc,type:"item"},{name:"System Menu",icon:jc,type:"item"},{name:"Reports",icon:zs,type:"item"},{name:"Support",icon:Wd,type:"item"},{name:"Log Out",icon:lj,type:"item"}],l=(r?.length??0)>0,d=()=>n?n():t("Log Out"),c=v.useMemo(()=>r??[],[r]),{moduleMenus:f,accountMenus:h}=v.useMemo(()=>{const p=new Set(["Location Manager","Account Management","Menu Management","System Menu","Reports","Support"]),g=c,x=[],b=[];for(const w of g){const j=fj(String(w.menuName??w.routerName??w.routeUrl??w.id??""));if(j==="Management"){const N=w.children??[];for(const C of N){const O=fj(String(C.menuName??C.routerName??C.routeUrl??C.id??""));p.has(O)?b.push(C):x.push(C)}continue}if(p.has(j)){b.push(w);continue}x.push(w)}return{moduleMenus:x,accountMenus:b}},[c]);return o.jsxs("div",{className:"w-64 bg-[#1e3a8a] text-white flex flex-col h-screen border-r border-blue-800 shadow-xl z-20 shrink-0",children:[o.jsx("div",{className:"flex items-center justify-center border-b border-blue-800/50 bg-white px-4 shrink-0",style:{height:90},children:o.jsx("img",{src:UV,alt:"MedVantage",className:"h-16 w-auto object-contain"})}),o.jsx(hC,{className:"flex-1 py-4",children:o.jsx("div",{className:"px-3 space-y-1",children:l?o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>t("Dashboard"),className:ke("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors",e==="Dashboard"?"bg-blue-700 text-white shadow-md shadow-blue-900/20":"text-blue-100 hover:bg-blue-800 hover:text-white"),children:[o.jsx(Vp,{className:"w-4 h-4"}),"Dashboard"]}),o.jsx("div",{className:"px-4 py-2 mt-4 text-xs font-semibold text-blue-300 uppercase tracking-wider",children:"MODULES"}),f.map(p=>o.jsx(hj,{node:p,level:0,currentKey:e,onSelect:t},String(p.id??Math.random()))),o.jsx("div",{className:"px-4 py-2 mt-4 text-xs font-semibold text-blue-300 uppercase tracking-wider",children:"MANAGEMENT"}),h.map(p=>o.jsx(hj,{node:p,level:0,currentKey:e,onSelect:t},String(p.id??Math.random()))),o.jsxs("button",{onClick:d,className:ke("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors","text-red-300 hover:bg-red-900/20 hover:text-red-200"),children:[o.jsx(lj,{className:"w-4 h-4"}),"Log Out"]})]}):s.map((p,g)=>{if(p.type==="header")return o.jsx("div",{className:"px-4 py-2 mt-4 text-xs font-semibold text-blue-300 uppercase tracking-wider",children:p.name},g);if(p.type==="sub"){const b=p.icon;return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("button",{onClick:p.toggle,className:ke("w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium rounded-lg transition-colors","hover:bg-blue-800/50 text-blue-100"),children:[o.jsxs("div",{className:"flex items-center gap-3",children:[b?o.jsx(b,{className:"w-4 h-4"}):null,p.name]}),p.isOpen?o.jsx(Bs,{className:"w-4 h-4"}):o.jsx(Ui,{className:"w-4 h-4"})]}),p.isOpen&&o.jsx("div",{className:"pl-4 space-y-1",children:p.children?.map((w,j)=>o.jsxs("button",{onClick:()=>t(w.name),className:ke("w-full flex items-center gap-3 px-4 py-2 text-sm font-medium rounded-lg transition-colors border-l-2",e===w.name?"bg-blue-800 border-blue-400 text-white":"border-transparent hover:bg-blue-800/30 text-blue-200 hover:text-white"),children:[o.jsx("div",{className:"w-1 h-1 rounded-full bg-current"}),w.name]},j))})]},g)}const x=p.icon;return o.jsxs("button",{onClick:()=>p.name==="Log Out"?d():t(p.name),className:ke("w-full flex items-center gap-3 px-4 py-2.5 text-sm font-medium rounded-lg transition-colors",e===p.name?"bg-blue-700 text-white shadow-md shadow-blue-900/20":p.name==="Log Out"?"text-red-300 hover:bg-red-900/20 hover:text-red-200":"text-blue-100 hover:bg-blue-800 hover:text-white"),children:[x?o.jsx(x,{className:"w-4 h-4"}):null,p.name]},g)})})})]})}function me({className:e,type:t,...r}){return o.jsx("input",{type:t,"data-slot":"input",className:ke("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border px-3 py-1 text-base bg-input-background transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...r})}var WV=Symbol.for("react.lazy"),Yp=nC[" use ".trim().toString()];function HV(e){return typeof e=="object"&&e!==null&&"then"in e}function a4(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===WV&&"_payload"in e&&HV(e._payload)}function mC(e){const t=GV(e),r=v.forwardRef((n,a)=>{let{children:i,...s}=n;a4(i)&&typeof Yp=="function"&&(i=Yp(i._payload));const l=v.Children.toArray(i),d=l.find(KV);if(d){const c=d.props.children,f=l.map(h=>h===d?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:h);return o.jsx(t,{...s,ref:a,children:v.isValidElement(c)?v.cloneElement(c,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}var o4=mC("Slot");function GV(e){const t=v.forwardRef((r,n)=>{let{children:a,...i}=r;if(a4(a)&&typeof Yp=="function"&&(a=Yp(a._payload)),v.isValidElement(a)){const s=JV(a),l=XV(i,a.props);return a.type!==v.Fragment&&(l.ref=n?Oa(n,s):s),v.cloneElement(a,l)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var YV=Symbol("radix.slottable");function KV(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===YV}function XV(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function JV(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}const uT=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,dT=vt,pC=(e,t)=>r=>{var n;if(t?.variants==null)return dT(e,r?.class,r?.className);const{variants:a,defaultVariants:i}=t,s=Object.keys(a).map(c=>{const f=r?.[c],h=i?.[c];if(f===null)return null;const p=uT(f)||uT(h);return a[c][p]}),l=r&&Object.entries(r).reduce((c,f)=>{let[h,p]=f;return p===void 0||(c[h]=p),c},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((c,f)=>{let{class:h,className:p,...g}=f;return Object.entries(g).every(x=>{let[b,w]=x;return Array.isArray(w)?w.includes({...i,...l}[b]):{...i,...l}[b]===w})?[...c,h,p]:c},[]);return dT(e,s,d,r?.class,r?.className)},Kp=pC("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9 rounded-md"}},defaultVariants:{variant:"default",size:"default"}}),de=v.forwardRef(({className:e,variant:t,size:r,asChild:n=!1,...a},i)=>{const s=n?o4:"button";return o.jsx(s,{ref:i,"data-slot":"button",className:ke(Kp({variant:t,size:r,className:e})),...a})});de.displayName="Button";function QV(e,t=[]){let r=[];function n(i,s){const l=v.createContext(s);l.displayName=i+"Context";const d=r.length;r=[...r,s];const c=h=>{const{scope:p,children:g,...x}=h,b=p?.[e]?.[d]||l,w=v.useMemo(()=>x,Object.values(x));return o.jsx(b.Provider,{value:w,children:g})};c.displayName=i+"Provider";function f(h,p){const g=p?.[e]?.[d]||l,x=v.useContext(g);if(x)return x;if(s!==void 0)return s;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[c,f]}const a=()=>{const i=r.map(s=>v.createContext(s));return function(l){const d=l?.[e]||i;return v.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return a.scopeName=e,[n,ZV(a,...t)]}function ZV(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const s=n.reduce((l,{useScope:d,scopeName:c})=>{const h=d(i)[`__scope${c}`];return{...l,...h}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return r.scopeName=t.scopeName,r}var eW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],gC=eW.reduce((e,t)=>{const r=mC(`Primitive.${t}`),n=v.forwardRef((a,i)=>{const{asChild:s,...l}=a,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Tx={exports:{}},kx={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var fT;function tW(){if(fT)return kx;fT=1;var e=fy();function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function l(h,p){var g=p(),x=n({inst:{value:g,getSnapshot:p}}),b=x[0].inst,w=x[1];return i(function(){b.value=g,b.getSnapshot=p,d(b)&&w({inst:b})},[h,g,p]),a(function(){return d(b)&&w({inst:b}),h(function(){d(b)&&w({inst:b})})},[h]),s(g),g}function d(h){var p=h.getSnapshot;h=h.value;try{var g=p();return!r(h,g)}catch{return!0}}function c(h,p){return p()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return kx.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,kx}var hT;function rW(){return hT||(hT=1,Tx.exports=tW()),Tx.exports}var nW=rW();function aW(){return nW.useSyncExternalStore(oW,()=>!0,()=>!1)}function oW(){return()=>{}}var yC="Avatar",[iW]=QV(yC),[sW,i4]=iW(yC),s4=v.forwardRef((e,t)=>{const{__scopeAvatar:r,...n}=e,[a,i]=v.useState("idle");return o.jsx(sW,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:i,children:o.jsx(gC.span,{...n,ref:t})})});s4.displayName=yC;var l4="AvatarImage",c4=v.forwardRef((e,t)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...i}=e,s=i4(l4,r),l=lW(n,i),d=dn(c=>{a(c),s.onImageLoadingStatusChange(c)});return Ir(()=>{l!=="idle"&&d(l)},[l,d]),l==="loaded"?o.jsx(gC.img,{...i,ref:t,src:n}):null});c4.displayName=l4;var u4="AvatarFallback",d4=v.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:n,...a}=e,i=i4(u4,r),[s,l]=v.useState(n===void 0);return v.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>l(!0),n);return()=>window.clearTimeout(d)}},[n]),s&&i.imageLoadingStatus!=="loaded"?o.jsx(gC.span,{...a,ref:t}):null});d4.displayName=u4;function mT(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function lW(e,{referrerPolicy:t,crossOrigin:r}){const n=aW(),a=v.useRef(null),i=n?(a.current||(a.current=new window.Image),a.current):null,[s,l]=v.useState(()=>mT(i,e));return Ir(()=>{l(mT(i,e))},[i,e]),Ir(()=>{const d=h=>()=>{l(h)};if(!i)return;const c=d("loaded"),f=d("error");return i.addEventListener("load",c),i.addEventListener("error",f),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",c),i.removeEventListener("error",f)}},[i,r,t]),s}var cW=s4,uW=c4,dW=d4;function fW({className:e,...t}){return o.jsx(cW,{"data-slot":"avatar",className:ke("relative flex size-10 shrink-0 overflow-hidden rounded-full",e),...t})}function hW({className:e,...t}){return o.jsx(uW,{"data-slot":"avatar-image",className:ke("aspect-square size-full",e),...t})}function mW({className:e,...t}){return o.jsx(dW,{"data-slot":"avatar-fallback",className:ke("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}function pW({title:e,onSettingsClick:t}){const r=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return o.jsxs("header",{className:"bg-white border-b border-gray-200 px-8 flex items-center justify-between shadow-sm sticky top-0 z-10 shrink-0",style:{height:90},children:[o.jsxs("div",{children:[o.jsxs("h1",{className:"text-2xl font-bold",style:{color:"rgb(43, 50, 143)"},children:[e," Overview"]}),o.jsxs("p",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[r," | Last updated: Just now"]})]}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("div",{className:"flex items-center w-64 h-9 rounded-md border border-gray-200 bg-gray-50 focus-within:bg-white focus-within:ring-2 focus-within:ring-ring/50 focus-within:border-ring transition-colors overflow-hidden",children:[o.jsx(Rf,{className:"h-4 w-4 text-gray-400 shrink-0 ml-3 pointer-events-none"}),o.jsx(me,{type:"search",placeholder:"Search...",className:"flex-1 min-w-0 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 py-2 px-2 h-full"})]}),o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"text-gray-500 hover:text-gray-700","aria-label":"Open Support",onClick:()=>t?.(),children:o.jsx(jc,{className:"w-5 h-5"})}),o.jsx("div",{className:"h-8 w-px bg-gray-200 mx-2"}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"text-right hidden md:block",children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Admin User"}),o.jsx("div",{className:"text-xs text-gray-500",children:"Administrator"})]}),o.jsxs(fW,{className:"h-10 w-10 border border-gray-200",children:[o.jsx(hW,{src:"https://github.com/shadcn.png"}),o.jsx(mW,{children:"AD"})]})]})]})]})}function gW({children:e,currentView:t,setCurrentView:r,menus:n,onLogout:a,hideAppChrome:i=!1}){return o.jsxs("div",{className:"flex h-screen bg-gray-50 overflow-hidden font-sans",children:[!i&&o.jsx(VV,{currentView:t,setCurrentView:r,menus:n,onLogout:a}),o.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",style:{flex:"1 1 0%",minHeight:0,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[!i&&o.jsxs(o.Fragment,{children:[o.jsx(pW,{title:t,onSettingsClick:()=>r("Support")}),o.jsx("div",{className:"mt-8 shrink-0 px-8",children:o.jsxs("nav",{className:"flex items-center gap-2 text-sm font-normal","aria-label":"Breadcrumb",children:[o.jsx("button",{type:"button",onClick:()=>r("Dashboard"),className:"text-gray-500 transition-colors hover:text-gray-700",children:"Home"}),o.jsx(Ui,{className:"h-4 w-4 shrink-0 text-gray-500"}),o.jsx("span",{style:{color:"rgb(43, 50, 143)"},children:t})]})})]}),o.jsx("main",{className:i?"flex flex-1 flex-col overflow-hidden p-0":"flex-1 overflow-y-auto p-8",style:i?{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",padding:0}:{flex:"1 1 0%",minHeight:0,minWidth:0},children:o.jsx("div",{className:"flex w-full min-w-0 flex-1 flex-col",style:{flex:"1 1 0%",minHeight:0,minWidth:0,width:"100%",display:"flex",flexDirection:"column"},children:e})})]})]})}function wn({className:e,...t}){return o.jsx("div",{"data-slot":"card",className:ke("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border",e),...t})}function Na({className:e,...t}){return o.jsx("div",{"data-slot":"card-header",className:ke("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 pt-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Ca({className:e,...t}){return o.jsx("h4",{"data-slot":"card-title",className:ke("leading-none",e),...t})}function Hd({className:e,...t}){return o.jsx("p",{"data-slot":"card-description",className:ke("text-muted-foreground",e),...t})}function Dn({className:e,...t}){return o.jsx("div",{"data-slot":"card-content",className:ke("px-6 [&:last-child]:pb-6",e),...t})}const yW=pC("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function fn({className:e,variant:t,asChild:r=!1,...n}){const a=r?o4:"span";return o.jsx(a,{"data-slot":"badge",className:ke(yW({variant:t}),e),...n})}function uo({className:e,...t}){return o.jsx("div",{"data-slot":"skeleton",className:ke("bg-accent animate-pulse rounded-md",e),...t})}var Ax,pT;function qn(){if(pT)return Ax;pT=1;var e=Array.isArray;return Ax=e,Ax}var Ix,gT;function f4(){if(gT)return Ix;gT=1;var e=typeof Nm=="object"&&Nm&&Nm.Object===Object&&Nm;return Ix=e,Ix}var Mx,yT;function Oo(){if(yT)return Mx;yT=1;var e=f4(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Mx=r,Mx}var Rx,vT;function Lf(){if(vT)return Rx;vT=1;var e=Oo(),t=e.Symbol;return Rx=t,Rx}var Dx,xT;function vW(){if(xT)return Dx;xT=1;var e=Lf(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,a=e?e.toStringTag:void 0;function i(s){var l=r.call(s,a),d=s[a];try{s[a]=void 0;var c=!0}catch{}var f=n.call(s);return c&&(l?s[a]=d:delete s[a]),f}return Dx=i,Dx}var Lx,bT;function xW(){if(bT)return Lx;bT=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Lx=r,Lx}var $x,wT;function ci(){if(wT)return $x;wT=1;var e=Lf(),t=vW(),r=xW(),n="[object Null]",a="[object Undefined]",i=e?e.toStringTag:void 0;function s(l){return l==null?l===void 0?a:n:i&&i in Object(l)?t(l):r(l)}return $x=s,$x}var Fx,ST;function ui(){if(ST)return Fx;ST=1;function e(t){return t!=null&&typeof t=="object"}return Fx=e,Fx}var Bx,jT;function uu(){if(jT)return Bx;jT=1;var e=ci(),t=ui(),r="[object Symbol]";function n(a){return typeof a=="symbol"||t(a)&&e(a)==r}return Bx=n,Bx}var zx,NT;function vC(){if(NT)return zx;NT=1;var e=qn(),t=uu(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,s){if(e(i))return!1;var l=typeof i;return l=="number"||l=="symbol"||l=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||s!=null&&i in Object(s)}return zx=a,zx}var Ux,CT;function Hi(){if(CT)return Ux;CT=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Ux=e,Ux}var qx,_T;function xC(){if(_T)return qx;_T=1;var e=ci(),t=Hi(),r="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function s(l){if(!t(l))return!1;var d=e(l);return d==n||d==a||d==r||d==i}return qx=s,qx}var Vx,ET;function bW(){if(ET)return Vx;ET=1;var e=Oo(),t=e["__core-js_shared__"];return Vx=t,Vx}var Wx,PT;function wW(){if(PT)return Wx;PT=1;var e=bW(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Wx=r,Wx}var Hx,OT;function h4(){if(OT)return Hx;OT=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return Hx=r,Hx}var Gx,TT;function SW(){if(TT)return Gx;TT=1;var e=xC(),t=wW(),r=Hi(),n=h4(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,s=Function.prototype,l=Object.prototype,d=s.toString,c=l.hasOwnProperty,f=RegExp("^"+d.call(c).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function h(p){if(!r(p)||t(p))return!1;var g=e(p)?f:i;return g.test(n(p))}return Gx=h,Gx}var Yx,kT;function jW(){if(kT)return Yx;kT=1;function e(t,r){return t?.[r]}return Yx=e,Yx}var Kx,AT;function ol(){if(AT)return Kx;AT=1;var e=SW(),t=jW();function r(n,a){var i=t(n,a);return e(i)?i:void 0}return Kx=r,Kx}var Xx,IT;function yy(){if(IT)return Xx;IT=1;var e=ol(),t=e(Object,"create");return Xx=t,Xx}var Jx,MT;function NW(){if(MT)return Jx;MT=1;var e=yy();function t(){this.__data__=e?e(null):{},this.size=0}return Jx=t,Jx}var Qx,RT;function CW(){if(RT)return Qx;RT=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Qx=e,Qx}var Zx,DT;function _W(){if(DT)return Zx;DT=1;var e=yy(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function a(i){var s=this.__data__;if(e){var l=s[i];return l===t?void 0:l}return n.call(s,i)?s[i]:void 0}return Zx=a,Zx}var eb,LT;function EW(){if(LT)return eb;LT=1;var e=yy(),t=Object.prototype,r=t.hasOwnProperty;function n(a){var i=this.__data__;return e?i[a]!==void 0:r.call(i,a)}return eb=n,eb}var tb,$T;function PW(){if($T)return tb;$T=1;var e=yy(),t="__lodash_hash_undefined__";function r(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&a===void 0?t:a,this}return tb=r,tb}var rb,FT;function OW(){if(FT)return rb;FT=1;var e=NW(),t=CW(),r=_W(),n=EW(),a=PW();function i(s){var l=-1,d=s==null?0:s.length;for(this.clear();++l-1}return lb=t,lb}var cb,HT;function MW(){if(HT)return cb;HT=1;var e=vy();function t(r,n){var a=this.__data__,i=e(a,r);return i<0?(++this.size,a.push([r,n])):a[i][1]=n,this}return cb=t,cb}var ub,GT;function xy(){if(GT)return ub;GT=1;var e=TW(),t=kW(),r=AW(),n=IW(),a=MW();function i(s){var l=-1,d=s==null?0:s.length;for(this.clear();++l0?1:-1},Is=function(t){return Us(t)&&t.indexOf("%")===t.length-1},Re=function(t){return nH(t)&&!$f(t)},aH=function(t){return yt(t)},zr=function(t){return Re(t)||Us(t)},oH=0,fu=function(t){var r=++oH;return"".concat(t||"").concat(r)},jn=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Re(t)&&!Us(t))return n;var i;if(Is(t)){var s=t.indexOf("%");i=r*parseFloat(t.slice(0,s))/100}else i=+t;return $f(i)&&(i=n),a&&i>r&&(i=r),i},Li=function(t){if(!t)return null;var r=Object.keys(t);return r&&r.length?t[r[0]]:null},iH=function(t){if(!Array.isArray(t))return!1;for(var r=t.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function hH(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function pj(e){"@babel/helpers - typeof";return pj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pj(e)}var wk={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},Zo=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},Sk=null,Db=null,_C=function e(t){if(t===Sk&&Array.isArray(Db))return Db;var r=[];return v.Children.forEach(t,function(n){yt(n)||(ZW.isFragment(n)?r=r.concat(e(n.props.children)):r.push(n))}),Db=r,Sk=t,r};function da(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(function(a){return Zo(a)}):n=[Zo(t)],_C(e).forEach(function(a){var i=ua(a,"type.displayName")||ua(a,"type.name");n.indexOf(i)!==-1&&r.push(a)}),r}function ea(e,t){var r=da(e,t);return r&&r[0]}var jk=function(t){if(!t||!t.props)return!1;var r=t.props,n=r.width,a=r.height;return!(!Re(n)||n<=0||!Re(a)||a<=0)},mH=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],pH=function(t){return t&&t.type&&Us(t.type)&&mH.indexOf(t.type)>=0},gH=function(t){return t&&pj(t)==="object"&&"clipDot"in t},yH=function(t,r,n,a){var i,s=(i=Rb?.[a])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!mt(t)&&(a&&s.includes(r)||cH.includes(r))||n&&CC.includes(r)},lt=function(t,r,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var a=t;if(v.isValidElement(t)&&(a=t.props),!du(a))return null;var i={};return Object.keys(a).forEach(function(s){var l;yH((l=a)===null||l===void 0?void 0:l[s],s,r,n)&&(i[s]=a[s])}),i},gj=function e(t,r){if(t===r)return!0;var n=v.Children.count(t);if(n!==v.Children.count(r))return!1;if(n===0)return!0;if(n===1)return Nk(Array.isArray(t)?t[0]:t,Array.isArray(r)?r[0]:r);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function SH(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function vj(e){var t=e.children,r=e.width,n=e.height,a=e.viewBox,i=e.className,s=e.style,l=e.title,d=e.desc,c=wH(e,bH),f=a||{width:r,height:n,x:0,y:0},h=vt("recharts-surface",i);return U.createElement("svg",yj({},lt(c,!0,"svg"),{className:h,width:r,height:n,style:s,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height)}),U.createElement("title",null,l),U.createElement("desc",null,d),t)}var jH=["children","className"];function xj(){return xj=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function CH(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Bt=U.forwardRef(function(e,t){var r=e.children,n=e.className,a=NH(e,jH),i=vt("recharts-layer",n);return U.createElement("g",xj({className:i},lt(a,!0),{ref:t}),r)}),Ka=function(t,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),i=2;ii?0:i+r),n=n>i?i:n,n<0&&(n+=i),i=r>n?0:n-r>>>0,r>>>=0;for(var s=Array(i);++a=i?r:e(r,n,a)}return $b=t,$b}var Fb,Pk;function x4(){if(Pk)return Fb;Pk=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",s="\\u200d",l=RegExp("["+s+e+a+i+"]");function d(c){return l.test(c)}return Fb=d,Fb}var Bb,Ok;function PH(){if(Ok)return Bb;Ok=1;function e(t){return t.split("")}return Bb=e,Bb}var zb,Tk;function OH(){if(Tk)return zb;Tk=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",s="["+e+"]",l="["+a+"]",d="\\ud83c[\\udffb-\\udfff]",c="(?:"+l+"|"+d+")",f="[^"+e+"]",h="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",g="\\u200d",x=c+"?",b="["+i+"]?",w="(?:"+g+"(?:"+[f,h,p].join("|")+")"+b+x+")*",j=b+x+w,N="(?:"+[f+l+"?",l,h,p,s].join("|")+")",C=RegExp(d+"(?="+d+")|"+N+j,"g");function O(P){return P.match(C)||[]}return zb=O,zb}var Ub,kk;function TH(){if(kk)return Ub;kk=1;var e=PH(),t=x4(),r=OH();function n(a){return t(a)?r(a):e(a)}return Ub=n,Ub}var qb,Ak;function kH(){if(Ak)return qb;Ak=1;var e=EH(),t=x4(),r=TH(),n=p4();function a(i){return function(s){s=n(s);var l=t(s)?r(s):void 0,d=l?l[0]:s.charAt(0),c=l?e(l,1).join(""):s.slice(1);return d[i]()+c}}return qb=a,qb}var Vb,Ik;function AH(){if(Ik)return Vb;Ik=1;var e=kH(),t=e("toUpperCase");return Vb=t,Vb}var IH=AH();const Sy=Wt(IH);function ar(e){return function(){return e}}const b4=Math.cos,Qp=Math.sin,ro=Math.sqrt,Zp=Math.PI,jy=2*Zp,bj=Math.PI,wj=2*bj,Ps=1e-6,MH=wj-Ps;function w4(e){this._+=e[0];for(let t=1,r=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return w4;const r=10**t;return function(n){this._+=n[0];for(let a=1,i=n.length;aPs)if(!(Math.abs(h*d-c*f)>Ps)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let g=n-s,x=a-l,b=d*d+c*c,w=g*g+x*x,j=Math.sqrt(b),N=Math.sqrt(p),C=i*Math.tan((bj-Math.acos((b+p-w)/(2*j*N)))/2),O=C/N,P=C/j;Math.abs(O-1)>Ps&&this._append`L${t+O*f},${r+O*h}`,this._append`A${i},${i},0,0,${+(h*g>f*x)},${this._x1=t+P*d},${this._y1=r+P*c}`}}arc(t,r,n,a,i,s){if(t=+t,r=+r,n=+n,s=!!s,n<0)throw new Error(`negative radius: ${n}`);let l=n*Math.cos(a),d=n*Math.sin(a),c=t+l,f=r+d,h=1^s,p=s?a-i:i-a;this._x1===null?this._append`M${c},${f}`:(Math.abs(this._x1-c)>Ps||Math.abs(this._y1-f)>Ps)&&this._append`L${c},${f}`,n&&(p<0&&(p=p%wj+wj),p>MH?this._append`A${n},${n},0,1,${h},${t-l},${r-d}A${n},${n},0,1,${h},${this._x1=c},${this._y1=f}`:p>Ps&&this._append`A${n},${n},0,${+(p>=bj)},${h},${this._x1=t+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(t,r,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function EC(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);t=n}return e},()=>new DH(t)}function PC(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function S4(e){this._context=e}S4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Ny(e){return new S4(e)}function j4(e){return e[0]}function N4(e){return e[1]}function C4(e,t){var r=ar(!0),n=null,a=Ny,i=null,s=EC(l);e=typeof e=="function"?e:e===void 0?j4:ar(e),t=typeof t=="function"?t:t===void 0?N4:ar(t);function l(d){var c,f=(d=PC(d)).length,h,p=!1,g;for(n==null&&(i=a(g=s())),c=0;c<=f;++c)!(c=g;--x)l.point(C[x],O[x]);l.lineEnd(),l.areaEnd()}j&&(C[p]=+e(w,p,h),O[p]=+t(w,p,h),l.point(n?+n(w,p,h):C[p],r?+r(w,p,h):O[p]))}if(N)return l=null,N+""||null}function f(){return C4().defined(a).curve(s).context(i)}return c.x=function(h){return arguments.length?(e=typeof h=="function"?h:ar(+h),n=null,c):e},c.x0=function(h){return arguments.length?(e=typeof h=="function"?h:ar(+h),c):e},c.x1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:ar(+h),c):n},c.y=function(h){return arguments.length?(t=typeof h=="function"?h:ar(+h),r=null,c):t},c.y0=function(h){return arguments.length?(t=typeof h=="function"?h:ar(+h),c):t},c.y1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:ar(+h),c):r},c.lineX0=c.lineY0=function(){return f().x(e).y(t)},c.lineY1=function(){return f().x(e).y(r)},c.lineX1=function(){return f().x(n).y(t)},c.defined=function(h){return arguments.length?(a=typeof h=="function"?h:ar(!!h),c):a},c.curve=function(h){return arguments.length?(s=h,i!=null&&(l=s(i)),c):s},c.context=function(h){return arguments.length?(h==null?i=l=null:l=s(i=h),c):i},c}class _4{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function LH(e){return new _4(e,!0)}function $H(e){return new _4(e,!1)}const OC={draw(e,t){const r=ro(t/Zp);e.moveTo(r,0),e.arc(0,0,r,0,jy)}},FH={draw(e,t){const r=ro(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},E4=ro(1/3),BH=E4*2,zH={draw(e,t){const r=ro(t/BH),n=r*E4;e.moveTo(0,-r),e.lineTo(n,0),e.lineTo(0,r),e.lineTo(-n,0),e.closePath()}},UH={draw(e,t){const r=ro(t),n=-r/2;e.rect(n,n,r,r)}},qH=.8908130915292852,P4=Qp(Zp/10)/Qp(7*Zp/10),VH=Qp(jy/10)*P4,WH=-b4(jy/10)*P4,HH={draw(e,t){const r=ro(t*qH),n=VH*r,a=WH*r;e.moveTo(0,-r),e.lineTo(n,a);for(let i=1;i<5;++i){const s=jy*i/5,l=b4(s),d=Qp(s);e.lineTo(d*r,-l*r),e.lineTo(l*n-d*a,d*n+l*a)}e.closePath()}},Wb=ro(3),GH={draw(e,t){const r=-ro(t/(Wb*3));e.moveTo(0,r*2),e.lineTo(-Wb*r,-r),e.lineTo(Wb*r,-r),e.closePath()}},wa=-.5,Sa=ro(3)/2,Sj=1/ro(12),YH=(Sj/2+1)*3,KH={draw(e,t){const r=ro(t/YH),n=r/2,a=r*Sj,i=n,s=r*Sj+r,l=-i,d=s;e.moveTo(n,a),e.lineTo(i,s),e.lineTo(l,d),e.lineTo(wa*n-Sa*a,Sa*n+wa*a),e.lineTo(wa*i-Sa*s,Sa*i+wa*s),e.lineTo(wa*l-Sa*d,Sa*l+wa*d),e.lineTo(wa*n+Sa*a,wa*a-Sa*n),e.lineTo(wa*i+Sa*s,wa*s-Sa*i),e.lineTo(wa*l+Sa*d,wa*d-Sa*l),e.closePath()}};function XH(e,t){let r=null,n=EC(a);e=typeof e=="function"?e:ar(e||OC),t=typeof t=="function"?t:ar(t===void 0?64:+t);function a(){let i;if(r||(r=i=n()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:ar(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:ar(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function eg(){}function tg(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function O4(e){this._context=e}O4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:tg(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:tg(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function JH(e){return new O4(e)}function T4(e){this._context=e}T4.prototype={areaStart:eg,areaEnd:eg,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:tg(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function QH(e){return new T4(e)}function k4(e){this._context=e}k4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:tg(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function ZH(e){return new k4(e)}function A4(e){this._context=e}A4.prototype={areaStart:eg,areaEnd:eg,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function eG(e){return new A4(e)}function Mk(e){return e<0?-1:1}function Rk(e,t,r){var n=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(n||a<0&&-0),s=(r-e._y1)/(a||n<0&&-0),l=(i*a+s*n)/(n+a);return(Mk(i)+Mk(s))*Math.min(Math.abs(i),Math.abs(s),.5*Math.abs(l))||0}function Dk(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function Hb(e,t,r){var n=e._x0,a=e._y0,i=e._x1,s=e._y1,l=(i-n)/3;e._context.bezierCurveTo(n+l,a+l*t,i-l,s-l*r,i,s)}function rg(e){this._context=e}rg.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:Hb(this,this._t0,Dk(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Hb(this,Dk(this,r=Rk(this,e,t)),r);break;default:Hb(this,this._t0,r=Rk(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function I4(e){this._context=new M4(e)}(I4.prototype=Object.create(rg.prototype)).point=function(e,t){rg.prototype.point.call(this,t,e)};function M4(e){this._context=e}M4.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,n,a,i){this._context.bezierCurveTo(t,e,n,r,i,a)}};function tG(e){return new rg(e)}function rG(e){return new I4(e)}function R4(e){this._context=e}R4.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var n=Lk(e),a=Lk(t),i=0,s=1;s=0;--t)a[t]=(s[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function aG(e){return new Cy(e,.5)}function oG(e){return new Cy(e,0)}function iG(e){return new Cy(e,1)}function _c(e,t){if((s=e.length)>1)for(var r=1,n,a,i=e[t[0]],s,l=i.length;r=0;)r[t]=t;return r}function sG(e,t){return e[t]}function lG(e){const t=[];return t.key=e,t}function cG(){var e=ar([]),t=jj,r=_c,n=sG;function a(i){var s=Array.from(e.apply(this,arguments),lG),l,d=s.length,c=-1,f;for(const h of i)for(l=0,++c;l0){for(var r,n,a=0,i=e[0].length,s;a0){for(var r=0,n=e[t[0]],a,i=n.length;r0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,n=1,a,i,s;n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function vG(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var D4={symbolCircle:OC,symbolCross:FH,symbolDiamond:zH,symbolSquare:UH,symbolStar:HH,symbolTriangle:GH,symbolWye:KH},xG=Math.PI/180,bG=function(t){var r="symbol".concat(Sy(t));return D4[r]||OC},wG=function(t,r,n){if(r==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var a=18*xG;return 1.25*t*t*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},SG=function(t,r){D4["symbol".concat(Sy(t))]=r},TC=function(t){var r=t.type,n=r===void 0?"circle":r,a=t.size,i=a===void 0?64:a,s=t.sizeType,l=s===void 0?"area":s,d=yG(t,hG),c=Fk(Fk({},d),{},{type:n,size:i,sizeType:l}),f=function(){var w=bG(n),j=XH().type(w).size(wG(i,l,n));return j()},h=c.className,p=c.cx,g=c.cy,x=lt(c,!0);return p===+p&&g===+g&&i===+i?U.createElement("path",Nj({},x,{className:vt("recharts-symbols",h),transform:"translate(".concat(p,", ").concat(g,")"),d:f()})):null};TC.registerSymbol=SG;function Ec(e){"@babel/helpers - typeof";return Ec=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ec(e)}function Cj(){return Cj=Object.assign?Object.assign.bind():function(e){for(var t=1;t`);var N=g.inactive?c:g.color;return U.createElement("li",Cj({className:w,style:h,key:"legend-item-".concat(x)},qs(n.props,g,x)),U.createElement(vj,{width:s,height:s,viewBox:f,style:p},n.renderIcon(g)),U.createElement("span",{className:"recharts-legend-item-text",style:{color:N}},b?b(j,g,x):j))})}},{key:"render",value:function(){var n=this.props,a=n.payload,i=n.layout,s=n.align;if(!a||!a.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?s:"left"};return U.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])})(v.PureComponent);Yd(kC,"displayName","Legend");Yd(kC,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var Gb,zk;function AG(){if(zk)return Gb;zk=1;var e=xy();function t(){this.__data__=new e,this.size=0}return Gb=t,Gb}var Yb,Uk;function IG(){if(Uk)return Yb;Uk=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Yb=e,Yb}var Kb,qk;function MG(){if(qk)return Kb;qk=1;function e(t){return this.__data__.get(t)}return Kb=e,Kb}var Xb,Vk;function RG(){if(Vk)return Xb;Vk=1;function e(t){return this.__data__.has(t)}return Xb=e,Xb}var Jb,Wk;function DG(){if(Wk)return Jb;Wk=1;var e=xy(),t=wC(),r=SC(),n=200;function a(i,s){var l=this.__data__;if(l instanceof e){var d=l.__data__;if(!t||d.lengthg))return!1;var b=h.get(s),w=h.get(l);if(b&&w)return b==l&&w==s;var j=-1,N=!0,C=d&a?new e:void 0;for(h.set(s,l),h.set(l,s);++j-1&&n%1==0&&n-1&&r%1==0&&r<=e}return xw=t,xw}var bw,p2;function KG(){if(p2)return bw;p2=1;var e=ci(),t=RC(),r=ui(),n="[object Arguments]",a="[object Array]",i="[object Boolean]",s="[object Date]",l="[object Error]",d="[object Function]",c="[object Map]",f="[object Number]",h="[object Object]",p="[object RegExp]",g="[object Set]",x="[object String]",b="[object WeakMap]",w="[object ArrayBuffer]",j="[object DataView]",N="[object Float32Array]",C="[object Float64Array]",O="[object Int8Array]",P="[object Int16Array]",E="[object Int32Array]",T="[object Uint8Array]",A="[object Uint8ClampedArray]",I="[object Uint16Array]",R="[object Uint32Array]",L={};L[N]=L[C]=L[O]=L[P]=L[E]=L[T]=L[A]=L[I]=L[R]=!0,L[n]=L[a]=L[w]=L[i]=L[j]=L[s]=L[l]=L[d]=L[c]=L[f]=L[h]=L[p]=L[g]=L[x]=L[b]=!1;function V(z){return r(z)&&t(z.length)&&!!L[e(z)]}return bw=V,bw}var ww,g2;function H4(){if(g2)return ww;g2=1;function e(t){return function(r){return t(r)}}return ww=e,ww}var Rd={exports:{}};Rd.exports;var y2;function XG(){return y2||(y2=1,(function(e,t){var r=f4(),n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,s=i&&r.process,l=(function(){try{var d=a&&a.require&&a.require("util").types;return d||s&&s.binding&&s.binding("util")}catch{}})();e.exports=l})(Rd,Rd.exports)),Rd.exports}var Sw,v2;function G4(){if(v2)return Sw;v2=1;var e=KG(),t=H4(),r=XG(),n=r&&r.isTypedArray,a=n?t(n):e;return Sw=a,Sw}var jw,x2;function JG(){if(x2)return jw;x2=1;var e=HG(),t=IC(),r=qn(),n=W4(),a=MC(),i=G4(),s=Object.prototype,l=s.hasOwnProperty;function d(c,f){var h=r(c),p=!h&&t(c),g=!h&&!p&&n(c),x=!h&&!p&&!g&&i(c),b=h||p||g||x,w=b?e(c.length,String):[],j=w.length;for(var N in c)(f||l.call(c,N))&&!(b&&(N=="length"||g&&(N=="offset"||N=="parent")||x&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,j)))&&w.push(N);return w}return jw=d,jw}var Nw,b2;function QG(){if(b2)return Nw;b2=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,a=typeof n=="function"&&n.prototype||e;return r===a}return Nw=t,Nw}var Cw,w2;function Y4(){if(w2)return Cw;w2=1;function e(t,r){return function(n){return t(r(n))}}return Cw=e,Cw}var _w,S2;function ZG(){if(S2)return _w;S2=1;var e=Y4(),t=e(Object.keys,Object);return _w=t,_w}var Ew,j2;function eY(){if(j2)return Ew;j2=1;var e=QG(),t=ZG(),r=Object.prototype,n=r.hasOwnProperty;function a(i){if(!e(i))return t(i);var s=[];for(var l in Object(i))n.call(i,l)&&l!="constructor"&&s.push(l);return s}return Ew=a,Ew}var Pw,N2;function Ff(){if(N2)return Pw;N2=1;var e=xC(),t=RC();function r(n){return n!=null&&t(n.length)&&!e(n)}return Pw=r,Pw}var Ow,C2;function _y(){if(C2)return Ow;C2=1;var e=JG(),t=eY(),r=Ff();function n(a){return r(a)?e(a):t(a)}return Ow=n,Ow}var Tw,_2;function tY(){if(_2)return Tw;_2=1;var e=UG(),t=WG(),r=_y();function n(a){return e(a,r,t)}return Tw=n,Tw}var kw,E2;function rY(){if(E2)return kw;E2=1;var e=tY(),t=1,r=Object.prototype,n=r.hasOwnProperty;function a(i,s,l,d,c,f){var h=l&t,p=e(i),g=p.length,x=e(s),b=x.length;if(g!=b&&!h)return!1;for(var w=g;w--;){var j=p[w];if(!(h?j in s:n.call(s,j)))return!1}var N=f.get(i),C=f.get(s);if(N&&C)return N==s&&C==i;var O=!0;f.set(i,s),f.set(s,i);for(var P=h;++w-1}return n1=t,n1}var a1,eA;function SY(){if(eA)return a1;eA=1;function e(t,r,n){for(var a=-1,i=t==null?0:t.length;++a=s){var j=c?null:a(d);if(j)return i(j);x=!1,p=n,w=new e}else w=c?[]:b;e:for(;++h=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function LY(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function $Y(e){return e.value}function FY(e,t){if(U.isValidElement(e))return U.cloneElement(e,t);if(typeof e=="function")return U.createElement(e,t);t.ref;var r=DY(t,PY);return U.createElement(kC,r)}var lA=1,mc=(function(e){function t(){var r;OY(this,t);for(var n=arguments.length,a=new Array(n),i=0;ilA||Math.abs(a.height-this.lastBoundingBox.height)>lA)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,n&&n(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?qo({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var a=this.props,i=a.layout,s=a.align,l=a.verticalAlign,d=a.margin,c=a.chartWidth,f=a.chartHeight,h,p;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(s==="center"&&i==="vertical"){var g=this.getBBoxSnapshot();h={left:((c||0)-g.width)/2}}else h=s==="right"?{right:d&&d.right||0}:{left:d&&d.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(l==="middle"){var x=this.getBBoxSnapshot();p={top:((f||0)-x.height)/2}}else p=l==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return qo(qo({},h),p)}},{key:"render",value:function(){var n=this,a=this.props,i=a.content,s=a.width,l=a.height,d=a.wrapperStyle,c=a.payloadUniqBy,f=a.payload,h=qo(qo({position:"absolute",width:s||"auto",height:l||"auto"},this.getDefaultPosition(d)),d);return U.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(g){n.wrapperNode=g}},FY(i,qo(qo({},this.props),{},{payload:Z4(f,c,$Y)})))}}],[{key:"getWithHeight",value:function(n,a){var i=qo(qo({},this.defaultProps),n.props),s=i.layout;return s==="vertical"&&Re(n.props.height)?{height:n.props.height}:s==="horizontal"?{width:n.props.width||a}:null}}])})(v.PureComponent);Ey(mc,"displayName","Legend");Ey(mc,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var c1,cA;function BY(){if(cA)return c1;cA=1;var e=Lf(),t=IC(),r=qn(),n=e?e.isConcatSpreadable:void 0;function a(i){return r(i)||t(i)||!!(n&&i&&i[n])}return c1=a,c1}var u1,uA;function r3(){if(uA)return u1;uA=1;var e=V4(),t=BY();function r(n,a,i,s,l){var d=-1,c=n.length;for(i||(i=t),l||(l=[]);++d0&&i(f)?a>1?r(f,a-1,i,s,l):e(l,f):s||(l[l.length]=f)}return l}return u1=r,u1}var d1,dA;function zY(){if(dA)return d1;dA=1;function e(t){return function(r,n,a){for(var i=-1,s=Object(r),l=a(r),d=l.length;d--;){var c=l[t?d:++i];if(n(s[c],c,s)===!1)break}return r}}return d1=e,d1}var f1,fA;function UY(){if(fA)return f1;fA=1;var e=zY(),t=e();return f1=t,f1}var h1,hA;function n3(){if(hA)return h1;hA=1;var e=UY(),t=_y();function r(n,a){return n&&e(n,a,t)}return h1=r,h1}var m1,mA;function qY(){if(mA)return m1;mA=1;var e=Ff();function t(r,n){return function(a,i){if(a==null)return a;if(!e(a))return r(a,i);for(var s=a.length,l=n?s:-1,d=Object(a);(n?l--:++ln||l&&d&&f&&!c&&!h||i&&d&&f||!a&&f||!s)return 1;if(!i&&!l&&!h&&r=c)return f;var h=a[i];return f*(h=="desc"?-1:1)}}return r.index-n.index}return x1=t,x1}var b1,bA;function GY(){if(bA)return b1;bA=1;var e=jC(),t=NC(),r=To(),n=a3(),a=VY(),i=H4(),s=HY(),l=hu(),d=qn();function c(f,h,p){h.length?h=e(h,function(b){return d(b)?function(w){return t(w,b.length===1?b[0]:b)}:b}):h=[l];var g=-1;h=e(h,i(r));var x=n(f,function(b,w,j){var N=e(h,function(C){return C(b)});return{criteria:N,index:++g,value:b}});return a(x,function(b,w){return s(b,w,p)})}return b1=c,b1}var w1,wA;function YY(){if(wA)return w1;wA=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return w1=e,w1}var S1,SA;function KY(){if(SA)return S1;SA=1;var e=YY(),t=Math.max;function r(n,a,i){return a=t(a===void 0?n.length-1:a,0),function(){for(var s=arguments,l=-1,d=t(s.length-a,0),c=Array(d);++l0){if(++i>=e)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return _1=n,_1}var E1,EA;function ZY(){if(EA)return E1;EA=1;var e=JY(),t=QY(),r=t(e);return E1=r,E1}var P1,PA;function eK(){if(PA)return P1;PA=1;var e=hu(),t=KY(),r=ZY();function n(a,i){return r(t(a,i,e),a+"")}return P1=n,P1}var O1,OA;function Py(){if(OA)return O1;OA=1;var e=bC(),t=Ff(),r=MC(),n=Hi();function a(i,s,l){if(!n(l))return!1;var d=typeof s;return(d=="number"?t(l)&&r(s,l.length):d=="string"&&s in l)?e(l[s],i):!1}return O1=a,O1}var T1,TA;function tK(){if(TA)return T1;TA=1;var e=r3(),t=GY(),r=eK(),n=Py(),a=r(function(i,s){if(i==null)return[];var l=s.length;return l>1&&n(i,s[0],s[1])?s=[]:l>2&&n(s[0],s[1],s[2])&&(s=[s[0]]),t(i,e(s,1),[])});return T1=a,T1}var rK=tK();const $C=Wt(rK);function Kd(e){"@babel/helpers - typeof";return Kd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Kd(e)}function Pj(){return Pj=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t.x),"".concat(md,"-left"),Re(r)&&t&&Re(t.x)&&r=t.y),"".concat(md,"-top"),Re(n)&&t&&Re(t.y)&&nb?Math.max(f,d[n]):Math.max(h,d[n])}function yK(e){var t=e.translateX,r=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function vK(e){var t=e.allowEscapeViewBox,r=e.coordinate,n=e.offsetTopLeft,a=e.position,i=e.reverseDirection,s=e.tooltipBox,l=e.useTranslate3d,d=e.viewBox,c,f,h;return s.height>0&&s.width>0&&r?(f=IA({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:i,tooltipDimension:s.width,viewBox:d,viewBoxDimension:d.width}),h=IA({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:i,tooltipDimension:s.height,viewBox:d,viewBoxDimension:d.height}),c=yK({translateX:f,translateY:h,useTranslate3d:l})):c=pK,{cssProperties:c,cssClasses:gK({translateX:f,translateY:h,coordinate:r})}}function Oc(e){"@babel/helpers - typeof";return Oc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oc(e)}function MA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function RA(e){for(var t=1;tDA||Math.abs(n.height-this.state.lastBoundingBox.height)>DA)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,a=this.props,i=a.active,s=a.allowEscapeViewBox,l=a.animationDuration,d=a.animationEasing,c=a.children,f=a.coordinate,h=a.hasPayload,p=a.isAnimationActive,g=a.offset,x=a.position,b=a.reverseDirection,w=a.useTranslate3d,j=a.viewBox,N=a.wrapperStyle,C=vK({allowEscapeViewBox:s,coordinate:f,offsetTopLeft:g,position:x,reverseDirection:b,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:j}),O=C.cssClasses,P=C.cssProperties,E=RA(RA({transition:p&&i?"transform ".concat(l,"ms ").concat(d):void 0},P),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},N);return U.createElement("div",{tabIndex:-1,className:O,style:E,ref:function(A){n.wrapperNode=A}},c)}}])})(v.PureComponent),PK=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},il={isSsr:PK()};function Tc(e){"@babel/helpers - typeof";return Tc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tc(e)}function LA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function $A(e){for(var t=1;t0;return U.createElement(EK,{allowEscapeViewBox:s,animationDuration:l,animationEasing:d,isAnimationActive:p,active:i,coordinate:f,hasPayload:E,offset:g,position:w,reverseDirection:j,useTranslate3d:N,viewBox:C,wrapperStyle:O},$K(c,$A($A({},this.props),{},{payload:P})))}}])})(v.PureComponent);FC(ta,"displayName","Tooltip");FC(ta,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!il.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var A1,FA;function FK(){if(FA)return A1;FA=1;var e=Oo(),t=function(){return e.Date.now()};return A1=t,A1}var I1,BA;function BK(){if(BA)return I1;BA=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return I1=t,I1}var M1,zA;function zK(){if(zA)return M1;zA=1;var e=BK(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return M1=r,M1}var R1,UA;function u3(){if(UA)return R1;UA=1;var e=zK(),t=Hi(),r=uu(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;function d(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var f=typeof c.valueOf=="function"?c.valueOf():c;c=t(f)?f+"":f}if(typeof c!="string")return c===0?c:+c;c=e(c);var h=i.test(c);return h||s.test(c)?l(c.slice(2),h?2:8):a.test(c)?n:+c}return R1=d,R1}var D1,qA;function UK(){if(qA)return D1;qA=1;var e=Hi(),t=FK(),r=u3(),n="Expected a function",a=Math.max,i=Math.min;function s(l,d,c){var f,h,p,g,x,b,w=0,j=!1,N=!1,C=!0;if(typeof l!="function")throw new TypeError(n);d=r(d)||0,e(c)&&(j=!!c.leading,N="maxWait"in c,p=N?a(r(c.maxWait)||0,d):p,C="trailing"in c?!!c.trailing:C);function O(z){var G=f,H=h;return f=h=void 0,w=z,g=l.apply(H,G),g}function P(z){return w=z,x=setTimeout(A,d),j?O(z):g}function E(z){var G=z-b,H=z-w,W=d-G;return N?i(W,p-H):W}function T(z){var G=z-b,H=z-w;return b===void 0||G>=d||G<0||N&&H>=p}function A(){var z=t();if(T(z))return I(z);x=setTimeout(A,E(z))}function I(z){return x=void 0,C&&f?O(z):(f=h=void 0,g)}function R(){x!==void 0&&clearTimeout(x),w=0,f=b=h=x=void 0}function L(){return x===void 0?g:I(t())}function V(){var z=t(),G=T(z);if(f=arguments,h=this,b=z,G){if(x===void 0)return P(b);if(N)return clearTimeout(x),x=setTimeout(A,d),O(b)}return x===void 0&&(x=setTimeout(A,d)),g}return V.cancel=R,V.flush=L,V}return D1=s,D1}var L1,VA;function qK(){if(VA)return L1;VA=1;var e=UK(),t=Hi(),r="Expected a function";function n(a,i,s){var l=!0,d=!0;if(typeof a!="function")throw new TypeError(r);return t(s)&&(l="leading"in s?!!s.leading:l,d="trailing"in s?!!s.trailing:d),e(a,i,{leading:l,maxWait:i,trailing:d})}return L1=n,L1}var VK=qK();const d3=Wt(VK);function Jd(e){"@babel/helpers - typeof";return Jd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Jd(e)}function WA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Am(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(z=d3(z,b,{trailing:!0,leading:!1}));var G=new ResizeObserver(z),H=P.current.getBoundingClientRect(),W=H.width,q=H.height;return L(W,q),G.observe(P.current),function(){G.disconnect()}},[L,b]);var V=v.useMemo(function(){var z=I.containerWidth,G=I.containerHeight;if(z<0||G<0)return null;Ka(Is(s)||Is(d),`The width(%s) and height(%s) are both fixed numbers, + maybe you don't need to use a ResponsiveContainer.`,s,d),Ka(!r||r>0,"The aspect(%s) must be greater than zero.",r);var H=Is(s)?z:s,W=Is(d)?G:d;r&&r>0&&(H?W=H/r:W&&(H=W*r),p&&W>p&&(W=p)),Ka(H>0||W>0,`The width(%s) and height(%s) of chart should be greater than 0, + please check the style of container, or the props width(%s) and height(%s), + or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the + height and width.`,H,W,s,d,f,h,r);var q=!Array.isArray(g)&&Zo(g.type).endsWith("Chart");return U.Children.map(g,function(M){return U.isValidElement(M)?v.cloneElement(M,Am({width:H,height:W},q?{style:Am({height:"100%",width:"100%",maxHeight:W,maxWidth:H},M.props.style)}:{})):M})},[r,g,d,p,h,f,I,s]);return U.createElement("div",{id:w?"".concat(w):void 0,className:vt("recharts-responsive-container",j),style:Am(Am({},O),{},{width:s,height:d,minWidth:f,minHeight:h,maxHeight:p}),ref:P},V)}),Oy=function(t){return null};Oy.displayName="Cell";function Qd(e){"@babel/helpers - typeof";return Qd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qd(e)}function GA(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Aj(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||il.isSsr)return{width:0,height:0};var n=aX(r),a=JSON.stringify({text:t,copyStyle:n});if(Vl.widthCache[a])return Vl.widthCache[a];try{var i=document.getElementById(YA);i||(i=document.createElement("span"),i.setAttribute("id",YA),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var s=Aj(Aj({},nX),n);Object.assign(i.style,s),i.textContent="".concat(t);var l=i.getBoundingClientRect(),d={width:l.width,height:l.height};return Vl.widthCache[a]=d,++Vl.cacheCount>rX&&(Vl.cacheCount=0,Vl.widthCache={}),d}catch{return{width:0,height:0}}},oX=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function Zd(e){"@babel/helpers - typeof";return Zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zd(e)}function lg(e,t){return cX(e)||lX(e,t)||sX(e,t)||iX()}function iX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sX(e,t){if(e){if(typeof e=="string")return KA(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return KA(e,t)}}function KA(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function jX(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function tI(e,t){return EX(e)||_X(e,t)||CX(e,t)||NX()}function NX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function CX(e,t){if(e){if(typeof e=="string")return rI(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return rI(e,t)}}function rI(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[];return H.reduce(function(W,q){var M=q.word,Y=q.width,F=W[W.length-1];if(F&&(a==null||i||F.width+Y+nq.width?W:q})};if(!f)return g;for(var b="…",w=function(H){var W=h.slice(0,H),q=p3({breakAll:c,style:d,children:W+b}).wordsWithComputedWidth,M=p(q),Y=M.length>s||x(M).width>Number(a);return[Y,M]},j=0,N=h.length-1,C=0,O;j<=N&&C<=h.length-1;){var P=Math.floor((j+N)/2),E=P-1,T=w(E),A=tI(T,2),I=A[0],R=A[1],L=w(P),V=tI(L,1),z=V[0];if(!I&&!z&&(j=P+1),I&&z&&(N=P-1),!I&&z){O=R;break}C++}return O||g},nI=function(t){var r=yt(t)?[]:t.toString().split(m3);return[{words:r}]},OX=function(t){var r=t.width,n=t.scaleToFit,a=t.children,i=t.style,s=t.breakAll,l=t.maxLines;if((r||n)&&!il.isSsr){var d,c,f=p3({breakAll:s,children:a,style:i});if(f){var h=f.wordsWithComputedWidth,p=f.spaceWidth;d=h,c=p}else return nI(a);return PX({breakAll:s,children:a,maxLines:l,style:i},d,c,r,n)}return nI(a)},aI="#808080",Vs=function(t){var r=t.x,n=r===void 0?0:r,a=t.y,i=a===void 0?0:a,s=t.lineHeight,l=s===void 0?"1em":s,d=t.capHeight,c=d===void 0?"0.71em":d,f=t.scaleToFit,h=f===void 0?!1:f,p=t.textAnchor,g=p===void 0?"start":p,x=t.verticalAnchor,b=x===void 0?"end":x,w=t.fill,j=w===void 0?aI:w,N=eI(t,wX),C=v.useMemo(function(){return OX({breakAll:N.breakAll,children:N.children,maxLines:N.maxLines,scaleToFit:h,style:N.style,width:N.width})},[N.breakAll,N.children,N.maxLines,h,N.style,N.width]),O=N.dx,P=N.dy,E=N.angle,T=N.className,A=N.breakAll,I=eI(N,SX);if(!zr(n)||!zr(i))return null;var R=n+(Re(O)?O:0),L=i+(Re(P)?P:0),V;switch(b){case"start":V=$1("calc(".concat(c,")"));break;case"middle":V=$1("calc(".concat((C.length-1)/2," * -").concat(l," + (").concat(c," / 2))"));break;default:V=$1("calc(".concat(C.length-1," * -").concat(l,")"));break}var z=[];if(h){var G=C[0].width,H=N.width;z.push("scale(".concat((Re(H)?H/G:1)/G,")"))}return E&&z.push("rotate(".concat(E,", ").concat(R,", ").concat(L,")")),z.length&&(I.transform=z.join(" ")),U.createElement("text",Ij({},lt(I,!0),{x:R,y:L,className:vt("recharts-text",T),textAnchor:g,fill:j.includes("url")?aI:j}),C.map(function(W,q){var M=W.words.join(A?"":" ");return U.createElement("tspan",{x:R,dy:q===0?V:l,key:"".concat(M,"-").concat(q)},M)}))};function Fi(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function TX(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function BC(e){let t,r,n;e.length!==2?(t=Fi,r=(l,d)=>Fi(e(l),d),n=(l,d)=>e(l)-d):(t=e===Fi||e===TX?e:kX,r=e,n=e);function a(l,d,c=0,f=l.length){if(c>>1;r(l[h],d)<0?c=h+1:f=h}while(c>>1;r(l[h],d)<=0?c=h+1:f=h}while(cc&&n(l[h-1],d)>-n(l[h],d)?h-1:h}return{left:a,center:s,right:i}}function kX(){return 0}function g3(e){return e===null?NaN:+e}function*AX(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const IX=BC(Fi),Bf=IX.right;BC(g3).center;class oI extends Map{constructor(t,r=DX){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[n,a]of t)this.set(n,a)}get(t){return super.get(iI(this,t))}has(t){return super.has(iI(this,t))}set(t,r){return super.set(MX(this,t),r)}delete(t){return super.delete(RX(this,t))}}function iI({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):r}function MX({_intern:e,_key:t},r){const n=t(r);return e.has(n)?e.get(n):(e.set(n,r),r)}function RX({_intern:e,_key:t},r){const n=t(r);return e.has(n)&&(r=e.get(n),e.delete(n)),r}function DX(e){return e!==null&&typeof e=="object"?e.valueOf():e}function LX(e=Fi){if(e===Fi)return y3;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const n=e(t,r);return n||n===0?n:(e(r,r)===0)-(e(t,t)===0)}}function y3(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const $X=Math.sqrt(50),FX=Math.sqrt(10),BX=Math.sqrt(2);function cg(e,t,r){const n=(t-e)/Math.max(0,r),a=Math.floor(Math.log10(n)),i=n/Math.pow(10,a),s=i>=$X?10:i>=FX?5:i>=BX?2:1;let l,d,c;return a<0?(c=Math.pow(10,-a)/s,l=Math.round(e*c),d=Math.round(t*c),l/ct&&--d,c=-c):(c=Math.pow(10,a)*s,l=Math.round(e/c),d=Math.round(t/c),l*ct&&--d),d0))return[];if(e===t)return[e];const n=t=a))return[];const l=i-a+1,d=new Array(l);if(n)if(s<0)for(let c=0;c=n)&&(r=n);return r}function lI(e,t){let r;for(const n of e)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function v3(e,t,r=0,n=1/0,a){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(e.length-1,n)),!(r<=t&&t<=n))return e;for(a=a===void 0?y3:LX(a);n>r;){if(n-r>600){const d=n-r+1,c=t-r+1,f=Math.log(d),h=.5*Math.exp(2*f/3),p=.5*Math.sqrt(f*h*(d-h)/d)*(c-d/2<0?-1:1),g=Math.max(r,Math.floor(t-c*h/d+p)),x=Math.min(n,Math.floor(t+(d-c)*h/d+p));v3(e,t,g,x,a)}const i=e[t];let s=r,l=n;for(pd(e,r,t),a(e[n],i)>0&&pd(e,r,n);s0;)--l}a(e[r],i)===0?pd(e,r,l):(++l,pd(e,l,n)),l<=t&&(r=l+1),t<=l&&(n=l-1)}return e}function pd(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function zX(e,t,r){if(e=Float64Array.from(AX(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return lI(e);if(t>=1)return sI(e);var n,a=(n-1)*t,i=Math.floor(a),s=sI(v3(e,i).subarray(0,i+1)),l=lI(e.subarray(i+1));return s+(l-s)*(a-i)}}function UX(e,t,r=g3){if(!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return+r(e[0],0,e);if(t>=1)return+r(e[n-1],n-1,e);var n,a=(n-1)*t,i=Math.floor(a),s=+r(e[i],i,e),l=+r(e[i+1],i+1,e);return s+(l-s)*(a-i)}}function qX(e,t,r){e=+e,t=+t,r=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+r;for(var n=-1,a=Math.max(0,Math.ceil((t-e)/r))|0,i=new Array(a);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?Mm(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?Mm(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=WX.exec(e))?new Ln(t[1],t[2],t[3],1):(t=HX.exec(e))?new Ln(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=GX.exec(e))?Mm(t[1],t[2],t[3],t[4]):(t=YX.exec(e))?Mm(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=KX.exec(e))?pI(t[1],t[2]/100,t[3]/100,1):(t=XX.exec(e))?pI(t[1],t[2]/100,t[3]/100,t[4]):cI.hasOwnProperty(e)?fI(cI[e]):e==="transparent"?new Ln(NaN,NaN,NaN,0):null}function fI(e){return new Ln(e>>16&255,e>>8&255,e&255,1)}function Mm(e,t,r,n){return n<=0&&(e=t=r=NaN),new Ln(e,t,r,n)}function ZX(e){return e instanceof zf||(e=nf(e)),e?(e=e.rgb(),new Ln(e.r,e.g,e.b,e.opacity)):new Ln}function $j(e,t,r,n){return arguments.length===1?ZX(e):new Ln(e,t,r,n??1)}function Ln(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}UC(Ln,$j,b3(zf,{brighter(e){return e=e==null?ug:Math.pow(ug,e),new Ln(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tf:Math.pow(tf,e),new Ln(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ln($s(this.r),$s(this.g),$s(this.b),dg(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:hI,formatHex:hI,formatHex8:eJ,formatRgb:mI,toString:mI}));function hI(){return`#${Ms(this.r)}${Ms(this.g)}${Ms(this.b)}`}function eJ(){return`#${Ms(this.r)}${Ms(this.g)}${Ms(this.b)}${Ms((isNaN(this.opacity)?1:this.opacity)*255)}`}function mI(){const e=dg(this.opacity);return`${e===1?"rgb(":"rgba("}${$s(this.r)}, ${$s(this.g)}, ${$s(this.b)}${e===1?")":`, ${e})`}`}function dg(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function $s(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ms(e){return e=$s(e),(e<16?"0":"")+e.toString(16)}function pI(e,t,r,n){return n<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new Ya(e,t,r,n)}function w3(e){if(e instanceof Ya)return new Ya(e.h,e.s,e.l,e.opacity);if(e instanceof zf||(e=nf(e)),!e)return new Ya;if(e instanceof Ya)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,a=Math.min(t,r,n),i=Math.max(t,r,n),s=NaN,l=i-a,d=(i+a)/2;return l?(t===i?s=(r-n)/l+(r0&&d<1?0:s,new Ya(s,l,d,e.opacity)}function tJ(e,t,r,n){return arguments.length===1?w3(e):new Ya(e,t,r,n??1)}function Ya(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}UC(Ya,tJ,b3(zf,{brighter(e){return e=e==null?ug:Math.pow(ug,e),new Ya(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tf:Math.pow(tf,e),new Ya(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*t,a=2*r-n;return new Ln(F1(e>=240?e-240:e+120,a,n),F1(e,a,n),F1(e<120?e+240:e-120,a,n),this.opacity)},clamp(){return new Ya(gI(this.h),Rm(this.s),Rm(this.l),dg(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=dg(this.opacity);return`${e===1?"hsl(":"hsla("}${gI(this.h)}, ${Rm(this.s)*100}%, ${Rm(this.l)*100}%${e===1?")":`, ${e})`}`}}));function gI(e){return e=(e||0)%360,e<0?e+360:e}function Rm(e){return Math.max(0,Math.min(1,e||0))}function F1(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const qC=e=>()=>e;function rJ(e,t){return function(r){return e+r*t}}function nJ(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function aJ(e){return(e=+e)==1?S3:function(t,r){return r-t?nJ(t,r,e):qC(isNaN(t)?r:t)}}function S3(e,t){var r=t-e;return r?rJ(e,r):qC(isNaN(e)?t:e)}const yI=(function e(t){var r=aJ(t);function n(a,i){var s=r((a=$j(a)).r,(i=$j(i)).r),l=r(a.g,i.g),d=r(a.b,i.b),c=S3(a.opacity,i.opacity);return function(f){return a.r=s(f),a.g=l(f),a.b=d(f),a.opacity=c(f),a+""}}return n.gamma=e,n})(1);function oJ(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,n=t.slice(),a;return function(i){for(a=0;ar&&(i=t.slice(r,i),l[s]?l[s]+=i:l[++s]=i),(n=n[0])===(a=a[0])?l[s]?l[s]+=a:l[++s]=a:(l[++s]=null,d.push({i:s,x:fg(n,a)})),r=B1.lastIndex;return rt&&(r=e,e=t,t=r),function(n){return Math.max(e,Math.min(t,n))}}function gJ(e,t,r){var n=e[0],a=e[1],i=t[0],s=t[1];return a2?yJ:gJ,d=c=null,h}function h(p){return p==null||isNaN(p=+p)?i:(d||(d=l(e.map(n),t,r)))(n(s(p)))}return h.invert=function(p){return s(a((c||(c=l(t,e.map(n),fg)))(p)))},h.domain=function(p){return arguments.length?(e=Array.from(p,hg),f()):e.slice()},h.range=function(p){return arguments.length?(t=Array.from(p),f()):t.slice()},h.rangeRound=function(p){return t=Array.from(p),r=VC,f()},h.clamp=function(p){return arguments.length?(s=p?!0:Nn,f()):s!==Nn},h.interpolate=function(p){return arguments.length?(r=p,f()):r},h.unknown=function(p){return arguments.length?(i=p,h):i},function(p,g){return n=p,a=g,f()}}function WC(){return Ty()(Nn,Nn)}function vJ(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function mg(e,t){if(!isFinite(e)||e===0)return null;var r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),n=e.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+e.slice(r+1)]}function kc(e){return e=mg(Math.abs(e)),e?e[1]:NaN}function xJ(e,t){return function(r,n){for(var a=r.length,i=[],s=0,l=e[0],d=0;a>0&&l>0&&(d+l+1>n&&(l=Math.max(1,n-d)),i.push(r.substring(a-=l,a+l)),!((d+=l+1)>n));)l=e[s=(s+1)%e.length];return i.reverse().join(t)}}function bJ(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var wJ=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function af(e){if(!(t=wJ.exec(e)))throw new Error("invalid format: "+e);var t;return new HC({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}af.prototype=HC.prototype;function HC(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}HC.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function SJ(e){e:for(var t=e.length,r=1,n=-1,a;r0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(a+1):e}var pg;function jJ(e,t){var r=mg(e,t);if(!r)return pg=void 0,e.toPrecision(t);var n=r[0],a=r[1],i=a-(pg=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,s=n.length;return i===s?n:i>s?n+new Array(i-s+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+mg(e,Math.max(0,t+i-1))[0]}function xI(e,t){var r=mg(e,t);if(!r)return e+"";var n=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+n:n.length>a+1?n.slice(0,a+1)+"."+n.slice(a+1):n+new Array(a-n.length+2).join("0")}const bI={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:vJ,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>xI(e*100,t),r:xI,s:jJ,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function wI(e){return e}var SI=Array.prototype.map,jI=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function NJ(e){var t=e.grouping===void 0||e.thousands===void 0?wI:xJ(SI.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?wI:bJ(SI.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",d=e.nan===void 0?"NaN":e.nan+"";function c(h,p){h=af(h);var g=h.fill,x=h.align,b=h.sign,w=h.symbol,j=h.zero,N=h.width,C=h.comma,O=h.precision,P=h.trim,E=h.type;E==="n"?(C=!0,E="g"):bI[E]||(O===void 0&&(O=12),P=!0,E="g"),(j||g==="0"&&x==="=")&&(j=!0,g="0",x="=");var T=(p&&p.prefix!==void 0?p.prefix:"")+(w==="$"?r:w==="#"&&/[boxX]/.test(E)?"0"+E.toLowerCase():""),A=(w==="$"?n:/[%p]/.test(E)?s:"")+(p&&p.suffix!==void 0?p.suffix:""),I=bI[E],R=/[defgprs%]/.test(E);O=O===void 0?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,O)):Math.max(0,Math.min(20,O));function L(V){var z=T,G=A,H,W,q;if(E==="c")G=I(V)+G,V="";else{V=+V;var M=V<0||1/V<0;if(V=isNaN(V)?d:I(Math.abs(V),O),P&&(V=SJ(V)),M&&+V==0&&b!=="+"&&(M=!1),z=(M?b==="("?b:l:b==="-"||b==="("?"":b)+z,G=(E==="s"&&!isNaN(V)&&pg!==void 0?jI[8+pg/3]:"")+G+(M&&b==="("?")":""),R){for(H=-1,W=V.length;++Hq||q>57){G=(q===46?a+V.slice(H+1):V.slice(H))+G,V=V.slice(0,H);break}}}C&&!j&&(V=t(V,1/0));var Y=z.length+V.length+G.length,F=Y>1)+z+V+G+F.slice(Y);break;default:V=F+z+V+G;break}return i(V)}return L.toString=function(){return h+""},L}function f(h,p){var g=Math.max(-8,Math.min(8,Math.floor(kc(p)/3)))*3,x=Math.pow(10,-g),b=c((h=af(h),h.type="f",h),{suffix:jI[8+g/3]});return function(w){return b(x*w)}}return{format:c,formatPrefix:f}}var Dm,GC,j3;CJ({thousands:",",grouping:[3],currency:["$",""]});function CJ(e){return Dm=NJ(e),GC=Dm.format,j3=Dm.formatPrefix,Dm}function _J(e){return Math.max(0,-kc(Math.abs(e)))}function EJ(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(kc(t)/3)))*3-kc(Math.abs(e)))}function PJ(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,kc(t)-kc(e))+1}function N3(e,t,r,n){var a=Dj(e,t,r),i;switch(n=af(n??",f"),n.type){case"s":{var s=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(i=EJ(a,s))&&(n.precision=i),j3(n,s)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=PJ(a,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=_J(a))&&(n.precision=i-(n.type==="%")*2);break}}return GC(n)}function Gi(e){var t=e.domain;return e.ticks=function(r){var n=t();return Mj(n[0],n[n.length-1],r??10)},e.tickFormat=function(r,n){var a=t();return N3(a[0],a[a.length-1],r??10,n)},e.nice=function(r){r==null&&(r=10);var n=t(),a=0,i=n.length-1,s=n[a],l=n[i],d,c,f=10;for(l0;){if(c=Rj(s,l,r),c===d)return n[a]=s,n[i]=l,t(n);if(c>0)s=Math.floor(s/c)*c,l=Math.ceil(l/c)*c;else if(c<0)s=Math.ceil(s*c)/c,l=Math.floor(l*c)/c;else break;d=c}return e},e}function gg(){var e=WC();return e.copy=function(){return Uf(e,gg())},Ra.apply(e,arguments),Gi(e)}function C3(e){var t;function r(n){return n==null||isNaN(n=+n)?t:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(e=Array.from(n,hg),r):e.slice()},r.unknown=function(n){return arguments.length?(t=n,r):t},r.copy=function(){return C3(e).unknown(t)},e=arguments.length?Array.from(e,hg):[0,1],Gi(r)}function _3(e,t){e=e.slice();var r=0,n=e.length-1,a=e[r],i=e[n],s;return iMath.pow(e,t)}function IJ(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function _I(e){return(t,r)=>-e(-t,r)}function YC(e){const t=e(NI,CI),r=t.domain;let n=10,a,i;function s(){return a=IJ(n),i=AJ(n),r()[0]<0?(a=_I(a),i=_I(i),e(OJ,TJ)):e(NI,CI),t}return t.base=function(l){return arguments.length?(n=+l,s()):n},t.domain=function(l){return arguments.length?(r(l),s()):r()},t.ticks=l=>{const d=r();let c=d[0],f=d[d.length-1];const h=f0){for(;p<=g;++p)for(x=1;xf)break;j.push(b)}}else for(;p<=g;++p)for(x=n-1;x>=1;--x)if(b=p>0?x/i(-p):x*i(p),!(bf)break;j.push(b)}j.length*2{if(l==null&&(l=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=af(d)).precision==null&&(d.trim=!0),d=GC(d)),l===1/0)return d;const c=Math.max(1,n*l/t.ticks().length);return f=>{let h=f/i(Math.round(a(f)));return h*nr(_3(r(),{floor:l=>i(Math.floor(a(l))),ceil:l=>i(Math.ceil(a(l)))})),t}function E3(){const e=YC(Ty()).domain([1,10]);return e.copy=()=>Uf(e,E3()).base(e.base()),Ra.apply(e,arguments),e}function EI(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function PI(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function KC(e){var t=1,r=e(EI(t),PI(t));return r.constant=function(n){return arguments.length?e(EI(t=+n),PI(t)):t},Gi(r)}function P3(){var e=KC(Ty());return e.copy=function(){return Uf(e,P3()).constant(e.constant())},Ra.apply(e,arguments)}function OI(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function MJ(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function RJ(e){return e<0?-e*e:e*e}function XC(e){var t=e(Nn,Nn),r=1;function n(){return r===1?e(Nn,Nn):r===.5?e(MJ,RJ):e(OI(r),OI(1/r))}return t.exponent=function(a){return arguments.length?(r=+a,n()):r},Gi(t)}function JC(){var e=XC(Ty());return e.copy=function(){return Uf(e,JC()).exponent(e.exponent())},Ra.apply(e,arguments),e}function DJ(){return JC.apply(null,arguments).exponent(.5)}function TI(e){return Math.sign(e)*e*e}function LJ(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function O3(){var e=WC(),t=[0,1],r=!1,n;function a(i){var s=LJ(e(i));return isNaN(s)?n:r?Math.round(s):s}return a.invert=function(i){return e.invert(TI(i))},a.domain=function(i){return arguments.length?(e.domain(i),a):e.domain()},a.range=function(i){return arguments.length?(e.range((t=Array.from(i,hg)).map(TI)),a):t.slice()},a.rangeRound=function(i){return a.range(i).round(!0)},a.round=function(i){return arguments.length?(r=!!i,a):r},a.clamp=function(i){return arguments.length?(e.clamp(i),a):e.clamp()},a.unknown=function(i){return arguments.length?(n=i,a):n},a.copy=function(){return O3(e.domain(),t).round(r).clamp(e.clamp()).unknown(n)},Ra.apply(a,arguments),Gi(a)}function T3(){var e=[],t=[],r=[],n;function a(){var s=0,l=Math.max(1,t.length);for(r=new Array(l-1);++s0?r[l-1]:e[0],l=r?[n[r-1],t]:[n[c-1],n[c]]},s.unknown=function(d){return arguments.length&&(i=d),s},s.thresholds=function(){return n.slice()},s.copy=function(){return k3().domain([e,t]).range(a).unknown(i)},Ra.apply(Gi(s),arguments)}function A3(){var e=[.5],t=[0,1],r,n=1;function a(i){return i!=null&&i<=i?t[Bf(e,i,0,n)]:r}return a.domain=function(i){return arguments.length?(e=Array.from(i),n=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(i){return arguments.length?(t=Array.from(i),n=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(i){var s=t.indexOf(i);return[e[s-1],e[s]]},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return A3().domain(e).range(t).unknown(r)},Ra.apply(a,arguments)}const z1=new Date,U1=new Date;function Ur(e,t,r,n){function a(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(e(i=new Date(+i)),i),a.ceil=i=>(e(i=new Date(i-1)),t(i,1),e(i),i),a.round=i=>{const s=a(i),l=a.ceil(i);return i-s(t(i=new Date(+i),s==null?1:Math.floor(s)),i),a.range=(i,s,l)=>{const d=[];if(i=a.ceil(i),l=l==null?1:Math.floor(l),!(i0))return d;let c;do d.push(c=new Date(+i)),t(i,l),e(i);while(cUr(s=>{if(s>=s)for(;e(s),!i(s);)s.setTime(s-1)},(s,l)=>{if(s>=s)if(l<0)for(;++l<=0;)for(;t(s,-1),!i(s););else for(;--l>=0;)for(;t(s,1),!i(s););}),r&&(a.count=(i,s)=>(z1.setTime(+i),U1.setTime(+s),e(z1),e(U1),Math.floor(r(z1,U1))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(n?s=>n(s)%i===0:s=>a.count(0,s)%i===0):a)),a}const yg=Ur(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);yg.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Ur(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):yg);yg.range;const Go=1e3,Pa=Go*60,Yo=Pa*60,ai=Yo*24,QC=ai*7,kI=ai*30,q1=ai*365,Rs=Ur(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Go)},(e,t)=>(t-e)/Go,e=>e.getUTCSeconds());Rs.range;const ZC=Ur(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Go)},(e,t)=>{e.setTime(+e+t*Pa)},(e,t)=>(t-e)/Pa,e=>e.getMinutes());ZC.range;const e_=Ur(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Pa)},(e,t)=>(t-e)/Pa,e=>e.getUTCMinutes());e_.range;const t_=Ur(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Go-e.getMinutes()*Pa)},(e,t)=>{e.setTime(+e+t*Yo)},(e,t)=>(t-e)/Yo,e=>e.getHours());t_.range;const r_=Ur(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Yo)},(e,t)=>(t-e)/Yo,e=>e.getUTCHours());r_.range;const qf=Ur(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Pa)/ai,e=>e.getDate()-1);qf.range;const ky=Ur(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ai,e=>e.getUTCDate()-1);ky.range;const I3=Ur(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/ai,e=>Math.floor(e/ai));I3.range;function sl(e){return Ur(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*Pa)/QC)}const Ay=sl(0),vg=sl(1),$J=sl(2),FJ=sl(3),Ac=sl(4),BJ=sl(5),zJ=sl(6);Ay.range;vg.range;$J.range;FJ.range;Ac.range;BJ.range;zJ.range;function ll(e){return Ur(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/QC)}const Iy=ll(0),xg=ll(1),UJ=ll(2),qJ=ll(3),Ic=ll(4),VJ=ll(5),WJ=ll(6);Iy.range;xg.range;UJ.range;qJ.range;Ic.range;VJ.range;WJ.range;const n_=Ur(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());n_.range;const a_=Ur(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());a_.range;const oi=Ur(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());oi.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ur(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});oi.range;const ii=Ur(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());ii.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ur(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});ii.range;function M3(e,t,r,n,a,i){const s=[[Rs,1,Go],[Rs,5,5*Go],[Rs,15,15*Go],[Rs,30,30*Go],[i,1,Pa],[i,5,5*Pa],[i,15,15*Pa],[i,30,30*Pa],[a,1,Yo],[a,3,3*Yo],[a,6,6*Yo],[a,12,12*Yo],[n,1,ai],[n,2,2*ai],[r,1,QC],[t,1,kI],[t,3,3*kI],[e,1,q1]];function l(c,f,h){const p=fw).right(s,p);if(g===s.length)return e.every(Dj(c/q1,f/q1,h));if(g===0)return yg.every(Math.max(Dj(c,f,h),1));const[x,b]=s[p/s[g-1][2]53)return null;"w"in Z||(Z.w=1),"Z"in Z?(Ne=W1(gd(Z.y,0,1)),qe=Ne.getUTCDay(),Ne=qe>4||qe===0?xg.ceil(Ne):xg(Ne),Ne=ky.offset(Ne,(Z.V-1)*7),Z.y=Ne.getUTCFullYear(),Z.m=Ne.getUTCMonth(),Z.d=Ne.getUTCDate()+(Z.w+6)%7):(Ne=V1(gd(Z.y,0,1)),qe=Ne.getDay(),Ne=qe>4||qe===0?vg.ceil(Ne):vg(Ne),Ne=qf.offset(Ne,(Z.V-1)*7),Z.y=Ne.getFullYear(),Z.m=Ne.getMonth(),Z.d=Ne.getDate()+(Z.w+6)%7)}else("W"in Z||"U"in Z)&&("w"in Z||(Z.w="u"in Z?Z.u%7:"W"in Z?1:0),qe="Z"in Z?W1(gd(Z.y,0,1)).getUTCDay():V1(gd(Z.y,0,1)).getDay(),Z.m=0,Z.d="W"in Z?(Z.w+6)%7+Z.W*7-(qe+5)%7:Z.w+Z.U*7-(qe+6)%7);return"Z"in Z?(Z.H+=Z.Z/100|0,Z.M+=Z.Z%100,W1(Z)):V1(Z)}}function A(se,fe,be,Z){for(var Se=0,Ne=fe.length,qe=be.length,De,He;Se=qe)return-1;if(De=fe.charCodeAt(Se++),De===37){if(De=fe.charAt(Se++),He=P[De in AI?fe.charAt(Se++):De],!He||(Z=He(se,be,Z))<0)return-1}else if(De!=be.charCodeAt(Z++))return-1}return Z}function I(se,fe,be){var Z=c.exec(fe.slice(be));return Z?(se.p=f.get(Z[0].toLowerCase()),be+Z[0].length):-1}function R(se,fe,be){var Z=g.exec(fe.slice(be));return Z?(se.w=x.get(Z[0].toLowerCase()),be+Z[0].length):-1}function L(se,fe,be){var Z=h.exec(fe.slice(be));return Z?(se.w=p.get(Z[0].toLowerCase()),be+Z[0].length):-1}function V(se,fe,be){var Z=j.exec(fe.slice(be));return Z?(se.m=N.get(Z[0].toLowerCase()),be+Z[0].length):-1}function z(se,fe,be){var Z=b.exec(fe.slice(be));return Z?(se.m=w.get(Z[0].toLowerCase()),be+Z[0].length):-1}function G(se,fe,be){return A(se,t,fe,be)}function H(se,fe,be){return A(se,r,fe,be)}function W(se,fe,be){return A(se,n,fe,be)}function q(se){return s[se.getDay()]}function M(se){return i[se.getDay()]}function Y(se){return d[se.getMonth()]}function F(se){return l[se.getMonth()]}function D(se){return a[+(se.getHours()>=12)]}function $(se){return 1+~~(se.getMonth()/3)}function K(se){return s[se.getUTCDay()]}function J(se){return i[se.getUTCDay()]}function oe(se){return d[se.getUTCMonth()]}function re(se){return l[se.getUTCMonth()]}function Q(se){return a[+(se.getUTCHours()>=12)]}function ce(se){return 1+~~(se.getUTCMonth()/3)}return{format:function(se){var fe=E(se+="",C);return fe.toString=function(){return se},fe},parse:function(se){var fe=T(se+="",!1);return fe.toString=function(){return se},fe},utcFormat:function(se){var fe=E(se+="",O);return fe.toString=function(){return se},fe},utcParse:function(se){var fe=T(se+="",!0);return fe.toString=function(){return se},fe}}}var AI={"-":"",_:" ",0:"0"},Xr=/^\s*\d+/,JJ=/^%/,QJ=/[\\^$*+?|[\]().{}]/g;function Ut(e,t,r){var n=e<0?"-":"",a=(n?-e:e)+"",i=a.length;return n+(i[t.toLowerCase(),r]))}function eQ(e,t,r){var n=Xr.exec(t.slice(r,r+1));return n?(e.w=+n[0],r+n[0].length):-1}function tQ(e,t,r){var n=Xr.exec(t.slice(r,r+1));return n?(e.u=+n[0],r+n[0].length):-1}function rQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.U=+n[0],r+n[0].length):-1}function nQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.V=+n[0],r+n[0].length):-1}function aQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.W=+n[0],r+n[0].length):-1}function II(e,t,r){var n=Xr.exec(t.slice(r,r+4));return n?(e.y=+n[0],r+n[0].length):-1}function MI(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function oQ(e,t,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function iQ(e,t,r){var n=Xr.exec(t.slice(r,r+1));return n?(e.q=n[0]*3-3,r+n[0].length):-1}function sQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.m=n[0]-1,r+n[0].length):-1}function RI(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.d=+n[0],r+n[0].length):-1}function lQ(e,t,r){var n=Xr.exec(t.slice(r,r+3));return n?(e.m=0,e.d=+n[0],r+n[0].length):-1}function DI(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.H=+n[0],r+n[0].length):-1}function cQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.M=+n[0],r+n[0].length):-1}function uQ(e,t,r){var n=Xr.exec(t.slice(r,r+2));return n?(e.S=+n[0],r+n[0].length):-1}function dQ(e,t,r){var n=Xr.exec(t.slice(r,r+3));return n?(e.L=+n[0],r+n[0].length):-1}function fQ(e,t,r){var n=Xr.exec(t.slice(r,r+6));return n?(e.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function hQ(e,t,r){var n=JJ.exec(t.slice(r,r+1));return n?r+n[0].length:-1}function mQ(e,t,r){var n=Xr.exec(t.slice(r));return n?(e.Q=+n[0],r+n[0].length):-1}function pQ(e,t,r){var n=Xr.exec(t.slice(r));return n?(e.s=+n[0],r+n[0].length):-1}function LI(e,t){return Ut(e.getDate(),t,2)}function gQ(e,t){return Ut(e.getHours(),t,2)}function yQ(e,t){return Ut(e.getHours()%12||12,t,2)}function vQ(e,t){return Ut(1+qf.count(oi(e),e),t,3)}function R3(e,t){return Ut(e.getMilliseconds(),t,3)}function xQ(e,t){return R3(e,t)+"000"}function bQ(e,t){return Ut(e.getMonth()+1,t,2)}function wQ(e,t){return Ut(e.getMinutes(),t,2)}function SQ(e,t){return Ut(e.getSeconds(),t,2)}function jQ(e){var t=e.getDay();return t===0?7:t}function NQ(e,t){return Ut(Ay.count(oi(e)-1,e),t,2)}function D3(e){var t=e.getDay();return t>=4||t===0?Ac(e):Ac.ceil(e)}function CQ(e,t){return e=D3(e),Ut(Ac.count(oi(e),e)+(oi(e).getDay()===4),t,2)}function _Q(e){return e.getDay()}function EQ(e,t){return Ut(vg.count(oi(e)-1,e),t,2)}function PQ(e,t){return Ut(e.getFullYear()%100,t,2)}function OQ(e,t){return e=D3(e),Ut(e.getFullYear()%100,t,2)}function TQ(e,t){return Ut(e.getFullYear()%1e4,t,4)}function kQ(e,t){var r=e.getDay();return e=r>=4||r===0?Ac(e):Ac.ceil(e),Ut(e.getFullYear()%1e4,t,4)}function AQ(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Ut(t/60|0,"0",2)+Ut(t%60,"0",2)}function $I(e,t){return Ut(e.getUTCDate(),t,2)}function IQ(e,t){return Ut(e.getUTCHours(),t,2)}function MQ(e,t){return Ut(e.getUTCHours()%12||12,t,2)}function RQ(e,t){return Ut(1+ky.count(ii(e),e),t,3)}function L3(e,t){return Ut(e.getUTCMilliseconds(),t,3)}function DQ(e,t){return L3(e,t)+"000"}function LQ(e,t){return Ut(e.getUTCMonth()+1,t,2)}function $Q(e,t){return Ut(e.getUTCMinutes(),t,2)}function FQ(e,t){return Ut(e.getUTCSeconds(),t,2)}function BQ(e){var t=e.getUTCDay();return t===0?7:t}function zQ(e,t){return Ut(Iy.count(ii(e)-1,e),t,2)}function $3(e){var t=e.getUTCDay();return t>=4||t===0?Ic(e):Ic.ceil(e)}function UQ(e,t){return e=$3(e),Ut(Ic.count(ii(e),e)+(ii(e).getUTCDay()===4),t,2)}function qQ(e){return e.getUTCDay()}function VQ(e,t){return Ut(xg.count(ii(e)-1,e),t,2)}function WQ(e,t){return Ut(e.getUTCFullYear()%100,t,2)}function HQ(e,t){return e=$3(e),Ut(e.getUTCFullYear()%100,t,2)}function GQ(e,t){return Ut(e.getUTCFullYear()%1e4,t,4)}function YQ(e,t){var r=e.getUTCDay();return e=r>=4||r===0?Ic(e):Ic.ceil(e),Ut(e.getUTCFullYear()%1e4,t,4)}function KQ(){return"+0000"}function FI(){return"%"}function BI(e){return+e}function zI(e){return Math.floor(+e/1e3)}var Wl,F3,B3;XQ({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function XQ(e){return Wl=XJ(e),F3=Wl.format,Wl.parse,B3=Wl.utcFormat,Wl.utcParse,Wl}function JQ(e){return new Date(e)}function QQ(e){return e instanceof Date?+e:+new Date(+e)}function o_(e,t,r,n,a,i,s,l,d,c){var f=WC(),h=f.invert,p=f.domain,g=c(".%L"),x=c(":%S"),b=c("%I:%M"),w=c("%I %p"),j=c("%a %d"),N=c("%b %d"),C=c("%B"),O=c("%Y");function P(E){return(d(E)t(a/(e.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,i)=>zX(e,i/n))},r.copy=function(){return V3(t).domain(e)},di.apply(r,arguments)}function Ry(){var e=0,t=.5,r=1,n=1,a,i,s,l,d,c=Nn,f,h=!1,p;function g(b){return isNaN(b=+b)?p:(b=.5+((b=+f(b))-i)*(n*br}return G1=e,G1}var Y1,WI;function nZ(){if(WI)return Y1;WI=1;var e=Dy(),t=Y3(),r=hu();function n(a){return a&&a.length?e(a,r,t):void 0}return Y1=n,Y1}var aZ=nZ();const Ly=Wt(aZ);var K1,HI;function K3(){if(HI)return K1;HI=1;function e(t,r){return te.e^i.s<0?1:-1;for(n=i.d.length,a=e.d.length,t=0,r=ne.d[t]^i.s<0?1:-1;return n===a?0:n>a^i.s<0?1:-1};We.decimalPlaces=We.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*dr;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};We.dividedBy=We.div=function(e){return ei(this,new this.constructor(e))};We.dividedToIntegerBy=We.idiv=function(e){var t=this,r=t.constructor;return Zt(ei(t,new r(e),0,1),r.precision)};We.equals=We.eq=function(e){return!this.cmp(e)};We.exponent=function(){return Ar(this)};We.greaterThan=We.gt=function(e){return this.cmp(e)>0};We.greaterThanOrEqualTo=We.gte=function(e){return this.cmp(e)>=0};We.isInteger=We.isint=function(){return this.e>this.d.length-2};We.isNegative=We.isneg=function(){return this.s<0};We.isPositive=We.ispos=function(){return this.s>0};We.isZero=function(){return this.s===0};We.lessThan=We.lt=function(e){return this.cmp(e)<0};We.lessThanOrEqualTo=We.lte=function(e){return this.cmp(e)<1};We.logarithm=We.log=function(e){var t,r=this,n=r.constructor,a=n.precision,i=a+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(aa))throw Error(Ta+"NaN");if(r.s<1)throw Error(Ta+(r.s?"NaN":"-Infinity"));return r.eq(aa)?new n(0):(pr=!1,t=ei(of(r,i),of(e,i),i),pr=!0,Zt(t,a))};We.minus=We.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?Z3(t,e):J3(t,(e.s=-e.s,e))};We.modulo=We.mod=function(e){var t,r=this,n=r.constructor,a=n.precision;if(e=new n(e),!e.s)throw Error(Ta+"NaN");return r.s?(pr=!1,t=ei(r,e,0,1).times(e),pr=!0,r.minus(t)):Zt(new n(r),a)};We.naturalExponential=We.exp=function(){return Q3(this)};We.naturalLogarithm=We.ln=function(){return of(this)};We.negated=We.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};We.plus=We.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?J3(t,e):Z3(t,(e.s=-e.s,e))};We.precision=We.sd=function(e){var t,r,n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Fs+e);if(t=Ar(a)+1,n=a.d.length-1,r=n*dr+1,n=a.d[n],n){for(;n%10==0;n/=10)r--;for(n=a.d[0];n>=10;n/=10)r++}return e&&t>r?t:r};We.squareRoot=We.sqrt=function(){var e,t,r,n,a,i,s,l=this,d=l.constructor;if(l.s<1){if(!l.s)return new d(0);throw Error(Ta+"NaN")}for(e=Ar(l),pr=!1,a=Math.sqrt(+l),a==0||a==1/0?(t=po(l.d),(t.length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=gu((e+1)/2)-(e<0||e%2),a==1/0?t="5e"+e:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new d(t)):n=new d(a.toString()),r=d.precision,a=s=r+3;;)if(i=n,n=i.plus(ei(l,i,s+2)).times(.5),po(i.d).slice(0,s)===(t=po(n.d)).slice(0,s)){if(t=t.slice(s-3,s+1),a==s&&t=="4999"){if(Zt(i,r+1,0),i.times(i).eq(l)){n=i;break}}else if(t!="9999")break;s+=4}return pr=!0,Zt(n,r)};We.times=We.mul=function(e){var t,r,n,a,i,s,l,d,c,f=this,h=f.constructor,p=f.d,g=(e=new h(e)).d;if(!f.s||!e.s)return new h(0);for(e.s*=f.s,r=f.e+e.e,d=p.length,c=g.length,d=0;){for(t=0,a=d+n;a>n;)l=i[a]+g[n]*p[a-n-1]+t,i[a--]=l%Gr|0,t=l/Gr|0;i[a]=(i[a]+t)%Gr|0}for(;!i[--s];)i.pop();return t?++r:i.shift(),e.d=i,e.e=r,pr?Zt(e,h.precision):e};We.toDecimalPlaces=We.todp=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(wo(e,0,pu),t===void 0?t=n.rounding:wo(t,0,8),Zt(r,e+Ar(r)+1,t))};We.toExponential=function(e,t){var r,n=this,a=n.constructor;return e===void 0?r=Ws(n,!0):(wo(e,0,pu),t===void 0?t=a.rounding:wo(t,0,8),n=Zt(new a(n),e+1,t),r=Ws(n,!0,e+1)),r};We.toFixed=function(e,t){var r,n,a=this,i=a.constructor;return e===void 0?Ws(a):(wo(e,0,pu),t===void 0?t=i.rounding:wo(t,0,8),n=Zt(new i(a),e+Ar(a)+1,t),r=Ws(n.abs(),!1,e+Ar(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};We.toInteger=We.toint=function(){var e=this,t=e.constructor;return Zt(new t(e),Ar(e)+1,t.rounding)};We.toNumber=function(){return+this};We.toPower=We.pow=function(e){var t,r,n,a,i,s,l=this,d=l.constructor,c=12,f=+(e=new d(e));if(!e.s)return new d(aa);if(l=new d(l),!l.s){if(e.s<1)throw Error(Ta+"Infinity");return l}if(l.eq(aa))return l;if(n=d.precision,e.eq(aa))return Zt(l,n);if(t=e.e,r=e.d.length-1,s=t>=r,i=l.s,s){if((r=f<0?-f:f)<=X3){for(a=new d(aa),t=Math.ceil(n/dr+4),pr=!1;r%2&&(a=a.times(l),QI(a.d,t)),r=gu(r/2),r!==0;)l=l.times(l),QI(l.d,t);return pr=!0,e.s<0?new d(aa).div(a):Zt(a,n)}}else if(i<0)throw Error(Ta+"NaN");return i=i<0&&e.d[Math.max(t,r)]&1?-1:1,l.s=1,pr=!1,a=e.times(of(l,n+c)),pr=!0,a=Q3(a),a.s=i,a};We.toPrecision=function(e,t){var r,n,a=this,i=a.constructor;return e===void 0?(r=Ar(a),n=Ws(a,r<=i.toExpNeg||r>=i.toExpPos)):(wo(e,1,pu),t===void 0?t=i.rounding:wo(t,0,8),a=Zt(new i(a),e,t),r=Ar(a),n=Ws(a,e<=r||r<=i.toExpNeg,e)),n};We.toSignificantDigits=We.tosd=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(wo(e,1,pu),t===void 0?t=n.rounding:wo(t,0,8)),Zt(new n(r),e,t)};We.toString=We.valueOf=We.val=We.toJSON=We[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=Ar(e),r=e.constructor;return Ws(e,t<=r.toExpNeg||t>=r.toExpPos)};function J3(e,t){var r,n,a,i,s,l,d,c,f=e.constructor,h=f.precision;if(!e.s||!t.s)return t.s||(t=new f(e)),pr?Zt(t,h):t;if(d=e.d,c=t.d,s=e.e,a=t.e,d=d.slice(),i=s-a,i){for(i<0?(n=d,i=-i,l=c.length):(n=c,a=s,l=d.length),s=Math.ceil(h/dr),l=s>l?s+1:l+1,i>l&&(i=l,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(l=d.length,i=c.length,l-i<0&&(i=l,n=c,c=d,d=n),r=0;i;)r=(d[--i]=d[i]+c[i]+r)/Gr|0,d[i]%=Gr;for(r&&(d.unshift(r),++a),l=d.length;d[--l]==0;)d.pop();return t.d=d,t.e=a,pr?Zt(t,h):t}function wo(e,t,r){if(e!==~~e||er)throw Error(Fs+e)}function po(e){var t,r,n,a=e.length-1,i="",s=e[0];if(a>0){for(i+=s,t=1;ts?1:-1;else for(l=d=0;la[l]?1:-1;break}return d}function r(n,a,i){for(var s=0;i--;)n[i]-=s,s=n[i]1;)n.shift()}return function(n,a,i,s){var l,d,c,f,h,p,g,x,b,w,j,N,C,O,P,E,T,A,I=n.constructor,R=n.s==a.s?1:-1,L=n.d,V=a.d;if(!n.s)return new I(n);if(!a.s)throw Error(Ta+"Division by zero");for(d=n.e-a.e,T=V.length,P=L.length,g=new I(R),x=g.d=[],c=0;V[c]==(L[c]||0);)++c;if(V[c]>(L[c]||0)&&--d,i==null?N=i=I.precision:s?N=i+(Ar(n)-Ar(a))+1:N=i,N<0)return new I(0);if(N=N/dr+2|0,c=0,T==1)for(f=0,V=V[0],N++;(c1&&(V=e(V,f),L=e(L,f),T=V.length,P=L.length),O=T,b=L.slice(0,T),w=b.length;w=Gr/2&&++E;do f=0,l=t(V,b,T,w),l<0?(j=b[0],T!=w&&(j=j*Gr+(b[1]||0)),f=j/E|0,f>1?(f>=Gr&&(f=Gr-1),h=e(V,f),p=h.length,w=b.length,l=t(h,b,p,w),l==1&&(f--,r(h,T16)throw Error(l_+Ar(e));if(!e.s)return new f(aa);for(pr=!1,l=h,s=new f(.03125);e.abs().gte(.1);)e=e.times(s),c+=5;for(n=Math.log(Os(2,c))/Math.LN10*2+5|0,l+=n,r=a=i=new f(aa),f.precision=l;;){if(a=Zt(a.times(e),l),r=r.times(++d),s=i.plus(ei(a,r,l)),po(s.d).slice(0,l)===po(i.d).slice(0,l)){for(;c--;)i=Zt(i.times(i),l);return f.precision=h,t==null?(pr=!0,Zt(i,h)):i}i=s}}function Ar(e){for(var t=e.e*dr,r=e.d[0];r>=10;r/=10)t++;return t}function eS(e,t,r){if(t>e.LN10.sd())throw pr=!0,r&&(e.precision=r),Error(Ta+"LN10 precision limit exceeded");return Zt(new e(e.LN10),t)}function Di(e){for(var t="";e--;)t+="0";return t}function of(e,t){var r,n,a,i,s,l,d,c,f,h=1,p=10,g=e,x=g.d,b=g.constructor,w=b.precision;if(g.s<1)throw Error(Ta+(g.s?"NaN":"-Infinity"));if(g.eq(aa))return new b(0);if(t==null?(pr=!1,c=w):c=t,g.eq(10))return t==null&&(pr=!0),eS(b,c);if(c+=p,b.precision=c,r=po(x),n=r.charAt(0),i=Ar(g),Math.abs(i)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)g=g.times(e),r=po(g.d),n=r.charAt(0),h++;i=Ar(g),n>1?(g=new b("0."+r),i++):g=new b(n+"."+r.slice(1))}else return d=eS(b,c+2,w).times(i+""),g=of(new b(n+"."+r.slice(1)),c-p).plus(d),b.precision=w,t==null?(pr=!0,Zt(g,w)):g;for(l=s=g=ei(g.minus(aa),g.plus(aa),c),f=Zt(g.times(g),c),a=3;;){if(s=Zt(s.times(f),c),d=l.plus(ei(s,new b(a),c)),po(d.d).slice(0,c)===po(l.d).slice(0,c))return l=l.times(2),i!==0&&(l=l.plus(eS(b,c+2,w).times(i+""))),l=ei(l,new b(h),c),b.precision=w,t==null?(pr=!0,Zt(l,w)):l;l=d,a+=2}}function JI(e,t){var r,n,a;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;)++n;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(n,a),t){if(a-=n,r=r-n-1,e.e=gu(r/dr),e.d=[],n=(r+1)%dr,r<0&&(n+=dr),nbg||e.e<-bg))throw Error(l_+r)}else e.s=0,e.e=0,e.d=[0];return e}function Zt(e,t,r){var n,a,i,s,l,d,c,f,h=e.d;for(s=1,i=h[0];i>=10;i/=10)s++;if(n=t-s,n<0)n+=dr,a=t,c=h[f=0];else{if(f=Math.ceil((n+1)/dr),i=h.length,f>=i)return e;for(c=i=h[f],s=1;i>=10;i/=10)s++;n%=dr,a=n-dr+s}if(r!==void 0&&(i=Os(10,s-a-1),l=c/i%10|0,d=t<0||h[f+1]!==void 0||c%i,d=r<4?(l||d)&&(r==0||r==(e.s<0?3:2)):l>5||l==5&&(r==4||d||r==6&&(n>0?a>0?c/Os(10,s-a):0:h[f-1])%10&1||r==(e.s<0?8:7))),t<1||!h[0])return d?(i=Ar(e),h.length=1,t=t-i-1,h[0]=Os(10,(dr-t%dr)%dr),e.e=gu(-t/dr)||0):(h.length=1,h[0]=e.e=e.s=0),e;if(n==0?(h.length=f,i=1,f--):(h.length=f+1,i=Os(10,dr-n),h[f]=a>0?(c/Os(10,s-a)%Os(10,a)|0)*i:0),d)for(;;)if(f==0){(h[0]+=i)==Gr&&(h[0]=1,++e.e);break}else{if(h[f]+=i,h[f]!=Gr)break;h[f--]=0,i=1}for(n=h.length;h[--n]===0;)h.pop();if(pr&&(e.e>bg||e.e<-bg))throw Error(l_+Ar(e));return e}function Z3(e,t){var r,n,a,i,s,l,d,c,f,h,p=e.constructor,g=p.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new p(e),pr?Zt(t,g):t;if(d=e.d,h=t.d,n=t.e,c=e.e,d=d.slice(),s=c-n,s){for(f=s<0,f?(r=d,s=-s,l=h.length):(r=h,n=c,l=d.length),a=Math.max(Math.ceil(g/dr),l)+2,s>a&&(s=a,r.length=1),r.reverse(),a=s;a--;)r.push(0);r.reverse()}else{for(a=d.length,l=h.length,f=a0;--a)d[l++]=0;for(a=h.length;a>s;){if(d[--a]0?i=i.charAt(0)+"."+i.slice(1)+Di(n):s>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(a<0?"e":"e+")+a):a<0?(i="0."+Di(-a-1)+i,r&&(n=r-s)>0&&(i+=Di(n))):a>=s?(i+=Di(a+1-s),r&&(n=r-a-1)>0&&(i=i+"."+Di(n))):((n=a+1)0&&(a+1===s&&(i+="."),i+=Di(n))),e.s<0?"-"+i:i}function QI(e,t){if(e.length>t)return e.length=t,!0}function e5(e){var t,r,n;function a(i){var s=this;if(!(s instanceof a))return new a(i);if(s.constructor=a,i instanceof a){s.s=i.s,s.e=i.e,s.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(Fs+i);if(i>0)s.s=1;else if(i<0)i=-i,s.s=-1;else{s.s=0,s.e=0,s.d=[0];return}if(i===~~i&&i<1e7){s.e=0,s.d=[i];return}return JI(s,i.toString())}else if(typeof i!="string")throw Error(Fs+i);if(i.charCodeAt(0)===45?(i=i.slice(1),s.s=-1):s.s=1,mZ.test(i))JI(s,i);else throw Error(Fs+i)}if(a.prototype=We,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=e5,a.config=a.set=pZ,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=a[t+1]&&n<=a[t+2])this[r]=n;else throw Error(Fs+r+": "+n);if((n=e[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Fs+r+": "+n);return this}var c_=e5(hZ);aa=new c_(1);const Jt=c_;function gZ(e){return bZ(e)||xZ(e)||vZ(e)||yZ()}function yZ(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vZ(e,t){if(e){if(typeof e=="string")return zj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return zj(e,t)}}function xZ(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function bZ(e){if(Array.isArray(e))return zj(e)}function zj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t?r.apply(void 0,a):e(t-s,ZI(function(){for(var l=arguments.length,d=new Array(l),c=0;ce.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!(Symbol.iterator in Object(e)))){var r=[],n=!0,a=!1,i=void 0;try{for(var s=e[Symbol.iterator](),l;!(n=(l=s.next()).done)&&(r.push(l.value),!(t&&r.length===t));n=!0);}catch(d){a=!0,i=d}finally{try{!n&&s.return!=null&&s.return()}finally{if(a)throw i}}return r}}function RZ(e){if(Array.isArray(e))return e}function o5(e){var t=sf(e,2),r=t[0],n=t[1],a=r,i=n;return r>n&&(a=n,i=r),[a,i]}function i5(e,t,r){if(e.lte(0))return new Jt(0);var n=By.getDigitCount(e.toNumber()),a=new Jt(10).pow(n),i=e.div(a),s=n!==1?.05:.1,l=new Jt(Math.ceil(i.div(s).toNumber())).add(r).mul(s),d=l.mul(a);return t?d:new Jt(Math.ceil(d))}function DZ(e,t,r){var n=1,a=new Jt(e);if(!a.isint()&&r){var i=Math.abs(e);i<1?(n=new Jt(10).pow(By.getDigitCount(e)-1),a=new Jt(Math.floor(a.div(n).toNumber())).mul(n)):i>1&&(a=new Jt(Math.floor(e)))}else e===0?a=new Jt(Math.floor((t-1)/2)):r||(a=new Jt(Math.floor(e)));var s=Math.floor((t-1)/2),l=NZ(jZ(function(d){return a.add(new Jt(d-s).mul(n)).toNumber()}),Uj);return l(0,t)}function s5(e,t,r,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(r-1)))return{step:new Jt(0),tickMin:new Jt(0),tickMax:new Jt(0)};var i=i5(new Jt(t).sub(e).div(r-1),n,a),s;e<=0&&t>=0?s=new Jt(0):(s=new Jt(e).add(t).div(2),s=s.sub(new Jt(s).mod(i)));var l=Math.ceil(s.sub(e).div(i).toNumber()),d=Math.ceil(new Jt(t).sub(s).div(i).toNumber()),c=l+d+1;return c>r?s5(e,t,r,n,a+1):(c0?d+(r-c):d,l=t>0?l:l+(r-c)),{step:i,tickMin:s.sub(new Jt(l).mul(i)),tickMax:s.add(new Jt(d).mul(i))})}function LZ(e){var t=sf(e,2),r=t[0],n=t[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=Math.max(a,2),l=o5([r,n]),d=sf(l,2),c=d[0],f=d[1];if(c===-1/0||f===1/0){var h=f===1/0?[c].concat(Vj(Uj(0,a-1).map(function(){return 1/0}))):[].concat(Vj(Uj(0,a-1).map(function(){return-1/0})),[f]);return r>n?qj(h):h}if(c===f)return DZ(c,a,i);var p=s5(c,f,s,i),g=p.step,x=p.tickMin,b=p.tickMax,w=By.rangeStep(x,b.add(new Jt(.1).mul(g)),g);return r>n?qj(w):w}function $Z(e,t){var r=sf(e,2),n=r[0],a=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,s=o5([n,a]),l=sf(s,2),d=l[0],c=l[1];if(d===-1/0||c===1/0)return[n,a];if(d===c)return[d];var f=Math.max(t,2),h=i5(new Jt(c).sub(d).div(f-1),i,0),p=[].concat(Vj(By.rangeStep(new Jt(d),new Jt(c).sub(new Jt(.99).mul(h)),h)),[c]);return n>a?qj(p):p}var FZ=n5(LZ),BZ=n5($Z),zZ="Invariant failed";function Hs(e,t){throw new Error(zZ)}var UZ=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function Mc(e){"@babel/helpers - typeof";return Mc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mc(e)}function wg(){return wg=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function KZ(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function XZ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function JZ(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=-1,l=(r=n?.length)!==null&&r!==void 0?r:0;if(l<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var d=i.range,c=0;c0?a[c-1].coordinate:a[l-1].coordinate,h=a[c].coordinate,p=c>=l-1?a[0].coordinate:a[c+1].coordinate,g=void 0;if(Sn(h-f)!==Sn(p-h)){var x=[];if(Sn(p-h)===Sn(d[1]-d[0])){g=p;var b=h+d[1]-d[0];x[0]=Math.min(b,(b+f)/2),x[1]=Math.max(b,(b+f)/2)}else{g=f;var w=p+d[1]-d[0];x[0]=Math.min(h,(w+h)/2),x[1]=Math.max(h,(w+h)/2)}var j=[Math.min(h,(g+h)/2),Math.max(h,(g+h)/2)];if(t>j[0]&&t<=j[1]||t>=x[0]&&t<=x[1]){s=a[c].index;break}}else{var N=Math.min(f,p),C=Math.max(f,p);if(t>(N+h)/2&&t<=(C+h)/2){s=a[c].index;break}}}else for(var O=0;O0&&O(n[O].coordinate+n[O-1].coordinate)/2&&t<=(n[O].coordinate+n[O+1].coordinate)/2||O===l-1&&t>(n[O].coordinate+n[O-1].coordinate)/2){s=n[O].index;break}return s},u_=function(t){var r,n=t,a=n.type.displayName,i=(r=t.type)!==null&&r!==void 0&&r.defaultProps?Nr(Nr({},t.type.defaultProps),t.props):t.props,s=i.stroke,l=i.fill,d;switch(a){case"Line":d=s;break;case"Area":case"Radar":d=s&&s!=="none"?s:l;break;default:d=l;break}return d},mee=function(t){var r=t.barSize,n=t.totalSize,a=t.stackGroups,i=a===void 0?{}:a;if(!i)return{};for(var s={},l=Object.keys(i),d=0,c=l.length;d=0});if(j&&j.length){var N=j[0].type.defaultProps,C=N!==void 0?Nr(Nr({},N),j[0].props):j[0].props,O=C.barSize,P=C[w];s[P]||(s[P]=[]);var E=yt(O)?r:O;s[P].push({item:j[0],stackList:j.slice(1),barSize:yt(E)?void 0:jn(E,n,0)})}}return s},pee=function(t){var r=t.barGap,n=t.barCategoryGap,a=t.bandSize,i=t.sizeList,s=i===void 0?[]:i,l=t.maxBarSize,d=s.length;if(d<1)return null;var c=jn(r,a,0,!0),f,h=[];if(s[0].barSize===+s[0].barSize){var p=!1,g=a/d,x=s.reduce(function(O,P){return O+P.barSize||0},0);x+=(d-1)*c,x>=a&&(x-=(d-1)*c,c=0),x>=a&&g>0&&(p=!0,g*=.9,x=d*g);var b=(a-x)/2>>0,w={offset:b-c,size:0};f=s.reduce(function(O,P){var E={item:P.item,position:{offset:w.offset+w.size+c,size:p?g:P.barSize}},T=[].concat(rM(O),[E]);return w=T[T.length-1].position,P.stackList&&P.stackList.length&&P.stackList.forEach(function(A){T.push({item:A,position:w})}),T},h)}else{var j=jn(n,a,0,!0);a-2*j-(d-1)*c<=0&&(c=0);var N=(a-2*j-(d-1)*c)/d;N>1&&(N>>=0);var C=l===+l?Math.min(N,l):N;f=s.reduce(function(O,P,E){var T=[].concat(rM(O),[{item:P.item,position:{offset:j+(N+c)*E+(N-C)/2,size:C}}]);return P.stackList&&P.stackList.length&&P.stackList.forEach(function(A){T.push({item:A,position:T[T.length-1].position})}),T},h)}return f},gee=function(t,r,n,a){var i=n.children,s=n.width,l=n.margin,d=s-(l.left||0)-(l.right||0),c=d5({children:i,legendWidth:d});if(c){var f=a||{},h=f.width,p=f.height,g=c.align,x=c.verticalAlign,b=c.layout;if((b==="vertical"||b==="horizontal"&&x==="middle")&&g!=="center"&&Re(t[g]))return Nr(Nr({},t),{},gc({},g,t[g]+(h||0)));if((b==="horizontal"||b==="vertical"&&g==="center")&&x!=="middle"&&Re(t[x]))return Nr(Nr({},t),{},gc({},x,t[x]+(p||0)))}return t},yee=function(t,r,n){return yt(r)?!0:t==="horizontal"?r==="yAxis":t==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},f5=function(t,r,n,a,i){var s=r.props.children,l=da(s,Wf).filter(function(c){return yee(a,i,c.props.direction)});if(l&&l.length){var d=l.map(function(c){return c.props.dataKey});return t.reduce(function(c,f){var h=Br(f,n);if(yt(h))return c;var p=Array.isArray(h)?[$y(h),Ly(h)]:[h,h],g=d.reduce(function(x,b){var w=Br(f,b,0),j=p[0]-Math.abs(Array.isArray(w)?w[0]:w),N=p[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(j,x[0]),Math.max(N,x[1])]},[1/0,-1/0]);return[Math.min(g[0],c[0]),Math.max(g[1],c[1])]},[1/0,-1/0])}return null},vee=function(t,r,n,a,i){var s=r.map(function(l){return f5(t,l,n,i,a)}).filter(function(l){return!yt(l)});return s&&s.length?s.reduce(function(l,d){return[Math.min(l[0],d[0]),Math.max(l[1],d[1])]},[1/0,-1/0]):null},h5=function(t,r,n,a,i){var s=r.map(function(d){var c=d.props.dataKey;return n==="number"&&c&&f5(t,d,c,a)||Bd(t,c,n,i)});if(n==="number")return s.reduce(function(d,c){return[Math.min(d[0],c[0]),Math.max(d[1],c[1])]},[1/0,-1/0]);var l={};return s.reduce(function(d,c){for(var f=0,h=c.length;f=2?Sn(l[0]-l[1])*2*c:c,r&&(t.ticks||t.niceTicks)){var f=(t.ticks||t.niceTicks).map(function(h){var p=i?i.indexOf(h):h;return{coordinate:a(p)+c,value:h,offset:c}});return f.filter(function(h){return!$f(h.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(h,p){return{coordinate:a(h)+c,value:h,index:p,offset:c}}):a.ticks&&!n?a.ticks(t.tickCount).map(function(h){return{coordinate:a(h)+c,value:h,offset:c}}):a.domain().map(function(h,p){return{coordinate:a(h)+c,value:i?i[h]:h,index:p,offset:c}})},tS=new WeakMap,Lm=function(t,r){if(typeof r!="function")return t;tS.has(t)||tS.set(t,new WeakMap);var n=tS.get(t);if(n.has(r))return n.get(r);var a=function(){t.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,a),a},g5=function(t,r,n){var a=t.scale,i=t.type,s=t.layout,l=t.axisType;if(a==="auto")return s==="radial"&&l==="radiusAxis"?{scale:ef(),realScaleType:"band"}:s==="radial"&&l==="angleAxis"?{scale:gg(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:Fd(),realScaleType:"point"}:i==="category"?{scale:ef(),realScaleType:"band"}:{scale:gg(),realScaleType:"linear"};if(Us(a)){var d="scale".concat(Sy(a));return{scale:(UI[d]||Fd)(),realScaleType:UI[d]?d:"point"}}return mt(a)?{scale:a}:{scale:Fd(),realScaleType:"point"}},aM=1e-4,y5=function(t){var r=t.domain();if(!(!r||r.length<=2)){var n=r.length,a=t.range(),i=Math.min(a[0],a[1])-aM,s=Math.max(a[0],a[1])+aM,l=t(r[0]),d=t(r[n-1]);(ls||ds)&&t.domain([r[0],r[n-1]])}},xee=function(t,r){if(!t)return null;for(var n=0,a=t.length;na)&&(i[1]=a),i[0]>a&&(i[0]=a),i[1]=0?(t[l][n][0]=i,t[l][n][1]=i+d,i=t[l][n][1]):(t[l][n][0]=s,t[l][n][1]=s+d,s=t[l][n][1])}},See=function(t){var r=t.length;if(!(r<=0))for(var n=0,a=t[0].length;n=0?(t[s][n][0]=i,t[s][n][1]=i+l,i=t[s][n][1]):(t[s][n][0]=0,t[s][n][1]=0)}},jee={sign:wee,expand:uG,none:_c,silhouette:dG,wiggle:fG,positive:See},Nee=function(t,r,n){var a=r.map(function(l){return l.props.dataKey}),i=jee[n],s=cG().keys(a).value(function(l,d){return+Br(l,d,0)}).order(jj).offset(i);return s(t)},Cee=function(t,r,n,a,i,s){if(!t)return null;var l=s?r.reverse():r,d={},c=l.reduce(function(h,p){var g,x=(g=p.type)!==null&&g!==void 0&&g.defaultProps?Nr(Nr({},p.type.defaultProps),p.props):p.props,b=x.stackId,w=x.hide;if(w)return h;var j=x[n],N=h[j]||{hasStack:!1,stackGroups:{}};if(zr(b)){var C=N.stackGroups[b]||{numericAxisId:n,cateAxisId:a,items:[]};C.items.push(p),N.hasStack=!0,N.stackGroups[b]=C}else N.stackGroups[fu("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[p]};return Nr(Nr({},h),{},gc({},j,N))},d),f={};return Object.keys(c).reduce(function(h,p){var g=c[p];if(g.hasStack){var x={};g.stackGroups=Object.keys(g.stackGroups).reduce(function(b,w){var j=g.stackGroups[w];return Nr(Nr({},b),{},gc({},w,{numericAxisId:n,cateAxisId:a,items:j.items,stackedData:Nee(t,j.items,i)}))},x)}return Nr(Nr({},h),{},gc({},p,g))},f)},v5=function(t,r){var n=r.realScaleType,a=r.type,i=r.tickCount,s=r.originalDomain,l=r.allowDecimals,d=n||r.scale;if(d!=="auto"&&d!=="linear")return null;if(i&&a==="number"&&s&&(s[0]==="auto"||s[1]==="auto")){var c=t.domain();if(!c.length)return null;var f=FZ(c,i,l);return t.domain([$y(f),Ly(f)]),{niceTicks:f}}if(i&&a==="number"){var h=t.domain(),p=BZ(h,i,l);return{niceTicks:p}}return null};function oM(e){var t=e.axis,r=e.ticks,n=e.bandSize,a=e.entry,i=e.index,s=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!yt(a[t.dataKey])){var l=Xp(r,"value",a[t.dataKey]);if(l)return l.coordinate+n/2}return r[i]?r[i].coordinate+n/2:null}var d=Br(a,yt(s)?t.dataKey:s);return yt(d)?null:t.scale(d)}var iM=function(t){var r=t.axis,n=t.ticks,a=t.offset,i=t.bandSize,s=t.entry,l=t.index;if(r.type==="category")return n[l]?n[l].coordinate+a:null;var d=Br(s,r.dataKey,r.domain[l]);return yt(d)?null:r.scale(d)-i/2+a},_ee=function(t){var r=t.numericAxis,n=r.scale.domain();if(r.type==="number"){var a=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return a<=0&&i>=0?0:i<0?i:a}return n[0]},Eee=function(t,r){var n,a=(n=t.type)!==null&&n!==void 0&&n.defaultProps?Nr(Nr({},t.type.defaultProps),t.props):t.props,i=a.stackId;if(zr(i)){var s=r[i];if(s){var l=s.items.indexOf(t);return l>=0?s.stackedData[l]:null}}return null},Pee=function(t){return t.reduce(function(r,n){return[$y(n.concat([r[0]]).filter(Re)),Ly(n.concat([r[1]]).filter(Re))]},[1/0,-1/0])},x5=function(t,r,n){return Object.keys(t).reduce(function(a,i){var s=t[i],l=s.stackedData,d=l.reduce(function(c,f){var h=Pee(f.slice(r,n+1));return[Math.min(c[0],h[0]),Math.max(c[1],h[1])]},[1/0,-1/0]);return[Math.min(d[0],a[0]),Math.max(d[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},sM=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,lM=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Yj=function(t,r,n){if(mt(t))return t(r,n);if(!Array.isArray(t))return r;var a=[];if(Re(t[0]))a[0]=n?t[0]:Math.min(t[0],r[0]);else if(sM.test(t[0])){var i=+sM.exec(t[0])[1];a[0]=r[0]-i}else mt(t[0])?a[0]=t[0](r[0]):a[0]=r[0];if(Re(t[1]))a[1]=n?t[1]:Math.max(t[1],r[1]);else if(lM.test(t[1])){var s=+lM.exec(t[1])[1];a[1]=r[1]+s}else mt(t[1])?a[1]=t[1](r[1]):a[1]=r[1];return a},jg=function(t,r,n){if(t&&t.scale&&t.scale.bandwidth){var a=t.scale.bandwidth();if(!n||a>0)return a}if(t&&r&&r.length>=2){for(var i=$C(r,function(h){return h.coordinate}),s=1/0,l=1,d=i.length;le.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},Lee=function(t,r,n,a,i){var s=t.width,l=t.height,d=t.startAngle,c=t.endAngle,f=jn(t.cx,s,s/2),h=jn(t.cy,l,l/2),p=S5(s,l,n),g=jn(t.innerRadius,p,0),x=jn(t.outerRadius,p,p*.8),b=Object.keys(r);return b.reduce(function(w,j){var N=r[j],C=N.domain,O=N.reversed,P;if(yt(N.range))a==="angleAxis"?P=[d,c]:a==="radiusAxis"&&(P=[g,x]),O&&(P=[P[1],P[0]]);else{P=N.range;var E=P,T=kee(E,2);d=T[0],c=T[1]}var A=g5(N,i),I=A.realScaleType,R=A.scale;R.domain(C).range(P),y5(R);var L=v5(R,Ho(Ho({},N),{},{realScaleType:I})),V=Ho(Ho(Ho({},N),L),{},{range:P,radius:x,realScaleType:I,scale:R,cx:f,cy:h,innerRadius:g,outerRadius:x,startAngle:d,endAngle:c});return Ho(Ho({},w),{},w5({},j,V))},{})},$ee=function(t,r){var n=t.x,a=t.y,i=r.x,s=r.y;return Math.sqrt(Math.pow(n-i,2)+Math.pow(a-s,2))},Fee=function(t,r){var n=t.x,a=t.y,i=r.cx,s=r.cy,l=$ee({x:n,y:a},{x:i,y:s});if(l<=0)return{radius:l};var d=(n-i)/l,c=Math.acos(d);return a>s&&(c=2*Math.PI-c),{radius:l,angle:Dee(c),angleInRadian:c}},Bee=function(t){var r=t.startAngle,n=t.endAngle,a=Math.floor(r/360),i=Math.floor(n/360),s=Math.min(a,i);return{startAngle:r-s*360,endAngle:n-s*360}},zee=function(t,r){var n=r.startAngle,a=r.endAngle,i=Math.floor(n/360),s=Math.floor(a/360),l=Math.min(i,s);return t+l*360},fM=function(t,r){var n=t.x,a=t.y,i=Fee({x:n,y:a},r),s=i.radius,l=i.angle,d=r.innerRadius,c=r.outerRadius;if(sc)return!1;if(s===0)return!0;var f=Bee(r),h=f.startAngle,p=f.endAngle,g=l,x;if(h<=p){for(;g>p;)g-=360;for(;g=h&&g<=p}else{for(;g>h;)g-=360;for(;g=p&&g<=h}return x?Ho(Ho({},r),{},{radius:s,angle:zee(g,r)}):null},j5=function(t){return!v.isValidElement(t)&&!mt(t)&&typeof t!="boolean"?t.className:""};function df(e){"@babel/helpers - typeof";return df=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},df(e)}var Uee=["offset"];function qee(e){return Gee(e)||Hee(e)||Wee(e)||Vee()}function Vee(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Wee(e,t){if(e){if(typeof e=="string")return Kj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Kj(e,t)}}function Hee(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Gee(e){if(Array.isArray(e))return Kj(e)}function Kj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Kee(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function hM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Fr(e){for(var t=1;t=0?1:-1,C,O;a==="insideStart"?(C=g+N*s,O=b):a==="insideEnd"?(C=x-N*s,O=!b):a==="end"&&(C=x+N*s,O=b),O=j<=0?O:!O;var P=or(c,f,w,C),E=or(c,f,w,C+(O?1:-1)*359),T="M".concat(P.x,",").concat(P.y,` + A`).concat(w,",").concat(w,",0,1,").concat(O?0:1,`, + `).concat(E.x,",").concat(E.y),A=yt(t.id)?fu("recharts-radial-line-"):t.id;return U.createElement("text",ff({},n,{dominantBaseline:"central",className:vt("recharts-radial-bar-label",l)}),U.createElement("defs",null,U.createElement("path",{id:A,d:T})),U.createElement("textPath",{xlinkHref:"#".concat(A)},r))},rte=function(t){var r=t.viewBox,n=t.offset,a=t.position,i=r,s=i.cx,l=i.cy,d=i.innerRadius,c=i.outerRadius,f=i.startAngle,h=i.endAngle,p=(f+h)/2;if(a==="outside"){var g=or(s,l,c+n,p),x=g.x,b=g.y;return{x,y:b,textAnchor:x>=s?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:s,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:s,y:l,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:s,y:l,textAnchor:"middle",verticalAnchor:"end"};var w=(d+c)/2,j=or(s,l,w,p),N=j.x,C=j.y;return{x:N,y:C,textAnchor:"middle",verticalAnchor:"middle"}},nte=function(t){var r=t.viewBox,n=t.parentViewBox,a=t.offset,i=t.position,s=r,l=s.x,d=s.y,c=s.width,f=s.height,h=f>=0?1:-1,p=h*a,g=h>0?"end":"start",x=h>0?"start":"end",b=c>=0?1:-1,w=b*a,j=b>0?"end":"start",N=b>0?"start":"end";if(i==="top"){var C={x:l+c/2,y:d-h*a,textAnchor:"middle",verticalAnchor:g};return Fr(Fr({},C),n?{height:Math.max(d-n.y,0),width:c}:{})}if(i==="bottom"){var O={x:l+c/2,y:d+f+p,textAnchor:"middle",verticalAnchor:x};return Fr(Fr({},O),n?{height:Math.max(n.y+n.height-(d+f),0),width:c}:{})}if(i==="left"){var P={x:l-w,y:d+f/2,textAnchor:j,verticalAnchor:"middle"};return Fr(Fr({},P),n?{width:Math.max(P.x-n.x,0),height:f}:{})}if(i==="right"){var E={x:l+c+w,y:d+f/2,textAnchor:N,verticalAnchor:"middle"};return Fr(Fr({},E),n?{width:Math.max(n.x+n.width-E.x,0),height:f}:{})}var T=n?{width:c,height:f}:{};return i==="insideLeft"?Fr({x:l+w,y:d+f/2,textAnchor:N,verticalAnchor:"middle"},T):i==="insideRight"?Fr({x:l+c-w,y:d+f/2,textAnchor:j,verticalAnchor:"middle"},T):i==="insideTop"?Fr({x:l+c/2,y:d+p,textAnchor:"middle",verticalAnchor:x},T):i==="insideBottom"?Fr({x:l+c/2,y:d+f-p,textAnchor:"middle",verticalAnchor:g},T):i==="insideTopLeft"?Fr({x:l+w,y:d+p,textAnchor:N,verticalAnchor:x},T):i==="insideTopRight"?Fr({x:l+c-w,y:d+p,textAnchor:j,verticalAnchor:x},T):i==="insideBottomLeft"?Fr({x:l+w,y:d+f-p,textAnchor:N,verticalAnchor:g},T):i==="insideBottomRight"?Fr({x:l+c-w,y:d+f-p,textAnchor:j,verticalAnchor:g},T):du(i)&&(Re(i.x)||Is(i.x))&&(Re(i.y)||Is(i.y))?Fr({x:l+jn(i.x,c),y:d+jn(i.y,f),textAnchor:"end",verticalAnchor:"end"},T):Fr({x:l+c/2,y:d+f/2,textAnchor:"middle",verticalAnchor:"middle"},T)},ate=function(t){return"cx"in t&&Re(t.cx)};function Yr(e){var t=e.offset,r=t===void 0?5:t,n=Yee(e,Uee),a=Fr({offset:r},n),i=a.viewBox,s=a.position,l=a.value,d=a.children,c=a.content,f=a.className,h=f===void 0?"":f,p=a.textBreakAll;if(!i||yt(l)&&yt(d)&&!v.isValidElement(c)&&!mt(c))return null;if(v.isValidElement(c))return v.cloneElement(c,a);var g;if(mt(c)){if(g=v.createElement(c,a),v.isValidElement(g))return g}else g=Zee(a);var x=ate(i),b=lt(a,!0);if(x&&(s==="insideStart"||s==="insideEnd"||s==="end"))return tte(a,g,b);var w=x?rte(a):nte(a);return U.createElement(Vs,ff({className:vt("recharts-label",h)},b,w,{breakAll:p}),g)}Yr.displayName="Label";var N5=function(t){var r=t.cx,n=t.cy,a=t.angle,i=t.startAngle,s=t.endAngle,l=t.r,d=t.radius,c=t.innerRadius,f=t.outerRadius,h=t.x,p=t.y,g=t.top,x=t.left,b=t.width,w=t.height,j=t.clockWise,N=t.labelViewBox;if(N)return N;if(Re(b)&&Re(w)){if(Re(h)&&Re(p))return{x:h,y:p,width:b,height:w};if(Re(g)&&Re(x))return{x:g,y:x,width:b,height:w}}return Re(h)&&Re(p)?{x:h,y:p,width:0,height:0}:Re(r)&&Re(n)?{cx:r,cy:n,startAngle:i||a||0,endAngle:s||a||0,innerRadius:c||0,outerRadius:f||d||l||0,clockWise:j}:t.viewBox?t.viewBox:{}},ote=function(t,r){return t?t===!0?U.createElement(Yr,{key:"label-implicit",viewBox:r}):zr(t)?U.createElement(Yr,{key:"label-implicit",viewBox:r,value:t}):v.isValidElement(t)?t.type===Yr?v.cloneElement(t,{key:"label-implicit",viewBox:r}):U.createElement(Yr,{key:"label-implicit",content:t,viewBox:r}):mt(t)?U.createElement(Yr,{key:"label-implicit",content:t,viewBox:r}):du(t)?U.createElement(Yr,ff({viewBox:r},t,{key:"label-implicit"})):null:null},ite=function(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&n&&!t.label)return null;var a=t.children,i=N5(t),s=da(a,Yr).map(function(d,c){return v.cloneElement(d,{viewBox:r||i,key:"label-".concat(c)})});if(!n)return s;var l=ote(t.label,r||i);return[l].concat(qee(s))};Yr.parseViewBox=N5;Yr.renderCallByParent=ite;var rS,mM;function ste(){if(mM)return rS;mM=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return rS=e,rS}var lte=ste();const cte=Wt(lte);function hf(e){"@babel/helpers - typeof";return hf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hf(e)}var ute=["valueAccessor"],dte=["data","dataKey","clockWise","id","textBreakAll"];function fte(e){return gte(e)||pte(e)||mte(e)||hte()}function hte(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mte(e,t){if(e){if(typeof e=="string")return Xj(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xj(e,t)}}function pte(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function gte(e){if(Array.isArray(e))return Xj(e)}function Xj(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function bte(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var wte=function(t){return Array.isArray(t.value)?cte(t.value):t.value};function ti(e){var t=e.valueAccessor,r=t===void 0?wte:t,n=yM(e,ute),a=n.data,i=n.dataKey,s=n.clockWise,l=n.id,d=n.textBreakAll,c=yM(n,dte);return!a||!a.length?null:U.createElement(Bt,{className:"recharts-label-list"},a.map(function(f,h){var p=yt(i)?r(f,h):Br(f&&f.payload,i),g=yt(l)?{}:{id:"".concat(l,"-").concat(h)};return U.createElement(Yr,Cg({},lt(f,!0),c,g,{parentViewBox:f.parentViewBox,value:p,textBreakAll:d,viewBox:Yr.parseViewBox(yt(s)?f:gM(gM({},f),{},{clockWise:s})),key:"label-".concat(h),index:h}))}))}ti.displayName="LabelList";function Ste(e,t){return e?e===!0?U.createElement(ti,{key:"labelList-implicit",data:t}):U.isValidElement(e)||mt(e)?U.createElement(ti,{key:"labelList-implicit",data:t,content:e}):du(e)?U.createElement(ti,Cg({data:t},e,{key:"labelList-implicit"})):null:null}function jte(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var n=e.children,a=da(n,ti).map(function(s,l){return v.cloneElement(s,{data:t,key:"labelList-".concat(l)})});if(!r)return a;var i=Ste(e.label,t);return[i].concat(fte(a))}ti.renderCallByParent=jte;function mf(e){"@babel/helpers - typeof";return mf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mf(e)}function Jj(){return Jj=Object.assign?Object.assign.bind():function(e){for(var t=1;t180),",").concat(+(s>c),`, + `).concat(h.x,",").concat(h.y,` + `);if(a>0){var g=or(r,n,a,s),x=or(r,n,a,c);p+="L ".concat(x.x,",").concat(x.y,` + A `).concat(a,",").concat(a,`,0, + `).concat(+(Math.abs(d)>180),",").concat(+(s<=c),`, + `).concat(g.x,",").concat(g.y," Z")}else p+="L ".concat(r,",").concat(n," Z");return p},Pte=function(t){var r=t.cx,n=t.cy,a=t.innerRadius,i=t.outerRadius,s=t.cornerRadius,l=t.forceCornerRadius,d=t.cornerIsExternal,c=t.startAngle,f=t.endAngle,h=Sn(f-c),p=$m({cx:r,cy:n,radius:i,angle:c,sign:h,cornerRadius:s,cornerIsExternal:d}),g=p.circleTangency,x=p.lineTangency,b=p.theta,w=$m({cx:r,cy:n,radius:i,angle:f,sign:-h,cornerRadius:s,cornerIsExternal:d}),j=w.circleTangency,N=w.lineTangency,C=w.theta,O=d?Math.abs(c-f):Math.abs(c-f)-b-C;if(O<0)return l?"M ".concat(x.x,",").concat(x.y,` + a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0 + a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0 + `):C5({cx:r,cy:n,innerRadius:a,outerRadius:i,startAngle:c,endAngle:f});var P="M ".concat(x.x,",").concat(x.y,` + A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(g.x,",").concat(g.y,` + A`).concat(i,",").concat(i,",0,").concat(+(O>180),",").concat(+(h<0),",").concat(j.x,",").concat(j.y,` + A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(N.x,",").concat(N.y,` + `);if(a>0){var E=$m({cx:r,cy:n,radius:a,angle:c,sign:h,isExternal:!0,cornerRadius:s,cornerIsExternal:d}),T=E.circleTangency,A=E.lineTangency,I=E.theta,R=$m({cx:r,cy:n,radius:a,angle:f,sign:-h,isExternal:!0,cornerRadius:s,cornerIsExternal:d}),L=R.circleTangency,V=R.lineTangency,z=R.theta,G=d?Math.abs(c-f):Math.abs(c-f)-I-z;if(G<0&&s===0)return"".concat(P,"L").concat(r,",").concat(n,"Z");P+="L".concat(V.x,",").concat(V.y,` + A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(L.x,",").concat(L.y,` + A`).concat(a,",").concat(a,",0,").concat(+(G>180),",").concat(+(h>0),",").concat(T.x,",").concat(T.y,` + A`).concat(s,",").concat(s,",0,0,").concat(+(h<0),",").concat(A.x,",").concat(A.y,"Z")}else P+="L".concat(r,",").concat(n,"Z");return P},Ote={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},_5=function(t){var r=xM(xM({},Ote),t),n=r.cx,a=r.cy,i=r.innerRadius,s=r.outerRadius,l=r.cornerRadius,d=r.forceCornerRadius,c=r.cornerIsExternal,f=r.startAngle,h=r.endAngle,p=r.className;if(s0&&Math.abs(f-h)<360?w=Pte({cx:n,cy:a,innerRadius:i,outerRadius:s,cornerRadius:Math.min(b,x/2),forceCornerRadius:d,cornerIsExternal:c,startAngle:f,endAngle:h}):w=C5({cx:n,cy:a,innerRadius:i,outerRadius:s,startAngle:f,endAngle:h}),U.createElement("path",Jj({},lt(r,!0),{className:g,d:w,role:"img"}))};function pf(e){"@babel/helpers - typeof";return pf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pf(e)}function Qj(){return Qj=Object.assign?Object.assign.bind():function(e){for(var t=1;tzte.call(e,t));function cl(e,t){return e===t||!e&&!t&&e!==e&&t!==t}const Vte="__v",Wte="__o",Hte="_owner",{getOwnPropertyDescriptor:EM,keys:PM}=Object;function Gte(e,t){return e.byteLength===t.byteLength&&Eg(new Uint8Array(e),new Uint8Array(t))}function Yte(e,t,r){let n=e.length;if(t.length!==n)return!1;for(;n-- >0;)if(!r.equals(e[n],t[n],n,n,e,t,r))return!1;return!0}function Kte(e,t){return e.byteLength===t.byteLength&&Eg(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function Xte(e,t){return cl(e.getTime(),t.getTime())}function Jte(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function Qte(e,t){return e===t}function OM(e,t,r){const n=e.size;if(n!==t.size)return!1;if(!n)return!0;const a=new Array(n),i=e.entries();let s,l,d=0;for(;(s=i.next())&&!s.done;){const c=t.entries();let f=!1,h=0;for(;(l=c.next())&&!l.done;){if(a[h]){h++;continue}const p=s.value,g=l.value;if(r.equals(p[0],g[0],d,h,e,t,r)&&r.equals(p[1],g[1],p[0],g[0],e,t,r)){f=a[h]=!0;break}h++}if(!f)return!1;d++}return!0}const Zte=cl;function ere(e,t,r){const n=PM(e);let a=n.length;if(PM(t).length!==a)return!1;for(;a-- >0;)if(!E5(e,t,r,n[a]))return!1;return!0}function wd(e,t,r){const n=_M(e);let a=n.length;if(_M(t).length!==a)return!1;let i,s,l;for(;a-- >0;)if(i=n[a],!E5(e,t,r,i)||(s=EM(e,i),l=EM(t,i),(s||l)&&(!s||!l||s.configurable!==l.configurable||s.enumerable!==l.enumerable||s.writable!==l.writable)))return!1;return!0}function tre(e,t){return cl(e.valueOf(),t.valueOf())}function rre(e,t){return e.source===t.source&&e.flags===t.flags}function TM(e,t,r){const n=e.size;if(n!==t.size)return!1;if(!n)return!0;const a=new Array(n),i=e.values();let s,l;for(;(s=i.next())&&!s.done;){const d=t.values();let c=!1,f=0;for(;(l=d.next())&&!l.done;){if(!a[f]&&r.equals(s.value,l.value,s.value,l.value,e,t,r)){c=a[f]=!0;break}f++}if(!c)return!1}return!0}function Eg(e,t){let r=e.byteLength;if(t.byteLength!==r||e.byteOffset!==t.byteOffset)return!1;for(;r-- >0;)if(e[r]!==t[r])return!1;return!0}function nre(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function E5(e,t,r,n){return(n===Hte||n===Wte||n===Vte)&&(e.$$typeof||t.$$typeof)?!0:qte(t,n)&&r.equals(e[n],t[n],n,n,e,t,r)}const are="[object ArrayBuffer]",ore="[object Arguments]",ire="[object Boolean]",sre="[object DataView]",lre="[object Date]",cre="[object Error]",ure="[object Map]",dre="[object Number]",fre="[object Object]",hre="[object RegExp]",mre="[object Set]",pre="[object String]",gre={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},yre="[object URL]",vre=Object.prototype.toString;function xre({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:a,areFunctionsEqual:i,areMapsEqual:s,areNumbersEqual:l,areObjectsEqual:d,arePrimitiveWrappersEqual:c,areRegExpsEqual:f,areSetsEqual:h,areTypedArraysEqual:p,areUrlsEqual:g,unknownTagComparators:x}){return function(w,j,N){if(w===j)return!0;if(w==null||j==null)return!1;const C=typeof w;if(C!==typeof j)return!1;if(C!=="object")return C==="number"?l(w,j,N):C==="function"?i(w,j,N):!1;const O=w.constructor;if(O!==j.constructor)return!1;if(O===Object)return d(w,j,N);if(Array.isArray(w))return t(w,j,N);if(O===Date)return n(w,j,N);if(O===RegExp)return f(w,j,N);if(O===Map)return s(w,j,N);if(O===Set)return h(w,j,N);const P=vre.call(w);if(P===lre)return n(w,j,N);if(P===hre)return f(w,j,N);if(P===ure)return s(w,j,N);if(P===mre)return h(w,j,N);if(P===fre)return typeof w.then!="function"&&typeof j.then!="function"&&d(w,j,N);if(P===yre)return g(w,j,N);if(P===cre)return a(w,j,N);if(P===ore)return d(w,j,N);if(gre[P])return p(w,j,N);if(P===are)return e(w,j,N);if(P===sre)return r(w,j,N);if(P===ire||P===dre||P===pre)return c(w,j,N);if(x){let E=x[P];if(!E){const T=Ute(w);T&&(E=x[T])}if(E)return E(w,j,N)}return!1}}function bre({circular:e,createCustomConfig:t,strict:r}){let n={areArrayBuffersEqual:Gte,areArraysEqual:r?wd:Yte,areDataViewsEqual:Kte,areDatesEqual:Xte,areErrorsEqual:Jte,areFunctionsEqual:Qte,areMapsEqual:r?iS(OM,wd):OM,areNumbersEqual:Zte,areObjectsEqual:r?wd:ere,arePrimitiveWrappersEqual:tre,areRegExpsEqual:rre,areSetsEqual:r?iS(TM,wd):TM,areTypedArraysEqual:r?iS(Eg,wd):Eg,areUrlsEqual:nre,unknownTagComparators:void 0};if(t&&(n=Object.assign({},n,t(n))),e){const a=Bm(n.areArraysEqual),i=Bm(n.areMapsEqual),s=Bm(n.areObjectsEqual),l=Bm(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:a,areMapsEqual:i,areObjectsEqual:s,areSetsEqual:l})}return n}function wre(e){return function(t,r,n,a,i,s,l){return e(t,r,l)}}function Sre({circular:e,comparator:t,createState:r,equals:n,strict:a}){if(r)return function(l,d){const{cache:c=e?new WeakMap:void 0,meta:f}=r();return t(l,d,{cache:c,equals:n,meta:f,strict:a})};if(e)return function(l,d){return t(l,d,{cache:new WeakMap,equals:n,meta:void 0,strict:a})};const i={cache:void 0,equals:n,meta:void 0,strict:a};return function(l,d){return t(l,d,i)}}const jre=Ki();Ki({strict:!0});Ki({circular:!0});Ki({circular:!0,strict:!0});Ki({createInternalComparator:()=>cl});Ki({strict:!0,createInternalComparator:()=>cl});Ki({circular:!0,createInternalComparator:()=>cl});Ki({circular:!0,createInternalComparator:()=>cl,strict:!0});function Ki(e={}){const{circular:t=!1,createInternalComparator:r,createState:n,strict:a=!1}=e,i=bre(e),s=xre(i),l=r?r(s):wre(s);return Sre({circular:t,comparator:s,createState:n,equals:l,strict:a})}function Nre(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function kM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function a(i){r<0&&(r=i),i-r>t?(e(i),r=-1):Nre(a)};requestAnimationFrame(n)}function Zj(e){"@babel/helpers - typeof";return Zj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Zj(e)}function Cre(e){return Ore(e)||Pre(e)||Ere(e)||_re()}function _re(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ere(e,t){if(e){if(typeof e=="string")return AM(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return AM(e,t)}}function AM(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1?1:j<0?0:j},b=function(j){for(var N=j>1?1:j,C=N,O=0;O<8;++O){var P=h(C)-N,E=g(C);if(Math.abs(P-N)0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,n=r===void 0?100:r,a=t.damping,i=a===void 0?8:a,s=t.dt,l=s===void 0?17:s,d=function(f,h,p){var g=-(f-h)*n,x=p*i,b=p+(g-x)*l/1e3,w=p*l/1e3+f;return Math.abs(w-h)e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function ine(e,t){if(e==null)return{};var r={},n=Object.keys(e),a,i;for(i=0;i=0)&&(r[a]=e[a]);return r}function sS(e){return une(e)||cne(e)||lne(e)||sne()}function sne(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lne(e,t){if(e){if(typeof e=="string")return aN(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return aN(e,t)}}function cne(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function une(e){if(Array.isArray(e))return aN(e)}function aN(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Tg(e){return Tg=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Tg(e)}var So=(function(e){pne(r,e);var t=gne(r);function r(n,a){var i;dne(this,r),i=t.call(this,n,a);var s=i.props,l=s.isActive,d=s.attributeName,c=s.from,f=s.to,h=s.steps,p=s.children,g=s.duration;if(i.handleStyleChange=i.handleStyleChange.bind(sN(i)),i.changeStyle=i.changeStyle.bind(sN(i)),!l||g<=0)return i.state={style:{}},typeof p=="function"&&(i.state={style:f}),iN(i);if(h&&h.length)i.state={style:h[0].style};else if(c){if(typeof p=="function")return i.state={style:c},iN(i);i.state={style:d?Dd({},d,c):c}}else i.state={style:{}};return i}return hne(r,[{key:"componentDidMount",value:function(){var a=this.props,i=a.isActive,s=a.canBegin;this.mounted=!0,!(!i||!s)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var i=this.props,s=i.isActive,l=i.canBegin,d=i.attributeName,c=i.shouldReAnimate,f=i.to,h=i.from,p=this.state.style;if(l){if(!s){var g={style:d?Dd({},d,f):f};this.state&&p&&(d&&p[d]!==f||!d&&p!==f)&&this.setState(g);return}if(!(jre(a.to,f)&&a.canBegin&&a.isActive)){var x=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var b=x||c?h:a.to;if(this.state&&p){var w={style:d?Dd({},d,b):b};(d&&p[d]!==b||!d&&p!==b)&&this.setState(w)}this.runAnimation(Ua(Ua({},this.props),{},{from:b,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var i=this,s=a.from,l=a.to,d=a.duration,c=a.easing,f=a.begin,h=a.onAnimationEnd,p=a.onAnimationStart,g=nne(s,l,Hre(c),d,this.changeStyle),x=function(){i.stopJSAnimation=g()};this.manager.start([p,f,x,d,h])}},{key:"runStepAnimation",value:function(a){var i=this,s=a.steps,l=a.begin,d=a.onAnimationStart,c=s[0],f=c.style,h=c.duration,p=h===void 0?0:h,g=function(b,w,j){if(j===0)return b;var N=w.duration,C=w.easing,O=C===void 0?"ease":C,P=w.style,E=w.properties,T=w.onAnimationEnd,A=j>0?s[j-1]:w,I=E||Object.keys(P);if(typeof O=="function"||O==="spring")return[].concat(sS(b),[i.runJSAnimation.bind(i,{from:A.style,to:P,duration:N,easing:O}),N]);var R=RM(I,N,O),L=Ua(Ua(Ua({},A.style),P),{},{transition:R});return[].concat(sS(b),[L,N,T]).filter(Mre)};return this.manager.start([d].concat(sS(s.reduce(g,[f,Math.max(p,l)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=Tre());var i=a.begin,s=a.duration,l=a.attributeName,d=a.to,c=a.easing,f=a.onAnimationStart,h=a.onAnimationEnd,p=a.steps,g=a.children,x=this.manager;if(this.unSubscribe=x.subscribe(this.handleStyleChange),typeof c=="function"||typeof g=="function"||c==="spring"){this.runJSAnimation(a);return}if(p.length>1){this.runStepAnimation(a);return}var b=l?Dd({},l,d):d,w=RM(Object.keys(b),s,c);x.start([f,i,Ua(Ua({},b),{},{transition:w}),s,h])}},{key:"render",value:function(){var a=this.props,i=a.children;a.begin;var s=a.duration;a.attributeName,a.easing;var l=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var d=one(a,ane),c=v.Children.count(i),f=this.state.style;if(typeof i=="function")return i(f);if(!l||c===0||s<=0)return i;var h=function(g){var x=g.props,b=x.style,w=b===void 0?{}:b,j=x.className,N=v.cloneElement(g,Ua(Ua({},d),{},{style:Ua(Ua({},w),f),className:j}));return N};return c===1?h(v.Children.only(i)):U.createElement("div",null,v.Children.map(i,function(p){return h(p)}))}}]),r})(v.PureComponent);So.displayName="Animate";So.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};So.propTypes={from:Gt.oneOfType([Gt.object,Gt.string]),to:Gt.oneOfType([Gt.object,Gt.string]),attributeName:Gt.string,duration:Gt.number,begin:Gt.number,easing:Gt.oneOfType([Gt.string,Gt.func]),steps:Gt.arrayOf(Gt.shape({duration:Gt.number.isRequired,style:Gt.object.isRequired,easing:Gt.oneOfType([Gt.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Gt.func]),properties:Gt.arrayOf("string"),onAnimationEnd:Gt.func})),children:Gt.oneOfType([Gt.node,Gt.func]),isActive:Gt.bool,canBegin:Gt.bool,onAnimationEnd:Gt.func,shouldReAnimate:Gt.bool,onAnimationStart:Gt.func,onAnimationReStart:Gt.func};function vf(e){"@babel/helpers - typeof";return vf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vf(e)}function kg(){return kg=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0?1:-1,d=n>=0?1:-1,c=a>=0&&n>=0||a<0&&n<0?1:0,f;if(s>0&&i instanceof Array){for(var h=[0,0,0,0],p=0,g=4;ps?s:i[p];f="M".concat(t,",").concat(r+l*h[0]),h[0]>0&&(f+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(c,",").concat(t+d*h[0],",").concat(r)),f+="L ".concat(t+n-d*h[1],",").concat(r),h[1]>0&&(f+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(c,`, + `).concat(t+n,",").concat(r+l*h[1])),f+="L ".concat(t+n,",").concat(r+a-l*h[2]),h[2]>0&&(f+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(c,`, + `).concat(t+n-d*h[2],",").concat(r+a)),f+="L ".concat(t+d*h[3],",").concat(r+a),h[3]>0&&(f+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(c,`, + `).concat(t,",").concat(r+a-l*h[3])),f+="Z"}else if(s>0&&i===+i&&i>0){var x=Math.min(s,i);f="M ".concat(t,",").concat(r+l*x,` + A `).concat(x,",").concat(x,",0,0,").concat(c,",").concat(t+d*x,",").concat(r,` + L `).concat(t+n-d*x,",").concat(r,` + A `).concat(x,",").concat(x,",0,0,").concat(c,",").concat(t+n,",").concat(r+l*x,` + L `).concat(t+n,",").concat(r+a-l*x,` + A `).concat(x,",").concat(x,",0,0,").concat(c,",").concat(t+n-d*x,",").concat(r+a,` + L `).concat(t+d*x,",").concat(r+a,` + A `).concat(x,",").concat(x,",0,0,").concat(c,",").concat(t,",").concat(r+a-l*x," Z")}else f="M ".concat(t,",").concat(r," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return f},_ne=function(t,r){if(!t||!r)return!1;var n=t.x,a=t.y,i=r.x,s=r.y,l=r.width,d=r.height;if(Math.abs(l)>0&&Math.abs(d)>0){var c=Math.min(i,i+l),f=Math.max(i,i+l),h=Math.min(s,s+d),p=Math.max(s,s+d);return n>=c&&n<=f&&a>=h&&a<=p}return!1},Ene={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},d_=function(t){var r=qM(qM({},Ene),t),n=v.useRef(),a=v.useState(-1),i=vne(a,2),s=i[0],l=i[1];v.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var O=n.current.getTotalLength();O&&l(O)}catch{}},[]);var d=r.x,c=r.y,f=r.width,h=r.height,p=r.radius,g=r.className,x=r.animationEasing,b=r.animationDuration,w=r.animationBegin,j=r.isAnimationActive,N=r.isUpdateAnimationActive;if(d!==+d||c!==+c||f!==+f||h!==+h||f===0||h===0)return null;var C=vt("recharts-rectangle",g);return N?U.createElement(So,{canBegin:s>0,from:{width:f,height:h,x:d,y:c},to:{width:f,height:h,x:d,y:c},duration:b,animationEasing:x,isActive:N},function(O){var P=O.width,E=O.height,T=O.x,A=O.y;return U.createElement(So,{canBegin:s>0,from:"0px ".concat(s===-1?1:s,"px"),to:"".concat(s,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:b,isActive:j,easing:x},U.createElement("path",kg({},lt(r,!0),{className:C,d:VM(T,A,P,E,p),ref:n})))}):U.createElement("path",kg({},lt(r,!0),{className:C,d:VM(d,c,f,h,p)}))},Pne=["points","className","baseLinePoints","connectNulls"];function sc(){return sc=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Tne(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function WM(e){return Mne(e)||Ine(e)||Ane(e)||kne()}function kne(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ane(e,t){if(e){if(typeof e=="string")return lN(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return lN(e,t)}}function Ine(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Mne(e){if(Array.isArray(e))return lN(e)}function lN(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return t.forEach(function(n){HM(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),HM(t[0])&&r[r.length-1].push(t[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},Ud=function(t,r){var n=Rne(t);r&&(n=[n.reduce(function(i,s){return[].concat(WM(i),WM(s))},[])]);var a=n.map(function(i){return i.reduce(function(s,l,d){return"".concat(s).concat(d===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return n.length===1?"".concat(a,"Z"):a},Dne=function(t,r,n){var a=Ud(t,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(Ud(r.reverse(),n).slice(1))},Lne=function(t){var r=t.points,n=t.className,a=t.baseLinePoints,i=t.connectNulls,s=One(t,Pne);if(!r||!r.length)return null;var l=vt("recharts-polygon",n);if(a&&a.length){var d=s.stroke&&s.stroke!=="none",c=Dne(r,a,i);return U.createElement("g",{className:l},U.createElement("path",sc({},lt(s,!0),{fill:c.slice(-1)==="Z"?s.fill:"none",stroke:"none",d:c})),d?U.createElement("path",sc({},lt(s,!0),{fill:"none",d:Ud(r,i)})):null,d?U.createElement("path",sc({},lt(s,!0),{fill:"none",d:Ud(a,i)})):null)}var f=Ud(r,i);return U.createElement("path",sc({},lt(s,!0),{fill:f.slice(-1)==="Z"?s.fill:"none",className:l,d:f}))};function cN(){return cN=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Vne(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var Wne=function(t,r,n,a,i,s){return"M".concat(t,",").concat(i,"v").concat(a,"M").concat(s,",").concat(r,"h").concat(n)},Hne=function(t){var r=t.x,n=r===void 0?0:r,a=t.y,i=a===void 0?0:a,s=t.top,l=s===void 0?0:s,d=t.left,c=d===void 0?0:d,f=t.width,h=f===void 0?0:f,p=t.height,g=p===void 0?0:p,x=t.className,b=qne(t,$ne),w=Fne({x:n,y:i,top:l,left:c,width:h,height:g},b);return!Re(n)||!Re(i)||!Re(h)||!Re(g)||!Re(l)||!Re(c)?null:U.createElement("path",uN({},lt(w,!0),{className:vt("recharts-cross",x),d:Wne(n,i,h,g,l,c)}))},lS,YM;function Gne(){if(YM)return lS;YM=1;var e=Dy(),t=Y3(),r=To();function n(a,i){return a&&a.length?e(a,r(i,2),t):void 0}return lS=n,lS}var Yne=Gne();const Kne=Wt(Yne);var cS,KM;function Xne(){if(KM)return cS;KM=1;var e=Dy(),t=To(),r=K3();function n(a,i){return a&&a.length?e(a,t(i,2),r):void 0}return cS=n,cS}var Jne=Xne();const Qne=Wt(Jne);var Zne=["cx","cy","angle","ticks","axisLine"],eae=["ticks","tick","angle","tickFormatter","stroke"];function Dc(e){"@babel/helpers - typeof";return Dc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dc(e)}function qd(){return qd=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function tae(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function rae(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function QM(e,t){for(var r=0;rtR?s=a==="outer"?"start":"end":i<-tR?s=a==="outer"?"end":"start":s="middle",s}},{key:"renderAxisLine",value:function(){var n=this.props,a=n.cx,i=n.cy,s=n.radius,l=n.axisLine,d=n.axisLineType,c=Ss(Ss({},lt(this.props,!1)),{},{fill:"none"},lt(l,!1));if(d==="circle")return U.createElement(zy,As({className:"recharts-polar-angle-axis-line"},c,{cx:a,cy:i,r:s}));var f=this.props.ticks,h=f.map(function(p){return or(a,i,s,p.coordinate)});return U.createElement(Lne,As({className:"recharts-polar-angle-axis-line"},c,{points:h}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,i=a.ticks,s=a.tick,l=a.tickLine,d=a.tickFormatter,c=a.stroke,f=lt(this.props,!1),h=lt(s,!1),p=Ss(Ss({},f),{},{fill:"none"},lt(l,!1)),g=i.map(function(x,b){var w=n.getTickLineCoord(x),j=n.getTickTextAnchor(x),N=Ss(Ss(Ss({textAnchor:j},f),{},{stroke:"none",fill:c},h),{},{index:b,payload:x,x:w.x2,y:w.y2});return U.createElement(Bt,As({className:vt("recharts-polar-angle-axis-tick",j5(s)),key:"tick-".concat(x.coordinate)},qs(n.props,x,b)),l&&U.createElement("line",As({className:"recharts-polar-angle-axis-tick-line"},p,w)),s&&t.renderTickItem(s,N,d?d(x.value,b):x.value))});return U.createElement(Bt,{className:"recharts-polar-angle-axis-ticks"},g)}},{key:"render",value:function(){var n=this.props,a=n.ticks,i=n.radius,s=n.axisLine;return i<=0||!a||!a.length?null:U.createElement(Bt,{className:vt("recharts-polar-angle-axis",this.props.className)},s&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,a,i){var s;return U.isValidElement(n)?s=U.cloneElement(n,a):mt(n)?s=n(a):s=U.createElement(Vs,As({},a,{className:"recharts-polar-angle-axis-tick-value"}),i),s}}])})(v.PureComponent);Vy(Wy,"displayName","PolarAngleAxis");Vy(Wy,"axisType","angleAxis");Vy(Wy,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var uS,rR;function yae(){if(rR)return uS;rR=1;var e=Y4(),t=e(Object.getPrototypeOf,Object);return uS=t,uS}var dS,nR;function vae(){if(nR)return dS;nR=1;var e=ci(),t=yae(),r=ui(),n="[object Object]",a=Function.prototype,i=Object.prototype,s=a.toString,l=i.hasOwnProperty,d=s.call(Object);function c(f){if(!r(f)||e(f)!=n)return!1;var h=t(f);if(h===null)return!0;var p=l.call(h,"constructor")&&h.constructor;return typeof p=="function"&&p instanceof p&&s.call(p)==d}return dS=c,dS}var xae=vae();const bae=Wt(xae);var fS,aR;function wae(){if(aR)return fS;aR=1;var e=ci(),t=ui(),r="[object Boolean]";function n(a){return a===!0||a===!1||t(a)&&e(a)==r}return fS=n,fS}var Sae=wae();const jae=Wt(Sae);function bf(e){"@babel/helpers - typeof";return bf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bf(e)}function Mg(){return Mg=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r0,from:{upperWidth:0,lowerWidth:0,height:p,x:d,y:c},to:{upperWidth:f,lowerWidth:h,height:p,x:d,y:c},duration:b,animationEasing:x,isActive:j},function(C){var O=C.upperWidth,P=C.lowerWidth,E=C.height,T=C.x,A=C.y;return U.createElement(So,{canBegin:s>0,from:"0px ".concat(s===-1?1:s,"px"),to:"".concat(s,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:b,easing:x},U.createElement("path",Mg({},lt(r,!0),{className:N,d:lR(T,A,O,P,E),ref:n})))}):U.createElement("g",null,U.createElement("path",Mg({},lt(r,!0),{className:N,d:lR(d,c,f,h,p)})))},Mae=["option","shapeType","propTransformer","activeClassName","isActive"];function wf(e){"@babel/helpers - typeof";return wf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wf(e)}function Rae(e,t){if(e==null)return{};var r=Dae(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Dae(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function cR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Rg(e){for(var t=1;t0?ua(C,"paddingAngle",0):0;if(P){var T=ra(P.endAngle-P.startAngle,C.endAngle-C.startAngle),A=nr(nr({},C),{},{startAngle:N+E,endAngle:N+T(b)+E});w.push(A),N=A.endAngle}else{var I=C.endAngle,R=C.startAngle,L=ra(0,I-R),V=L(b),z=nr(nr({},C),{},{startAngle:N+E,endAngle:N+V+E});w.push(z),N=z.endAngle}}),U.createElement(Bt,null,n.renderSectorsStatically(w))})}},{key:"attachKeyboardHandlers",value:function(n){var a=this;n.onkeydown=function(i){if(!i.altKey)switch(i.key){case"ArrowLeft":{var s=++a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[s].focus(),a.setState({sectorToFocus:s});break}case"ArrowRight":{var l=--a.state.sectorToFocus<0?a.sectorRefs.length-1:a.state.sectorToFocus%a.sectorRefs.length;a.sectorRefs[l].focus(),a.setState({sectorToFocus:l});break}case"Escape":{a.sectorRefs[a.state.sectorToFocus].blur(),a.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,a=n.sectors,i=n.isAnimationActive,s=this.state.prevSectors;return i&&a&&a.length&&(!s||!Vf(s,a))?this.renderSectorsWithAnimation():this.renderSectorsStatically(a)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,a=this.props,i=a.hide,s=a.sectors,l=a.className,d=a.label,c=a.cx,f=a.cy,h=a.innerRadius,p=a.outerRadius,g=a.isAnimationActive,x=this.state.isAnimationFinished;if(i||!s||!s.length||!Re(c)||!Re(f)||!Re(h)||!Re(p))return null;var b=vt("recharts-pie",l);return U.createElement(Bt,{tabIndex:this.props.rootTabIndex,className:b,ref:function(j){n.pieRef=j}},this.renderSectors(),d&&this.renderLabels(s),Yr.renderCallByParent(this.props,null,!1),(!g||x)&&ti.renderCallByParent(this.props,s,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?N:N-1)*d,O=w-N*g-C,P=a.reduce(function(A,I){var R=Br(I,j,0);return A+(Re(R)?R:0)},0),E;if(P>0){var T;E=a.map(function(A,I){var R=Br(A,j,0),L=Br(A,f,I),V=(Re(R)?R:0)/P,z;I?z=T.endAngle+Sn(b)*d*(R!==0?1:0):z=s;var G=z+Sn(b)*((R!==0?g:0)+V*O),H=(z+G)/2,W=(x.innerRadius+x.outerRadius)/2,q=[{name:L,value:R,payload:A,dataKey:j,type:p}],M=or(x.cx,x.cy,W,H);return T=nr(nr(nr({percent:V,cornerRadius:i,name:L,tooltipPayload:q,midAngle:H,middleRadius:W,tooltipPosition:M},A),x),{},{value:Br(A,j),startAngle:z,endAngle:G,payload:A,paddingAngle:Sn(b)*d}),T})}return nr(nr({},x),{},{sectors:E,data:a})});var hS,hR;function noe(){if(hR)return hS;hR=1;var e=Math.ceil,t=Math.max;function r(n,a,i,s){for(var l=-1,d=t(e((a-n)/(i||1)),0),c=Array(d);d--;)c[s?d:++l]=n,n+=i;return c}return hS=r,hS}var mS,mR;function z5(){if(mR)return mS;mR=1;var e=u3(),t=1/0,r=17976931348623157e292;function n(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var i=a<0?-1:1;return i*r}return a===a?a:0}return mS=n,mS}var pS,pR;function aoe(){if(pR)return pS;pR=1;var e=noe(),t=Py(),r=z5();function n(a){return function(i,s,l){return l&&typeof l!="number"&&t(i,s,l)&&(s=l=void 0),i=r(i),s===void 0?(s=i,i=0):s=r(s),l=l===void 0?i0&&n.handleDrag(a.changedTouches[0])}),Zn(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=n.props,i=a.endIndex,s=a.onDragEnd,l=a.startIndex;s?.({endIndex:i,startIndex:l})}),n.detachDragEndListener()}),Zn(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Zn(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Zn(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Zn(n,"handleSlideDragStart",function(a){var i=wR(a)?a.changedTouches[0]:a;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return goe(t,e),foe(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var a=n.startX,i=n.endX,s=this.state.scaleValues,l=this.props,d=l.gap,c=l.data,f=c.length-1,h=Math.min(a,i),p=Math.max(a,i),g=t.getIndexInRange(s,h),x=t.getIndexInRange(s,p);return{startIndex:g-g%d,endIndex:x===f?f:x-x%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,i=a.data,s=a.tickFormatter,l=a.dataKey,d=Br(i[n],l,n);return mt(s)?s(d,n):d}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var a=this.state,i=a.slideMoveStartX,s=a.startX,l=a.endX,d=this.props,c=d.x,f=d.width,h=d.travellerWidth,p=d.startIndex,g=d.endIndex,x=d.onChange,b=n.pageX-i;b>0?b=Math.min(b,c+f-h-l,c+f-h-s):b<0&&(b=Math.max(b,c-s,c-l));var w=this.getIndex({startX:s+b,endX:l+b});(w.startIndex!==p||w.endIndex!==g)&&x&&x(w),this.setState({startX:s+b,endX:l+b,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var i=wR(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var a=this.state,i=a.brushMoveStartX,s=a.movingTravellerId,l=a.endX,d=a.startX,c=this.state[s],f=this.props,h=f.x,p=f.width,g=f.travellerWidth,x=f.onChange,b=f.gap,w=f.data,j={startX:this.state.startX,endX:this.state.endX},N=n.pageX-i;N>0?N=Math.min(N,h+p-g-c):N<0&&(N=Math.max(N,h-c)),j[s]=c+N;var C=this.getIndex(j),O=C.startIndex,P=C.endIndex,E=function(){var A=w.length-1;return s==="startX"&&(l>d?O%b===0:P%b===0)||ld?P%b===0:O%b===0)||l>d&&P===A};this.setState(Zn(Zn({},s,c+N),"brushMoveStartX",n.pageX),function(){x&&E()&&x(C)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var i=this,s=this.state,l=s.scaleValues,d=s.startX,c=s.endX,f=this.state[a],h=l.indexOf(f);if(h!==-1){var p=h+n;if(!(p===-1||p>=l.length)){var g=l[p];a==="startX"&&g>=c||a==="endX"&&g<=d||this.setState(Zn({},a,g),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,a=n.x,i=n.y,s=n.width,l=n.height,d=n.fill,c=n.stroke;return U.createElement("rect",{stroke:c,fill:d,x:a,y:i,width:s,height:l})}},{key:"renderPanorama",value:function(){var n=this.props,a=n.x,i=n.y,s=n.width,l=n.height,d=n.data,c=n.children,f=n.padding,h=v.Children.only(c);return h?U.cloneElement(h,{x:a,y:i,width:s,height:l,margin:f,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var i,s,l=this,d=this.props,c=d.y,f=d.travellerWidth,h=d.height,p=d.traveller,g=d.ariaLabel,x=d.data,b=d.startIndex,w=d.endIndex,j=Math.max(n,this.props.x),N=yS(yS({},lt(this.props,!1)),{},{x:j,y:c,width:f,height:h}),C=g||"Min value: ".concat((i=x[b])===null||i===void 0?void 0:i.name,", Max value: ").concat((s=x[w])===null||s===void 0?void 0:s.name);return U.createElement(Bt,{tabIndex:0,role:"slider","aria-label":C,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(P){["ArrowLeft","ArrowRight"].includes(P.key)&&(P.preventDefault(),P.stopPropagation(),l.handleTravellerMoveKeyboard(P.key==="ArrowRight"?1:-1,a))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(p,N))}},{key:"renderSlide",value:function(n,a){var i=this.props,s=i.y,l=i.height,d=i.stroke,c=i.travellerWidth,f=Math.min(n,a)+c,h=Math.max(Math.abs(a-n)-c,0);return U.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:d,fillOpacity:.2,x:f,y:s,width:h,height:l})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,i=n.endIndex,s=n.y,l=n.height,d=n.travellerWidth,c=n.stroke,f=this.state,h=f.startX,p=f.endX,g=5,x={pointerEvents:"none",fill:c};return U.createElement(Bt,{className:"recharts-brush-texts"},U.createElement(Vs,$g({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,p)-g,y:s+l/2},x),this.getTextOfTick(a)),U.createElement(Vs,$g({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,p)+d+g,y:s+l/2},x),this.getTextOfTick(i)))}},{key:"render",value:function(){var n=this.props,a=n.data,i=n.className,s=n.children,l=n.x,d=n.y,c=n.width,f=n.height,h=n.alwaysShowText,p=this.state,g=p.startX,x=p.endX,b=p.isTextActive,w=p.isSlideMoving,j=p.isTravellerMoving,N=p.isTravellerFocused;if(!a||!a.length||!Re(l)||!Re(d)||!Re(c)||!Re(f)||c<=0||f<=0)return null;var C=vt("recharts-brush",i),O=U.Children.count(s)===1,P=uoe("userSelect","none");return U.createElement(Bt,{className:C,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:P},this.renderBackground(),O&&this.renderPanorama(),this.renderSlide(g,x),this.renderTravellerLayer(g,"startX"),this.renderTravellerLayer(x,"endX"),(b||w||j||N||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,i=n.y,s=n.width,l=n.height,d=n.stroke,c=Math.floor(i+l/2)-1;return U.createElement(U.Fragment,null,U.createElement("rect",{x:a,y:i,width:s,height:l,fill:d,stroke:"none"}),U.createElement("line",{x1:a+1,y1:c,x2:a+s-1,y2:c,fill:"none",stroke:"#fff"}),U.createElement("line",{x1:a+1,y1:c+2,x2:a+s-1,y2:c+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var i;return U.isValidElement(n)?i=U.cloneElement(n,a):mt(n)?i=n(a):i=t.renderDefaultTraveller(a),i}},{key:"getDerivedStateFromProps",value:function(n,a){var i=n.data,s=n.width,l=n.x,d=n.travellerWidth,c=n.updateId,f=n.startIndex,h=n.endIndex;if(i!==a.prevData||c!==a.prevUpdateId)return yS({prevData:i,prevTravellerWidth:d,prevUpdateId:c,prevX:l,prevWidth:s},i&&i.length?voe({data:i,width:s,x:l,travellerWidth:d,startIndex:f,endIndex:h}):{scale:null,scaleValues:null});if(a.scale&&(s!==a.prevWidth||l!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([l,l+s-d]);var p=a.scale.domain().map(function(g){return a.scale(g)});return{prevData:i,prevTravellerWidth:d,prevUpdateId:c,prevX:l,prevWidth:s,startX:a.scale(n.startIndex),endX:a.scale(n.endIndex),scaleValues:p}}return null}},{key:"getIndexInRange",value:function(n,a){for(var i=n.length,s=0,l=i-1;l-s>1;){var d=Math.floor((s+l)/2);n[d]>a?l=d:s=d}return a>=n[l]?l:s}}])})(v.PureComponent);Zn(Bc,"displayName","Brush");Zn(Bc,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var vS,SR;function xoe(){if(SR)return vS;SR=1;var e=LC();function t(r,n){var a;return e(r,function(i,s,l){return a=n(i,s,l),!a}),!!a}return vS=t,vS}var xS,jR;function boe(){if(jR)return xS;jR=1;var e=z4(),t=To(),r=xoe(),n=qn(),a=Py();function i(s,l,d){var c=n(s)?e:r;return d&&a(s,l,d)&&(l=void 0),c(s,t(l,3))}return xS=i,xS}var woe=boe();const Soe=Wt(woe);var xo=function(t,r){var n=t.alwaysShow,a=t.ifOverflow;return n&&(a="extendDomain"),a===r},bS,NR;function joe(){if(NR)return bS;NR=1;var e=o3();function t(r,n,a){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):r[n]=a}return bS=t,bS}var wS,CR;function Noe(){if(CR)return wS;CR=1;var e=joe(),t=n3(),r=To();function n(a,i){var s={};return i=r(i,3),t(a,function(l,d,c){e(s,d,i(l,d,c))}),s}return wS=n,wS}var Coe=Noe();const _oe=Wt(Coe);var SS,_R;function Eoe(){if(_R)return SS;_R=1;function e(t,r){for(var n=-1,a=t==null?0:t.length;++n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Doe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Loe(e,t){var r=e.x,n=e.y,a=Roe(e,koe),i="".concat(r),s=parseInt(i,10),l="".concat(n),d=parseInt(l,10),c="".concat(t.height||a.height),f=parseInt(c,10),h="".concat(t.width||a.width),p=parseInt(h,10);return Sd(Sd(Sd(Sd(Sd({},t),a),s?{x:s}:{}),d?{y:d}:{}),{},{height:f,width:p,name:t.name,radius:t.radius})}function TR(e){return U.createElement($5,pN({shapeType:"rectangle",propTransformer:Loe,activeClassName:"recharts-active-bar"},e))}var $oe=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof t=="number")return t;var i=Re(n)||aH(n);return i?t(n,a):(i||Hs(),r)}},Foe=["value","background"],H5;function zc(e){"@babel/helpers - typeof";return zc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zc(e)}function Boe(e,t){if(e==null)return{};var r=zoe(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function zoe(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Bg(){return Bg=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&Math.abs(H)0&&Math.abs(G)0&&(z=Math.min((J||0)-(G[oe-1]||0),z))}),Number.isFinite(z)){var H=z/V,W=b.layout==="vertical"?n.height:n.width;if(b.padding==="gap"&&(T=H*W/2),b.padding==="no-gap"){var q=jn(t.barCategoryGap,H*W),M=H*W/2;T=M-q-(M-q)/W*q}}}a==="xAxis"?A=[n.left+(C.left||0)+(T||0),n.left+n.width-(C.right||0)-(T||0)]:a==="yAxis"?A=d==="horizontal"?[n.top+n.height-(C.bottom||0),n.top+(C.top||0)]:[n.top+(C.top||0)+(T||0),n.top+n.height-(C.bottom||0)-(T||0)]:A=b.range,P&&(A=[A[1],A[0]]);var Y=g5(b,i,p),F=Y.scale,D=Y.realScaleType;F.domain(j).range(A),y5(F);var $=v5(F,Ha(Ha({},b),{},{realScaleType:D}));a==="xAxis"?(L=w==="top"&&!O||w==="bottom"&&O,I=n.left,R=h[E]-L*b.height):a==="yAxis"&&(L=w==="left"&&!O||w==="right"&&O,I=h[E]-L*b.width,R=n.top);var K=Ha(Ha(Ha({},b),$),{},{realScaleType:D,x:I,y:R,scale:F,width:a==="xAxis"?n.width:b.width,height:a==="yAxis"?n.height:b.height});return K.bandSize=jg(K,$),!b.hide&&a==="xAxis"?h[E]+=(L?-1:1)*K.height:b.hide||(h[E]+=(L?-1:1)*K.width),Ha(Ha({},g),{},Yy({},x,K))},{})},J5=function(t,r){var n=t.x,a=t.y,i=r.x,s=r.y;return{x:Math.min(n,i),y:Math.min(a,s),width:Math.abs(i-n),height:Math.abs(s-a)}},Qoe=function(t){var r=t.x1,n=t.y1,a=t.x2,i=t.y2;return J5({x:r,y:n},{x:a,y:i})},Q5=(function(){function e(t){Koe(this,e),this.scale=t}return Xoe(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,i=n.position;if(r!==void 0){if(i)switch(i){case"start":return this.scale(r);case"middle":{var s=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+s}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(r)+l}default:return this.scale(r)}if(a){var d=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+d}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),a=n[0],i=n[n.length-1];return a<=i?r>=a&&r<=i:r>=i&&r<=a}}],[{key:"create",value:function(r){return new e(r)}}])})();Yy(Q5,"EPS",1e-4);var f_=function(t){var r=Object.keys(t).reduce(function(n,a){return Ha(Ha({},n),{},Yy({},a,Q5.create(t[a])))},{});return Ha(Ha({},r),{},{apply:function(a){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=i.bandAware,l=i.position;return _oe(a,function(d,c){return r[c].apply(d,{bandAware:s,position:l})})},isInRange:function(a){return W5(a,function(i,s){return r[s].isInRange(i)})}})};function Zoe(e){return(e%180+180)%180}var eie=function(t){var r=t.width,n=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=Zoe(a),s=i*Math.PI/180,l=Math.atan(n/r),d=s>l&&s-1?d[c?i[f]:f]:void 0}}return CS=n,CS}var _S,DR;function rie(){if(DR)return _S;DR=1;var e=z5();function t(r){var n=e(r),a=n%1;return n===n?a?n-a:n:0}return _S=t,_S}var ES,LR;function nie(){if(LR)return ES;LR=1;var e=Q4(),t=To(),r=rie(),n=Math.max;function a(i,s,l){var d=i==null?0:i.length;if(!d)return-1;var c=l==null?0:r(l);return c<0&&(c=n(d+c,0)),e(i,t(s,3),c)}return ES=a,ES}var PS,$R;function aie(){if($R)return PS;$R=1;var e=tie(),t=nie(),r=e(t);return PS=r,PS}var oie=aie();const iie=Wt(oie);var sie=m4();const lie=Wt(sie);var cie=lie(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),h_=v.createContext(void 0),m_=v.createContext(void 0),Z5=v.createContext(void 0),eF=v.createContext({}),tF=v.createContext(void 0),rF=v.createContext(0),nF=v.createContext(0),FR=function(t){var r=t.state,n=r.xAxisMap,a=r.yAxisMap,i=r.offset,s=t.clipPathId,l=t.children,d=t.width,c=t.height,f=cie(i);return U.createElement(h_.Provider,{value:n},U.createElement(m_.Provider,{value:a},U.createElement(eF.Provider,{value:i},U.createElement(Z5.Provider,{value:f},U.createElement(tF.Provider,{value:s},U.createElement(rF.Provider,{value:c},U.createElement(nF.Provider,{value:d},l)))))))},uie=function(){return v.useContext(tF)},aF=function(t){var r=v.useContext(h_);r==null&&Hs();var n=r[t];return n==null&&Hs(),n},die=function(){var t=v.useContext(h_);return Li(t)},fie=function(){var t=v.useContext(m_),r=iie(t,function(n){return W5(n.domain,Number.isFinite)});return r||Li(t)},oF=function(t){var r=v.useContext(m_);r==null&&Hs();var n=r[t];return n==null&&Hs(),n},hie=function(){var t=v.useContext(Z5);return t},mie=function(){return v.useContext(eF)},p_=function(){return v.useContext(nF)},g_=function(){return v.useContext(rF)};function Uc(e){"@babel/helpers - typeof";return Uc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Uc(e)}function pie(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gie(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);re*a)return!1;var i=r();return e*(t-e*i/2-n)>=0&&e*(t+e*i/2-a)<=0}function Jie(e,t){return fF(e,t+1)}function Qie(e,t,r,n,a){for(var i=(n||[]).slice(),s=t.start,l=t.end,d=0,c=1,f=s,h=function(){var x=n?.[d];if(x===void 0)return{v:fF(n,c)};var b=d,w,j=function(){return w===void 0&&(w=r(x,b)),w},N=x.coordinate,C=d===0||Wg(e,N,j,f,l);C||(d=0,f=s,c+=1),C&&(f=N+e*(j()/2+a),d+=c)},p;c<=i.length;)if(p=h(),p)return p.v;return[]}function _f(e){"@babel/helpers - typeof";return _f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_f(e)}function GR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ln(e){for(var t=1;t0?g.coordinate-w*e:g.coordinate})}else i[p]=g=ln(ln({},g),{},{tickCoord:g.coordinate});var j=Wg(e,g.tickCoord,b,l,d);j&&(d=g.tickCoord-e*(b()/2+a),i[p]=ln(ln({},g),{},{isShow:!0}))},f=s-1;f>=0;f--)c(f);return i}function nse(e,t,r,n,a,i){var s=(n||[]).slice(),l=s.length,d=t.start,c=t.end;if(i){var f=n[l-1],h=r(f,l-1),p=e*(f.coordinate+e*h/2-c);s[l-1]=f=ln(ln({},f),{},{tickCoord:p>0?f.coordinate-p*e:f.coordinate});var g=Wg(e,f.tickCoord,function(){return h},d,c);g&&(c=f.tickCoord-e*(h/2+a),s[l-1]=ln(ln({},f),{},{isShow:!0}))}for(var x=i?l-1:l,b=function(N){var C=s[N],O,P=function(){return O===void 0&&(O=r(C,N)),O};if(N===0){var E=e*(C.coordinate-e*P()/2-d);s[N]=C=ln(ln({},C),{},{tickCoord:E<0?C.coordinate-E*e:C.coordinate})}else s[N]=C=ln(ln({},C),{},{tickCoord:C.coordinate});var T=Wg(e,C.tickCoord,P,d,c);T&&(d=C.tickCoord+e*(P()/2+a),s[N]=ln(ln({},C),{},{isShow:!0}))},w=0;w=2?Sn(a[1].coordinate-a[0].coordinate):1,j=Xie(i,w,g);return d==="equidistantPreserveStart"?Qie(w,j,b,a,s):(d==="preserveStart"||d==="preserveStartEnd"?p=nse(w,j,b,a,s,d==="preserveStartEnd"):p=rse(w,j,b,a,s),p.filter(function(N){return N.isShow}))}var ase=["viewBox"],ose=["viewBox"],ise=["ticks"];function Wc(e){"@babel/helpers - typeof";return Wc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wc(e)}function cc(){return cc=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function sse(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function lse(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function KR(e,t){for(var r=0;r0?d(this.props):d(g)),s<=0||l<=0||!x||!x.length?null:U.createElement(Bt,{className:vt("recharts-cartesian-axis",c),ref:function(w){n.layerReference=w}},i&&this.renderAxisLine(),this.renderTicks(x,this.state.fontSize,this.state.letterSpacing),Yr.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,i){var s,l=vt(a.className,"recharts-cartesian-axis-tick-value");return U.isValidElement(n)?s=U.cloneElement(n,$r($r({},a),{},{className:l})):mt(n)?s=n($r($r({},a),{},{className:l})):s=U.createElement(Vs,cc({},a,{className:"recharts-cartesian-axis-tick-value"}),i),s}}])})(v.Component);b_(yu,"displayName","CartesianAxis");b_(yu,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var pse=["x1","y1","x2","y2","key"],gse=["offset"];function Gs(e){"@babel/helpers - typeof";return Gs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gs(e)}function XR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function un(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function bse(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}var wse=function(t){var r=t.fill;if(!r||r==="none")return null;var n=t.fillOpacity,a=t.x,i=t.y,s=t.width,l=t.height,d=t.ry;return U.createElement("rect",{x:a,y:i,ry:d,width:s,height:l,stroke:"none",fill:r,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function pF(e,t){var r;if(U.isValidElement(e))r=U.cloneElement(e,t);else if(mt(e))r=e(t);else{var n=t.x1,a=t.y1,i=t.x2,s=t.y2,l=t.key,d=JR(t,pse),c=lt(d,!1);c.offset;var f=JR(c,gse);r=U.createElement("line",Ds({},f,{x1:n,y1:a,x2:i,y2:s,fill:"none",key:l}))}return r}function Sse(e){var t=e.x,r=e.width,n=e.horizontal,a=n===void 0?!0:n,i=e.horizontalPoints;if(!a||!i||!i.length)return null;var s=i.map(function(l,d){var c=un(un({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(d),index:d});return pF(a,c)});return U.createElement("g",{className:"recharts-cartesian-grid-horizontal"},s)}function jse(e){var t=e.y,r=e.height,n=e.vertical,a=n===void 0?!0:n,i=e.verticalPoints;if(!a||!i||!i.length)return null;var s=i.map(function(l,d){var c=un(un({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(d),index:d});return pF(a,c)});return U.createElement("g",{className:"recharts-cartesian-grid-vertical"},s)}function Nse(e){var t=e.horizontalFill,r=e.fillOpacity,n=e.x,a=e.y,i=e.width,s=e.height,l=e.horizontalPoints,d=e.horizontal,c=d===void 0?!0:d;if(!c||!t||!t.length)return null;var f=l.map(function(p){return Math.round(p+a-a)}).sort(function(p,g){return p-g});a!==f[0]&&f.unshift(0);var h=f.map(function(p,g){var x=!f[g+1],b=x?a+s-p:f[g+1]-p;if(b<=0)return null;var w=g%t.length;return U.createElement("rect",{key:"react-".concat(g),y:p,x:n,height:b,width:i,stroke:"none",fill:t[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return U.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function Cse(e){var t=e.vertical,r=t===void 0?!0:t,n=e.verticalFill,a=e.fillOpacity,i=e.x,s=e.y,l=e.width,d=e.height,c=e.verticalPoints;if(!r||!n||!n.length)return null;var f=c.map(function(p){return Math.round(p+i-i)}).sort(function(p,g){return p-g});i!==f[0]&&f.unshift(0);var h=f.map(function(p,g){var x=!f[g+1],b=x?i+l-p:f[g+1]-p;if(b<=0)return null;var w=g%n.length;return U.createElement("rect",{key:"react-".concat(g),x:p,y:s,width:b,height:d,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return U.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var _se=function(t,r){var n=t.xAxis,a=t.width,i=t.height,s=t.offset;return p5(x_(un(un(un({},yu.defaultProps),n),{},{ticks:Ko(n,!0),viewBox:{x:0,y:0,width:a,height:i}})),s.left,s.left+s.width,r)},Ese=function(t,r){var n=t.yAxis,a=t.width,i=t.height,s=t.offset;return p5(x_(un(un(un({},yu.defaultProps),n),{},{ticks:Ko(n,!0),viewBox:{x:0,y:0,width:a,height:i}})),s.top,s.top+s.height,r)},Hl={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Gg(e){var t,r,n,a,i,s,l=p_(),d=g_(),c=mie(),f=un(un({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:Hl.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:Hl.fill,horizontal:(n=e.horizontal)!==null&&n!==void 0?n:Hl.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:Hl.horizontalFill,vertical:(i=e.vertical)!==null&&i!==void 0?i:Hl.vertical,verticalFill:(s=e.verticalFill)!==null&&s!==void 0?s:Hl.verticalFill,x:Re(e.x)?e.x:c.left,y:Re(e.y)?e.y:c.top,width:Re(e.width)?e.width:c.width,height:Re(e.height)?e.height:c.height}),h=f.x,p=f.y,g=f.width,x=f.height,b=f.syncWithTicks,w=f.horizontalValues,j=f.verticalValues,N=die(),C=fie();if(!Re(g)||g<=0||!Re(x)||x<=0||!Re(h)||h!==+h||!Re(p)||p!==+p)return null;var O=f.verticalCoordinatesGenerator||_se,P=f.horizontalCoordinatesGenerator||Ese,E=f.horizontalPoints,T=f.verticalPoints;if((!E||!E.length)&&mt(P)){var A=w&&w.length,I=P({yAxis:C?un(un({},C),{},{ticks:A?w:C.ticks}):void 0,width:l,height:d,offset:c},A?!0:b);Ka(Array.isArray(I),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(Gs(I),"]")),Array.isArray(I)&&(E=I)}if((!T||!T.length)&&mt(O)){var R=j&&j.length,L=O({xAxis:N?un(un({},N),{},{ticks:R?j:N.ticks}):void 0,width:l,height:d,offset:c},R?!0:b);Ka(Array.isArray(L),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(Gs(L),"]")),Array.isArray(L)&&(T=L)}return U.createElement("g",{className:"recharts-cartesian-grid"},U.createElement(wse,{fill:f.fill,fillOpacity:f.fillOpacity,x:f.x,y:f.y,width:f.width,height:f.height,ry:f.ry}),U.createElement(Sse,Ds({},f,{offset:c,horizontalPoints:E,xAxis:N,yAxis:C})),U.createElement(jse,Ds({},f,{offset:c,verticalPoints:T,xAxis:N,yAxis:C})),U.createElement(Nse,Ds({},f,{horizontalPoints:E})),U.createElement(Cse,Ds({},f,{verticalPoints:T})))}Gg.displayName="CartesianGrid";var Pse=["type","layout","connectNulls","ref"],Ose=["key"];function Hc(e){"@babel/helpers - typeof";return Hc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hc(e)}function QR(e,t){if(e==null)return{};var r=Tse(e,t),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Tse(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function Vd(){return Vd=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);rh){g=[].concat(Gl(d.slice(0,x)),[h-b]);break}var w=g.length%2===0?[0,p]:[p];return[].concat(Gl(t.repeat(d,f)),Gl(g),w).map(function(j){return"".concat(j,"px")}).join(", ")}),Ga(r,"id",fu("recharts-line-")),Ga(r,"pathRef",function(s){r.mainCurve=s}),Ga(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Ga(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return Bse(t,e),Dse(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,s=i.points,l=i.xAxis,d=i.yAxis,c=i.layout,f=i.children,h=da(f,Wf);if(!h)return null;var p=function(b,w){return{x:b.x,y:b.y,value:b.value,errorVal:Br(b.payload,w)}},g={clipPath:n?"url(#clipPath-".concat(a,")"):null};return U.createElement(Bt,g,h.map(function(x){return U.cloneElement(x,{key:"bar-".concat(x.props.dataKey),data:s,xAxis:l,yAxis:d,layout:c,dataPointFormatter:p})}))}},{key:"renderDots",value:function(n,a,i){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var l=this.props,d=l.dot,c=l.points,f=l.dataKey,h=lt(this.props,!1),p=lt(d,!0),g=c.map(function(b,w){var j=Qn(Qn(Qn({key:"dot-".concat(w),r:3},h),p),{},{index:w,cx:b.x,cy:b.y,value:b.value,dataKey:f,payload:b.payload,points:c});return t.renderDotItem(d,j)}),x={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return U.createElement(Bt,Vd({className:"recharts-line-dots",key:"dots"},x),g)}},{key:"renderCurveStatically",value:function(n,a,i,s){var l=this.props,d=l.type,c=l.layout,f=l.connectNulls;l.ref;var h=QR(l,Pse),p=Qn(Qn(Qn({},lt(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(i,")"):null,points:n},s),{},{type:d,layout:c,connectNulls:f});return U.createElement(_g,Vd({},p,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var i=this,s=this.props,l=s.points,d=s.strokeDasharray,c=s.isAnimationActive,f=s.animationBegin,h=s.animationDuration,p=s.animationEasing,g=s.animationId,x=s.animateNewValues,b=s.width,w=s.height,j=this.state,N=j.prevPoints,C=j.totalLength;return U.createElement(So,{begin:f,duration:h,isActive:c,easing:p,from:{t:0},to:{t:1},key:"line-".concat(g),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var P=O.t;if(N){var E=N.length/l.length,T=l.map(function(V,z){var G=Math.floor(z*E);if(N[G]){var H=N[G],W=ra(H.x,V.x),q=ra(H.y,V.y);return Qn(Qn({},V),{},{x:W(P),y:q(P)})}if(x){var M=ra(b*2,V.x),Y=ra(w/2,V.y);return Qn(Qn({},V),{},{x:M(P),y:Y(P)})}return Qn(Qn({},V),{},{x:V.x,y:V.y})});return i.renderCurveStatically(T,n,a)}var A=ra(0,C),I=A(P),R;if(d){var L="".concat(d).split(/[,\s]+/gim).map(function(V){return parseFloat(V)});R=i.getStrokeDasharray(I,C,L)}else R=i.generateSimpleStrokeDasharray(C,I);return i.renderCurveStatically(l,n,a,{strokeDasharray:R})})}},{key:"renderCurve",value:function(n,a){var i=this.props,s=i.points,l=i.isAnimationActive,d=this.state,c=d.prevPoints,f=d.totalLength;return l&&s&&s.length&&(!c&&f>0||!Vf(c,s))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(s,n,a)}},{key:"render",value:function(){var n,a=this.props,i=a.hide,s=a.dot,l=a.points,d=a.className,c=a.xAxis,f=a.yAxis,h=a.top,p=a.left,g=a.width,x=a.height,b=a.isAnimationActive,w=a.id;if(i||!l||!l.length)return null;var j=this.state.isAnimationFinished,N=l.length===1,C=vt("recharts-line",d),O=c&&c.allowDataOverflow,P=f&&f.allowDataOverflow,E=O||P,T=yt(w)?this.id:w,A=(n=lt(s,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},I=A.r,R=I===void 0?3:I,L=A.strokeWidth,V=L===void 0?2:L,z=gH(s)?s:{},G=z.clipDot,H=G===void 0?!0:G,W=R*2+V;return U.createElement(Bt,{className:C},O||P?U.createElement("defs",null,U.createElement("clipPath",{id:"clipPath-".concat(T)},U.createElement("rect",{x:O?p:p-g/2,y:P?h:h-x/2,width:O?g:g*2,height:P?x:x*2})),!H&&U.createElement("clipPath",{id:"clipPath-dots-".concat(T)},U.createElement("rect",{x:p-W/2,y:h-W/2,width:g+W,height:x+W}))):null,!N&&this.renderCurve(E,T),this.renderErrorBar(E,T),(N||s)&&this.renderDots(E,H,T),(!b||j)&&ti.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var i=n.length%2!==0?[].concat(Gl(n),[0]):n,s=[],l=0;le.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function Tle(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function kle(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ale(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=new Array(t);r0?s:t&&t.length&&Re(a)&&Re(i)?t.slice(a,i+1):[]};function TF(e){return e==="number"?[0,"auto"]:void 0}var MN=function(t,r,n,a){var i=t.graphicalItems,s=t.tooltipAxis,l=Zy(r,t);return n<0||!i||!i.length||n>=l.length?null:i.reduce(function(d,c){var f,h=(f=c.props.data)!==null&&f!==void 0?f:r;h&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(h=h.slice(t.dataStartIndex,t.dataEndIndex+1));var p;if(s.dataKey&&!s.allowDuplicatedCategory){var g=h===void 0?l:h;p=Xp(g,s.dataKey,a)}else p=h&&h[n]||l[n];return p?[].concat(Xc(d),[b5(c,p)]):d},[])},sD=function(t,r,n,a){var i=a||{x:t.chartX,y:t.chartY},s=Vle(i,n),l=t.orderedTooltipTicks,d=t.tooltipAxis,c=t.tooltipTicks,f=hee(s,l,c,d);if(f>=0&&c){var h=c[f]&&c[f].value,p=MN(t,r,f,h),g=Wle(n,l,f,i);return{activeTooltipIndex:f,activeLabel:h,activePayload:p,activeCoordinate:g}}return null},Hle=function(t,r){var n=r.axes,a=r.graphicalItems,i=r.axisType,s=r.axisIdKey,l=r.stackGroups,d=r.dataStartIndex,c=r.dataEndIndex,f=t.layout,h=t.children,p=t.stackOffset,g=m5(f,i);return n.reduce(function(x,b){var w,j=b.type.defaultProps!==void 0?je(je({},b.type.defaultProps),b.props):b.props,N=j.type,C=j.dataKey,O=j.allowDataOverflow,P=j.allowDuplicatedCategory,E=j.scale,T=j.ticks,A=j.includeHidden,I=j[s];if(x[I])return x;var R=Zy(t.data,{graphicalItems:a.filter(function($){var K,J=s in $.props?$.props[s]:(K=$.type.defaultProps)===null||K===void 0?void 0:K[s];return J===I}),dataStartIndex:d,dataEndIndex:c}),L=R.length,V,z,G;vle(j.domain,O,N)&&(V=Yj(j.domain,null,O),g&&(N==="number"||E!=="auto")&&(G=Bd(R,C,"category")));var H=TF(N);if(!V||V.length===0){var W,q=(W=j.domain)!==null&&W!==void 0?W:H;if(C){if(V=Bd(R,C,N),N==="category"&&g){var M=iH(V);P&&M?(z=V,V=Lg(0,L)):P||(V=cM(q,V,b).reduce(function($,K){return $.indexOf(K)>=0?$:[].concat(Xc($),[K])},[]))}else if(N==="category")P?V=V.filter(function($){return $!==""&&!yt($)}):V=cM(q,V,b).reduce(function($,K){return $.indexOf(K)>=0||K===""||yt(K)?$:[].concat(Xc($),[K])},[]);else if(N==="number"){var Y=vee(R,a.filter(function($){var K,J,oe=s in $.props?$.props[s]:(K=$.type.defaultProps)===null||K===void 0?void 0:K[s],re="hide"in $.props?$.props.hide:(J=$.type.defaultProps)===null||J===void 0?void 0:J.hide;return oe===I&&(A||!re)}),C,i,f);Y&&(V=Y)}g&&(N==="number"||E!=="auto")&&(G=Bd(R,C,"category"))}else g?V=Lg(0,L):l&&l[I]&&l[I].hasStack&&N==="number"?V=p==="expand"?[0,1]:x5(l[I].stackGroups,d,c):V=h5(R,a.filter(function($){var K=s in $.props?$.props[s]:$.type.defaultProps[s],J="hide"in $.props?$.props.hide:$.type.defaultProps.hide;return K===I&&(A||!J)}),N,f,!0);if(N==="number")V=kN(h,V,I,i,T),q&&(V=Yj(q,V,O));else if(N==="category"&&q){var F=q,D=V.every(function($){return F.indexOf($)>=0});D&&(V=F)}}return je(je({},x),{},dt({},I,je(je({},j),{},{axisType:i,domain:V,categoricalDomain:G,duplicateDomain:z,originalDomain:(w=j.domain)!==null&&w!==void 0?w:H,isCategorical:g,layout:f})))},{})},Gle=function(t,r){var n=r.graphicalItems,a=r.Axis,i=r.axisType,s=r.axisIdKey,l=r.stackGroups,d=r.dataStartIndex,c=r.dataEndIndex,f=t.layout,h=t.children,p=Zy(t.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:c}),g=p.length,x=m5(f,i),b=-1;return n.reduce(function(w,j){var N=j.type.defaultProps!==void 0?je(je({},j.type.defaultProps),j.props):j.props,C=N[s],O=TF("number");if(!w[C]){b++;var P;return x?P=Lg(0,g):l&&l[C]&&l[C].hasStack?(P=x5(l[C].stackGroups,d,c),P=kN(h,P,C,i)):(P=Yj(O,h5(p,n.filter(function(E){var T,A,I=s in E.props?E.props[s]:(T=E.type.defaultProps)===null||T===void 0?void 0:T[s],R="hide"in E.props?E.props.hide:(A=E.type.defaultProps)===null||A===void 0?void 0:A.hide;return I===C&&!R}),"number",f),a.defaultProps.allowDataOverflow),P=kN(h,P,C,i)),je(je({},w),{},dt({},C,je(je({axisType:i},a.defaultProps),{},{hide:!0,orientation:ua(Ule,"".concat(i,".").concat(b%2),null),domain:P,originalDomain:O,isCategorical:x,layout:f})))}return w},{})},Yle=function(t,r){var n=r.axisType,a=n===void 0?"xAxis":n,i=r.AxisComp,s=r.graphicalItems,l=r.stackGroups,d=r.dataStartIndex,c=r.dataEndIndex,f=t.children,h="".concat(a,"Id"),p=da(f,i),g={};return p&&p.length?g=Hle(t,{axes:p,graphicalItems:s,axisType:a,axisIdKey:h,stackGroups:l,dataStartIndex:d,dataEndIndex:c}):s&&s.length&&(g=Gle(t,{Axis:i,graphicalItems:s,axisType:a,axisIdKey:h,stackGroups:l,dataStartIndex:d,dataEndIndex:c})),g},Kle=function(t){var r=Li(t),n=Ko(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:$C(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:jg(r,n)}},lD=function(t){var r=t.children,n=t.defaultShowTooltip,a=ea(r,Bc),i=0,s=0;return t.data&&t.data.length!==0&&(s=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(s=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:s,activeTooltipIndex:-1,isTooltipActive:!!n}},Xle=function(t){return!t||!t.length?!1:t.some(function(r){var n=Zo(r&&r.type);return n&&n.indexOf("Bar")>=0})},cD=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Jle=function(t,r){var n=t.props,a=t.graphicalItems,i=t.xAxisMap,s=i===void 0?{}:i,l=t.yAxisMap,d=l===void 0?{}:l,c=n.width,f=n.height,h=n.children,p=n.margin||{},g=ea(h,Bc),x=ea(h,mc),b=Object.keys(d).reduce(function(P,E){var T=d[E],A=T.orientation;return!T.mirror&&!T.hide?je(je({},P),{},dt({},A,P[A]+T.width)):P},{left:p.left||0,right:p.right||0}),w=Object.keys(s).reduce(function(P,E){var T=s[E],A=T.orientation;return!T.mirror&&!T.hide?je(je({},P),{},dt({},A,ua(P,"".concat(A))+T.height)):P},{top:p.top||0,bottom:p.bottom||0}),j=je(je({},w),b),N=j.bottom;g&&(j.bottom+=g.props.height||Bc.defaultProps.height),x&&r&&(j=gee(j,a,n,r));var C=c-j.left-j.right,O=f-j.top-j.bottom;return je(je({brushBottom:N},j),{},{width:Math.max(C,0),height:Math.max(O,0)})},Qle=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},w_=function(t){var r=t.chartName,n=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,s=t.validateTooltipEventTypes,l=s===void 0?["axis"]:s,d=t.axisComponents,c=t.legendContent,f=t.formatAxisMap,h=t.defaultProps,p=function(j,N){var C=N.graphicalItems,O=N.stackGroups,P=N.offset,E=N.updateId,T=N.dataStartIndex,A=N.dataEndIndex,I=j.barSize,R=j.layout,L=j.barGap,V=j.barCategoryGap,z=j.maxBarSize,G=cD(R),H=G.numericAxisName,W=G.cateAxisName,q=Xle(C),M=[];return C.forEach(function(Y,F){var D=Zy(j.data,{graphicalItems:[Y],dataStartIndex:T,dataEndIndex:A}),$=Y.type.defaultProps!==void 0?je(je({},Y.type.defaultProps),Y.props):Y.props,K=$.dataKey,J=$.maxBarSize,oe=$["".concat(H,"Id")],re=$["".concat(W,"Id")],Q={},ce=d.reduce(function(ye,Ae){var Ge=N["".concat(Ae.axisType,"Map")],ut=$["".concat(Ae.axisType,"Id")];Ge&&Ge[ut]||Ae.axisType==="zAxis"||Hs();var Ce=Ge[ut];return je(je({},ye),{},dt(dt({},Ae.axisType,Ce),"".concat(Ae.axisType,"Ticks"),Ko(Ce)))},Q),se=ce[W],fe=ce["".concat(W,"Ticks")],be=O&&O[oe]&&O[oe].hasStack&&Eee(Y,O[oe].stackGroups),Z=Zo(Y.type).indexOf("Bar")>=0,Se=jg(se,fe),Ne=[],qe=q&&mee({barSize:I,stackGroups:O,totalSize:Qle(ce,W)});if(Z){var De,He,ne=yt(J)?z:J,pe=(De=(He=jg(se,fe,!0))!==null&&He!==void 0?He:ne)!==null&&De!==void 0?De:0;Ne=pee({barGap:L,barCategoryGap:V,bandSize:pe!==Se?pe:Se,sizeList:qe[re],maxBarSize:ne}),pe!==Se&&(Ne=Ne.map(function(ye){return je(je({},ye),{},{position:je(je({},ye.position),{},{offset:ye.position.offset-pe/2})})}))}var _e=Y&&Y.type&&Y.type.getComposedData;_e&&M.push({props:je(je({},_e(je(je({},ce),{},{displayedData:D,props:j,dataKey:K,item:Y,bandSize:Se,barPosition:Ne,offset:P,stackedData:be,layout:R,dataStartIndex:T,dataEndIndex:A}))),{},dt(dt(dt({key:Y.key||"item-".concat(F)},H,ce[H]),W,ce[W]),"animationId",E)),childIndex:xH(Y,j.children),item:Y})}),M},g=function(j,N){var C=j.props,O=j.dataStartIndex,P=j.dataEndIndex,E=j.updateId;if(!jk({props:C}))return null;var T=C.children,A=C.layout,I=C.stackOffset,R=C.data,L=C.reverseStackOrder,V=cD(A),z=V.numericAxisName,G=V.cateAxisName,H=da(T,n),W=Cee(R,H,"".concat(z,"Id"),"".concat(G,"Id"),I,L),q=d.reduce(function($,K){var J="".concat(K.axisType,"Map");return je(je({},$),{},dt({},J,Yle(C,je(je({},K),{},{graphicalItems:H,stackGroups:K.axisType===z&&W,dataStartIndex:O,dataEndIndex:P}))))},{}),M=Jle(je(je({},q),{},{props:C,graphicalItems:H}),N?.legendBBox);Object.keys(q).forEach(function($){q[$]=f(C,q[$],M,$.replace("Map",""),r)});var Y=q["".concat(G,"Map")],F=Kle(Y),D=p(C,je(je({},q),{},{dataStartIndex:O,dataEndIndex:P,updateId:E,graphicalItems:H,stackGroups:W,offset:M}));return je(je({formattedGraphicalItems:D,graphicalItems:H,offset:M,stackGroups:W},F),q)},x=(function(w){function j(N){var C,O,P;return kle(this,j),P=Mle(this,j,[N]),dt(P,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),dt(P,"accessibilityManager",new yle),dt(P,"handleLegendBBoxUpdate",function(E){if(E){var T=P.state,A=T.dataStartIndex,I=T.dataEndIndex,R=T.updateId;P.setState(je({legendBBox:E},g({props:P.props,dataStartIndex:A,dataEndIndex:I,updateId:R},je(je({},P.state),{},{legendBBox:E}))))}}),dt(P,"handleReceiveSyncEvent",function(E,T,A){if(P.props.syncId===E){if(A===P.eventEmitterSymbol&&typeof P.props.syncMethod!="function")return;P.applySyncEvent(T)}}),dt(P,"handleBrushChange",function(E){var T=E.startIndex,A=E.endIndex;if(T!==P.state.dataStartIndex||A!==P.state.dataEndIndex){var I=P.state.updateId;P.setState(function(){return je({dataStartIndex:T,dataEndIndex:A},g({props:P.props,dataStartIndex:T,dataEndIndex:A,updateId:I},P.state))}),P.triggerSyncEvent({dataStartIndex:T,dataEndIndex:A})}}),dt(P,"handleMouseEnter",function(E){var T=P.getMouseInfo(E);if(T){var A=je(je({},T),{},{isTooltipActive:!0});P.setState(A),P.triggerSyncEvent(A);var I=P.props.onMouseEnter;mt(I)&&I(A,E)}}),dt(P,"triggeredAfterMouseMove",function(E){var T=P.getMouseInfo(E),A=T?je(je({},T),{},{isTooltipActive:!0}):{isTooltipActive:!1};P.setState(A),P.triggerSyncEvent(A);var I=P.props.onMouseMove;mt(I)&&I(A,E)}),dt(P,"handleItemMouseEnter",function(E){P.setState(function(){return{isTooltipActive:!0,activeItem:E,activePayload:E.tooltipPayload,activeCoordinate:E.tooltipPosition||{x:E.cx,y:E.cy}}})}),dt(P,"handleItemMouseLeave",function(){P.setState(function(){return{isTooltipActive:!1}})}),dt(P,"handleMouseMove",function(E){E.persist(),P.throttleTriggeredAfterMouseMove(E)}),dt(P,"handleMouseLeave",function(E){P.throttleTriggeredAfterMouseMove.cancel();var T={isTooltipActive:!1};P.setState(T),P.triggerSyncEvent(T);var A=P.props.onMouseLeave;mt(A)&&A(T,E)}),dt(P,"handleOuterEvent",function(E){var T=vH(E),A=ua(P.props,"".concat(T));if(T&&mt(A)){var I,R;/.*touch.*/i.test(T)?R=P.getMouseInfo(E.changedTouches[0]):R=P.getMouseInfo(E),A((I=R)!==null&&I!==void 0?I:{},E)}}),dt(P,"handleClick",function(E){var T=P.getMouseInfo(E);if(T){var A=je(je({},T),{},{isTooltipActive:!0});P.setState(A),P.triggerSyncEvent(A);var I=P.props.onClick;mt(I)&&I(A,E)}}),dt(P,"handleMouseDown",function(E){var T=P.props.onMouseDown;if(mt(T)){var A=P.getMouseInfo(E);T(A,E)}}),dt(P,"handleMouseUp",function(E){var T=P.props.onMouseUp;if(mt(T)){var A=P.getMouseInfo(E);T(A,E)}}),dt(P,"handleTouchMove",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&P.throttleTriggeredAfterMouseMove(E.changedTouches[0])}),dt(P,"handleTouchStart",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&P.handleMouseDown(E.changedTouches[0])}),dt(P,"handleTouchEnd",function(E){E.changedTouches!=null&&E.changedTouches.length>0&&P.handleMouseUp(E.changedTouches[0])}),dt(P,"handleDoubleClick",function(E){var T=P.props.onDoubleClick;if(mt(T)){var A=P.getMouseInfo(E);T(A,E)}}),dt(P,"handleContextMenu",function(E){var T=P.props.onContextMenu;if(mt(T)){var A=P.getMouseInfo(E);T(A,E)}}),dt(P,"triggerSyncEvent",function(E){P.props.syncId!==void 0&&kS.emit(AS,P.props.syncId,E,P.eventEmitterSymbol)}),dt(P,"applySyncEvent",function(E){var T=P.props,A=T.layout,I=T.syncMethod,R=P.state.updateId,L=E.dataStartIndex,V=E.dataEndIndex;if(E.dataStartIndex!==void 0||E.dataEndIndex!==void 0)P.setState(je({dataStartIndex:L,dataEndIndex:V},g({props:P.props,dataStartIndex:L,dataEndIndex:V,updateId:R},P.state)));else if(E.activeTooltipIndex!==void 0){var z=E.chartX,G=E.chartY,H=E.activeTooltipIndex,W=P.state,q=W.offset,M=W.tooltipTicks;if(!q)return;if(typeof I=="function")H=I(M,E);else if(I==="value"){H=-1;for(var Y=0;Y=0){var be,Z;if(z.dataKey&&!z.allowDuplicatedCategory){var Se=typeof z.dataKey=="function"?fe:"payload.".concat(z.dataKey.toString());be=Xp(Y,Se,H),Z=F&&D&&Xp(D,Se,H)}else be=Y?.[G],Z=F&&D&&D[G];if(re||oe){var Ne=E.props.activeIndex!==void 0?E.props.activeIndex:G;return[v.cloneElement(E,je(je(je({},I.props),ce),{},{activeIndex:Ne})),null,null]}if(!yt(be))return[se].concat(Xc(P.renderActivePoints({item:I,activePoint:be,basePoint:Z,childIndex:G,isRange:F})))}else{var qe,De=(qe=P.getItemByXY(P.state.activeCoordinate))!==null&&qe!==void 0?qe:{graphicalItem:se},He=De.graphicalItem,ne=He.item,pe=ne===void 0?E:ne,_e=He.childIndex,ye=je(je(je({},I.props),ce),{},{activeIndex:_e});return[v.cloneElement(pe,ye),null,null]}return F?[se,null,null]:[se,null]}),dt(P,"renderCustomized",function(E,T,A){return v.cloneElement(E,je(je({key:"recharts-customized-".concat(A)},P.props),P.state))}),dt(P,"renderMap",{CartesianGrid:{handler:Um,once:!0},ReferenceArea:{handler:P.renderReferenceElement},ReferenceLine:{handler:Um},ReferenceDot:{handler:P.renderReferenceElement},XAxis:{handler:Um},YAxis:{handler:Um},Brush:{handler:P.renderBrush,once:!0},Bar:{handler:P.renderGraphicChild},Line:{handler:P.renderGraphicChild},Area:{handler:P.renderGraphicChild},Radar:{handler:P.renderGraphicChild},RadialBar:{handler:P.renderGraphicChild},Scatter:{handler:P.renderGraphicChild},Pie:{handler:P.renderGraphicChild},Funnel:{handler:P.renderGraphicChild},Tooltip:{handler:P.renderCursor,once:!0},PolarGrid:{handler:P.renderPolarGrid,once:!0},PolarAngleAxis:{handler:P.renderPolarAxis},PolarRadiusAxis:{handler:P.renderPolarAxis},Customized:{handler:P.renderCustomized}}),P.clipPathId="".concat((C=N.id)!==null&&C!==void 0?C:fu("recharts"),"-clip"),P.throttleTriggeredAfterMouseMove=d3(P.triggeredAfterMouseMove,(O=N.throttleDelay)!==null&&O!==void 0?O:1e3/60),P.state={},P}return Lle(j,w),Ile(j,[{key:"componentDidMount",value:function(){var C,O;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(C=this.props.margin.left)!==null&&C!==void 0?C:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var C=this.props,O=C.children,P=C.data,E=C.height,T=C.layout,A=ea(O,ta);if(A){var I=A.props.defaultIndex;if(!(typeof I!="number"||I<0||I>this.state.tooltipTicks.length-1)){var R=this.state.tooltipTicks[I]&&this.state.tooltipTicks[I].value,L=MN(this.state,P,I,R),V=this.state.tooltipTicks[I].coordinate,z=(this.state.offset.top+E)/2,G=T==="horizontal",H=G?{x:V,y:z}:{y:V,x:z},W=this.state.formattedGraphicalItems.find(function(M){var Y=M.item;return Y.type.name==="Scatter"});W&&(H=je(je({},H),W.props.points[I].tooltipPosition),L=W.props.points[I].tooltipPayload);var q={activeTooltipIndex:I,isTooltipActive:!0,activeLabel:R,activePayload:L,activeCoordinate:H};this.setState(q),this.renderCursor(A),this.accessibilityManager.setIndex(I)}}}},{key:"getSnapshotBeforeUpdate",value:function(C,O){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==O.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==C.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==C.margin){var P,E;this.accessibilityManager.setDetails({offset:{left:(P=this.props.margin.left)!==null&&P!==void 0?P:0,top:(E=this.props.margin.top)!==null&&E!==void 0?E:0}})}return null}},{key:"componentDidUpdate",value:function(C){gj([ea(C.children,ta)],[ea(this.props.children,ta)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var C=ea(this.props.children,ta);if(C&&typeof C.props.shared=="boolean"){var O=C.props.shared?"axis":"item";return l.indexOf(O)>=0?O:i}return i}},{key:"getMouseInfo",value:function(C){if(!this.container)return null;var O=this.container,P=O.getBoundingClientRect(),E=oX(P),T={chartX:Math.round(C.pageX-E.left),chartY:Math.round(C.pageY-E.top)},A=P.width/O.offsetWidth||1,I=this.inRange(T.chartX,T.chartY,A);if(!I)return null;var R=this.state,L=R.xAxisMap,V=R.yAxisMap,z=this.getTooltipEventType(),G=sD(this.state,this.props.data,this.props.layout,I);if(z!=="axis"&&L&&V){var H=Li(L).scale,W=Li(V).scale,q=H&&H.invert?H.invert(T.chartX):null,M=W&&W.invert?W.invert(T.chartY):null;return je(je({},T),{},{xValue:q,yValue:M},G)}return G?je(je({},T),G):null}},{key:"inRange",value:function(C,O){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,E=this.props.layout,T=C/P,A=O/P;if(E==="horizontal"||E==="vertical"){var I=this.state.offset,R=T>=I.left&&T<=I.left+I.width&&A>=I.top&&A<=I.top+I.height;return R?{x:T,y:A}:null}var L=this.state,V=L.angleAxisMap,z=L.radiusAxisMap;if(V&&z){var G=Li(V);return fM({x:T,y:A},G)}return null}},{key:"parseEventsOfWrapper",value:function(){var C=this.props.children,O=this.getTooltipEventType(),P=ea(C,ta),E={};P&&O==="axis"&&(P.props.trigger==="click"?E={onClick:this.handleClick}:E={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var T=Jp(this.props,this.handleOuterEvent);return je(je({},T),E)}},{key:"addListener",value:function(){kS.on(AS,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){kS.removeListener(AS,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(C,O,P){for(var E=this.state.formattedGraphicalItems,T=0,A=E.length;Ttypeof r=="string"?r.trim():"").filter(Boolean);return t.length?t.join("; "):null}if(typeof e=="object"){const t=e,r=typeof t.message=="string"?t.message.trim():"";if(r)return r;const n=typeof t.details=="string"?t.details.trim():"";if(n)return n}return null}function fD(e){if(Array.isArray(e))return{items:e,totalCount:e.length};if(!e||typeof e!="object")return e;const t=e,r="TotalCount"in t||"Items"in t,n="totalCount"in t||"items"in t;if(r&&!n)return{...t,totalCount:t.TotalCount,items:t.Items};if(!("items"in t)&&Array.isArray(t.data)&&typeof t.totalCount=="number")return{...t,items:t.data};if(!("items"in t)&&Array.isArray(t.Data)&&typeof t.TotalCount=="number")return{...t,totalCount:t.TotalCount,items:t.Data};if(Array.isArray(t.items)&&typeof t.totalCount!="number"){const a=t.TotalCount;return{...t,totalCount:typeof a=="number"?a:t.items.length}}return e}function Er(e={}){const t=e.baseUrl??"http://flus-test.3ffoodsafety.com"??"http://localhost:19001",r=e.getToken;async function n(a){const i=a.prefix??"/api/app",s=tce(t,`${i}${a.path}${rce(a.query??{})}`),l={"Content-Type":"application/json"},d=r?.();d&&(l.Authorization=`Bearer ${d}`);const c=await fetch(s,{method:a.method,headers:l,body:a.body===void 0?void 0:JSON.stringify(a.body),signal:a.signal}),p=(c.headers.get("content-type")??"").includes("application/json")?await c.json().catch(()=>null):await c.text().catch(()=>"");if(!c.ok){const x=uD(p)??(typeof p=="string"&&p.trim()?p:"Request failed.");throw new _r(x,c.status,p)}if(p&&typeof p=="object"&&"data"in p){const g=p,x=typeof g.statusCode=="number"?g.statusCode:c.status;if(g.succeeded===!1||x>=400){const w=g.error?.message?.trim()||dD(g.errors)||uD(p)||dD(p?.errors)||"Request failed.";throw new _r(w,x||400,p)}return fD(g.data??null)}return fD(p)}return{requestJson:n}}const nce=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),ace="/dashboard/overview";function Xo(e,t=0){const r=typeof e=="number"?e:Number(e);return Number.isFinite(r)?r:t}function js(e){if(!e||typeof e!="object")return{key:"",title:"",value:0,previousValue:0,changeValue:0,changeRate:0};const t=e;return{key:String(t.key??t.Key??""),title:String(t.title??t.Title??""),value:Xo(t.value??t.Value,0),previousValue:Xo(t.previousValue??t.PreviousValue,0),changeValue:Xo(t.changeValue??t.ChangeValue,0),changeRate:Xo(t.changeRate??t.ChangeRate,0)}}function oce(e){if(!e||typeof e!="object")return null;const t=e,r=String(t.date??t.Date??"");return r?{date:r,value:Xo(t.value??t.Value,0)}:null}function hD(e){if(!e||typeof e!="object")return null;const t=e,r=String(t.categoryId??t.CategoryId??""),n=String(t.categoryName??t.CategoryName??"");return{categoryId:r,categoryName:n,count:Xo(t.count??t.Count,0),ratio:Xo(t.ratio??t.Ratio,0)}}function Ns(e,t,r,n=""){const a=e[t]??e[r];return a==null?n:String(a)}function ice(e){if(!e||typeof e!="object")return null;const t=e,r=Ns(t,"taskId","TaskId",""),n=Ns(t,"labelCode","LabelCode",""),a=Ns(t,"displayName","DisplayName",""),i=Ns(t,"printedAt","PrintedAt",""),s=Ns(t,"status","Status","active"),l=Ns(t,"labelTypeBadge","LabelTypeBadge",""),d=Ns(t,"printedByName","PrintedByName",""),c=t.printedByUserId??t.PrintedByUserId,f=c==null?null:String(c);return!r&&!n?null:{taskId:r||n,labelCode:n||"—",displayName:a||"—",printedByUserId:f,printedByName:d||"—",printedAt:i,status:s||"active",labelTypeBadge:l||"—"}}function sce(e){if(!e||typeof e!="object")return lce();const t=e,r=t.weeklyPrintVolume??t.WeeklyPrintVolume,n=Array.isArray(r)?r:[],a=t.byCategory??t.ByCategory,i=t.categoryDistribution??t.CategoryDistribution,s=Array.isArray(a)&&a.length?a:Array.isArray(i)?i:[],l=t.byCategoryTotal??t.ByCategoryTotal??t.categoryDistributionTotal??t.CategoryDistributionTotal,d=Xo(l,0),c=t.recentLabels??t.RecentLabels,f=Array.isArray(c)?c:[];return{labelsPrintedToday:js(t.labelsPrintedToday??t.LabelsPrintedToday),activeTemplates:js(t.activeTemplates??t.ActiveTemplates),activeUsers:js(t.activeUsers??t.ActiveUsers),locations:js(t.locations??t.Locations),people:js(t.people??t.People),products:js(t.products??t.Products),weeklyPrintVolume:n.map(oce).filter(h=>h!==null),byCategory:s.map(hD).filter(h=>h!==null),byCategoryTotal:Number.isFinite(d)?d:0,recentLabels:f.map(ice).filter(h=>h!==null),generatedAt:t.generatedAt??t.GeneratedAt??null,metricCards:Array.isArray(t.metricCards??t.MetricCards)?(t.metricCards??t.MetricCards).map(js):void 0,categoryDistribution:Array.isArray(t.categoryDistribution??t.CategoryDistribution)?(t.categoryDistribution??t.CategoryDistribution).map(hD).filter(Boolean):void 0,categoryDistributionTotal:Xo(t.categoryDistributionTotal??t.CategoryDistributionTotal,0)}}function Yl(e,t){return{key:e,title:t,value:0,previousValue:0,changeValue:0,changeRate:0}}function lce(){return{labelsPrintedToday:Yl("labelsPrintedToday","Labels Printed Today"),activeTemplates:Yl("activeTemplates","Active Templates"),activeUsers:Yl("activeUsers","Active Users"),locations:Yl("locations","Locations"),people:Yl("people","People"),products:Yl("products","Products"),weeklyPrintVolume:[],byCategory:[],byCategoryTotal:0,recentLabels:[],generatedAt:null}}async function cce(e){const t=await nce.requestJson({path:ace,method:"GET",signal:e});return sce(t)}const mD=["#3b82f6","#f59e0b","#6366f1","#10b981","#ec4899","#8b5cf6","#14b8a6"];function uce(e){const t=(e.labelTypeBadge||"").trim();if(t&&t!=="—")return t.length>=2?t.slice(0,2):`${t} `.slice(0,2);const r=(e.displayName||"").trim();return r&&r!=="—"?r.slice(0,2):"LB"}function dce(e){return(e.status||"").toLowerCase()==="expired"}function fce(e){const t=e?new Date(e):new Date;return Number.isFinite(t.getTime())?t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}):new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function pD(e){if(!e)return"—";const t=new Date(e).getTime();if(!Number.isFinite(t))return"—";const r=Math.max(0,Math.round((Date.now()-t)/1e3));return r<60?"Just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} hr ago`:`${Math.floor(r/86400)} day(s) ago`}function hce(e){const t=e.changeRate;return`${t>0?"+":""}${t.toFixed(1)}%`}function qm(e){const t=e.changeValue;return t===0?"No change":`${t>0?"+":""}${t} New`}function mce(e){return e.changeValue===0?"Stable":`${e.changeValue>0?"+":""}${e.changeValue} New`}function pce(e){return e.changeRate>0||e.changeRate===0&&e.changeValue>=0}function jd(e){return e.changeValue>=0}function gce(e){const t=e.weeklyPrintVolume??[];if(t.length)return t.map(n=>({date:n.date,day:new Date(`${n.date}T12:00:00`).toLocaleDateString("en-US",{weekday:"short"}),labels:n.value}));const r=[];for(let n=6;n>=0;n--){const a=new Date;a.setHours(12,0,0,0),a.setDate(a.getDate()-n);const i=a.toISOString().slice(0,10);r.push({date:i,day:a.toLocaleDateString("en-US",{weekday:"short"}),labels:0})}return r}function yce({onNewLabel:e,onViewReports:t,onViewAllRecentLabels:r}={}){const[n,a]=U.useState(null),[i,s]=U.useState(!0),l=U.useCallback(async()=>{s(!0);try{const g=await cce();a(g)}catch(g){console.error(g),ee.error(g instanceof Error?g.message:"Failed to load dashboard"),a(null)}finally{s(!1)}},[]);U.useEffect(()=>{l()},[l]);const d=U.useMemo(()=>n?gce(n):[],[n]),c=U.useMemo(()=>n?.byCategory?.length?n.byCategory.map((g,x)=>({id:g.categoryId||`cat-${x}`,name:g.categoryName||"—",value:g.count,color:mD[x%mD.length]})):[],[n]),f=n?.recentLabels??[],h=n?.byCategoryTotal??0,p=n?.generatedAt;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"bg-white border border-gray-200 p-4 rounded-xl shadow-sm flex flex-col md:flex-row justify-between items-center gap-4",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-xl font-bold text-gray-900",children:"Dashboard Overview"}),o.jsx("p",{className:"text-sm text-gray-500",children:"Welcome back, Admin. Here's what's happening today."}),o.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[fce(p)," | Last updated: ",i?"…":pD(p)]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(de,{type:"button",className:"bg-blue-600 text-white hover:bg-blue-700 font-medium",onClick:()=>e?.(),children:[o.jsx(Un,{className:"w-4 h-4 mr-2"})," New Label"]}),o.jsx(de,{type:"button",variant:"outline",onClick:()=>t?.(),children:"View Reports"})]})]}),o.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:i||!n?o.jsx(o.Fragment,{children:Array.from({length:6}).map((g,x)=>o.jsx(wn,{className:"border-gray-200 shadow-sm",children:o.jsxs(Dn,{className:"p-6 space-y-3",children:[o.jsx(uo,{className:"h-4 w-32"}),o.jsx(uo,{className:"h-8 w-20"}),o.jsx(uo,{className:"h-4 w-40"})]})},x))}):o.jsxs(o.Fragment,{children:[o.jsx(Kl,{title:n.labelsPrintedToday.title||"Labels Printed Today",value:String(n.labelsPrintedToday.value),trend:hce(n.labelsPrintedToday),trendUp:pce(n.labelsPrintedToday),icon:T$,color:"text-blue-600",bgColor:"bg-blue-50"}),o.jsx(Kl,{title:n.activeTemplates.title||"Active Templates",value:String(n.activeTemplates.value),trend:qm(n.activeTemplates),trendUp:jd(n.activeTemplates),icon:zs,color:"text-indigo-600",bgColor:"bg-indigo-50"}),o.jsx(Kl,{title:n.activeUsers.title||"Active Users",value:String(n.activeUsers.value),trend:mce(n.activeUsers),trendUp:jd(n.activeUsers),icon:hy,color:"text-emerald-600",bgColor:"bg-emerald-50"}),o.jsx(Kl,{title:n.locations.title||"Locations",value:String(n.locations.value),trend:qm(n.locations),trendUp:jd(n.locations),icon:su,color:"text-sky-600",bgColor:"bg-sky-50"}),o.jsx(Kl,{title:n.people.title||"People",value:String(n.people.value),trend:qm(n.people),trendUp:jd(n.people),icon:bq,color:"text-violet-600",bgColor:"bg-violet-50"}),o.jsx(Kl,{title:n.products.title||"Products",value:String(n.products.value),trend:qm(n.products),trendUp:jd(n.products),icon:Sc,color:"text-amber-600",bgColor:"bg-amber-50"})]})}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[o.jsxs(wn,{className:"shadow-sm border-gray-200",children:[o.jsxs(Na,{children:[o.jsxs(Ca,{className:"text-base font-bold text-gray-800 flex items-center gap-2",children:[o.jsx(g7,{className:"w-5 h-5 text-gray-500"}),"Weekly Print Volume"]}),o.jsx(Hd,{children:"Number of labels printed over the last 7 days"})]}),o.jsx(Dn,{children:i?o.jsx("div",{className:"h-[300px] w-full flex items-center justify-center",children:o.jsx(uo,{className:"h-[240px] w-full"})}):o.jsx("div",{className:"h-[300px] w-full",children:o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(kF,{data:d,children:[o.jsx(Gg,{strokeDasharray:"3 3",vertical:!1,stroke:"#e5e7eb"}),o.jsx(Ys,{dataKey:"day",axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12},dy:10}),o.jsx(Ks,{axisLine:!1,tickLine:!1,tick:{fill:"#6b7280",fontSize:12}}),o.jsx(ta,{labelFormatter:(g,x)=>x?.[0]?.payload?.date??"",contentStyle:{borderRadius:"8px",border:"none",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)"},cursor:{stroke:"#d1d5db",strokeWidth:1}}),o.jsx(vu,{type:"monotone",dataKey:"labels",stroke:"#2563eb",strokeWidth:3,dot:{r:4,fill:"#2563eb",strokeWidth:2,stroke:"#fff"},activeDot:{r:6}})]})})})})]}),o.jsxs(wn,{className:"shadow-sm border-gray-200",children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between",children:[o.jsxs("div",{children:[o.jsxs(Ca,{className:"text-base font-bold text-gray-800 flex items-center gap-2",children:[o.jsx(Nc,{className:"w-5 h-5 text-gray-500"}),"Recent Labels"]}),o.jsx(Hd,{children:"Latest printed labels across all locations"})]}),o.jsx(de,{type:"button",variant:"ghost",size:"sm",className:"text-blue-600",onClick:()=>r?.(),children:"View All"})]}),o.jsx(Dn,{children:i?o.jsx("div",{className:"space-y-4",children:Array.from({length:5}).map((g,x)=>o.jsx("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg border border-gray-100",children:o.jsxs("div",{className:"flex items-center gap-3 w-full",children:[o.jsx(uo,{className:"h-10 w-10 rounded-full shrink-0"}),o.jsxs("div",{className:"space-y-2 flex-1 min-w-0",children:[o.jsx(uo,{className:"h-4 w-2/3 max-w-xs"}),o.jsx(uo,{className:"h-3 w-1/2 max-w-sm"})]}),o.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[o.jsx(uo,{className:"h-3 w-16"}),o.jsx(uo,{className:"h-6 w-16 rounded-md"})]})]})},x))}):f.length===0?o.jsx("div",{className:"py-10 text-center text-sm text-gray-500",children:"No recent labels. Printed labels will appear here."}):o.jsx("div",{className:"space-y-4",children:f.map((g,x)=>{const b=dce(g);return o.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg border border-gray-100 hover:bg-gray-100 transition-colors",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[o.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 font-bold text-xs shrink-0",title:g.labelTypeBadge||void 0,children:uce(g)}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",children:g.displayName||"—"}),o.jsxs("p",{className:"text-xs text-gray-500 truncate",children:[g.labelCode||"—"," • ",g.printedByName||"—"]})]})]}),o.jsxs("div",{className:"flex items-center gap-4 shrink-0 ml-2",children:[o.jsx("span",{className:"text-xs text-gray-500 font-medium whitespace-nowrap",children:pD(g.printedAt||null)}),o.jsx(fn,{variant:"secondary",className:b?"bg-red-100 text-red-700":"bg-green-100 text-green-700",children:g.status||"—"})]})]},`${g.taskId}-${x}`)})})})]})]}),o.jsx("div",{className:"space-y-6",children:o.jsxs(wn,{className:"shadow-sm border-gray-200",children:[o.jsx(Na,{children:o.jsxs(Ca,{className:"text-base font-bold text-gray-800 flex items-center gap-2",children:[o.jsx(Sc,{className:"w-5 h-5 text-gray-500"}),"By Category"]})}),o.jsx(Dn,{children:i?o.jsx("div",{className:"h-[200px] w-full flex items-center justify-center",children:o.jsx(uo,{className:"h-[160px] w-[160px] rounded-full"})}):c.length===0?o.jsx("div",{className:"h-[200px] flex flex-col items-center justify-center text-sm text-gray-500",children:"No category distribution"}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"h-[200px] relative",children:[o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(ece,{children:[o.jsx(fi,{data:c,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"value",children:c.map((g,x)=>o.jsx(Oy,{fill:g.color},`cell-${x}`))}),o.jsx(ta,{})]})}),o.jsxs("div",{className:"absolute inset-0 flex items-center justify-center flex-col pointer-events-none",children:[o.jsx("span",{className:"text-2xl font-bold text-gray-900",children:h}),o.jsx("span",{className:"text-xs text-gray-500",children:"Total"})]})]}),o.jsx("div",{className:"mt-4 space-y-2",children:c.map(g=>o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:g.color}}),o.jsx("span",{className:"text-gray-600",children:g.name})]}),o.jsx("span",{className:"font-medium text-gray-900",children:g.value})]},g.id))})]})})]})})]})]})}function Kl({title:e,value:t,trend:r,trendUp:n,icon:a,color:i,bgColor:s}){return o.jsx(wn,{className:"border-gray-200 shadow-sm hover:shadow-md transition-shadow",children:o.jsxs(Dn,{className:"p-6",children:[o.jsxs("div",{className:"flex justify-between items-start",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-gray-500 mb-1",children:e}),o.jsx("h3",{className:"text-2xl font-bold text-gray-900",children:t})]}),o.jsx("div",{className:`p-2 rounded-lg ${s}`,children:o.jsx(a,{className:`w-5 h-5 ${i}`})})]}),o.jsxs("div",{className:"mt-4 flex items-center text-sm",children:[n?o.jsx(_$,{className:"w-4 h-4 text-green-500 mr-1 shrink-0"}):o.jsx(rq,{className:"w-4 h-4 text-red-500 mr-1 shrink-0"}),o.jsx("span",{className:n?"text-green-600 font-medium":"text-red-600 font-medium",children:r}),o.jsx("span",{className:"text-gray-400 ml-1",children:"Vs. last period"})]})]})})}function vce({title:e}){return o.jsxs("div",{className:"space-y-6",children:[o.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[1,2,3,4].map(t=>o.jsxs(wn,{children:[o.jsx(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:o.jsxs(Ca,{className:"text-sm font-medium",children:["Metric ",t]})}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:"000"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"+0.0% from last month"})]})]},t))}),o.jsx(wn,{className:"min-h-[400px] flex items-center justify-center border-dashed",children:o.jsxs("div",{className:"text-center text-muted-foreground",children:[o.jsxs("h3",{className:"text-lg font-medium",children:[e," Module"]}),o.jsx("p",{children:"This module is currently under development."})]})})]})}function hn({className:e,...t}){return o.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:o.jsx("table",{"data-slot":"table",className:ke("w-full caption-bottom text-sm",e),...t})})}function mn({className:e,...t}){return o.jsx("thead",{"data-slot":"table-header",className:ke("[&_tr]:border-b",e),...t})}function pn({className:e,...t}){return o.jsx("tbody",{"data-slot":"table-body",className:ke("[&_tr:last-child]:border-0",e),...t})}function nt({className:e,...t}){return o.jsx("tr",{"data-slot":"table-row",className:ke("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...t})}function Ee({className:e,...t}){return o.jsx("th",{"data-slot":"table-head",className:ke("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&>[role=checkbox]]:translate-y-[2px]",e),...t})}function xe({className:e,...t}){return o.jsx("td",{"data-slot":"table-cell",className:ke("p-2 align-middle whitespace-nowrap [&>[role=checkbox]]:translate-y-[2px]",e),...t})}function gD(e){const t=xce(e),r=v.forwardRef((n,a)=>{const{children:i,...s}=n,l=v.Children.toArray(i),d=l.find(wce);if(d){const c=d.props.children,f=l.map(h=>h===d?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:h);return o.jsx(t,{...s,ref:a,children:v.isValidElement(c)?v.cloneElement(c,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function xce(e){const t=v.forwardRef((r,n)=>{const{children:a,...i}=r;if(v.isValidElement(a)){const s=jce(a),l=Sce(i,a.props);return a.type!==v.Fragment&&(l.ref=n?Oa(n,s):s),v.cloneElement(a,l)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var bce=Symbol("radix.slottable");function wce(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===bce}function Sce(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function jce(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function AF(e){const t=e+"CollectionProvider",[r,n]=Eo(t),[a,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),s=b=>{const{scope:w,children:j}=b,N=U.useRef(null),C=U.useRef(new Map).current;return o.jsx(a,{scope:w,itemMap:C,collectionRef:N,children:j})};s.displayName=t;const l=e+"CollectionSlot",d=gD(l),c=U.forwardRef((b,w)=>{const{scope:j,children:N}=b,C=i(l,j),O=Tt(w,C.collectionRef);return o.jsx(d,{ref:O,children:N})});c.displayName=l;const f=e+"CollectionItemSlot",h="data-radix-collection-item",p=gD(f),g=U.forwardRef((b,w)=>{const{scope:j,children:N,...C}=b,O=U.useRef(null),P=Tt(w,O),E=i(f,j);return U.useEffect(()=>(E.itemMap.set(O,{ref:O,...C}),()=>void E.itemMap.delete(O))),o.jsx(p,{[h]:"",ref:P,children:N})});g.displayName=f;function x(b){const w=i(e+"CollectionConsumer",b);return U.useCallback(()=>{const N=w.collectionRef.current;if(!N)return[];const C=Array.from(N.querySelectorAll(`[${h}]`));return Array.from(w.itemMap.values()).sort((E,T)=>C.indexOf(E.ref.current)-C.indexOf(T.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:s,Slot:c,ItemSlot:g},x,n]}function Nce(e,t=globalThis?.document){const r=dn(e);v.useEffect(()=>{const n=a=>{a.key==="Escape"&&r(a)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var Cce="DismissableLayer",RN="dismissableLayer.update",_ce="dismissableLayer.pointerDownOutside",Ece="dismissableLayer.focusOutside",yD,IF=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ev=v.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:s,onDismiss:l,...d}=e,c=v.useContext(IF),[f,h]=v.useState(null),p=f?.ownerDocument??globalThis?.document,[,g]=v.useState({}),x=Tt(t,T=>h(T)),b=Array.from(c.layers),[w]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),j=b.indexOf(w),N=f?b.indexOf(f):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,O=N>=j,P=Tce(T=>{const A=T.target,I=[...c.branches].some(R=>R.contains(A));!O||I||(a?.(T),s?.(T),T.defaultPrevented||l?.())},p),E=kce(T=>{const A=T.target;[...c.branches].some(R=>R.contains(A))||(i?.(T),s?.(T),T.defaultPrevented||l?.())},p);return Nce(T=>{N===c.layers.size-1&&(n?.(T),!T.defaultPrevented&&l&&(T.preventDefault(),l()))},p),v.useEffect(()=>{if(f)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(yD=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),vD(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=yD)}},[f,p,r,c]),v.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),vD())},[f,c]),v.useEffect(()=>{const T=()=>g({});return document.addEventListener(RN,T),()=>document.removeEventListener(RN,T)},[]),o.jsx(ct.div,{...d,ref:x,style:{pointerEvents:C?O?"auto":"none":void 0,...e.style},onFocusCapture:pt(e.onFocusCapture,E.onFocusCapture),onBlurCapture:pt(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:pt(e.onPointerDownCapture,P.onPointerDownCapture)})});ev.displayName=Cce;var Pce="DismissableLayerBranch",Oce=v.forwardRef((e,t)=>{const r=v.useContext(IF),n=v.useRef(null),a=Tt(t,n);return v.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),o.jsx(ct.div,{...e,ref:a})});Oce.displayName=Pce;function Tce(e,t=globalThis?.document){const r=dn(e),n=v.useRef(!1),a=v.useRef(()=>{});return v.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let d=function(){MF(_ce,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=d,t.addEventListener("click",a.current,{once:!0})):d()}else t.removeEventListener("click",a.current);n.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>n.current=!0}}function kce(e,t=globalThis?.document){const r=dn(e),n=v.useRef(!1);return v.useEffect(()=>{const a=i=>{i.target&&!n.current&&MF(Ece,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function vD(){const e=new CustomEvent(RN);document.dispatchEvent(e)}function MF(e,t,r,{discrete:n}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),n?bV(a,i):a.dispatchEvent(i)}var MS=0;function S_(){v.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??xD()),document.body.insertAdjacentElement("beforeend",e[1]??xD()),MS++,()=>{MS===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),MS--}},[])}function xD(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var RS="focusScope.autoFocusOnMount",DS="focusScope.autoFocusOnUnmount",bD={bubbles:!1,cancelable:!0},Ace="FocusScope",tv=v.forwardRef((e,t)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...s}=e,[l,d]=v.useState(null),c=dn(a),f=dn(i),h=v.useRef(null),p=Tt(t,b=>d(b)),g=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(n){let b=function(C){if(g.paused||!l)return;const O=C.target;l.contains(O)?h.current=O:Ri(h.current,{select:!0})},w=function(C){if(g.paused||!l)return;const O=C.relatedTarget;O!==null&&(l.contains(O)||Ri(h.current,{select:!0}))},j=function(C){if(document.activeElement===document.body)for(const P of C)P.removedNodes.length>0&&Ri(l)};document.addEventListener("focusin",b),document.addEventListener("focusout",w);const N=new MutationObserver(j);return l&&N.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",w),N.disconnect()}}},[n,l,g.paused]),v.useEffect(()=>{if(l){SD.add(g);const b=document.activeElement;if(!l.contains(b)){const j=new CustomEvent(RS,bD);l.addEventListener(RS,c),l.dispatchEvent(j),j.defaultPrevented||(Ice($ce(RF(l)),{select:!0}),document.activeElement===b&&Ri(l))}return()=>{l.removeEventListener(RS,c),setTimeout(()=>{const j=new CustomEvent(DS,bD);l.addEventListener(DS,f),l.dispatchEvent(j),j.defaultPrevented||Ri(b??document.body,{select:!0}),l.removeEventListener(DS,f),SD.remove(g)},0)}}},[l,c,f,g]);const x=v.useCallback(b=>{if(!r&&!n||g.paused)return;const w=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,j=document.activeElement;if(w&&j){const N=b.currentTarget,[C,O]=Mce(N);C&&O?!b.shiftKey&&j===O?(b.preventDefault(),r&&Ri(C,{select:!0})):b.shiftKey&&j===C&&(b.preventDefault(),r&&Ri(O,{select:!0})):j===N&&b.preventDefault()}},[r,n,g.paused]);return o.jsx(ct.div,{tabIndex:-1,...s,ref:p,onKeyDown:x})});tv.displayName=Ace;function Ice(e,{select:t=!1}={}){const r=document.activeElement;for(const n of e)if(Ri(n,{select:t}),document.activeElement!==r)return}function Mce(e){const t=RF(e),r=wD(t,e),n=wD(t.reverse(),e);return[r,n]}function RF(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function wD(e,t){for(const r of e)if(!Rce(r,{upTo:t}))return r}function Rce(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Dce(e){return e instanceof HTMLInputElement&&"select"in e}function Ri(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&Dce(e)&&t&&e.select()}}var SD=Lce();function Lce(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=jD(e,t),e.unshift(t)},remove(t){e=jD(e,t),e[0]?.resume()}}}function jD(e,t){const r=[...e],n=r.indexOf(t);return n!==-1&&r.splice(n,1),r}function $ce(e){return e.filter(t=>t.tagName!=="A")}var Fce=nC[" useId ".trim().toString()]||(()=>{}),Bce=0;function Bn(e){const[t,r]=v.useState(Fce());return Ir(()=>{r(n=>n??String(Bce++))},[e]),e||(t?`radix-${t}`:"")}const zce=["top","right","bottom","left"],qi=Math.min,na=Math.max,Qg=Math.round,Vm=Math.floor,bo=e=>({x:e,y:e}),Uce={left:"right",right:"left",bottom:"top",top:"bottom"},qce={start:"end",end:"start"};function DN(e,t,r){return na(e,qi(t,r))}function si(e,t){return typeof e=="function"?e(t):e}function li(e){return e.split("-")[0]}function xu(e){return e.split("-")[1]}function j_(e){return e==="x"?"y":"x"}function N_(e){return e==="y"?"height":"width"}const Vce=new Set(["top","bottom"]);function go(e){return Vce.has(li(e))?"y":"x"}function C_(e){return j_(go(e))}function Wce(e,t,r){r===void 0&&(r=!1);const n=xu(e),a=C_(e),i=N_(a);let s=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(s=Zg(s)),[s,Zg(s)]}function Hce(e){const t=Zg(e);return[LN(e),t,LN(t)]}function LN(e){return e.replace(/start|end/g,t=>qce[t])}const ND=["left","right"],CD=["right","left"],Gce=["top","bottom"],Yce=["bottom","top"];function Kce(e,t,r){switch(e){case"top":case"bottom":return r?t?CD:ND:t?ND:CD;case"left":case"right":return t?Gce:Yce;default:return[]}}function Xce(e,t,r,n){const a=xu(e);let i=Kce(li(e),r==="start",n);return a&&(i=i.map(s=>s+"-"+a),t&&(i=i.concat(i.map(LN)))),i}function Zg(e){return e.replace(/left|right|bottom|top/g,t=>Uce[t])}function Jce(e){return{top:0,right:0,bottom:0,left:0,...e}}function DF(e){return typeof e!="number"?Jce(e):{top:e,right:e,bottom:e,left:e}}function ey(e){const{x:t,y:r,width:n,height:a}=e;return{width:n,height:a,top:r,left:t,right:t+n,bottom:r+a,x:t,y:r}}function _D(e,t,r){let{reference:n,floating:a}=e;const i=go(t),s=C_(t),l=N_(s),d=li(t),c=i==="y",f=n.x+n.width/2-a.width/2,h=n.y+n.height/2-a.height/2,p=n[l]/2-a[l]/2;let g;switch(d){case"top":g={x:f,y:n.y-a.height};break;case"bottom":g={x:f,y:n.y+n.height};break;case"right":g={x:n.x+n.width,y:h};break;case"left":g={x:n.x-a.width,y:h};break;default:g={x:n.x,y:n.y}}switch(xu(t)){case"start":g[s]-=p*(r&&c?-1:1);break;case"end":g[s]+=p*(r&&c?-1:1);break}return g}async function Qce(e,t){var r;t===void 0&&(t={});const{x:n,y:a,platform:i,rects:s,elements:l,strategy:d}=e,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:p=!1,padding:g=0}=si(t,e),x=DF(g),w=l[p?h==="floating"?"reference":"floating":h],j=ey(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(w)))==null||r?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:f,strategy:d})),N=h==="floating"?{x:n,y:a,width:s.floating.width,height:s.floating.height}:s.reference,C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),O=await(i.isElement==null?void 0:i.isElement(C))?await(i.getScale==null?void 0:i.getScale(C))||{x:1,y:1}:{x:1,y:1},P=ey(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:N,offsetParent:C,strategy:d}):N);return{top:(j.top-P.top+x.top)/O.y,bottom:(P.bottom-j.bottom+x.bottom)/O.y,left:(j.left-P.left+x.left)/O.x,right:(P.right-j.right+x.right)/O.x}}const Zce=async(e,t,r)=>{const{placement:n="bottom",strategy:a="absolute",middleware:i=[],platform:s}=r,l=i.filter(Boolean),d=await(s.isRTL==null?void 0:s.isRTL(t));let c=await s.getElementRects({reference:e,floating:t,strategy:a}),{x:f,y:h}=_D(c,n,d),p=n,g={},x=0;for(let w=0;w({name:"arrow",options:e,async fn(t){const{x:r,y:n,placement:a,rects:i,platform:s,elements:l,middlewareData:d}=t,{element:c,padding:f=0}=si(e,t)||{};if(c==null)return{};const h=DF(f),p={x:r,y:n},g=C_(a),x=N_(g),b=await s.getDimensions(c),w=g==="y",j=w?"top":"left",N=w?"bottom":"right",C=w?"clientHeight":"clientWidth",O=i.reference[x]+i.reference[g]-p[g]-i.floating[x],P=p[g]-i.reference[g],E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c));let T=E?E[C]:0;(!T||!await(s.isElement==null?void 0:s.isElement(E)))&&(T=l.floating[C]||i.floating[x]);const A=O/2-P/2,I=T/2-b[x]/2-1,R=qi(h[j],I),L=qi(h[N],I),V=R,z=T-b[x]-L,G=T/2-b[x]/2+A,H=DN(V,G,z),W=!d.arrow&&xu(a)!=null&&G!==H&&i.reference[x]/2-(GG<=0)){var L,V;const G=(((L=i.flip)==null?void 0:L.index)||0)+1,H=T[G];if(H&&(!(h==="alignment"?N!==go(H):!1)||R.every(M=>go(M.placement)===N?M.overflows[0]>0:!0)))return{data:{index:G,overflows:R},reset:{placement:H}};let W=(V=R.filter(q=>q.overflows[0]<=0).sort((q,M)=>q.overflows[1]-M.overflows[1])[0])==null?void 0:V.placement;if(!W)switch(g){case"bestFit":{var z;const q=(z=R.filter(M=>{if(E){const Y=go(M.placement);return Y===N||Y==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(Y=>Y>0).reduce((Y,F)=>Y+F,0)]).sort((M,Y)=>M[1]-Y[1])[0])==null?void 0:z[0];q&&(W=q);break}case"initialPlacement":W=l;break}if(a!==W)return{reset:{placement:W}}}return{}}}};function ED(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function PD(e){return zce.some(t=>e[t]>=0)}const rue=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r,platform:n}=t,{strategy:a="referenceHidden",...i}=si(e,t);switch(a){case"referenceHidden":{const s=await n.detectOverflow(t,{...i,elementContext:"reference"}),l=ED(s,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:PD(l)}}}case"escaped":{const s=await n.detectOverflow(t,{...i,altBoundary:!0}),l=ED(s,r.floating);return{data:{escapedOffsets:l,escaped:PD(l)}}}default:return{}}}}},LF=new Set(["left","top"]);async function nue(e,t){const{placement:r,platform:n,elements:a}=e,i=await(n.isRTL==null?void 0:n.isRTL(a.floating)),s=li(r),l=xu(r),d=go(r)==="y",c=LF.has(s)?-1:1,f=i&&d?-1:1,h=si(t,e);let{mainAxis:p,crossAxis:g,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof x=="number"&&(g=l==="end"?x*-1:x),d?{x:g*f,y:p*c}:{x:p*c,y:g*f}}const aue=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,n;const{x:a,y:i,placement:s,middlewareData:l}=t,d=await nue(t,e);return s===((r=l.offset)==null?void 0:r.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:i+d.y,data:{...d,placement:s}}}}},oue=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:n,placement:a,platform:i}=t,{mainAxis:s=!0,crossAxis:l=!1,limiter:d={fn:j=>{let{x:N,y:C}=j;return{x:N,y:C}}},...c}=si(e,t),f={x:r,y:n},h=await i.detectOverflow(t,c),p=go(li(a)),g=j_(p);let x=f[g],b=f[p];if(s){const j=g==="y"?"top":"left",N=g==="y"?"bottom":"right",C=x+h[j],O=x-h[N];x=DN(C,x,O)}if(l){const j=p==="y"?"top":"left",N=p==="y"?"bottom":"right",C=b+h[j],O=b-h[N];b=DN(C,b,O)}const w=d.fn({...t,[g]:x,[p]:b});return{...w,data:{x:w.x-r,y:w.y-n,enabled:{[g]:s,[p]:l}}}}}},iue=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:n,placement:a,rects:i,middlewareData:s}=t,{offset:l=0,mainAxis:d=!0,crossAxis:c=!0}=si(e,t),f={x:r,y:n},h=go(a),p=j_(h);let g=f[p],x=f[h];const b=si(l,t),w=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(d){const C=p==="y"?"height":"width",O=i.reference[p]-i.floating[C]+w.mainAxis,P=i.reference[p]+i.reference[C]-w.mainAxis;gP&&(g=P)}if(c){var j,N;const C=p==="y"?"width":"height",O=LF.has(li(a)),P=i.reference[h]-i.floating[C]+(O&&((j=s.offset)==null?void 0:j[h])||0)+(O?0:w.crossAxis),E=i.reference[h]+i.reference[C]+(O?0:((N=s.offset)==null?void 0:N[h])||0)-(O?w.crossAxis:0);xE&&(x=E)}return{[p]:g,[h]:x}}}},sue=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,n;const{placement:a,rects:i,platform:s,elements:l}=t,{apply:d=()=>{},...c}=si(e,t),f=await s.detectOverflow(t,c),h=li(a),p=xu(a),g=go(a)==="y",{width:x,height:b}=i.floating;let w,j;h==="top"||h==="bottom"?(w=h,j=p===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(j=h,w=p==="end"?"top":"bottom");const N=b-f.top-f.bottom,C=x-f.left-f.right,O=qi(b-f[w],N),P=qi(x-f[j],C),E=!t.middlewareData.shift;let T=O,A=P;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(A=C),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(T=N),E&&!p){const R=na(f.left,0),L=na(f.right,0),V=na(f.top,0),z=na(f.bottom,0);g?A=x-2*(R!==0||L!==0?R+L:na(f.left,f.right)):T=b-2*(V!==0||z!==0?V+z:na(f.top,f.bottom))}await d({...t,availableWidth:A,availableHeight:T});const I=await s.getDimensions(l.floating);return x!==I.width||b!==I.height?{reset:{rects:!0}}:{}}}};function rv(){return typeof window<"u"}function bu(e){return $F(e)?(e.nodeName||"").toLowerCase():"#document"}function fa(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ko(e){var t;return(t=($F(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $F(e){return rv()?e instanceof Node||e instanceof fa(e).Node:!1}function Xa(e){return rv()?e instanceof Element||e instanceof fa(e).Element:!1}function jo(e){return rv()?e instanceof HTMLElement||e instanceof fa(e).HTMLElement:!1}function OD(e){return!rv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof fa(e).ShadowRoot}const lue=new Set(["inline","contents"]);function Hf(e){const{overflow:t,overflowX:r,overflowY:n,display:a}=Ja(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+r)&&!lue.has(a)}const cue=new Set(["table","td","th"]);function uue(e){return cue.has(bu(e))}const due=[":popover-open",":modal"];function nv(e){return due.some(t=>{try{return e.matches(t)}catch{return!1}})}const fue=["transform","translate","scale","rotate","perspective"],hue=["transform","translate","scale","rotate","perspective","filter"],mue=["paint","layout","strict","content"];function __(e){const t=E_(),r=Xa(e)?Ja(e):e;return fue.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||hue.some(n=>(r.willChange||"").includes(n))||mue.some(n=>(r.contain||"").includes(n))}function pue(e){let t=Vi(e);for(;jo(t)&&!Jc(t);){if(__(t))return t;if(nv(t))return null;t=Vi(t)}return null}function E_(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const gue=new Set(["html","body","#document"]);function Jc(e){return gue.has(bu(e))}function Ja(e){return fa(e).getComputedStyle(e)}function av(e){return Xa(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vi(e){if(bu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||OD(e)&&e.host||ko(e);return OD(t)?t.host:t}function FF(e){const t=Vi(e);return Jc(t)?e.ownerDocument?e.ownerDocument.body:e.body:jo(t)&&Hf(t)?t:FF(t)}function Of(e,t,r){var n;t===void 0&&(t=[]),r===void 0&&(r=!0);const a=FF(e),i=a===((n=e.ownerDocument)==null?void 0:n.body),s=fa(a);if(i){const l=$N(s);return t.concat(s,s.visualViewport||[],Hf(a)?a:[],l&&r?Of(l):[])}return t.concat(a,Of(a,[],r))}function $N(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function BF(e){const t=Ja(e);let r=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=jo(e),i=a?e.offsetWidth:r,s=a?e.offsetHeight:n,l=Qg(r)!==i||Qg(n)!==s;return l&&(r=i,n=s),{width:r,height:n,$:l}}function P_(e){return Xa(e)?e:e.contextElement}function yc(e){const t=P_(e);if(!jo(t))return bo(1);const r=t.getBoundingClientRect(),{width:n,height:a,$:i}=BF(t);let s=(i?Qg(r.width):r.width)/n,l=(i?Qg(r.height):r.height)/a;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const yue=bo(0);function zF(e){const t=fa(e);return!E_()||!t.visualViewport?yue:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vue(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==fa(e)?!1:t}function Xs(e,t,r,n){t===void 0&&(t=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=P_(e);let s=bo(1);t&&(n?Xa(n)&&(s=yc(n)):s=yc(e));const l=vue(i,r,n)?zF(i):bo(0);let d=(a.left+l.x)/s.x,c=(a.top+l.y)/s.y,f=a.width/s.x,h=a.height/s.y;if(i){const p=fa(i),g=n&&Xa(n)?fa(n):n;let x=p,b=$N(x);for(;b&&n&&g!==x;){const w=yc(b),j=b.getBoundingClientRect(),N=Ja(b),C=j.left+(b.clientLeft+parseFloat(N.paddingLeft))*w.x,O=j.top+(b.clientTop+parseFloat(N.paddingTop))*w.y;d*=w.x,c*=w.y,f*=w.x,h*=w.y,d+=C,c+=O,x=fa(b),b=$N(x)}}return ey({width:f,height:h,x:d,y:c})}function ov(e,t){const r=av(e).scrollLeft;return t?t.left+r:Xs(ko(e)).left+r}function UF(e,t){const r=e.getBoundingClientRect(),n=r.left+t.scrollLeft-ov(e,r),a=r.top+t.scrollTop;return{x:n,y:a}}function xue(e){let{elements:t,rect:r,offsetParent:n,strategy:a}=e;const i=a==="fixed",s=ko(n),l=t?nv(t.floating):!1;if(n===s||l&&i)return r;let d={scrollLeft:0,scrollTop:0},c=bo(1);const f=bo(0),h=jo(n);if((h||!h&&!i)&&((bu(n)!=="body"||Hf(s))&&(d=av(n)),jo(n))){const g=Xs(n);c=yc(n),f.x=g.x+n.clientLeft,f.y=g.y+n.clientTop}const p=s&&!h&&!i?UF(s,d):bo(0);return{width:r.width*c.x,height:r.height*c.y,x:r.x*c.x-d.scrollLeft*c.x+f.x+p.x,y:r.y*c.y-d.scrollTop*c.y+f.y+p.y}}function bue(e){return Array.from(e.getClientRects())}function wue(e){const t=ko(e),r=av(e),n=e.ownerDocument.body,a=na(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=na(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-r.scrollLeft+ov(e);const l=-r.scrollTop;return Ja(n).direction==="rtl"&&(s+=na(t.clientWidth,n.clientWidth)-a),{width:a,height:i,x:s,y:l}}const TD=25;function Sue(e,t){const r=fa(e),n=ko(e),a=r.visualViewport;let i=n.clientWidth,s=n.clientHeight,l=0,d=0;if(a){i=a.width,s=a.height;const f=E_();(!f||f&&t==="fixed")&&(l=a.offsetLeft,d=a.offsetTop)}const c=ov(n);if(c<=0){const f=n.ownerDocument,h=f.body,p=getComputedStyle(h),g=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,x=Math.abs(n.clientWidth-h.clientWidth-g);x<=TD&&(i-=x)}else c<=TD&&(i+=c);return{width:i,height:s,x:l,y:d}}const jue=new Set(["absolute","fixed"]);function Nue(e,t){const r=Xs(e,!0,t==="fixed"),n=r.top+e.clientTop,a=r.left+e.clientLeft,i=jo(e)?yc(e):bo(1),s=e.clientWidth*i.x,l=e.clientHeight*i.y,d=a*i.x,c=n*i.y;return{width:s,height:l,x:d,y:c}}function kD(e,t,r){let n;if(t==="viewport")n=Sue(e,r);else if(t==="document")n=wue(ko(e));else if(Xa(t))n=Nue(t,r);else{const a=zF(e);n={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return ey(n)}function qF(e,t){const r=Vi(e);return r===t||!Xa(r)||Jc(r)?!1:Ja(r).position==="fixed"||qF(r,t)}function Cue(e,t){const r=t.get(e);if(r)return r;let n=Of(e,[],!1).filter(l=>Xa(l)&&bu(l)!=="body"),a=null;const i=Ja(e).position==="fixed";let s=i?Vi(e):e;for(;Xa(s)&&!Jc(s);){const l=Ja(s),d=__(s);!d&&l.position==="fixed"&&(a=null),(i?!d&&!a:!d&&l.position==="static"&&!!a&&jue.has(a.position)||Hf(s)&&!d&&qF(e,s))?n=n.filter(f=>f!==s):a=l,s=Vi(s)}return t.set(e,n),n}function _ue(e){let{element:t,boundary:r,rootBoundary:n,strategy:a}=e;const s=[...r==="clippingAncestors"?nv(t)?[]:Cue(t,this._c):[].concat(r),n],l=s[0],d=s.reduce((c,f)=>{const h=kD(t,f,a);return c.top=na(h.top,c.top),c.right=qi(h.right,c.right),c.bottom=qi(h.bottom,c.bottom),c.left=na(h.left,c.left),c},kD(t,l,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Eue(e){const{width:t,height:r}=BF(e);return{width:t,height:r}}function Pue(e,t,r){const n=jo(t),a=ko(t),i=r==="fixed",s=Xs(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const d=bo(0);function c(){d.x=ov(a)}if(n||!n&&!i)if((bu(t)!=="body"||Hf(a))&&(l=av(t)),n){const g=Xs(t,!0,i,t);d.x=g.x+t.clientLeft,d.y=g.y+t.clientTop}else a&&c();i&&!n&&a&&c();const f=a&&!n&&!i?UF(a,l):bo(0),h=s.left+l.scrollLeft-d.x-f.x,p=s.top+l.scrollTop-d.y-f.y;return{x:h,y:p,width:s.width,height:s.height}}function LS(e){return Ja(e).position==="static"}function AD(e,t){if(!jo(e)||Ja(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return ko(e)===r&&(r=r.ownerDocument.body),r}function VF(e,t){const r=fa(e);if(nv(e))return r;if(!jo(e)){let a=Vi(e);for(;a&&!Jc(a);){if(Xa(a)&&!LS(a))return a;a=Vi(a)}return r}let n=AD(e,t);for(;n&&uue(n)&&LS(n);)n=AD(n,t);return n&&Jc(n)&&LS(n)&&!__(n)?r:n||pue(e)||r}const Oue=async function(e){const t=this.getOffsetParent||VF,r=this.getDimensions,n=await r(e.floating);return{reference:Pue(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Tue(e){return Ja(e).direction==="rtl"}const kue={convertOffsetParentRelativeRectToViewportRelativeRect:xue,getDocumentElement:ko,getClippingRect:_ue,getOffsetParent:VF,getElementRects:Oue,getClientRects:bue,getDimensions:Eue,getScale:yc,isElement:Xa,isRTL:Tue};function WF(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Aue(e,t){let r=null,n;const a=ko(e);function i(){var l;clearTimeout(n),(l=r)==null||l.disconnect(),r=null}function s(l,d){l===void 0&&(l=!1),d===void 0&&(d=1),i();const c=e.getBoundingClientRect(),{left:f,top:h,width:p,height:g}=c;if(l||t(),!p||!g)return;const x=Vm(h),b=Vm(a.clientWidth-(f+p)),w=Vm(a.clientHeight-(h+g)),j=Vm(f),C={rootMargin:-x+"px "+-b+"px "+-w+"px "+-j+"px",threshold:na(0,qi(1,d))||1};let O=!0;function P(E){const T=E[0].intersectionRatio;if(T!==d){if(!O)return s();T?s(!1,T):n=setTimeout(()=>{s(!1,1e-7)},1e3)}T===1&&!WF(c,e.getBoundingClientRect())&&s(),O=!1}try{r=new IntersectionObserver(P,{...C,root:a.ownerDocument})}catch{r=new IntersectionObserver(P,C)}r.observe(e)}return s(!0),i}function Iue(e,t,r,n){n===void 0&&(n={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=n,c=P_(e),f=a||i?[...c?Of(c):[],...Of(t)]:[];f.forEach(j=>{a&&j.addEventListener("scroll",r,{passive:!0}),i&&j.addEventListener("resize",r)});const h=c&&l?Aue(c,r):null;let p=-1,g=null;s&&(g=new ResizeObserver(j=>{let[N]=j;N&&N.target===c&&g&&(g.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var C;(C=g)==null||C.observe(t)})),r()}),c&&!d&&g.observe(c),g.observe(t));let x,b=d?Xs(e):null;d&&w();function w(){const j=Xs(e);b&&!WF(b,j)&&r(),b=j,x=requestAnimationFrame(w)}return r(),()=>{var j;f.forEach(N=>{a&&N.removeEventListener("scroll",r),i&&N.removeEventListener("resize",r)}),h?.(),(j=g)==null||j.disconnect(),g=null,d&&cancelAnimationFrame(x)}}const Mue=aue,Rue=oue,Due=tue,Lue=sue,$ue=rue,ID=eue,Fue=iue,Bue=(e,t,r)=>{const n=new Map,a={platform:kue,...r},i={...a.platform,_c:n};return Zce(e,t,{...a,platform:i})};var zue=typeof document<"u",Uue=function(){},Lp=zue?v.useLayoutEffect:Uue;function ty(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,n,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(n=r;n--!==0;)if(!ty(e[n],t[n]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(t,a[n]))return!1;for(n=r;n--!==0;){const i=a[n];if(!(i==="_owner"&&e.$$typeof)&&!ty(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function HF(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MD(e,t){const r=HF(e);return Math.round(t*r)/r}function $S(e){const t=v.useRef(e);return Lp(()=>{t.current=e}),t}function que(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:n=[],platform:a,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:d,open:c}=e,[f,h]=v.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[p,g]=v.useState(n);ty(p,n)||g(n);const[x,b]=v.useState(null),[w,j]=v.useState(null),N=v.useCallback(M=>{M!==E.current&&(E.current=M,b(M))},[]),C=v.useCallback(M=>{M!==T.current&&(T.current=M,j(M))},[]),O=i||x,P=s||w,E=v.useRef(null),T=v.useRef(null),A=v.useRef(f),I=d!=null,R=$S(d),L=$S(a),V=$S(c),z=v.useCallback(()=>{if(!E.current||!T.current)return;const M={placement:t,strategy:r,middleware:p};L.current&&(M.platform=L.current),Bue(E.current,T.current,M).then(Y=>{const F={...Y,isPositioned:V.current!==!1};G.current&&!ty(A.current,F)&&(A.current=F,Mf.flushSync(()=>{h(F)}))})},[p,t,r,L,V]);Lp(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(M=>({...M,isPositioned:!1})))},[c]);const G=v.useRef(!1);Lp(()=>(G.current=!0,()=>{G.current=!1}),[]),Lp(()=>{if(O&&(E.current=O),P&&(T.current=P),O&&P){if(R.current)return R.current(O,P,z);z()}},[O,P,z,R,I]);const H=v.useMemo(()=>({reference:E,floating:T,setReference:N,setFloating:C}),[N,C]),W=v.useMemo(()=>({reference:O,floating:P}),[O,P]),q=v.useMemo(()=>{const M={position:r,left:0,top:0};if(!W.floating)return M;const Y=MD(W.floating,f.x),F=MD(W.floating,f.y);return l?{...M,transform:"translate("+Y+"px, "+F+"px)",...HF(W.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:Y,top:F}},[r,l,W.floating,f.x,f.y]);return v.useMemo(()=>({...f,update:z,refs:H,elements:W,floatingStyles:q}),[f,z,H,W,q])}const Vue=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:n,padding:a}=typeof e=="function"?e(r):e;return n&&t(n)?n.current!=null?ID({element:n.current,padding:a}).fn(r):{}:n?ID({element:n,padding:a}).fn(r):{}}}},Wue=(e,t)=>({...Mue(e),options:[e,t]}),Hue=(e,t)=>({...Rue(e),options:[e,t]}),Gue=(e,t)=>({...Fue(e),options:[e,t]}),Yue=(e,t)=>({...Due(e),options:[e,t]}),Kue=(e,t)=>({...Lue(e),options:[e,t]}),Xue=(e,t)=>({...$ue(e),options:[e,t]}),Jue=(e,t)=>({...Vue(e),options:[e,t]});var Que="Arrow",GF=v.forwardRef((e,t)=>{const{children:r,width:n=10,height:a=5,...i}=e;return o.jsx(ct.svg,{...i,ref:t,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});GF.displayName=Que;var Zue=GF;function O_(e){const[t,r]=v.useState(void 0);return Ir(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let s,l;if("borderBoxSize"in i){const d=i.borderBoxSize,c=Array.isArray(d)?d[0]:d;s=c.inlineSize,l=c.blockSize}else s=e.offsetWidth,l=e.offsetHeight;r({width:s,height:l})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else r(void 0)},[e]),t}var T_="Popper",[YF,iv]=Eo(T_),[ede,KF]=YF(T_),XF=e=>{const{__scopePopper:t,children:r}=e,[n,a]=v.useState(null);return o.jsx(ede,{scope:t,anchor:n,onAnchorChange:a,children:r})};XF.displayName=T_;var JF="PopperAnchor",QF=v.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:n,...a}=e,i=KF(JF,r),s=v.useRef(null),l=Tt(t,s),d=v.useRef(null);return v.useEffect(()=>{const c=d.current;d.current=n?.current||s.current,c!==d.current&&i.onAnchorChange(d.current)}),n?null:o.jsx(ct.div,{...a,ref:l})});QF.displayName=JF;var k_="PopperContent",[tde,rde]=YF(k_),ZF=v.forwardRef((e,t)=>{const{__scopePopper:r,side:n="bottom",sideOffset:a=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:d=!0,collisionBoundary:c=[],collisionPadding:f=0,sticky:h="partial",hideWhenDetached:p=!1,updatePositionStrategy:g="optimized",onPlaced:x,...b}=e,w=KF(k_,r),[j,N]=v.useState(null),C=Tt(t,Q=>N(Q)),[O,P]=v.useState(null),E=O_(O),T=E?.width??0,A=E?.height??0,I=n+(i!=="center"?"-"+i:""),R=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},L=Array.isArray(c)?c:[c],V=L.length>0,z={padding:R,boundary:L.filter(ade),altBoundary:V},{refs:G,floatingStyles:H,placement:W,isPositioned:q,middlewareData:M}=que({strategy:"fixed",placement:I,whileElementsMounted:(...Q)=>Iue(...Q,{animationFrame:g==="always"}),elements:{reference:w.anchor},middleware:[Wue({mainAxis:a+A,alignmentAxis:s}),d&&Hue({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?Gue():void 0,...z}),d&&Yue({...z}),Kue({...z,apply:({elements:Q,rects:ce,availableWidth:se,availableHeight:fe})=>{const{width:be,height:Z}=ce.reference,Se=Q.floating.style;Se.setProperty("--radix-popper-available-width",`${se}px`),Se.setProperty("--radix-popper-available-height",`${fe}px`),Se.setProperty("--radix-popper-anchor-width",`${be}px`),Se.setProperty("--radix-popper-anchor-height",`${Z}px`)}}),O&&Jue({element:O,padding:l}),ode({arrowWidth:T,arrowHeight:A}),p&&Xue({strategy:"referenceHidden",...z})]}),[Y,F]=rB(W),D=dn(x);Ir(()=>{q&&D?.()},[q,D]);const $=M.arrow?.x,K=M.arrow?.y,J=M.arrow?.centerOffset!==0,[oe,re]=v.useState();return Ir(()=>{j&&re(window.getComputedStyle(j).zIndex)},[j]),o.jsx("div",{ref:G.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:q?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[M.transformOrigin?.x,M.transformOrigin?.y].join(" "),...M.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx(tde,{scope:r,placedSide:Y,onArrowChange:P,arrowX:$,arrowY:K,shouldHideArrow:J,children:o.jsx(ct.div,{"data-side":Y,"data-align":F,...b,ref:C,style:{...b.style,animation:q?void 0:"none"}})})})});ZF.displayName=k_;var eB="PopperArrow",nde={top:"bottom",right:"left",bottom:"top",left:"right"},tB=v.forwardRef(function(t,r){const{__scopePopper:n,...a}=t,i=rde(eB,n),s=nde[i.placedSide];return o.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:o.jsx(Zue,{...a,ref:r,style:{...a.style,display:"block"}})})});tB.displayName=eB;function ade(e){return e!==null}var ode=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:n,middlewareData:a}=t,s=a.arrow?.centerOffset!==0,l=s?0:e.arrowWidth,d=s?0:e.arrowHeight,[c,f]=rB(r),h={start:"0%",center:"50%",end:"100%"}[f],p=(a.arrow?.x??0)+l/2,g=(a.arrow?.y??0)+d/2;let x="",b="";return c==="bottom"?(x=s?h:`${p}px`,b=`${-d}px`):c==="top"?(x=s?h:`${p}px`,b=`${n.floating.height+d}px`):c==="right"?(x=`${-d}px`,b=s?h:`${g}px`):c==="left"&&(x=`${n.floating.width+d}px`,b=s?h:`${g}px`),{data:{x,y:b}}}});function rB(e){const[t,r="center"]=e.split("-");return[t,r]}var nB=XF,A_=QF,aB=ZF,oB=tB,ide="Portal",sv=v.forwardRef((e,t)=>{const{container:r,...n}=e,[a,i]=v.useState(!1);Ir(()=>i(!0),[]);const s=r||a&&globalThis?.document?.body;return s?j$.createPortal(o.jsx(ct.div,{...n,ref:t}),s):null});sv.displayName=ide;function sde(e){const t=lde(e),r=v.forwardRef((n,a)=>{const{children:i,...s}=n,l=v.Children.toArray(i),d=l.find(ude);if(d){const c=d.props.children,f=l.map(h=>h===d?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:h);return o.jsx(t,{...s,ref:a,children:v.isValidElement(c)?v.cloneElement(c,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function lde(e){const t=v.forwardRef((r,n)=>{const{children:a,...i}=r;if(v.isValidElement(a)){const s=fde(a),l=dde(i,a.props);return a.type!==v.Fragment&&(l.ref=n?Oa(n,s):s),v.cloneElement(a,l)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var cde=Symbol("radix.slottable");function ude(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cde}function dde(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function fde(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var hde=nC[" useInsertionEffect ".trim().toString()]||Ir;function No({prop:e,defaultProp:t,onChange:r=()=>{},caller:n}){const[a,i,s]=mde({defaultProp:t,onChange:r}),l=e!==void 0,d=l?e:a;{const f=v.useRef(e!==void 0);v.useEffect(()=>{const h=f.current;h!==l&&console.warn(`${n} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,n])}const c=v.useCallback(f=>{if(l){const h=pde(f)?f(e):f;h!==e&&s.current?.(h)}else i(f)},[l,e,i,s]);return[d,c]}function mde({defaultProp:e,onChange:t}){const[r,n]=v.useState(e),a=v.useRef(r),i=v.useRef(t);return hde(()=>{i.current=t},[t]),v.useEffect(()=>{a.current!==r&&(i.current?.(r),a.current=r)},[r,a]),[r,n,i]}function pde(e){return typeof e=="function"}function I_(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var iB=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),gde="VisuallyHidden",yde=v.forwardRef((e,t)=>o.jsx(ct.span,{...e,ref:t,style:{...iB,...e.style}}));yde.displayName=gde;var vde=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Xl=new WeakMap,Wm=new WeakMap,Hm={},FS=0,sB=function(e){return e&&(e.host||sB(e.parentNode))},xde=function(e,t){return t.map(function(r){if(e.contains(r))return r;var n=sB(r);return n&&e.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},bde=function(e,t,r,n){var a=xde(t,Array.isArray(e)?e:[e]);Hm[r]||(Hm[r]=new WeakMap);var i=Hm[r],s=[],l=new Set,d=new Set(a),c=function(h){!h||l.has(h)||(l.add(h),c(h.parentNode))};a.forEach(c);var f=function(h){!h||d.has(h)||Array.prototype.forEach.call(h.children,function(p){if(l.has(p))f(p);else try{var g=p.getAttribute(n),x=g!==null&&g!=="false",b=(Xl.get(p)||0)+1,w=(i.get(p)||0)+1;Xl.set(p,b),i.set(p,w),s.push(p),b===1&&x&&Wm.set(p,!0),w===1&&p.setAttribute(r,"true"),x||p.setAttribute(n,"true")}catch(j){console.error("aria-hidden: cannot operate on ",p,j)}})};return f(t),l.clear(),FS++,function(){s.forEach(function(h){var p=Xl.get(h)-1,g=i.get(h)-1;Xl.set(h,p),i.set(h,g),p||(Wm.has(h)||h.removeAttribute(n),Wm.delete(h)),g||h.removeAttribute(r)}),FS--,FS||(Xl=new WeakMap,Xl=new WeakMap,Wm=new WeakMap,Hm={})}},M_=function(e,t,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=vde(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live], script"))),bde(n,a,r,"aria-hidden")):function(){return null}},mo=function(){return mo=Object.assign||function(t){for(var r,n=1,a=arguments.length;n"u")return Lde;var t=$de(e),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-r+t[2]-t[0])}},Bde=dB(),vc="data-scroll-locked",zde=function(e,t,r,n){var a=e.left,i=e.top,s=e.right,l=e.gap;return r===void 0&&(r="margin"),` + .`.concat(Sde,` { + overflow: hidden `).concat(n,`; + padding-right: `).concat(l,"px ").concat(n,`; + } + body[`).concat(vc,`] { + overflow: hidden `).concat(n,`; + overscroll-behavior: contain; + `).concat([t&&"position: relative ".concat(n,";"),r==="margin"&&` + padding-left: `.concat(a,`px; + padding-top: `).concat(i,`px; + padding-right: `).concat(s,`px; + margin-left:0; + margin-top:0; + margin-right: `).concat(l,"px ").concat(n,`; + `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(n,";")].filter(Boolean).join(""),` + } + + .`).concat($p,` { + right: `).concat(l,"px ").concat(n,`; + } + + .`).concat(Fp,` { + margin-right: `).concat(l,"px ").concat(n,`; + } + + .`).concat($p," .").concat($p,` { + right: 0 `).concat(n,`; + } + + .`).concat(Fp," .").concat(Fp,` { + margin-right: 0 `).concat(n,`; + } + + body[`).concat(vc,`] { + `).concat(jde,": ").concat(l,`px; + } +`)},DD=function(){var e=parseInt(document.body.getAttribute(vc)||"0",10);return isFinite(e)?e:0},Ude=function(){v.useEffect(function(){return document.body.setAttribute(vc,(DD()+1).toString()),function(){var e=DD()-1;e<=0?document.body.removeAttribute(vc):document.body.setAttribute(vc,e.toString())}},[])},qde=function(e){var t=e.noRelative,r=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;Ude();var i=v.useMemo(function(){return Fde(a)},[a]);return v.createElement(Bde,{styles:zde(i,!t,a,r?"":"!important")})},FN=!1;if(typeof window<"u")try{var Gm=Object.defineProperty({},"passive",{get:function(){return FN=!0,!0}});window.addEventListener("test",Gm,Gm),window.removeEventListener("test",Gm,Gm)}catch{FN=!1}var Jl=FN?{passive:!1}:!1,Vde=function(e){return e.tagName==="TEXTAREA"},fB=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Vde(e)&&r[t]==="visible")},Wde=function(e){return fB(e,"overflowY")},Hde=function(e){return fB(e,"overflowX")},LD=function(e,t){var r=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=hB(e,n);if(a){var i=mB(e,n),s=i[1],l=i[2];if(s>l)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Gde=function(e){var t=e.scrollTop,r=e.scrollHeight,n=e.clientHeight;return[t,r,n]},Yde=function(e){var t=e.scrollLeft,r=e.scrollWidth,n=e.clientWidth;return[t,r,n]},hB=function(e,t){return e==="v"?Wde(t):Hde(t)},mB=function(e,t){return e==="v"?Gde(t):Yde(t)},Kde=function(e,t){return e==="h"&&t==="rtl"?-1:1},Xde=function(e,t,r,n,a){var i=Kde(e,window.getComputedStyle(t).direction),s=i*n,l=r.target,d=t.contains(l),c=!1,f=s>0,h=0,p=0;do{if(!l)break;var g=mB(e,l),x=g[0],b=g[1],w=g[2],j=b-w-i*x;(x||j)&&hB(e,l)&&(h+=j,p+=x);var N=l.parentNode;l=N&&N.nodeType===Node.DOCUMENT_FRAGMENT_NODE?N.host:N}while(!d&&l!==document.body||d&&(t.contains(l)||t===l));return(f&&Math.abs(h)<1||!f&&Math.abs(p)<1)&&(c=!0),c},Ym=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},$D=function(e){return[e.deltaX,e.deltaY]},FD=function(e){return e&&"current"in e?e.current:e},Jde=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Qde=function(e){return` + .block-interactivity-`.concat(e,` {pointer-events: none;} + .allow-interactivity-`).concat(e,` {pointer-events: all;} +`)},Zde=0,Ql=[];function efe(e){var t=v.useRef([]),r=v.useRef([0,0]),n=v.useRef(),a=v.useState(Zde++)[0],i=v.useState(dB)[0],s=v.useRef(e);v.useEffect(function(){s.current=e},[e]),v.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var b=wde([e.lockRef.current],(e.shards||[]).map(FD),!0).filter(Boolean);return b.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),b.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=v.useCallback(function(b,w){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!s.current.allowPinchZoom;var j=Ym(b),N=r.current,C="deltaX"in b?b.deltaX:N[0]-j[0],O="deltaY"in b?b.deltaY:N[1]-j[1],P,E=b.target,T=Math.abs(C)>Math.abs(O)?"h":"v";if("touches"in b&&T==="h"&&E.type==="range")return!1;var A=window.getSelection(),I=A&&A.anchorNode,R=I?I===E||I.contains(E):!1;if(R)return!1;var L=LD(T,E);if(!L)return!0;if(L?P=T:(P=T==="v"?"h":"v",L=LD(T,E)),!L)return!1;if(!n.current&&"changedTouches"in b&&(C||O)&&(n.current=P),!P)return!0;var V=n.current||P;return Xde(V,w,b,V==="h"?C:O)},[]),d=v.useCallback(function(b){var w=b;if(!(!Ql.length||Ql[Ql.length-1]!==i)){var j="deltaY"in w?$D(w):Ym(w),N=t.current.filter(function(P){return P.name===w.type&&(P.target===w.target||w.target===P.shadowParent)&&Jde(P.delta,j)})[0];if(N&&N.should){w.cancelable&&w.preventDefault();return}if(!N){var C=(s.current.shards||[]).map(FD).filter(Boolean).filter(function(P){return P.contains(w.target)}),O=C.length>0?l(w,C[0]):!s.current.noIsolation;O&&w.cancelable&&w.preventDefault()}}},[]),c=v.useCallback(function(b,w,j,N){var C={name:b,delta:w,target:j,should:N,shadowParent:tfe(j)};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(O){return O!==C})},1)},[]),f=v.useCallback(function(b){r.current=Ym(b),n.current=void 0},[]),h=v.useCallback(function(b){c(b.type,$D(b),b.target,l(b,e.lockRef.current))},[]),p=v.useCallback(function(b){c(b.type,Ym(b),b.target,l(b,e.lockRef.current))},[]);v.useEffect(function(){return Ql.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:p}),document.addEventListener("wheel",d,Jl),document.addEventListener("touchmove",d,Jl),document.addEventListener("touchstart",f,Jl),function(){Ql=Ql.filter(function(b){return b!==i}),document.removeEventListener("wheel",d,Jl),document.removeEventListener("touchmove",d,Jl),document.removeEventListener("touchstart",f,Jl)}},[]);var g=e.removeScrollBar,x=e.inert;return v.createElement(v.Fragment,null,x?v.createElement(i,{styles:Qde(a)}):null,g?v.createElement(qde,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tfe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const rfe=Tde(uB,efe);var cv=v.forwardRef(function(e,t){return v.createElement(lv,mo({},e,{ref:t,sideCar:rfe}))});cv.classNames=lv.classNames;var nfe=[" ","Enter","ArrowUp","ArrowDown"],afe=[" ","Enter"],Js="Select",[uv,dv,ofe]=AF(Js),[wu]=Eo(Js,[ofe,iv]),fv=iv(),[ife,Xi]=wu(Js),[sfe,lfe]=wu(Js),pB=e=>{const{__scopeSelect:t,children:r,open:n,defaultOpen:a,onOpenChange:i,value:s,defaultValue:l,onValueChange:d,dir:c,name:f,autoComplete:h,disabled:p,required:g,form:x}=e,b=fv(t),[w,j]=v.useState(null),[N,C]=v.useState(null),[O,P]=v.useState(!1),E=my(c),[T,A]=No({prop:n,defaultProp:a??!1,onChange:i,caller:Js}),[I,R]=No({prop:s,defaultProp:l,onChange:d,caller:Js}),L=v.useRef(null),V=w?x||!!w.closest("form"):!0,[z,G]=v.useState(new Set),H=Array.from(z).map(W=>W.props.value).join(";");return o.jsx(nB,{...b,children:o.jsxs(ife,{required:g,scope:t,trigger:w,onTriggerChange:j,valueNode:N,onValueNodeChange:C,valueNodeHasChildren:O,onValueNodeHasChildrenChange:P,contentId:Bn(),value:I,onValueChange:R,open:T,onOpenChange:A,dir:E,triggerPointerDownPosRef:L,disabled:p,children:[o.jsx(uv.Provider,{scope:t,children:o.jsx(sfe,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(W=>{G(q=>new Set(q).add(W))},[]),onNativeOptionRemove:v.useCallback(W=>{G(q=>{const M=new Set(q);return M.delete(W),M})},[]),children:r})}),V?o.jsxs(LB,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:I,onChange:W=>R(W.target.value),disabled:p,form:x,children:[I===void 0?o.jsx("option",{value:""}):null,Array.from(z)]},H):null]})})};pB.displayName=Js;var gB="SelectTrigger",yB=v.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:n=!1,...a}=e,i=fv(r),s=Xi(gB,r),l=s.disabled||n,d=Tt(t,s.onTriggerChange),c=dv(r),f=v.useRef("touch"),[h,p,g]=FB(b=>{const w=c().filter(C=>!C.disabled),j=w.find(C=>C.value===s.value),N=BB(w,b,j);N!==void 0&&s.onValueChange(N.value)}),x=b=>{l||(s.onOpenChange(!0),g()),b&&(s.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return o.jsx(A_,{asChild:!0,...i,children:o.jsx(ct.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":$B(s.value)?"":void 0,...a,ref:d,onClick:pt(a.onClick,b=>{b.currentTarget.focus(),f.current!=="mouse"&&x(b)}),onPointerDown:pt(a.onPointerDown,b=>{f.current=b.pointerType;const w=b.target;w.hasPointerCapture(b.pointerId)&&w.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(x(b),b.preventDefault())}),onKeyDown:pt(a.onKeyDown,b=>{const w=h.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&p(b.key),!(w&&b.key===" ")&&nfe.includes(b.key)&&(x(),b.preventDefault())})})})});yB.displayName=gB;var vB="SelectValue",xB=v.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:a,children:i,placeholder:s="",...l}=e,d=Xi(vB,r),{onValueNodeHasChildrenChange:c}=d,f=i!==void 0,h=Tt(t,d.onValueNodeChange);return Ir(()=>{c(f)},[c,f]),o.jsx(ct.span,{...l,ref:h,style:{pointerEvents:"none"},children:$B(d.value)?o.jsx(o.Fragment,{children:s}):i})});xB.displayName=vB;var cfe="SelectIcon",bB=v.forwardRef((e,t)=>{const{__scopeSelect:r,children:n,...a}=e;return o.jsx(ct.span,{"aria-hidden":!0,...a,ref:t,children:n||"▼"})});bB.displayName=cfe;var ufe="SelectPortal",wB=e=>o.jsx(sv,{asChild:!0,...e});wB.displayName=ufe;var Qs="SelectContent",SB=v.forwardRef((e,t)=>{const r=Xi(Qs,e.__scopeSelect),[n,a]=v.useState();if(Ir(()=>{a(new DocumentFragment)},[]),!r.open){const i=n;return i?Mf.createPortal(o.jsx(jB,{scope:e.__scopeSelect,children:o.jsx(uv.Slot,{scope:e.__scopeSelect,children:o.jsx("div",{children:e.children})})}),i):null}return o.jsx(NB,{...e,ref:t})});SB.displayName=Qs;var Wa=10,[jB,Ji]=wu(Qs),dfe="SelectContentImpl",ffe=sde("SelectContent.RemoveScroll"),NB=v.forwardRef((e,t)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:s,side:l,sideOffset:d,align:c,alignOffset:f,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:x,hideWhenDetached:b,avoidCollisions:w,...j}=e,N=Xi(Qs,r),[C,O]=v.useState(null),[P,E]=v.useState(null),T=Tt(t,Q=>O(Q)),[A,I]=v.useState(null),[R,L]=v.useState(null),V=dv(r),[z,G]=v.useState(!1),H=v.useRef(!1);v.useEffect(()=>{if(C)return M_(C)},[C]),S_();const W=v.useCallback(Q=>{const[ce,...se]=V().map(Z=>Z.ref.current),[fe]=se.slice(-1),be=document.activeElement;for(const Z of Q)if(Z===be||(Z?.scrollIntoView({block:"nearest"}),Z===ce&&P&&(P.scrollTop=0),Z===fe&&P&&(P.scrollTop=P.scrollHeight),Z?.focus(),document.activeElement!==be))return},[V,P]),q=v.useCallback(()=>W([A,C]),[W,A,C]);v.useEffect(()=>{z&&q()},[z,q]);const{onOpenChange:M,triggerPointerDownPosRef:Y}=N;v.useEffect(()=>{if(C){let Q={x:0,y:0};const ce=fe=>{Q={x:Math.abs(Math.round(fe.pageX)-(Y.current?.x??0)),y:Math.abs(Math.round(fe.pageY)-(Y.current?.y??0))}},se=fe=>{Q.x<=10&&Q.y<=10?fe.preventDefault():C.contains(fe.target)||M(!1),document.removeEventListener("pointermove",ce),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",se,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",se,{capture:!0})}}},[C,M,Y]),v.useEffect(()=>{const Q=()=>M(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[M]);const[F,D]=FB(Q=>{const ce=V().filter(be=>!be.disabled),se=ce.find(be=>be.ref.current===document.activeElement),fe=BB(ce,Q,se);fe&&setTimeout(()=>fe.ref.current.focus())}),$=v.useCallback((Q,ce,se)=>{const fe=!H.current&&!se;(N.value!==void 0&&N.value===ce||fe)&&(I(Q),fe&&(H.current=!0))},[N.value]),K=v.useCallback(()=>C?.focus(),[C]),J=v.useCallback((Q,ce,se)=>{const fe=!H.current&&!se;(N.value!==void 0&&N.value===ce||fe)&&L(Q)},[N.value]),oe=n==="popper"?BN:CB,re=oe===BN?{side:l,sideOffset:d,align:c,alignOffset:f,arrowPadding:h,collisionBoundary:p,collisionPadding:g,sticky:x,hideWhenDetached:b,avoidCollisions:w}:{};return o.jsx(jB,{scope:r,content:C,viewport:P,onViewportChange:E,itemRefCallback:$,selectedItem:A,onItemLeave:K,itemTextRefCallback:J,focusSelectedItem:q,selectedItemText:R,position:n,isPositioned:z,searchRef:F,children:o.jsx(cv,{as:ffe,allowPinchZoom:!0,children:o.jsx(tv,{asChild:!0,trapped:N.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:pt(a,Q=>{N.trigger?.focus({preventScroll:!0}),Q.preventDefault()}),children:o.jsx(ev,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:o.jsx(oe,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:Q=>Q.preventDefault(),...j,...re,onPlaced:()=>G(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:pt(j.onKeyDown,Q=>{const ce=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!ce&&Q.key.length===1&&D(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let fe=V().filter(be=>!be.disabled).map(be=>be.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(fe=fe.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const be=Q.target,Z=fe.indexOf(be);fe=fe.slice(Z+1)}setTimeout(()=>W(fe)),Q.preventDefault()}})})})})})})});NB.displayName=dfe;var hfe="SelectItemAlignedPosition",CB=v.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:n,...a}=e,i=Xi(Qs,r),s=Ji(Qs,r),[l,d]=v.useState(null),[c,f]=v.useState(null),h=Tt(t,T=>f(T)),p=dv(r),g=v.useRef(!1),x=v.useRef(!0),{viewport:b,selectedItem:w,selectedItemText:j,focusSelectedItem:N}=s,C=v.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&c&&b&&w&&j){const T=i.trigger.getBoundingClientRect(),A=c.getBoundingClientRect(),I=i.valueNode.getBoundingClientRect(),R=j.getBoundingClientRect();if(i.dir!=="rtl"){const be=R.left-A.left,Z=I.left-be,Se=T.left-Z,Ne=T.width+Se,qe=Math.max(Ne,A.width),De=window.innerWidth-Wa,He=uj(Z,[Wa,Math.max(Wa,De-qe)]);l.style.minWidth=Ne+"px",l.style.left=He+"px"}else{const be=A.right-R.right,Z=window.innerWidth-I.right-be,Se=window.innerWidth-T.right-Z,Ne=T.width+Se,qe=Math.max(Ne,A.width),De=window.innerWidth-Wa,He=uj(Z,[Wa,Math.max(Wa,De-qe)]);l.style.minWidth=Ne+"px",l.style.right=He+"px"}const L=p(),V=window.innerHeight-Wa*2,z=b.scrollHeight,G=window.getComputedStyle(c),H=parseInt(G.borderTopWidth,10),W=parseInt(G.paddingTop,10),q=parseInt(G.borderBottomWidth,10),M=parseInt(G.paddingBottom,10),Y=H+W+z+M+q,F=Math.min(w.offsetHeight*5,Y),D=window.getComputedStyle(b),$=parseInt(D.paddingTop,10),K=parseInt(D.paddingBottom,10),J=T.top+T.height/2-Wa,oe=V-J,re=w.offsetHeight/2,Q=w.offsetTop+re,ce=H+W+Q,se=Y-ce;if(ce<=J){const be=L.length>0&&w===L[L.length-1].ref.current;l.style.bottom="0px";const Z=c.clientHeight-b.offsetTop-b.offsetHeight,Se=Math.max(oe,re+(be?K:0)+Z+q),Ne=ce+Se;l.style.height=Ne+"px"}else{const be=L.length>0&&w===L[0].ref.current;l.style.top="0px";const Se=Math.max(J,H+b.offsetTop+(be?$:0)+re)+se;l.style.height=Se+"px",b.scrollTop=ce-J+b.offsetTop}l.style.margin=`${Wa}px 0`,l.style.minHeight=F+"px",l.style.maxHeight=V+"px",n?.(),requestAnimationFrame(()=>g.current=!0)}},[p,i.trigger,i.valueNode,l,c,b,w,j,i.dir,n]);Ir(()=>C(),[C]);const[O,P]=v.useState();Ir(()=>{c&&P(window.getComputedStyle(c).zIndex)},[c]);const E=v.useCallback(T=>{T&&x.current===!0&&(C(),N?.(),x.current=!1)},[C,N]);return o.jsx(pfe,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:o.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:O},children:o.jsx(ct.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});CB.displayName=hfe;var mfe="SelectPopperPosition",BN=v.forwardRef((e,t)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Wa,...i}=e,s=fv(r);return o.jsx(aB,{...s,...i,ref:t,align:n,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});BN.displayName=mfe;var[pfe,R_]=wu(Qs,{}),zN="SelectViewport",_B=v.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:n,...a}=e,i=Ji(zN,r),s=R_(zN,r),l=Tt(t,i.onViewportChange),d=v.useRef(0);return o.jsxs(o.Fragment,{children:[o.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),o.jsx(uv.Slot,{scope:r,children:o.jsx(ct.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:pt(a.onScroll,c=>{const f=c.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:p}=s;if(p?.current&&h){const g=Math.abs(d.current-f.scrollTop);if(g>0){const x=window.innerHeight-Wa*2,b=parseFloat(h.style.minHeight),w=parseFloat(h.style.height),j=Math.max(b,w);if(j0?O:0,h.style.justifyContent="flex-end")}}}d.current=f.scrollTop})})})]})});_B.displayName=zN;var EB="SelectGroup",[gfe,yfe]=wu(EB),vfe=v.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=Bn();return o.jsx(gfe,{scope:r,id:a,children:o.jsx(ct.div,{role:"group","aria-labelledby":a,...n,ref:t})})});vfe.displayName=EB;var PB="SelectLabel",xfe=v.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=yfe(PB,r);return o.jsx(ct.div,{id:a.id,...n,ref:t})});xfe.displayName=PB;var ry="SelectItem",[bfe,OB]=wu(ry),TB=v.forwardRef((e,t)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:i,...s}=e,l=Xi(ry,r),d=Ji(ry,r),c=l.value===n,[f,h]=v.useState(i??""),[p,g]=v.useState(!1),x=Tt(t,N=>d.itemRefCallback?.(N,n,a)),b=Bn(),w=v.useRef("touch"),j=()=>{a||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return o.jsx(bfe,{scope:r,value:n,disabled:a,textId:b,isSelected:c,onItemTextChange:v.useCallback(N=>{h(C=>C||(N?.textContent??"").trim())},[]),children:o.jsx(uv.ItemSlot,{scope:r,value:n,disabled:a,textValue:f,children:o.jsx(ct.div,{role:"option","aria-labelledby":b,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...s,ref:x,onFocus:pt(s.onFocus,()=>g(!0)),onBlur:pt(s.onBlur,()=>g(!1)),onClick:pt(s.onClick,()=>{w.current!=="mouse"&&j()}),onPointerUp:pt(s.onPointerUp,()=>{w.current==="mouse"&&j()}),onPointerDown:pt(s.onPointerDown,N=>{w.current=N.pointerType}),onPointerMove:pt(s.onPointerMove,N=>{w.current=N.pointerType,a?d.onItemLeave?.():w.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:pt(s.onPointerLeave,N=>{N.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:pt(s.onKeyDown,N=>{d.searchRef?.current!==""&&N.key===" "||(afe.includes(N.key)&&j(),N.key===" "&&N.preventDefault())})})})})});TB.displayName=ry;var Ld="SelectItemText",kB=v.forwardRef((e,t)=>{const{__scopeSelect:r,className:n,style:a,...i}=e,s=Xi(Ld,r),l=Ji(Ld,r),d=OB(Ld,r),c=lfe(Ld,r),[f,h]=v.useState(null),p=Tt(t,j=>h(j),d.onItemTextChange,j=>l.itemTextRefCallback?.(j,d.value,d.disabled)),g=f?.textContent,x=v.useMemo(()=>o.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:w}=c;return Ir(()=>(b(x),()=>w(x)),[b,w,x]),o.jsxs(o.Fragment,{children:[o.jsx(ct.span,{id:d.textId,...i,ref:p}),d.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Mf.createPortal(i.children,s.valueNode):null]})});kB.displayName=Ld;var AB="SelectItemIndicator",IB=v.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return OB(AB,r).isSelected?o.jsx(ct.span,{"aria-hidden":!0,...n,ref:t}):null});IB.displayName=AB;var UN="SelectScrollUpButton",MB=v.forwardRef((e,t)=>{const r=Ji(UN,e.__scopeSelect),n=R_(UN,e.__scopeSelect),[a,i]=v.useState(!1),s=Tt(t,n.onScrollButtonChange);return Ir(()=>{if(r.viewport&&r.isPositioned){let l=function(){const c=d.scrollTop>0;i(c)};const d=r.viewport;return l(),d.addEventListener("scroll",l),()=>d.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?o.jsx(DB,{...e,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=r;l&&d&&(l.scrollTop=l.scrollTop-d.offsetHeight)}}):null});MB.displayName=UN;var qN="SelectScrollDownButton",RB=v.forwardRef((e,t)=>{const r=Ji(qN,e.__scopeSelect),n=R_(qN,e.__scopeSelect),[a,i]=v.useState(!1),s=Tt(t,n.onScrollButtonChange);return Ir(()=>{if(r.viewport&&r.isPositioned){let l=function(){const c=d.scrollHeight-d.clientHeight,f=Math.ceil(d.scrollTop)d.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?o.jsx(DB,{...e,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:d}=r;l&&d&&(l.scrollTop=l.scrollTop+d.offsetHeight)}}):null});RB.displayName=qN;var DB=v.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=e,i=Ji("SelectScrollButton",r),s=v.useRef(null),l=dv(r),d=v.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return v.useEffect(()=>()=>d(),[d]),Ir(()=>{l().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),o.jsx(ct.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:pt(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(n,50))}),onPointerMove:pt(a.onPointerMove,()=>{i.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(n,50))}),onPointerLeave:pt(a.onPointerLeave,()=>{d()})})}),wfe="SelectSeparator",Sfe=v.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e;return o.jsx(ct.div,{"aria-hidden":!0,...n,ref:t})});Sfe.displayName=wfe;var VN="SelectArrow",jfe=v.forwardRef((e,t)=>{const{__scopeSelect:r,...n}=e,a=fv(r),i=Xi(VN,r),s=Ji(VN,r);return i.open&&s.position==="popper"?o.jsx(oB,{...a,...n,ref:t}):null});jfe.displayName=VN;var Nfe="SelectBubbleInput",LB=v.forwardRef(({__scopeSelect:e,value:t,...r},n)=>{const a=v.useRef(null),i=Tt(n,a),s=I_(t);return v.useEffect(()=>{const l=a.current;if(!l)return;const d=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(d,"value").set;if(s!==t&&f){const h=new Event("change",{bubbles:!0});f.call(l,t),l.dispatchEvent(h)}},[s,t]),o.jsx(ct.select,{...r,style:{...iB,...r.style},ref:i,defaultValue:t})});LB.displayName=Nfe;function $B(e){return e===""||e===void 0}function FB(e){const t=dn(e),r=v.useRef(""),n=v.useRef(0),a=v.useCallback(s=>{const l=r.current+s;t(l),(function d(c){r.current=c,window.clearTimeout(n.current),c!==""&&(n.current=window.setTimeout(()=>d(""),1e3))})(l)},[t]),i=v.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,i]}function BB(e,t,r){const a=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let s=Cfe(e,Math.max(i,0));a.length===1&&(s=s.filter(c=>c!==r));const d=s.find(c=>c.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==r?d:void 0}function Cfe(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var _fe=pB,Efe=yB,Pfe=xB,Ofe=bB,Tfe=wB,kfe=SB,Afe=_B,Ife=TB,Mfe=kB,Rfe=IB,Dfe=MB,Lfe=RB;function $e({...e}){return o.jsx(_fe,{"data-slot":"select",...e})}function Fe({...e}){return o.jsx(Pfe,{"data-slot":"select-value",...e})}function Be({className:e,size:t="default",children:r,...n}){return o.jsxs(Efe,{"data-slot":"select-trigger","data-size":t,className:ke("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-full items-center justify-between gap-2 rounded-md border bg-input-background px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...n,children:[r,o.jsx(Ofe,{asChild:!0,children:o.jsx(Bs,{className:"size-4 opacity-50"})})]})}function ze({className:e,children:t,position:r="popper",...n}){return o.jsx(Tfe,{children:o.jsxs(kfe,{"data-slot":"select-content",className:ke("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...n,children:[o.jsx($fe,{}),o.jsx(Afe,{className:ke("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),o.jsx(Ffe,{})]})})}function we({className:e,children:t,...r}){return o.jsxs(Ife,{"data-slot":"select-item",className:ke("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[o.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:o.jsx(Rfe,{children:o.jsx(E$,{className:"size-4"})})}),o.jsx(Mfe,{children:t})]})}function $fe({className:e,...t}){return o.jsx(Dfe,{"data-slot":"select-scroll-up-button",className:ke("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx(gq,{className:"size-4"})})}function Ffe({className:e,...t}){return o.jsx(Lfe,{"data-slot":"select-scroll-down-button",className:ke("flex cursor-default items-center justify-center py-1",e),...t,children:o.jsx(Bs,{className:"size-4"})})}function Bfe(e){const t=zfe(e),r=v.forwardRef((n,a)=>{const{children:i,...s}=n,l=v.Children.toArray(i),d=l.find(qfe);if(d){const c=d.props.children,f=l.map(h=>h===d?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:h);return o.jsx(t,{...s,ref:a,children:v.isValidElement(c)?v.cloneElement(c,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function zfe(e){const t=v.forwardRef((r,n)=>{const{children:a,...i}=r;if(v.isValidElement(a)){const s=Wfe(a),l=Vfe(i,a.props);return a.type!==v.Fragment&&(l.ref=n?Oa(n,s):s),v.cloneElement(a,l)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ufe=Symbol("radix.slottable");function qfe(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ufe}function Vfe(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function Wfe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var hv="Dialog",[zB]=Eo(hv),[Hfe,no]=zB(hv),UB=e=>{const{__scopeDialog:t,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:s=!0}=e,l=v.useRef(null),d=v.useRef(null),[c,f]=No({prop:n,defaultProp:a??!1,onChange:i,caller:hv});return o.jsx(Hfe,{scope:t,triggerRef:l,contentRef:d,contentId:Bn(),titleId:Bn(),descriptionId:Bn(),open:c,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:s,children:r})};UB.displayName=hv;var qB="DialogTrigger",Gfe=v.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(qB,r),i=Tt(t,a.triggerRef);return o.jsx(ct.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$_(a.open),...n,ref:i,onClick:pt(e.onClick,a.onOpenToggle)})});Gfe.displayName=qB;var D_="DialogPortal",[Yfe,VB]=zB(D_,{forceMount:void 0}),WB=e=>{const{__scopeDialog:t,forceMount:r,children:n,container:a}=e,i=no(D_,t);return o.jsx(Yfe,{scope:t,forceMount:r,children:v.Children.map(n,s=>o.jsx(to,{present:r||i.open,children:o.jsx(sv,{asChild:!0,container:a,children:s})}))})};WB.displayName=D_;var ny="DialogOverlay",HB=v.forwardRef((e,t)=>{const r=VB(ny,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=no(ny,e.__scopeDialog);return i.modal?o.jsx(to,{present:n||i.open,children:o.jsx(Xfe,{...a,ref:t})}):null});HB.displayName=ny;var Kfe=Bfe("DialogOverlay.RemoveScroll"),Xfe=v.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(ny,r);return o.jsx(cv,{as:Kfe,allowPinchZoom:!0,shards:[a.contentRef],children:o.jsx(ct.div,{"data-state":$_(a.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Zs="DialogContent",GB=v.forwardRef((e,t)=>{const r=VB(Zs,e.__scopeDialog),{forceMount:n=r.forceMount,...a}=e,i=no(Zs,e.__scopeDialog);return o.jsx(to,{present:n||i.open,children:i.modal?o.jsx(Jfe,{...a,ref:t}):o.jsx(Qfe,{...a,ref:t})})});GB.displayName=Zs;var Jfe=v.forwardRef((e,t)=>{const r=no(Zs,e.__scopeDialog),n=v.useRef(null),a=Tt(t,r.contentRef,n);return v.useEffect(()=>{const i=n.current;if(i)return M_(i)},[]),o.jsx(YB,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pt(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:pt(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0;(s.button===2||l)&&i.preventDefault()}),onFocusOutside:pt(e.onFocusOutside,i=>i.preventDefault())})}),Qfe=v.forwardRef((e,t)=>{const r=no(Zs,e.__scopeDialog),n=v.useRef(!1),a=v.useRef(!1);return o.jsx(YB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),YB=v.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...s}=e,l=no(Zs,r),d=v.useRef(null),c=Tt(t,d);return S_(),o.jsxs(o.Fragment,{children:[o.jsx(tv,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:o.jsx(ev,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":$_(l.open),...s,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(Zfe,{titleId:l.titleId}),o.jsx(the,{contentRef:d,descriptionId:l.descriptionId})]})]})}),L_="DialogTitle",KB=v.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(L_,r);return o.jsx(ct.h2,{id:a.titleId,...n,ref:t})});KB.displayName=L_;var XB="DialogDescription",JB=v.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(XB,r);return o.jsx(ct.p,{id:a.descriptionId,...n,ref:t})});JB.displayName=XB;var QB="DialogClose",ZB=v.forwardRef((e,t)=>{const{__scopeDialog:r,...n}=e,a=no(QB,r);return o.jsx(ct.button,{type:"button",...n,ref:t,onClick:pt(e.onClick,()=>a.onOpenChange(!1))})});ZB.displayName=QB;function $_(e){return e?"open":"closed"}var e8="DialogTitleWarning",[w1e,t8]=NV(e8,{contentName:Zs,titleName:L_,docsSlug:"dialog"}),Zfe=({titleId:e})=>{const t=t8(e8),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. + +If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. + +For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return v.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},ehe="DialogDescriptionWarning",the=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${t8(ehe).contentName}}.`;return v.useEffect(()=>{const a=e.current?.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},r8=UB,n8=WB,a8=HB,o8=GB,rhe=KB,nhe=JB,ahe=ZB;function kt({...e}){return o.jsx(r8,{"data-slot":"dialog",...e})}function ohe({...e}){return o.jsx(n8,{"data-slot":"dialog-portal",...e})}const i8=v.forwardRef(({className:e,...t},r)=>o.jsx(a8,{ref:r,"data-slot":"dialog-overlay",className:ke("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t}));i8.displayName="DialogOverlay";const Ot=v.forwardRef(({className:e,children:t,...r},n)=>o.jsxs(ohe,{"data-slot":"dialog-portal",children:[o.jsx(i8,{}),o.jsxs(o8,{ref:n,"data-slot":"dialog-content",className:ke("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,o.jsxs(ahe,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[o.jsx(Qo,{}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Ot.displayName="DialogContent";function At({className:e,...t}){return o.jsx("div",{"data-slot":"dialog-header",className:ke("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Dt({className:e,...t}){return o.jsx("div",{"data-slot":"dialog-footer",className:ke("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function It({className:e,...t}){return o.jsx(rhe,{"data-slot":"dialog-title",className:ke("text-lg leading-none font-semibold",e),...t})}function qt({className:e,...t}){return o.jsx(nhe,{"data-slot":"dialog-description",className:ke("text-muted-foreground text-sm",e),...t})}var ihe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],she=ihe.reduce((e,t)=>{const r=mC(`Primitive.${t}`),n=v.forwardRef((a,i)=>{const{asChild:s,...l}=a,d=s?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(d,{...l,ref:i})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),lhe="Label",s8=v.forwardRef((e,t)=>o.jsx(she.label,{...e,ref:t,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));s8.displayName=lhe;var che=s8;function ue({className:e,...t}){return o.jsx(che,{"data-slot":"label",className:ke("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}var mv="Switch",[uhe]=Eo(mv),[dhe,fhe]=uhe(mv),l8=v.forwardRef((e,t)=>{const{__scopeSwitch:r,name:n,checked:a,defaultChecked:i,required:s,disabled:l,value:d="on",onCheckedChange:c,form:f,...h}=e,[p,g]=v.useState(null),x=Tt(t,C=>g(C)),b=v.useRef(!1),w=p?f||!!p.closest("form"):!0,[j,N]=No({prop:a,defaultProp:i??!1,onChange:c,caller:mv});return o.jsxs(dhe,{scope:r,checked:j,disabled:l,children:[o.jsx(ct.button,{type:"button",role:"switch","aria-checked":j,"aria-required":s,"data-state":f8(j),"data-disabled":l?"":void 0,disabled:l,value:d,...h,ref:x,onClick:pt(e.onClick,C=>{N(O=>!O),w&&(b.current=C.isPropagationStopped(),b.current||C.stopPropagation())})}),w&&o.jsx(d8,{control:p,bubbles:!b.current,name:n,value:d,checked:j,required:s,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});l8.displayName=mv;var c8="SwitchThumb",u8=v.forwardRef((e,t)=>{const{__scopeSwitch:r,...n}=e,a=fhe(c8,r);return o.jsx(ct.span,{"data-state":f8(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:t})});u8.displayName=c8;var hhe="SwitchBubbleInput",d8=v.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:n=!0,...a},i)=>{const s=v.useRef(null),l=Tt(s,i),d=I_(r),c=O_(t);return v.useEffect(()=>{const f=s.current;if(!f)return;const h=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(h,"checked").set;if(d!==r&&g){const x=new Event("click",{bubbles:n});g.call(f,r),f.dispatchEvent(x)}},[d,r,n]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});d8.displayName=hhe;function f8(e){return e?"checked":"unchecked"}var mhe=l8,phe=u8;function br({className:e,...t}){return o.jsx(mhe,{"data-slot":"switch",className:ke("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-switch-background focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:o.jsx(phe,{"data-slot":"switch-thumb",className:ke("bg-card dark:data-[state=unchecked]:bg-card-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}function Qa(e){return Math.max(1,e)}function ghe(e){const t=yhe(e),r=v.forwardRef((n,a)=>{const{children:i,...s}=n,l=v.Children.toArray(i),d=l.find(xhe);if(d){const c=d.props.children,f=l.map(h=>h===d?v.Children.count(c)>1?v.Children.only(null):v.isValidElement(c)?c.props.children:null:h);return o.jsx(t,{...s,ref:a,children:v.isValidElement(c)?v.cloneElement(c,void 0,f):null})}return o.jsx(t,{...s,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}function yhe(e){const t=v.forwardRef((r,n)=>{const{children:a,...i}=r;if(v.isValidElement(a)){const s=whe(a),l=bhe(i,a.props);return a.type!==v.Fragment&&(l.ref=n?Oa(n,s):s),v.cloneElement(a,l)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var vhe=Symbol("radix.slottable");function xhe(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vhe}function bhe(e,t){const r={...t};for(const n in t){const a=e[n],i=t[n];/^on[A-Z]/.test(n)?a&&i?r[n]=(...l)=>{const d=i(...l);return a(...l),d}:a&&(r[n]=a):n==="style"?r[n]={...a,...i}:n==="className"&&(r[n]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function whe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var pv="Popover",[h8]=Eo(pv,[iv]),Gf=iv(),[She,Qi]=h8(pv),m8=e=>{const{__scopePopover:t,children:r,open:n,defaultOpen:a,onOpenChange:i,modal:s=!1}=e,l=Gf(t),d=v.useRef(null),[c,f]=v.useState(!1),[h,p]=No({prop:n,defaultProp:a??!1,onChange:i,caller:pv});return o.jsx(nB,{...l,children:o.jsx(She,{scope:t,contentId:Bn(),triggerRef:d,open:h,onOpenChange:p,onOpenToggle:v.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:c,onCustomAnchorAdd:v.useCallback(()=>f(!0),[]),onCustomAnchorRemove:v.useCallback(()=>f(!1),[]),modal:s,children:r})})};m8.displayName=pv;var p8="PopoverAnchor",jhe=v.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Qi(p8,r),i=Gf(r),{onCustomAnchorAdd:s,onCustomAnchorRemove:l}=a;return v.useEffect(()=>(s(),()=>l()),[s,l]),o.jsx(A_,{...i,...n,ref:t})});jhe.displayName=p8;var g8="PopoverTrigger",y8=v.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Qi(g8,r),i=Gf(r),s=Tt(t,a.triggerRef),l=o.jsx(ct.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":S8(a.open),...n,ref:s,onClick:pt(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:o.jsx(A_,{asChild:!0,...i,children:l})});y8.displayName=g8;var F_="PopoverPortal",[Nhe,Che]=h8(F_,{forceMount:void 0}),v8=e=>{const{__scopePopover:t,forceMount:r,children:n,container:a}=e,i=Qi(F_,t);return o.jsx(Nhe,{scope:t,forceMount:r,children:o.jsx(to,{present:r||i.open,children:o.jsx(sv,{asChild:!0,container:a,children:n})})})};v8.displayName=F_;var Qc="PopoverContent",x8=v.forwardRef((e,t)=>{const r=Che(Qc,e.__scopePopover),{forceMount:n=r.forceMount,...a}=e,i=Qi(Qc,e.__scopePopover);return o.jsx(to,{present:n||i.open,children:i.modal?o.jsx(Ehe,{...a,ref:t}):o.jsx(Phe,{...a,ref:t})})});x8.displayName=Qc;var _he=ghe("PopoverContent.RemoveScroll"),Ehe=v.forwardRef((e,t)=>{const r=Qi(Qc,e.__scopePopover),n=v.useRef(null),a=Tt(t,n),i=v.useRef(!1);return v.useEffect(()=>{const s=n.current;if(s)return M_(s)},[]),o.jsx(cv,{as:_he,allowPinchZoom:!0,children:o.jsx(b8,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:pt(e.onCloseAutoFocus,s=>{s.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:pt(e.onPointerDownOutside,s=>{const l=s.detail.originalEvent,d=l.button===0&&l.ctrlKey===!0,c=l.button===2||d;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:pt(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),Phe=v.forwardRef((e,t)=>{const r=Qi(Qc,e.__scopePopover),n=v.useRef(!1),a=v.useRef(!1);return o.jsx(b8,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(n.current||r.triggerRef.current?.focus(),i.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const s=i.target;r.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),b8=v.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:c,onInteractOutside:f,...h}=e,p=Qi(Qc,r),g=Gf(r);return S_(),o.jsx(tv,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:o.jsx(ev,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:f,onEscapeKeyDown:l,onPointerDownOutside:d,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1),children:o.jsx(aB,{"data-state":S8(p.open),role:"dialog",id:p.contentId,...g,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),w8="PopoverClose",Ohe=v.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Qi(w8,r);return o.jsx(ct.button,{type:"button",...n,ref:t,onClick:pt(e.onClick,()=>a.onOpenChange(!1))})});Ohe.displayName=w8;var The="PopoverArrow",khe=v.forwardRef((e,t)=>{const{__scopePopover:r,...n}=e,a=Gf(r);return o.jsx(oB,{...a,...n,ref:t})});khe.displayName=The;function S8(e){return e?"open":"closed"}var Ahe=m8,Ihe=y8,Mhe=v8,Rhe=x8;function ka({...e}){return o.jsx(Ahe,{"data-slot":"popover",...e})}function Aa({...e}){return o.jsx(Ihe,{"data-slot":"popover-trigger",...e})}function Ia({className:e,align:t="center",sideOffset:r=4,...n}){return o.jsx(Mhe,{children:o.jsx(Rhe,{"data-slot":"popover-content",align:t,sideOffset:r,className:ke("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...n})})}var BD=1,Dhe=.9,Lhe=.8,$he=.17,qS=.1,VS=.999,Fhe=.9999,Bhe=.99,zhe=/[\\\/_+.#"@\[\(\{&]/,Uhe=/[\\\/_+.#"@\[\(\{&]/g,qhe=/[\s-]/,j8=/[\s-]/g;function WN(e,t,r,n,a,i,s){if(i===t.length)return a===e.length?BD:Bhe;var l=`${a},${i}`;if(s[l]!==void 0)return s[l];for(var d=n.charAt(i),c=r.indexOf(d,a),f=0,h,p,g,x;c>=0;)h=WN(e,t,r,n,c+1,i+1,s),h>f&&(c===a?h*=BD:zhe.test(e.charAt(c-1))?(h*=Lhe,g=e.slice(a,c-1).match(Uhe),g&&a>0&&(h*=Math.pow(VS,g.length))):qhe.test(e.charAt(c-1))?(h*=Dhe,x=e.slice(a,c-1).match(j8),x&&a>0&&(h*=Math.pow(VS,x.length))):(h*=$he,a>0&&(h*=Math.pow(VS,c-a))),e.charAt(c)!==t.charAt(i)&&(h*=Fhe)),(hh&&(h=p*qS)),h>f&&(f=h),c=r.indexOf(d,c+1);return s[l]=f,f}function zD(e){return e.toLowerCase().replace(j8," ")}function Vhe(e,t,r){return e=r&&r.length>0?`${e+" "+r.join(" ")}`:e,WN(e,t,zD(e),zD(t),0,0,{})}var Nd='[cmdk-group=""]',WS='[cmdk-group-items=""]',Whe='[cmdk-group-heading=""]',N8='[cmdk-item=""]',UD=`${N8}:not([aria-disabled="true"])`,HN="cmdk-item-select",ac="data-value",Hhe=(e,t,r)=>Vhe(e,t,r),C8=v.createContext(void 0),Yf=()=>v.useContext(C8),_8=v.createContext(void 0),B_=()=>v.useContext(_8),E8=v.createContext(void 0),P8=v.forwardRef((e,t)=>{let r=oc(()=>{var $,K;return{search:"",value:(K=($=e.value)!=null?$:e.defaultValue)!=null?K:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=oc(()=>new Set),a=oc(()=>new Map),i=oc(()=>new Map),s=oc(()=>new Set),l=O8(e),{label:d,children:c,value:f,onValueChange:h,filter:p,shouldFilter:g,loop:x,disablePointerSelection:b=!1,vimBindings:w=!0,...j}=e,N=Bn(),C=Bn(),O=Bn(),P=v.useRef(null),E=nme();el(()=>{if(f!==void 0){let $=f.trim();r.current.value=$,T.emit()}},[f]),el(()=>{E(6,z)},[]);let T=v.useMemo(()=>({subscribe:$=>(s.current.add($),()=>s.current.delete($)),snapshot:()=>r.current,setState:($,K,J)=>{var oe,re,Q,ce;if(!Object.is(r.current[$],K)){if(r.current[$]=K,$==="search")V(),R(),E(1,L);else if($==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let se=document.getElementById(O);se?se.focus():(oe=document.getElementById(N))==null||oe.focus()}if(E(7,()=>{var se;r.current.selectedItemId=(se=G())==null?void 0:se.id,T.emit()}),J||E(5,z),((re=l.current)==null?void 0:re.value)!==void 0){let se=K??"";(ce=(Q=l.current).onValueChange)==null||ce.call(Q,se);return}}T.emit()}},emit:()=>{s.current.forEach($=>$())}}),[]),A=v.useMemo(()=>({value:($,K,J)=>{var oe;K!==((oe=i.current.get($))==null?void 0:oe.value)&&(i.current.set($,{value:K,keywords:J}),r.current.filtered.items.set($,I(K,J)),E(2,()=>{R(),T.emit()}))},item:($,K)=>(n.current.add($),K&&(a.current.has(K)?a.current.get(K).add($):a.current.set(K,new Set([$]))),E(3,()=>{V(),R(),r.current.value||L(),T.emit()}),()=>{i.current.delete($),n.current.delete($),r.current.filtered.items.delete($);let J=G();E(4,()=>{V(),J?.getAttribute("id")===$&&L(),T.emit()})}),group:$=>(a.current.has($)||a.current.set($,new Set),()=>{i.current.delete($),a.current.delete($)}),filter:()=>l.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:N,inputId:O,labelId:C,listInnerRef:P}),[]);function I($,K){var J,oe;let re=(oe=(J=l.current)==null?void 0:J.filter)!=null?oe:Hhe;return $?re($,r.current.search,K):0}function R(){if(!r.current.search||l.current.shouldFilter===!1)return;let $=r.current.filtered.items,K=[];r.current.filtered.groups.forEach(oe=>{let re=a.current.get(oe),Q=0;re.forEach(ce=>{let se=$.get(ce);Q=Math.max(se,Q)}),K.push([oe,Q])});let J=P.current;H().sort((oe,re)=>{var Q,ce;let se=oe.getAttribute("id"),fe=re.getAttribute("id");return((Q=$.get(fe))!=null?Q:0)-((ce=$.get(se))!=null?ce:0)}).forEach(oe=>{let re=oe.closest(WS);re?re.appendChild(oe.parentElement===re?oe:oe.closest(`${WS} > *`)):J.appendChild(oe.parentElement===J?oe:oe.closest(`${WS} > *`))}),K.sort((oe,re)=>re[1]-oe[1]).forEach(oe=>{var re;let Q=(re=P.current)==null?void 0:re.querySelector(`${Nd}[${ac}="${encodeURIComponent(oe[0])}"]`);Q?.parentElement.appendChild(Q)})}function L(){let $=H().find(J=>J.getAttribute("aria-disabled")!=="true"),K=$?.getAttribute(ac);T.setState("value",K||void 0)}function V(){var $,K,J,oe;if(!r.current.search||l.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let re=0;for(let Q of n.current){let ce=(K=($=i.current.get(Q))==null?void 0:$.value)!=null?K:"",se=(oe=(J=i.current.get(Q))==null?void 0:J.keywords)!=null?oe:[],fe=I(ce,se);r.current.filtered.items.set(Q,fe),fe>0&&re++}for(let[Q,ce]of a.current)for(let se of ce)if(r.current.filtered.items.get(se)>0){r.current.filtered.groups.add(Q);break}r.current.filtered.count=re}function z(){var $,K,J;let oe=G();oe&&((($=oe.parentElement)==null?void 0:$.firstChild)===oe&&((J=(K=oe.closest(Nd))==null?void 0:K.querySelector(Whe))==null||J.scrollIntoView({block:"nearest"})),oe.scrollIntoView({block:"nearest"}))}function G(){var $;return($=P.current)==null?void 0:$.querySelector(`${N8}[aria-selected="true"]`)}function H(){var $;return Array.from((($=P.current)==null?void 0:$.querySelectorAll(UD))||[])}function W($){let K=H()[$];K&&T.setState("value",K.getAttribute(ac))}function q($){var K;let J=G(),oe=H(),re=oe.findIndex(ce=>ce===J),Q=oe[re+$];(K=l.current)!=null&&K.loop&&(Q=re+$<0?oe[oe.length-1]:re+$===oe.length?oe[0]:oe[re+$]),Q&&T.setState("value",Q.getAttribute(ac))}function M($){let K=G(),J=K?.closest(Nd),oe;for(;J&&!oe;)J=$>0?tme(J,Nd):rme(J,Nd),oe=J?.querySelector(UD);oe?T.setState("value",oe.getAttribute(ac)):q($)}let Y=()=>W(H().length-1),F=$=>{$.preventDefault(),$.metaKey?Y():$.altKey?M(1):q(1)},D=$=>{$.preventDefault(),$.metaKey?W(0):$.altKey?M(-1):q(-1)};return v.createElement(ct.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:$=>{var K;(K=j.onKeyDown)==null||K.call(j,$);let J=$.nativeEvent.isComposing||$.keyCode===229;if(!($.defaultPrevented||J))switch($.key){case"n":case"j":{w&&$.ctrlKey&&F($);break}case"ArrowDown":{F($);break}case"p":case"k":{w&&$.ctrlKey&&D($);break}case"ArrowUp":{D($);break}case"Home":{$.preventDefault(),W(0);break}case"End":{$.preventDefault(),Y();break}case"Enter":{$.preventDefault();let oe=G();if(oe){let re=new Event(HN);oe.dispatchEvent(re)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:A.inputId,id:A.labelId,style:ome},d),gv(e,$=>v.createElement(_8.Provider,{value:T},v.createElement(C8.Provider,{value:A},$))))}),Ghe=v.forwardRef((e,t)=>{var r,n;let a=Bn(),i=v.useRef(null),s=v.useContext(E8),l=Yf(),d=O8(e),c=(n=(r=d.current)==null?void 0:r.forceMount)!=null?n:s?.forceMount;el(()=>{if(!c)return l.item(a,s?.id)},[c]);let f=T8(a,i,[e.value,e.children,i],e.keywords),h=B_(),p=Wi(E=>E.value&&E.value===f.current),g=Wi(E=>c||l.filter()===!1?!0:E.search?E.filtered.items.get(a)>0:!0);v.useEffect(()=>{let E=i.current;if(!(!E||e.disabled))return E.addEventListener(HN,x),()=>E.removeEventListener(HN,x)},[g,e.onSelect,e.disabled]);function x(){var E,T;b(),(T=(E=d.current).onSelect)==null||T.call(E,f.current)}function b(){h.setState("value",f.current,!0)}if(!g)return null;let{disabled:w,value:j,onSelect:N,forceMount:C,keywords:O,...P}=e;return v.createElement(ct.div,{ref:Oa(i,t),...P,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!p,"data-disabled":!!w,"data-selected":!!p,onPointerMove:w||l.getDisablePointerSelection()?void 0:b,onClick:w?void 0:x},e.children)}),Yhe=v.forwardRef((e,t)=>{let{heading:r,children:n,forceMount:a,...i}=e,s=Bn(),l=v.useRef(null),d=v.useRef(null),c=Bn(),f=Yf(),h=Wi(g=>a||f.filter()===!1?!0:g.search?g.filtered.groups.has(s):!0);el(()=>f.group(s),[]),T8(s,l,[e.value,e.heading,d]);let p=v.useMemo(()=>({id:s,forceMount:a}),[a]);return v.createElement(ct.div,{ref:Oa(l,t),...i,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&v.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:c},r),gv(e,g=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?c:void 0},v.createElement(E8.Provider,{value:p},g))))}),Khe=v.forwardRef((e,t)=>{let{alwaysRender:r,...n}=e,a=v.useRef(null),i=Wi(s=>!s.search);return!r&&!i?null:v.createElement(ct.div,{ref:Oa(a,t),...n,"cmdk-separator":"",role:"separator"})}),Xhe=v.forwardRef((e,t)=>{let{onValueChange:r,...n}=e,a=e.value!=null,i=B_(),s=Wi(c=>c.search),l=Wi(c=>c.selectedItemId),d=Yf();return v.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),v.createElement(ct.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":l,id:d.inputId,type:"text",value:a?e.value:s,onChange:c=>{a||i.setState("search",c.target.value),r?.(c.target.value)}})}),Jhe=v.forwardRef((e,t)=>{let{children:r,label:n="Suggestions",...a}=e,i=v.useRef(null),s=v.useRef(null),l=Wi(c=>c.selectedItemId),d=Yf();return v.useEffect(()=>{if(s.current&&i.current){let c=s.current,f=i.current,h,p=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let g=c.offsetHeight;f.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return p.observe(c),()=>{cancelAnimationFrame(h),p.unobserve(c)}}},[]),v.createElement(ct.div,{ref:Oa(i,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":n,id:d.listId},gv(e,c=>v.createElement("div",{ref:Oa(s,d.listInnerRef),"cmdk-list-sizer":""},c)))}),Qhe=v.forwardRef((e,t)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:i,container:s,...l}=e;return v.createElement(r8,{open:r,onOpenChange:n},v.createElement(n8,{container:s},v.createElement(a8,{"cmdk-overlay":"",className:a}),v.createElement(o8,{"aria-label":e.label,"cmdk-dialog":"",className:i},v.createElement(P8,{ref:t,...l}))))}),Zhe=v.forwardRef((e,t)=>Wi(r=>r.filtered.count===0)?v.createElement(ct.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),eme=v.forwardRef((e,t)=>{let{progress:r,children:n,label:a="Loading...",...i}=e;return v.createElement(ct.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},gv(e,s=>v.createElement("div",{"aria-hidden":!0},s)))}),Su=Object.assign(P8,{List:Jhe,Item:Ghe,Input:Xhe,Group:Yhe,Separator:Khe,Dialog:Qhe,Empty:Zhe,Loading:eme});function tme(e,t){let r=e.nextElementSibling;for(;r;){if(r.matches(t))return r;r=r.nextElementSibling}}function rme(e,t){let r=e.previousElementSibling;for(;r;){if(r.matches(t))return r;r=r.previousElementSibling}}function O8(e){let t=v.useRef(e);return el(()=>{t.current=e}),t}var el=typeof window>"u"?v.useEffect:v.useLayoutEffect;function oc(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function Wi(e){let t=B_(),r=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,r,r)}function T8(e,t,r,n=[]){let a=v.useRef(),i=Yf();return el(()=>{var s;let l=(()=>{var c;for(let f of r){if(typeof f=="string")return f.trim();if(typeof f=="object"&&"current"in f)return f.current?(c=f.current.textContent)==null?void 0:c.trim():a.current}})(),d=n.map(c=>c.trim());i.value(e,l,d),(s=t.current)==null||s.setAttribute(ac,l),a.current=l}),a}var nme=()=>{let[e,t]=v.useState(),r=oc(()=>new Map);return el(()=>{r.current.forEach(n=>n()),r.current=new Map},[e]),(n,a)=>{r.current.set(n,a),t({})}};function ame(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function gv({asChild:e,children:t},r){return e&&v.isValidElement(t)?v.cloneElement(ame(t),{ref:t.ref},r(t.props.children)):r(t)}var ome={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function ime({className:e,...t}){return o.jsx(Su,{"data-slot":"command",className:ke("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}function sme({className:e,...t}){return o.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[o.jsx(Rf,{className:"size-4 shrink-0 opacity-50"}),o.jsx(Su.Input,{"data-slot":"command-input",className:ke("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})}function lme({className:e,...t}){return o.jsx(Su.List,{"data-slot":"command-list",className:ke("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function cme({...e}){return o.jsx(Su.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function ume({className:e,...t}){return o.jsx(Su.Group,{"data-slot":"command-group",className:ke("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}function dme({className:e,...t}){return o.jsx(Su.Item,{"data-slot":"command-item",className:ke("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}function $n({value:e,onValueChange:t,options:r,placeholder:n="Select…",searchPlaceholder:a="Search…",emptyText:i="No matching results.",disabled:s,className:l}){const[d,c]=v.useState(!1),f=e?r.find(p=>p.value===e):void 0,h=e?f?.label??e:null;return o.jsxs(ka,{open:d,onOpenChange:c,children:[o.jsx(Aa,{asChild:!0,children:o.jsxs(de,{type:"button",variant:"outline",role:"combobox","aria-expanded":d,disabled:s,className:ke("w-full justify-between h-10 px-3 font-normal border border-gray-300 bg-white",l),children:[o.jsx("span",{className:ke("truncate text-left text-sm",!h&&"text-gray-500"),children:h??n}),o.jsx(P$,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),o.jsxs(Ia,{className:"p-0 w-[var(--radix-popover-trigger-width)] max-w-[min(100vw-2rem,400px)]",align:"start",children:[o.jsxs(ime,{children:[o.jsx(sme,{placeholder:a}),o.jsxs(lme,{children:[o.jsx(cme,{children:i}),o.jsx(ume,{children:r.map(p=>o.jsx(dme,{value:`${p.label} ${p.value}`,onSelect:()=>{t(p.value),c(!1)},className:ke("cursor-pointer rounded-md px-2 py-2 transition-colors","hover:bg-gray-100 hover:text-gray-900","data-[selected=true]:bg-gray-100",e===p.value&&"bg-blue-50 text-gray-900 font-medium data-[selected=true]:bg-blue-100"),children:o.jsx("span",{className:"truncate",children:p.label})},p.value))})]})]}),e?o.jsx("div",{className:"border-t border-gray-100 px-2 py-1.5",children:o.jsx("button",{type:"button",className:"text-xs text-gray-500 hover:text-gray-900 underline-offset-2 hover:underline",onClick:()=>{t(""),c(!1)},children:"Clear selection"})}):null]})]})}function ia({className:e,...t}){return o.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:ke("mx-auto flex w-full justify-center",e),...t})}function sa({className:e,...t}){return o.jsx("ul",{"data-slot":"pagination-content",className:ke("flex flex-row items-center gap-1",e),...t})}function St({...e}){return o.jsx("li",{"data-slot":"pagination-item",...e})}function Cn({className:e,isActive:t,size:r="icon",...n}){return o.jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:ke(Kp({variant:t?"outline":"ghost",size:r}),e),...n})}function la({className:e,...t}){return o.jsxs(Cn,{"aria-label":"Go to previous page",size:"default",className:ke("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[o.jsx(aC,{}),o.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function ca({className:e,...t}){return o.jsxs(Cn,{"aria-label":"Go to next page",size:"default",className:ke("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[o.jsx("span",{className:"hidden sm:block",children:"Next"}),o.jsx(Ui,{})]})}const Kf=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Xf="/label";async function fme(e,t){return Kf.requestJson({path:Xf,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,LocationId:e.locationId,ProductId:e.productId,LabelCategoryId:e.labelCategoryId,LabelTypeId:e.labelTypeId,TemplateCode:e.templateCode,State:e.state},signal:t})}async function hme(e,t){return Kf.requestJson({path:`${Xf}/${encodeURIComponent(e)}`,method:"GET",signal:t})}async function mme(e){return Kf.requestJson({path:Xf,method:"POST",body:{labelCode:String(e.labelCode??"").trim()||null,labelName:e.labelName,templateCode:e.templateCode,locationId:e.locationId,labelCategoryId:e.labelCategoryId,labelTypeId:e.labelTypeId,productIds:e.productIds,labelInfoJson:e.labelInfoJson,state:e.state??!0}})}async function pme(e,t){return Kf.requestJson({path:`${Xf}/${encodeURIComponent(e)}`,method:"PUT",body:{labelName:t.labelName,templateCode:t.templateCode,locationId:t.locationId,labelCategoryId:t.labelCategoryId,labelTypeId:t.labelTypeId,productIds:t.productIds,labelInfoJson:t.labelInfoJson,state:t.state??!0}})}async function gme(e){await Kf.requestJson({path:`${Xf}/${encodeURIComponent(e)}`,method:"DELETE"})}const z_="/api/app";function U_(e,t){const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function k8(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))if(!(a==null||a==="")){if(typeof a=="boolean"){t.set(n,a?"true":"false");continue}t.set(n,String(a))}const r=t.toString();return r?`?${r}`:""}function q_(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}function A8(e){if(!e)return null;const t=/filename\*?=(?:UTF-8''|)([^;]+)/i.exec(e);return t?.[1]?decodeURIComponent(t[1].trim().replace(/^["']|["']$/g,"")):null}function Zc(e){if(!e||typeof e!="object")return null;const t=e,r=t.error?.message?.trim();return r||(typeof t.errors=="string"&&t.errors.trim()?t.errors.trim():null)}function yme(e){if(!e||typeof e!="object")return e;const t=e;if("data"in t&&t.data!==void 0){if(t.succeeded===!1){const r=(typeof t.error?.message=="string"?t.error.message.trim():"")||Zc(e)||"Request failed.";throw new _r(r,typeof t.statusCode=="number"?t.statusCode:400,e)}return t.data}return e}async function vme(e){const r=U_("http://flus-test.3ffoodsafety.com",`${z_}${e.path}${k8(e.query??{})}`),n=q_(),a=await fetch(r,{method:"GET",headers:n?{Authorization:`Bearer ${n}`}:{},signal:e.signal}),i=a.headers.get("content-type")??"";if(!a.ok){if(i.includes("application/json")){const h=await a.json().catch(()=>null),p=Zc(h)||"Download failed.";throw new _r(p,a.status,h)}const f=await a.text().catch(()=>"");throw new _r(f||"Download failed.",a.status,f)}if(i.includes("application/json")){const f=await a.json().catch(()=>null),h=Zc(f)||"Download failed.";throw new _r(h,a.status,f)}const s=await a.blob(),l=A8(a.headers.get("content-disposition"))||e.defaultFileName,d=URL.createObjectURL(s),c=document.createElement("a");c.href=d,c.download=l,c.click(),URL.revokeObjectURL(d)}async function ju(e){const r=U_("http://flus-test.3ffoodsafety.com",`${z_}${e.path}${k8(e.query??{})}`),n=q_(),a={Accept:"*/*"};n&&(a.Authorization=`Bearer ${n}`);const i=await fetch(r,{method:"POST",headers:a,signal:e.signal}),s=i.headers.get("content-type")??"";if(!i.ok){if(s.includes("application/json")){const p=await i.json().catch(()=>null),g=Zc(p)||"Download failed.";throw new _r(g,i.status,p)}const h=await i.text().catch(()=>"");throw new _r(h||"Download failed.",i.status,h)}if(s.includes("application/json")){const h=await i.json().catch(()=>null),p=Zc(h)||"Download failed.";throw new _r(p,i.status,h)}const l=await i.blob(),d=A8(i.headers.get("content-disposition"))||e.defaultFileName,c=URL.createObjectURL(l),f=document.createElement("a");f.href=c,f.download=d,f.click(),URL.revokeObjectURL(c)}async function V_(e){const r=U_("http://flus-test.3ffoodsafety.com",`${z_}${e.path}`),n=q_(),a=new FormData;a.append(e.fieldName,e.file);const i={};n&&(i.Authorization=`Bearer ${n}`);const s=await fetch(r,{method:"POST",headers:i,body:a,signal:e.signal}),d=(s.headers.get("content-type")??"").includes("application/json")?await s.json().catch(()=>null):await s.text().catch(()=>"");if(!s.ok){const c=typeof d=="object"&&d&&Zc(d)||typeof d=="string"&&d.trim()||"Upload failed.";throw new _r(c,s.status,d)}if(typeof d!="object"||d===null)throw new _r("Invalid import response.",s.status,d);return yme(d)}const Jf=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});async function Nu(e,t){return Jf.requestJson({path:"/location",method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,Partner:e.partner,GroupName:e.groupName,State:e.state},signal:t})}async function xme(e){return Jf.requestJson({path:"/location",method:"POST",body:{partner:e.partner,groupName:e.groupName,locationCode:e.locationCode,locationName:e.locationName,street:e.street,city:e.city,stateCode:e.stateCode,country:e.country,zipCode:e.zipCode,phone:e.phone,email:e.email,latitude:e.latitude,longitude:e.longitude,state:e.state??!0}})}async function bme(e,t){return Jf.requestJson({path:`/location/${encodeURIComponent(e)}`,method:"PUT",body:{partner:t.partner,groupName:t.groupName,locationCode:t.locationCode,locationName:t.locationName,street:t.street,city:t.city,stateCode:t.stateCode,country:t.country,zipCode:t.zipCode,phone:t.phone,email:t.email,latitude:t.latitude,longitude:t.longitude,state:t.state??!0}})}async function wme(e){await Jf.requestJson({path:`/location/${encodeURIComponent(e)}`,method:"DELETE"})}async function Sme(e){await ju({path:"/location/download-location-import-template",defaultFileName:"Location-Manager-template.xlsx",signal:e})}async function jme(e,t){await ju({path:"/location/export-locations-excel",query:{Sorting:e.sorting,Keyword:e.keyword,Partner:e.partner,GroupName:e.groupName,State:e.state},defaultFileName:"locations-export.xlsx",signal:t})}async function Nme(e,t){return V_({path:"/location/import-locations-batch",fieldName:"file",file:e,signal:t})}async function Cme(e){return Jf.requestJson({path:"/location/locations-bulk",method:"PUT",body:e})}const _me=["TEXT","COLOR","IMAGE"];function tl(e){if(e==null)return[];if(Array.isArray(e)){const n=new Set;for(const a of e){const i=String(a??"").trim().toUpperCase();(i==="TEXT"||i==="COLOR"||i==="IMAGE")&&n.add(i)}return _me.filter(a=>n.has(a))}const t=String(e).trim();if(!t)return[];if(t.startsWith("["))try{const n=JSON.parse(t);if(Array.isArray(n))return tl(n)}catch{}const r=t.toUpperCase();return r==="TEXT"||r==="COLOR"||r==="IMAGE"?[r]:[]}function xc(e){return e.length===1&&e[0]==="IMAGE"?{text:!1,color:!1,image:!0}:{text:e.includes("TEXT"),color:e.includes("COLOR"),image:!1}}function W_(e){if(e.image)return["IMAGE"];const t=[];return e.text&&t.push("TEXT"),e.color&&t.push("COLOR"),t}function Ls(e){const t=String(e??"").trim();return t?/^#([0-9a-f]{6}|[0-9a-f]{3})$/i.test(t)?t:/^([0-9a-f]{6}|[0-9a-f]{3})$/i.test(t)?`#${t}`:"":""}function Bp(e){return e?!!(/^https?:\/\//i.test(e)||e.startsWith("/")||/\.(png|jpe?g|gif|webp|svg)(\?|$)/i.test(e)):!1}function H_(e){const t={v:1,appearances:e.appearances,displayText:(e.displayText??"").trim()||null,buttonBgColor:(e.buttonBgColor??"").trim()||null,buttonTextColor:(e.buttonTextColor??"").trim()||null,buttonImageUrl:(e.buttonImageUrl??"").trim()||null};return JSON.stringify(t)}function G_(e){const t=String(e??"").trim();if(!t.startsWith("["))return null;try{const r=JSON.parse(t);return Array.isArray(r)?r.map(n=>n==null?"":String(n)):null}catch{return null}}function Y_(e,t,r){const n={buttonAppearance:e,categoryName:r.categoryName,name:r.name,buttonTextColor:r.buttonTextColor,categoryPhotoUrl:""},a=Math.min(e.length,t.length);for(let i=0;iString(a??"").trim()).filter(a=>a.length>0);return n.length===0?null:JSON.stringify(n)}const t=String(e).trim();if(!t)return null;if(t.startsWith("["))try{const n=JSON.parse(t);if(Array.isArray(n)){const a=n.map(i=>String(i??"").trim()).filter(i=>i.length>0);return a.length===0?null:JSON.stringify(a)}}catch{return t}const r=t.toUpperCase();return r==="TEXT"||r==="COLOR"||r==="IMAGE"?JSON.stringify([r]):t}function ay(e){const t=(e??"").trim();if(!t)return null;try{const r=JSON.parse(t);if(!r||typeof r!="object")return null;const n=tl(r.appearances??r.buttonAppearance);return n.length===0?null:{v:1,appearances:n,displayText:r.displayText!=null?String(r.displayText):null,buttonBgColor:r.buttonBgColor!=null?String(r.buttonBgColor):null,buttonTextColor:r.buttonTextColor!=null?String(r.buttonTextColor):null,buttonImageUrl:r.buttonImageUrl!=null?String(r.buttonImageUrl):null}}catch{return null}}function Eme(e){const t=ay(e.buttonStyleJson);if(t)return{buttonAppearance:t.appearances,displayText:t.displayText??e.displayText,buttonBgColor:t.buttonBgColor??e.buttonBgColor,buttonTextColor:t.buttonTextColor??e.buttonTextColor,buttonImageUrl:t.buttonImageUrl??e.buttonImageUrl,categoryPhotoUrl:e.categoryPhotoUrl,categoryName:e.categoryName,name:e.name};const r=tl(e.buttonAppearance),n=G_(e.categoryPhotoUrl);return n&&r.length>0&&r.length===n.length?Y_(r,n,e):{buttonAppearance:e.buttonAppearance,displayText:e.displayText,buttonBgColor:e.buttonBgColor,buttonTextColor:e.buttonTextColor,buttonImageUrl:e.buttonImageUrl,categoryPhotoUrl:e.categoryPhotoUrl,categoryName:e.categoryName,name:e.name}}function I8(e){return X_(Eme(e))}function X_(e){const t=tl(e.buttonAppearance),r=(e.categoryName??e.name??"").trim(),n=(e.displayText??"").trim(),a=Ls(e.buttonBgColor),i=(e.buttonImageUrl??"").trim(),s=String(e.categoryPhotoUrl??"").trim();if(t.includes("IMAGE")){const p=i||(s&&Bp(s)?s:"");return p?{mode:"image",imageUrl:p}:{mode:"none"}}const l=t.includes("TEXT"),d=t.includes("COLOR");let c=a;!c&&d&&(c=Ls(s));let f=n;l&&!f&&s&&!Ls(s)&&!Bp(s)&&(f=s);const h=(f||r).trim();if(l&&d&&c)return{mode:"colorText",bg:c,text:h||r,textColor:(e.buttonTextColor??"").trim()||null};if(d&&c)return{mode:"color",bg:c};if(l&&h)return{mode:"text",text:h};if(t.length===0){const p=Ls(s);return p?{mode:"color",bg:p}:s&&Bp(s)?{mode:"image",imageUrl:s}:s?{mode:"text",text:s}:{mode:"none"}}return{mode:"none"}}const vv=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),xv="/label-category";async function M8(e,t){return vv.requestJson({path:xv,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function Pme(e){return vv.requestJson({path:xv,method:"POST",body:{categoryCode:String(e.categoryCode??"").trim()||null,categoryName:e.categoryName,categoryPhotoUrl:e.categoryPhotoUrl,displayText:(e.displayText??"").trim()||null,buttonBgColor:(e.buttonBgColor??"").trim()||null,buttonImageUrl:(e.buttonImageUrl??"").trim()||null,buttonAppearance:yv(e.buttonAppearance),buttonStyleJson:(e.buttonStyleJson??"").trim()||null,state:e.state??!0,orderNum:e.orderNum}})}async function Ome(e,t){return vv.requestJson({path:`${xv}/${encodeURIComponent(e)}`,method:"PUT",body:{categoryCode:String(t.categoryCode??"").trim()||null,categoryName:t.categoryName,categoryPhotoUrl:t.categoryPhotoUrl,displayText:(t.displayText??"").trim()||null,buttonBgColor:(t.buttonBgColor??"").trim()||null,buttonImageUrl:(t.buttonImageUrl??"").trim()||null,buttonAppearance:yv(t.buttonAppearance),buttonStyleJson:(t.buttonStyleJson??"").trim()||null,state:t.state??!0,orderNum:t.orderNum}})}async function Tme(e){await vv.requestJson({path:`${xv}/${encodeURIComponent(e)}`,method:"DELETE"})}const bv=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),wv="/label-type";async function J_(e,t){return bv.requestJson({path:wv,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function kme(e){return bv.requestJson({path:wv,method:"POST",body:{typeCode:String(e.typeCode??"").trim()||null,typeName:e.typeName,state:e.state??!0,orderNum:e.orderNum}})}async function Ame(e,t){return bv.requestJson({path:`${wv}/${encodeURIComponent(e)}`,method:"PUT",body:{typeCode:String(t.typeCode??"").trim()||null,typeName:t.typeName,state:t.state??!0,orderNum:t.orderNum}})}async function Ime(e){await bv.requestJson({path:`${wv}/${encodeURIComponent(e)}`,method:"DELETE"})}const rl=[{key:"fat",label:"Total Fat",defaultUnit:"g"},{key:"saturatedFat",label:"Saturated Fat",defaultUnit:"g"},{key:"transFat",label:"Trans Fat",defaultUnit:"g"},{key:"cholesterol",label:"Cholesterol",defaultUnit:"mg"},{key:"sodium",label:"Sodium",defaultUnit:"mg"},{key:"carbs",label:"Total Carbohydrates",defaultUnit:"g"},{key:"dietaryFiber",label:"Dietary Fiber",defaultUnit:"g"},{key:"totalSugar",label:"Total Sugar",defaultUnit:"g"},{key:"protein",label:"Protein",defaultUnit:"g"},{key:"vitaminA",label:"Vitamin A",defaultUnit:"mcg"},{key:"vitaminC",label:"Vitamin C",defaultUnit:"mg"},{key:"calcium",label:"Calcium",defaultUnit:"mg"},{key:"iron",label:"Iron",defaultUnit:"mg"}],R8=["Template","Label","Auto-generated","Print input"],D8={模版信息:"Template",模板信息:"Template",标签信息:"Label",自动生成:"Auto-generated",打印时输入:"Print input"};function Q_(e){const t=String(e??"").trim();return R8.includes(t)?t:D8[t]??"Template"}function L8(e){const t=String(e??"").trim();return R8.includes(t)||t in D8}function $8(e){const t=Q_(String(e));return t==="Auto-generated"?"AUTO_DB":t==="Print input"?"PRINT_INPUT":"FIXED"}function Mme(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"")||"field"}function Rme(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Dme(e,t){const r=Mme(e),n=new RegExp(`^${Rme(r)}(\\d+)$`,"i"),a=[];for(const s of t){const l=(s.elementName??"").trim();if(!l)continue;const d=l.match(n);d&&a.push(parseInt(d[1],10)),l.toLowerCase()===r&&a.push(1)}const i=a.length>0?Math.max(...a)+1:1;return`${r}${i}`}const Lme={Template:"template",Label:"label","Auto-generated":"auto","Print input":"print"};function Z_(e,t){const r=Lme[e],n=(t??"").trim()||"Field";return`${r}_${n}`}const $me=/^(template|label|auto|print)_/;function Fme(e){return $me.test(e.trim())}function F8(e){const t=e.config??{},r=Kr(e.type);if(tu(e)){if(r==="TEXT_STATIC"){const n=t.inputType;return n==="number"?"Number":n==="options"?"Multiple Options":"Text"}if(r==="DATE")return"Date & Time";if(r==="WEIGHT")return"Weight"}switch(r){case"TEXT_PRODUCT":return"Label Name";case"TEXT_PRICE":return"Price";case"NUTRITION":return"Nutrition Facts";case"DURATION":return"Duration";case"DATE":return"Current Date";case"TIME":return"Current Time";case"BARCODE":return"Barcode";case"QRCODE":return"QR Code";case"BLANK":return"Blank Space";case"IMAGE":return"Image";case"WEIGHT_PRICE":return"Weight Price";case"TEXT_STATIC":return"Text";default:return r.replace(/_/g," ")}}function Bme(){return`template-${Date.now()}`}function zme(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Ume(e){return{id:e??Bme(),name:"Unnamed template",labelType:"PRICE",unit:"cm",width:6,height:4,appliedLocation:"ALL",appliedLocationIds:[],showRuler:!0,showGrid:!0,elements:[]}}const bc=[{name:'2"×1"',width:2,height:1,unit:"inch"},{name:'2"×2"',width:2,height:2,unit:"inch"},{name:'3"×1"',width:3,height:1,unit:"inch"},{name:'3"×2"',width:3,height:2,unit:"inch"},{name:'4"×2"',width:4,height:2,unit:"inch"},{name:'4"×6"',width:4,height:6,unit:"inch"},{name:"6cm×4cm",width:6,height:4,unit:"cm"},{name:"10cm×6cm",width:10,height:6,unit:"cm"},{name:"A4",width:21,height:29.7,unit:"cm"},{name:"A5",width:14.8,height:21,unit:"cm"}];function qme(e,t=20,r=20){const n=zme(),i={TEXT_STATIC:{width:120,height:24,config:{text:"Text",fontFamily:"Arial",fontSize:14,fontWeight:"normal",textAlign:"left"}},TEXT_PRODUCT:{width:120,height:24,config:{text:"Product name",fontFamily:"Arial",fontSize:14,fontWeight:"normal",textAlign:"left"}},TEXT_PRICE:{width:80,height:24,config:{text:"0.00",decimal:2,fontFamily:"Arial",fontSize:14,fontWeight:"bold",textAlign:"right"}},BARCODE:{width:160,height:48,config:{barcodeType:"CODE128",data:"123456789",showText:!0,orientation:"horizontal"}},QRCODE:{width:80,height:80,config:{data:"https://example.com",errorLevel:"M"}},IMAGE:{width:60,height:60,config:{src:"",scaleMode:"contain"}},DATE:{width:120,height:24,config:{format:"DD/MM/YYYY",offsetDays:0,fontSize:14,textAlign:"left"}},TIME:{width:100,height:24,config:{format:"HH:mm",offsetDays:0}},DURATION:{width:120,height:24,config:{format:"Days",durationValue:3,fontSize:14,textAlign:"left"}},WEIGHT:{width:80,height:24,config:{unit:"g",value:500,fontSize:14,textAlign:"left"}},WEIGHT_PRICE:{width:100,height:24,config:{unitPrice:10,weight:.5,currency:"$"}},BLANK:{width:40,height:24,config:{}},NUTRITION:{width:200,height:120,config:{nutritionTitleFontSize:16,servingsPerContainer:"",servingSize:"",calories:"120",fat:"5",protein:"3",carbs:"10",layout:"standard",fixedNutrients:rl.map(s=>({key:s.key,label:s.label,value:s.key==="fat"?"5":s.key==="protein"?"3":s.key==="carbs"?"10":"",unit:s.defaultUnit??""})),extraNutrients:[]}}}[e];return{id:n,type:e,x:t,y:r,width:i.width,height:i.height,rotation:"horizontal",border:"none",config:{...i.config}}}function eE(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};return delete t.prefix,delete t.Prefix,t}function tE(e){return e.map((t,r)=>({id:t.id,elementName:(t.elementName??"").trim(),type:Kr(t.type),typeAdd:Qf(t),x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation,border:t.border,zIndex:t.zIndex??r+1,orderNum:t.orderNum??r+1,valueSourceType:V8(t),...t.inputKey!=null&&String(t.inputKey).trim()!==""?{inputKey:String(t.inputKey).trim()}:{},isRequiredInput:t.isRequiredInput??!1,config:eE(t.config??{})}))}function eu(e){const t=String(e.appliedLocation??"").trim().toUpperCase();return t==="ALL"?"ALL":t==="SPECIFIED"||(e.appliedLocationIds?.length??0)>0?"SPECIFIED":"ALL"}function tu(e){const t=Kr(e.type);if(String(e.valueSourceType??"").trim().toUpperCase()==="PRINT_INPUT")return!0;const n=e.config??{};return t==="TEXT_STATIC"&&n.inputType!=null&&String(n.inputType).trim()!==""||t==="DATE"&&(n.inputType==="datetime"||n.inputType==="date")||t==="WEIGHT"}function Vme(e){const t=e.config??{},r=Kr(e.type),n=typeof t.text=="string"?t.text.trim():"";if(n)return n;const a=t.inputType;return a==="number"?"Number":a==="text"?"Text":a==="options"?"Multiple Options":a==="datetime"||a==="date"?"Date & Time":r==="WEIGHT"?"Weight":r.replace(/_/g," ")}function B8(e){const t=e,r=e.inputKey??t.InputKey;return typeof r=="string"?r.trim():""}function ru(e){const t=Kr(e.type),r=e.config??{};if(t==="TIME"||t==="DURATION")return!0;if(t==="DATE"){const n=String(r.inputType??r.InputType??"").toLowerCase();if(n==="datetime"||n==="date")return!0;const a=Qf(e).trim().toLowerCase().replace(/\s+/g," ");if(a==="label_duration date"||a.includes("duration date"))return!0;const i=`${e.elementName??""} ${B8(e)}`.toLowerCase();if(/(durationdate|duration_date|duration\s*date)/.test(i))return!0}return!1}function z8(e){return Kr(e.type)==="BLANK"}function U8(e){return Qf(e).trim().toLowerCase().startsWith("template_")}function rE(e){const t=Qf(e).trim().toLowerCase();if(U8(e))return!1;const r=new Set(["label_label name","label_text","label_qr code","label_barcode","label_price","label_duration date","label_duration time","label_duration","label_image","label_label type","label_how-to","label_expiration alert"]),n=q8(e);return z8(e)||!r.has(t)?!1:n==="FIXED"||n==="PRINT_INPUT"}function GN(e){const t=Kr(e.type),r=(e.elementName??"").trim();if(r)return r;const n=B8(e);if(n)return n;const a=e.config??{};return t==="TEXT_PRODUCT"?(typeof a.text=="string"?a.text.trim():"")||"Product name":t==="TEXT_PRICE"?(typeof a.text=="string"?a.text.trim():"")||"Price":t==="IMAGE"?"Image":Vme(e)}function oy(e){return[...e].sort((t,r)=>{const n=t.orderNum??0,a=r.orderNum??0;if(n!==a)return n-a;const i=t.zIndex??0,s=r.zIndex??0;return i!==s?i-s:0})}function q8(e){const t=String(e.valueSourceType??"").trim().toUpperCase();if(t==="FIXED"&&tu({...e,valueSourceType:""}))return"PRINT_INPUT";if(t==="FIXED"||t==="AUTO_DB"||t==="PRINT_INPUT")return t;const r=(e.libraryCategory??"").trim();if(r.startsWith("print_"))return"PRINT_INPUT";if(r.startsWith("auto_"))return"AUTO_DB";if(r.startsWith("template_")||r.startsWith("label_"))return"FIXED";const n=e.libraryCategory??"";return L8(n)?$8(Q_(n)):tu({...e,valueSourceType:""})?"PRINT_INPUT":"FIXED"}function V8(e){return q8(e)}function W8(e){const t=Kr(e.type);if(tu(e))return"Print input";switch(t){case"TEXT_PRODUCT":case"NUTRITION":case"DURATION":case"TEXT_PRICE":case"WEIGHT_PRICE":return"Label";case"DATE":case"TIME":return"Auto-generated";case"TEXT_STATIC":case"BARCODE":case"QRCODE":case"IMAGE":case"BLANK":default:return"Template"}}const Wme=new Set(["TEXT_STATIC","TEXT_PRODUCT","TEXT_PRICE","BARCODE","QRCODE","IMAGE","DATE","TIME","DURATION","WEIGHT","WEIGHT_PRICE","BLANK","NUTRITION"]),nE=/^(template|label|auto|print)_(.+)$/i,Hme={"template|text":"TEXT_STATIC","template|qr code":"QRCODE","template|barcode":"BARCODE","template|blank space":"BLANK","template|price":"TEXT_PRICE","template|image":"IMAGE","template|logo":"IMAGE","label|label name":"TEXT_PRODUCT","label|text":"TEXT_STATIC","label|qr code":"QRCODE","label|barcode":"BARCODE","label|nutrition facts":"NUTRITION","label|price":"TEXT_PRICE","label|duration date":"DATE","label|duration time":"TIME","label|duration":"DURATION","label|image":"IMAGE","label|label type":"TEXT_STATIC","label|how-to":"TEXT_STATIC","label|expiration alert":"TEXT_STATIC","auto|company":"TEXT_STATIC","auto|employee":"TEXT_STATIC","auto|current date":"DATE","auto|current time":"TIME","auto|label id":"TEXT_STATIC","print|text":"TEXT_STATIC","print|weight":"WEIGHT","print|number":"TEXT_STATIC","print|date & time":"DATE","print|multiple options":"TEXT_STATIC"};function Gme(e){return String(e??"").trim().toLowerCase().replace(/\s+/g," ")}function Kr(e){const t=String(e??"").trim();if(Wme.has(t))return t;const r=t.match(nE);if(r){const n=r[1].toLowerCase(),a=Gme(r[2]),i=Hme[`${n}|${a}`];if(i)return i}return"TEXT_STATIC"}function H8(e,t){return Z_(e,t)}function Yme(e){const t=String(e.type??"").trim();if(nE.test(t))return t;const r=W8(e),n=F8(e);return H8(r,n)}function Qf(e){const t=String(e.typeAdd??"").trim();if(t)return t;const r=String(e.type??"").trim();return nE.test(r)?r:Yme(e)}function Kme(e){const t=e.libraryCategory?.trim();if(t&&Fme(t))return t;const r=t&&L8(t)?Q_(t):W8(e),n=F8(e);return Z_(r,n)}const Zf=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),eh="/label-template";function Xme(e){const t=e;if(!t||typeof t!="object")return"";const r=t.id??t.templateCode??t.TemplateCode;return typeof r=="string"?r.trim():String(r??"").trim()}function Jme(e){return Array.isArray(e)?e.map(t=>{const r=t,n=r.inputKey??r.InputKey,a=r.elementName??r.ElementName,i=r.typeAdd??r.TypeAdd,s=r.libraryCategory??r.LibraryCategory;let l;if(typeof s=="string"){const c=s.trim();c&&(l=c)}const d=r.config&&typeof r.config=="object"&&!Array.isArray(r.config)?r.config:{};return{...r,elementName:typeof a=="string"?a.trim():void 0,typeAdd:typeof i=="string"?i.trim():void 0,inputKey:typeof n=="string"?n:r.inputKey??null,libraryCategory:l,config:eE(d)}}):[]}function Qme(e){if(e==null||typeof e!="object"||Array.isArray(e))return{};const t={};for(const[r,n]of Object.entries(e))n==null?t[r]="":typeof n=="string"?t[r]=n:typeof n=="number"||typeof n=="boolean"?t[r]=String(n):t[r]=JSON.stringify(n);return t}function Zme(e){return Array.isArray(e)?e.map((t,r)=>{const n=t,a=n.defaultValues??n.DefaultValues??n.defaultValuesJson??n.DefaultValuesJson;return{productId:String(n.productId??n.ProductId??"").trim(),labelTypeId:String(n.labelTypeId??n.LabelTypeId??"").trim(),defaultValues:Qme(a),orderNum:Number(n.orderNum??n.OrderNum??r+1)||r+1}}):[]}function Sv(e){const t=e,n=((Array.isArray(t.appliedLocationIds)?t.appliedLocationIds:null)??(Array.isArray(t.AppliedLocationIds)?t.AppliedLocationIds:null)??[]).map(g=>String(g)),a=Xme(e),i=t.templateName??t.TemplateName,s=t.templateCode??t.TemplateCode,l=t.locationText??t.LocationText,d=t.sizeText??t.SizeText,c=t.contentsCount??t.ContentsCount,f=typeof c=="number"?c:void 0,h=t.lastEdited??t.LastEdited,p=(typeof t.name=="string"&&t.name.trim()?t.name:null)??(typeof i=="string"&&String(i).trim()?String(i):null);return{...t,id:a,name:p??t.name,templateName:(typeof i=="string"?i:null)??t.templateName,templateCode:(typeof s=="string"?s:null)??t.templateCode,locationText:(typeof l=="string"?l:null)??t.locationText,sizeText:(typeof d=="string"?d:null)??t.sizeText,contentsCount:f??t.contentsCount,lastEdited:(typeof h=="string"?h:null)??t.lastEdited,appliedLocationIds:n,elements:Jme(t.elements),templateProductDefaults:Zme(t.templateProductDefaults??t.TemplateProductDefaults)}}async function jv(e,t){const r=await Zf.requestJson({path:eh,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,LocationId:e.locationId,LabelType:e.labelType,State:e.state},signal:t}),n=(r.items??[]).map(a=>Sv(a));return{...r,items:n}}async function nu(e,t){const r=await Zf.requestJson({path:`${eh}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Sv(r)}async function epe(e){const t=await Zf.requestJson({path:eh,method:"POST",body:{id:e.id,name:e.name,labelType:e.labelType,unit:e.unit,width:e.width,height:e.height,appliedLocation:e.appliedLocation,showRuler:e.showRuler??!0,showGrid:e.showGrid??!0,state:e.state??!0,elements:e.elements,appliedLocationIds:e.appliedLocationIds??[]}});return Sv(t)}async function aE(e,t){const r={id:t.id,name:t.name,labelType:t.labelType,unit:t.unit,width:t.width,height:t.height,appliedLocation:t.appliedLocation,showRuler:t.showRuler??!0,showGrid:t.showGrid??!0,state:t.state??!0,elements:t.elements,appliedLocationIds:t.appliedLocationIds??[]};t.templateProductDefaults!==void 0&&(r.templateProductDefaults=t.templateProductDefaults.map((a,i)=>({productId:a.productId,labelTypeId:a.labelTypeId,defaultValues:a.defaultValues,orderNum:a.orderNum??i+1})));const n=await Zf.requestJson({path:`${eh}/${encodeURIComponent(e)}`,method:"PUT",body:r});return Sv(n)}async function tpe(e){await Zf.requestJson({path:`${eh}/${encodeURIComponent(e)}`,method:"DELETE"})}const Cu=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),hi="/product";function Nv(e){const t=e,r=String(t?.id??t?.Id??"").trim(),n=t?.locationIds??t?.LocationIds,a=Array.isArray(n)?n.map(i=>String(i).trim()).filter(Boolean):void 0;return{...t,id:r,productCode:t?.productCode??t?.ProductCode,productName:t?.productName??t?.ProductName,categoryId:t?.categoryId??t?.CategoryId,categoryName:t?.categoryName??t?.CategoryName,productImageUrl:t?.productImageUrl??t?.ProductImageUrl,state:typeof t?.state=="boolean"?t.state:typeof t?.State=="boolean"?t.State:null,...Array.isArray(n)?{locationIds:a??[]}:{}}}async function iy(e,t){const r=await Cu.requestJson({path:hi,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t});return{...r,items:(r.items??[]).map(n=>Nv(n))}}async function G8(e,t){const r=await Cu.requestJson({path:`${hi}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Nv(r)}async function rpe(e){const t={productCode:String(e.productCode??"").trim()||null,productName:e.productName,categoryId:e.categoryId?.trim()?e.categoryId.trim():null,productImageUrl:e.productImageUrl??null,state:e.state??!0};e.locationIds!==void 0&&(t.locationIds=e.locationIds);const r=await Cu.requestJson({path:hi,method:"POST",body:t});return Nv(r)}async function npe(e,t){const r={productCode:String(t.productCode??"").trim()||null,productName:t.productName,categoryId:t.categoryId?.trim()?t.categoryId.trim():null,productImageUrl:t.productImageUrl??null,state:t.state??!0};t.locationIds!==void 0&&(r.locationIds=t.locationIds);const n=await Cu.requestJson({path:`${hi}/${encodeURIComponent(e)}`,method:"PUT",body:r});return Nv(n)}async function ape(e){await Cu.requestJson({path:`${hi}/${encodeURIComponent(e)}`,method:"DELETE"})}async function ope(e){await ju({path:`${hi}/download-product-import-template`,defaultFileName:"Product-Manager-template.xlsx",signal:e})}async function ipe(e,t){await vme({path:`${hi}/export-products-excel`,query:{Keyword:e.keyword,State:e.state,Sorting:e.sorting},defaultFileName:"products-export.xlsx",signal:t})}async function spe(e,t){return V_({path:`${hi}/import-products-batch`,fieldName:"file",file:e,signal:t})}async function lpe(e){return Cu.requestJson({path:`${hi}/products-bulk`,method:"PUT",body:e})}const th=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),rh="/product-category";async function YN(e,t){return th.requestJson({path:rh,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function cpe(e,t){return th.requestJson({path:`${rh}/${encodeURIComponent(e)}`,method:"GET",signal:t})}async function upe(e){return th.requestJson({path:rh,method:"POST",body:{categoryCode:String(e.categoryCode??"").trim()||null,categoryName:e.categoryName,categoryPhotoUrl:e.categoryPhotoUrl??null,displayText:(e.displayText??"").trim()||null,buttonAppearance:yv(e.buttonAppearance),buttonTextColor:(e.buttonTextColor??"").trim()||null,buttonBgColor:(e.buttonBgColor??"").trim()||null,buttonImageUrl:(e.buttonImageUrl??"").trim()||null,buttonStyleJson:(e.buttonStyleJson??"").trim()||null,availabilityType:e.availabilityType??"ALL",locationIds:e.locationIds??[],state:e.state??!0,orderNum:e.orderNum??0}})}async function dpe(e,t){return th.requestJson({path:`${rh}/${encodeURIComponent(e)}`,method:"PUT",body:{categoryCode:String(t.categoryCode??"").trim()||null,categoryName:t.categoryName,categoryPhotoUrl:t.categoryPhotoUrl??null,displayText:(t.displayText??"").trim()||null,buttonAppearance:yv(t.buttonAppearance),buttonTextColor:(t.buttonTextColor??"").trim()||null,buttonBgColor:(t.buttonBgColor??"").trim()||null,buttonImageUrl:(t.buttonImageUrl??"").trim()||null,buttonStyleJson:(t.buttonStyleJson??"").trim()||null,availabilityType:t.availabilityType??"ALL",locationIds:t.locationIds??[],state:t.state??!0,orderNum:t.orderNum??0}})}async function fpe(e){await th.requestJson({path:`${rh}/${encodeURIComponent(e)}`,method:"DELETE"})}const hpe="/api/app/picture/category/upload";function mpe(e,t){const r=e.replace(/\/$/,""),n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}const Y8=5*1024*1024;function K8(){return"http://flus-test.3ffoodsafety.com".replace(/\/$/,"")??"http://localhost:19001"}function ppe(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")}catch{return null}}function qD(e){if(typeof e=="string"&&e.trim()){const r=e.trim();if(/^https?:\/\//i.test(r)||r.startsWith("/")||r.startsWith("data:"))return r}if(!e||typeof e!="object")return null;const t=e;for(const r of["url","Url","fileUrl","FileUrl","imageUrl","ImageUrl","path","Path"]){const n=t[r];if(typeof n=="string"&&n.trim())return n.trim()}return null}function gpe(e){if(!e||typeof e!="object")return e;const t=e;return"data"in t&&t.data!==void 0?t.data:"result"in t&&t.result!==void 0?t.result:e}function ype(e,t){if(e&&typeof e=="object"){const r=e,n=r.errors??r.Errors;if(typeof n=="string"&&n.trim())return n.trim();const a=r.error;if(a&&typeof a.message=="string"&&a.message.trim())return a.message.trim()}return`Upload failed (${t})`}function Tf(e){const t=(e??"").trim();if(!t)return"";if(t.startsWith("data:")||/^https?:\/\//i.test(t))return t;const r=K8();return t.startsWith("/")?`${r}${t}`:`${r}/${t}`}function vpe(e){if(e.size>Y8)throw new Error("Image must be 5 MB or smaller.");const t=/^(image\/(jpeg|png|webp|gif))$/i.test(e.type),r=/\.(jpe?g|png|webp|gif)$/i.test(e.name);if(!t&&!r)throw new Error("Only JPG, PNG, WebP, and GIF are allowed.")}async function xpe(e,t){vpe(e);const r=t?.subDir?.trim();if(r&&r.includes(".."))throw new Error("Invalid subDir.");const n=mpe(K8(),hpe),a=new FormData;a.append("file",e),r&&a.append("subDir",r);const i={},s=ppe();s&&(i.Authorization=`Bearer ${s}`);const l=await fetch(n,{method:"POST",body:a,headers:i,signal:t?.signal}),d=await l.text();let c=d;try{c=d?JSON.parse(d):null}catch{c=d}if(!l.ok)throw new Error(ype(c,l.status));const f=gpe(c),h=qD(f)??qD(c);if(!h)throw new Error("Upload response did not contain a usable image URL.");return h}function _u({value:e,onChange:t,disabled:r,hint:n,emptyLabel:a="",accept:i="image/jpeg,image/png,image/webp,image/gif",maxSizeMb:s=Y8/(1024*1024),className:l,boxClassName:d,uploadSubDir:c,oneImageOnly:f}){const h=v.useRef(null),[p,g]=v.useState(!1),x=async C=>{const O=C.target.files?.[0];if(C.target.value="",!!O){if(!O.type.startsWith("image/")){ee.error("Please select an image file.");return}if(O.size>s*1024*1024){ee.error(`Image must be ${s} MB or smaller.`);return}g(!0);try{const P=await xpe(O,{subDir:c});t(P),ee.success("Image uploaded.")}catch(P){const E=P instanceof Error?P.message:String(P);ee.error("Upload failed",{description:E||void 0})}finally{g(!1)}}},b=r||p,w=()=>{b||h.current?.click()},j=!!d?.trim(),N=j?"rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2":"w-full max-w-[200px] aspect-square rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2";return o.jsxs("div",{className:ke("space-y-2",l),children:[o.jsx("input",{ref:h,type:"file",accept:i,className:"sr-only",disabled:b,multiple:!1,onChange:x}),e?o.jsxs("div",{className:ke("group relative overflow-hidden border-2 border-dashed border-gray-300 bg-gray-50/80",N,j?d:null),children:[o.jsxs("button",{type:"button",disabled:b,onClick:w,className:"relative h-full w-full p-0","aria-label":"Replace image",children:[o.jsx("img",{src:Tf(e),alt:"",className:"h-full w-full object-contain",onError:C=>{C.target.style.opacity="0.2"}}),o.jsx("span",{className:"absolute inset-0 flex items-center justify-center bg-black/0 text-sm font-medium text-white opacity-0 transition group-hover:bg-black/45 group-hover:opacity-100",children:"Click to replace"})]}),o.jsx("button",{type:"button",disabled:b,onClick:C=>{C.stopPropagation(),t("")},className:"absolute right-1.5 top-1.5 flex h-7 w-7 items-center justify-center rounded-full bg-white/95 text-gray-600 shadow-sm ring-1 ring-gray-200 transition hover:bg-white hover:text-gray-900 disabled:opacity-50","aria-label":"Remove image",children:o.jsx(Qo,{className:"h-4 w-4"})})]}):o.jsx("button",{type:"button",disabled:b,onClick:w,"aria-label":a||"Upload image",className:ke(N,j?d:null,"flex border-2 border-dashed border-gray-300 bg-gray-50/80 text-gray-400",a&&!p?"flex-col items-center justify-center gap-2":"items-center justify-center","hover:border-gray-400 hover:bg-gray-100/90 hover:text-gray-500","disabled:pointer-events-none disabled:opacity-50"),children:p?o.jsx("span",{className:"px-3 text-center text-sm font-normal text-gray-500",children:"Uploading…"}):o.jsxs(o.Fragment,{children:[o.jsx(Un,{className:"h-10 w-10 shrink-0 stroke-[1.25]","aria-hidden":!0}),a?o.jsx("span",{className:"px-3 text-center text-sm font-normal leading-tight text-gray-400",children:a}):null]})}),f?o.jsx("p",{className:"text-xs text-muted-foreground",children:"One image only. Replace or clear to change."}):null,n?o.jsx("p",{className:"text-xs text-muted-foreground",children:n}):null]})}const oE=["Minutes","Hours","Days","Weeks","Months (30 Day)","Years"];function bpe(e,t,r){const n=new Date(e.getTime());switch(String(r??"").trim()){case"Minutes":n.setMinutes(n.getMinutes()+t);break;case"Hours":n.setHours(n.getHours()+t);break;case"Days":n.setDate(n.getDate()+t);break;case"Weeks":n.setDate(n.getDate()+t*7);break;case"Months (30 Day)":n.setDate(n.getDate()+t*30);break;case"Years":n.setFullYear(n.getFullYear()+t);break;default:n.setDate(n.getDate()+t)}return n}function VD(e,t){const r=String(t.getFullYear()),n=r.slice(-2),a=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),d=t.toLocaleString("en-US",{month:"long"}).toUpperCase(),c=t.toLocaleString("en-US",{weekday:"long"}).toUpperCase(),f=t.toLocaleString("en-US",{weekday:"short"}).toUpperCase();switch(t.toLocaleString("en-US",{month:"short"}).toUpperCase(),e){case"DD/MM/YYYY":return`${i}/${a}/${r}`;case"MM/DD/YYYY":return`${a}/${i}/${r}`;case"DD/MM/YY":return`${i}/${a}/${n}`;case"MM/DD/YY":return`${a}/${i}/${n}`;case"MM/YY":return`${a}/${n}`;case"MM/DD":return`${a}/${i}`;case"MM":return a;case"DD":return i;case"YY":return n;case"FULLY DAY(WEDNESDAY)":return c;case"DAY (WED)":return f;case"MONTH (DECEMBER)":return d;case"YEAR (2025)":return r;case"DD MONTH YEAR (25 DECEMBER 2025)":return`${i} ${d} ${r}`;default:return e.replace(/YYYY/g,r).replace(/YY/g,n).replace(/MM/g,a).replace(/DD/g,i).replace(/HH/g,s).replace(/mm/g,l)}}const wpe=new Set(oE);function X8(e){const t=String(e??"").trim();if(t==="")return{kind:"zero"};const r=Number(t);return Number.isFinite(r)?r===0?{kind:"zero"}:{kind:"amount",amount:r,storeValue:t}:{kind:"invalid"}}function kf(e,t){const r=String(e??"").trim()||"Days";return JSON.stringify({unit:r,value:String(t??"")})}function J8(e){const t=String(e??"").trim();if(!t.startsWith("{"))return null;try{const r=JSON.parse(t);if(r==null||typeof r!="object"||Array.isArray(r))return null;const n=r,a=String(n.unit??n.Unit??"").trim(),i=String(n.value??n.Value??"");return!a||!wpe.has(a)?null:{unit:a,value:i}}catch{return null}}function Q8(e){const t=J8(e);if(t)return t;const r=String(e??"").trim();return/^\d+$/.test(r)?{unit:"Days",value:r}:{unit:"Days",value:""}}const Z8="###nut###";function dc(e,t){return`${e}${Z8}${t}`}function Cv(e){const t=e.extraNutrients;return Array.isArray(t)?t.map((r,n)=>{const a=r;return{id:String(a.id??`extra-${n}`),name:String(a.name??""),value:String(a.value??""),unit:String(a.unit??"")}}):[]}function e6(e){return rl.find(r=>r.key===e)?.label??e}function au(e,t){const r=e[t];if(r!=null&&String(r).trim()!=="")return String(r).trim();const a=(Array.isArray(e.fixedNutrients)?e.fixedNutrients:[]).find(i=>String(i.key??"").trim()===t);return String(a?.value??"").trim()}function Spe(e){return String(e.calories??e.Calories??au(e,"calories")??"").trim()}function jpe(e){return String(e.servingsPerContainer??e.ServingsPerContainer??"").trim()}function Npe(e){return String(e.servingSize??e.ServingSize??"").trim()}function Cpe(e){return{id:"__nutrition_cfg__",type:"NUTRITION",x:0,y:0,width:1,height:1,rotation:"horizontal",border:"none",config:e}}function Eu(e){if(Kr(e.type)!=="NUTRITION")return[];const t=e.config??{},r=[];Spe(t)&&r.push({subKey:"calories",columnLabel:"Calories"}),jpe(t)&&r.push({subKey:"servingsPerContainer",columnLabel:"Servings Per Container"}),Npe(t)&&r.push({subKey:"servingSize",columnLabel:"Serving Size"});const n=Array.isArray(t.fixedNutrients)?t.fixedNutrients:[],a=new Set;if(n.length>0)for(const i of n){const s=String(i.key??"").trim();if(!s||a.has(s)||!String(i.value??"").trim())continue;a.add(s);const d=String(i.label??"").trim()||e6(s);r.push({subKey:s,columnLabel:d})}else for(const i of rl)au(t,i.key).trim()&&r.push({subKey:i.key,columnLabel:i.label});for(const i of Cv(t)){const s=String(i.id??"").trim();if(!s||!String(i.value??"").trim())continue;const d=i.name.trim()||"Other";r.push({subKey:`extra:${s}:value`,columnLabel:d})}return r}function wc(e){return(e??[]).filter(t=>Kr(t.type)==="NUTRITION")}function _pe(e){const t=e.config??{},r={},n=Eu(e);for(const a of n){if(a.subKey==="calories"){r.calories=String(t.calories??t.Calories??au(t,"calories")??"").trim();continue}if(a.subKey==="servingsPerContainer"){r.servingsPerContainer=String(t.servingsPerContainer??t.ServingsPerContainer??"").trim();continue}if(a.subKey==="servingSize"){r.servingSize=String(t.servingSize??t.ServingSize??"").trim();continue}if(a.subKey.startsWith("extra:")&&a.subKey.endsWith(":value")){const i=a.subKey.slice(6,-6),s=Cv(t).find(l=>l.id===i);r[a.subKey]=(s?.value??"").trim();continue}r[a.subKey]=au(t,a.subKey)}return r}function Cd(e,t,r){const n=String(e[t]??"").trim();if(n!=="")return n;if(t==="calories")return String(r.calories??r.Calories??au(r,"calories")??"").trim();if(t==="servingsPerContainer")return String(r.servingsPerContainer??r.ServingsPerContainer??"").trim();if(t==="servingSize")return String(r.servingSize??r.ServingSize??"").trim();if(t.startsWith("extra:")&&t.endsWith(":value")){const a=t.slice(6,-6);return(Cv(r).find(s=>s.id===a)?.value??"").trim()}return au(r,t)}function Epe(e,t){const r={...e},n=Eu(Cpe(e)),a=new Set(n.map(d=>d.subKey));if(a.has("calories")){const d=Cd(t,"calories",e);d?r.calories=d:(delete r.calories,delete r.Calories)}else delete r.calories,delete r.Calories;a.has("servingsPerContainer")?r.servingsPerContainer=Cd(t,"servingsPerContainer",e):(r.servingsPerContainer="",delete r.ServingsPerContainer),a.has("servingSize")?r.servingSize=Cd(t,"servingSize",e):(r.servingSize="",delete r.ServingSize);const i=Array.isArray(e.fixedNutrients)?e.fixedNutrients:[],s=[];for(const d of n){if(["calories","servingsPerContainer","servingSize"].includes(d.subKey)||d.subKey.startsWith("extra:"))continue;const c=Cd(t,d.subKey,e),f=i.find(g=>String(g.key??"").trim()===d.subKey),h=String(f?.unit??rl.find(g=>g.key===d.subKey)?.defaultUnit??""),p=String(f?.label??e6(d.subKey));s.push({key:d.subKey,label:p,value:c,unit:h})}r.fixedNutrients=s;const l=[];for(const d of n){if(!d.subKey.startsWith("extra:")||!d.subKey.endsWith(":value"))continue;const c=d.subKey.slice(6,-6),f=Cv(e).find(h=>h.id===c);l.push({id:c,name:(f?.name??d.columnLabel).trim()||"Other",value:Cd(t,d.subKey,e),unit:String(f?.unit??"").trim()})}return r.extraNutrients=l,r}function Ppe(e){const t={};for(const[r,n]of Object.entries(e)){const a=String(n??"").trim();a!==""&&(t[r]=a)}return JSON.stringify(t)}function Ope(e){const t=String(e??"").trim();if(!t.startsWith("{"))return{};try{const r=JSON.parse(t);if(r==null||typeof r!="object"||Array.isArray(r))return{};const n={};for(const[a,i]of Object.entries(r))n[a]=String(i??"");return n}catch{return{}}}function t6(e){const t=Ppe(e);return t==="{}"?null:t}function Tpe(e,t){const r={...e};for(const n of wc(t)){const a=r[n.id];if(typeof a!="string"||!a.trim().startsWith("{"))continue;const i=Ope(a);delete r[n.id];const s=new Set(Eu(n).map(l=>l.subKey));for(const[l,d]of Object.entries(i))s.has(l)&&(r[dc(n.id,l)]=d)}return r}function kpe(e,t){const r={...e};for(const n of wc(t)){const a=Eu(n),i={};for(const d of a){const c=dc(n.id,d.subKey);Object.prototype.hasOwnProperty.call(e,c)&&(i[d.subKey]=e[c]??"")}const s=`${n.id}${Z8}`;for(const d of Object.keys(r))d.startsWith(s)&&delete r[d];const l=t6(i);l?r[n.id]=l:delete r[n.id]}return r}function HS(){try{return crypto.randomUUID()}catch{return`row-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}}function Ape(e,t){if(!ru(e))return t??"";const r=String(t??"").trim();if(!r)return"";if(J8(r))return r;const{unit:n,value:a}=Q8(r);if(!String(a).trim())return r;const i=Number(String(a).trim());return Number.isFinite(i)?kf(n,String(a).trim()):r}const Ipe="h-[100px] w-[100px] min-h-[100px] min-w-[100px] max-h-[100px] max-w-[100px] shrink-0 aspect-auto";function Mpe(e){const t=Kr(e.type);return t==="IMAGE"||t==="QRCODE"?!0:(e.elementName??"").trim().toLowerCase().includes("qrcode")}function Rpe({value:e,onValueChange:t}){const{unit:r,value:n}=Q8(e);return o.jsxs("div",{className:"flex flex-wrap items-center gap-2 min-w-0 max-w-[220px]",children:[o.jsxs($e,{value:r,onValueChange:a=>t(kf(a,n)),children:[o.jsx(Be,{className:"h-10 min-w-0 flex-1 bg-white text-sm border-gray-300",children:o.jsx(Fe,{})}),o.jsx(ze,{children:oE.map(a=>o.jsx(we,{value:a,className:"text-xs",children:a},a))})]}),o.jsx(me,{type:"number",className:"h-10 w-20 shrink-0 border-gray-300 bg-white",value:n,onChange:a=>t(kf(r,a.target.value)),placeholder:"Val"})]})}function Dpe({element:e,value:t,onValueChange:r}){return Mpe(e)?o.jsx(_u,{value:t,onChange:r,uploadSubDir:"label-template-data",oneImageOnly:!0,boxClassName:Ipe,hint:"Upload stores full URL/path for save."}):ru(e)?o.jsx(Rpe,{value:t,onValueChange:r}):o.jsx(me,{value:t,onChange:n=>r(n.target.value),placeholder:"—",className:"h-10 border-gray-300 max-w-[220px]"})}function Lpe({templateCode:e,onBack:t,contextHint:r}){const[n,a]=v.useState(!0),[i,s]=v.useState(!1),[l,d]=v.useState(""),[c,f]=v.useState(null),[h,p]=v.useState([]),[g,x]=v.useState([]),[b,w]=v.useState([]),j=v.useMemo(()=>oy(c?.elements??[]),[c]),N=v.useMemo(()=>{const R=[];for(const L of j)if(rE(L)&&R.push({kind:"element",el:L}),Kr(L.type)==="NUTRITION")for(const V of Eu(L))R.push({kind:"nutrition",parent:L,spec:V});return R},[j]),C=v.useMemo(()=>h.map(R=>{const L=(R.productName??R.productCode??"").trim()||R.id;return{value:R.id,label:L}}),[h]),O=v.useMemo(()=>g.map(R=>{const L=(R.typeName??R.typeCode??"").trim()||R.id;return{value:R.id,label:L}}),[g]);v.useEffect(()=>{let R=!1;return(async()=>{a(!0);try{const[L,V,z]=await Promise.all([nu(e),iy({skipCount:Qa(1),maxResultCount:500}),J_({skipCount:Qa(1),maxResultCount:500})]);if(R)return;const G=(L.templateName??L.name??"").trim()||(L.templateCode??L.id??"").trim()||e;d(G),p(V.items??[]),x(z.items??[]),f(L);const H=L.templateProductDefaults??[],W=H.length>0?[...H].sort((q,M)=>(q.orderNum??0)-(M.orderNum??0)):[];W.length>0?w(W.map(q=>({id:HS(),productId:q.productId,labelTypeId:q.labelTypeId,fieldValues:Tpe({...q.defaultValues},L.elements??[])}))):w([{id:HS(),productId:"",labelTypeId:"",fieldValues:{}}])}catch(L){R||(ee.error("Failed to load template or options.",{description:L instanceof Error?L.message:"Please try again."}),d(e),w([]),f(null))}finally{R||a(!1)}})(),()=>{R=!0}},[e]);const P=v.useCallback(()=>{w(R=>[...R,{id:HS(),productId:"",labelTypeId:"",fieldValues:{}}])},[]),E=v.useCallback(R=>{w(L=>L.length<=1?L:L.filter(V=>V.id!==R))},[]),T=v.useCallback((R,L)=>{w(V=>V.map(z=>z.id===R?{...z,...L}:z))},[]),A=v.useCallback((R,L,V)=>{w(z=>z.map(G=>G.id!==R?G:{...G,fieldValues:{...G.fieldValues,[L]:V}}))},[]),I=v.useCallback(async()=>{if(!c){ee.error("Template not loaded",{description:"Please reload the page and try again."});return}if(b.filter(W=>W.productId.trim()||W.labelTypeId.trim()).some(W=>!W.productId.trim()||!W.labelTypeId.trim())){ee.error("Product and label type required",{description:"Each row that you started must have both Product and Label type selected."});return}const V=b.filter(W=>W.productId.trim()&&W.labelTypeId.trim()),z=oy(c.elements??[]),G=V.map((W,q)=>{const M=kpe(W.fieldValues,z),Y={};for(const F of N)F.kind==="element"&&(Y[F.el.id]=Ape(F.el,M[F.el.id]??""));for(const F of z)if(Kr(F.type)==="NUTRITION"){const D=M[F.id];D&&(Y[F.id]=D)}return{productId:W.productId.trim(),labelTypeId:W.labelTypeId.trim(),defaultValues:Y,orderNum:q+1}});if(z.length===0){ee.error("Template has no elements",{description:"Cannot save this template."});return}const H=eu(c);s(!0);try{const W=await aE(e,{id:c.id,name:(c.name??c.templateName??"").trim()||e,labelType:c.labelType??"PRICE",unit:c.unit??"inch",width:Number(c.width??2),height:Number(c.height??2),appliedLocation:H,showRuler:c.showRuler??!0,showGrid:c.showGrid??!0,state:c.state??!0,elements:tE(z),appliedLocationIds:H==="ALL"?[]:c.appliedLocationIds??[],templateProductDefaults:G});f(W),ee.success("Saved",{description:"Template product defaults were updated on the server."})}catch(W){ee.error("Save failed",{description:W instanceof Error?W.message:"Please try again."})}finally{s(!1)}},[e,c,b,N]);return o.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3 pb-4 border-b border-gray-200 shrink-0",children:[o.jsxs(de,{type:"button",variant:"outline",className:"h-10 gap-2",onClick:t,children:[o.jsx(C$,{className:"h-4 w-4"}),"Back"]}),o.jsxs("div",{className:"flex-1 min-w-[200px]",children:[o.jsx("div",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide",children:"Label template"}),o.jsx("h2",{className:"text-lg font-semibold text-gray-900 truncate",title:l,children:l}),r?o.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",title:r,children:r}):null]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(de,{type:"button",variant:"outline",className:"h-10 gap-1",onClick:P,children:[o.jsx(Un,{className:"h-4 w-4"}),"Add row"]}),o.jsx(de,{type:"button",className:"h-10 bg-blue-600 hover:bg-blue-700",onClick:()=>void I(),disabled:i||n||!c,children:i?"Saving…":"Save"})]})]}),o.jsxs("p",{className:"text-sm text-gray-600 py-3 shrink-0",children:["Bind product and label type per row. Values are saved with the template (edit API) as"," ",o.jsx("span",{className:"font-medium",children:"templateProductDefaults"})," (interface doc section 4.4). Columns cover"," ",o.jsx("span",{className:"font-medium",children:"Label"})," group defaults, ",o.jsx("span",{className:"font-medium",children:"PRINT_INPUT"})," / Duration fields, and (when present) ",o.jsx("span",{className:"font-medium",children:"Nutrition Facts"})," manual cells."," ",o.jsx("span",{className:"font-medium",children:"Template"})," panel elements are edited only in the label template editor (not here). Date / time / duration columns use ",o.jsx("span",{className:"font-medium",children:"unit + value"}),"; stored as JSON with ",o.jsx("span",{className:"font-medium",children:"unit"})," and ",o.jsx("span",{className:"font-medium",children:"value"})," keys. Nutrition values are stored as JSON under the nutrition element id for App print preview."]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-auto rounded-md border bg-white shadow-sm",children:n?o.jsx("div",{className:"p-10 text-center text-sm text-gray-500",children:"Loading…"}):N.length===0?o.jsx("div",{className:"p-10 text-center text-sm text-gray-600",children:"No manual input or nutrition columns in this template."}):o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px] min-w-[160px]",children:"Product"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[180px] min-w-[140px]",children:"Label type"}),N.map(R=>o.jsx(Ee,{className:"font-bold text-gray-900 min-w-[120px] whitespace-nowrap",title:R.kind==="element"?R.el.id:`${R.parent.id} · ${R.spec.subKey}`,children:R.kind==="element"?GN(R.el):R.spec.columnLabel},R.kind==="element"?R.el.id:dc(R.parent.id,R.spec.subKey))),o.jsx(Ee,{className:"w-[72px] text-center font-bold text-gray-900",children:" "})]})}),o.jsx(pn,{children:b.map(R=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"align-top py-2",children:o.jsx($n,{value:R.productId,onValueChange:L=>T(R.id,{productId:L}),options:C,placeholder:"Select product",searchPlaceholder:"Search product…"})}),o.jsx(xe,{className:"align-top py-2",children:o.jsx($n,{value:R.labelTypeId,onValueChange:L=>T(R.id,{labelTypeId:L}),options:O,placeholder:"Select label type",searchPlaceholder:"Search type…"})}),N.map(L=>o.jsx(xe,{className:"align-top py-2",children:L.kind==="element"?o.jsx(Dpe,{element:L.el,value:R.fieldValues[L.el.id]??"",onValueChange:V=>A(R.id,L.el.id,V)}):o.jsx(me,{value:R.fieldValues[dc(L.parent.id,L.spec.subKey)]??"",onChange:V=>A(R.id,dc(L.parent.id,L.spec.subKey),V.target.value),placeholder:"—",className:"h-10 border-gray-300 max-w-[220px]"})},L.kind==="element"?L.el.id:dc(L.parent.id,L.spec.subKey))),o.jsx(xe,{className:"text-center align-top py-2",children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 text-red-600 hover:text-red-700 hover:bg-red-50","aria-label":"Remove row",onClick:()=>E(R.id),disabled:b.length<=1,children:o.jsx(zt,{className:"h-4 w-4"})})})]},R.id))})]})})]})}var Km={},_d={},Xm={},WD;function ma(){if(WD)return Xm;WD=1,Object.defineProperty(Xm,"__esModule",{value:!0});function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}var t=function r(n,a){e(this,r),this.data=n,this.text=a.text||n,this.options=a};return Xm.default=t,Xm}var HD;function $pe(){if(HD)return _d;HD=1,Object.defineProperty(_d,"__esModule",{value:!0}),_d.CODE39=void 0;var e=(function(){function b(w,j){for(var N=0;N=200){w=p.shift()-105;var j=n.SWAP[w];j!==void 0?b=f.next(p,g+1,j):((x===n.SET_A||x===n.SET_B)&&w===n.SHIFT&&(p[0]=x===n.SET_A?p[0]>95?p[0]-96:p[0]:p[0]<32?p[0]+96:p[0]),b=f.next(p,g+1,x))}else w=f.correctIndex(p,x),b=f.next(p,g+1,x);var N=f.getBar(w),C=w*g;return{result:N+b.result,checksum:C+b.checksum}}}]),f})(r.default);return Qm.default=d,Qm}var Zm={},KD;function Fpe(){if(KD)return Zm;KD=1,Object.defineProperty(Zm,"__esModule",{value:!0});var e=nh(),t=function(l){return l.match(new RegExp("^"+e.A_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+e.B_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+e.C_CHARS+"*"))[0]};function a(s,l){var d=l?e.A_CHARS:e.B_CHARS,c=s.match(new RegExp("^("+d+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(c)return c[1]+"Ì"+i(s.substring(c[1].length));var f=s.match(new RegExp("^"+d+"+"))[0];return f.length===s.length?s:f+String.fromCharCode(l?205:206)+a(s.substring(f.length),!l)}function i(s){var l=n(s),d=l.length;if(d===s.length)return s;s=s.substring(d);var c=t(s)>=r(s);return l+String.fromCharCode(c?206:205)+a(s,c)}return Zm.default=function(s){var l=void 0,d=n(s).length;if(d>=2)l=e.C_START_CHAR+i(s);else{var c=t(s)>r(s);l=(c?e.A_START_CHAR:e.B_START_CHAR)+a(s,c)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(f,h){return"Ë"+h})},Zm}var XD;function Bpe(){if(XD)return Jm;XD=1,Object.defineProperty(Jm,"__esModule",{value:!0});var e=_v(),t=a(e),r=Fpe(),n=a(r);function a(c){return c&&c.__esModule?c:{default:c}}function i(c,f){if(!(c instanceof f))throw new TypeError("Cannot call a class as a function")}function s(c,f){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f&&(typeof f=="object"||typeof f=="function")?f:c}function l(c,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);c.prototype=Object.create(f&&f.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(c,f):c.__proto__=f)}var d=(function(c){l(f,c);function f(h,p){if(i(this,f),/^[\x00-\x7F\xC8-\xD3]+$/.test(h))var g=s(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,(0,n.default)(h),p));else var g=s(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,h,p));return s(g)}return f})(t.default);return Jm.default=d,Jm}var ep={},JD;function zpe(){if(JD)return ep;JD=1,Object.defineProperty(ep,"__esModule",{value:!0});var e=(function(){function c(f,h){for(var p=0;px.width*10?x.width*10:x.fontSize,b.guardHeight=x.height+b.fontSize/2+x.textMargin,b}return e(p,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(x,b){return this.text.substr(x,b)}},{key:"leftEncode",value:function(x,b){return(0,n.default)(x,b)}},{key:"rightText",value:function(x,b){return this.text.substr(x,b)}},{key:"rightEncode",value:function(x,b){return(0,n.default)(x,b)}},{key:"encodeGuarded",value:function(){var x={fontSize:this.fontSize},b={height:this.guardHeight};return[{data:t.SIDE_BIN,options:b},{data:this.leftEncode(),text:this.leftText(),options:x},{data:t.MIDDLE_BIN,options:b},{data:this.rightEncode(),text:this.rightText(),options:x},{data:t.SIDE_BIN,options:b}]}},{key:"encodeFlat",value:function(){var x=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:x.join(""),text:this.text}}}]),p})(i.default);return ap.default=f,ap}var aL;function Wpe(){if(aL)return np;aL=1,Object.defineProperty(np,"__esModule",{value:!0});var e=(function(){function h(p,g){for(var x=0;xx.width*10?b.fontSize=x.width*10:b.fontSize=x.fontSize,b.guardHeight=x.height+b.fontSize/2+x.textMargin,b}return e(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==f(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var x="";return x+="101",x+=(0,r.default)(this.data.substr(0,6),"LLLLLL"),x+="01010",x+=(0,r.default)(this.data.substr(6,6),"RRRRRR"),x+="101",{data:x,text:this.text}}},{key:"guardedEncoding",value:function(){var x=[];return this.displayValue&&x.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),x.push({data:"101"+(0,r.default)(this.data[0],"L"),options:{height:this.guardHeight}}),x.push({data:(0,r.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),x.push({data:"01010",options:{height:this.guardHeight}}),x.push({data:(0,r.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),x.push({data:(0,r.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&x.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),x}}]),p})(a.default);function f(h){var p=0,g;for(g=1;g<11;g+=2)p+=parseInt(h[g]);for(g=0;g<11;g+=2)p+=parseInt(h[g])*3;return(10-p%10)%10}return Ed.default=c,Ed}var cp={},cL;function Kpe(){if(cL)return cp;cL=1,Object.defineProperty(cp,"__esModule",{value:!0});var e=(function(){function x(b,w){for(var j=0;jj.width*10?N.fontSize=j.width*10:N.fontSize=j.fontSize,N.guardHeight=j.height+N.fontSize/2+j.textMargin,N}return e(b,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var j="";return j+="101",j+=this.encodeMiddleDigits(),j+="010101",{data:j,text:this.text}}},{key:"guardedEncoding",value:function(){var j=[];return this.displayValue&&j.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),j.push({data:"101",options:{height:this.guardHeight}}),j.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),j.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&j.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),j}},{key:"encodeMiddleDigits",value:function(){var j=this.upcA[0],N=this.upcA[this.upcA.length-1],C=h[parseInt(N)][parseInt(j)];return(0,r.default)(this.middleDigits,C)}}]),b})(a.default);function g(x,b){for(var w=parseInt(x[x.length-1]),j=f[w],N="",C=0,O=0;O=3&&this.number<=131070}}]),c})(r.default);return Od.pharmacode=l,Od}var Td={},jL;function ige(){if(jL)return Td;jL=1,Object.defineProperty(Td,"__esModule",{value:!0}),Td.codabar=void 0;var e=(function(){function d(c,f){for(var h=0;h":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),ec}var CL;function o6(){if(CL)return yp;CL=1,Object.defineProperty(yp,"__esModule",{value:!0});var e=(function(){function c(f,h){for(var p=0;p0?f.fontSize+f.textMargin:0)+f.marginTop+f.marginBottom}function a(c,f,h){if(h.displayValue&&ff&&(f=c[h].height);return f}function d(c,f,h){var p;if(h)p=h;else if(typeof document<"u")p=document.createElement("canvas").getContext("2d");else return 0;p.font=f.fontOptions+" "+f.fontSize+"px "+f.font;var g=p.measureText(c);if(!g)return 0;var x=g.width;return x}return Jn.getMaximumHeightOfEncodings=l,Jn.getEncodingHeight=n,Jn.getBarcodePadding=a,Jn.calculateEncodingAttributes=i,Jn.getTotalWidthOfEncodings=s,Jn}var LL;function pge(){if(LL)return Ep;LL=1,Object.defineProperty(Ep,"__esModule",{value:!0});var e=(function(){function l(d,c){for(var f=0;f0?(g=0,h.textAlign="left"):c.textAlign=="right"?(g=f.width-1,h.textAlign="right"):(g=f.width/2,h.textAlign="center"),h.fillText(f.text,g,x)}}},{key:"moveCanvasDrawing",value:function(c){var f=this.canvas.getContext("2d");f.translate(c.width,0)}},{key:"restoreCanvas",value:function(){var c=this.canvas.getContext("2d");c.restore()}}]),l})();return Ep.default=s,Ep}var Pp={},$L;function gge(){if($L)return Pp;$L=1,Object.defineProperty(Pp,"__esModule",{value:!0});var e=(function(){function d(c,f){for(var h=0;h0&&(this.drawRect(w-h.width*b,x,h.width*b,h.height,f),b=0);b>0&&this.drawRect(w-h.width*(b-1),x,h.width*b,h.height,f)}},{key:"drawSVGText",value:function(f,h,p){var g=this.document.createElementNS(s,"text");if(h.displayValue){var x,b;g.setAttribute("font-family",h.font),g.setAttribute("font-size",h.fontSize),h.fontOptions.includes("bold")&&g.setAttribute("font-weight","bold"),h.fontOptions.includes("italic")&&g.setAttribute("font-style","italic"),h.textPosition=="top"?b=h.fontSize-h.textMargin:b=h.height+h.textMargin+h.fontSize,h.textAlign=="left"||p.barcodePadding>0?(x=0,g.setAttribute("text-anchor","start")):h.textAlign=="right"?(x=p.width-1,g.setAttribute("text-anchor","end")):(x=p.width/2,g.setAttribute("text-anchor","middle")),g.setAttribute("x",x),g.setAttribute("y",b),g.appendChild(this.document.createTextNode(p.text)),f.appendChild(g)}}},{key:"setSvgAttributes",value:function(f,h){var p=this.svg;p.setAttribute("width",f+"px"),p.setAttribute("height",h+"px"),p.setAttribute("x","0px"),p.setAttribute("y","0px"),p.setAttribute("viewBox","0 0 "+f+" "+h),p.setAttribute("xmlns",s),p.setAttribute("version","1.1")}},{key:"createGroup",value:function(f,h,p){var g=this.document.createElementNS(s,"g");return g.setAttribute("transform","translate("+f+", "+h+")"),p.appendChild(g),g}},{key:"setGroupOptions",value:function(f,h){f.setAttribute("fill",h.lineColor)}},{key:"drawRect",value:function(f,h,p,g,x){var b=this.document.createElementNS(s,"rect");return b.setAttribute("x",f),b.setAttribute("y",h),b.setAttribute("width",p),b.setAttribute("height",g),x.appendChild(b),b}}]),d})();return Pp.default=l,Pp}var Op={},FL;function yge(){if(FL)return Op;FL=1,Object.defineProperty(Op,"__esModule",{value:!0});var e=(function(){function n(a,i){for(var s=0;s"u"?"undefined":e(f))==="object"&&!f.nodeName)return{element:f,renderer:a.default.ObjectRenderer};throw new i.InvalidElementException}}function d(f){var h=document.querySelectorAll(f);if(h.length!==0){for(var p=[],g=0;g"u")throw Error("No element to render on was provided.");return z._renderProperties=(0,c.default)(R),z._encodings=[],z._options=w.default,z._errorHandler=new g.default(z),typeof L<"u"&&(V=V||{},V.format||(V.format=T()),z.options(V)[V.format](L,V).render()),z};C.getModule=function(I){return t.default[I]};for(var O in t.default)t.default.hasOwnProperty(O)&&P(t.default,O);function P(I,R){N.prototype[R]=N.prototype[R.toUpperCase()]=N.prototype[R.toLowerCase()]=function(L,V){var z=this;return z._errorHandler.wrapBarcodeCall(function(){V.text=typeof V.text>"u"?void 0:""+V.text;var G=(0,n.default)(z._options,V);G=(0,h.default)(G);var H=I[R],W=E(L,H,G);return z._encodings.push(W),z})}}function E(I,R,L){I=""+I;var V=new R(I,L);if(!V.valid())throw new x.InvalidInputException(V.constructor.name,I);var z=V.encode();z=(0,i.default)(z);for(var G=0;Gt in e?Nge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,KN=(e,t)=>{for(var r in t||(t={}))u6.call(t,r)&&WL(e,r,t[r]);if(sy)for(var r of sy(t))d6.call(t,r)&&WL(e,r,t[r]);return e},XN=(e,t)=>{var r={};for(var n in e)u6.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&sy)for(var n of sy(e))t.indexOf(n)<0&&d6.call(e,n)&&(r[n]=e[n]);return r};/** + * @license QR Code generator library (TypeScript) + * Copyright (c) Project Nayuki. + * SPDX-License-Identifier: MIT + */var nl;(e=>{const t=class Ct{constructor(d,c,f,h){if(this.version=d,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],dCt.MAX_VERSION)throw new RangeError("Version value out of range");if(h<-1||h>7)throw new RangeError("Mask value out of range");this.size=d*4+17;let p=[];for(let x=0;x7)throw new RangeError("Invalid value");let x,b;for(x=f;;x++){const C=Ct.getNumDataCodewords(x,c)*8,O=s.getTotalBits(d,x);if(O<=C){b=O;break}if(x>=h)throw new RangeError("Data too long")}for(const C of[Ct.Ecc.MEDIUM,Ct.Ecc.QUARTILE,Ct.Ecc.HIGH])g&&b<=Ct.getNumDataCodewords(x,C)*8&&(c=C);let w=[];for(const C of d){r(C.mode.modeBits,4,w),r(C.numChars,C.mode.numCharCountBits(x),w);for(const O of C.getData())w.push(O)}a(w.length==b);const j=Ct.getNumDataCodewords(x,c)*8;a(w.length<=j),r(0,Math.min(4,j-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let C=236;w.lengthN[O>>>3]|=C<<7-(O&7)),new Ct(x,c,N,p)}getModule(d,c){return 0<=d&&d>>9)*1335;const h=(c<<10|f)^21522;a(h>>>15==0);for(let p=0;p<=5;p++)this.setFunctionModule(8,p,n(h,p));this.setFunctionModule(8,7,n(h,6)),this.setFunctionModule(8,8,n(h,7)),this.setFunctionModule(7,8,n(h,8));for(let p=9;p<15;p++)this.setFunctionModule(14-p,8,n(h,p));for(let p=0;p<8;p++)this.setFunctionModule(this.size-1-p,8,n(h,p));for(let p=8;p<15;p++)this.setFunctionModule(8,this.size-15+p,n(h,p));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let f=0;f<12;f++)d=d<<1^(d>>>11)*7973;const c=this.version<<12|d;a(c>>>18==0);for(let f=0;f<18;f++){const h=n(c,f),p=this.size-11+f%3,g=Math.floor(f/3);this.setFunctionModule(p,g,h),this.setFunctionModule(g,p,h)}}drawFinderPattern(d,c){for(let f=-4;f<=4;f++)for(let h=-4;h<=4;h++){const p=Math.max(Math.abs(h),Math.abs(f)),g=d+h,x=c+f;0<=g&&g{(C!=b-p||P>=x)&&N.push(O[C])});return a(N.length==g),N}drawCodewords(d){if(d.length!=Math.floor(Ct.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let h=0;h>>3],7-(c&7)),c++)}}a(c==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let c=0;c5&&d++):(this.finderPenaltyAddHistory(x,b),g||(d+=this.finderPenaltyCountPatterns(b)*Ct.PENALTY_N3),g=this.modules[p][w],x=1);d+=this.finderPenaltyTerminateAndCount(g,x,b)*Ct.PENALTY_N3}for(let p=0;p5&&d++):(this.finderPenaltyAddHistory(x,b),g||(d+=this.finderPenaltyCountPatterns(b)*Ct.PENALTY_N3),g=this.modules[w][p],x=1);d+=this.finderPenaltyTerminateAndCount(g,x,b)*Ct.PENALTY_N3}for(let p=0;pg+(x?1:0),c);const f=this.size*this.size,h=Math.ceil(Math.abs(c*20-f*10)/f)-1;return a(0<=h&&h<=9),d+=h*Ct.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let f=[6];for(let h=this.size-7;f.lengthCt.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*d+128)*d+64;if(d>=2){const f=Math.floor(d/7)+2;c-=(25*f-10)*f-55,d>=7&&(c-=36)}return a(208<=c&&c<=29648),c}static getNumDataCodewords(d,c){return Math.floor(Ct.getNumRawDataModules(d)/8)-Ct.ECC_CODEWORDS_PER_BLOCK[c.ordinal][d]*Ct.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let c=[];for(let h=0;h0);for(const h of d){const p=h^f.shift();f.push(0),c.forEach((g,x)=>f[x]^=Ct.reedSolomonMultiply(g,p))}return f}static reedSolomonMultiply(d,c){if(d>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let h=7;h>=0;h--)f=f<<1^(f>>>7)*285,f^=(c>>>h&1)*d;return a(f>>>8==0),f}finderPenaltyCountPatterns(d){const c=d[1];a(c<=this.size*3);const f=c>0&&d[2]==c&&d[3]==c*3&&d[4]==c&&d[5]==c;return(f&&d[0]>=c*4&&d[6]>=c?1:0)+(f&&d[6]>=c*4&&d[0]>=c?1:0)}finderPenaltyTerminateAndCount(d,c,f){return d&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(d,c){c[0]==0&&(d+=this.size),c.pop(),c.unshift(d)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function r(l,d,c){if(d<0||d>31||l>>>d)throw new RangeError("Value out of range");for(let f=d-1;f>=0;f--)c.push(l>>>f&1)}function n(l,d){return(l>>>d&1)!=0}function a(l){if(!l)throw new Error("Assertion error")}const i=class jr{constructor(d,c,f){if(this.mode=d,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(d){let c=[];for(const f of d)r(f,8,c);return new jr(jr.Mode.BYTE,d.length,c)}static makeNumeric(d){if(!jr.isNumeric(d))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f=1<{(t=>{const r=class{constructor(a,i){this.ordinal=a,this.formatBits=i}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(nl||(nl={}));(e=>{(t=>{const r=class{constructor(a,i){this.modeBits=a,this.numBitsCharCount=i}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(nl||(nl={}));var fc=nl;/** + * @license qrcode.react + * Copyright (c) Paul O'Shannessy + * SPDX-License-Identifier: ISC + */var Cge={L:fc.QrCode.Ecc.LOW,M:fc.QrCode.Ecc.MEDIUM,Q:fc.QrCode.Ecc.QUARTILE,H:fc.QrCode.Ecc.HIGH},f6=128,h6="L",m6="#FFFFFF",p6="#000000",g6=!1,y6=1,_ge=4,Ege=0,Pge=.1;function v6(e,t=0){const r=[];return e.forEach(function(n,a){let i=null;n.forEach(function(s,l){if(!s&&i!==null){r.push(`M${i+t} ${a+t}h${l-i}v1H${i+t}z`),i=null;return}if(l===n.length-1){if(!s)return;i===null?r.push(`M${l+t},${a+t} h1v1H${l+t}z`):r.push(`M${i+t},${a+t} h${l+1-i}v1H${i+t}z`);return}s&&i===null&&(i=l)})}),r.join("")}function x6(e,t){return e.slice().map((r,n)=>n=t.y+t.h?r:r.map((a,i)=>i=t.x+t.w?a:!1))}function Oge(e,t,r,n){if(n==null)return null;const a=e.length+r*2,i=Math.floor(t*Pge),s=a/t,l=(n.width||i)*s,d=(n.height||i)*s,c=n.x==null?e.length/2-l/2:n.x*s,f=n.y==null?e.length/2-d/2:n.y*s,h=n.opacity==null?1:n.opacity;let p=null;if(n.excavate){let x=Math.floor(c),b=Math.floor(f),w=Math.ceil(l+c-x),j=Math.ceil(d+f-b);p={x,y:b,w,h:j}}const g=n.crossOrigin;return{x:c,y:f,h:d,w:l,excavation:p,opacity:h,crossOrigin:g}}function Tge(e,t){return t!=null?Math.max(Math.floor(t),0):e?_ge:Ege}function b6({value:e,level:t,minVersion:r,includeMargin:n,marginSize:a,imageSettings:i,size:s,boostLevel:l}){let d=U.useMemo(()=>{const x=(Array.isArray(e)?e:[e]).reduce((b,w)=>(b.push(...fc.QrSegment.makeSegments(w)),b),[]);return fc.QrCode.encodeSegments(x,Cge[t],r,void 0,void 0,l)},[e,t,r,l]);const{cells:c,margin:f,numCells:h,calculatedImageSettings:p}=U.useMemo(()=>{let g=d.getModules();const x=Tge(n,a),b=g.length+x*2,w=Oge(g,s,x,i);return{cells:g,margin:x,numCells:b,calculatedImageSettings:w}},[d,s,i,n,a]);return{qrcode:d,margin:f,cells:c,numCells:h,calculatedImageSettings:p}}var kge=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Age=U.forwardRef(function(t,r){const n=t,{value:a,size:i=f6,level:s=h6,bgColor:l=m6,fgColor:d=p6,includeMargin:c=g6,minVersion:f=y6,boostLevel:h,marginSize:p,imageSettings:g}=n,b=XN(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=b,j=XN(b,["style"]),N=g?.src,C=U.useRef(null),O=U.useRef(null),P=U.useCallback(G=>{C.current=G,typeof r=="function"?r(G):r&&(r.current=G)},[r]),[E,T]=U.useState(!1),{margin:A,cells:I,numCells:R,calculatedImageSettings:L}=b6({value:a,level:s,minVersion:f,boostLevel:h,includeMargin:c,marginSize:p,imageSettings:g,size:i});U.useEffect(()=>{if(C.current!=null){const G=C.current,H=G.getContext("2d");if(!H)return;let W=I;const q=O.current,M=L!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;M&&L.excavation!=null&&(W=x6(I,L.excavation));const Y=window.devicePixelRatio||1;G.height=G.width=i*Y;const F=i/R*Y;H.scale(F,F),H.fillStyle=l,H.fillRect(0,0,R,R),H.fillStyle=d,kge?H.fill(new Path2D(v6(W,A))):I.forEach(function(D,$){D.forEach(function(K,J){K&&H.fillRect(J+A,$+A,1,1)})}),L&&(H.globalAlpha=L.opacity),M&&H.drawImage(q,L.x+A,L.y+A,L.w,L.h)}}),U.useEffect(()=>{T(!1)},[N]);const V=KN({height:i,width:i},w);let z=null;return N!=null&&(z=U.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{T(!0)},ref:O,crossOrigin:L?.crossOrigin})),U.createElement(U.Fragment,null,U.createElement("canvas",KN({style:V,height:i,width:i,ref:P,role:"img"},j)),z)});Age.displayName="QRCodeCanvas";var w6=U.forwardRef(function(t,r){const n=t,{value:a,size:i=f6,level:s=h6,bgColor:l=m6,fgColor:d=p6,includeMargin:c=g6,minVersion:f=y6,boostLevel:h,title:p,marginSize:g,imageSettings:x}=n,b=XN(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:j,numCells:N,calculatedImageSettings:C}=b6({value:a,level:s,minVersion:f,boostLevel:h,includeMargin:c,marginSize:g,imageSettings:x,size:i});let O=j,P=null;x!=null&&C!=null&&(C.excavation!=null&&(O=x6(j,C.excavation)),P=U.createElement("image",{href:x.src,height:C.h,width:C.w,x:C.x+w,y:C.y+w,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const E=v6(O,w);return U.createElement("svg",KN({height:i,width:i,viewBox:`0 0 ${N} ${N}`,ref:r,role:"img"},b),!!p&&U.createElement("title",null,p),U.createElement("path",{fill:l,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),U.createElement("path",{fill:d,d:E,shapeRendering:"crispEdges"}),P)});w6.displayName="QRCodeSVG";function Ige({data:e,width:t,height:r,showText:n,orientation:a="horizontal"}){const i=v.useRef(null),s=a==="vertical",l=Math.max(20,(s?t:r)-(n?14:4));v.useEffect(()=>{if(i.current&&e)try{jge(i.current,e,{format:"CODE128",width:1,height:l,displayValue:n!==!1,margin:2,fontOptions:"",fontSize:10})}catch{}},[e,l,n]);const d=o.jsx("svg",{ref:i,className:"w-full h-full min-h-0",style:{maxHeight:s?t:r}});return s?o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx("div",{style:{transform:"rotate(-90deg)",transformOrigin:"center center",width:r,height:t,display:"flex",alignItems:"center",justifyContent:"center"},children:d})}):d}const Jo=8;function cn(e){return Math.round(e/Jo)*Jo}const Ts=16;function zp(e,t,r,n,a,i,s=Ts){const l=s,d=s,c=a-s,f=i-s;let h=Math.max(20,cn(r)),p=Math.max(12,cn(n));const g=c-l,x=f-d;if(gh+T*f,g=[];let x=1;i==="mm"&&(d>120?x=20:d>60?x=10:d>25&&(x=5));const b=i==="inch"?8:10,w=Math.floor((0-h)/f)-2,j=Math.ceil((e-h)/f)+2,N=Math.max(-5e3,Math.min(5e3,w)),C=Math.max(-5e3,Math.min(5e3,j));for(let T=N;T<=C;T++){const A=p(T);if(A<-8||A>e+8)continue;const I=T===0||T%x===0;g.push(o.jsxs("g",{children:[o.jsx("line",{x1:A,y1:c,x2:A,y2:4,stroke:"#9ca3af",strokeWidth:1}),I?o.jsx("text",{x:A,y:12,fontSize:8,fill:"#4b5563",className:"select-none font-mono",textAnchor:"middle",children:T}):null]},`maj-${T}`));const R=Math.floor(b/2);for(let L=1;Le+4)continue;const G=L===R?10:12;g.push(o.jsx("line",{x1:z,y1:c,x2:z,y2:G,stroke:"#d1d5db",strokeWidth:.5},`min-${T}-${L}`))}}let O=0,P=0;l&&Number.isFinite(s)&&s>0&&(O=r+l.x/s*t,P=l.width/s*t);const E=l?Rge(l.width,s,n,a,i):null;return o.jsxs("svg",{width:"100%",height:c,viewBox:`0 0 ${e} ${c}`,preserveAspectRatio:"none",className:"block bg-slate-100/90 border-b border-slate-300 pointer-events-none select-none shrink-0","aria-hidden":!0,children:[o.jsx("line",{x1:0,y1:c-.5,x2:e,y2:c-.5,stroke:"#e5e7eb"}),g,l&&Number.isFinite(P)&&P>.5&&o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:O,y:1,width:Math.max(1,Math.min(P,e-O+1)),height:c-4,fill:"rgb(59 130 246 / 0.22)",stroke:"rgb(37 99 235 / 0.85)",strokeWidth:1,rx:2}),E&&o.jsx("text",{x:O+Math.max(2,Math.min(P,e-O)/2),y:c-6,textAnchor:"middle",fontSize:8,fill:"#1d4ed8",className:"select-none font-mono",children:E})]})]})}function GL(e,t,r){const n=String(e.prefix??"").trim(),a=String(e.multipleOptionName??e.MultipleOptionName??"").trim(),i=r.filter(Boolean).join(", "),s=t||"…";return n?i?`${n}${i}`:`${n}${s}`:a?`${a}: ${i||s}`:i||s}function Lge(e){const t=e.extraNutrients;return Array.isArray(t)?t.map((r,n)=>{const a=r;return{id:String(a.id??`extra-${n}`),name:String(a.name??""),value:String(a.value??""),unit:String(a.unit??"")}}):[]}function YS(e,t,r){const n=r==="value"?t:`${t}Unit`,a=e[n];if(a!=null&&String(a).trim()!=="")return String(a).trim();const s=(Array.isArray(e.fixedNutrients)?e.fixedNutrients:[]).find(l=>String(l.key??"").trim()===t);return String(s?.[r]??"").trim()}function $ge(e,t){const r=String(t.getFullYear()),n=r.slice(-2),a=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),d=t.toLocaleString("en-US",{month:"long"}).toUpperCase(),c=t.toLocaleString("en-US",{weekday:"long"}).toUpperCase(),f=t.toLocaleString("en-US",{weekday:"short"}).toUpperCase();switch(t.toLocaleString("en-US",{month:"short"}).toUpperCase(),e){case"DD/MM/YYYY":return`${i}/${a}/${r}`;case"MM/DD/YYYY":return`${a}/${i}/${r}`;case"DD/MM/YY":return`${i}/${a}/${n}`;case"MM/DD/YY":return`${a}/${i}/${n}`;case"MM/YY":return`${a}/${n}`;case"MM/DD":return`${a}/${i}`;case"MM":return a;case"DD":return i;case"YY":return n;case"FULLY DAY(WEDNESDAY)":return c;case"DAY (WED)":return f;case"MONTH (DECEMBER)":return d;case"YEAR (2025)":return r;case"DD MONTH YEAR (25 DECEMBER 2025)":return`${i} ${d} ${r}`;default:return e.replace("YYYY",r).replace("YY",n).replace("MM",a).replace("DD",i).replace("HH",s).replace("mm",l)}}const Fge=new Set(["Minutes","Hours","Days","Weeks","Months (30 Day)","Years"]);function Bge(e){const t=String(e??"").trim().toLowerCase();return t==="milligrams"?"mg":t==="grams"?"g":t==="ounces"?"oz":t==="pounds"?"lb":t==="kilograms"?"kg":t==="lb"||t==="kg"||t==="mg"||t==="g"||t==="oz"?t:"g"}function j6({el:e,isAppPrintField:t}){const r=e.config,n=Kr(e.type),a=e.rotation==="vertical",i={fontSize:r?.fontSize??14,fontFamily:r?.fontFamily??"Arial",fontWeight:r?.fontWeight??"normal",textAlign:r?.textAlign??"left",color:r?.color??"#000"},l=a&&(n==="TEXT_STATIC"||n==="TEXT_PRODUCT"||n==="TEXT_PRICE")?{writingMode:"vertical-rl",textOrientation:"mixed"}:{},d=a?{transform:"rotate(-90deg)",transformOrigin:"center center"}:{},c=r?.inputType;if(n==="TEXT_STATIC"){const f=r?.text??"Text";if(t){if(c==="options"){const p=Array.isArray(r?.selectedOptionValues)?r.selectedOptionValues:[],g=GL(r,f,p);return o.jsx("div",{className:"w-full h-full px-1 flex flex-col justify-center overflow-hidden pointer-events-none text-gray-600 italic text-[11px] leading-tight break-all",style:{...i,...l},title:"Filled in mobile app when printing",children:g})}const h=c==="number"?r?.text??"0":f;return o.jsx("div",{className:"w-full h-full px-1 flex items-center overflow-hidden pointer-events-none text-gray-600 italic text-[11px]",style:{...i,...l},title:"Filled in mobile app when printing",children:h})}if(c==="number")return o.jsx("input",{type:"number",readOnly:!0,value:r?.text??"0",className:"w-full h-full min-w-0 border border-gray-300 bg-white rounded px-1 pointer-events-none",style:{...i,...l,textAlign:"right"}});if(c==="options"){const h=Array.isArray(r?.selectedOptionValues)?r.selectedOptionValues:[],p=GL(r,f,h),g=h.length===0;return o.jsx("div",{className:ke("w-full h-full px-1 overflow-hidden whitespace-pre-wrap break-all leading-tight",g&&"text-gray-400"),style:{...i,...l},title:p,children:p})}return c==="text"?o.jsx("input",{type:"text",readOnly:!0,value:f,className:"w-full h-full min-w-0 border border-gray-300 bg-white rounded px-1 pointer-events-none",style:{...i,...l}}):o.jsx("div",{className:"w-full h-full px-1 overflow-hidden whitespace-pre-wrap break-all leading-tight",style:{...i,...l},children:f})}if(n==="TEXT_PRODUCT"){const f=r?.text??"Product name";return o.jsx("div",{className:"w-full h-full px-1 overflow-hidden whitespace-pre-wrap break-all leading-tight",style:{...i,...l},children:f})}if(n==="TEXT_PRICE"){const f=r?.text??"0.00";return o.jsx("div",{className:"w-full h-full px-1 overflow-hidden flex items-center",style:{...i,...l,justifyContent:i.textAlign==="center"?"center":i.textAlign==="right"?"flex-end":"flex-start"},children:o.jsx("span",{children:f})})}if(n==="BARCODE"){const f=r?.data??"123456789",h=r?.showText!==!1,p=r?.orientation==="vertical"?"vertical":"horizontal";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full overflow-hidden p-0.5",children:o.jsx("div",{className:"flex-1 w-full min-h-0 flex items-center justify-center",children:o.jsx(Ige,{data:f,width:e.width,height:e.height,showText:h,orientation:p})})})}if(n==="QRCODE"){const f=r?.data??"https://example.com",h=Math.min(e.width,e.height)-4;return o.jsx("div",{className:"w-full h-full flex items-center justify-center p-0.5",children:o.jsx(w6,{value:f,size:Math.max(20,h),level:"M",includeMargin:!1})})}if(n==="IMAGE"){const f=r?.src,h=a?{transform:"rotate(-90deg)"}:{};return f?o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("img",{src:Tf(f),alt:"",className:"max-w-full max-h-full object-contain",style:h})}):o.jsx("div",{className:"w-full h-full flex flex-col items-center justify-center bg-gray-100 text-gray-500 text-[10px] border border-dashed border-gray-300",style:h,children:o.jsx("span",{className:"font-medium",children:"Logo"})})}if(n==="DATE"){const f=r?.__previewFormatted;if(typeof f=="string"){const j=f.trim();return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:j||"—"})})}const h=String(r?.inputType??r?.InputType??"").toLowerCase(),p=(typeof r?.format=="string"&&r.format.trim()?r.format:typeof r?.Format=="string"&&r.Format.trim()?r.Format:h==="datetime"?"YYYY-MM-DD HH:mm":"DD/MM/YYYY")??(h==="datetime"?"YYYY-MM-DD HH:mm":"DD/MM/YYYY"),g=Number(r?.offsetDays??r?.OffsetDays??0)||0,x=new Date;x.setDate(x.getDate()+g);const b=$ge(p,x);return h==="datetime"||h==="date"?t?o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 flex items-center justify-center overflow-hidden pointer-events-none text-[10px] text-center whitespace-nowrap",style:{...i,...d},title:`Format: ${p}`,children:p})}):o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("input",{type:"date",readOnly:!0,value:"2025-02-01",className:"w-full h-full min-w-0 border border-gray-300 bg-white rounded px-1 pointer-events-none text-[10px]",style:{...i,...d}})}):o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:b})})}if(n==="TIME"){const f=r?.__previewFormatted;if(typeof f=="string")return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:f.trim()||"—"})});const p="HH:mm".replace("HH","12").replace("mm","30");return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:p})})}if(n==="DURATION"){const f=r?.__previewFormatted;if(typeof f=="string")return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:f.trim()||"—"})});const h=(typeof r?.format=="string"&&r.format.trim()?r.format:typeof r?.Format=="string"&&r.Format.trim()?r.Format:"Days")??"Days",p=Fge.has(h)?h:"Days",g=r?.durationValue??r?.value??r?.offsetDays??r?.DurationValue??r?.Value??r?.OffsetDays,b=`${Number.isFinite(Number(g))?Number(g):3} ${p}`;return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d},children:b})})}if(n==="WEIGHT"){const f=r?.value??r?.Value,h=f==null||f===""?500:typeof f=="number"?f:Number(f),p=Number.isFinite(h)?h:500,g=Bge((typeof r?.unit=="string"&&r.unit.trim()?r.unit:typeof r?.Unit=="string"&&r.Unit.trim()?r.Unit:"g")??"g"),x=r?.fontSize??r?.FontSize,b=Number.isFinite(Number(x))?Number(x):14,w=String(r?.textAlign??r?.TextAlign??"left").toLowerCase(),j=w==="center"||w==="right"?w:"left";return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsxs("div",{className:"px-1 overflow-hidden whitespace-nowrap",style:{...i,...d,fontSize:b,textAlign:j},children:[p,g]})})}if(n==="WEIGHT_PRICE"){const f=r?.unitPrice??10,h=r?.weight??.5,p=r?.currency??"$";return o.jsxs("div",{className:"w-full h-full px-1 overflow-hidden whitespace-nowrap",style:i,children:[p,(f*h).toFixed(2)]})}if(n==="NUTRITION"){const f=String(r.servingsPerContainer??r.ServingsPerContainer??"").trim(),h=String(r.servingSize??r.ServingSize??"").trim(),p=String(r.calories??r.Calories??YS(r,"calories","value")??"").trim(),g=Number(r.nutritionTitleFontSize??r.NutritionTitleFontSize??16)||16,x=rl.map(C=>{const O=YS(r,C.key,"value"),P=YS(r,C.key,"unit");return O?{id:C.key,label:C.label,value:O,unit:P}:null}).filter(Boolean),b=Lge(r).filter(C=>C.value.trim()).map(C=>({id:C.id,label:C.name.trim()||"Other",value:C.value.trim(),unit:C.unit.trim()})),w=[...x,...b],j=(C,O)=>{const P=String(C??"").trim(),E=String(O??"").trim();return!P&&!E?"":`<${P}${E?` ${E}`:""}`},N=o.jsxs("div",{className:"text-[10px] p-1 w-full h-full overflow-hidden flex flex-col leading-tight bg-white",children:[o.jsx("div",{className:"font-bold border-b border-black pb-0.5",style:{fontSize:`${g}px`},children:"Nutrition Facts"}),p?o.jsxs("div",{className:"flex items-center justify-between py-0.5 mt-0.5",children:[o.jsx("span",{className:"font-semibold text-[10px]",children:"Calories"}),o.jsx("span",{className:"font-semibold text-[10px]",children:j(p,"")})]}):null,f?o.jsxs("div",{className:"flex items-center justify-between py-0.5 text-[10px]",children:[o.jsx("span",{children:"Servings Per Container"}),o.jsx("span",{children:f})]}):null,h?o.jsxs("div",{className:"flex items-center justify-between pb-0.5 text-[10px]",children:[o.jsx("span",{children:"Serving Size"}),o.jsx("span",{children:h})]}):null,o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden pt-0.5",children:w.length===0?o.jsx("div",{className:"text-[7px] text-gray-500",children:"No nutrients"}):w.slice(0,18).map(C=>o.jsxs("div",{className:"flex items-center justify-between py-[1px] text-[10px]",children:[o.jsx("span",{className:"truncate font-medium",children:C.label}),o.jsx("span",{className:"shrink-0 font-medium",children:j(C.value,C.unit)})]},C.id))})]});return o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",children:o.jsx("div",{className:"shrink-0",style:a?{width:e.height,height:e.width,transform:"rotate(-90deg)",transformOrigin:"center center"}:{width:"100%",height:"100%"},children:N})})}return n==="BLANK"?o.jsx("div",{className:"w-full h-full border border-dashed border-gray-200"}):o.jsx("div",{className:"text-gray-500 text-[10px] px-1 truncate w-full flex items-center justify-center",children:e.type.replace(/_/g," ")})}function zge(e){return e==="top"||e==="bottom"?"ns-resize":e==="left"||e==="right"?"ew-resize":e==="top-left"||e==="bottom-right"?"nwse-resize":"nesw-resize"}function Uge({template:e,canvasBorder:t="none",selectedId:r,onSelect:n,onUpdateElement:a,onDeleteElement:i,onTemplateChange:s,scale:l=1,onZoomIn:d,onZoomOut:c,onResetZoom:f,onPreview:h,hideToolbarPresetSize:p=!1}){const g=v.useRef(null),x=v.useRef(null),b=v.useRef(null),w=v.useRef(null),j=v.useRef(null),N=v.useRef(null),C=v.useRef(null),[O,P]=U.useState(!1),[E,T]=U.useState(!1),[A,I]=U.useState(null),R=v.useRef(null),[L,V]=U.useState({x:0,y:0}),z=v.useRef(null),[G,H]=v.useState("cm"),W=ho(e.width,e.unit),q=ho(e.height,e.unit),M=W*l,Y=q*l,F=e.showGrid!==!1,D=t==="line"?"border border-gray-500":t==="dotted"?"border border-dotted border-gray-500":"border border-transparent",$=v.useRef(null),[K,J]=v.useState(0);v.useLayoutEffect(()=>{const ne=$.current;if(!ne)return;const pe=new ResizeObserver(_e=>{for(const ye of _e)J(ye.contentRect.width)});return pe.observe(ne),J(ne.getBoundingClientRect().width),()=>pe.disconnect()},[]);const oe=Math.max(1,K,M),re=Math.max(0,(oe-M)/2),Q=v.useMemo(()=>{if(!r)return null;const ne=e.elements.find(pe=>pe.id===r);return ne?{x:ne.x,width:ne.width}:null},[r,e.elements]),ce=v.useCallback((ne,pe)=>{if(O||ne.button===1)return;ne.stopPropagation(),n(pe),x.current?.focus();const _e=e.elements.find(Ae=>Ae.id===pe);if(!_e)return;const ye=document.getElementById(`element-${pe}`);ye&&(ye.classList.add("z-50","opacity-90","shadow-xl","ring-2","ring-blue-400","ring-offset-2"),ye.style.cursor="grabbing"),b.current={id:pe,startX:ne.clientX,startY:ne.clientY,elX:_e.x,elY:_e.y,w:_e.width,h:_e.height},N.current={id:pe,x:_e.x,y:_e.y},ne.currentTarget.setPointerCapture?.(ne.pointerId)},[e.elements,n,O]),se=v.useCallback(ne=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{ne(),C.current=null})},[]),fe=v.useCallback((ne,pe)=>{ne.stopPropagation(),j.current={edge:pe,startX:ne.clientX,startY:ne.clientY,startW:e.width,startH:e.height,startElements:e.elements.map(ye=>({id:ye.id,x:ye.x,y:ye.y}))};const _e=zge(pe);I(_e),document.body.style.cursor=_e,ne.currentTarget.setPointerCapture?.(ne.pointerId)},[e.width,e.height,e.elements]),be=v.useCallback(ne=>{if(E&&z.current){const pe=ne.clientX-z.current.startX,_e=ne.clientY-z.current.startY;V({x:z.current.x+pe,y:z.current.y+_e});return}if(E&&R.current&&g.current){const pe=ne.clientX-R.current.x,_e=ne.clientY-R.current.y;g.current.scrollLeft=R.current.scrollLeft-pe,g.current.scrollTop=R.current.scrollTop-_e;return}if(b.current){const{id:pe,startX:_e,startY:ye,elX:Ae,elY:Ge,w:ut,h:Ce}=b.current,tt=ne.clientX,ot=ne.clientY;se(()=>{const Nt=(tt-_e)/l,er=(ot-ye)/l,Ie=Ae+Nt,gt=Ge+er,{x:_t,y:Qt}=HL(Ie,gt,ut,Ce,W,q,Ts),Pr=document.getElementById(`element-${pe}`);Pr&&(Pr.style.left=`${_t}px`,Pr.style.top=`${Qt}px`),N.current={id:pe,x:_t,y:Qt}})}if(w.current){const{id:pe,corner:_e,startX:ye,startY:Ae,w:Ge,h:ut,elX:Ce,elY:tt}=w.current,ot=ne.clientX,Nt=ne.clientY;se(()=>{const er=(ot-ye)/l,Ie=(Nt-Ae)/l;let gt=Ge,_t=ut,Qt=Ce,Pr=tt;_e.includes("e")&&(gt=Math.max(20,Ge+er)),_e.includes("w")&&(gt=Math.max(20,Ge-er),Qt=Ce+(Ge-gt)),_e.includes("s")&&(_t=Math.max(12,ut+Ie)),_e.includes("n")&&(_t=Math.max(12,ut-Ie),Pr=tt+(ut-_t));const Vn=cn(gt),Jr=cn(_t),qr=cn(Qt),Or=cn(Pr),Vt=zp(qr,Or,Vn,Jr,W,q,Ts),gr=document.getElementById(`element-${pe}`);gr&&(gr.style.width=`${Vt.w}px`,gr.style.height=`${Vt.h}px`,gr.style.left=`${Vt.x}px`,gr.style.top=`${Vt.y}px`),N.current={id:pe,width:Vt.w,height:Vt.h,x:Vt.x,y:Vt.y}})}if(j.current&&s){const{edge:pe,startX:_e,startY:ye,startW:Ae,startH:Ge,startElements:ut}=j.current,Ce=ne.clientX,tt=ne.clientY;se(()=>{const ot=(Ce-_e)/l,Nt=(tt-ye)/l,er=1,Ie=ho(Ae,e.unit),gt=ho(Ge,e.unit),_t=ho(er,e.unit),Qt=ho(er,e.unit),Pr=pe==="top"||pe==="top-left"||pe==="top-right",Vn=pe==="bottom"||pe==="bottom-left"||pe==="bottom-right",Jr=pe==="left"||pe==="top-left"||pe==="bottom-left",qr=pe==="right"||pe==="top-right"||pe==="bottom-right";let Or=Ae,Vt=Ge,gr=0,Kt=0;if(qr){const tr=Math.max(_t,Ie+ot);Or=Math.max(er,Math.round(kp(tr,e.unit)))}if(Vn){const tr=Math.max(Qt,gt+Nt);Vt=Math.max(er,Math.round(kp(tr,e.unit)))}if(Jr){const tr=Math.max(_t,Ie-ot);Or=Math.max(er,Math.round(kp(tr,e.unit)));const Je=ho(Or,e.unit);gr=Ie-Je}if(Pr){const tr=Math.max(Qt,gt-Nt);Vt=Math.max(er,Math.round(kp(tr,e.unit)));const Je=ho(Vt,e.unit);Kt=gt-Je}const fr={};if((Jr||qr)&&(fr.width=Or),(Pr||Vn)&&(fr.height=Vt),(gr!==0||Kt!==0)&&ut.length>0){const tr=new Map(ut.map(Je=>[Je.id,Je]));fr.elements=e.elements.map(Je=>{const Et=tr.get(Je.id);if(!Et)return Je;const Lt=Math.max(0,Et.x-gr),sr=Math.max(0,Et.y-Kt);return Lt===Je.x&&sr===Je.y?Je:{...Je,x:Lt,y:sr}})}s(fr)})}},[E,s,l,e.unit,se,W,q]),Z=v.useCallback(()=>{E&&(T(!1),R.current=null,z.current=null),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null);const ne=b.current?.id||w.current?.id;if(ne){const pe=document.getElementById(`element-${ne}`);pe&&(pe.classList.remove("z-50","opacity-90","shadow-xl","ring-2","ring-blue-400","ring-offset-2"),pe.style.cursor="")}if(N.current){const{id:pe,..._e}=N.current;a(pe,_e),N.current=null}b.current=null,w.current=null,j.current=null,I(null),document.body.style.cursor=""},[a]);v.useEffect(()=>{const ne=_e=>{_e.code==="Space"&&!_e.repeat&&P(!0)},pe=_e=>{_e.code==="Space"&&(P(!1),T(!1),R.current=null,z.current=null)};return window.addEventListener("keydown",ne),window.addEventListener("keyup",pe),()=>{window.removeEventListener("keydown",ne),window.removeEventListener("keyup",pe)}},[]),v.useEffect(()=>{if(A)return document.body.style.cursor=A,()=>{document.body.style.cursor=""}},[A]);const Se=v.useCallback(()=>{const ne=g.current;if(!ne)return;const pe=()=>{ne.scrollLeft=Math.max(0,(ne.scrollWidth-ne.clientWidth)/2),ne.scrollTop=Math.max(0,(ne.scrollHeight-ne.clientHeight)/2)};requestAnimationFrame(()=>requestAnimationFrame(pe))},[]);v.useEffect(()=>{V({x:0,y:0}),Se();const ne=window.setTimeout(Se,80);return()=>window.clearTimeout(ne)},[l,W,q,K,Se]);const Ne=v.useCallback(ne=>{if(!r)return;if(ne.key==="Delete"||ne.key==="Backspace"){ne.preventDefault();const ot=e.elements.findIndex(Nt=>Nt.id===r);if(ot>=0){const Nt=e.elements.filter(er=>er.id!==r);i(r),n(Nt[ot]?.id??Nt[ot-1]?.id??null)}return}const pe=e.elements.find(ot=>ot.id===r);if(!pe)return;const _e=ne.shiftKey?1:Jo;let ye=0,Ae=0;switch(ne.key){case"ArrowLeft":ye=-_e;break;case"ArrowRight":ye=_e;break;case"ArrowUp":Ae=-_e;break;case"ArrowDown":Ae=_e;break;default:return}ne.preventDefault();const Ge=pe.x+ye,ut=pe.y+Ae,{x:Ce,y:tt}=HL(Ge,ut,pe.width,pe.height,W,q,Ts);a(pe.id,{x:Ce,y:tt})},[r,e.elements,a,i,n,W,q]),qe=ne=>{(O||ne.button===1)&&(ne.preventDefault(),T(!0),R.current={x:ne.clientX,y:ne.clientY,scrollLeft:g.current?.scrollLeft||0,scrollTop:g.current?.scrollTop||0},ne.currentTarget.setPointerCapture(ne.pointerId))},De=ne=>{if(E&&R.current&&g.current){const pe=ne.clientX-R.current.x,_e=ne.clientY-R.current.y;g.current.scrollLeft=R.current.scrollLeft-pe,g.current.scrollTop=R.current.scrollTop-_e}},He=ne=>{E&&(T(!1),R.current=null)};return o.jsxs("div",{className:"flex flex-col overflow-hidden bg-gray-100",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{className:"shrink-0 px-4 py-2 border-b border-gray-200 bg-white flex flex-nowrap items-center justify-between gap-3 z-10 min-h-[44px]",children:[o.jsx("span",{className:"text-sm font-medium text-gray-700 shrink-0 min-w-0 truncate",children:"Label Preview"}),o.jsxs("div",{className:"flex flex-nowrap items-center justify-end gap-2 shrink-0 min-w-0",children:[h&&o.jsx("button",{type:"button",onClick:h,className:"h-8 px-3 rounded border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 text-xs font-medium shadow-sm transition-all active:scale-95 shrink-0",children:"Preview"}),s&&!p?o.jsxs($e,{value:(()=>{const ne=bc.findIndex(pe=>pe.width===e.width&&pe.height===e.height&&pe.unit===e.unit);return ne>=0?String(ne):"custom"})(),onValueChange:ne=>{if(ne==="custom")return;const pe=bc[Number(ne)];pe&&s({width:pe.width,height:pe.height,unit:pe.unit})},children:[o.jsx(Be,{className:"h-8 w-[130px] max-w-[130px] text-xs shrink-0",children:o.jsx(Fe,{placeholder:"Canvas size"})}),o.jsxs(ze,{children:[bc.map((ne,pe)=>o.jsx(we,{value:String(pe),className:"text-xs",children:ne.name},pe)),o.jsx(we,{value:"custom",className:"text-xs text-gray-500",children:"Custom"})]})]}):null,s?o.jsx("button",{type:"button",onClick:()=>s({showGrid:!F}),className:ke("h-8 px-3 rounded border text-xs font-medium shadow-sm transition-colors shrink-0",F?"border-gray-300 bg-white text-gray-700 hover:bg-gray-50":"border-gray-300 bg-gray-100 text-gray-500"),children:F?"Hide grid":"Show grid"}):null,o.jsxs("div",{className:"flex items-center gap-1 bg-white rounded border border-gray-300 p-0.5 shadow-sm h-8 shrink-0",children:[o.jsx("button",{type:"button",onClick:c,disabled:!c,className:"h-6 w-6 rounded hover:bg-gray-100 text-gray-600 disabled:opacity-50 disabled:pointer-events-none flex items-center justify-center text-sm font-medium active:scale-90 transition-transform",title:"Zoom out",children:"−"}),o.jsxs("span",{className:"min-w-[3rem] text-center text-xs text-gray-600 font-medium",children:[Math.round(l*100),"%"]}),o.jsx("button",{type:"button",onClick:d,disabled:!d,className:"h-6 w-6 rounded hover:bg-gray-100 text-gray-600 disabled:opacity-50 disabled:pointer-events-none flex items-center justify-center text-sm font-medium active:scale-90 transition-transform",title:"Zoom in",children:"+"})]}),f?o.jsx("button",{type:"button",onClick:f,className:"h-8 px-3 rounded border border-blue-200 bg-blue-50 text-blue-800 hover:bg-blue-100 text-xs font-medium shadow-sm transition-all active:scale-95 shrink-0",title:"Reset zoom to 100% (match ruler canvas size, e.g. 3×2 inch)",children:"Restore size"}):null,o.jsxs($e,{value:G,onValueChange:ne=>H(ne),children:[o.jsx(Be,{className:ke("h-8 w-auto min-w-[4.25rem] max-w-[5.5rem] px-3 text-xs font-medium shrink-0 rounded border border-gray-300 bg-white text-gray-700 shadow-sm","hover:bg-gray-50 transition-all active:scale-95","focus:ring-0 focus:ring-offset-0 data-[state=open]:bg-gray-50"),title:"Preview ruler unit (does not change canvas size)",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"cm",className:"text-xs",children:"cm"}),o.jsx(we,{value:"mm",className:"text-xs",children:"mm"}),o.jsx(we,{value:"inch",className:"text-xs",children:"inch"})]})]})]})]}),o.jsxs("div",{ref:g,className:ke("overflow-auto relative",O?"cursor-grab active:cursor-grabbing":""),style:{flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},onPointerDown:qe,onPointerMove:De,onPointerUp:He,onPointerLeave:He,children:[o.jsx("div",{className:"pointer-events-none absolute inset-0 z-0 bg-gray-100","aria-hidden":!0}),o.jsx("div",{className:"relative z-[1] flex min-w-full w-max min-h-full flex-col box-border p-[50px]",style:{transform:`translate(${L.x}px, ${L.y}px)`},children:o.jsxs("div",{ref:$,className:"flex w-full min-w-full flex-col",children:[o.jsx("div",{className:"mb-2 w-full min-w-0",children:o.jsx(Dge,{rulerTotalWidthPx:oe,paperWidthPx:M,paperOffsetLeftPx:re,paperWidthTemplate:e.width,templateUnit:e.unit,displayUnit:G,baseW:W,selection:Q})}),o.jsx("div",{className:"flex w-full min-w-0 justify-center",children:o.jsx("div",{className:"shrink-0 relative overflow-visible",style:{width:M,height:Y},children:o.jsxs("div",{ref:x,tabIndex:0,className:ke("absolute left-0 top-0 bg-white shadow-lg outline-none",D,E?"cursor-grabbing":"cursor-grab"),style:{width:W,height:q,transform:`scale(${l})`,transformOrigin:"top left",backgroundImage:F?`linear-gradient(to right, rgba(0,0,0,0.06) 1px, transparent 1px), + linear-gradient(to bottom, rgba(0,0,0,0.06) 1px, transparent 1px)`:void 0,backgroundSize:F?`${Jo}px ${Jo}px`:void 0,pointerEvents:O?"none":"auto",cursor:A??void 0},onClick:ne=>{const pe=ne.target,_e=pe.closest('[id^="element-"]'),ye=pe.closest('[data-paper-resize-handle="true"]')||pe.closest('[title*="Drag to resize paper"]')||pe.closest('[title*="Drag to increase paper height"]')||pe.closest('[title*="Drag to increase paper width"]');!_e&&!ye&&n(null)},onPointerDown:ne=>{const pe=ne.target,_e=pe.closest('[id^="element-"]'),ye=pe.closest('[data-paper-resize-handle="true"]')||pe.closest('[title*="Drag to resize paper"]')||pe.closest('[title*="Drag to increase paper height"]')||pe.closest('[title*="Drag to increase paper width"]');x.current?.contains(pe)&&!_e&&!ye&&!b.current&&!w.current&&(O||ne.button===1)&&(ne.preventDefault(),ne.stopPropagation(),T(!0),z.current={x:L.x,y:L.y,startX:ne.clientX,startY:ne.clientY},R.current={x:ne.clientX,y:ne.clientY,scrollLeft:g.current?.scrollLeft??0,scrollTop:g.current?.scrollTop??0},ne.currentTarget.setPointerCapture?.(ne.pointerId))},onPointerMove:be,onPointerUp:Z,onKeyDown:Ne,children:[r?(()=>{const ne=e.elements.find(_e=>_e.id===r);if(!ne)return null;const pe="pointer-events-none absolute z-[2] border-blue-600";return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:ke(pe,"left-0 right-0 border-t border-dashed"),style:{top:ne.y},"aria-hidden":!0}),o.jsx("div",{className:ke(pe,"left-0 right-0 border-t border-dashed"),style:{top:ne.y+ne.height},"aria-hidden":!0}),o.jsx("div",{className:ke(pe,"top-0 bottom-0 border-l border-dashed"),style:{left:ne.x},"aria-hidden":!0}),o.jsx("div",{className:ke(pe,"top-0 bottom-0 border-l border-dashed"),style:{left:ne.x+ne.width},"aria-hidden":!0})]})})():null,s&&o.jsx("div",{className:"absolute left-0 right-0 h-3 cursor-ns-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-b border-gray-300 text-[10px] text-gray-500 transition-colors",style:{top:0},title:"Drag to resize paper (top edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"top"),children:"⋮"}),s&&o.jsx("div",{className:"absolute top-0 bottom-0 w-3 cursor-ew-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-r border-gray-300 text-[10px] text-gray-500 transition-colors",style:{top:0},title:"Drag to resize paper (left edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"left"),children:"⋮"}),s&&o.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-3 cursor-ns-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-t border-gray-300 text-[10px] text-gray-500 transition-colors",title:"Drag to resize paper (bottom edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"bottom"),children:"⋮"}),s&&o.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-3 cursor-ew-resize flex items-center justify-center bg-gray-200/80 hover:bg-blue-400/30 border-l border-gray-300 text-[10px] text-gray-500 transition-colors",title:"Drag to resize paper (right edge)","data-paper-resize-handle":"true",onPointerDown:ne=>fe(ne,"right"),children:"⋮"}),e.elements.map(ne=>{const pe=tu(ne);return o.jsxs("div",{id:`element-${ne.id}`,className:ke("absolute box-border cursor-move overflow-hidden transition-shadow",ne.border==="line"&&"border border-gray-400",ne.border==="dotted"&&"border border-dotted border-gray-400",r===ne.id&&"ring-2 ring-blue-500 ring-offset-1 z-10"),style:{left:ne.x,top:ne.y,width:ne.width,height:ne.height},onClick:_e=>{_e.stopPropagation(),n(ne.id)},onPointerDown:_e=>ce(_e,ne.id),children:[o.jsx("div",{className:ke("w-full h-full min-h-0 relative",pe&&"rounded-sm border-2 border-dashed border-amber-500/85 bg-amber-50/35"),children:o.jsx(j6,{el:ne,isAppPrintField:pe})}),r===ne.id&&o.jsxs(o.Fragment,{children:[["nw","ne","sw","se"].map(_e=>o.jsx("div",{className:"absolute w-3.5 h-3.5 bg-white border-2 border-blue-600 rounded-none z-20 shadow-sm hover:scale-110 transition-transform",style:{cursor:"nwse-resize",top:_e.startsWith("n")?-6:void 0,bottom:_e.startsWith("s")?-6:void 0,left:_e.endsWith("w")?-6:void 0,right:_e.endsWith("e")?-6:void 0},onPointerDown:ye=>{ye.stopPropagation();const Ae=e.elements.find(Ge=>Ge.id===ne.id);w.current={id:ne.id,corner:_e,startX:ye.clientX,startY:ye.clientY,w:Ae.width,h:Ae.height,elX:Ae.x,elY:Ae.y},ye.currentTarget.setPointerCapture?.(ye.pointerId)}},_e)),["n","s","w","e"].map(_e=>o.jsx("div",{className:"absolute bg-white border-2 border-blue-600 rounded-none z-10 shadow-sm hover:bg-blue-50",style:{cursor:_e==="n"||_e==="s"?"ns-resize":"ew-resize",width:_e==="n"||_e==="s"?"20px":"6px",height:_e==="n"||_e==="s"?"6px":"20px",top:_e==="n"?-3:_e==="s"?void 0:"50%",bottom:_e==="s"?-3:void 0,left:_e==="w"?-3:_e==="e"?void 0:"50%",right:_e==="e"?-3:void 0,transform:_e==="n"||_e==="s"?"translateX(-50%)":"translateY(-50%)"},onPointerDown:ye=>{ye.stopPropagation();const Ae=e.elements.find(ut=>ut.id===ne.id),Ge=document.getElementById(`element-${ne.id}`);Ge&&Ge.classList.add("z-50","opacity-90"),w.current={id:ne.id,corner:_e,startX:ye.clientX,startY:ye.clientY,w:Ae.width,h:Ae.height,elX:Ae.x,elY:Ae.y},ye.currentTarget.setPointerCapture?.(ye.pointerId)}},_e))]})]},ne.id)}),W>Ts*2&&q>Ts*2?o.jsx("svg",{className:"pointer-events-none absolute left-0 top-0 z-[12]",width:W,height:q,style:{overflow:"visible"},"aria-hidden":!0,children:(()=>{const ne=Ts,pe="#2563eb",_e=2,ye="10 6";return o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:0,y1:ne,x2:W,y2:ne,stroke:pe,strokeWidth:_e,strokeDasharray:ye}),o.jsx("line",{x1:0,y1:q-ne,x2:W,y2:q-ne,stroke:pe,strokeWidth:_e,strokeDasharray:ye}),o.jsx("line",{x1:ne,y1:0,x2:ne,y2:q,stroke:pe,strokeWidth:_e,strokeDasharray:ye}),o.jsx("line",{x1:W-ne,y1:0,x2:W-ne,y2:q,stroke:pe,strokeWidth:_e,strokeDasharray:ye})]})})()}):null]})})})]})})]})]})}function iE({template:e,canvasBorder:t="none",maxWidth:r=480}){const n=ho(e.width,e.unit),a=ho(e.height,e.unit),i=Math.min(0,...e.elements.map(b=>b.x)),s=Math.min(0,...e.elements.map(b=>b.y)),l=Math.max(n,...e.elements.map(b=>b.x+b.width)),d=Math.max(a,...e.elements.map(b=>b.y+b.height)),c=Math.max(1,l-i),f=Math.max(1,d-s),h=r?Math.min(r/c,r/f,2):1,p=c*h,g=f*h,x=t==="line"?"border border-gray-500":t==="dotted"?"border border-dotted border-gray-500":"border border-transparent";return o.jsx("div",{className:"inline-flex items-center justify-center p-4 bg-gray-100 rounded",style:{minWidth:p+32},children:o.jsx("div",{style:{width:p,height:g},className:ke("relative bg-white shadow-lg overflow-hidden",x),children:o.jsx("div",{className:"origin-top-left",style:{position:"absolute",left:0,top:0,width:c,height:f,transform:`scale(${h})`,transformOrigin:"0 0"},children:e.elements.map(b=>{const w=tu(b);return o.jsx("div",{className:"absolute box-border overflow-hidden pointer-events-none flex items-center justify-center text-xs",style:{left:b.x-i,top:b.y-s,width:b.width,height:b.height,border:b.border==="line"?"1px solid #999":b.border==="dotted"?"1px dotted #999":void 0},children:o.jsx("div",{className:ke("w-full h-full min-h-0 relative",w&&"rounded-sm border-2 border-dashed border-amber-500/85 bg-amber-50/35"),children:o.jsx(j6,{el:b,isAppPrintField:w})})},b.id)})})})})}function Ea(e){const t=(e??"").trim();return t||"None"}function qge(e){return(e.labelCode??e.id??"").trim()||"None"}function Vge(e){const t=(e.products??"").trim();if(t)return t;const r=(e.productName??"").trim();if(r)return r;const n=e.productIds?.length??0;return n>0?`${n} product(s)`:"None"}function YL(e){const t=e.productIds,r=Array.isArray(t)?t.map(n=>String(n).trim()).filter(Boolean):[];return{labelName:e.labelName??"",templateCode:e.templateCode??"",locationId:e.locationId??"",labelCategoryId:e.labelCategoryId??"",labelTypeId:e.labelTypeId??"",productIds:r.length?[r[0]]:[],labelInfoJson:e.labelInfoJson??null,state:e.state??!0}}function Up(e){return e?oy(e.elements??[]).filter(rE):[]}function Wge(e,t,r,n){if(!e)return null;const a=N6(e),i=new Date;for(const s of a.elements){if(!rE(s))continue;const l={...s.config};delete l.__previewFormatted;const d=s.id,c=Kr(s.type);if(ru(s)){const f=r[d]??{unit:"Days",value:""},h=f.unit||"Days",p=X8(f.value);if(p.kind==="invalid")l.__previewFormatted="";else{const g=p.kind==="zero"?0:p.amount,x=bpe(i,g,h);if(c==="DATE"){const b=String(l.inputType??l.InputType??"").toLowerCase(),w=(typeof l.format=="string"&&l.format.trim()?l.format:typeof l.Format=="string"&&l.Format.trim()?l.Format:b==="datetime"?"YYYY-MM-DD HH:mm":"DD/MM/YYYY")??"DD/MM/YYYY";l.__previewFormatted=VD(w,x)}else c==="TIME"?l.__previewFormatted=VD("HH:mm",x):l.__previewFormatted=`${g} ${h}`}}else{const f=t[d]??"";c==="BARCODE"||c==="QRCODE"?l.data=f:c==="IMAGE"?l.src=f:l.text=f}s.config=l}for(const s of a.elements){if(Kr(s.type)!=="NUTRITION")continue;const l=n[s.id]??{},d=Epe({...s.config},l);s.config=d}return a}function Hge(e,t,r,n){const a={};for(const i of Up(e)){const s=i.id;if(ru(i)){const l=r[s]??{unit:"Days",value:""},d=l.unit||"Days",c=X8(l.value);c.kind==="invalid"?a[s]="":c.kind==="zero"?a[s]=kf(d,"0"):a[s]=kf(d,c.storeValue)}else a[s]=String(t[s]??"")}for(const i of wc(e.elements??[])){const s=n[i.id];if(!s)continue;const l=t6(s);l&&(a[i.id]=l)}return a}function Bi(e){return(e.templateCode??e.id??"").trim()}function ly(e){const t=(e.templateName??e.name??"").trim()||"None",r=Bi(e)||"None";return`${t} (${r})`}function N6(e){return{id:e.id,name:(e.name??e.templateName??"").trim()||"Unnamed template",labelType:e.labelType??"PRICE",unit:e.unit??"cm",width:e.width??6,height:e.height??4,appliedLocation:eu(e),appliedLocationIds:[...e.appliedLocationIds??[]],showRuler:e.showRuler??!0,showGrid:e.showGrid??!0,elements:(e.elements??[]).map((t,r)=>{const n=t,a=(n.elementName??"").trim();return{...n,elementName:a||`element${r+1}`}})}}function Gge(e){const t=new Map;for(const r of e.templateProductDefaults??[]){const n=`${r.productId}::${r.labelTypeId}`;t.set(n,r)}return t}function C6(e){const[t,r]=v.useState(!1),[n,a]=v.useState([]),[i,s]=v.useState([]),[l,d]=v.useState([]),[c,f]=v.useState([]),[h,p]=v.useState([]),[g,x]=v.useState([]);return v.useEffect(()=>{if(!e)return;let b=!1;return(async()=>{r(!0);try{const[w,j,N,C,O,P]=await Promise.all([jv({skipCount:1,maxResultCount:500}),Nu({skipCount:1,maxResultCount:500}),M8({skipCount:1,maxResultCount:500}),J_({skipCount:1,maxResultCount:500}),iy({skipCount:1,maxResultCount:500}),YN({skipCount:1,maxResultCount:500,sorting:"OrderNum desc"})]);if(b)return;a(w.items??[]),s(j.items??[]),d(N.items??[]),f(C.items??[]),p(O.items??[]),x(P.items??[])}catch(w){b||(ee.error("Failed to load options",{description:w?.message?String(w.message):"Check network or sign-in."}),a([]),s([]),d([]),f([]),p([]),x([]))}finally{b||r(!1)}})(),()=>{b=!0}},[e]),{loading:t,templates:n,locations:i,categories:l,types:c,products:h,productCategories:g}}function _6({productCatalogCategoryId:e,onProductCatalogCategoryIdChange:t,productId:r,onProductIdChange:n,products:a,productCategories:i,disabled:s}){const l=v.useMemo(()=>i.map(h=>({value:(h.id??"").trim(),label:Ea(h.categoryName??h.categoryCode??h.id)})).filter(h=>h.value),[i]),d=v.useMemo(()=>{const h=e.trim();return h?a.filter(p=>(p.categoryId??"").trim()===h):[]},[a,e]),c=v.useMemo(()=>{const h=d.map(g=>{const x=(g.productName??g.productCode??"").trim()||g.id;return{value:g.id,label:`${x}`}}),p=r.trim();if(p&&!h.some(g=>g.value===p)){const g=a.find(b=>b.id===p),x=(g?.productName??g?.productCode??"").trim()||p;return[{value:p,label:`${x} (current)`},...h]}return h},[d,r,a]),f=v.useMemo(()=>c.map(h=>({value:h.value,label:h.label})),[c]);return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Product category *"}),o.jsx($n,{value:e,onValueChange:h=>{t(h),n("")},options:l,placeholder:"Select product category first",searchPlaceholder:"Search product category…",emptyText:"No product categories.",disabled:s})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Product *"}),o.jsx($n,{value:r,onValueChange:n,options:f,placeholder:e.trim()?"Select one product":"Select category first",searchPlaceholder:"Search products…",emptyText:e.trim()?"No products in this category.":"Select a product category.",disabled:s||!e.trim()}),r.trim()?o.jsxs("p",{className:"text-xs text-gray-500 font-mono truncate",title:r,children:["Id: ",r]}):null]})]})}function Yge({openCreateSeq:e=0,onOpenCreateIntentConsumed:t}={}){const[r,n]=v.useState(null),[a,i]=v.useState(void 0),[s,l]=v.useState(!1),[d,c]=v.useState(!1),[f,h]=v.useState(!1),[p,g]=v.useState([]),[x,b]=v.useState(""),[w,j]=v.useState(null),[N,C]=v.useState(!1),[O,P]=v.useState(!1),[E,T]=v.useState(!1),[A,I]=v.useState(null),[R,L]=v.useState(null),[V,z]=v.useState([]),[G,H]=v.useState(!1),[W,q]=v.useState(0),[M,Y]=v.useState(0),[F,D]=v.useState(null),[$,K]=v.useState(""),[J,oe]=v.useState("all"),[re,Q]=v.useState("all"),[ce,se]=v.useState("all"),[fe,be]=v.useState("all"),[Z,Se]=v.useState("all"),[Ne,qe]=v.useState(1),[De,He]=v.useState(10);v.useEffect(()=>{e<=0||(C(!0),t?.())},[e,t]);const ne=v.useRef(null),pe=v.useRef(null),[_e,ye]=v.useState("");v.useEffect(()=>(pe.current&&window.clearTimeout(pe.current),pe.current=window.setTimeout(()=>ye($.trim()),300),()=>{pe.current&&window.clearTimeout(pe.current)}),[$]);const Ae=Math.max(1,Math.ceil(W/De));v.useEffect(()=>{qe(1)},[_e,J,re,ce,fe,Z,De]),v.useEffect(()=>((async()=>{ne.current?.abort();const gt=new AbortController;ne.current=gt,H(!0);try{const _t=Qa(Ne),Qt=await fme({skipCount:_t,maxResultCount:De,keyword:_e||void 0,locationId:J!=="all"?J:void 0,labelCategoryId:re!=="all"?re:void 0,labelTypeId:ce!=="all"?ce:void 0,templateCode:fe!=="all"?fe:void 0,state:Z==="all"?void 0:Z==="true"},gt.signal);z(Qt.items??[]),q(Qt.totalCount??0)}catch(_t){if(_t?.name==="AbortError")return;ee.error("Failed to load labels.",{description:_t?.message?String(_t.message):"Please try again."}),z([]),q(0)}finally{H(!1)}})(),()=>ne.current?.abort()),[_e,J,re,ce,fe,Z,Ne,De,M]);const Ge=()=>Y(Ie=>Ie+1),ut=Ie=>{D(null),I(Ie),P(!0)},Ce=Ie=>{D(null),L(Ie),T(!0)};v.useEffect(()=>{if(!s)return;let Ie=!1;return(async()=>{c(!0);try{const gt=await jv({skipCount:1,maxResultCount:500});if(Ie)return;const _t=(gt.items??[]).filter(Qt=>Bi(Qt));g(_t)}catch(gt){if(Ie)return;g([]),ee.error("Failed to load templates.",{description:gt instanceof Error?gt.message:"Please try again."})}finally{Ie||c(!1)}})(),()=>{Ie=!0}},[s]),v.useEffect(()=>{if(!s||!x){j(null);return}let Ie=!1;return(async()=>{h(!0);try{const gt=await nu(x);if(Ie)return;j(N6(gt))}catch(gt){if(Ie)return;j(null),ee.error("Failed to load template preview.",{description:gt instanceof Error?gt.message:"Please try again."})}finally{Ie||h(!1)}})(),()=>{Ie=!0}},[s,x]);const tt=v.useMemo(()=>p.map(Ie=>({value:Bi(Ie),label:ly(Ie)})),[p]),ot=()=>{if(!x.trim()){ee.error("Template required",{description:"Please select a template first."});return}const Ie=p.find(_t=>Bi(_t)===x),gt=Ie?ly(Ie):x;i(`Bulk Add template: ${gt}`),n(x),l(!1)},Nt=Ie=>{l(Ie),Ie||(b(""),j(null))},er=()=>{n(null),i(void 0),Ge()};return r?o.jsx("div",{className:"h-[calc(100vh-8rem)] min-h-[500px] flex flex-col pt-2",children:o.jsx(Lpe,{templateCode:r,onBack:er,contextHint:a})}):o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:$,onChange:Ie=>K(Ie.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:J,onValueChange:oe,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsx(ze,{children:o.jsx(we,{value:"all",children:"All Locations"})})]}),o.jsxs($e,{value:re,onValueChange:Q,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Category"})}),o.jsx(ze,{children:o.jsx(we,{value:"all",children:"All Categories"})})]}),o.jsxs($e,{value:ce,onValueChange:se,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Type"})}),o.jsx(ze,{children:o.jsx(we,{value:"all",children:"All Types"})})]}),o.jsxs($e,{value:Z,onValueChange:Se,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All States"}),o.jsx(we,{value:"true",children:"Active"}),o.jsx(we,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsx(de,{variant:"outline",className:"h-10 px-6 shrink-0 font-semibold border",style:{backgroundColor:"#16a34a",color:"#ffffff",borderColor:"#16a34a"},onClick:()=>l(!0),children:"Bulk Add"}),o.jsxs(de,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>C(!0),children:["New Label ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Label Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[140px]",children:"Label Name"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Location"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[140px]",children:"Category"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[140px]",children:"Type"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Template"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Products"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:G?o.jsx(nt,{children:o.jsx(xe,{colSpan:9,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):V.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:9,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):V.map(Ie=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"font-medium whitespace-nowrap",children:qge(Ie)}),o.jsx(xe,{className:"whitespace-nowrap",children:Ea(Ie.labelName)}),o.jsx(xe,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ie.locationName??Ie.locationId)}),o.jsx(xe,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ie.labelCategoryName??Ie.labelCategoryId)}),o.jsx(xe,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ie.labelTypeName??Ie.labelTypeId)}),o.jsx(xe,{className:"text-gray-600 whitespace-nowrap",children:Ea(Ie.templateName??Ie.templateCode)}),o.jsx(xe,{className:"text-gray-600 whitespace-nowrap",children:Vge(Ie)}),o.jsx(xe,{children:o.jsx(fn,{className:Ie.state===!0?"bg-green-600":"bg-gray-400",children:Ie.state===!0?"Active":"Inactive"})}),o.jsx(xe,{className:"text-center",children:o.jsxs(ka,{open:F===Ie.id,onOpenChange:gt=>D(gt?Ie.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-48 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>ut(Ie),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Ce(Ie),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},Ie.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",W===0?0:(Ne-1)*De+1,"-",Math.min(Ne*De,W)," of ",W]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(De),onValueChange:Ie=>He(Number(Ie)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(Ie=>o.jsxs(we,{value:String(Ie),children:[Ie," / page"]},Ie))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:Ie=>{Ie.preventDefault(),qe(gt=>Math.max(1,gt-1))},"aria-disabled":Ne<=1,className:Ne<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:Ie=>Ie.preventDefault(),children:["Page ",Ne," / ",Ae]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:Ie=>{Ie.preventDefault(),qe(gt=>Math.min(Ae,gt+1))},"aria-disabled":Ne>=Ae,className:Ne>=Ae?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(Kge,{open:N,onOpenChange:C,onCreated:()=>{qe(1),Ge()}}),o.jsx(Xge,{open:O,label:A,onOpenChange:Ie=>{P(Ie),Ie||I(null)},onUpdated:Ge}),o.jsx(Jge,{open:E,label:R,onOpenChange:Ie=>{T(Ie),Ie||L(null)},onDeleted:Ge}),o.jsx(kt,{open:s,onOpenChange:Nt,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsx(At,{children:o.jsx(It,{children:"Select a Template to Bulk Add"})}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 py-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Template"}),o.jsx($n,{value:x,onValueChange:b,options:tt,placeholder:d?"Loading templates…":"Select template",searchPlaceholder:"Search template…",emptyText:"No templates found.",disabled:d})]}),o.jsx("div",{className:"rounded-xl border border-gray-200 bg-gray-50 p-4 flex items-center justify-center min-h-[320px]",children:f?o.jsx("div",{className:"text-sm text-gray-500",children:"Loading preview…"}):w?o.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-auto",children:o.jsx(iE,{template:w,maxWidth:360})}):o.jsx("div",{className:"text-sm text-gray-500",children:"Select a template to preview."})})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>Nt(!1),children:"Cancel"}),o.jsx(de,{variant:"outline",className:"min-w-24 font-semibold border",style:{backgroundColor:"#16a34a",color:"#ffffff",borderColor:"#16a34a"},disabled:!x.trim()||f,onClick:ot,children:"Bulk Add"})]})]})})]})}function Kge({open:e,onOpenChange:t,onCreated:r}){const{loading:n,templates:a,locations:i,categories:s,types:l,products:d,productCategories:c}=C6(e),[f,h]=v.useState(""),[p,g]=v.useState(!1),[x,b]=v.useState(!1),[w,j]=v.useState(null),[N,C]=v.useState({}),[O,P]=v.useState({}),[E,T]=v.useState({}),[A,I]=v.useState({labelCode:"",labelName:"",templateCode:"",locationId:"",labelCategoryId:"",labelTypeId:"",productIds:[],labelInfoJson:null,state:!0}),R=()=>{I({labelCode:"",labelName:"",templateCode:"",locationId:"",labelCategoryId:"",labelTypeId:"",productIds:[],labelInfoJson:null,state:!0}),j(null),C({}),P({}),T({}),h("")};v.useEffect(()=>{e||R()},[e]),v.useEffect(()=>{if(!e)return;const D=A.templateCode.trim();if(!D){j(null),C({}),P({}),T({});return}let $=!1;return(async()=>{b(!0);try{const K=await nu(D);if($)return;j(K);const J=Up(K),oe={},re={};for(const se of J)oe[se.id]="",ru(se)&&(re[se.id]={unit:"Days",value:""});C(oe),P(re);const Q=wc(K.elements??[]),ce={};for(const se of Q)ce[se.id]=_pe(se);T(ce)}catch(K){if($)return;j(null),C({}),P({}),T({}),ee.error("Failed to load template fields.",{description:K?.message?String(K.message):"Please select another template."})}finally{$||b(!1)}})(),()=>{$=!0}},[e,A.templateCode]);const L=async()=>{if(!A.labelName.trim()||!A.templateCode.trim()||!A.locationId.trim()||!A.labelCategoryId.trim()||!A.labelTypeId.trim()){ee.error("Validation failed",{description:"Fill all required fields and select template, location, category, and type."});return}if(!f.trim()||A.productIds.length===0){ee.error("Validation failed",{description:"Select a product category and one product."});return}const D=async()=>{const $=A.templateCode.trim();if(!$||!w)return;const K=A.labelTypeId.trim();if(!K)return;const J=await nu($),oe=Up(J),re=wc(J.elements??[]).length>0;if(oe.length===0&&!re)return;const Q=Hge(J,N,O,E),ce=Gge(J);for(const be of A.productIds){const Z=`${be}::${K}`;ce.set(Z,{productId:be,labelTypeId:K,defaultValues:{...Q},orderNum:ce.size+1})}const se=Array.from(ce.values()).map((be,Z)=>({...be,orderNum:Z+1})),fe=oy(J.elements??[]);await aE($,{id:J.id,name:(J.name??J.templateName??"").trim()||J.id,labelType:J.labelType??"PRICE",unit:J.unit??"inch",width:Number(J.width??2),height:Number(J.height??2),appliedLocation:eu(J),showRuler:J.showRuler??!0,showGrid:J.showGrid??!0,state:J.state??!0,elements:tE(fe),appliedLocationIds:eu(J)==="ALL"?[]:J.appliedLocationIds??[],templateProductDefaults:se})};g(!0);try{await mme(A);try{await D()}catch($){ee.warning("Label created, template data failed.",{description:$?.message?String($.message):"Please edit template data manually."})}ee.success("Label created.",{description:"The label has been created successfully."}),t(!1),r()}catch($){ee.error("Failed to create label.",{description:$?.message?String($.message):"Please try again."})}finally{g(!1)}},V=v.useMemo(()=>a.filter(D=>Bi(D)).map(D=>({value:Bi(D),label:ly(D)})),[a]),z=v.useMemo(()=>i.map(D=>({value:D.id,label:Ea(D.locationName??D.locationCode??D.id)})),[i]),G=v.useMemo(()=>s.map(D=>({value:D.id,label:Ea(D.categoryName??D.categoryCode??D.id)})),[s]),H=v.useMemo(()=>l.map(D=>({value:D.id,label:Ea(D.typeName??D.typeCode??D.id)})),[l]),W=v.useMemo(()=>Up(w),[w]),q=v.useMemo(()=>{if(!w)return[];const D=[];for(const $ of wc(w.elements??[]))for(const K of Eu($))D.push({el:$,spec:K});return D},[w]),M=W.length>0||q.length>0,Y=v.useMemo(()=>Wge(w,N,O,E),[w,N,O,E]),F=A.templateCode.trim().length>0;return o.jsx(kt,{open:e,onOpenChange:t,children:o.jsxs(Ot,{className:"flex max-h-[calc(100dvh-2rem)] flex-col overflow-hidden max-w-none gap-4 !top-5 !translate-y-0",style:{width:F?"calc(100vw - 3rem)":"min(96vw, 780px)",maxWidth:F?"calc(100vw - 3rem)":"min(96vw, 780px)"},children:[o.jsxs(At,{className:"shrink-0",children:[o.jsx(It,{children:"Add New Label"}),o.jsx(qt,{children:"Enter the details for the new label."})]}),o.jsx("div",{className:F?"min-h-0 flex-none overflow-hidden py-2":"min-h-0 flex-1 overflow-hidden py-2",style:F?{height:"min(72vh, calc(100dvh - 10.5rem))",maxHeight:"min(72vh, calc(100dvh - 10.5rem))"}:void 0,children:o.jsxs("div",{className:"grid h-full min-h-0 min-w-0 gap-3 items-stretch",style:F?M?{gridTemplateColumns:"minmax(0, 1fr) minmax(0, 12.5rem) minmax(0, 1.55fr)",gridTemplateRows:"minmax(0, 1fr)"}:{gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1.55fr)",gridTemplateRows:"minmax(0, 1fr)"}:{gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:"minmax(0, 1fr)"},children:[o.jsxs("div",{className:"min-h-0 min-w-0 w-full overflow-y-auto overflow-x-hidden overscroll-contain rounded-lg border bg-gray-50 p-4 [scrollbar-gutter:stable]",children:[o.jsx("div",{className:"text-sm font-semibold text-gray-900",children:"General Settings"}),o.jsx("div",{className:"space-y-2 mt-3 mb-2",children:o.jsx(_6,{productCatalogCategoryId:f,onProductCatalogCategoryIdChange:h,productId:A.productIds[0]??"",onProductIdChange:D=>I($=>({...$,productIds:D.trim()?[D.trim()]:[]})),products:d,productCategories:c,disabled:n})}),o.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Code"}),o.jsx(me,{className:"h-10",placeholder:"e.g. LBL_TEST_001",value:A.labelCode??"",onChange:D=>I($=>({...$,labelCode:D.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Name *"}),o.jsx(me,{className:"h-10",placeholder:"e.g. Breakfast label",value:A.labelName,onChange:D=>I($=>({...$,labelName:D.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Template *"}),o.jsx($n,{value:A.templateCode,onValueChange:D=>I($=>({...$,templateCode:D})),options:V,placeholder:"Select template",searchPlaceholder:"Search template…",emptyText:"No templates found.",disabled:n})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Location *"}),o.jsx($n,{value:A.locationId,onValueChange:D=>I($=>({...$,locationId:D})),options:z,placeholder:"Select location",searchPlaceholder:"Search location…",emptyText:"No locations found.",disabled:n})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Category *"}),o.jsx($n,{value:A.labelCategoryId,onValueChange:D=>I($=>({...$,labelCategoryId:D})),options:G,placeholder:"Select category",searchPlaceholder:"Search category…",emptyText:"No categories found.",disabled:n})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Type *"}),o.jsx($n,{value:A.labelTypeId,onValueChange:D=>I($=>({...$,labelTypeId:D})),options:H,placeholder:"Select type",searchPlaceholder:"Search type…",emptyText:"No types found.",disabled:n})]})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white mt-4",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:A.state,onCheckedChange:D=>I($=>({...$,state:D}))})]})]}),F&&M?o.jsxs("div",{className:"box-border min-h-0 min-w-0 w-full max-w-full overflow-y-auto overflow-x-hidden overscroll-contain rounded-lg border bg-gray-50 p-4 [scrollbar-gutter:stable]",children:[o.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Template Input Data"}),x?o.jsx("div",{className:"text-sm text-gray-500",children:"Loading template fields..."}):A.templateCode.trim()?o.jsxs("div",{className:"space-y-3",children:[W.map(D=>o.jsxs("div",{className:"space-y-1.5 w-full min-w-0",children:[o.jsx(ue,{className:"block",children:GN(D)}),ru(D)?o.jsxs("div",{className:"flex flex-wrap items-center gap-2 w-full min-w-0",children:[o.jsxs($e,{value:O[D.id]?.unit??"Days",onValueChange:$=>P(K=>({...K,[D.id]:{unit:$,value:K[D.id]?.value??""}})),children:[o.jsx(Be,{className:"h-10 min-w-0 flex-1 bg-white text-sm",children:o.jsx(Fe,{})}),o.jsx(ze,{children:oE.map($=>o.jsx(we,{value:$,className:"text-xs",children:$},$))})]}),o.jsx(me,{type:"number",className:"h-10 w-20 shrink-0 bg-white",value:O[D.id]?.value??"",onChange:$=>P(K=>({...K,[D.id]:{unit:K[D.id]?.unit??"Days",value:$.target.value}})),placeholder:"Value"})]}):o.jsx(me,{className:"h-10 w-full min-w-0 box-border",value:N[D.id]??"",onChange:$=>C(K=>({...K,[D.id]:$.target.value})),placeholder:`Enter ${GN(D)}`})]},D.id)),q.length>0?o.jsxs("div",{className:"pt-2 mt-2 border-t border-gray-200 space-y-3",children:[o.jsx("div",{className:"text-xs font-semibold text-gray-700",children:"Nutrition Facts (manual)"}),q.map(({el:D,spec:$})=>o.jsxs("div",{className:"space-y-1.5 w-full min-w-0",children:[o.jsx(ue,{className:"block",children:$.columnLabel}),o.jsx(me,{className:"h-10 w-full min-w-0 box-border",value:E[D.id]?.[$.subKey]??"",onChange:K=>T(J=>({...J,[D.id]:{...J[D.id]??{},[$.subKey]:K.target.value}})),placeholder:`Enter ${$.columnLabel}`})]},`${D.id}-${$.subKey}`))]}):null,o.jsx("div",{className:"text-xs text-gray-500 pt-1 w-full min-w-0 break-words",children:`Date/time fields: preview uses the current time as base; leave empty or enter 0 for "now"; other numbers add that offset. Format follows each field's template setting. On save, values are written for the selected product. Nutrition columns follow the template's nutrient list; values are saved with the template defaults JSON for printing.`})]}):o.jsx("div",{className:"text-sm text-gray-500",children:"Select template first to load input fields."})]}):null,F?o.jsxs("div",{className:"min-h-0 min-w-0 w-full overflow-y-auto overflow-x-hidden overscroll-contain rounded-lg border bg-gray-50 p-4 [scrollbar-gutter:stable]",children:[o.jsx("div",{className:"text-sm font-semibold text-gray-900 mb-3",children:"Label Preview"}),Y?o.jsx("div",{className:"flex justify-center w-full min-w-0 overflow-hidden",children:o.jsx(iE,{template:Y,maxWidth:480})}):o.jsx("div",{className:"text-sm text-gray-500",children:"Select template to preview."})]}):null]})}),o.jsxs(Dt,{className:"shrink-0",children:[o.jsx(de,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(de,{disabled:p||n,onClick:L,children:p?"Creating…":"Create"})]})]})})}function Xge({open:e,label:t,onOpenChange:r,onUpdated:n}){const{loading:a,templates:i,locations:s,categories:l,types:d,products:c,productCategories:f}=C6(e),[h,p]=v.useState(""),[g,x]=v.useState(!1),[b,w]=v.useState(!1),[j,N]=v.useState({labelName:"",templateCode:"",locationId:"",labelCategoryId:"",labelTypeId:"",productIds:[],labelInfoJson:null,state:!0});v.useEffect(()=>{if(!e||!t?.id)return;const A=t.id;N(YL(t));const I=new AbortController;let R=!1;return w(!0),(async()=>{try{const L=await hme(A,I.signal);if(R)return;N(YL(L))}catch(L){if(R||L?.name==="AbortError")return;ee.error("Failed to load label details.",{description:L?.message?String(L.message):"Form shows list data only; check network."})}finally{R||w(!1)}})(),()=>{R=!0,I.abort()}},[e,t]),v.useEffect(()=>{if(!e){p("");return}const A=(j.productIds[0]??"").trim();if(!A){p("");return}const I=c.find(L=>L.id===A);if(I?.categoryId){p(String(I.categoryId).trim());return}let R=!1;return(async()=>{try{const L=await G8(A);if(R)return;p((L.categoryId??"").trim())}catch{R||p("")}})(),()=>{R=!0}},[e,j.productIds,c]);const C=async()=>{if(t?.id){if(!j.labelName.trim()||!j.templateCode.trim()||!j.locationId.trim()||!j.labelCategoryId.trim()||!j.labelTypeId.trim()){ee.error("Validation failed",{description:"Fill all required fields and select template, location, category, and type."});return}if(!h.trim()||j.productIds.length===0){ee.error("Validation failed",{description:"Select a product category and one product."});return}x(!0);try{await pme(t.id,j),ee.success("Label updated.",{description:"The label has been updated successfully."}),r(!1),n()}catch(A){ee.error("Failed to update label.",{description:A?.message?String(A.message):"Please try again."})}finally{x(!1)}}},O=v.useMemo(()=>{const A=i.filter(R=>Bi(R)).map(R=>({value:Bi(R),label:ly(R)})),I=j.templateCode;return I&&!A.some(R=>R.value===I)?[{value:I,label:`${I} (current)`},...A]:A},[i,j.templateCode]),P=v.useMemo(()=>{const A=s.map(R=>({value:R.id,label:Ea(R.locationName??R.locationCode??R.id)})),I=j.locationId;return I&&!A.some(R=>R.value===I)?[{value:I,label:`${I} (current)`},...A]:A},[s,j.locationId]),E=v.useMemo(()=>{const A=l.map(R=>({value:R.id,label:Ea(R.categoryName??R.categoryCode??R.id)})),I=j.labelCategoryId;return I&&!A.some(R=>R.value===I)?[{value:I,label:`${I} (current)`},...A]:A},[l,j.labelCategoryId]),T=v.useMemo(()=>{const A=d.map(R=>({value:R.id,label:Ea(R.typeName??R.typeCode??R.id)})),I=j.labelTypeId;return I&&!A.some(R=>R.value===I)?[{value:I,label:`${I} (current)`},...A]:A},[d,j.labelTypeId]);return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Edit Label"}),o.jsx(qt,{children:b?"Loading label details…":"Update the label details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Name *"}),o.jsx(me,{className:"h-10",placeholder:"e.g. Breakfast label",value:j.labelName,onChange:A=>N(I=>({...I,labelName:A.target.value})),disabled:b})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Template *"}),o.jsx($n,{value:j.templateCode,onValueChange:A=>N(I=>({...I,templateCode:A})),options:O,placeholder:"Select template",searchPlaceholder:"Search template…",emptyText:"No templates found.",disabled:a||b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Location *"}),o.jsx($n,{value:j.locationId,onValueChange:A=>N(I=>({...I,locationId:A})),options:P,placeholder:"Select location",searchPlaceholder:"Search location…",emptyText:"No locations found.",disabled:a||b})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Category *"}),o.jsx($n,{value:j.labelCategoryId,onValueChange:A=>N(I=>({...I,labelCategoryId:A})),options:E,placeholder:"Select category",searchPlaceholder:"Search category…",emptyText:"No categories found.",disabled:a||b})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Label Type *"}),o.jsx($n,{value:j.labelTypeId,onValueChange:A=>N(I=>({...I,labelTypeId:A})),options:T,placeholder:"Select type",searchPlaceholder:"Search type…",emptyText:"No types found.",disabled:a||b})]})]}),o.jsx("div",{className:"space-y-2",children:o.jsx(_6,{productCatalogCategoryId:h,onProductCatalogCategoryIdChange:p,productId:j.productIds[0]??"",onProductIdChange:A=>N(I=>({...I,productIds:A.trim()?[A.trim()]:[]})),products:c,productCategories:f,disabled:a||b})}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:j.state,onCheckedChange:A=>N(I=>({...I,state:A})),disabled:b})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:g||a||b,onClick:C,children:g?"Updating…":"Update"})]})]})})}function Jge({open:e,label:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>(t?.labelName??"").trim()||t?.labelCode||t?.id||"this label",[t]),l=async()=>{if(t?.id){i(!0);try{await gme(t.id),ee.success("Label deleted.",{description:"The label has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Label"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}var KS="rovingFocusGroup.onEntryFocus",Qge={bubbles:!1,cancelable:!0},sh="RovingFocusGroup",[JN,E6,Zge]=AF(sh),[eye,P6]=Eo(sh,[Zge]),[tye,rye]=eye(sh),O6=v.forwardRef((e,t)=>o.jsx(JN.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(JN.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(nye,{...e,ref:t})})}));O6.displayName=sh;var nye=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:a=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:d,onEntryFocus:c,preventScrollOnEntryFocus:f=!1,...h}=e,p=v.useRef(null),g=Tt(t,p),x=my(i),[b,w]=No({prop:s,defaultProp:l??null,onChange:d,caller:sh}),[j,N]=v.useState(!1),C=dn(c),O=E6(r),P=v.useRef(!1),[E,T]=v.useState(0);return v.useEffect(()=>{const A=p.current;if(A)return A.addEventListener(KS,C),()=>A.removeEventListener(KS,C)},[C]),o.jsx(tye,{scope:r,orientation:n,dir:x,loop:a,currentTabStopId:b,onItemFocus:v.useCallback(A=>w(A),[w]),onItemShiftTab:v.useCallback(()=>N(!0),[]),onFocusableItemAdd:v.useCallback(()=>T(A=>A+1),[]),onFocusableItemRemove:v.useCallback(()=>T(A=>A-1),[]),children:o.jsx(ct.div,{tabIndex:j||E===0?-1:0,"data-orientation":n,...h,ref:g,style:{outline:"none",...e.style},onMouseDown:pt(e.onMouseDown,()=>{P.current=!0}),onFocus:pt(e.onFocus,A=>{const I=!P.current;if(A.target===A.currentTarget&&I&&!j){const R=new CustomEvent(KS,Qge);if(A.currentTarget.dispatchEvent(R),!R.defaultPrevented){const L=O().filter(W=>W.focusable),V=L.find(W=>W.active),z=L.find(W=>W.id===b),H=[V,z,...L].filter(Boolean).map(W=>W.ref.current);A6(H,f)}}P.current=!1}),onBlur:pt(e.onBlur,()=>N(!1))})})}),T6="RovingFocusGroupItem",k6=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:i,children:s,...l}=e,d=Bn(),c=i||d,f=rye(T6,r),h=f.currentTabStopId===c,p=E6(r),{onFocusableItemAdd:g,onFocusableItemRemove:x,currentTabStopId:b}=f;return v.useEffect(()=>{if(n)return g(),()=>x()},[n,g,x]),o.jsx(JN.ItemSlot,{scope:r,id:c,focusable:n,active:a,children:o.jsx(ct.span,{tabIndex:h?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:pt(e.onMouseDown,w=>{n?f.onItemFocus(c):w.preventDefault()}),onFocus:pt(e.onFocus,()=>f.onItemFocus(c)),onKeyDown:pt(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const j=iye(w,f.orientation,f.dir);if(j!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let C=p().filter(O=>O.focusable).map(O=>O.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const O=C.indexOf(w.currentTarget);C=f.loop?sye(C,O+1):C.slice(O+1)}setTimeout(()=>A6(C))}}),children:typeof s=="function"?s({isCurrentTabStop:h,hasTabStop:b!=null}):s})})});k6.displayName=T6;var aye={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function oye(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function iye(e,t,r){const n=oye(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return aye[n]}function A6(e,t=!1){const r=document.activeElement;for(const n of e)if(n===r||(n.focus({preventScroll:t}),document.activeElement!==r))return}function sye(e,t){return e.map((r,n)=>e[(t+n)%e.length])}var lye=O6,cye=k6,I6="Toggle",M6=v.forwardRef((e,t)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...i}=e,[s,l]=No({prop:r,onChange:a,defaultProp:n??!1,caller:I6});return o.jsx(ct.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...i,ref:t,onClick:pt(e.onClick,()=>{e.disabled||l(!s)})})});M6.displayName=I6;var Zi="ToggleGroup",[R6]=Eo(Zi,[P6]),D6=P6(),sE=U.forwardRef((e,t)=>{const{type:r,...n}=e;if(r==="single"){const a=n;return o.jsx(uye,{...a,ref:t})}if(r==="multiple"){const a=n;return o.jsx(dye,{...a,ref:t})}throw new Error(`Missing prop \`type\` expected on \`${Zi}\``)});sE.displayName=Zi;var[L6,$6]=R6(Zi),uye=U.forwardRef((e,t)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...i}=e,[s,l]=No({prop:r,defaultProp:n??"",onChange:a,caller:Zi});return o.jsx(L6,{scope:e.__scopeToggleGroup,type:"single",value:U.useMemo(()=>s?[s]:[],[s]),onItemActivate:l,onItemDeactivate:U.useCallback(()=>l(""),[l]),children:o.jsx(F6,{...i,ref:t})})}),dye=U.forwardRef((e,t)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...i}=e,[s,l]=No({prop:r,defaultProp:n??[],onChange:a,caller:Zi}),d=U.useCallback(f=>l((h=[])=>[...h,f]),[l]),c=U.useCallback(f=>l((h=[])=>h.filter(p=>p!==f)),[l]);return o.jsx(L6,{scope:e.__scopeToggleGroup,type:"multiple",value:s,onItemActivate:d,onItemDeactivate:c,children:o.jsx(F6,{...i,ref:t})})});sE.displayName=Zi;var[fye,hye]=R6(Zi),F6=U.forwardRef((e,t)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:i,dir:s,loop:l=!0,...d}=e,c=D6(r),f=my(s),h={role:"group",dir:f,...d};return o.jsx(fye,{scope:r,rovingFocus:a,disabled:n,children:a?o.jsx(lye,{asChild:!0,...c,orientation:i,dir:f,loop:l,children:o.jsx(ct.div,{...h,ref:t})}):o.jsx(ct.div,{...h,ref:t})})}),cy="ToggleGroupItem",B6=U.forwardRef((e,t)=>{const r=$6(cy,e.__scopeToggleGroup),n=hye(cy,e.__scopeToggleGroup),a=D6(e.__scopeToggleGroup),i=r.value.includes(e.value),s=n.disabled||e.disabled,l={...e,pressed:i,disabled:s},d=U.useRef(null);return n.rovingFocus?o.jsx(cye,{asChild:!0,...a,focusable:!s,active:i,ref:d,children:o.jsx(KL,{...l,ref:t})}):o.jsx(KL,{...l,ref:t})});B6.displayName=cy;var KL=U.forwardRef((e,t)=>{const{__scopeToggleGroup:r,value:n,...a}=e,i=$6(cy,r),s={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},l=i.type==="single"?s:void 0;return o.jsx(M6,{...l,...a,ref:t,onPressedChange:d=>{d?i.onItemActivate(n):i.onItemDeactivate(n)}})}),mye=sE,pye=B6;const gye=pC("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}}),z6=v.createContext({size:"default",variant:"default"});function ou({className:e,variant:t,size:r,children:n,...a}){return o.jsx(mye,{"data-slot":"toggle-group","data-variant":t,"data-size":r,className:ke("group/toggle-group flex w-fit items-center rounded-md data-[variant=outline]:shadow-xs",e),...a,children:o.jsx(z6.Provider,{value:{variant:t,size:r},children:n})})}function ri({className:e,children:t,variant:r,size:n,...a}){const i=v.useContext(z6);return o.jsx(pye,{"data-slot":"toggle-group-item","data-variant":i.variant||r,"data-size":i.size||n,className:ke(gye({variant:i.variant||r,size:i.size||n}),"min-w-0 flex-1 shrink-0 rounded-none shadow-none first:rounded-l-md last:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first:border-l",e),...a,children:t})}function XL(e){const t=(e??"").trim();return t||"None"}const U6=["#111827","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899"];function yye(e){const t=I8({buttonStyleJson:e.buttonStyleJson??e.ButtonStyleJson,buttonAppearance:e.buttonAppearance??e.ButtonAppearance,displayText:e.displayText,buttonBgColor:e.buttonBgColor,buttonImageUrl:e.buttonImageUrl,categoryPhotoUrl:e.categoryPhotoUrl,categoryName:e.categoryName}),r="w-10 h-10 rounded border border-gray-200 shadow-sm overflow-hidden";if(t.mode==="image"){const n=t.imageUrl?Tf(t.imageUrl):"";return n?o.jsx("img",{src:n,alt:"",className:[r,"object-cover"].join(" ")}):o.jsx("span",{className:"text-gray-400 text-sm",children:"—"})}return t.mode==="colorText"?o.jsx("div",{className:[r,"flex items-center justify-center px-1"].join(" "),style:{backgroundColor:t.bg,color:t.textColor||"#ffffff"},title:t.text,children:o.jsx("span",{className:"text-[11px] font-semibold truncate w-full text-center leading-tight line-clamp-2 break-all",children:t.text})}):t.mode==="color"?o.jsx("div",{className:r,style:{backgroundColor:t.bg},title:t.bg}):t.mode==="text"?o.jsx("div",{className:[r,"bg-gray-50 flex items-center justify-center px-1"].join(" "),title:t.text,children:o.jsx("span",{className:"text-[11px] font-semibold text-gray-800 truncate w-full text-center leading-tight line-clamp-2 break-all",children:t.text})}):o.jsx("span",{className:"text-gray-400 text-sm",children:"—"})}function vye(){const[e,t]=v.useState(!1),[r,n]=v.useState(!1),[a,i]=v.useState(!1),[s,l]=v.useState(null),[d,c]=v.useState(null),[f,h]=v.useState([]),[p,g]=v.useState(!1),[x,b]=v.useState(0),[w,j]=v.useState(0),[N,C]=v.useState(null),[O,P]=v.useState(""),[E,T]=v.useState("all"),[A,I]=v.useState(1),[R,L]=v.useState(10),V=v.useRef(null),z=v.useRef(null),[G,H]=v.useState("");v.useEffect(()=>(z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>H(O.trim()),300),()=>{z.current&&window.clearTimeout(z.current)}),[O]);const W=Math.max(1,Math.ceil(x/R));v.useEffect(()=>{I(1)},[G,E,R]),v.useEffect(()=>((async()=>{V.current?.abort();const D=new AbortController;V.current=D,g(!0);try{const $=Qa(A),K=await M8({skipCount:$,maxResultCount:R,keyword:G||void 0,state:E==="all"?void 0:E==="true"},D.signal);h(K.items??[]),b(K.totalCount??0)}catch($){if($?.name==="AbortError")return;ee.error("Failed to load label categories.",{description:$?.message?String($.message):"Please try again."}),h([]),b(0)}finally{g(!1)}})(),()=>V.current?.abort()),[G,E,A,R,w]);const q=()=>j(F=>F+1),M=F=>{C(null),l(F),n(!0)},Y=F=>{C(null),c(F),i(!0)};return o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:O,onChange:F=>P(F.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:E,onValueChange:T,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All States"}),o.jsx(we,{value:"true",children:"Active"}),o.jsx(we,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(de,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>t(!0),children:["New Label Category ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[250px]",children:"Label Category"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Category Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Category Photo"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Order"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:p?o.jsx(nt,{children:o.jsx(xe,{colSpan:6,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):f.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:6,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):f.map(F=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"font-medium",children:XL(F.categoryName)}),o.jsx(xe,{className:"text-gray-600",children:XL(F.categoryCode)}),o.jsx(xe,{children:yye(F)}),o.jsx(xe,{children:o.jsx(fn,{className:F.state?"bg-green-600":"bg-gray-400",children:F.state?"Active":"Inactive"})}),o.jsx(xe,{className:"font-numeric",children:F.orderNum??"None"}),o.jsx(xe,{className:"text-center",children:o.jsxs(ka,{open:N===F.id,onOpenChange:D=>C(D?F.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>M(F),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Y(F),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},F.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",x===0?0:(A-1)*R+1,"-",Math.min(A*R,x)," of ",x]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(R),onValueChange:F=>L(Number(F)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(F=>o.jsxs(we,{value:String(F),children:[F," / page"]},F))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:F=>{F.preventDefault(),I(D=>Math.max(1,D-1))},"aria-disabled":A<=1,className:A<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:F=>F.preventDefault(),children:["Page ",A," / ",W]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:F=>{F.preventDefault(),I(D=>Math.min(W,D+1))},"aria-disabled":A>=W,className:A>=W?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(xye,{open:e,onOpenChange:t,onCreated:()=>{I(1),q()}}),o.jsx(bye,{open:r,category:s,onOpenChange:F=>{n(F),F||l(null)},onUpdated:q}),o.jsx(wye,{open:a,category:d,onOpenChange:F=>{i(F),F||c(null)},onDeleted:q})]})}function xye({open:e,onOpenChange:t,onCreated:r}){const[n,a]=v.useState(!1),[i,s]=v.useState({text:!0,color:!1,image:!1}),[l,d]=v.useState(""),[c,f]=v.useState("#3B82F6"),[h,p]=v.useState({categoryCode:"",categoryName:"",categoryPhotoUrl:null,state:!0,orderNum:null}),g=v.useMemo(()=>{const w=[];return i.text&&w.push("TEXT"),i.color&&w.push("COLOR"),w},[i.text,i.color]),x=()=>{s({text:!0,color:!1,image:!1}),d(""),f("#3B82F6"),p({categoryCode:"",categoryName:"",categoryPhotoUrl:null,state:!0,orderNum:null})};v.useEffect(()=>{e||x()},[e]);const b=async()=>{if(!h.categoryName.trim()){ee.error("Validation failed",{description:"Category Name is required."});return}if(h.orderNum===null||h.orderNum===void 0||!Number.isFinite(h.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}const w=W_(i);if(w.length===0){ee.error("Validation failed",{description:"Select at least one button appearance (Text, Color, or Image)."});return}if(w[0]==="IMAGE"){if(!String(h.categoryPhotoUrl??"").trim()){ee.error("Validation failed",{description:"Please upload or select an image for Image appearance."});return}}else{if(i.text&&!l.trim()){ee.error("Validation failed",{description:"Please enter display text for Text appearance."});return}if(i.color&&!c.trim()){ee.error("Validation failed",{description:"Please select a background color for Color appearance."});return}}const j=K_(w,{displayText:l.trim(),buttonBgColor:c.trim(),buttonImageUrl:i.image?String(h.categoryPhotoUrl??"").trim():""}),N=H_({appearances:w,displayText:i.image?null:l.trim()||null,buttonBgColor:i.image?null:c.trim()||null,buttonTextColor:null,buttonImageUrl:i.image&&String(h.categoryPhotoUrl??"").trim()||null});a(!0);try{await Pme({...h,categoryPhotoUrl:j,displayText:l.trim()||null,buttonBgColor:c.trim()||null,buttonImageUrl:i.image&&String(h.categoryPhotoUrl??"").trim()||null,buttonAppearance:w,buttonStyleJson:N}),ee.success("Label category created.",{description:"The label category has been created successfully."}),t(!1),r()}catch(C){ee.error("Failed to create label category.",{description:C?.message?String(C.message):"Please try again."})}finally{a(!1)}};return o.jsx(kt,{open:e,onOpenChange:t,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Add New Label Category"}),o.jsx(qt,{children:"Enter the details for the new label category."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category Code"}),o.jsx(me,{placeholder:"e.g. CAT_PREP",value:h.categoryCode,onChange:w=>p(j=>({...j,categoryCode:w.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category Name *"}),o.jsx(me,{placeholder:"e.g. Prep",value:h.categoryName,onChange:w=>p(j=>({...j,categoryName:w.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Button Appearance"}),o.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-100 p-3 space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Text & Color — can combine"}),o.jsxs(ou,{type:"multiple",value:g,onValueChange:w=>{const j=w??[];s(N=>({...N,text:j.includes("TEXT"),color:j.includes("COLOR"),image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent gap-1 flex-wrap justify-stretch",children:[o.jsx(ri,{value:"TEXT",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",i.text&&!i.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(Df,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Text"]})}),o.jsx(ri,{value:"COLOR",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",i.color&&!i.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(O$,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Color"]})})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Image — exclusive"}),o.jsx(ou,{type:"single",value:i.image?"IMAGE":"",onValueChange:w=>{const j=String(w||"").toUpperCase();s(j==="IMAGE"?{text:!1,color:!1,image:!0}:N=>({...N,image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent",children:o.jsx(ri,{value:"IMAGE",className:["w-full gap-2 h-10 rounded-full","border border-transparent",i.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(sC,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Image"]})})})]})]})]}),i.text&&!i.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Display Text"}),o.jsx(me,{placeholder:"Category Name",value:l,onChange:w=>d(w.target.value)}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"DisplayText"})," when supported."]})]}):null,i.color&&!i.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Select Color"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[U6.map(w=>o.jsx("button",{type:"button",className:["h-10 w-10 rounded-full border border-gray-200 shadow-sm",c.toLowerCase()===w.toLowerCase()?"ring-2 ring-blue-500 ring-offset-2":""].join(" "),style:{backgroundColor:w},onClick:()=>f(w),"aria-label":`Select ${w}`},w)),o.jsx("button",{type:"button",className:"h-10 w-10 rounded-full border border-dashed border-gray-300 bg-white text-gray-500 hover:text-gray-700 hover:border-gray-400 flex items-center justify-center",onClick:()=>{document.getElementById("label-category-custom-color-create")?.click()},"aria-label":"Custom color",children:"+"}),o.jsx("input",{id:"label-category-custom-color-create",type:"color",value:c||"#3B82F6",onChange:w=>f(w.target.value),className:"h-0 w-0 opacity-0 pointer-events-none","aria-label":"Custom color picker"})]}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"ButtonBgColor"})," when supported."]})]}):null,i.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category photo"}),o.jsx(_u,{value:h.categoryPhotoUrl??"",onChange:w=>p(j=>({...j,categoryPhotoUrl:w||null})),uploadSubDir:"category",oneImageOnly:!0,hint:"One image only. Replace or clear to change. JPG, PNG, WebP, or GIF — max 5 MB. Saved as CategoryPhotoUrl."})]}):null,o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:h.orderNum??"",onChange:w=>p(j=>({...j,orderNum:w.target.value?Number(w.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:h.state,onCheckedChange:w=>p(j=>({...j,state:w}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(de,{disabled:n,onClick:b,children:n?"Creating...":"Create"})]})]})})}function bye({open:e,category:t,onOpenChange:r,onUpdated:n}){const[a,i]=v.useState(!1),[s,l]=v.useState({text:!0,color:!1,image:!1}),[d,c]=v.useState(""),[f,h]=v.useState("#3B82F6"),[p,g]=v.useState({categoryCode:"",categoryName:"",categoryPhotoUrl:null,state:!0,orderNum:null}),x=v.useMemo(()=>{const w=[];return s.text&&w.push("TEXT"),s.color&&w.push("COLOR"),w},[s.text,s.color]);v.useEffect(()=>{if(e&&t){const w=ay(t.buttonStyleJson??t.ButtonStyleJson);if(w){const I=xc(w.appearances);l(I),c(w.displayText??""),h(w.buttonBgColor||"#3B82F6"),g({categoryCode:t.categoryCode??"",categoryName:t.categoryName??"",categoryPhotoUrl:I.image?t.categoryPhotoUrl??null:null,state:t.state??!0,orderNum:t.orderNum??null});return}const j=t.buttonAppearance??t.ButtonAppearance??void 0,N=tl(j),C=G_(t.categoryPhotoUrl);if(C&&N.length>0&&N.length===C.length){const I=Y_(N,C,{categoryName:t.categoryName,name:void 0,buttonTextColor:t.buttonTextColor??null}),R=xc(N);l(R),c(I.displayText??""),h(I.buttonBgColor?.trim()?I.buttonBgColor:"#3B82F6"),g({categoryCode:t.categoryCode??"",categoryName:t.categoryName??"",categoryPhotoUrl:R.image&&(I.buttonImageUrl??"").trim()||null,state:t.state??!0,orderNum:t.orderNum??null});return}let O=xc(N);if(N.length===0){const I=X_({buttonAppearance:j,displayText:t.displayText,buttonBgColor:t.buttonBgColor,buttonImageUrl:t.buttonImageUrl,categoryPhotoUrl:t.categoryPhotoUrl,categoryName:t.categoryName});I.mode==="image"?O={text:!1,color:!1,image:!0}:I.mode==="colorText"?O={text:!0,color:!0,image:!1}:I.mode==="color"?O={text:!1,color:!0,image:!1}:I.mode==="text"?O={text:!0,color:!1,image:!1}:O={text:!0,color:!1,image:!1}}l(O);const P=String(t.categoryPhotoUrl??"").trim(),E=String(t.displayText??"").trim(),T=Ls(t.buttonBgColor),A=Ls(P);c(E||(!O.image&&O.text&&P&&!A&&!Bp(P)?P:"")||(!O.image&&O.text&&!O.color?(t.categoryName??"").trim():"")),h(T||(O.color&&A?A:"")||"#3B82F6"),g({categoryCode:t.categoryCode??"",categoryName:t.categoryName??"",categoryPhotoUrl:O.image?t.categoryPhotoUrl??null:null,state:t.state??!0,orderNum:t.orderNum??null})}},[e,t]);const b=async()=>{if(!t?.id)return;if(!p.categoryName.trim()){ee.error("Validation failed",{description:"Category Name is required."});return}if(p.orderNum===null||p.orderNum===void 0||!Number.isFinite(p.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}const w=W_(s);if(w.length===0){ee.error("Validation failed",{description:"Select at least one button appearance (Text, Color, or Image)."});return}if(w[0]==="IMAGE"){if(!String(p.categoryPhotoUrl??"").trim()){ee.error("Validation failed",{description:"Please upload or select an image for Image appearance."});return}}else{if(s.text&&!d.trim()){ee.error("Validation failed",{description:"Please enter display text for Text appearance."});return}if(s.color&&!f.trim()){ee.error("Validation failed",{description:"Please select a background color for Color appearance."});return}}const j=K_(w,{displayText:d.trim(),buttonBgColor:f.trim(),buttonImageUrl:s.image?String(p.categoryPhotoUrl??"").trim():""}),N=H_({appearances:w,displayText:s.image?null:d.trim()||null,buttonBgColor:s.image?null:f.trim()||null,buttonTextColor:null,buttonImageUrl:s.image&&String(p.categoryPhotoUrl??"").trim()||null});i(!0);try{await Ome(t.id,{...p,categoryPhotoUrl:j,displayText:d.trim()||null,buttonBgColor:f.trim()||null,buttonImageUrl:s.image&&String(p.categoryPhotoUrl??"").trim()||null,buttonAppearance:w,buttonStyleJson:N}),ee.success("Label category updated.",{description:"The label category has been updated successfully."}),r(!1),n()}catch(C){ee.error("Failed to update label category.",{description:C?.message?String(C.message):"Please try again."})}finally{i(!1)}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Edit Label Category"}),o.jsx(qt,{children:"Update the label category details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category Code"}),o.jsx(me,{placeholder:"e.g. CAT_PREP",value:p.categoryCode,onChange:w=>g(j=>({...j,categoryCode:w.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category Name *"}),o.jsx(me,{placeholder:"e.g. Prep",value:p.categoryName,onChange:w=>g(j=>({...j,categoryName:w.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Button Appearance"}),o.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-100 p-3 space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Text & Color — can combine"}),o.jsxs(ou,{type:"multiple",value:x,onValueChange:w=>{const j=w??[];l(N=>({...N,text:j.includes("TEXT"),color:j.includes("COLOR"),image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent gap-1 flex-wrap justify-stretch",children:[o.jsx(ri,{value:"TEXT",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",s.text&&!s.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(Df,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Text"]})}),o.jsx(ri,{value:"COLOR",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",s.color&&!s.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(O$,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Color"]})})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Image — exclusive"}),o.jsx(ou,{type:"single",value:s.image?"IMAGE":"",onValueChange:w=>{const j=String(w||"").toUpperCase();l(j==="IMAGE"?{text:!1,color:!1,image:!0}:N=>({...N,image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent",children:o.jsx(ri,{value:"IMAGE",className:["w-full gap-2 h-10 rounded-full","border border-transparent",s.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx(sC,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Image"]})})})]})]})]}),s.text&&!s.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Display Text"}),o.jsx(me,{placeholder:"Category Name",value:d,onChange:w=>c(w.target.value)}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"DisplayText"})," when supported."]})]}):null,s.color&&!s.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Select Color"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[U6.map(w=>o.jsx("button",{type:"button",className:["h-10 w-10 rounded-full border border-gray-200 shadow-sm",f.toLowerCase()===w.toLowerCase()?"ring-2 ring-blue-500 ring-offset-2":""].join(" "),style:{backgroundColor:w},onClick:()=>h(w),"aria-label":`Select ${w}`},w)),o.jsx("button",{type:"button",className:"h-10 w-10 rounded-full border border-dashed border-gray-300 bg-white text-gray-500 hover:text-gray-700 hover:border-gray-400 flex items-center justify-center",onClick:()=>{document.getElementById("label-category-custom-color-edit")?.click()},"aria-label":"Custom color",children:"+"}),o.jsx("input",{id:"label-category-custom-color-edit",type:"color",value:f||"#3B82F6",onChange:w=>h(w.target.value),className:"h-0 w-0 opacity-0 pointer-events-none","aria-label":"Custom color picker"})]}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Also stored in ",o.jsx("span",{className:"font-mono",children:"ButtonBgColor"})," when supported."]})]}):null,s.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category photo"}),o.jsx(_u,{value:p.categoryPhotoUrl??"",onChange:w=>g(j=>({...j,categoryPhotoUrl:w||null})),uploadSubDir:"category",oneImageOnly:!0,hint:"One image only. Replace or clear to change. JPG, PNG, WebP, or GIF — max 5 MB. Saved as CategoryPhotoUrl."})]}):null,o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:p.orderNum??"",onChange:w=>g(j=>({...j,orderNum:w.target.value?Number(w.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:p.state,onCheckedChange:w=>g(j=>({...j,state:w}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:a,onClick:b,children:a?"Updating...":"Update"})]})]})})}function wye({open:e,category:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>(t?.categoryName??"").trim()||t?.categoryCode||"this category",[t]),l=async()=>{if(t?.id){i(!0);try{await Tme(t.id),ee.success("Label category deleted.",{description:"The label category has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label category.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Label Category"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function JL(e){const t=(e??"").trim();return t||"None"}function Sye(){const[e,t]=v.useState(!1),[r,n]=v.useState(!1),[a,i]=v.useState(!1),[s,l]=v.useState(null),[d,c]=v.useState(null),[f,h]=v.useState([]),[p,g]=v.useState(!1),[x,b]=v.useState(0),[w,j]=v.useState(0),[N,C]=v.useState(null),[O,P]=v.useState(""),[E,T]=v.useState("all"),[A,I]=v.useState(1),[R,L]=v.useState(10),V=v.useRef(null),z=v.useRef(null),[G,H]=v.useState("");v.useEffect(()=>(z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>H(O.trim()),300),()=>{z.current&&window.clearTimeout(z.current)}),[O]);const W=Math.max(1,Math.ceil(x/R));v.useEffect(()=>{I(1)},[G,E,R]),v.useEffect(()=>((async()=>{V.current?.abort();const D=new AbortController;V.current=D,g(!0);try{const $=Qa(A),K=await J_({skipCount:$,maxResultCount:R,keyword:G||void 0,state:E==="all"?void 0:E==="true"},D.signal);h(K.items??[]),b(K.totalCount??0)}catch($){if($?.name==="AbortError")return;ee.error("Failed to load label types.",{description:$?.message?String($.message):"Please try again."}),h([]),b(0)}finally{g(!1)}})(),()=>V.current?.abort()),[G,E,A,R,w]);const q=()=>j(F=>F+1),M=F=>{C(null),l(F),n(!0)},Y=F=>{C(null),c(F),i(!0)};return o.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:O,onChange:F=>P(F.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:E,onValueChange:T,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All States"}),o.jsx(we,{value:"true",children:"Active"}),o.jsx(we,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(de,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>t(!0),children:["New Label Type ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[250px]",children:"Label Types"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Type Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Order"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:p?o.jsx(nt,{children:o.jsx(xe,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):f.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):f.map(F=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"font-medium",children:JL(F.typeName)}),o.jsx(xe,{className:"text-gray-600",children:JL(F.typeCode)}),o.jsx(xe,{children:o.jsx(fn,{className:F.state?"bg-green-600":"bg-gray-400",children:F.state?"Active":"Inactive"})}),o.jsx(xe,{className:"font-numeric",children:F.orderNum??"None"}),o.jsx(xe,{className:"text-center",children:o.jsxs(ka,{open:N===F.id,onOpenChange:D=>C(D?F.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>M(F),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Y(F),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},F.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",x===0?0:(A-1)*R+1,"-",Math.min(A*R,x)," of ",x]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(R),onValueChange:F=>L(Number(F)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(F=>o.jsxs(we,{value:String(F),children:[F," / page"]},F))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:F=>{F.preventDefault(),I(D=>Math.max(1,D-1))},"aria-disabled":A<=1,className:A<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:F=>F.preventDefault(),children:["Page ",A," / ",W]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:F=>{F.preventDefault(),I(D=>Math.min(W,D+1))},"aria-disabled":A>=W,className:A>=W?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(jye,{open:e,onOpenChange:t,onCreated:()=>{I(1),q()}}),o.jsx(Nye,{open:r,type:s,onOpenChange:F=>{n(F),F||l(null)},onUpdated:q}),o.jsx(Cye,{open:a,type:d,onOpenChange:F=>{i(F),F||c(null)},onDeleted:q})]})}function jye({open:e,onOpenChange:t,onCreated:r}){const[n,a]=v.useState(!1),[i,s]=v.useState({typeCode:"",typeName:"",state:!0,orderNum:null}),l=()=>{s({typeCode:"",typeName:"",state:!0,orderNum:null})};v.useEffect(()=>{e||l()},[e]);const d=async()=>{if(!i.typeName.trim()){ee.error("Validation failed",{description:"Type Name is required."});return}if(i.orderNum===null||i.orderNum===void 0||!Number.isFinite(i.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}a(!0);try{await kme(i),ee.success("Label type created.",{description:"The label type has been created successfully."}),t(!1),r()}catch(c){ee.error("Failed to create label type.",{description:c?.message?String(c.message):"Please try again."})}finally{a(!1)}};return o.jsx(kt,{open:e,onOpenChange:t,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Add New Label Type"}),o.jsx(qt,{children:"Enter the details for the new label type."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Type Code"}),o.jsx(me,{placeholder:"e.g. TYPE_DEFROST",value:i.typeCode,onChange:c=>s(f=>({...f,typeCode:c.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Type Name *"}),o.jsx(me,{placeholder:"e.g. Defrost",value:i.typeName,onChange:c=>s(f=>({...f,typeName:c.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:i.orderNum??"",onChange:c=>s(f=>({...f,orderNum:c.target.value?Number(c.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:i.state,onCheckedChange:c=>s(f=>({...f,state:c}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(de,{disabled:n,onClick:d,children:n?"Creating...":"Create"})]})]})})}function Nye({open:e,type:t,onOpenChange:r,onUpdated:n}){const[a,i]=v.useState(!1),[s,l]=v.useState({typeCode:"",typeName:"",state:!0,orderNum:null});v.useEffect(()=>{e&&t&&l({typeCode:t.typeCode??"",typeName:t.typeName??"",state:t.state??!0,orderNum:t.orderNum??null})},[e,t]);const d=async()=>{if(t?.id){if(!s.typeName.trim()){ee.error("Validation failed",{description:"Type Name is required."});return}if(s.orderNum===null||s.orderNum===void 0||!Number.isFinite(s.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}i(!0);try{await Ame(t.id,s),ee.success("Label type updated.",{description:"The label type has been updated successfully."}),r(!1),n()}catch(c){ee.error("Failed to update label type.",{description:c?.message?String(c.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Edit Label Type"}),o.jsx(qt,{children:"Update the label type details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Type Code"}),o.jsx(me,{placeholder:"e.g. TYPE_DEFROST",value:s.typeCode,onChange:c=>l(f=>({...f,typeCode:c.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Type Name *"}),o.jsx(me,{placeholder:"e.g. Defrost",value:s.typeName,onChange:c=>l(f=>({...f,typeName:c.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:s.orderNum??"",onChange:c=>l(f=>({...f,orderNum:c.target.value?Number(c.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:s.state,onCheckedChange:c=>l(f=>({...f,state:c}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:a,onClick:d,children:a?"Updating...":"Update"})]})]})})}function Cye({open:e,type:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>(t?.typeName??"").trim()||t?.typeCode||"this type",[t]),l=async()=>{if(t?.id){i(!0);try{await Ime(t.id),ee.success("Label type deleted.",{description:"The label type has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label type.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Label Type"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}const _ye=[{title:"Template",items:[{label:"Text",type:"TEXT_STATIC"},{label:"QR Code",type:"QRCODE"},{label:"Barcode",type:"BARCODE"},{label:"Blank Space",type:"BLANK"},{label:"Price",type:"TEXT_PRICE"},{label:"Image",type:"IMAGE"},{label:"Logo",type:"IMAGE"}]},{title:"Label",items:[{label:"Label Name",type:"TEXT_PRODUCT"},{label:"Text",type:"TEXT_STATIC"},{label:"QR Code",type:"QRCODE"},{label:"Barcode",type:"BARCODE"},{label:"Nutrition Facts",type:"NUTRITION"},{label:"Price",type:"TEXT_PRICE"},{label:"Duration Date",type:"DATE"},{label:"Duration Time",type:"TIME"},{label:"Duration",type:"DURATION"},{label:"Image",type:"IMAGE"},{label:"Label Type",type:"TEXT_STATIC"},{label:"How-to",type:"TEXT_STATIC"},{label:"Expiration Alert",type:"TEXT_STATIC"}]},{title:"Auto-generated",items:[{label:"Company",type:"TEXT_STATIC"},{label:"Employee",type:"TEXT_STATIC"},{label:"Current Date",type:"DATE"},{label:"Current Time",type:"TIME"},{label:"Label ID",type:"TEXT_STATIC"}]},{title:"Print input",subtitle:"Click to add to canvas",items:[{label:"Text",type:"TEXT_STATIC",config:{inputType:"text"}},{label:"Weight",type:"WEIGHT"},{label:"Number",type:"TEXT_STATIC",config:{inputType:"number",text:"0"}},{label:"Date & Time",type:"DATE",config:{inputType:"datetime",format:"YYYY-MM-DD HH:mm"}},{label:"Multiple Options",type:"TEXT_STATIC",config:{inputType:"options",multipleOptionId:"",selectedOptionValues:[],text:"Text",fontFamily:"Arial",fontSize:14,fontWeight:"normal",textAlign:"left"}}]}];function Eye(e){const t=e.trim().toLowerCase();return t==="template"?{backgroundColor:"#dbeafe",border:"1px solid #93c5fd",borderRadius:8,padding:8}:t==="label"?{backgroundColor:"#e0f2fe",border:"1px solid #7dd3fc",borderRadius:8,padding:8}:t==="auto-generated"?{backgroundColor:"#ede9fe",border:"1px solid #c4b5fd",borderRadius:8,padding:8}:t==="print input"?{backgroundColor:"#ffedd5",border:"1px solid #fdba74",borderRadius:8,padding:8}:{backgroundColor:"#f1f5f9",border:"1px solid #cbd5e1",borderRadius:8,padding:8}}function Pye({onAddElement:e}){return o.jsxs("div",{className:"border-r border-slate-200 bg-slate-50",children:[o.jsx("div",{className:"border-b border-slate-200 px-2 py-2 text-sm font-semibold text-slate-800",style:{backgroundColor:"#eff6ff",borderBottomColor:"#93c5fd"},children:"Elements"}),o.jsx("div",{className:"p-2 space-y-3",children:_ye.map(t=>o.jsxs("div",{style:Eye(t.title),children:[o.jsx("div",{className:"px-2 py-1 text-xs font-medium uppercase tracking-wide text-gray-600",children:t.title}),t.subtitle?o.jsx("div",{className:"px-2 py-0.5 text-[10px] text-gray-400",children:t.subtitle}):null,o.jsx("div",{className:"mt-0.5 grid grid-cols-2 gap-1",children:t.items.map((r,n)=>o.jsx("button",{type:"button",onClick:()=>e(r.type,r.config,t.title,r.label),className:"items-start justify-start whitespace-normal break-words rounded border border-transparent px-2 py-1.5 text-left text-xs leading-snug hover:border-gray-200 hover:bg-gray-100",children:r.label},`${t.title}-${r.label}-${n}`))})]},t.title))})]})}const Ov=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Tv="/label-multiple-option";function Oye(e){if(e==null)return[];if(Array.isArray(e))return e.map(t=>String(t));if(typeof e=="string"){const t=e.trim();if(!t)return[];try{const r=JSON.parse(t);return Array.isArray(r)?r.map(n=>String(n)):[]}catch{return[]}}return[]}function lE(e){return{...e,optionValuesJson:Oye(e.optionValuesJson)}}function Tye(e){return{totalCount:e.totalCount??0,items:(e.items??[]).map(lE)}}function q6(e){return JSON.stringify(e)}async function V6(e,t){const r=await Ov.requestJson({path:Tv,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t});return Tye(r)}async function kye(e){const t=await Ov.requestJson({path:Tv,method:"POST",body:{optionCode:String(e.optionCode??"").trim()||null,optionName:e.optionName,optionValuesJson:q6(e.optionValuesJson),state:e.state??!0,orderNum:e.orderNum}});return lE(t)}async function Aye(e,t){const r=await Ov.requestJson({path:`${Tv}/${encodeURIComponent(e)}`,method:"PUT",body:{optionCode:String(t.optionCode??"").trim()||null,optionName:t.optionName,optionValuesJson:q6(t.optionValuesJson),state:t.state??!0,orderNum:t.orderNum}});return lE(r)}async function Iye(e){await Ov.requestJson({path:`${Tv}/${encodeURIComponent(e)}`,method:"DELETE"})}var kv="Checkbox",[Mye]=Eo(kv),[Rye,cE]=Mye(kv);function Dye(e){const{__scopeCheckbox:t,checked:r,children:n,defaultChecked:a,disabled:i,form:s,name:l,onCheckedChange:d,required:c,value:f="on",internal_do_not_use_render:h}=e,[p,g]=No({prop:r,defaultProp:a??!1,onChange:d,caller:kv}),[x,b]=v.useState(null),[w,j]=v.useState(null),N=v.useRef(!1),C=x?!!s||!!x.closest("form"):!0,O={checked:p,disabled:i,setChecked:g,control:x,setControl:b,name:l,form:s,value:f,hasConsumerStoppedPropagationRef:N,required:c,defaultChecked:zi(a)?!1:a,isFormControl:C,bubbleInput:w,setBubbleInput:j};return o.jsx(Rye,{scope:t,...O,children:Lye(h)?h(O):n})}var W6="CheckboxTrigger",H6=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...n},a)=>{const{control:i,value:s,disabled:l,checked:d,required:c,setControl:f,setChecked:h,hasConsumerStoppedPropagationRef:p,isFormControl:g,bubbleInput:x}=cE(W6,e),b=Tt(a,f),w=v.useRef(d);return v.useEffect(()=>{const j=i?.form;if(j){const N=()=>h(w.current);return j.addEventListener("reset",N),()=>j.removeEventListener("reset",N)}},[i,h]),o.jsx(ct.button,{type:"button",role:"checkbox","aria-checked":zi(d)?"mixed":d,"aria-required":c,"data-state":Q6(d),"data-disabled":l?"":void 0,disabled:l,value:s,...n,ref:b,onKeyDown:pt(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:pt(r,j=>{h(N=>zi(N)?!0:!N),x&&g&&(p.current=j.isPropagationStopped(),p.current||j.stopPropagation())})})});H6.displayName=W6;var G6=v.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:n,checked:a,defaultChecked:i,required:s,disabled:l,value:d,onCheckedChange:c,form:f,...h}=e;return o.jsx(Dye,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:l,required:s,onCheckedChange:c,name:n,form:f,value:d,internal_do_not_use_render:({isFormControl:p})=>o.jsxs(o.Fragment,{children:[o.jsx(H6,{...h,ref:t,__scopeCheckbox:r}),p&&o.jsx(J6,{__scopeCheckbox:r})]})})});G6.displayName=kv;var Y6="CheckboxIndicator",K6=v.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:n,...a}=e,i=cE(Y6,r);return o.jsx(to,{present:n||zi(i.checked)||i.checked===!0,children:o.jsx(ct.span,{"data-state":Q6(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});K6.displayName=Y6;var X6="CheckboxBubbleInput",J6=v.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:s,required:l,disabled:d,name:c,value:f,form:h,bubbleInput:p,setBubbleInput:g}=cE(X6,e),x=Tt(r,g),b=I_(i),w=O_(n);v.useEffect(()=>{const N=p;if(!N)return;const C=window.HTMLInputElement.prototype,P=Object.getOwnPropertyDescriptor(C,"checked").set,E=!a.current;if(b!==i&&P){const T=new Event("click",{bubbles:E});N.indeterminate=zi(i),P.call(N,zi(i)?!1:i),N.dispatchEvent(T)}},[p,b,i,a]);const j=v.useRef(zi(i)?!1:i);return o.jsx(ct.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??j.current,required:l,disabled:d,name:c,value:f,form:h,...t,tabIndex:-1,ref:x,style:{...t.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});J6.displayName=X6;function Lye(e){return typeof e=="function"}function zi(e){return e==="indeterminate"}function Q6(e){return zi(e)?"indeterminate":e?"checked":"unchecked"}function Co({className:e,...t}){return o.jsx(G6,{"data-slot":"checkbox",className:ke("peer border bg-input-background dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:o.jsx(K6,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:o.jsx(E$,{className:"size-3.5"})})})}const QL=["DD/MM/YYYY","MM/DD/YYYY","DD/MM/YY","MM/DD/YY","MM/YY","MM/DD","MM","DD","YY","FULLY DAY(WEDNESDAY)","DAY (WED)","MONTH (DECEMBER)","YEAR (2025)","DD MONTH YEAR (25 DECEMBER 2025)"],ZL="YYYY-MM-DD HH:mm",$ye=["Minutes","Hours","Days","Weeks","Months (30 Day)","Years"];function Fye({template:e,selectedElement:t,onTemplateChange:r,onElementChange:n,onDeleteElement:a,readOnlyTemplateCode:i=!1}){if(t){const s=z8(t);return o.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col border-l border-gray-200 bg-white",children:[o.jsx("div",{className:"shrink-0 border-b border-gray-200 px-3 py-2 font-semibold text-gray-800",children:"Properties (Element)"}),o.jsx("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain",children:o.jsxs("div",{className:"space-y-3 p-3",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"X"}),o.jsx(me,{type:"number",value:t.x,onChange:l=>n(t.id,{x:Number(l.target.value)||0}),className:"h-8 text-sm"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Y"}),o.jsx(me,{type:"number",value:t.y,onChange:l=>n(t.id,{y:Number(l.target.value)||0}),className:"h-8 text-sm"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Width"}),o.jsx(me,{type:"number",value:t.width,onChange:l=>n(t.id,{width:Math.max(1,Number(l.target.value)||0)}),className:"h-8 text-sm"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Height"}),o.jsx(me,{type:"number",value:t.height,onChange:l=>n(t.id,{height:Math.max(1,Number(l.target.value)||0)}),className:"h-8 text-sm"})]})]}),s?null:o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Rotation"}),o.jsxs($e,{value:t.rotation,onValueChange:l=>n(t.id,{rotation:l}),children:[o.jsx(Be,{className:"h-8 text-sm",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"horizontal",children:"horizontal"}),o.jsx(we,{value:"vertical",children:"vertical"})]})]})]}),s?null:o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Border"}),o.jsxs($e,{value:t.border,onValueChange:l=>n(t.id,{border:l}),children:[o.jsx(Be,{className:"h-8 text-sm",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"none",children:"none"}),o.jsx(we,{value:"line",children:"line"}),o.jsx(we,{value:"dotted",children:"dotted"})]})]})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Element name"}),o.jsx(me,{value:(t.elementName??"").trim(),onChange:l=>n(t.id,{elementName:l.target.value}),className:"h-8 text-sm mt-1",placeholder:"e.g. text1"}),o.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Required for save; used as data-entry column header (elementName)."})]}),o.jsx(Vye,{element:t,onChange:l=>n(t.id,{config:{...t.config,...l}})}),a&&o.jsx("div",{className:"pt-4 border-t border-gray-100",children:o.jsxs(de,{variant:"destructive",className:"w-full gap-2",onClick:()=>a(t.id),children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),"Delete Element"]})})]})})]})}return o.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col border-l border-gray-200 bg-white",children:[o.jsx("div",{className:"shrink-0 border-b border-gray-200 px-3 py-2 font-semibold text-gray-800",children:"Properties (Element)"}),o.jsx("div",{className:"min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain",children:o.jsx("div",{className:"p-3",children:o.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50/50 p-3 text-xs text-blue-900",children:"Select an element on the canvas to edit its properties."})})})]})}const XS="__none__";function Bye({cfg:e,onPatch:t}){const[r,n]=v.useState([]),[a,i]=v.useState(!1);v.useEffect(()=>{let h=!1;return i(!0),V6({skipCount:1,maxResultCount:500}).then(p=>{h||n(p.items??[])}).catch(()=>{h||n([])}).finally(()=>{h||i(!1)}),()=>{h=!0}},[]);const s=(e.multipleOptionId??"").trim(),l=Array.isArray(e.selectedOptionValues)?e.selectedOptionValues:[],d=r.find(h=>h.id===s),c=d?.optionValuesJson??[];v.useEffect(()=>{if(!s||r.length===0)return;const h=r.find(x=>x.id===s),p=String(h?.optionName??"").trim();if(!h||!p)return;const g=String(e.multipleOptionName??"").trim();p!==g&&t({multipleOptionName:p})},[s,r,e.multipleOptionName,t]);const f=s||XS;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Option dictionary"}),o.jsxs($e,{value:f,onValueChange:h=>{if(h===XS){t({multipleOptionId:"",multipleOptionName:"",selectedOptionValues:[]});return}const p=r.find(w=>w.id===h),g=new Set(p?.optionValuesJson??[]),x=l.filter(w=>g.has(w)),b=String(p?.optionName??p?.optionCode??"").trim();t({multipleOptionId:h,multipleOptionName:b,selectedOptionValues:x})},disabled:a,children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{placeholder:a?"Loading…":"Select from Multiple Options"})}),o.jsxs(ze,{children:[o.jsx(we,{value:XS,children:"— None —"}),r.map(h=>o.jsx(we,{value:h.id,children:h.optionName??h.optionCode??h.id},h.id))]})]}),o.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Data comes from the Multiple Options tab (label-multiple-option list)."})]}),d&&c.length>0?o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Values (multi-select)"}),o.jsx("div",{className:"mt-1 max-h-44 overflow-y-auto border border-gray-200 rounded-md p-2 space-y-2 bg-gray-50/50",children:c.map(h=>o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx(Co,{className:"shrink-0",checked:l.includes(h),onCheckedChange:p=>{const g=new Set(l);p?g.add(h):g.delete(h),t({selectedOptionValues:Array.from(g)})}}),o.jsx("span",{className:"text-xs truncate",title:h,children:h})]},h))})]}):s?o.jsx("p",{className:"text-[10px] text-amber-600",children:"No values in this dictionary or still loading."}):null]})}const zye="box-border h-[150px] w-[150px] min-h-[150px] min-w-[150px] max-h-[150px] max-w-[150px] shrink-0";function JS({cfg:e,update:t,textAlignDefault:r,primaryTextLabel:n}){const a=n??"Text";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:a}),o.jsx(me,{value:e.text??"0.00",onChange:i=>t("text",i.target.value),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:e.fontSize??14,onChange:i=>t("fontSize",Number(i.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:e.textAlign??r,onValueChange:i=>t("textAlign",i),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"left",children:"Left"}),o.jsx(we,{value:"center",children:"Center"}),o.jsx(we,{value:"right",children:"Right"})]})]})]})]})}function fo(e,t,r){for(const n of t){const a=e[n];if(a!=null&&String(a).trim()!=="")return String(a).trim()}return r}function rc(e,t,r){for(const n of t){const a=e[n];if(a==null||a==="")continue;const i=typeof a=="number"?a:Number(a);if(Number.isFinite(i))return i}return r}const Z6=[{value:"lb",label:"Lb"},{value:"kg",label:"Kg"},{value:"mg",label:"Milligrams"},{value:"g",label:"Grams"},{value:"oz",label:"Ounces"}];function Uye(e){const t=String(e??"").trim().toLowerCase();return t==="milligrams"?"mg":t==="grams"?"g":t==="ounces"?"oz":t==="pounds"?"lb":t==="kilograms"?"kg":Z6.some(r=>r.value===t)?t:"g"}function qye(e){const t=e.extraNutrients;return Array.isArray(t)?t.map((r,n)=>{const a=r;return{id:String(a.id??`extra-${n}`),name:String(a.name??""),value:String(a.value??""),unit:String(a.unit??"")}}):[]}function Ap(e,t,r){const n=r==="value"?t:`${t}Unit`,a=e[n];if(a!=null&&String(a).trim()!=="")return String(a).trim();const s=(Array.isArray(e.fixedNutrients)?e.fixedNutrients:[]).find(l=>String(l.key??"").trim()===t);return String(s?.[r]??"").trim()}function Vye({element:e,onChange:t}){const r=e.config,n=Kr(e.type),a=(l,d)=>t({[l]:d}),i=U8(e),s=i?"Value":"Text";switch(n){case"TEXT_STATIC":return r.inputType==="options"?o.jsxs(o.Fragment,{children:[o.jsx(Bye,{cfg:r,onPatch:t}),o.jsx(JS,{cfg:r,update:a,textAlignDefault:"left",primaryTextLabel:s})]}):o.jsx(JS,{cfg:r,update:a,textAlignDefault:"right",primaryTextLabel:s});case"TEXT_PRODUCT":case"TEXT_PRICE":return o.jsx(JS,{cfg:r,update:a,textAlignDefault:"right"});case"BARCODE":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Data"}),o.jsx(me,{value:r.data??"123456789",onChange:l=>a("data",l.target.value),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Orientation"}),o.jsxs($e,{value:r.orientation??"horizontal",onValueChange:l=>a("orientation",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"horizontal",children:"Horizontal"}),o.jsx(we,{value:"vertical",children:"Vertical"})]})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(br,{checked:r.showText!==!1,onCheckedChange:l=>a("showText",l)}),o.jsx(ue,{className:"text-xs",children:"Show Text"})]})]});case"QRCODE":return o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Data (URL)"}),o.jsx(me,{value:r.data??"https://example.com",onChange:l=>a("data",l.target.value),className:"h-8 text-sm mt-1"})]});case"IMAGE":{if(i){const l=String(r.src??"").trim();return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Image"}),o.jsx(_u,{value:l,onChange:d=>a("src",d),uploadSubDir:"label-template-editor",oneImageOnly:!0,boxClassName:zye,hint:"Stored in template; print uses this URL (empty if cleared)."})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Scale Mode"}),o.jsxs($e,{value:r.scaleMode??"contain",onValueChange:d=>a("scaleMode",d),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"contain",children:"Contain"}),o.jsx(we,{value:"cover",children:"Cover"}),o.jsx(we,{value:"fill",children:"Fill"})]})]})]})]})}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Image URL / path"}),o.jsx(me,{value:r.src??"",onChange:l=>a("src",l.target.value),className:"h-8 text-sm mt-1",placeholder:"https://... or /picture/..."})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Scale Mode"}),o.jsxs($e,{value:r.scaleMode??"contain",onValueChange:l=>a("scaleMode",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"contain",children:"Contain"}),o.jsx(we,{value:"cover",children:"Cover"}),o.jsx(we,{value:"fill",children:"Fill"})]})]})]})]})}case"DATE":{const l=String(r.inputType??r.InputType??"").toLowerCase(),d=l==="datetime"||l==="date",c=fo(r,["format","Format"],l==="datetime"?ZL:"DD/MM/YYYY"),f=l==="datetime"?[ZL,...QL]:[...QL];return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Format"}),o.jsxs($e,{value:c,onValueChange:h=>a("format",h),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsx(ze,{children:f.map(h=>o.jsx(we,{value:h,children:h},h))})]}),d?o.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:"Shown as placeholder on the label until the app fills the date at print time."}):null]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:rc(r,["fontSize","FontSize"],14),onChange:h=>a("fontSize",Number(h.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:fo(r,["textAlign","TextAlign"],"left"),onValueChange:h=>a("textAlign",h),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"left",children:"Left"}),o.jsx(we,{value:"center",children:"Center"}),o.jsx(we,{value:"right",children:"Right"})]})]})]})]})}case"TIME":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Format"}),o.jsx(me,{value:"HH:mm",className:"h-8 text-sm mt-1",readOnly:!0})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:rc(r,["fontSize","FontSize"],14),onChange:l=>a("fontSize",Number(l.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:fo(r,["textAlign","TextAlign"],"left"),onValueChange:l=>a("textAlign",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"left",children:"Left"}),o.jsx(we,{value:"center",children:"Center"}),o.jsx(we,{value:"right",children:"Right"})]})]})]})]});case"DURATION":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Format"}),o.jsxs($e,{value:fo(r,["format","Format"],"Days"),onValueChange:l=>a("format",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsx(ze,{children:$ye.map(l=>o.jsx(we,{value:l,children:l},l))})]})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:rc(r,["fontSize","FontSize"],14),onChange:l=>a("fontSize",Number(l.target.value)||14),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:fo(r,["textAlign","TextAlign"],"left"),onValueChange:l=>a("textAlign",l),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"left",children:"Left"}),o.jsx(we,{value:"center",children:"Center"}),o.jsx(we,{value:"right",children:"Right"})]})]})]})]});case"WEIGHT":{const l=Uye(fo(r,["unit","Unit"],"g")),d=fo(r,["textAlign","TextAlign"],"left"),c=rc(r,["fontSize","FontSize"],14);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Value"}),o.jsx(me,{type:"number",value:rc(r,["value","Value"],500),onChange:f=>a("value",Number(f.target.value)||0),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Unit"}),o.jsxs($e,{value:l,onValueChange:f=>a("unit",f),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsx(ze,{children:Z6.map(f=>o.jsx(we,{value:f.value,children:f.label},f.value))})]})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Font Size"}),o.jsx(me,{type:"number",value:c,onChange:f=>a("fontSize",Math.max(1,Number(f.target.value)||14)),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Text Align"}),o.jsxs($e,{value:d,onValueChange:f=>a("textAlign",f),children:[o.jsx(Be,{className:"h-8 text-sm mt-1",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"left",children:"Left"}),o.jsx(we,{value:"center",children:"Center"}),o.jsx(we,{value:"right",children:"Right"})]})]})]})]})}case"WEIGHT_PRICE":return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Unit Price"}),o.jsx(me,{type:"number",value:r.unitPrice??10,onChange:l=>a("unitPrice",Number(l.target.value)||0),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Weight"}),o.jsx(me,{type:"number",step:"0.1",value:r.weight??.5,onChange:l=>a("weight",Number(l.target.value)||0),className:"h-8 text-sm mt-1"})]}),o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Currency"}),o.jsx(me,{value:r.currency??"$",onChange:l=>a("currency",l.target.value),className:"h-8 text-sm mt-1"})]})]});case"NUTRITION":{const l=qye(r),d=(p,g,x)=>{const b=rl.map(N=>{const C={key:N.key,label:N.label,value:Ap(r,N.key,"value"),unit:Ap(r,N.key,"unit")};return N.key!==p?C:{...C,[g]:x}}),w={fixedNutrients:b},j=b.find(N=>N.key===p);j&&(w[p]=j.value,w[`${p}Unit`]=j.unit),t(w)},c=()=>{const p=[...l,{id:`extra-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,name:"",value:"",unit:""}];a("extraNutrients",p)},f=(p,g,x)=>{const b=l.map(w=>w.id===p?{...w,[g]:x}:w);a("extraNutrients",b)},h=p=>{a("extraNutrients",l.filter(g=>g.id!==p))};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx(ue,{className:"text-xs",children:"Nutrition summary"}),o.jsxs("div",{className:"space-y-2 mt-1",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Nutrition Facts title (px)"}),o.jsx(me,{type:"number",value:rc(r,["nutritionTitleFontSize","NutritionTitleFontSize"],16),onChange:p=>a("nutritionTitleFontSize",Math.max(10,Number(p.target.value)||16)),className:"h-8 text-sm"})]}),o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Servings Per Container"}),o.jsx(me,{value:fo(r,["servingsPerContainer","ServingsPerContainer"],""),onChange:p=>a("servingsPerContainer",p.target.value),className:"h-8 text-sm",placeholder:"e.g. 8"})]}),o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Serving Size"}),o.jsx(me,{value:fo(r,["servingSize","ServingSize"],""),onChange:p=>a("servingSize",p.target.value),className:"h-8 text-sm",placeholder:"e.g. 1 cup"})]}),o.jsxs("div",{className:"grid grid-cols-[1fr_90px] gap-2 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:"Calories"}),o.jsx(me,{value:fo(r,["calories","Calories"],""),onChange:p=>a("calories",p.target.value),className:"h-8 text-sm",placeholder:"e.g. 120"})]})]})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-1",children:[o.jsx(ue,{className:"text-xs",children:"Nutrition table"}),o.jsx(de,{type:"button",variant:"outline",className:"h-7 px-2 text-xs",onClick:c,children:"Add nutrient"})]}),o.jsxs("div",{className:"space-y-1.5 mt-1",children:[o.jsxs("div",{className:"grid grid-cols-[1fr_78px_58px_26px] gap-1.5 items-center text-[10px] text-gray-500 px-0.5",children:[o.jsx("span",{children:"Name"}),o.jsx("span",{children:"Value"}),o.jsx("span",{children:"Unit"}),o.jsx("span",{})]}),rl.map(p=>o.jsxs("div",{className:"grid grid-cols-[1fr_78px_58px_26px] gap-1.5 items-center",children:[o.jsx("span",{className:"text-xs text-gray-600",children:p.label}),o.jsx(me,{value:Ap(r,p.key,"value"),onChange:g=>d(p.key,"value",g.target.value),className:"h-8 text-sm",placeholder:"Value"}),o.jsx(me,{value:Ap(r,p.key,"unit")||(p.defaultUnit??""),onChange:g=>d(p.key,"unit",g.target.value),className:"h-8 text-sm",placeholder:"Unit"}),o.jsx("span",{})]},p.key))]})]}),o.jsxs("div",{className:"space-y-2",children:[l.length===0?o.jsx("p",{className:"text-[10px] text-gray-400",children:"No custom nutrients yet."}):l.map(p=>o.jsxs("div",{className:"grid grid-cols-[1fr_78px_58px_26px] gap-1.5 items-center",children:[o.jsx(me,{value:p.name,onChange:g=>f(p.id,"name",g.target.value),className:"h-8 text-sm",placeholder:"Name"}),o.jsx(me,{value:p.value,onChange:g=>f(p.id,"value",g.target.value),className:"h-8 text-sm",placeholder:"Value"}),o.jsx(me,{value:p.unit,onChange:g=>f(p.id,"unit",g.target.value),className:"h-8 text-sm",placeholder:"Unit"}),o.jsx(de,{type:"button",variant:"ghost",className:"h-8 w-8 p-0 text-gray-500 hover:text-red-600",onClick:()=>h(p.id),"aria-label":"Delete nutrient",children:o.jsx(zt,{className:"h-3.5 w-3.5"})})]},p.id)),o.jsx("div",{className:"text-[10px] text-gray-400",children:"Unit is appended after value in template preview."})]})]})}case"BLANK":return o.jsx("div",{className:"text-xs text-gray-500",children:"Blank spacer; no configuration needed."});default:return o.jsxs("div",{className:"text-xs text-gray-500",children:["Config for ",n," (edit in code if needed)"]})}}const Wye=.5,Hye=2,e$=.25,t$=1;function ez(e){return`tpl_${Math.random().toString(36).slice(2,8)}_${Date.now().toString(36)}`}function Gye(e){return{...e,id:ez(e.id),name:`${(e.name||"Unnamed template").trim()} Copy`,elements:e.elements.map(t=>({...t,config:{...t.config??{}}}))}}function Yye({templateId:e,initialTemplate:t,onClose:r,onSaved:n}){const[a,i]=v.useState(()=>t?{...t}:{...Ume(e??void 0),id:ez()}),[s,l]=v.useState(null),[d,c]=v.useState(t$),[f,h]=v.useState(!1),[p,g]=v.useState("none"),[x,b]=v.useState("horizontal"),[w,j]=v.useState([]),[N,C]=v.useState(""),[O,P]=v.useState(!1),E=a.elements.find(M=>M.id===s)??null;v.useEffect(()=>{if(e)return;let M=!1;return(async()=>{try{const Y=await jv({skipCount:1,maxResultCount:200});if(M)return;const F=(Y.items??[]).map(D=>{const $=(D.templateCode??D.id??"").trim(),K=(D.templateName??D.name??$).trim();return $?{code:$,name:K}:null}).filter(D=>!!D);j(F),!N&&F.length>0&&C(F[0].code)}catch{M||j([])}})(),()=>{M=!0}},[e,N]),v.useEffect(()=>{if(e||!N)return;let M=!1;return(async()=>{P(!0);try{const Y=await nu(N);if(M)return;const F=Gye({id:Y.id,name:(Y.name??Y.templateName??"").trim()||"Unnamed template",labelType:Y.labelType??"PRICE",unit:Y.unit??"cm",width:Y.width??6,height:Y.height??4,appliedLocation:Y.appliedLocation==="SPECIFIED"?"SPECIFIED":"ALL",appliedLocationIds:[...Y.appliedLocationIds??[]],showRuler:!0,showGrid:Y.showGrid??!0,elements:(Y.elements??[]).map((D,$)=>{const K=D,J=(K.elementName??"").trim();return{...K,elementName:J||`element${$+1}`}})});i(F),l(null)}catch(Y){if(M)return;ee.error("Failed to copy starter template.",{description:Y?.message?String(Y.message):"Please try again."})}finally{M||P(!1)}})(),()=>{M=!0}},[e,N]),v.useEffect(()=>{i(M=>{const Y=(J,oe)=>oe==="cm"?J*37.8:J*96,F=Y(M.width,M.unit),D=Y(M.height,M.unit);let $=!1;const K=M.elements.map(J=>{const oe=zp(J.x,J.y,J.width,J.height,F,D);return J.x!==oe.x||J.y!==oe.y||J.width!==oe.w||J.height!==oe.h?($=!0,{...J,x:oe.x,y:oe.y,width:oe.w,height:oe.h}):J});return $?{...M,elements:K}:M})},[a.width,a.height,a.unit,a.id]);const T=p,A="space-y-1",I="!h-7 px-2 py-1 text-xs leading-tight bg-white",R="!h-7 gap-1 px-2 py-0 text-xs leading-tight bg-white [&_svg]:!size-3 *:data-[slot=select-value]:line-clamp-1",L="text-[11px] font-semibold leading-tight text-[#1d3c8f]",V=v.useCallback((M,Y,F,D)=>{let $="";i(K=>{const J=(De,He)=>He==="cm"?De*37.8:De*96,oe=J(K.width,K.unit),re=J(K.height,K.unit);let Q=qme(M,0,0);const ce=8,se=De=>Math.round(De/ce)*ce;let fe=(oe-Q.width)/2,be=(re-Q.height)/2;const Z=(De,He,ne,pe)=>K.elements.some(_e=>{const ye=_e.x+_e.width,Ae=_e.y+_e.height,Ge=De+ne,ut=He+pe;return!(De>=ye||Ge<=_e.x||He>=Ae||ut<=_e.y)});if(Z(fe,be,Q.width,Q.height)){const De=ce*2;let He=!1;for(let ne=be;ne=0&&!He;ne-=De)for(let pe=fe;pe>=0&&!He;pe-=De)Z(pe,ne,Q.width,Q.height)||(fe=pe,be=ne,He=!0)}Q={...Q,x:Math.max(0,se(fe)),y:Math.max(0,se(be))};const Se=zp(Q.x,Q.y,Q.width,Q.height,oe,re);Q={...Q,x:Se.x,y:Se.y,width:Se.w,height:Se.h},Y&&Object.keys(Y).length>0&&(Q.config={...Q.config,...Y});const Ne=Dme(D,K.elements),qe=$8(F);return Q={...Q,type:Q.type,typeAdd:H8(F,D),libraryCategory:Z_(F,D),valueSourceType:qe,elementName:Ne},$=Q.id,{...K,elements:[...K.elements,Q]}}),l($)},[a.width,a.height,a.unit]),z=v.useCallback((M,Y)=>{i(F=>{const D=(J,oe)=>oe==="cm"?J*37.8:J*96,$=D(F.width,F.unit),K=D(F.height,F.unit);return{...F,elements:F.elements.map(J=>{if(J.id!==M)return J;const oe={...J,...Y};if(!(Y.x!==void 0||Y.y!==void 0||Y.width!==void 0||Y.height!==void 0))return oe;const Q=zp(oe.x,oe.y,oe.width,oe.height,$,K);return{...oe,x:Q.x,y:Q.y,width:Q.w,height:Q.h}})}})},[]),G=v.useCallback(M=>{i(Y=>({...Y,elements:Y.elements.filter(F=>F.id!==M)})),l(null)},[]),H=v.useCallback(M=>{i(Y=>({...Y,...M}))},[]),W=v.useCallback(async()=>{try{const M=(a.id??"").trim();if(!M){ee.error("Template code is required.",{description:"Please enter a template code (e.g. TPL_TEST_001)."});return}if(a.elements.find($=>!($.elementName??"").trim())){ee.error("Component name required.",{description:"Each element must have a non-empty element name."});return}if(a.elements.find($=>{if($.type!=="TEXT_STATIC")return!1;const K=$.config;return String(K?.inputType??"").toLowerCase()!=="options"?!1:!String(K?.multipleOptionId??K?.MultipleOptionId??"").trim()})){ee.error("Option dictionary required.",{description:"Each Multiple Options element must have an Option dictionary selected in the properties panel."});return}const D={id:M,name:a.name,labelType:a.labelType,unit:a.unit,width:a.width,height:a.height,appliedLocation:"ALL",showRuler:!0,showGrid:a.showGrid??!0,state:!0,elements:tE(a.elements),appliedLocationIds:[]};e?(await aE(M,D),ee.success("Template updated.",{description:"The template has been updated successfully."})):(await epe(D),ee.success("Template created.",{description:"The template has been created successfully."})),n(),r()}catch(M){ee.error("Failed to save template.",{description:M?.message?String(M.message):"Please try again."})}},[a,e,n,r]),q=v.useCallback(()=>{const M={...a,elements:a.elements.map($=>({...$,type:Kr($.type),typeAdd:Qf($),elementName:($.elementName??"").trim(),valueSourceType:V8($),libraryCategory:Kme($),config:eE($.config??{})}))},Y=new Blob([JSON.stringify(M,null,2)],{type:"application/json"}),F=URL.createObjectURL(Y),D=document.createElement("a");D.href=F,D.download=`label-template-${a.id}.json`,D.click(),URL.revokeObjectURL(F)},[a]);return o.jsxs("div",{className:"flex flex-col overflow-hidden",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-gray-200 bg-white shrink-0",children:[o.jsxs(de,{variant:"outline",size:"sm",onClick:r,children:[o.jsx(C$,{className:"w-4 h-4 mr-1"}),"Back"]}),o.jsx("span",{className:"text-sm font-medium text-gray-700 truncate flex-1",children:a.name}),o.jsxs(de,{size:"sm",onClick:q,variant:"outline",children:[o.jsx(oC,{className:"w-4 h-4 mr-1"}),"Export JSON"]}),o.jsxs(de,{size:"sm",className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:W,children:[o.jsx(e7,{className:"w-4 h-4 mr-1"}),"Save"]})]}),o.jsx("div",{className:"shrink-0 border-b border-[#cfd9ea] bg-[#dde7f5] px-4 py-2",children:o.jsx("div",{className:"rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsxs("div",{className:A,children:[o.jsx(ue,{className:L,children:"Label Template Name"}),o.jsx(me,{value:a.name,onChange:M=>H({name:M.target.value}),className:I})]}),o.jsxs("div",{className:`${A} col-span-2`,children:[o.jsx(ue,{className:L,children:"Ruler"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs($e,{value:a.unit,onValueChange:M=>H({unit:M,showRuler:!0}),children:[o.jsx(Be,{className:`w-[72px] shrink-0 ${R}`,children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"inch",className:"text-xs",children:"Inch"}),o.jsx(we,{value:"cm",className:"text-xs",children:"cm"})]})]}),o.jsx("span",{className:"shrink-0 text-center text-[11px] font-semibold text-[#1d3c8f]",children:"W"}),o.jsx(me,{type:"number",value:a.width,onChange:M=>H({width:Math.max(.1,Number(M.target.value)||0),showRuler:!0}),className:`w-[72px] shrink-0 ${I}`,placeholder:"Width"}),o.jsx("span",{className:"shrink-0 text-center text-[11px] font-semibold text-[#1d3c8f]",children:"H"}),o.jsx(me,{type:"number",value:a.height,onChange:M=>H({height:Math.max(.1,Number(M.target.value)||0),showRuler:!0}),className:`w-[72px] shrink-0 ${I}`,placeholder:"Height"}),o.jsxs($e,{value:(()=>{const M=bc.findIndex(Y=>Y.width===a.width&&Y.height===a.height&&Y.unit===a.unit);return M>=0?String(M):"custom"})(),onValueChange:M=>{if(M==="custom")return;const Y=bc[Number(M)];Y&&H({width:Y.width,height:Y.height,unit:Y.unit,showRuler:!0})},children:[o.jsx(Be,{className:`w-[118px] shrink-0 ${R}`,children:o.jsx(Fe,{placeholder:"Canvas size"})}),o.jsxs(ze,{children:[bc.map((M,Y)=>o.jsx(we,{value:String(Y),className:"text-xs",children:M.name},Y)),o.jsx(we,{value:"custom",className:"text-xs text-gray-500",children:"Custom"})]})]})]})]}),o.jsxs("div",{className:A,children:[o.jsx(ue,{className:L,children:"Starter Template"}),e?o.jsx(me,{value:"Current template",disabled:!0,className:I}):o.jsxs($e,{value:N,onValueChange:C,children:[o.jsx(Be,{className:R,children:o.jsx(Fe,{placeholder:"Select starter template"})}),o.jsx(ze,{children:w.map(M=>o.jsx(we,{value:M.code,className:"text-xs",children:M.name},M.code))})]})]}),o.jsxs("div",{className:A,children:[o.jsx(ue,{className:L,children:"Border"}),o.jsxs($e,{value:T,onValueChange:M=>g(M),children:[o.jsx(Be,{className:R,children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"none",className:"text-xs",children:"none"}),o.jsx(we,{value:"line",className:"text-xs",children:"line"}),o.jsx(we,{value:"dotted",className:"text-xs",children:"dotted"})]})]})]}),o.jsxs("div",{className:A,children:[o.jsx(ue,{className:L,children:"Rotation"}),o.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:o.jsx("div",{className:"col-span-2",children:o.jsxs($e,{value:x,onValueChange:M=>{b(M),a.height>a.width!==(M==="vertical")&&H({width:a.height,height:a.width})},children:[o.jsx(Be,{className:R,children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"horizontal",className:"text-xs",children:"horizontal"}),o.jsx(we,{value:"vertical",className:"text-xs",children:"vertical"})]})]})})})]}),O?o.jsx("div",{className:"col-span-3 text-[11px] leading-tight text-[#1d3c8f]",children:"Copying starter template…"}):null]})})}),o.jsxs("div",{className:"gap-2 bg-[#dde7f5] p-2",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"row",alignItems:"stretch",gap:8},children:[o.jsx("div",{className:"shrink-0 rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-1",style:{width:"15rem",flexShrink:0,alignSelf:"stretch",minHeight:0,overflowX:"hidden",overflowY:"auto",WebkitOverflowScrolling:"touch",boxSizing:"border-box"},children:o.jsx(Pye,{onAddElement:V})}),o.jsx("div",{className:"rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-1",style:{flex:"1 1 0%",minHeight:0,minWidth:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:o.jsx(Uge,{template:a,canvasBorder:p,selectedId:s,onSelect:l,onUpdateElement:z,onDeleteElement:G,onTemplateChange:H,scale:d,onZoomIn:()=>c(M=>Math.min(Hye,M+e$)),onZoomOut:()=>c(M=>Math.max(Wye,M-e$)),onResetZoom:()=>c(t$),onPreview:()=>h(!0),hideToolbarPresetSize:!0})}),o.jsx("div",{className:"rounded-lg border border-[#c2d1e8] bg-[#e4ecf8] p-1",style:{width:"18rem",flexShrink:0,alignSelf:"stretch",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:o.jsx(Fye,{template:a,selectedElement:E,onTemplateChange:H,onElementChange:z,onDeleteElement:G,readOnlyTemplateCode:!!e})})]}),o.jsx(kt,{open:f,onOpenChange:h,children:o.jsxs(Ot,{className:"max-w-[90vw] max-h-[90vh] p-0 overflow-hidden flex flex-col",children:[o.jsx(At,{className:"shrink-0 px-6 py-4 border-b bg-white",children:o.jsx(It,{children:"Label preview"})}),o.jsx("div",{className:"flex-1 min-h-0 overflow-x-auto overflow-y-auto p-4 bg-gray-50",children:o.jsx("div",{className:"min-w-max",children:o.jsx(iE,{template:a,canvasBorder:p,maxWidth:0})})})]})})]})}function QS(e){const t=(e??"").trim();return t||"None"}function Kye(e,t){if(eu(e)==="ALL")return"All";const n=e.appliedLocationIds??[];if(n.length===0)return"Specified (0)";const a=n.map(i=>t.find(s=>s.id===i)?.locationName?.trim()||i);return a.length<=2?a.join(", "):`${a.slice(0,2).join(", ")} +${a.length-2}`}function Xye(e){const t=(e.templateName??e.name??"").trim();return t||"None"}function Jye(e){const t=(e.templateCode??e.id??"").trim();return t||"None"}function Qye(e,t){const r=(e.locationText??"").trim();return r||Kye(e,t)}function Zye(e){return typeof e.contentsCount=="number"?e.contentsCount:e.elements?.length??0}function eve(e){const t=(e.sizeText??"").trim();if(t)return t;const r=e.width,n=e.height,a=e.unit;return r!=null&&n!=null&&a?`${r}×${n} ${a}`:"None"}function tve({onTemplateEditorOverlayChange:e}){const[t,r]=v.useState([]),[n,a]=v.useState("list"),[i,s]=v.useState(null),[l,d]=v.useState(null),[c,f]=v.useState(!1),[h,p]=v.useState(0),[g,x]=v.useState(0),[b,w]=v.useState(null),[j,N]=v.useState(!1),[C,O]=v.useState(null),[P,E]=v.useState(""),[T,A]=v.useState("all"),[I,R]=v.useState("all"),[L,V]=v.useState("all"),[z,G]=v.useState(1),[H,W]=v.useState(10),[q,M]=v.useState([]),Y=v.useRef(null),F=v.useRef(null),[D,$]=v.useState("");v.useEffect(()=>(F.current&&window.clearTimeout(F.current),F.current=window.setTimeout(()=>$(P.trim()),300),()=>{F.current&&window.clearTimeout(F.current)}),[P]);const K=Math.max(1,Math.ceil(h/H));v.useEffect(()=>{let Se=!1;return(async()=>{try{const Ne=await Nu({skipCount:1,maxResultCount:500});Se||M(Ne.items??[])}catch{Se||M([])}})(),()=>{Se=!0}},[]),v.useEffect(()=>{G(1)},[D,T,I,L,H]),v.useEffect(()=>n!=="list"?void 0:((async()=>{Y.current?.abort();const Ne=new AbortController;Y.current=Ne,f(!0);try{const qe=Qa(z),De=await jv({skipCount:qe,maxResultCount:H,keyword:D||void 0,locationId:T!=="all"?T:void 0,labelType:I!=="all"?I:void 0,state:L==="all"?void 0:L==="true"},Ne.signal);r(De.items??[]),p(De.totalCount??0)}catch(qe){if(qe?.name==="AbortError")return;ee.error("Failed to load label templates.",{description:qe?.message?String(qe.message):"Please try again."}),r([]),p(0)}finally{f(!1)}})(),()=>Y.current?.abort()),[D,T,I,L,z,H,g,n]),v.useEffect(()=>(e?.(n==="editor"),()=>{e?.(!1)}),[n,e]);const J=()=>x(Se=>Se+1),oe=()=>{s(null),d(null),a("editor")},re=async Se=>{w(null),s(Se),f(!0);try{const Ne=await nu(Se),qe={id:Ne.id,name:(Ne.name??Ne.templateName??"").trim()||"Unnamed template",labelType:Ne.labelType??"PRICE",unit:Ne.unit??"cm",width:Ne.width??6,height:Ne.height??4,appliedLocation:eu(Ne),appliedLocationIds:[...Ne.appliedLocationIds??[]],showRuler:Ne.showRuler??!0,showGrid:Ne.showGrid??!0,elements:(Ne.elements??[]).map((De,He)=>{const ne=De,pe=(ne.elementName??"").trim();return{...ne,elementName:pe||`element${He+1}`}})};d(qe),a("editor")}catch(Ne){ee.error("Failed to load template.",{description:Ne?.message?String(Ne.message):"Please try again."})}finally{f(!1)}},Q=()=>{a("list"),s(null),d(null)},ce=Se=>{w(null),O(Se),N(!0)},se=o.jsx("div",{className:"shrink-0 pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:P,onChange:Se=>E(Se.target.value),style:{height:40,boxSizing:"border-box"},className:"w-40 shrink-0 rounded-md border border-gray-300 bg-white placeholder:text-gray-500"}),o.jsxs($e,{value:T,onValueChange:A,children:[o.jsx(Be,{className:"w-[150px] shrink-0 rounded-md border border-gray-300 bg-white",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All Locations"}),q.map(Se=>o.jsx(we,{value:Se.id,children:QS(Se.locationName??Se.locationCode??Se.id)},Se.id))]})]}),o.jsxs($e,{value:I,onValueChange:R,children:[o.jsx(Be,{className:"w-[150px] shrink-0 rounded-md border border-gray-300 bg-white",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Label Type"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All Types"}),o.jsx(we,{value:"PRICE",children:"PRICE"}),o.jsx(we,{value:"NUTRITION",children:"NUTRITION"}),o.jsx(we,{value:"SHIPPING",children:"SHIPPING"})]})]}),o.jsxs($e,{value:L,onValueChange:V,children:[o.jsx(Be,{className:"w-[150px] shrink-0 rounded-md border border-gray-300 bg-white",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All States"}),o.jsx(we,{value:"true",children:"Active"}),o.jsx(we,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(de,{className:"h-10 shrink-0 rounded-md bg-blue-600 px-6 font-medium text-white hover:bg-blue-700",onClick:oe,children:["New Label Template ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),fe=o.jsx("div",{className:"min-h-0 flex-1 overflow-auto pt-2",children:o.jsx("div",{className:"rounded-md border border-gray-200 bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[180px]",children:"Label Template"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Template Code"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[120px]",children:"Location"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Label Type"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Contents"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[150px]",children:"Size"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:c?o.jsx(nt,{children:o.jsx(xe,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):t.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:'No templates yet. Click "New Label Template" to create one.'})}):t.map(Se=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"font-medium whitespace-nowrap overflow-hidden text-ellipsis max-w-[180px]",children:Xye(Se)}),o.jsx(xe,{className:"text-gray-600 whitespace-nowrap overflow-hidden text-ellipsis max-w-[140px]",children:Jye(Se)}),o.jsx(xe,{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[140px]",children:QS(Qye(Se,q))}),o.jsx(xe,{className:"whitespace-nowrap",children:QS(Se.labelType)}),o.jsxs(xe,{className:"text-sm text-gray-600 whitespace-nowrap",children:[Zye(Se)," element(s)"]}),o.jsx(xe,{className:"whitespace-nowrap overflow-hidden text-ellipsis max-w-[160px]",children:eve(Se)}),o.jsx(xe,{className:"text-center",children:o.jsxs(ka,{open:b===Se.id,onOpenChange:Ne=>w(Ne?Se.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>re(Se.id),children:[o.jsx(Rp,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>ce(Se),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},Se.id))})]})})}),be=o.jsx("div",{className:"shrink-0 pt-3",children:o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",h===0?0:(z-1)*H+1,"-",Math.min(z*H,h)," of ",h]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsxs($e,{value:String(H),onValueChange:Se=>W(Number(Se)),children:[o.jsx(Be,{className:"h-9 w-[110px] rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(Se=>o.jsxs(we,{value:String(Se),children:[Se," / page"]},Se))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:Se=>{Se.preventDefault(),G(Ne=>Math.max(1,Ne-1))},"aria-disabled":z<=1,className:z<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:Se=>Se.preventDefault(),children:["Page ",z," / ",K]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:Se=>{Se.preventDefault(),G(Ne=>Math.min(K,Ne+1))},"aria-disabled":z>=K,className:z>=K?"pointer-events-none opacity-50":""})})]})})]})]})}),Z=o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[se,fe,be]});return o.jsxs("div",{className:"flex h-full flex-col",style:{height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[n==="editor"?o.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",style:{flex:"1 1 0%",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:o.jsx(Yye,{templateId:i,initialTemplate:l,onClose:Q,onSaved:J})}):o.jsx("div",{className:"flex flex-1 flex-col",style:{flex:"1 1 0%",minHeight:0},children:Z}),o.jsx(rve,{open:j,template:C,onOpenChange:Se=>{N(Se),Se||O(null)},onDeleted:J})]})}function rve({open:e,template:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>(t?.templateName??t?.name??"").trim()||(t?.templateCode??t?.id??"").trim()||"this template",[t]),l=async()=>{if(t?.id){i(!0);try{await tpe(t.id),ee.success("Label template deleted.",{description:"The label template has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete label template.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Label Template"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function r$(e){const t=(e??"").trim();return t||"None"}function nve(){const[e,t]=v.useState(!1),[r,n]=v.useState(!1),[a,i]=v.useState(!1),[s,l]=v.useState(null),[d,c]=v.useState(null),[f,h]=v.useState([]),[p,g]=v.useState(!1),[x,b]=v.useState(0),[w,j]=v.useState(0),[N,C]=v.useState(null),[O,P]=v.useState(""),[E,T]=v.useState("all"),[A,I]=v.useState(1),[R,L]=v.useState(10),V=v.useRef(null),z=v.useRef(null),[G,H]=v.useState("");v.useEffect(()=>(z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>H(O.trim()),300),()=>{z.current&&window.clearTimeout(z.current)}),[O]);const W=Math.max(1,Math.ceil(x/R));v.useEffect(()=>{I(1)},[G,E,R]),v.useEffect(()=>((async()=>{V.current?.abort();const D=new AbortController;V.current=D,g(!0);try{const $=Qa(A),K=await V6({skipCount:$,maxResultCount:R,keyword:G||void 0,state:E==="all"?void 0:E==="true"},D.signal);h(K.items??[]),b(K.totalCount??0)}catch($){if($?.name==="AbortError")return;ee.error("Failed to load multiple options.",{description:$?.message?String($.message):"Please try again."}),h([]),b(0)}finally{g(!1)}})(),()=>V.current?.abort()),[G,E,A,R,w]);const q=()=>j(F=>F+1),M=F=>{C(null),l(F),n(!0)},Y=F=>{C(null),c(F),i(!0)};return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:O,onChange:F=>P(F.target.value),style:{height:40,boxSizing:"border-box"},className:"bg-white border border-gray-300 rounded-md w-40 shrink-0 placeholder:text-gray-500"}),o.jsxs($e,{value:E,onValueChange:T,children:[o.jsx(Be,{className:"bg-white border border-gray-300 rounded-md w-[150px] shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All States"}),o.jsx(we,{value:"true",children:"Active"}),o.jsx(we,{value:"false",children:"Inactive"})]})]}),o.jsx("div",{className:"flex-1"}),o.jsxs(de,{className:"bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md h-10 px-6 shrink-0",onClick:()=>t(!0),children:["New Multiple Options ",o.jsx(Un,{className:"ml-1 h-4 w-4"})]})]})})}),o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"rounded-md border bg-white shadow-sm",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-50 hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Multiple Option Name"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[200px]",children:"Option Code"}),o.jsx(Ee,{className:"font-bold text-gray-900",children:"Contents"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"State"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[100px]",children:"Order"}),o.jsx(Ee,{className:"font-bold text-gray-900 w-[180px]",children:"Last Edited"}),o.jsx(Ee,{className:"font-bold text-gray-900 text-center w-[100px]",children:"Actions"})]})}),o.jsx(pn,{children:p?o.jsx(nt,{children:o.jsx(xe,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):f.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:7,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):f.map(F=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"font-medium",children:r$(F.optionName)}),o.jsx(xe,{className:"text-gray-600",children:r$(F.optionCode)}),o.jsx(xe,{className:"text-gray-600",children:F.optionValuesJson&&F.optionValuesJson.length>0?F.optionValuesJson.join("; "):"None"}),o.jsx(xe,{children:o.jsx(fn,{className:F.state?"bg-green-600":"bg-gray-400",children:F.state?"Active":"Inactive"})}),o.jsx(xe,{className:"font-numeric",children:F.orderNum??"None"}),o.jsx(xe,{className:"text-gray-500 tabular-nums font-numeric",children:F.creationTime?new Date(F.creationTime).toLocaleString():"None"}),o.jsx(xe,{className:"text-center",children:o.jsxs(ka,{open:N===F.id,onOpenChange:D=>C(D?F.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>M(F),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>Y(F),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},F.id))})]})})}),o.jsx("div",{className:"pt-4",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",x===0?0:(A-1)*R+1,"-",Math.min(A*R,x)," of ",x]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(R),onValueChange:F=>L(Number(F)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(F=>o.jsxs(we,{value:String(F),children:[F," / page"]},F))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:F=>{F.preventDefault(),I(D=>Math.max(1,D-1))},"aria-disabled":A<=1,className:A<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:F=>F.preventDefault(),children:["Page ",A," / ",W]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:F=>{F.preventDefault(),I(D=>Math.min(W,D+1))},"aria-disabled":A>=W,className:A>=W?"pointer-events-none opacity-50":""})})]})})]})]})}),o.jsx(ave,{open:e,onOpenChange:t,onCreated:()=>{I(1),q()}}),o.jsx(ove,{open:r,option:s,onOpenChange:F=>{n(F),F||l(null)},onUpdated:q}),o.jsx(ive,{open:a,option:d,onOpenChange:F=>{i(F),F||c(null)},onDeleted:q})]})}function ave({open:e,onOpenChange:t,onCreated:r}){const[n,a]=v.useState(!1),[i,s]=v.useState({optionCode:"",optionName:"",optionValuesJson:[],state:!0,orderNum:null}),[l,d]=v.useState(""),c=()=>{s({optionCode:"",optionName:"",optionValuesJson:[],state:!0,orderNum:null}),d("")};v.useEffect(()=>{e||c()},[e]);const f=()=>{const g=l.trim();if(g){if(i.optionValuesJson.includes(g)){ee.error("Duplicate value",{description:"This value already exists."});return}s(x=>({...x,optionValuesJson:[...x.optionValuesJson,g]})),d("")}},h=g=>{s(x=>({...x,optionValuesJson:x.optionValuesJson.filter((b,w)=>w!==g)}))},p=async()=>{if(!i.optionName.trim()){ee.error("Validation failed",{description:"Option Name is required."});return}if(i.optionValuesJson.length===0){ee.error("Validation failed",{description:"At least one option value is required."});return}if(i.orderNum===null||i.orderNum===void 0||!Number.isFinite(i.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}a(!0);try{await kye(i),ee.success("Multiple option created.",{description:"The multiple option has been created successfully."}),t(!1),r()}catch(g){ee.error("Failed to create multiple option.",{description:g?.message?String(g.message):"Please try again."})}finally{a(!1)}};return o.jsx(kt,{open:e,onOpenChange:t,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Add New Multiple Option"}),o.jsx(qt,{children:"Enter the details for the new multiple option."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Option Code"}),o.jsx(me,{placeholder:"e.g. OPT_ALLERGENS",value:i.optionCode,onChange:g=>s(x=>({...x,optionCode:g.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Option Name *"}),o.jsx(me,{placeholder:"e.g. Allergens",value:i.optionName,onChange:g=>s(x=>({...x,optionName:g.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Option Values *"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{placeholder:"Enter a value and press Add",value:l,onChange:g=>d(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),f())}}),o.jsx(de,{type:"button",onClick:f,variant:"outline",children:"Add"})]}),i.optionValuesJson.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:i.optionValuesJson.map((g,x)=>o.jsxs(fn,{variant:"secondary",className:"flex items-center gap-1",children:[g,o.jsx("button",{type:"button",onClick:()=>h(x),className:"ml-1 hover:text-red-600",children:o.jsx(Qo,{className:"h-3 w-3"})})]},x))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:i.orderNum??"",onChange:g=>s(x=>({...x,orderNum:g.target.value?Number(g.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:i.state,onCheckedChange:g=>s(x=>({...x,state:g}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(de,{disabled:n,onClick:p,children:n?"Creating...":"Create"})]})]})})}function ove({open:e,option:t,onOpenChange:r,onUpdated:n}){const[a,i]=v.useState(!1),[s,l]=v.useState({optionCode:"",optionName:"",optionValuesJson:[],state:!0,orderNum:null}),[d,c]=v.useState("");v.useEffect(()=>{e&&t&&(l({optionCode:t.optionCode??"",optionName:t.optionName??"",optionValuesJson:t.optionValuesJson??[],state:t.state??!0,orderNum:t.orderNum??null}),c(""))},[e,t]);const f=()=>{const g=d.trim();if(g){if(s.optionValuesJson.includes(g)){ee.error("Duplicate value",{description:"This value already exists."});return}l(x=>({...x,optionValuesJson:[...x.optionValuesJson,g]})),c("")}},h=g=>{l(x=>({...x,optionValuesJson:x.optionValuesJson.filter((b,w)=>w!==g)}))},p=async()=>{if(t?.id){if(!s.optionName.trim()){ee.error("Validation failed",{description:"Option Name is required."});return}if(s.optionValuesJson.length===0){ee.error("Validation failed",{description:"At least one option value is required."});return}if(s.orderNum===null||s.orderNum===void 0||!Number.isFinite(s.orderNum)){ee.error("Validation failed",{description:"Order is required."});return}i(!0);try{await Aye(t.id,s),ee.success("Multiple option updated.",{description:"The multiple option has been updated successfully."}),r(!1),n()}catch(g){ee.error("Failed to update multiple option.",{description:g?.message?String(g.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Edit Multiple Option"}),o.jsx(qt,{children:"Update the multiple option details."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Option Code"}),o.jsx(me,{placeholder:"e.g. OPT_ALLERGENS",value:s.optionCode,onChange:g=>l(x=>({...x,optionCode:g.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Option Name *"}),o.jsx(me,{placeholder:"e.g. Allergens",value:s.optionName,onChange:g=>l(x=>({...x,optionName:g.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Option Values *"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{placeholder:"Enter a value and press Add",value:d,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),f())}}),o.jsx(de,{type:"button",onClick:f,variant:"outline",children:"Add"})]}),s.optionValuesJson.length>0&&o.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:s.optionValuesJson.map((g,x)=>o.jsxs(fn,{variant:"secondary",className:"flex items-center gap-1",children:[g,o.jsx("button",{type:"button",onClick:()=>h(x),className:"ml-1 hover:text-red-600",children:o.jsx(Qo,{className:"h-3 w-3"})})]},x))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{type:"number",placeholder:"e.g. 1",value:s.orderNum??"",onChange:g=>l(x=>({...x,orderNum:g.target.value?Number(g.target.value):null}))})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:s.state,onCheckedChange:g=>l(x=>({...x,state:g}))})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:a,onClick:p,children:a?"Updating...":"Update"})]})]})})}function ive({open:e,option:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>(t?.optionName??"").trim()||t?.optionCode||"this option",[t]),l=async()=>{if(t?.id){i(!0);try{await Iye(t.id),ee.success("Multiple option deleted.",{description:"The multiple option has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete multiple option.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Multiple Option"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function sve({currentView:e="Labels",onViewChange:t,labelCreateOpenSeq:r=0,onLabelCreateIntentConsumed:n,onLabelTemplateEditorLayoutOverlay:a}){const[i,s]=v.useState(!1),l=v.useCallback(f=>{s(f),a?.(f)},[a]),d=["Labels","Label Categories","Label Types","Label Templates","Multiple Options"],c=f=>{t&&t(f)};return o.jsxs("div",{className:`flex h-full flex-col ${i?"gap-0":"gap-6"}`,style:{minHeight:0,height:"100%",display:"flex",flexDirection:"column"},children:[!i&&o.jsx("div",{className:"w-full shrink-0 border-b border-gray-200",children:o.jsx("div",{className:"flex overflow-x-auto bg-white",children:d.map(f=>o.jsx("div",{onClick:()=>c(f),style:e===f?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:`px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px ${e===f?"text-blue-600":"border-b-2 border-b-transparent text-gray-600 hover:text-gray-800"}`,children:f},f))})}),o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",style:{flex:"1 1 0%",minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:[e==="Labels"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(Yge,{openCreateSeq:r,onOpenCreateIntentConsumed:n})}),e==="Label Categories"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(vye,{})}),e==="Label Types"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(Sye,{})}),e==="Label Templates"&&o.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:o.jsx(tve,{onTemplateEditorOverlayChange:l})}),e==="Multiple Options"&&o.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:o.jsx(nve,{})}),!["Labels","Label Categories","Label Types","Label Templates","Multiple Options"].includes(e)&&o.jsxs("div",{className:"flex h-64 items-center justify-center text-gray-400",children:[e," content coming soon..."]})]})]})}function lve(){const[e,t]=v.useState([{id:"1",name:"Pop",isOpen:!0,subcategories:[{id:"1-1",name:"2024",isOpen:!0,files:[{id:"f1",name:"uuuuu",date:"10/23/24, 12:21 AM",type:"image"},{id:"f2",name:"664EF167-DFCE-49C1-A417-DC09FEDF78D7.jpg",date:"11/24/25, 8:40 PM",type:"image"}]}]},{id:"2",name:"Training",isOpen:!0,subcategories:[{id:"2-1",name:"BOH",isOpen:!1,files:[]},{id:"2-2",name:"FOH",isOpen:!0,files:[]}]},{id:"3",name:"ww",isOpen:!1,subcategories:[]}]),r=a=>{t(i=>i.map(s=>s.id===a?{...s,isOpen:!s.isOpen}:s))},n=(a,i)=>{t(s=>s.map(l=>l.id!==a?l:{...l,subcategories:l.subcategories.map(d=>d.id===i?{...d,isOpen:!d.isOpen}:d)}))};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(me,{className:"bg-white border border-black rounded-md h-10 w-[150px]"}),o.jsx("span",{className:"text-sm text-black whitespace-nowrap",children:"Search"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs($e,{defaultValue:"all",children:[o.jsx(Be,{className:"bg-white border border-black rounded-md h-10 w-[100px]",children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"all"}),o.jsx(we,{value:"loc-a",children:"Location A"})]})]}),o.jsx("span",{className:"text-sm text-black whitespace-nowrap",children:"Location"})]})]}),o.jsxs("div",{className:"bg-gray-100 p-2 flex justify-between items-center border-b border-gray-200",children:[o.jsx("h1",{className:"text-xl font-medium text-gray-700",children:"Information"}),o.jsxs("div",{className:"flex items-center gap-4 text-gray-600",children:[o.jsx("div",{className:"flex items-center gap-1 bg-gray-700 text-white text-[10px] px-1 py-0.5 rounded-sm font-bold",children:"NEW"}),o.jsx(s7,{className:"h-5 w-5"}),o.jsx("span",{className:"font-medium",children:"55789"})]})]}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("button",{className:"w-full bg-[#2c7bb6] hover:bg-[#256b9e] text-white py-2 px-4 flex items-center gap-2 text-sm font-medium rounded-sm",children:[o.jsx(Un,{className:"h-4 w-4"}),"New Category",o.jsx(Wd,{className:"h-4 w-4 opacity-70"})]}),o.jsx("div",{className:"space-y-4",children:e.map(a=>o.jsxs("div",{className:"border border-gray-300 rounded-sm overflow-hidden",children:[o.jsxs("div",{className:"bg-gradient-to-b from-gray-50 to-gray-100 border-b border-gray-200 p-2 flex items-center justify-between",children:[o.jsxs("button",{onClick:()=>r(a.id),className:"flex items-center gap-2 text-gray-700 font-medium text-sm flex-1 text-left",children:[a.isOpen?o.jsx(Bs,{className:"h-4 w-4 text-[#2c7bb6]"}):o.jsx(Ui,{className:"h-4 w-4 text-[#2c7bb6]"}),a.name]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:o.jsx(Rp,{className:"h-4 w-4"})}),o.jsx("button",{className:"text-red-400 hover:text-red-600",children:o.jsx(Qo,{className:"h-4 w-4"})})]})]}),a.isOpen&&o.jsxs("div",{className:"p-2 space-y-3 bg-white",children:[o.jsxs("button",{className:"w-full bg-[#2c7bb6] hover:bg-[#256b9e] text-white py-2 px-4 flex items-center gap-2 text-sm font-medium rounded-sm",children:[o.jsx(Un,{className:"h-4 w-4"}),"New Subcategory",o.jsx(Wd,{className:"h-4 w-4 opacity-70"})]}),o.jsxs("div",{className:"space-y-3",children:[a.subcategories.map(i=>o.jsxs("div",{className:"border border-gray-200 rounded-sm",children:[o.jsxs("div",{className:"bg-white border-b border-gray-200 p-2 flex items-center justify-between",children:[o.jsxs("button",{onClick:()=>n(a.id,i.id),className:"flex items-center gap-2 text-gray-700 font-medium text-sm flex-1 text-left",children:[i.isOpen?o.jsx(Bs,{className:"h-4 w-4 text-[#2c7bb6]"}):o.jsx(Ui,{className:"h-4 w-4 text-[#2c7bb6]"}),i.name]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{className:"text-gray-400 hover:text-gray-600",children:o.jsx(Rp,{className:"h-4 w-4"})}),o.jsx("button",{className:"text-red-400 hover:text-red-600",children:o.jsx(Qo,{className:"h-4 w-4"})})]})]}),i.isOpen&&o.jsxs("div",{className:"p-3 bg-gray-50/50",children:[o.jsx("div",{className:"mb-2 text-xs font-bold text-gray-500 uppercase tracking-wide",children:"Files"}),o.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 justify-end",children:[o.jsx(de,{size:"sm",className:"h-8 bg-[#4CAF50] hover:bg-[#43a047] text-white text-xs border-none rounded-sm",children:"Upload Your Own File(s)"}),o.jsx(de,{size:"sm",className:"h-8 bg-[#4CAF50] hover:bg-[#43a047] text-white text-xs border-none rounded-sm",children:"Create A Custom File"}),o.jsx(de,{size:"sm",className:"h-8 bg-[#2c7bb6] hover:bg-[#256b9e] text-white text-xs border-none rounded-sm",children:"Edit File Permissions"}),o.jsxs(de,{size:"sm",className:"h-8 bg-[#2c7bb6] hover:bg-[#256b9e] text-white text-xs border-none rounded-sm gap-1",children:["Sort (A-Z) ",o.jsx(oq,{className:"h-3 w-3"})]})]}),o.jsx("div",{className:"space-y-1",children:i.files.length>0?i.files.map(s=>o.jsxs("div",{className:"flex items-center bg-gray-200/50 p-2 border border-gray-200 rounded-sm text-sm hover:bg-gray-200 transition-colors",children:[o.jsx("div",{className:"flex-shrink-0 mr-3",children:s.type==="image"?o.jsx(sC,{className:"h-5 w-5 text-[#2c7bb6]"}):o.jsx(zs,{className:"h-5 w-5 text-[#2c7bb6]"})}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx("div",{className:"font-medium text-gray-700 truncate",children:s.name})}),o.jsx("div",{className:"text-xs text-gray-500 mr-4 whitespace-nowrap",children:s.date}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{className:"p-1 text-gray-400 hover:text-gray-600 bg-white border border-gray-300 rounded-sm",children:o.jsx(zs,{className:"h-3 w-3"})}),o.jsx("button",{className:"p-1 text-gray-400 hover:text-gray-600 bg-white border border-gray-300 rounded-sm",children:o.jsx(Rp,{className:"h-3 w-3"})}),o.jsx("button",{className:"p-1 text-red-400 hover:text-red-600 bg-white border border-gray-300 rounded-sm",children:o.jsx(Qo,{className:"h-3 w-3"})})]})]},s.id)):o.jsx("div",{className:"p-4 border-2 border-dashed border-gray-300 rounded-sm text-center text-gray-400 text-sm",children:"No files in this subcategory"})})]})]},i.id)),a.subcategories.length===0&&o.jsx("div",{className:"p-2 text-sm text-gray-400 italic",children:"No subcategories"})]})]})]},a.id))})]})]})}const cve=[{id:1,title:"Coffee - 2 hrs",subtitle:"1 min - Completes at 12:05 PM",totalTime:7200,remainingTime:0,status:"expired",icon:Sq},{id:2,title:"Clean Tablet",subtitle:"1 hrs - Completes at 12:37 PM",totalTime:3600,remainingTime:237,status:"running",icon:u7},{id:3,title:"Replace Sanitizer Towels",subtitle:"1 hrs - Completes at 12:37 PM",totalTime:3600,remainingTime:238,status:"running",icon:zt},{id:4,title:"Take Out Trash",subtitle:"1 hrs - Completes at 01:03 PM",totalTime:3600,remainingTime:58,status:"running",icon:zt},{id:5,title:"Change Utensils",subtitle:"1 hrs - Completes at 01:03 PM",totalTime:3600,remainingTime:58,status:"running",icon:j7},{id:6,title:"Sanitize Surfaces",subtitle:"1 hrs - Completes at 02:00 PM",totalTime:3600,remainingTime:2157,status:"running",icon:Ex},{id:7,title:"Check Temperatures",subtitle:"1 hrs - Completes at 02:00 PM",totalTime:3600,remainingTime:2158,status:"running",icon:Ex},{id:8,title:"Ranch 4 hrs",subtitle:"4 hrs - Completes at 04:04 PM",totalTime:14400,remainingTime:2158,status:"running",icon:Ex}];function uve({timer:e}){const t=(e.totalTime-e.remainingTime)/e.totalTime*100,r=e.remainingTime===0,n=a=>{if(a<=0)return"0s";const i=Math.floor(a/60),s=a%60;return`${i.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`};return o.jsxs("div",{className:"bg-gray-200 rounded-xl p-4 flex flex-col items-center relative shadow-sm h-[280px]",children:[o.jsxs("div",{className:"text-center mb-2",children:[o.jsx("h3",{className:"text-lg font-medium text-gray-800 leading-tight",children:e.title}),o.jsx("p",{className:"text-xs text-gray-500 mt-1",children:e.subtitle})]}),o.jsxs("div",{className:"relative w-32 h-32 my-auto flex items-center justify-center",children:[o.jsxs("svg",{className:"w-full h-full transform -rotate-90",children:[o.jsx("circle",{cx:"64",cy:"64",r:"56",stroke:"white",strokeWidth:"12",fill:"transparent"}),o.jsx("circle",{cx:"64",cy:"64",r:"56",stroke:r?"#ef4444":"#3b82f6",strokeWidth:"12",fill:"transparent",strokeDasharray:351.86,strokeDashoffset:r?0:351.86*(t/100),className:"transition-all duration-1000 ease-linear"})]}),o.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[o.jsx("span",{className:ke("text-3xl font-bold",r?"text-red-500":"text-gray-800"),children:r?"0s":n(e.remainingTime)}),o.jsx("span",{className:ke("text-[10px] font-medium uppercase mt-1",r?"text-red-400":"text-gray-400"),children:"Remaining"})]})]}),o.jsxs("div",{className:"w-full flex justify-between items-end mt-2",children:[o.jsx(Yq,{className:"w-5 h-5 text-blue-700 fill-current"}),o.jsx("div",{className:"flex flex-col items-center",children:o.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-gray-300 flex items-center justify-center text-gray-400 mb-1",children:o.jsx(e.icon,{className:"w-5 h-5"})})}),o.jsx("div",{className:"flex flex-col items-end",children:o.jsx("span",{className:"text-xs text-blue-600 font-bold mb-2 cursor-pointer",children:"EDIT"})})]}),o.jsx("button",{className:"absolute bottom-12 right-4 bg-blue-600 rounded-full p-1 text-white hover:bg-blue-700 shadow-md",children:o.jsx(Qo,{className:"w-4 h-4"})})]})}function dve(){const[e,t]=v.useState(!0);return o.jsxs("div",{className:"h-full flex flex-col bg-gray-50 relative",children:[o.jsxs("div",{className:"bg-white border-b border-gray-200 px-4 py-3 flex items-center justify-between shadow-sm z-10",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("button",{className:"flex items-center text-blue-500 text-lg font-medium",children:[o.jsx(aC,{className:"w-6 h-6"}),"Back"]}),o.jsx(zq,{className:"w-6 h-6 text-gray-500"})]}),o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"bg-blue-600 p-1.5 rounded-md",children:o.jsx(h7,{className:"w-5 h-5 text-white"})}),o.jsx("h1",{className:"text-xl font-bold text-blue-900",children:"Timers"})]}),o.jsxs("div",{className:"flex items-center gap-1 text-xs text-green-600 font-medium",children:[o.jsx("span",{children:"86016"}),o.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"})]})]}),o.jsxs("div",{className:"flex items-center gap-4 text-blue-500 font-medium",children:[o.jsx(b7,{className:"w-6 h-6 text-gray-400"}),o.jsxs("button",{className:"flex items-center gap-1",children:[o.jsx(Un,{className:"w-5 h-5"}),"Add Timer"]})]})]}),o.jsxs("div",{className:"bg-gray-700 text-white px-6 py-2 flex items-center justify-between",children:[o.jsx("div",{className:"flex-1"})," ",o.jsx("div",{className:"font-medium",children:"Today, December 15"}),o.jsxs("div",{className:"flex-1 flex justify-end items-center gap-4",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Tq,{className:"w-5 h-5 text-gray-300"}),o.jsx(Rq,{className:"w-5 h-5 text-gray-500"})]}),o.jsx(eq,{className:"w-5 h-5 text-blue-400"})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:cve.map(r=>o.jsx(uve,{timer:r},r.id))})}),e&&o.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-[1px]",children:o.jsx("div",{className:"bg-black text-white rounded-xl shadow-2xl w-[600px] max-w-full overflow-hidden border border-gray-800",children:o.jsxs("div",{className:"p-8 text-center space-y-6",children:[o.jsx("h2",{className:"text-3xl font-medium text-blue-500",children:"Coffee - 2 hrs"}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsx("p",{className:"text-2xl font-light",children:"Timer expired at 12:05 PM"}),o.jsx("p",{className:"text-2xl font-light",children:"Please discard the coffee"})]}),o.jsx("div",{className:"flex justify-end",children:o.jsx("span",{className:"bg-gray-200 text-black text-[10px] px-1 rounded-sm opacity-50",children:"TACT_Img_Timer-Notification@2x"})}),o.jsxs("div",{className:"grid grid-cols-3 gap-4 mt-8",children:[o.jsx(de,{onClick:()=>t(!1),className:"bg-blue-700 hover:bg-blue-600 text-white h-14 text-xl font-medium rounded-lg",children:"Mute"}),o.jsx(de,{onClick:()=>t(!1),className:"bg-blue-600 hover:bg-blue-500 text-white h-14 text-xl font-medium rounded-lg",children:"Restart"}),o.jsx(de,{onClick:()=>t(!1),className:"bg-blue-800 hover:bg-blue-700 text-white h-14 text-xl font-medium rounded-lg",children:"Acknowledge"})]})]})})})]})}const tz=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),rz="/product-location";function fve(e){const t=e;return{id:t?.id??t?.Id,locationId:t?.locationId??t?.LocationId,productId:t?.productId??t?.ProductId}}async function hve(e,t){const r=await tz.requestJson({path:rz,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,LocationId:e.locationId,ProductId:e.productId},signal:t});return{...r,items:(r.items??[]).map(n=>fve(n))}}async function mve(e,t){const r=await tz.requestJson({path:`${rz}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Array.isArray(r?.productIds)?r.productIds.map(String):Array.isArray(r?.items)?(r.items??[]).map(n=>n?.productId).filter(n=>typeof n=="string"&&n.length>0):[]}function pve(e){const t=new Set,r=[];for(const n of e){const a=n.trim();!a||t.has(a)||(t.add(a),r.push(a))}return r}function gve({values:e,onValuesChange:t,options:r,placeholder:n="Select…",searchPlaceholder:a="Search…",emptyText:i="No matching results.",disabled:s,className:l}){const[d,c]=v.useState(!1),[f,h]=v.useState(""),p=v.useMemo(()=>pve(e),[e]),g=v.useMemo(()=>{const j=f.trim().toLowerCase();return j?r.filter(N=>N.label.toLowerCase().includes(j)||N.value.toLowerCase().includes(j)):r},[r,f]),x=v.useMemo(()=>{const j=new Map;for(const N of r)j.set(N.value,N.label);return j},[r]),b=v.useMemo(()=>{if(p.length===0)return null;if(p.length===1)return x.get(p[0])??p[0];const j=x.get(p[0])??p[0],N=x.get(p[1])??p[1];return p.length===2?`${j}, ${N}`:`${j}, ${N} +${p.length-2}`},[p,x]),w=j=>{const N=j.trim();N&&(p.includes(N)?t(p.filter(C=>C!==N)):t([...p,N]))};return o.jsxs(ka,{open:d,onOpenChange:j=>{c(j),j||h("")},children:[o.jsx(Aa,{asChild:!0,children:o.jsxs(de,{type:"button",variant:"outline",role:"combobox","aria-expanded":d,disabled:s,className:ke("h-auto min-h-10 w-full justify-between px-3 py-2 font-normal border border-gray-300 bg-white",l),children:[o.jsx("span",{className:ke("line-clamp-2 text-left text-sm",!b&&"text-gray-500"),children:b??n}),o.jsx(P$,{className:"ml-2 h-4 w-4 shrink-0 self-center opacity-50"})]})}),o.jsxs(Ia,{className:"w-[var(--radix-popover-trigger-width)] max-w-[min(100vw-2rem,400px)] p-0",align:"start",children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-100 px-2 py-2",children:[o.jsx(Rf,{className:"h-4 w-4 shrink-0 text-gray-400"}),o.jsx(me,{value:f,onChange:j=>h(j.target.value),placeholder:a,className:"h-8 border-0 bg-transparent px-0 text-sm shadow-none focus-visible:ring-0"})]}),o.jsx("div",{className:"max-h-[min(240px,50vh)] overflow-y-auto p-1",children:g.length===0?o.jsx("div",{className:"px-2 py-6 text-center text-sm text-gray-500",children:i}):g.map(j=>o.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-sm hover:bg-gray-100",children:[o.jsx(Co,{checked:p.includes(j.value),onCheckedChange:()=>w(j.value),onClick:N=>N.stopPropagation()}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label})]},j.value))}),p.length>0?o.jsx("div",{className:"border-t border-gray-100 px-2 py-1.5",children:o.jsxs("button",{type:"button",className:"text-xs text-gray-500 underline-offset-2 hover:text-gray-900 hover:underline",onClick:()=>{t([]),h("")},children:["Clear all (",p.length,")"]})}):null]})]})}const yve=".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";function n$(e){return!Number.isFinite(e)||e<0?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vve(e){const t=e?.[0];return!t||!t.name.toLowerCase().endsWith(".xlsx")?null:t}function uE({open:e,onOpenChange:t,title:r,description:n,onDownloadTemplate:a,onImportFile:i,downloadingTemplate:s=!1}){const l=v.useId(),d=v.useRef(null),[c,f]=v.useState(null),[h,p]=v.useState(!1),[g,x]=v.useState(!1),b=()=>{f(null),x(!1),d.current&&(d.current.value="")},w=()=>{f(null),d.current&&(d.current.value="")},j=v.useCallback(C=>{const O=vve(C);if(C?.length&&!O){ee.error("Invalid file",{description:"Please choose an .xlsx file."});return}f(O)},[]),N=()=>{window.setTimeout(()=>{const C=d.current;C&&(C.value="",C.click())},0)};return o.jsx(kt,{open:e,onOpenChange:C=>{C||b(),t(C)},children:o.jsxs(Ot,{className:ke("gap-4"),style:{padding:20,width:"min(50vw, calc(100vw - 2rem))",maxWidth:"min(50vw, calc(100vw - 2rem))"},children:[o.jsxs(At,{className:"space-y-1.5",children:[o.jsx(It,{className:"text-base",children:r}),n?o.jsx(qt,{className:"text-xs leading-relaxed",children:n}):null]}),o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{htmlFor:l,className:"text-sm",children:"Excel file (.xlsx)"}),o.jsx("input",{id:l,ref:d,type:"file",accept:yve,className:"sr-only",tabIndex:-1,"aria-label":"Choose Excel spreadsheet",onChange:C=>j(C.target.files)}),o.jsxs("button",{type:"button",className:ke("flex w-full flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed px-4 py-5 text-center transition-colors outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",g?"border-blue-400 bg-blue-50/80":"border-gray-300 bg-gray-50/90 hover:border-gray-400 hover:bg-gray-50"),onClick:N,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),N())},onDragEnter:C=>{C.preventDefault(),x(!0)},onDragOver:C=>{C.preventDefault(),C.dataTransfer.dropEffect="copy"},onDragLeave:C=>{C.preventDefault(),C.currentTarget.contains(C.relatedTarget)||x(!1)},onDrop:C=>{C.preventDefault(),x(!1),j(C.dataTransfer.files)},children:[o.jsx(k$,{className:"h-7 w-7 shrink-0 text-gray-400","aria-hidden":!0}),o.jsxs("div",{className:"text-sm text-gray-700",children:[o.jsx("span",{className:"font-medium text-blue-700",children:"Browse"}),o.jsx("span",{className:"text-gray-600",children:" or drop your file here"})]}),o.jsx("p",{className:"text-xs text-gray-500",children:c?"Click again to replace the file":"Only .xlsx is accepted"})]}),c?o.jsxs("div",{role:"status","aria-live":"polite",className:"flex items-center gap-3 rounded-lg border border-blue-200 bg-blue-50/60 px-3 py-2.5",children:[o.jsx(Eq,{className:"h-8 w-8 shrink-0 text-blue-600","aria-hidden":!0}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-blue-800",children:"Selected file"}),o.jsx("div",{className:"truncate text-sm font-semibold text-gray-900",title:c.name,children:c.name}),n$(c.size)?o.jsx("div",{className:"text-xs text-gray-600",children:n$(c.size)}):null]}),o.jsxs(de,{type:"button",variant:"outline",size:"sm",className:"shrink-0 border-gray-300 bg-white px-2 text-gray-700 hover:bg-gray-50",onClick:C=>{C.stopPropagation(),w()},"aria-label":"Remove selected file",children:[o.jsx(Qo,{className:"h-4 w-4","aria-hidden":!0}),o.jsx("span",{className:"ml-1 hidden sm:inline",children:"Remove"})]})]}):o.jsx("div",{className:"rounded-lg border border-dashed border-gray-200 bg-gray-50/50 px-3 py-2 text-center text-xs text-gray-500",children:"No file selected yet — use Browse or drag an .xlsx above"}),o.jsxs("p",{className:"text-xs text-gray-600",children:["After a file is selected, click ",o.jsx("span",{className:"font-medium text-gray-900",children:"Import"})," to upload it to the server."]})]}),o.jsx("div",{className:"flex justify-stretch sm:justify-center",children:o.jsx(de,{type:"button",variant:"outline",className:"w-full sm:w-auto",size:"sm",disabled:s,onClick:()=>void a(),children:s?"Downloading…":"Download template"})})]}),o.jsxs(Dt,{className:"gap-2 sm:gap-0",children:[o.jsx(de,{type:"button",variant:"outline",size:"sm",onClick:()=>{b(),t(!1)},children:"Cancel"}),o.jsx(de,{type:"button",size:"sm",className:"bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",disabled:!c||h,onClick:async()=>{if(c){p(!0);try{const C=await i(c);ee.success("Import finished",{description:`Success: ${C.successCount}, failed: ${C.failCount}`}),b(),t(!1)}catch(C){const O=C instanceof _r||C instanceof Error?C.message:"Import failed.";ee.error("Import failed",{description:O})}finally{p(!1)}}},children:h?"Importing…":"Import"})]})]})})}function xve(e){return!!(e??"").trim()}function bve(e,t){return{id:e.id,productCode:e.productCode??"",productName:(e.productName??"").trim(),categoryId:(e.categoryId??"").trim()||null,productImageUrl:e.productImageUrl??null,state:e.state!==!1,locationIds:[...t]}}function a$(e){return e.split(/[,;|\s]+/).map(t=>t.trim()).filter(Boolean)}function wve({seed:e,categories:t,onBack:r,onSaved:n}){const[a,i]=v.useState([]),[s,l]=v.useState(!1),[d,c]=v.useState([]);v.useEffect(()=>{const g=e.map(x=>bve(x,x.locationIds??[]));i(g),c(g.map(x=>x.locationIds&&x.locationIds.length?x.locationIds.join(","):""))},[e]);const f=(g,x)=>{i(b=>{const w=[...b];return w[g]={...w[g],...x},w})},h=(g,x)=>{const b=[...d];b[g]=x,c(b),f(g,{locationIds:a$(x)})},p=async()=>{const g=a.filter(x=>xve(x.id)).map((x,b)=>({id:x.id.trim(),productCode:String(x.productCode??"").trim()||null,productName:x.productName.trim(),categoryId:x.categoryId?.trim()?x.categoryId.trim():null,productImageUrl:x.productImageUrl?.trim()?x.productImageUrl.trim():null,state:x.state!==!1,locationIds:a$(d[b]??"")}));if(g.length===0){ee.error("No valid rows",{description:"Select products in the list first, then open Bulk Edit."});return}l(!0);try{const x=await lpe({items:g});ee.success("Bulk update finished",{description:`Success: ${x.successCount}, failed: ${x.failCount}`}),n(),r()}catch(x){const b=x instanceof _r||x instanceof Error?x.message:"Save failed.";ee.error("Bulk save failed",{description:b})}finally{l(!1)}};return o.jsxs("div",{className:"flex flex-col h-full min-h-0 bg-white",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-gray-200 shrink-0",children:[o.jsx(de,{type:"button",variant:"outline",onClick:r,children:"Back"}),o.jsx("h1",{className:"text-base font-semibold text-gray-900 flex-1 text-center truncate px-2",children:"Product bulk edit"}),o.jsx(de,{type:"button",className:"bg-green-600 hover:bg-green-700 text-white shrink-0",disabled:s,onClick:()=>void p(),children:s?"Saving…":"Save All"})]}),o.jsx("div",{className:"overflow-auto flex-1 min-h-0 px-2 py-3",children:o.jsxs("table",{className:"w-full text-xs border-collapse border border-gray-200",children:[o.jsx("thead",{className:"bg-gray-100 sticky top-0 z-10",children:o.jsxs("tr",{children:[o.jsx("th",{className:"border p-1 w-9 text-center text-gray-600 font-semibold",children:"#"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Product Code"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Product *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Category"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Image URL"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location IDs"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Active"})]})}),o.jsx("tbody",{children:a.map((g,x)=>o.jsxs("tr",{children:[o.jsx("td",{className:"border p-1 text-center align-middle text-gray-700 tabular-nums text-xs font-medium",children:x+1}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs",value:g.productCode??"",onChange:b=>f(x,{productCode:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[120px]",value:g.productName,onChange:b=>f(x,{productName:b.target.value})})}),o.jsx("td",{className:"border p-1 align-top min-w-[140px]",children:o.jsxs($e,{value:g.categoryId??"__none__",onValueChange:b=>f(x,{categoryId:b==="__none__"?null:b}),children:[o.jsx(Be,{className:"h-7 text-xs",children:o.jsx(Fe,{placeholder:"Category"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"__none__",children:"(none)"}),t.map(b=>o.jsx(we,{value:b.id,children:b.categoryName??b.id},b.id))]})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[140px]",value:g.productImageUrl??"",onChange:b=>f(x,{productImageUrl:b.target.value||null})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[160px]",value:d[x]??"",onChange:b=>h(x,b.target.value),placeholder:"id1,id2"})}),o.jsx("td",{className:"border p-1 text-center align-middle",children:o.jsx(br,{checked:g.state!==!1,onCheckedChange:b=>f(x,{state:!!b})})})]},`${g.id}-${x}`))})]})}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 text-center text-xs text-gray-500 shrink-0 space-y-1",children:[o.jsx("p",{children:"Only the products you selected in the list are shown here."}),o.jsx("p",{children:"Columns with * are required for saved rows."}),o.jsx("p",{children:"Location IDs: comma-separated location primary keys (GUID)."})]})]})}function Mn(e){const t=(e??"").trim();return t||"—"}async function Sve(e){const t=new Map;try{const r=await hve({skipCount:1,maxResultCount:2e3},e);for(const n of r.items??[]){const a=(n.productId??"").trim(),i=(n.locationId??"").trim();if(!a||!i)continue;t.has(a)||t.set(a,[]);const s=t.get(a);s.includes(i)||s.push(i)}}catch{}return t}function o$(e,t){const r=new Map(e);for(const n of t)Array.isArray(n.locationIds)&&r.set(n.id,[...new Set(n.locationIds.map(a=>String(a).trim()).filter(Boolean))]);return r}function jve(){const[e,t]=v.useState("products"),[r,n]=v.useState([]),[a,i]=v.useState(0),[s,l]=v.useState(!1),[d,c]=v.useState(new Map),[f,h]=v.useState([]),[p,g]=v.useState([]),[x,b]=v.useState(0),[w,j]=v.useState([]),[N,C]=v.useState(0),[O,P]=v.useState(!1),[E,T]=v.useState(1),[A,I]=v.useState(10),[R,L]=v.useState(0),V=v.useRef(null),[z,G]=v.useState(""),[H,W]=v.useState(""),q=v.useRef(null),[M,Y]=v.useState("all"),[F,D]=v.useState("all"),[$,K]=v.useState("all"),[J,oe]=v.useState(1),[re,Q]=v.useState(10),[ce,se]=v.useState(0),fe=v.useRef(null),[be,Z]=v.useState(!1),[Se,Ne]=v.useState(!1),[qe,De]=v.useState(null),[He,ne]=v.useState(null),[pe,_e]=v.useState(null),[ye,Ae]=v.useState(null),[Ge,ut]=v.useState(null),[Ce,tt]=v.useState(null),[ot,Nt]=v.useState(()=>new Set),[er,Ie]=v.useState(!1),[gt,_t]=v.useState(!1),[Qt,Pr]=v.useState([]),[Vn,Jr]=v.useState(!1),[qr,Or]=v.useState(!1);v.useEffect(()=>(q.current&&window.clearTimeout(q.current),q.current=window.setTimeout(()=>W(z.trim()),300),()=>{q.current&&window.clearTimeout(q.current)}),[z]),v.useEffect(()=>{let ve=!1;return(async()=>{try{const[Le,rt]=await Promise.all([Nu({skipCount:1,maxResultCount:500}),YN({skipCount:1,maxResultCount:500,sorting:"OrderNum desc"})]);if(ve)return;h(Le.items??[]),g(rt.items??[])}catch{ve||(h([]),g([]))}})(),()=>{ve=!0}},[x]);const Vt=()=>b(ve=>ve+1);v.useEffect(()=>{oe(1)},[H,M,F,$,re]),v.useEffect(()=>{T(1)},[H,$,A]);const gr=M!=="all"||F!=="all";v.useEffect(()=>e!=="products"?void 0:((async()=>{fe.current?.abort();const Le=new AbortController;fe.current=Le,l(!0);try{const rt=await Sve(Le.signal);if(Le.signal.aborted)return;if(gr){const Xt=await iy({skipCount:1,maxResultCount:500,keyword:H||void 0,state:$==="all"?void 0:$==="true"},Le.signal);if(Le.signal.aborted)return;let xt=Xt.items??[];if(M!=="all"){const Mr=new Set(await mve(M));xt=xt.filter(Ao=>Mr.has(Ao.id))}F!=="all"&&(xt=xt.filter(Mr=>(Mr.categoryId??"").trim()===F));const hr=xt.length;i(hr);const Qr=(J-1)*re;n(xt.slice(Qr,Qr+re)),c(o$(rt,xt))}else{const Xt=Qa(J),xt=await iy({skipCount:Xt,maxResultCount:re,keyword:H||void 0,state:$==="all"?void 0:$==="true"},Le.signal);if(Le.signal.aborted)return;const hr=xt.items??[];n(hr),i(xt.totalCount??0),c(o$(rt,hr))}}catch(rt){if(rt?.name==="AbortError")return;ee.error("Failed to load products",{description:rt?.message?String(rt.message):"Please try again."}),n([]),i(0)}finally{Le.signal.aborted||l(!1)}})(),()=>fe.current?.abort()),[e,H,M,F,$,J,re,ce,gr]);const Kt=Math.max(1,Math.ceil(N/A)||1);v.useEffect(()=>{T(ve=>{const Le=Math.max(1,Math.ceil(N/A)||1);return ve>Le?Le:ve})},[N,A]),v.useEffect(()=>e!=="categories"?void 0:((async()=>{V.current?.abort();const Le=new AbortController;V.current=Le,P(!0);try{const rt=Qa(E),Xt=await YN({skipCount:rt,maxResultCount:A,sorting:"OrderNum desc",keyword:H||void 0,state:$==="all"?void 0:$==="true"},Le.signal);if(Le.signal.aborted)return;j(Xt.items??[]),C(Xt.totalCount??0)}catch(rt){if(rt?.name==="AbortError")return;ee.error("Failed to load categories",{description:rt?.message?String(rt.message):"Please try again."}),j([]),C(0)}finally{Le.signal.aborted||P(!1)}})(),()=>V.current?.abort()),[e,H,$,E,A,R]);const fr=()=>se(ve=>ve+1);v.useEffect(()=>{Nt(new Set)},[H,M,F,$,J]);const tr=()=>{L(ve=>ve+1),Vt()};v.useEffect(()=>{e!=="products"&&_t(!1)},[e]);const Je=v.useMemo(()=>f.map(ve=>({value:ve.id,label:Mn(ve.locationName??ve.locationCode??ve.id)})),[f]),Et=v.useMemo(()=>p.map(ve=>({value:(ve.id??"").trim(),label:Mn(ve.categoryName??ve.categoryCode??ve.id)})).filter(ve=>ve.value),[p]),Lt=Math.max(1,Math.ceil(a/re)),sr=v.useCallback(ve=>{const Le=f.find(rt=>rt.id===ve);return Mn(Le?.locationName??Le?.locationCode??ve)},[f]);return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:ke("pb-4",gt&&"hidden"),children:[o.jsx("div",{className:"flex flex-col gap-3",children:o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsxs("div",{className:"flex items-center w-40 shrink-0 rounded-md border border-gray-300 bg-white overflow-hidden",style:{height:40},children:[o.jsx(Rf,{className:"h-4 w-4 text-gray-400 shrink-0 ml-2.5 pointer-events-none"}),o.jsx(me,{placeholder:"Search...",value:z,onChange:ve=>G(ve.target.value),className:"flex-1 min-w-0 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 py-2 px-2 h-full placeholder:text-gray-500"})]}),o.jsxs($e,{value:"all",disabled:!0,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0 opacity-70",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Partner"})}),o.jsx(ze,{children:o.jsx(we,{value:"all",children:"All partners"})})]}),o.jsxs($e,{value:"all",disabled:!0,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0 opacity-70",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Group"})}),o.jsx(ze,{children:o.jsx(we,{value:"all",children:"All groups"})})]}),o.jsxs($e,{value:M,onValueChange:Y,children:[o.jsx(Be,{className:"w-[160px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All Locations"}),f.map(ve=>o.jsx(we,{value:ve.id,children:Mn(ve.locationName??ve.locationCode??ve.id)},ve.id))]})]}),o.jsxs($e,{value:F,onValueChange:D,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Category"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All Categories"}),Et.map(ve=>o.jsx(we,{value:ve.value,children:ve.label},ve.value))]})]}),o.jsxs($e,{value:$,onValueChange:K,children:[o.jsx(Be,{className:"w-[120px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"State"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All states"}),o.jsx(we,{value:"true",children:"Active"}),o.jsx(we,{value:"false",children:"Inactive"})]})]})]})}),o.jsx("div",{className:"w-full border-b border-gray-200 mt-4",children:o.jsxs("div",{className:"flex overflow-x-auto w-fit",children:[o.jsx("button",{type:"button",onClick:()=>t("products"),style:e==="products"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:`px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2 ${e==="products"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"}`,children:"Products"}),o.jsx("button",{type:"button",onClick:()=>t("categories"),style:e==="categories"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:`px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2 ${e==="categories"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"}`,children:"Categories"})]})})]}),o.jsx("div",{className:"flex-1 overflow-auto pt-6 flex flex-col min-h-0",children:gt?o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md flex-1 flex flex-col min-h-0 overflow-hidden max-h-full",children:o.jsx(wve,{seed:Qt,categories:p,onBack:()=>{_t(!1),Pr([])},onSaved:()=>{Nt(new Set),fr()}})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-nowrap items-center justify-end gap-3 min-w-0 overflow-x-auto pb-0.5 mb-3 shrink-0 [scrollbar-width:thin]",children:[e==="products"&&o.jsxs(o.Fragment,{children:[o.jsxs(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",onClick:()=>Ie(!0),children:[o.jsx(k$,{className:"w-4 h-4"})," Bulk Import"]}),o.jsxs(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",disabled:qr,onClick:async()=>{Or(!0);try{await ipe({keyword:H||void 0,state:$==="all"?void 0:$==="true"}),ee.success("Export started",{description:"Your browser should download the Excel file."})}catch(ve){const Le=ve instanceof Error?ve.message:"Please try again.";ee.error("Export failed",{description:Le})}finally{Or(!1)}},children:[o.jsx(oC,{className:"w-4 h-4"})," ",qr?"Exporting…":"Bulk Export"]}),o.jsxs(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",onClick:()=>{const ve=r.filter(Le=>ot.has(Le.id)).map(Le=>({...Le,locationIds:d.get(Le.id)??Le.locationIds??[]}));if(ve.length===0){ee.error("No rows selected",{description:"Use the checkboxes on the left, then open Bulk Edit."});return}Pr(ve),_t(!0)},children:[o.jsx(oa,{className:"w-4 h-4"})," Bulk Edit"]})]}),e==="products"?o.jsxs(de,{className:"h-10 rounded-md bg-blue-600 text-white hover:bg-blue-700 font-medium gap-1 shrink-0",onClick:()=>{Ae(null),Z(!0)},children:["New Product ",o.jsx(Un,{className:"w-4 h-4"})]}):o.jsxs(de,{className:"h-10 rounded-md bg-blue-600 text-white hover:bg-blue-700 font-medium gap-1 shrink-0",onClick:()=>{De(null),Ne(!0)},children:["New Category ",o.jsx(Un,{className:"w-4 h-4"})]})]}),e==="products"?o.jsxs("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r w-12 shrink-0 text-center whitespace-nowrap px-3",children:o.jsx(Co,{checked:r.length>0&&r.every(ve=>ot.has(ve.id)),onCheckedChange:ve=>{Nt(ve===!0?new Set(r.map(Le=>Le.id)):new Set)},"aria-label":"Select all on page"})}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Location"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product Category"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product ID"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Product Code"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Status"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center whitespace-nowrap",children:"Actions"})]})}),o.jsx(pn,{children:s?o.jsx(nt,{children:o.jsx(xe,{colSpan:8,className:"text-center text-gray-500 py-10",children:"Loading..."})}):r.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:8,className:"text-center text-gray-500 py-10",children:"No products found."})}):r.map(ve=>{const Le=d.get(ve.id)??[],rt=Le.length===0?"—":Le.map(xt=>sr(xt)).join(", "),Xt=ve.state!==!1;return o.jsxs(nt,{children:[o.jsx(xe,{className:"border-r w-12 shrink-0 text-center px-3",children:o.jsx(Co,{checked:ot.has(ve.id),onCheckedChange:xt=>{Nt(hr=>{const Qr=new Set(hr);return xt===!0?Qr.add(ve.id):Qr.delete(ve.id),Qr})},"aria-label":"Select row"})}),o.jsx(xe,{className:"border-r text-sm max-w-[200px] truncate",title:rt,children:rt}),o.jsx(xe,{className:"border-r text-gray-900 font-medium whitespace-nowrap",children:Mn(ve.categoryName)}),o.jsx(xe,{className:"border-r text-gray-900 font-medium",children:o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[ve.productImageUrl?o.jsx("img",{src:Tf(ve.productImageUrl),alt:"",className:"w-8 h-8 rounded object-cover border border-gray-200 shrink-0"}):o.jsx(Sc,{className:"w-4 h-4 text-gray-400 shrink-0"}),o.jsx("span",{className:"truncate",children:Mn(ve.productName)})]})}),o.jsx(xe,{className:"border-r font-mono text-sm text-gray-600 whitespace-nowrap",children:ve.id}),o.jsx(xe,{className:"border-r font-mono text-sm text-gray-600 whitespace-nowrap",children:Mn(ve.productCode)}),o.jsx(xe,{className:"border-r whitespace-nowrap",children:o.jsx(fn,{variant:Xt?"default":"secondary",className:Xt?"bg-green-600":"bg-gray-400",children:Xt?"active":"inactive"})}),o.jsx(xe,{className:"text-center whitespace-nowrap",children:o.jsxs(ka,{open:Ce===ve.id,onOpenChange:xt=>tt(xt?ve.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",children:o.jsx(ni,{className:"h-4 w-4"})})}),o.jsxs(Ia,{align:"end",className:"w-36 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start h-9 px-2 font-normal",onClick:async()=>{tt(null);try{const xt=await G8(ve.id);Ae(xt),Z(!0)}catch(xt){ee.error("Failed to load product",{description:xt?.message?String(xt.message):""})}},children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>{tt(null),ut(ve)},children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},ve.id)})})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-2 text-sm text-gray-600 border-t border-gray-100",children:[o.jsx("span",{children:a===0?"Showing 0 of 0":`Showing ${(J-1)*re+1}–${Math.min(J*re,a)} of ${a}`}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs($e,{value:String(re),onValueChange:ve=>Q(Number(ve)),children:[o.jsx(Be,{className:"w-[100px] h-9",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ve=>o.jsxs(we,{value:String(ve),children:[ve," / page"]},ve))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{className:J<=1?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>J>1&&oe(ve=>Math.max(1,ve-1)),"aria-disabled":J<=1})}),o.jsx(St,{children:o.jsxs(Cn,{className:"cursor-default",size:"default",isActive:!0,onClick:ve=>ve.preventDefault(),children:["Page ",J," / ",Lt]})}),o.jsx(St,{children:o.jsx(ca,{className:J>=Lt?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>JMath.min(Lt,ve+1)),"aria-disabled":J>=Lt})})]})})]})]})]}):o.jsxs("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Category Name"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Code"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Photo"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Order"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Status"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r whitespace-nowrap",children:"Last edited"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center whitespace-nowrap w-[72px]",children:"Actions"})]})}),o.jsx(pn,{children:O?o.jsx(nt,{children:o.jsx(xe,{colSpan:7,className:"text-center text-gray-500 py-10",children:"Loading..."})}):w.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:7,className:"text-center text-gray-500 py-10",children:"No categories found."})}):w.map(ve=>{const Le=ve.state!==!1,rt=I8({buttonStyleJson:ve.buttonStyleJson,buttonAppearance:ve.buttonAppearance,displayText:ve.displayText,buttonBgColor:ve.buttonBgColor,buttonImageUrl:ve.buttonImageUrl,buttonTextColor:ve.buttonTextColor,categoryPhotoUrl:ve.categoryPhotoUrl,categoryName:ve.categoryName});return o.jsxs(nt,{children:[o.jsx(xe,{className:"border-r font-medium text-gray-900",children:Mn(ve.categoryName)}),o.jsx(xe,{className:"border-r text-gray-600 font-mono text-sm",children:Mn(ve.categoryCode)}),o.jsx(xe,{className:"border-r",children:rt.mode==="image"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 overflow-hidden shadow-sm bg-gray-50",children:o.jsx("img",{src:Tf(rt.imageUrl),alt:"",className:"w-full h-full object-cover"})}):rt.mode==="colorText"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 shadow-sm flex items-center justify-center px-1 overflow-hidden",style:{backgroundColor:rt.bg,color:rt.textColor||"#ffffff"},title:`${rt.text}`,children:o.jsx("span",{className:"text-[10px] font-bold leading-tight text-center line-clamp-2 break-all",children:rt.text})}):rt.mode==="color"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 shadow-sm",style:{backgroundColor:rt.bg},title:rt.bg}):rt.mode==="text"?o.jsx("div",{className:"w-10 h-10 rounded-[12px] border border-gray-200 shadow-sm bg-gray-50 flex items-center justify-center px-1 overflow-hidden",title:rt.text,children:o.jsx("span",{className:"text-[10px] font-bold text-gray-800 text-center line-clamp-2 break-all",children:rt.text})}):o.jsx("span",{className:"text-gray-400 text-sm",children:"—"})}),o.jsx(xe,{className:"border-r text-gray-700",children:ve.orderNum??"—"}),o.jsx(xe,{className:"border-r whitespace-nowrap",children:o.jsx(fn,{variant:Le?"default":"secondary",className:Le?"bg-green-600":"bg-gray-400",children:Le?"active":"inactive"})}),o.jsx(xe,{className:"border-r text-gray-600 text-sm",children:Mn(ve.lastEdited)}),o.jsx(xe,{className:"text-center whitespace-nowrap",children:o.jsxs(ka,{open:pe===ve.id,onOpenChange:Xt=>_e(Xt?ve.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",children:o.jsx(ni,{className:"h-4 w-4"})})}),o.jsxs(Ia,{align:"end",className:"w-36 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start h-9 px-2 font-normal",onClick:async()=>{_e(null);try{const Xt=await cpe(ve.id);De(Xt),Ne(!0)}catch(Xt){ee.error("Failed to load category",{description:Xt?.message?String(Xt.message):""})}},children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>{_e(null),ne(ve)},children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},ve.id)})})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3 shrink-0",children:[o.jsx("div",{className:"text-sm text-gray-600",children:N===0?"Showing 0 of 0":`Showing ${(E-1)*A+1}–${Math.min(E*A,N)} of ${N}`}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(A),onValueChange:ve=>I(Number(ve)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ve=>o.jsxs(we,{value:String(ve),children:[ve," / page"]},ve))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:ve=>{ve.preventDefault(),T(Le=>Math.max(1,Le-1))},"aria-disabled":E<=1,className:E<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ve=>ve.preventDefault(),children:["Page ",E," / ",Kt]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:ve=>{ve.preventDefault(),T(Le=>Math.min(Kt,Le+1))},"aria-disabled":E>=Kt,className:E>=Kt?"pointer-events-none opacity-50":""})})]})})]})]})]})]})}),o.jsx(Nve,{open:be,onOpenChange:ve=>{Z(ve),ve||Ae(null)},editing:ye,locationOptions:Je,categoryOptions:Et,locationMap:d,onSaved:()=>{fr(),Z(!1),Ae(null)}}),o.jsx(Cve,{open:!!Ge,product:Ge,onOpenChange:ve=>{ve||ut(null)},onDeleted:fr}),o.jsx(uE,{open:er,onOpenChange:Ie,title:"Bulk import products",description:"Upload an .xlsx file. Use the official template for column headers.",downloadingTemplate:Vn,onDownloadTemplate:async()=>{Jr(!0);try{await ope(),ee.success("Template downloaded.")}catch(ve){const Le=ve instanceof Error?ve.message:"Download failed.";ee.error("Template download failed",{description:Le})}finally{Jr(!1)}},onImportFile:async ve=>{const Le=await spe(ve);return fr(),Vt(),{successCount:Le.successCount,failCount:Le.failCount}}}),o.jsx(_ve,{open:Se,category:qe,locations:f,onOpenChange:ve=>{Ne(ve),ve||De(null)},onSaved:()=>{tr(),Ne(!1),De(null)}}),o.jsx(Eve,{open:!!He,category:He,onOpenChange:ve=>{ve||ne(null)},onDeleted:tr})]})}function Nve({open:e,onOpenChange:t,editing:r,locationOptions:n,categoryOptions:a,locationMap:i,onSaved:s}){const[l,d]=v.useState(!1),[c,f]=v.useState(""),[h,p]=v.useState(""),[g,x]=v.useState(""),[b,w]=v.useState(""),[j,N]=v.useState(!0),[C,O]=v.useState([]);v.useEffect(()=>{if(e)if(r){f(r.productCode??""),p(r.productName??""),x((r.categoryId??"").trim()),w(r.productImageUrl??""),N(r.state!==!1);const E=r.locationIds,T=i.get(r.id)??[],A=Array.isArray(E)?[...new Set(E.map(I=>String(I).trim()).filter(Boolean))]:[...new Set(T.map(I=>String(I).trim()).filter(Boolean))];O(A)}else f(""),p(""),x(""),w(""),N(!0),O([])},[e,r,i]);const P=async()=>{if(!h.trim()){ee.error("Validation",{description:"Product name is required."});return}const E=[...new Set(C.map(A=>String(A).trim()).filter(Boolean))];if(E.length===0){ee.error("Validation",{description:"Select at least one store to bind this product."});return}const T={productCode:c.trim()||null,productName:h.trim(),categoryId:g.trim()||null,productImageUrl:b.trim()||null,state:j,locationIds:E};d(!0);try{r?await npe(r.id,T):await rpe(T),ee.success(r?"Product updated.":"Product created."),s()}catch(A){ee.error(r?"Update failed":"Create failed",{description:A?.message?String(A.message):""})}finally{d(!1)}};return o.jsx(kt,{open:e,onOpenChange:t,children:o.jsxs(Ot,{className:"w-[min(50%,calc(100vw-2rem))] max-w-none sm:max-w-none max-h-[90vh] overflow-y-auto",children:[o.jsxs(At,{children:[o.jsx(It,{children:r?"Edit Product":"Add New Product"}),o.jsx(qt,{children:r?"Update product and store bindings.":"Create a product and bind it to one or more stores."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Product code"}),o.jsx(me,{className:"h-10",value:c,onChange:E=>f(E.target.value),placeholder:"e.g. PRD_TEST_001"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Product name *"}),o.jsx(me,{className:"h-10",value:h,onChange:E=>p(E.target.value),placeholder:"e.g. Chicken"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category"}),o.jsx($n,{value:g,onValueChange:x,options:a,placeholder:"Select category (optional)",searchPlaceholder:"Search category…",emptyText:"No categories."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Product image"}),o.jsx(_u,{value:b,onChange:w,uploadSubDir:"product",oneImageOnly:!0,hint:"POST /api/app/picture/category/upload (subDir: product). JPG/PNG/WebP/GIF, max 5 MB."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Bind to stores *"}),o.jsx(gve,{values:C,onValuesChange:O,options:n,placeholder:"Select one or more locations",searchPlaceholder:"Search location…",emptyText:"No locations."})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 h-10 bg-white",children:[o.jsx("span",{className:"text-sm font-medium",children:"Enabled"}),o.jsx(br,{checked:j,onCheckedChange:N})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(de,{type:"button",disabled:l,onClick:P,className:"bg-blue-600 hover:bg-blue-700 text-white",children:l?"Saving…":r?"Save":"Create"})]})]})})}function Cve({open:e,product:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=async()=>{if(t?.id){i(!0);try{await ape(t.id),ee.success("Product deleted."),r(!1),n()}catch(l){ee.error("Delete failed",{description:l?.message?String(l.message):""})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-md",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete product"}),o.jsx(qt,{children:"This cannot be undone."})]}),o.jsxs("p",{className:"text-sm text-gray-700 py-2",children:["Delete ",o.jsx("span",{className:"font-medium",children:Mn(t?.productName)})," (",Mn(t?.productCode),")?"]}),o.jsxs(Dt,{children:[o.jsx(de,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{type:"button",variant:"destructive",className:"gap-2",disabled:a,onClick:s,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting…":"Delete"]})]})]})})}function _ve({open:e,category:t,locations:r,onOpenChange:n,onSaved:a}){const i=!!t?.id,[s,l]=v.useState(!1),[d,c]=v.useState(""),[f,h]=v.useState(""),[p,g]=v.useState(""),[x,b]=v.useState(""),[w,j]=v.useState({text:!0,color:!1,image:!1}),[N,C]=v.useState(""),[O,P]=v.useState(""),[E,T]=v.useState("0"),[A,I]=v.useState(!0),R=v.useMemo(()=>{const z=[];return w.text&&z.push("TEXT"),w.color&&z.push("COLOR"),z},[w.text,w.color]);v.useEffect(()=>{if(e)if(t){c(t.categoryCode??""),h(t.categoryName??""),g(t.categoryPhotoUrl??"");{const z=ay(t.buttonStyleJson);if(z)j(xc(z.appearances)),b(z.displayText??""),C(z.buttonBgColor??""),P(z.buttonImageUrl??"");else{const G=tl(t.buttonAppearance),H=G_(t.categoryPhotoUrl);if(H&&G.length>0&&G.length===H.length){const W=Y_(G,H,{categoryName:t.categoryName,name:void 0,buttonTextColor:t.buttonTextColor});j(xc(G)),b(W.displayText??""),C(W.buttonBgColor??""),P(W.buttonImageUrl??"")}else{b(t.displayText??"");const W=tl(t.buttonAppearance);if(W.length===0){const q=X_({buttonAppearance:t.buttonAppearance,displayText:t.displayText,buttonBgColor:t.buttonBgColor,buttonImageUrl:t.buttonImageUrl,buttonTextColor:t.buttonTextColor,categoryPhotoUrl:t.categoryPhotoUrl,categoryName:t.categoryName});q.mode==="image"?j({text:!1,color:!1,image:!0}):q.mode==="colorText"?j({text:!0,color:!0,image:!1}):q.mode==="color"?j({text:!1,color:!0,image:!1}):q.mode==="text"?j({text:!0,color:!1,image:!1}):j({text:!0,color:!1,image:!1})}else j(xc(W));C(t.buttonBgColor??""),P(t.buttonImageUrl??"")}}}T(t.orderNum===null||t.orderNum===void 0?"0":String(t.orderNum)),I(t.state!==!1)}else c(""),h(""),g(""),b(""),j({text:!0,color:!1,image:!1}),C(""),P(""),T("0"),I(!0)},[e,t]);const L=v.useMemo(()=>["#111827","#374151","#6B7280","#EF4444","#F59E0B","#10B981","#3B82F6","#8B5CF6","#EC4899"],[]),V=async()=>{if(!f.trim()){ee.error("Validation",{description:"Category name is required."});return}const z=Number(E);if(!Number.isFinite(z)){ee.error("Validation",{description:"Order must be a number."});return}const G=W_(w);if(G.length===0){ee.error("Validation",{description:"Select at least one button appearance (Text, Color, or Image)."});return}if(G[0]==="IMAGE"){if(!O.trim()){ee.error("Validation",{description:"Please upload/select an image for Image appearance."});return}}else{if(w.text&&!x.trim()){ee.error("Validation",{description:"Please enter display text for Text appearance."});return}if(w.color&&!N.trim()){ee.error("Validation",{description:"Please select a background color for Color appearance."});return}}const H=K_(G,{displayText:x.trim(),buttonBgColor:N.trim(),buttonImageUrl:O.trim()}),W=w.image?null:(()=>{const Y=(t?.buttonTextColor??"").trim();return Y||(ay(t?.buttonStyleJson??null)?.buttonTextColor??"").trim()||null})(),q=H_({appearances:G,displayText:x.trim()||null,buttonBgColor:w.image?null:N.trim()||null,buttonTextColor:W,buttonImageUrl:w.image&&O.trim()||null}),M={categoryCode:d.trim()||null,categoryName:f.trim(),categoryPhotoUrl:H,displayText:x.trim()||null,buttonAppearance:G,buttonTextColor:W,buttonBgColor:N.trim()||null,buttonImageUrl:O.trim()||null,buttonStyleJson:q,availabilityType:"ALL",locationIds:[],state:A,orderNum:z};l(!0);try{i&&t?.id?(await dpe(t.id,M),ee.success("Category updated.")):(await upe(M),ee.success("Category created.")),a()}catch(Y){ee.error(i?"Update failed":"Create failed",{description:Y?.message?String(Y.message):""})}finally{l(!1)}};return o.jsx(kt,{open:e,onOpenChange:n,children:o.jsxs(Ot,{className:"w-[min(50%,calc(100vw-2rem))] max-w-none sm:max-w-none max-h-[90vh] overflow-y-auto",children:[o.jsxs(At,{children:[o.jsx(It,{children:i?"Edit Category":"New Category"}),o.jsx(qt,{children:i?"Update product category (API: /api/app/product-category).":"Create a product category."})]}),o.jsxs("div",{className:"grid gap-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category code"}),o.jsx(me,{className:"h-10",value:d,onChange:z=>c(z.target.value),placeholder:"e.g. CAT_PREP"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Category name *"}),o.jsx(me,{className:"h-10",value:f,onChange:z=>h(z.target.value),placeholder:"e.g. Prep"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Button Appearance"}),o.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-gray-100 p-3 space-y-3",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Text & Color — can combine"}),o.jsxs(ou,{type:"multiple",value:R,onValueChange:z=>{const G=z??[];j(H=>({...H,text:G.includes("TEXT"),color:G.includes("COLOR"),image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent gap-1 flex-wrap justify-stretch",children:[o.jsx(ri,{value:"TEXT",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",w.text&&!w.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"text-lg leading-none",children:"T"}),"Text"]})}),o.jsx(ri,{value:"COLOR",className:["flex-1 min-w-[100px] gap-2 h-10 rounded-full","border border-transparent",w.color&&!w.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center gap-2",children:[o.jsx("span",{className:"text-lg leading-none",children:"🎨"}),"Color"]})})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-xs text-gray-600",children:"Image — exclusive (clears Text & Color)"}),o.jsx(ou,{type:"single",value:w.image?"IMAGE":"",onValueChange:z=>{const G=String(z||"").toUpperCase();j(G==="IMAGE"?{text:!1,color:!1,image:!0}:H=>({...H,image:!1}))},variant:"outline",size:"sm",className:"w-full bg-transparent",children:o.jsx(ri,{value:"IMAGE",className:["w-full gap-2 h-10 rounded-full","border border-transparent",w.image?"!bg-white !border-gray-300 !text-gray-900 shadow-sm":"bg-transparent text-gray-700 opacity-90"].join(" "),children:o.jsxs("span",{className:"font-medium flex items-center justify-center gap-2",children:[o.jsx("span",{className:"text-lg leading-none",children:"🖼"}),"Image"]})})})]})]})]}),w.text&&!w.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Display Text"}),o.jsx(me,{className:"h-10",value:x,onChange:z=>b(z.target.value),placeholder:"Category Name"}),o.jsxs("div",{className:"text-xs text-gray-500",children:["Saved to ",o.jsx("span",{className:"font-mono",children:"photo"})," as this text."]})]}):null,w.color&&!w.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Select Color"}),o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[L.map(z=>o.jsx("button",{type:"button",className:["h-10 w-10 rounded-full border border-gray-200 shadow-sm",N.toLowerCase()===z.toLowerCase()?"ring-2 ring-blue-500 ring-offset-2":""].join(" "),style:{backgroundColor:z},onClick:()=>C(z),"aria-label":`Select ${z}`},z)),o.jsx("button",{type:"button",className:"h-10 w-10 rounded-full border border-dashed border-gray-300 bg-white text-gray-500 hover:text-gray-700 hover:border-gray-400 flex items-center justify-center",onClick:()=>{document.getElementById("product-category-custom-color")?.click()},"aria-label":"Custom color",children:"+"}),o.jsx("input",{id:"product-category-custom-color",type:"color",value:N||"#3B82F6",onChange:z=>C(z.target.value),className:"h-0 w-0 opacity-0 pointer-events-none","aria-label":"Custom color picker"})]})]}):null,w.image?o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Button Image"}),o.jsx(_u,{value:O,onChange:P,uploadSubDir:"category",oneImageOnly:!0,hint:"One image only. Replace or clear to change. JPG, PNG, WebP, or GIF — max 5 MB. Saved as CategoryPhotoUrl."})]}):null,o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{className:"h-10",type:"number",value:E,onChange:z=>T(z.target.value),placeholder:"0"})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 h-10 bg-white",children:[o.jsx("span",{className:"text-sm font-medium",children:"Enabled"}),o.jsx(br,{checked:A,onCheckedChange:I})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{type:"button",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),o.jsx(de,{type:"button",disabled:s,onClick:V,className:"bg-blue-600 hover:bg-blue-700 text-white",children:s?"Saving…":i?"Save":"Create"})]})]})})}function Eve({open:e,category:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=async()=>{if(t?.id){i(!0);try{await fpe(t.id),ee.success("Category deleted."),r(!1),n()}catch(l){ee.error("Delete failed",{description:l?.message?String(l.message):""})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-md",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete category"}),o.jsx(qt,{children:"This cannot be undone."})]}),o.jsxs("p",{className:"text-sm text-gray-700 py-2",children:["Delete ",o.jsx("span",{className:"font-medium",children:Mn(t?.categoryName)})," (",Mn(t?.categoryCode),")?"]}),o.jsxs(Dt,{children:[o.jsx(de,{type:"button",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{type:"button",variant:"destructive",className:"gap-2",disabled:a,onClick:s,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting…":"Delete"]})]})]})})}const lh=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),ch="/rbac-menu";function Af(e){if(!e||typeof e!="object")return{id:""};const t=e,r=t.router??t.Router,n=t.routeUrl??t.RouteUrl??r;return{id:String(t.id??t.Id??""),orderNum:t.orderNum??t.OrderNum,state:t.state??t.State,menuName:t.menuName??t.MenuName,routerName:t.routerName??t.RouterName,router:r,menuType:t.menuType??t.MenuType,permissionCode:t.permissionCode??t.PermissionCode,parentId:t.parentId??t.ParentId,menuIcon:t.menuIcon??t.MenuIcon,routeUrl:n,link:t.link??t.Link,isCache:t.isCache??t.IsCache,isShow:t.isShow??t.IsShow,remark:t.remark??t.Remark,component:t.component??t.Component,menuSource:t.menuSource??t.MenuSource,query:t.query??t.Query,concurrencyStamp:t.concurrencyStamp??t.ConcurrencyStamp}}function Pve(e){if(Array.isArray(e))return{items:e.map(Af),totalCount:e.length};const t=e,r=t.items??t.Items??[],n=typeof t.totalCount=="number"?t.totalCount:typeof t.TotalCount=="number"?t.TotalCount:r.length;return{items:r.map(Af),totalCount:n}}async function nz(e,t){const r=await lh.requestJson({path:ch,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword},signal:t});return Pve(r)}function QN(e){const t=Af(e),r=e,n=r?.children??r?.Children,a=Array.isArray(n)?n.map(QN):void 0;return{...t,children:a}}function Ove(e){if(Array.isArray(e))return e.map(QN);if(!e||typeof e!="object")return[];const t=e,r=t.items??t.Items??t.data??t.Data;return Array.isArray(r)?r.map(QN):[]}async function Tve(e){const t=await lh.requestJson({path:`${ch}/tree`,method:"GET",signal:e});return Ove(t)}async function kve(e){const t=new Map;let r=1;const n=500;for(;;){const i=(await nz({skipCount:r,maxResultCount:n},e)).items??[];for(const s of i)s.menuType!==0||!s.id||t.has(s.id)||t.set(s.id,s);if(i.length100))break}return Array.from(t.values()).sort((a,i)=>(a.orderNum??0)-(i.orderNum??0))}async function Ave(e){const t=await lh.requestJson({path:ch,method:"POST",body:e});return Af(t)}async function Ive(e,t){const r=await lh.requestJson({path:`${ch}/${encodeURIComponent(e)}`,method:"PUT",body:t});return Af(r)}async function Mve(e){e.length&&await lh.requestJson({path:ch,method:"DELETE",body:e})}async function Rve(e){await Mve([e])}const az=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),oz="/rbac-role-menu";async function Dve(e){await az.requestJson({path:`${oz}/set`,method:"POST",body:e})}async function Lve(e){await az.requestJson({path:oz,method:"DELETE",body:e})}const $ve=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Fve="/role";async function dE(e,t){return $ve.requestJson({path:Fve,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,RoleName:e.roleName,RoleCode:e.roleCode,State:e.state},signal:t})}const Av=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),Iv="/rbac-role";async function Bve(e){return Av.requestJson({path:Iv,method:"POST",body:e})}async function zve(e,t){return Av.requestJson({path:`${Iv}/${encodeURIComponent(e)}`,method:"PUT",body:t})}function Uve(e){if(!e||typeof e!="object")return[];const t=e,r=Array.isArray(t.menuIds)?t.menuIds:Array.isArray(t.MenuIds)?t.MenuIds:void 0;if(r)return r.map(String);const n=t.data??t.Data;if(n&&typeof n=="object"){const i=n,s=Array.isArray(i.menuIds)?i.menuIds:Array.isArray(i.MenuIds)?i.MenuIds:void 0;if(s)return s.map(String)}const a=Array.isArray(t.roleMenus)?t.roleMenus:Array.isArray(t.RoleMenus)?t.RoleMenus:void 0;if(Array.isArray(a)){const i=[];for(const s of a){if(!s||typeof s!="object")continue;const l=s,d=l.menuId??l.MenuId??l.id??l.Id;d&&i.push(String(d))}return i}return[]}async function qve(e){e.length&&await Av.requestJson({path:Iv,method:"DELETE",body:e})}async function Vve(e){await qve([e])}async function Wve(e,t){const r=await Av.requestJson({path:`${Iv}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Uve(r)}const Pu=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),mi="/team-member";function Hve(e){if(!Array.isArray(e))return[];const t=[];for(const r of e)if(r!=null){if(typeof r=="string"||typeof r=="number"){t.push(String(r));continue}if(typeof r=="object"){const n=r,a=n.id??n.Id??n.locationId??n.LocationId??n.location_id??n.locationID;a!=null&&t.push(String(a))}}return t}function Gve(e){if(!Array.isArray(e))return[];const t=[];for(const r of e)if(r!=null){if(typeof r=="string"||typeof r=="number"){t.push(String(r));continue}if(typeof r=="object"){const n=r,a=n.locationCode??n.LocationCode??n.code??n.Code??n.location_code??n.locationCodeId,i=n.locationName??n.LocationName??n.name??n.Name??n.location_name,s=n.id??n.Id??n.locationId??n.LocationId,l=a==null?"":String(a).trim(),d=i==null?"":String(i).trim(),c=s==null?"":String(s).trim();l&&d?t.push(`${l} - ${d}`):d?t.push(d):l?t.push(l):c&&t.push(c)}}return t}function Mv(e){if(!e||typeof e!="object")return{id:""};const t=e,r=String(t.id??t.Id??t.userId??t.UserId??t.user_id??t.UserID??t.memberId??t.MemberId??""),n=t.fullName??t.FullName??t.name??t.Name,a=t.userName??t.UserName??t.username??t.UserName,i=t.email??t.Email,s=t.phone??t.Phone;let l=t.roleId??t.RoleId,d=t.roleName??t.RoleName??t.roleName??t.Role;const c=t.role??t.Role;if((!l||!d)&&c&&typeof c=="object"){const w=c;l=w.id??w.Id??w.roleId??w.RoleId??l,d=w.roleName??w.RoleName??w.name??w.Name??w.role??w.Role??d}const f=t.state??t.State,h=typeof f=="boolean"?f:f==="true"?!0:f==="false"?!1:void 0,p=t.locationIds??t.LocationIds??t.assignedLocationIds??t.AssignedLocationIds??t.location_id_list??t.LocationIdList;let g=Hve(p);const x=t.locations??t.Locations??t.assignedLocations??t.AssignedLocations??t.locationNames??t.LocationNames;let b=Gve(x);if(g.length===0&&Array.isArray(x)){const w=[];for(const j of x){if(typeof j!="object"||!j)continue;const N=j,C=N.id??N.Id??N.locationId??N.LocationId;C!=null&&w.push(String(C))}w.length&&(g=w)}return{id:r,fullName:n,userName:a,email:i,phone:s,roleId:l,roleName:d,locationIds:g,locations:b,state:h??(t.status?String(t.status).toLowerCase()==="active":void 0)}}async function Yve(e,t){const r=await Pu.requestJson({path:mi,method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Keyword:e.keyword,RoleId:e.roleId,LocationId:e.locationId,State:e.state,Sorting:e.sorting},signal:t}),n=r.items??[];return{totalCount:r.totalCount??0,items:n.map(Mv)}}async function Kve(e,t){const r=await Pu.requestJson({path:`${mi}/${encodeURIComponent(e)}`,method:"GET",signal:t});return Mv(r)}function iz(e){if(e==null||e==="")return null;const t=String(e).trim();return t?Number(t.replace(/\D/g,""))||0:null}function Xve(e){const t=e.phone!=null&&e.phone!==""?iz(String(e.phone)):null;return{fullName:e.fullName,userName:e.userName,password:e.password,email:e.email??null,phone:t,roleId:e.roleId,locationIds:e.locationIds,locations:e.locationIds,state:e.state}}function Jve(e){const t=e.phone!=null&&e.phone!==""?iz(String(e.phone)):null,r={fullName:e.fullName,userName:e.userName,email:e.email??null,phone:t,roleId:e.roleId,locationIds:e.locationIds,locations:e.locationIds,state:e.state};return e.password&&(r.password=e.password),r}async function Qve(e){const t=await Pu.requestJson({path:mi,method:"POST",body:Xve(e)});return Mv(t)}async function Zve(e,t){const r=await Pu.requestJson({path:`${mi}/${encodeURIComponent(e)}`,method:"PUT",body:Jve(t)});return Mv(r)}async function e0e(e){await Pu.requestJson({path:`${mi}/${encodeURIComponent(e)}`,method:"DELETE"})}async function t0e(e){await ju({path:`${mi}/download-team-member-import-template`,defaultFileName:"Team-Member-template.xlsx",signal:e})}async function r0e(e,t){await ju({path:`${mi}/export-team-members-pdf`,query:{Keyword:e.keyword,RoleId:e.roleId,LocationId:e.locationId,State:e.state,Sorting:e.sorting},defaultFileName:"team-members.pdf",signal:t})}async function n0e(e,t){return V_({path:`${mi}/import-team-members-batch`,fieldName:"file",file:e,signal:t})}async function a0e(e){return Pu.requestJson({path:`${mi}/team-members-bulk`,method:"PUT",body:e})}const Rv=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});function o0e(){return"http://flus-test.3ffoodsafety.com"}function i0e(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}function s0e(e,t){const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function l0e(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))if(!(a==null||a==="")){if(typeof a=="boolean"){t.set(n,a?"true":"false");continue}t.set(n,String(a))}const r=t.toString();return r?`?${r}`:""}async function uh(e,t){return Rv.requestJson({path:"/partner",method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,State:e.state},signal:t})}async function c0e(e,t){return Rv.requestJson({path:"/partner",method:"POST",body:{partnerName:e.partnerName.trim(),contactEmail:e.contactEmail?.trim()?e.contactEmail.trim():null,phoneNumber:e.phoneNumber?.trim()?e.phoneNumber.trim():null,state:e.state??!0},signal:t})}async function u0e(e,t,r){return Rv.requestJson({path:`/partner/${encodeURIComponent(e)}`,method:"PUT",body:{partnerName:t.partnerName.trim(),contactEmail:t.contactEmail?.trim()?t.contactEmail.trim():null,phoneNumber:t.phoneNumber?.trim()?t.phoneNumber.trim():null,state:t.state??!0},signal:r})}async function d0e(e,t){await Rv.requestJson({path:`/partner/${encodeURIComponent(e)}`,method:"DELETE",signal:t})}async function f0e(e,t){const r=o0e(),n=i0e(),a=s0e(r,`/api/app/partner/export-pdf${l0e({Keyword:e.keyword,State:e.state,Sorting:e.sorting})}`),i={};n&&(i.Authorization=`Bearer ${n}`);const s=await fetch(a,{method:"POST",headers:i,signal:t});if(!s.ok){const l=s.headers.get("content-type")??"";let d="Export failed.";if(l.includes("application/json")){const c=await s.json().catch(()=>null),f=c?.error?.message?.trim()||c?.message?.trim();f&&(d=f)}else{const c=await s.text().catch(()=>"");c.trim()&&(d=c.trim())}throw new _r(d,s.status,null)}return s.blob()}const Dv=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});function h0e(){return"http://flus-test.3ffoodsafety.com"}function m0e(){try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}function p0e(e,t){const r=e.endsWith("/")?e.slice(0,-1):e,n=t.startsWith("/")?t:`/${t}`;return`${r}${n}`}function g0e(e){const t=new URLSearchParams;for(const[n,a]of Object.entries(e))if(!(a==null||a==="")){if(typeof a=="boolean"){t.set(n,a?"true":"false");continue}t.set(n,String(a))}const r=t.toString();return r?`?${r}`:""}async function fE(e,t){return Dv.requestJson({path:"/group",method:"GET",query:{SkipCount:e.skipCount,MaxResultCount:e.maxResultCount,Sorting:e.sorting,Keyword:e.keyword,PartnerId:e.partnerId,State:e.state},signal:t})}async function y0e(e,t){return Dv.requestJson({path:"/group",method:"POST",body:{groupName:e.groupName.trim(),partnerId:e.partnerId.trim(),state:e.state??!0},signal:t})}async function v0e(e,t,r){return Dv.requestJson({path:`/group/${encodeURIComponent(e)}`,method:"PUT",body:{groupName:t.groupName.trim(),partnerId:t.partnerId.trim(),state:t.state??!0},signal:r})}async function x0e(e,t){await Dv.requestJson({path:`/group/${encodeURIComponent(e)}`,method:"DELETE",signal:t})}async function b0e(e,t){const r=h0e(),n=m0e(),a=p0e(r,`/api/app/group/export-pdf${g0e({Keyword:e.keyword,PartnerId:e.partnerId,State:e.state,Sorting:e.sorting})}`),i={};n&&(i.Authorization=`Bearer ${n}`);const s=await fetch(a,{method:"POST",headers:i,signal:t});if(!s.ok){const l=s.headers.get("content-type")??"";let d="Export failed.";if(l.includes("application/json")){const c=await s.json().catch(()=>null),f=c?.error?.message?.trim()||c?.message?.trim();f&&(d=f)}else{const c=await s.text().catch(()=>"");c.trim()&&(d=c.trim())}throw new _r(d,s.status,null)}return s.blob()}const w0e="00000000-0000-0000-0000-000000000000";function S0e(e){const t=(e??"").trim();return t?t.toLowerCase()!==w0e:!1}function j0e(e){return{id:e.id,locationCodeReadonly:(e.locationCode??e.id??"").trim(),partner:e.partner??"",groupName:e.groupName??"",locationName:(e.locationName??"").trim()||"",street:e.street??"",city:e.city??"",stateCode:e.stateCode??"",country:e.country??"",zipCode:e.zipCode??"",phone:e.phone??"",email:e.email??"",latitude:e.latitude??null,longitude:e.longitude??null,state:e.state!==!1}}function N0e({seed:e,onBack:t,onSaved:r}){const[n,a]=v.useState([]),[i,s]=v.useState(!1);v.useEffect(()=>{a(e.map(j0e))},[e]);const l=(c,f)=>{a(h=>{const p=[...h];return p[c]={...p[c],...f},p})},d=async()=>{const c=n.filter(f=>S0e(f.id)).map(f=>({id:f.id.trim(),partner:f.partner?.trim()||null,groupName:f.groupName?.trim()||null,locationName:f.locationName.trim(),street:f.street?.trim()||null,city:f.city?.trim()||null,stateCode:f.stateCode?.trim()||null,country:f.country?.trim()||null,zipCode:f.zipCode?.trim()||null,phone:f.phone?.trim()||null,email:f.email?.trim()||null,latitude:f.latitude,longitude:f.longitude,state:f.state!==!1}));if(c.length===0){ee.error("No valid rows",{description:"Select locations in the list first, then open Bulk Edit."});return}s(!0);try{const f=await Cme({items:c});if(ee.success("Bulk update finished",{description:`Success: ${f.successCount}, failed: ${f.failCount}`}),f.errors?.length){const h=f.errors.slice(0,5).map(p=>`Row ${p.rowNumber??"?"}: ${p.message??""}`).join(` +`);ee.message("Errors (first 5)",{description:h})}r(),t()}catch(f){const h=f instanceof _r||f instanceof Error?f.message:"Save failed.";ee.error("Bulk save failed",{description:h})}finally{s(!1)}};return o.jsxs("div",{className:"flex flex-col h-full min-h-0 bg-white",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-gray-200 shrink-0",children:[o.jsx(de,{type:"button",variant:"outline",onClick:t,children:"Back"}),o.jsx("h1",{className:"text-base font-semibold text-gray-900 flex-1 text-center truncate px-2",children:"Location bulk edit"}),o.jsx(de,{type:"button",className:"bg-green-600 hover:bg-green-700 text-white shrink-0",disabled:i,onClick:()=>void d(),children:i?"Saving…":"Save All"})]}),o.jsx("div",{className:"overflow-auto flex-1 min-h-0 px-2 py-3",children:o.jsxs("table",{className:"w-full text-xs border-collapse border border-gray-200",children:[o.jsx("thead",{className:"bg-gray-100 sticky top-0 z-10",children:o.jsxs("tr",{children:[o.jsx("th",{className:"border p-1 w-9 text-center text-gray-600 font-semibold",children:"#"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location ID"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Company"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Region"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location Name *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Street"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"City"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"State"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Country"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Zip"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Phone"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Email"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Lat"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Lng"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Active"})]})}),o.jsx("tbody",{children:n.map((c,f)=>o.jsxs("tr",{className:"bg-white",children:[o.jsx("td",{className:"border p-1 text-center align-middle text-gray-700 tabular-nums text-xs font-medium",children:f+1}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:c.locationCodeReadonly,readOnly:!0,title:"Location ID is not changed in bulk edit"})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",value:c.partner??"",onChange:h=>l(f,{partner:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",value:c.groupName??"",onChange:h=>l(f,{groupName:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:c.locationName,onChange:h=>l(f,{locationName:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",value:c.street??"",onChange:h=>l(f,{street:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[72px]",value:c.city??"",onChange:h=>l(f,{city:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[48px]",value:c.stateCode??"",onChange:h=>l(f,{stateCode:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[56px]",value:c.country??"",onChange:h=>l(f,{country:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[56px]",value:c.zipCode??"",onChange:h=>l(f,{zipCode:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[88px]",value:c.phone??"",onChange:h=>l(f,{phone:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[120px]",value:c.email??"",onChange:h=>l(f,{email:h.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[64px]",value:c.latitude===null||c.latitude===void 0?"":String(c.latitude),onChange:h=>{const p=h.target.value.trim();l(f,{latitude:p===""?null:Number(p)})}})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[64px]",value:c.longitude===null||c.longitude===void 0?"":String(c.longitude),onChange:h=>{const p=h.target.value.trim();l(f,{longitude:p===""?null:Number(p)})}})}),o.jsx("td",{className:"border p-1 align-middle text-center",children:o.jsx("div",{className:"flex justify-center",children:o.jsx(br,{checked:c.state!==!1,onCheckedChange:h=>l(f,{state:!!h})})})})]},`${c.id}-${f}`))})]})}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 text-center text-xs text-gray-500 shrink-0 space-y-1",children:[o.jsx("p",{children:"Only the locations you selected in the list are shown here."}),o.jsx("p",{children:"You can copy and paste from Excel or Google Sheets."}),o.jsx("p",{children:"Columns marked * are required for each row."})]})]})}const Pt="__none__";async function sz(e){const t=[];let r=1;const n=100;for(;;){const i=await uh({skipCount:r,maxResultCount:n,state:!0},e);if(t.push(...i.items??[]),!i.items||i.items.length200))break}const a=new Map;for(const i of t)i.id&&!a.has(i.id)&&a.set(i.id,i);return Array.from(a.values())}async function lz(e,t){const r=[];let n=1;const a=100;for(;;){const s=await fE({skipCount:n,maxResultCount:a,partnerId:e,state:!0},t);if(r.push(...s.items??[]),!s.items||s.items.length200))break}const i=new Map;for(const s of r)s.id&&!i.has(s.id)&&i.set(s.id,s);return Array.from(i.values())}function Va(e){const t=(e??"").trim();return t||"N/A"}function C0e(e,t){return e==null||t===null||t===void 0||!Number.isFinite(e)||!Number.isFinite(t)?"N/A":`${e}, ${t}`}function cz(e){const t=[];e.locationCode.trim()||t.push("Location ID"),e.locationName.trim()||t.push("Location Name"),(e.street??"").trim()||t.push("Street"),(e.city??"").trim()||t.push("City"),(e.stateCode??"").trim()||t.push("State"),(e.country??"").trim()||t.push("Country"),(e.zipCode??"").trim()||t.push("Zip Code"),(e.phone??"").trim()||t.push("Phone Number"),(e.email??"").trim()||t.push("Email");const r=e.latitude,n=e.longitude;return(r==null||!Number.isFinite(r))&&t.push("Latitude"),(n==null||!Number.isFinite(n))&&t.push("Longitude"),t}function _0e({renderBeforeTabs:e}={}){const[t,r]=v.useState(!1),[n,a]=v.useState(!1),[i,s]=v.useState(!1),[l,d]=v.useState(null),[c,f]=v.useState(null),[h,p]=v.useState([]),[g,x]=v.useState(!1),[b,w]=v.useState(0),[j,N]=v.useState(0),[C,O]=v.useState(null),[P,E]=v.useState(()=>new Set),[T,A]=v.useState(!1),[I,R]=v.useState(!1),[L,V]=v.useState([]),[z,G]=v.useState(!1),[H,W]=v.useState(!1),[q,M]=v.useState(""),[Y,F]=v.useState("all"),[D,$]=v.useState("all"),[K,J]=v.useState("all"),[oe,re]=v.useState(1),[Q,ce]=v.useState(10),se=v.useRef(null),fe=v.useRef(null),[be,Z]=v.useState("");v.useEffect(()=>(fe.current&&window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>Z(q.trim()),300),()=>{fe.current&&window.clearTimeout(fe.current)}),[q]);const Se=v.useMemo(()=>K!=="all"?K:be.trim(),[K,be]),Ne=v.useMemo(()=>{const Ce=new Set;for(const tt of h){const ot=(tt.partner??"").trim();ot&&Ce.add(ot)}return["all",...Array.from(Ce).sort((tt,ot)=>tt.localeCompare(ot))]},[h]),qe=v.useMemo(()=>{const Ce=new Set;for(const tt of h){const ot=(tt.groupName??"").trim();ot&&Ce.add(ot)}return["all",...Array.from(Ce).sort((tt,ot)=>tt.localeCompare(ot))]},[h]),De=v.useMemo(()=>{const Ce=new Set;for(const tt of h){const ot=(tt.locationCode??"").trim();ot&&Ce.add(ot)}return["all",...Array.from(Ce).sort((tt,ot)=>tt.localeCompare(ot))]},[h]),He=Math.max(1,Math.ceil(b/Q));v.useEffect(()=>{re(1)},[be,Y,D,K,Q]),v.useEffect(()=>((async()=>{se.current?.abort();const tt=new AbortController;se.current=tt,x(!0);try{const ot=Qa(oe),Nt=await Nu({skipCount:ot,maxResultCount:Q,keyword:Se||void 0,partner:Y!=="all"?Y:void 0,groupName:D!=="all"?D:void 0},tt.signal);p(Nt.items??[]),w(Nt.totalCount??0)}catch(ot){if(ot?.name==="AbortError")return;ee.error("Failed to load locations.",{description:ot?.message?String(ot.message):"Please try again."}),p([]),w(0)}finally{x(!1)}})(),()=>se.current?.abort()),[Se,Y,D,K,oe,Q,j]),v.useEffect(()=>{E(new Set)},[be,Y,D,K,oe]);const ne=()=>N(Ce=>Ce+1),pe=Ce=>{O(null),d(Ce),a(!0)},_e=Ce=>{O(null),f(Ce),s(!0)},ye=o.jsx("div",{className:ke(!I&&"pb-4",I&&"hidden"),children:o.jsx("div",{className:"flex flex-col gap-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:q,onChange:Ce=>M(Ce.target.value),style:{height:40,boxSizing:"border-box"},className:"border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"}),o.jsxs($e,{value:Y,onValueChange:F,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Company"})}),o.jsx(ze,{children:Ne.map(Ce=>o.jsx(we,{value:Ce,children:Ce==="all"?"Company (All)":Ce},Ce))})]}),o.jsxs($e,{value:D,onValueChange:$,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Region"})}),o.jsx(ze,{children:qe.map(Ce=>o.jsx(we,{value:Ce,children:Ce==="all"?"Region (All)":Ce},Ce))})]}),o.jsxs($e,{value:K,onValueChange:J,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",style:{height:40,boxSizing:"border-box"},children:o.jsx(Fe,{placeholder:"Location"})}),o.jsx(ze,{children:De.map(Ce=>o.jsx(we,{value:Ce,children:Ce==="all"?"All Locations":Ce},Ce))})]}),o.jsx("div",{className:"flex-1"}),o.jsx(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>A(!0),children:"Bulk Import"}),o.jsx(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",disabled:H,onClick:async()=>{W(!0);try{await jme({keyword:Se||void 0,partner:Y!=="all"?Y:void 0,groupName:D!=="all"?D:void 0}),ee.success("Export started",{description:"Your browser should download the Excel file."})}catch(Ce){const tt=Ce instanceof Error?Ce.message:"Please try again.";ee.error("Export failed",{description:tt})}finally{W(!1)}},children:H?"Exporting…":"Bulk Export"}),o.jsx(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>{const Ce=h.filter(tt=>P.has(tt.id));if(Ce.length===0){ee.error("No rows selected",{description:"Use the checkboxes on the left, then open Bulk Edit."});return}V(Ce),R(!0)},children:"Bulk Edit"}),o.jsx(de,{className:"h-10 bg-blue-600 hover:bg-blue-700 text-white rounded-md px-6 font-medium shrink-0",onClick:()=>r(!0),children:"New"})]})})}),Ae=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex-1 overflow-auto pt-6 min-h-0",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden",children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r w-12 shrink-0 text-center px-3",children:o.jsx(Co,{checked:h.length>0&&h.every(Ce=>P.has(Ce.id)),onCheckedChange:Ce=>{E(Ce===!0?new Set(h.map(tt=>tt.id)):new Set)},"aria-label":"Select all on page"})}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Company"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Region"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Location ID"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Location Name"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Street"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"City"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"State"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Country"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Zip Code"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Phone"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Email"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"GPS"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Active"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center",children:"Actions"})]})}),o.jsx(pn,{children:g?o.jsx(nt,{children:o.jsx(xe,{colSpan:15,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):h.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:15,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):h.map(Ce=>o.jsxs(nt,{children:[o.jsx(xe,{className:"border-r w-12 shrink-0 text-center px-3",children:o.jsx(Co,{checked:P.has(Ce.id),onCheckedChange:tt=>{E(ot=>{const Nt=new Set(ot);return tt===!0?Nt.add(Ce.id):Nt.delete(Ce.id),Nt})},"aria-label":"Select row"})}),o.jsx(xe,{className:"border-r text-gray-600 max-w-[140px] truncate",children:Va(Ce.partner)}),o.jsx(xe,{className:"border-r text-gray-600 max-w-[140px] truncate",children:Va(Ce.groupName)}),o.jsx(xe,{className:"border-r font-numeric text-gray-600",children:Va(Ce.locationCode??Ce.id)}),o.jsx(xe,{className:"border-r font-medium text-black",children:Va(Ce.locationName)}),o.jsx(xe,{className:"border-r text-gray-600 max-w-[140px] truncate",children:Va(Ce.street)}),o.jsx(xe,{className:"border-r text-gray-600",children:Va(Ce.city)}),o.jsx(xe,{className:"border-r text-gray-600",children:Va(Ce.stateCode)}),o.jsx(xe,{className:"border-r text-gray-600",children:Va(Ce.country)}),o.jsx(xe,{className:"border-r text-gray-600 font-numeric",children:Va(Ce.zipCode)}),o.jsx(xe,{className:"border-r text-gray-600 whitespace-nowrap",children:Va(Ce.phone)}),o.jsx(xe,{className:"border-r text-gray-600 text-sm max-w-[180px] truncate",children:Va(Ce.email)}),o.jsx(xe,{className:"border-r text-gray-500 font-numeric text-xs",children:C0e(Ce.latitude,Ce.longitude)}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{className:Ce.state?"bg-green-600":"bg-gray-400",children:Ce.state?"Yes":"No"})}),o.jsx(xe,{className:"text-center",children:o.jsxs(ka,{open:C===Ce.id,onOpenChange:tt=>O(tt?Ce.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4 text-gray-500"})})}),o.jsxs(Ia,{align:"end",className:"w-40 p-1",children:[o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal",onClick:()=>pe(Ce),children:[o.jsx(oa,{className:"w-4 h-4"}),"Edit"]}),o.jsxs(de,{type:"button",variant:"ghost",className:"w-full justify-start gap-2 h-9 px-2 font-normal text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>_e(Ce),children:[o.jsx(zt,{className:"w-4 h-4 shrink-0"}),"Delete"]})]})]})})]},Ce.id))})]})})}),o.jsx("div",{className:"pt-4 shrink-0",children:o.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-600",children:[o.jsxs("div",{children:["Showing ",b===0?0:(oe-1)*Q+1,"-",Math.min(oe*Q,b)," of ",b]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(Q),onValueChange:Ce=>ce(Number(Ce)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(Ce=>o.jsxs(we,{value:String(Ce),children:[Ce," / page"]},Ce))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:Ce=>{Ce.preventDefault(),re(tt=>Math.max(1,tt-1))},"aria-disabled":oe<=1,className:oe<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:Ce=>Ce.preventDefault(),children:["Page ",oe," / ",He]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:Ce=>{Ce.preventDefault(),re(tt=>Math.min(He,tt+1))},"aria-disabled":oe>=He,className:oe>=He?"pointer-events-none opacity-50":""})})]})})]})]})})]}),Ge=I?o.jsx("div",{className:"flex-1 overflow-auto pt-6 min-h-0",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden flex flex-col min-h-0 h-full max-h-full",children:o.jsx(N0e,{seed:L,onBack:()=>{R(!1),V([])},onSaved:()=>{E(new Set),ne()}})})}):Ae,ut=o.jsxs(o.Fragment,{children:[o.jsx(E0e,{open:t,onOpenChange:r,onCreated:()=>{re(1),ne()}}),o.jsx(O0e,{open:n,location:l,onOpenChange:Ce=>{a(Ce),Ce||d(null)},onUpdated:()=>{ne()}}),o.jsx(T0e,{open:i,location:c,onOpenChange:Ce=>{s(Ce),Ce||f(null)},onDeleted:()=>{ne()}}),o.jsx(uE,{open:T,onOpenChange:A,title:"Bulk import locations",description:"Upload an .xlsx file. Use the official template for correct column headers.",downloadingTemplate:z,onDownloadTemplate:async()=>{G(!0);try{await Sme(),ee.success("Template downloaded.")}catch(Ce){const tt=Ce instanceof Error?Ce.message:"Download failed.";ee.error("Template download failed",{description:tt})}finally{G(!1)}},onImportFile:async Ce=>{const tt=await Nme(Ce);return ne(),{successCount:tt.successCount,failCount:tt.failCount}}})]});return e?o.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[e(ye),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:Ge}),ut]}):o.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[ye,o.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:Ge}),ut]})}function E0e({open:e,onOpenChange:t,onCreated:r}){const[n,a]=v.useState(!1),[i,s]=v.useState({partner:"",groupName:"",locationCode:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}),[l,d]=v.useState(Pt),[c,f]=v.useState(Pt),[h,p]=v.useState([]),[g,x]=v.useState([]),[b,w]=v.useState(!1),[j,N]=v.useState(!1),C=v.useRef(null),O=()=>{s({partner:"",groupName:"",locationCode:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}),d(Pt),f(Pt),p([]),x([])};v.useEffect(()=>{e||(C.current?.abort(),O(),a(!1))},[e]),v.useEffect(()=>{if(!e)return;C.current?.abort();const E=new AbortController;return C.current=E,w(!0),(async()=>{try{const T=await sz(E.signal);p(T)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load companies.",{description:T?.message?String(T.message):"Please try again."}),p([])}finally{w(!1)}})(),()=>E.abort()},[e]),v.useEffect(()=>{if(!e||l===Pt){x([]),f(Pt),N(!1);return}const E=new AbortController;return N(!0),(async()=>{try{const T=await lz(l,E.signal);x(T),f(Pt)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load regions.",{description:T?.message?String(T.message):"Please try again."}),x([])}finally{N(!1)}})(),()=>E.abort()},[e,l]);const P=async()=>{const E=cz(i);if(E.length){ee.error("Please fill in required fields.",{description:`Missing: ${E.join(", ")}.`});return}const T=l!==Pt?h.find(I=>I.id===l):void 0,A=c!==Pt?g.find(I=>I.id===c):void 0;a(!0);try{await xme({...i,locationCode:i.locationCode.trim(),locationName:i.locationName.trim(),partner:T?.partnerName?.trim()?T.partnerName.trim():null,groupName:A?.groupName?.trim()?A.groupName.trim():null,street:(i.street??"").trim(),city:(i.city??"").trim(),stateCode:(i.stateCode??"").trim(),country:(i.country??"").trim(),zipCode:(i.zipCode??"").trim(),phone:(i.phone??"").trim(),email:(i.email??"").trim(),latitude:i.latitude,longitude:i.longitude}),ee.success("Location created.",{description:"The location has been added successfully."}),t(!1),r()}catch(I){ee.error("Failed to create location.",{description:I?.message?String(I.message):"Please try again."})}finally{a(!1)}};return o.jsx(kt,{open:e,onOpenChange:t,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Add New Location"}),o.jsx(qt,{children:"Enter the details for the new store location."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Company"}),o.jsxs($e,{value:l,onValueChange:E=>{d(E),f(Pt)},disabled:b,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:b?"Loading...":"e.g. Global Foods Inc."})}),o.jsxs(ze,{children:[o.jsx(we,{value:Pt,children:"None"}),h.map(E=>o.jsx(we,{value:E.id,children:E.partnerName??E.id},E.id))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Region"}),o.jsxs($e,{value:c,onValueChange:f,disabled:j||l===Pt,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:l===Pt?"Select a company first":j?"Loading...":"e.g. East Coast Region"})}),o.jsxs(ze,{children:[o.jsx(we,{value:Pt,children:"None"}),g.map(E=>o.jsx(we,{value:E.id,children:E.groupName??E.id},E.id))]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2 col-span-1",children:[o.jsx(ue,{children:"Location ID *"}),o.jsx(me,{placeholder:"e.g. 12345",value:i.locationCode,onChange:E=>s(T=>({...T,locationCode:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2 col-span-2",children:[o.jsx(ue,{children:"Location Name *"}),o.jsx(me,{placeholder:"e.g. Downtown Store",value:i.locationName,onChange:E=>s(T=>({...T,locationName:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Street *"}),o.jsx(me,{placeholder:"e.g. 123 Main St",value:i.street??"",onChange:E=>s(T=>({...T,street:E.target.value}))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"City *"}),o.jsx(me,{placeholder:"e.g. New York",value:i.city??"",onChange:E=>s(T=>({...T,city:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"State *"}),o.jsx(me,{placeholder:"e.g. NY",value:i.stateCode??"",onChange:E=>s(T=>({...T,stateCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Country *"}),o.jsx(me,{placeholder:"e.g. USA",value:i.country??"",onChange:E=>s(T=>({...T,country:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Zip Code *"}),o.jsx(me,{placeholder:"e.g. 10001",value:i.zipCode??"",onChange:E=>s(T=>({...T,zipCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Phone Number *"}),o.jsx(me,{placeholder:"+1 (555) 000-0000",value:i.phone??"",onChange:E=>s(T=>({...T,phone:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Email *"}),o.jsx(me,{placeholder:"store@example.com",value:i.email??"",onChange:E=>s(T=>({...T,email:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ue,{className:"flex items-center gap-2",children:[o.jsx(su,{className:"w-4 h-4"})," GPS Coordinates *"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(me,{placeholder:"Latitude (e.g. 40.7128)",value:i.latitude===null||i.latitude===void 0?"":String(i.latitude),onChange:E=>{const T=E.target.value.trim();s(A=>({...A,latitude:T?Number(T):null}))}}),o.jsx(me,{placeholder:"Longitude (e.g. -74.0060)",value:i.longitude===null||i.longitude===void 0?"":String(i.longitude),onChange:E=>{const T=E.target.value.trim();s(A=>({...A,longitude:T?Number(T):null}))}})]})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx(br,{id:"loc-status",checked:!!i.state,onCheckedChange:E=>s(T=>({...T,state:E}))}),o.jsx(ue,{htmlFor:"loc-status",children:"Active Location"})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),o.jsx(de,{disabled:n,onClick:P,className:"bg-blue-600 text-white hover:bg-blue-700",children:n?"Creating...":"Create Location"})]})]})})}function P0e(e){return{partner:e.partner??"",groupName:e.groupName??"",locationCode:e.locationCode??"",locationName:e.locationName??"",street:e.street??"",city:e.city??"",stateCode:e.stateCode??"",country:e.country??"",zipCode:e.zipCode??"",phone:e.phone??"",email:e.email??"",latitude:e.latitude??null,longitude:e.longitude??null,state:!!e.state}}function O0e({open:e,location:t,onOpenChange:r,onUpdated:n}){const[a,i]=v.useState(!1),[s,l]=v.useState({partner:"",groupName:"",locationCode:"",locationName:"",street:"",city:"",stateCode:"",country:"",zipCode:"",phone:"",email:"",latitude:null,longitude:null,state:!0}),[d,c]=v.useState(Pt),[f,h]=v.useState(Pt),[p,g]=v.useState([]),[x,b]=v.useState([]),[w,j]=v.useState(!1),[N,C]=v.useState(!1),O=v.useRef(Pt);v.useEffect(()=>{if(!e){i(!1),c(Pt),h(Pt),g([]),b([]),O.current=Pt;return}if(!t)return;l(P0e(t)),i(!1),O.current=Pt,c(Pt),h(Pt);const E=new AbortController;return j(!0),(async()=>{try{const T=await sz(E.signal);g(T);const A=(t.partner??"").trim().toLowerCase();let I=Pt;if(A){const R=T.find(L=>(L.partnerName??"").trim().toLowerCase()===A);R&&(I=R.id)}O.current=I,c(I)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load companies.",{description:T?.message?String(T.message):"Please try again."}),g([])}finally{j(!1)}})(),()=>E.abort()},[e,t?.id]),v.useEffect(()=>{if(!e||d===Pt){b([]),h(Pt),C(!1);return}const E=new AbortController;return C(!0),(async()=>{try{const T=await lz(d,E.signal);b(T);let A=Pt;const I=O.current;if(!!t&&I!=="__user__"&&I!==Pt&&d===I){const L=(t.groupName??"").trim().toLowerCase();if(L){const V=T.find(z=>(z.groupName??"").trim().toLowerCase()===L);V&&(A=V.id)}}h(A)}catch(T){if(T?.name==="AbortError")return;ee.error("Failed to load regions.",{description:T?.message?String(T.message):"Please try again."}),b([])}finally{C(!1)}})(),()=>E.abort()},[e,d,t?.groupName,t?.id]);const P=async()=>{if(!t?.id)return;const E=cz(s);if(E.length){ee.error("Please fill in required fields.",{description:`Missing: ${E.join(", ")}.`});return}const T=d!==Pt?p.find(I=>I.id===d):void 0,A=f!==Pt?x.find(I=>I.id===f):void 0;i(!0);try{await bme(t.id,{...s,locationCode:s.locationCode.trim(),locationName:s.locationName.trim(),partner:T?.partnerName?.trim()?T.partnerName.trim():null,groupName:A?.groupName?.trim()?A.groupName.trim():null,street:(s.street??"").trim(),city:(s.city??"").trim(),stateCode:(s.stateCode??"").trim(),country:(s.country??"").trim(),zipCode:(s.zipCode??"").trim(),phone:(s.phone??"").trim(),email:(s.email??"").trim(),latitude:s.latitude,longitude:s.longitude}),ee.success("Location updated.",{description:"The changes have been saved successfully."}),r(!1),n()}catch(I){ee.error("Failed to update location.",{description:I?.message?String(I.message):"Please try again."})}finally{i(!1)}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:"Edit Location"}),o.jsx(qt,{children:"Update the details for this store location."})]}),o.jsxs("div",{className:"grid gap-4 py-4",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Company"}),o.jsxs($e,{value:d,onValueChange:E=>{O.current="__user__",c(E),h(Pt)},disabled:w,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:w?"Loading...":"e.g. Global Foods Inc."})}),o.jsxs(ze,{children:[o.jsx(we,{value:Pt,children:"None"}),p.map(E=>o.jsx(we,{value:E.id,children:E.partnerName??E.id},E.id))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Region"}),o.jsxs($e,{value:f,onValueChange:h,disabled:N||d===Pt,children:[o.jsx(Be,{className:"h-11 rounded-xl border border-transparent bg-gray-100 px-4 font-semibold text-gray-900 data-[placeholder]:font-medium data-[placeholder]:text-gray-500",children:o.jsx(Fe,{placeholder:d===Pt?"Select a company first":N?"Loading...":"e.g. East Coast Region"})}),o.jsxs(ze,{children:[o.jsx(we,{value:Pt,children:"None"}),x.map(E=>o.jsx(we,{value:E.id,children:E.groupName??E.id},E.id))]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2 col-span-1",children:[o.jsx(ue,{children:"Location ID *"}),o.jsx(me,{placeholder:"e.g. 12345",value:s.locationCode,onChange:E=>l(T=>({...T,locationCode:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2 col-span-2",children:[o.jsx(ue,{children:"Location Name *"}),o.jsx(me,{placeholder:"e.g. Downtown Store",value:s.locationName,onChange:E=>l(T=>({...T,locationName:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Street *"}),o.jsx(me,{placeholder:"e.g. 123 Main St",value:s.street??"",onChange:E=>l(T=>({...T,street:E.target.value}))})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"City *"}),o.jsx(me,{placeholder:"e.g. New York",value:s.city??"",onChange:E=>l(T=>({...T,city:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"State *"}),o.jsx(me,{placeholder:"e.g. NY",value:s.stateCode??"",onChange:E=>l(T=>({...T,stateCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Country *"}),o.jsx(me,{placeholder:"e.g. USA",value:s.country??"",onChange:E=>l(T=>({...T,country:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Zip Code *"}),o.jsx(me,{placeholder:"e.g. 10001",value:s.zipCode??"",onChange:E=>l(T=>({...T,zipCode:E.target.value}))})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Phone Number *"}),o.jsx(me,{placeholder:"+1 (555) 000-0000",value:s.phone??"",onChange:E=>l(T=>({...T,phone:E.target.value}))})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Email *"}),o.jsx(me,{placeholder:"store@example.com",value:s.email??"",onChange:E=>l(T=>({...T,email:E.target.value}))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(ue,{className:"flex items-center gap-2",children:[o.jsx(su,{className:"w-4 h-4"})," GPS Coordinates *"]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsx(me,{placeholder:"Latitude (e.g. 40.7128)",value:s.latitude===null||s.latitude===void 0?"":String(s.latitude),onChange:E=>{const T=E.target.value.trim();l(A=>({...A,latitude:T?Number(T):null}))}}),o.jsx(me,{placeholder:"Longitude (e.g. -74.0060)",value:s.longitude===null||s.longitude===void 0?"":String(s.longitude),onChange:E=>{const T=E.target.value.trim();l(A=>({...A,longitude:T?Number(T):null}))}})]})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx(br,{id:"loc-status-edit",checked:!!s.state,onCheckedChange:E=>l(T=>({...T,state:E}))}),o.jsx(ue,{htmlFor:"loc-status-edit",children:"Active Location"})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:a,onClick:P,className:"bg-blue-600 text-white hover:bg-blue-700",children:a?"Saving...":"Save Changes"})]})]})})}function T0e({open:e,location:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>{const d=(t?.locationCode??"").trim(),c=(t?.locationName??"").trim();return d&&c?`${d} - ${c}`:d||c||"this location"},[t?.locationCode,t?.locationName]),l=async()=>{if(t?.id){i(!0);try{await wme(t.id),ee.success("Location deleted.",{description:"The location has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete location.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Location"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}const k0e="00000000-0000-0000-0000-000000000000";function Es(e){return e==null?"":String(e).trim()}function A0e(e){const t=(e??"").trim();return t?t.toLowerCase()!==k0e:!1}function I0e(e){const t=e.trim();return t?Number(t.replace(/\D/g,""))||0:null}function M0e(e){const t=Array.isArray(e.locationIds)?e.locationIds:[];return{id:Es(e.id),fullName:Es(e.fullName),userName:Es(e.userName),password:"",email:Es(e.email),phone:Es(e.phone),roleId:Es(e.roleId),locationIdsCsv:t.map(r=>Es(r)).filter(Boolean).join(","),state:e.state!==!1}}function R0e(e){return e.split(/[,;|\s]+/).map(t=>t.trim()).filter(Boolean)}function D0e({seed:e,onBack:t,onSaved:r}){const[n,a]=v.useState([]),[i,s]=v.useState([]),[l,d]=v.useState(!1);v.useEffect(()=>{let h=!1;return(async()=>{try{const p=[];let g=1;const x=100;for(;;){const b=await dE({skipCount:g,maxResultCount:x});if(p.push(...b.items??[]),!b.items||b.items.length50))break}h||s(p)}catch{h||s([])}})(),()=>{h=!0}},[]),v.useEffect(()=>{a(e.map(M0e))},[e]);const c=(h,p)=>{a(g=>{const x=[...g];return x[h]={...x[h],...p},x})},f=async()=>{const h=n.filter(p=>A0e(p.id)).map(p=>{const g={id:p.id.trim(),fullName:p.fullName.trim(),userName:p.userName.trim(),email:p.email.trim()||null,phone:I0e(p.phone),roleId:p.roleId.trim(),locationIds:R0e(p.locationIdsCsv),state:p.state!==!1},x=p.password.trim();return x&&(g.password=x),g});if(h.length===0){ee.error("No valid rows",{description:"Select team members in the list first."});return}d(!0);try{const p=await a0e({items:h});ee.success("Bulk update finished",{description:`Success: ${p.successCount}, failed: ${p.failCount}`}),r(),t()}catch(p){const g=p instanceof _r||p instanceof Error?p.message:"Save failed.";ee.error("Bulk save failed",{description:g})}finally{d(!1)}};return o.jsxs("div",{className:"flex flex-col h-full min-h-0 bg-white",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-gray-200 shrink-0",children:[o.jsx(de,{type:"button",variant:"outline",onClick:t,children:"Back"}),o.jsx("h1",{className:"text-base font-semibold text-gray-900 flex-1 text-center truncate px-2",children:"Team member bulk edit"}),o.jsx(de,{type:"button",className:"bg-green-600 hover:bg-green-700 text-white shrink-0",disabled:l,onClick:()=>void f(),children:l?"Saving…":"Save All"})]}),o.jsx("div",{className:"overflow-auto flex-1 min-h-0 px-2 py-3",children:o.jsxs("table",{className:"w-full text-xs border-collapse border border-gray-200",children:[o.jsx("thead",{className:"bg-gray-100 sticky top-0 z-10",children:o.jsxs("tr",{children:[o.jsx("th",{className:"border p-1 w-9 text-center text-gray-600 font-semibold",children:"#"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Full name *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"User name *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Password"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Email"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Phone"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Role *"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Location IDs"}),o.jsx("th",{className:"border p-1 whitespace-nowrap",children:"Active"})]})}),o.jsx("tbody",{children:n.map((h,p)=>o.jsxs("tr",{children:[o.jsx("td",{className:"border p-1 text-center align-middle text-gray-700 tabular-nums text-xs font-medium",children:p+1}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:h.fullName,onChange:g=>c(p,{fullName:g.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[100px]",value:h.userName,onChange:g=>c(p,{userName:g.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[80px]",type:"password",placeholder:"(unchanged)",value:h.password,onChange:g=>c(p,{password:g.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[120px]",value:h.email,onChange:g=>c(p,{email:g.target.value})})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[88px]",value:h.phone,onChange:g=>c(p,{phone:g.target.value})})}),o.jsx("td",{className:"border p-1 align-top min-w-[140px]",children:o.jsxs($e,{value:h.roleId||"__none__",onValueChange:g=>c(p,{roleId:g==="__none__"?"":g}),children:[o.jsx(Be,{className:"h-7 text-xs",children:o.jsx(Fe,{placeholder:"Role"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"__none__",children:"(select)"}),i.map(g=>o.jsx(we,{value:g.id,children:g.roleName??g.id},g.id))]})]})}),o.jsx("td",{className:"border p-1 align-top",children:o.jsx(me,{className:"h-7 text-xs min-w-[140px]",value:h.locationIdsCsv,onChange:g=>c(p,{locationIdsCsv:g.target.value}),placeholder:"guid1,guid2"})}),o.jsx("td",{className:"border p-1 text-center align-middle",children:o.jsx(br,{checked:h.state!==!1,onCheckedChange:g=>c(p,{state:!!g})})})]},`${h.id||"e"}-${p}`))})]})}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-100 text-center text-xs text-gray-500 shrink-0 space-y-1",children:[o.jsx("p",{children:"Leave password empty to keep the current password."}),o.jsx("p",{children:"Location IDs: comma-separated location primary keys."})]})]})}function i$(e,t){const r=URL.createObjectURL(e),n=document.createElement("a");n.href=r,n.download=t,n.click(),URL.revokeObjectURL(r)}function Ip(e){if(e!=="all")return e==="active"}async function L0e(e){const t=[];let r=1;const n=100;for(;;){const i=await uh({skipCount:r,maxResultCount:n},e);if(t.push(...i.items??[]),!i.items||i.items.length200))break}const a=new Map;for(const i of t)i.id&&!a.has(i.id)&&a.set(i.id,i);return Array.from(a.values())}async function $0e(e){const t=[];let r=1;const n=100;for(;;){const i=await uh({skipCount:r,maxResultCount:n,state:!0},e);if(t.push(...i.items??[]),!i.items||i.items.length200))break}const a=new Map;for(const i of t)i.id&&!a.has(i.id)&&a.set(i.id,i);return Array.from(a.values())}const F0e=[{id:"Roles",label:"Roles"},{id:"Partner",label:"Company"},{id:"Group",label:"Region"},{id:"Location Manager",label:"Location Manager"},{id:"Team Member",label:"Team Member"}];function ZN(e,t){const r=(e??"").trim();return r?/^partner admin$/i.test(r)?"Company Admin":r:(t??"").trim()||"N/A"}function B0e({initialSubTab:e,onInitialSubTabConsumed:t}={}){const[r,n]=v.useState("Roles");v.useEffect(()=>{e==="Location Manager"&&(n("Location Manager"),t?.())},[e,t]),v.useEffect(()=>{r!=="Team Member"&&(hl(!1),ml([]))},[r]);const[a,i]=v.useState([]),[s,l]=v.useState(0),[d,c]=v.useState(!1),[f,h]=v.useState(0),[p,g]=v.useState(1),[x,b]=v.useState(10),w=Math.max(1,Math.ceil(s/x)),j=v.useRef(null),[N,C]=v.useState(""),O=v.useRef(null),[P,E]=v.useState(""),[T,A]=v.useState([]),[I,R]=v.useState(0),[L,V]=v.useState(!1),[z,G]=v.useState(1),[H,W]=v.useState(10),q=Math.max(1,Math.ceil(I/H)),M=v.useRef(null),[Y,F]=v.useState(""),D=v.useRef(null),[$,K]=v.useState(""),[J,oe]=v.useState("all"),[re,Q]=v.useState(0),[ce,se]=v.useState([]),[fe,be]=v.useState(0),[Z,Se]=v.useState(!1),[Ne,qe]=v.useState(1),[De,He]=v.useState(10),ne=Math.max(1,Math.ceil(fe/De)),pe=v.useRef(null),[_e,ye]=v.useState(""),Ae=v.useRef(null),[Ge,ut]=v.useState(""),[Ce,tt]=v.useState("all"),[ot,Nt]=v.useState("all"),[er,Ie]=v.useState(0),[gt,_t]=v.useState([]),[Qt,Pr]=v.useState([]),[Vn,Jr]=v.useState(!1),[qr,Or]=v.useState(0),[Vt,gr]=v.useState(0),[Kt,fr]=v.useState(1),[tr,Je]=v.useState(10),Et=Math.max(1,Math.ceil(qr/tr)),Lt=v.useRef(null),[sr,ve]=v.useState(""),Le=v.useRef(null),[rt,Xt]=v.useState(""),[xt,hr]=v.useState(null),[Qr,Mr]=v.useState(!1),[Ao,fl]=v.useState(null),[Ou,es]=v.useState(()=>new Set),[Fv,ao]=v.useState(!1),[ph,hl]=v.useState(!1),[Bv,ml]=v.useState([]),[gh,Tu]=v.useState(!1),[ku,yh]=v.useState(!1),[zv,lr]=v.useState(!1),[Uv,ts]=v.useState(null),[vh,rs]=v.useState(!1),[qv,Au]=v.useState(null),[pl,Wn]=v.useState(!1),[Vv,_n]=v.useState(null),[Wv,Iu]=v.useState(!1),[Hv,pi]=v.useState(null),[gl,gi]=v.useState(!1),[yl,xh]=v.useState(null),[Gv,ns]=v.useState(!1),[bh,as]=v.useState(null),[os,wh]=v.useState(!1),[Mu,$t]=v.useState(null),[Sh,vl]=v.useState(!1),Ru=async()=>{try{if(r==="Partner"){const ae=Ip(J),Qe=await f0e({keyword:$||void 0,state:ae,sorting:"CreationTime desc"});i$(Qe,`companies_${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.pdf`),ee.success("Export started.",{description:"Company PDF downloaded."});return}if(r==="Group"){const ae=Ip(ot),Qe=await b0e({keyword:Ge||void 0,partnerId:Ce!=="all"?Ce:void 0,state:ae,sorting:"CreationTime desc"});i$(Qe,`regions_${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.pdf`),ee.success("Export started.",{description:"Region PDF downloaded."});return}ee.message("Export not available for this tab.",{description:"Use Company or Region tab."})}catch(ae){ee.error("Export failed.",{description:ae?.message?String(ae.message):"Please try again."})}};v.useEffect(()=>(O.current&&window.clearTimeout(O.current),O.current=window.setTimeout(()=>E(N.trim()),300),()=>{O.current&&window.clearTimeout(O.current)}),[N]),v.useEffect(()=>(Le.current&&window.clearTimeout(Le.current),Le.current=window.setTimeout(()=>Xt(sr.trim()),300),()=>{Le.current&&window.clearTimeout(Le.current)}),[sr]),v.useEffect(()=>{es(new Set)},[rt,Kt]),v.useEffect(()=>(D.current&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>K(Y.trim()),300),()=>{D.current&&window.clearTimeout(D.current)}),[Y]),v.useEffect(()=>(Ae.current&&window.clearTimeout(Ae.current),Ae.current=window.setTimeout(()=>ut(_e.trim()),300),()=>{Ae.current&&window.clearTimeout(Ae.current)}),[_e]),v.useEffect(()=>{g(1)},[P,x]),v.useEffect(()=>{fr(1)},[rt,tr]),v.useEffect(()=>{G(1)},[$,H,J]),v.useEffect(()=>{qe(1)},[Ge,De,Ce,ot]),v.useEffect(()=>{if(r!=="Group")return;const ae=new AbortController;return(async()=>{try{const Qe=await L0e(ae.signal);_t(Qe)}catch(Qe){if(Qe?.name==="AbortError")return;_t([])}})(),()=>ae.abort()},[r,re]),v.useEffect(()=>r!=="Partner"?void 0:((async()=>{M.current?.abort();const Qe=new AbortController;M.current=Qe,V(!0);try{const bt=await uh({skipCount:Math.max(1,z),maxResultCount:H,keyword:$||void 0,state:Ip(J),sorting:"CreationTime desc"},Qe.signal);A(bt.items??[]),R(bt.totalCount??0)}catch(bt){if(bt?.name==="AbortError")return;ee.error("Failed to load companies.",{description:bt?.message?String(bt.message):"Please try again."}),A([]),R(0)}finally{V(!1)}})(),()=>M.current?.abort()),[r,$,z,H,J,re]),v.useEffect(()=>r!=="Group"?void 0:((async()=>{pe.current?.abort();const Qe=new AbortController;pe.current=Qe,Se(!0);try{const bt=await fE({skipCount:Math.max(1,Ne),maxResultCount:De,keyword:Ge||void 0,partnerId:Ce!=="all"?Ce:void 0,state:Ip(ot),sorting:"CreationTime desc"},Qe.signal);se(bt.items??[]),be(bt.totalCount??0)}catch(bt){if(bt?.name==="AbortError")return;ee.error("Failed to load regions.",{description:bt?.message?String(bt.message):"Please try again."}),se([]),be(0)}finally{Se(!1)}})(),()=>pe.current?.abort()),[r,Ge,Ne,De,Ce,ot,er]),v.useEffect(()=>r!=="Roles"?void 0:((async()=>{j.current?.abort();const Qe=new AbortController;j.current=Qe,c(!0);try{const bt=await dE({skipCount:Math.max(1,p),maxResultCount:x,roleName:P||void 0},Qe.signal);i(bt.items??[]),l(bt.totalCount??0)}catch(bt){if(bt?.name==="AbortError")return;ee.error("Failed to load roles.",{description:bt?.message?String(bt.message):"Please try again."}),i([]),l(0)}finally{c(!1)}})(),()=>j.current?.abort()),[r,P,p,x,f]),v.useEffect(()=>r!=="Team Member"?void 0:((async()=>{Lt.current?.abort();const Qe=new AbortController;Lt.current=Qe,Jr(!0);try{const bt=await Yve({skipCount:Math.max(1,Kt),maxResultCount:tr,keyword:rt||void 0},Qe.signal);Pr(bt.items??[]),Or(bt.totalCount??0)}catch(bt){if(bt?.name==="AbortError")return;ee.error("Failed to load team members.",{description:bt?.message?String(bt.message):"Please try again."}),Pr([]),Or(0)}finally{Jr(!1)}})(),()=>Lt.current?.abort()),[r,rt,Kt,tr,Vt]);const jh=()=>{switch(r){case"Roles":ts(null),lr(!0);break;case"Partner":pi(null),Iu(!0);break;case"Group":as(null),ns(!0);break;case"Team Member":hr(null),vl(!0);break}},xl=()=>o.jsx("div",{className:"w-full border-b border-gray-200",children:o.jsx("div",{className:"flex overflow-x-auto w-fit",children:F0e.map(({id:ae,label:Qe})=>o.jsx("button",{type:"button",onClick:()=>n(ae),style:r===ae?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:ke("px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2",r===ae?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"),children:Qe},ae))})}),Nh=()=>o.jsxs("div",{className:"flex flex-col gap-4 pb-4",children:[o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:r==="Roles"?N:r==="Team Member"?sr:r==="Partner"?Y:r==="Group"?_e:"",onChange:ae=>{r==="Roles"&&C(ae.target.value),r==="Team Member"&&ve(ae.target.value),r==="Partner"&&F(ae.target.value),r==="Group"&&ye(ae.target.value)},style:{height:40,boxSizing:"border-box"},className:"border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"}),r==="Partner"&&o.jsxs($e,{value:J,onValueChange:ae=>oe(ae),children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Status"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All statuses"}),o.jsx(we,{value:"active",children:"Active"}),o.jsx(we,{value:"inactive",children:"Inactive"})]})]}),r==="Group"&&o.jsxs(o.Fragment,{children:[o.jsxs($e,{value:Ce,onValueChange:tt,children:[o.jsx(Be,{className:"w-[180px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Parent company"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"Company (All)"}),gt.map(ae=>o.jsx(we,{value:ae.id,children:ae.partnerName??ae.id},ae.id))]})]}),o.jsxs($e,{value:ot,onValueChange:ae=>Nt(ae),children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Status"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"all",children:"All statuses"}),o.jsx(we,{value:"active",children:"Active"}),o.jsx(we,{value:"inactive",children:"Inactive"})]})]})]}),o.jsx("div",{className:"flex-1"}),r==="Team Member"&&o.jsxs(o.Fragment,{children:[o.jsx(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>ao(!0),children:"Bulk Import"}),o.jsx(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",disabled:ku,onClick:async()=>{yh(!0);try{await r0e({keyword:rt||void 0}),ee.success("Export started.",{description:"Team member PDF download should begin shortly."})}catch(ae){const Qe=ae instanceof Error?ae.message:"Please try again.";ee.error("Export failed.",{description:Qe})}finally{yh(!1)}},children:ku?"Exporting…":"Bulk Export (PDF)"}),o.jsx(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",onClick:()=>{const ae=Qt.filter(Qe=>Ou.has(Qe.id));if(ae.length===0){ee.error("No rows selected",{description:"Use the checkboxes on the left, then open Bulk Edit."});return}ml(ae),hl(!0)},children:"Bulk Edit"})]}),(r==="Partner"||r==="Group")&&o.jsx(de,{variant:"outline",onClick:Ru,className:"h-10 border border-gray-300 rounded-md text-gray-900 px-4 bg-white hover:bg-gray-50 shrink-0",children:"Bulk Export (PDF)"}),o.jsx(de,{className:"h-10 bg-blue-600 hover:bg-blue-700 text-white rounded-md px-6 font-medium shrink-0",onClick:jh,children:"New+"})]}),xl()]}),bl=()=>{switch(r){case"Roles":return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r",children:"Role Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Role Code"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Order"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:a.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:d?"Loading...":"No data"})}):a.map(ae=>o.jsxs(nt,{children:[o.jsx(xe,{className:"font-medium border-r",children:ZN(ae.roleName)}),o.jsx(xe,{className:"border-r text-gray-600",children:ae.roleCode??"N/A"}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"Active":"Inactive"})}),o.jsx(xe,{className:"border-r text-gray-600",children:ae.orderNum??"N/A"}),o.jsxs(xe,{className:"text-center",children:[o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{Au(ae),rs(!0)},title:"Menu Permissions",children:o.jsx(a7,{className:"w-4 h-4 text-blue-600"})}),o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{ts(ae),lr(!0)},children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(de,{variant:"ghost",size:"sm",onClick:async()=>{_n(ae),Wn(!0)},title:"Delete role",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",s===0?0:(p-1)*x+1,"-",Math.min(p*x,s)," of ",s]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(x),onValueChange:ae=>b(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(we,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),g(Qe=>Math.max(1,Qe-1))},"aria-disabled":p<=1,className:p<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",p," / ",w]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),g(Qe=>Math.min(w,Qe+1))},"aria-disabled":p>=w,className:p>=w?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Partner":return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r",children:"Company Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Contact"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Phone"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:L?o.jsx(nt,{children:o.jsx(xe,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):T.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:5,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):T.map(ae=>o.jsxs(nt,{children:[o.jsx(xe,{className:"font-medium border-r",children:ae.partnerName??"N/A"}),o.jsx(xe,{className:"border-r",children:(ae.contactEmail??"").trim()?ae.contactEmail:"N/A"}),o.jsx(xe,{className:"border-r text-gray-600",children:(ae.phoneNumber??"").trim()?ae.phoneNumber:"N/A"}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"active":"inactive"})}),o.jsx(xe,{className:"text-center",children:o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{pi(ae),Iu(!0)},title:"Edit",children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{xh(ae),gi(!0)},title:"Delete",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",I===0?0:(z-1)*H+1,"-",Math.min(z*H,I)," of ",I]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(H),onValueChange:ae=>W(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(we,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),G(Qe=>Math.max(1,Qe-1))},"aria-disabled":z<=1,className:z<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",z," / ",q]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),G(Qe=>Math.min(q,Qe+1))},"aria-disabled":z>=q,className:z>=q?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Group":return o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r",children:"Region Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Parent company"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:Z?o.jsx(nt,{children:o.jsx(xe,{colSpan:4,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):ce.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:4,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):ce.map(ae=>o.jsxs(nt,{children:[o.jsx(xe,{className:"font-medium border-r",children:ae.groupName??"N/A"}),o.jsx(xe,{className:"border-r",children:(ae.partnerName??"").trim()?ae.partnerName:"N/A"}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"active":"inactive"})}),o.jsx(xe,{className:"text-center",children:o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{as(ae),ns(!0)},title:"Edit",children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{$t(ae),wh(!0)},title:"Delete",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",fe===0?0:(Ne-1)*De+1,"-",Math.min(Ne*De,fe)," of ",fe]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(De),onValueChange:ae=>He(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(we,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),qe(Qe=>Math.max(1,Qe-1))},"aria-disabled":Ne<=1,className:Ne<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",Ne," / ",ne]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),qe(Qe=>Math.min(ne,Qe+1))},"aria-disabled":Ne>=ne,className:Ne>=ne?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Team Member":return o.jsxs(o.Fragment,{children:[o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100",children:[o.jsx(Ee,{className:"font-bold text-black border-r w-12 shrink-0 text-center px-3",children:o.jsx(Co,{checked:Qt.length>0&&Qt.every(ae=>Ou.has(ae.id)),onCheckedChange:ae=>{es(ae===!0?new Set(Qt.map(Qe=>Qe.id)):new Set)},"aria-label":"Select all on page"})}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Name"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Email"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Phone"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Role"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Assigned Locations"}),o.jsx(Ee,{className:"font-bold text-black border-r",children:"Status"}),o.jsx(Ee,{className:"font-bold text-black text-center",children:"Actions"})]})}),o.jsx(pn,{children:Vn?o.jsx(nt,{children:o.jsx(xe,{colSpan:8,className:"text-center text-sm text-gray-500 py-10",children:"Loading..."})}):Qt.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:8,className:"text-center text-sm text-gray-500 py-10",children:"No results."})}):Qt.map(ae=>o.jsxs(nt,{children:[o.jsx(xe,{className:"border-r w-12 shrink-0 text-center px-3",children:o.jsx(Co,{checked:Ou.has(ae.id),onCheckedChange:Qe=>{es(bt=>{const Io=new Set(bt);return Qe===!0?Io.add(ae.id):Io.delete(ae.id),Io})},"aria-label":"Select row"})}),o.jsx(xe,{className:"font-medium border-r",children:ae.fullName??ae.userName??"N/A"}),o.jsx(xe,{className:"border-r text-gray-600",children:ae.email??"N/A"}),o.jsx(xe,{className:"border-r text-gray-600",children:ae.phone??"N/A"}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{variant:"outline",className:"font-normal",children:ZN(ae.roleName,ae.roleId)})}),o.jsx(xe,{className:"border-r",children:o.jsxs("div",{className:"flex flex-col gap-1",children:[(ae.locations?.length?ae.locations:ae.locationIds??[]).map(Qe=>o.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-600",children:[o.jsx(su,{className:"w-3 h-3"})," ",Qe]},Qe)),!ae.locations?.length&&!(ae.locationIds?.length??0)&&o.jsx("div",{className:"text-xs text-gray-500",children:"None"})]})}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{className:ae.state?"bg-green-600":"bg-gray-400",children:ae.state?"Active":"Inactive"})}),o.jsx(xe,{className:"text-center",children:o.jsxs("div",{className:"flex items-center justify-center gap-2",children:[o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{hr(ae),vl(!0)},title:"Edit",children:o.jsx(oa,{className:"w-4 h-4 text-gray-500"})}),o.jsx(de,{variant:"ghost",size:"sm",onClick:()=>{fl(ae),Mr(!0)},title:"Delete",children:o.jsx(zt,{className:"w-4 h-4 text-red-600"})})]})})]},ae.id))})]}),o.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 bg-white flex flex-wrap items-center justify-between gap-3",children:[o.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",qr===0?0:(Kt-1)*tr+1,"-",Math.min(Kt*tr,qr)," of ",qr]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs($e,{value:String(tr),onValueChange:ae=>Je(Number(ae)),children:[o.jsx(Be,{className:"w-[110px] h-9 rounded-md border border-gray-300 bg-white text-gray-900",children:o.jsx(Fe,{})}),o.jsx(ze,{children:[10,20,50].map(ae=>o.jsxs(we,{value:String(ae),children:[ae," / page"]},ae))})]}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),fr(Qe=>Math.max(1,Qe-1))},"aria-disabled":Kt<=1,className:Kt<=1?"pointer-events-none opacity-50":""})}),o.jsx(St,{children:o.jsxs(Cn,{href:"#",isActive:!0,size:"default",onClick:ae=>ae.preventDefault(),children:["Page ",Kt," / ",Et]})}),o.jsx(St,{children:o.jsx(ca,{href:"#",size:"default",onClick:ae=>{ae.preventDefault(),fr(Qe=>Math.min(Et,Qe+1))},"aria-disabled":Kt>=Et,className:Kt>=Et?"pointer-events-none opacity-50":""})})]})})]})]})]});case"Location Manager":return o.jsx(_0e,{renderBeforeTabs:ae=>o.jsxs("div",{className:"flex flex-col gap-4 pb-4 shrink-0",children:[ae,xl()]})})}},is=r==="Team Member"&&ph;return o.jsxs("div",{className:"h-full flex flex-col",children:[r!=="Location Manager"&&!is?Nh():null,r==="Location Manager"?o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:bl()}):is?o.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden pt-6",children:[o.jsx("div",{className:"shrink-0 pb-4",children:xl()}),o.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md flex-1 flex flex-col min-h-0 overflow-hidden",children:o.jsx(D0e,{seed:Bv,onBack:()=>{hl(!1),ml([])},onSaved:()=>{es(new Set),gr(ae=>ae+1)}})})})]}):o.jsx("div",{className:"flex-1 overflow-auto pt-6",children:o.jsx("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md",children:bl()})}),o.jsx(z0e,{open:zv,role:Uv,onOpenChange:ae=>{lr(ae),ae||ts(null)},onSaved:()=>{g(1),h(ae=>ae+1)}}),o.jsx(U0e,{open:vh,role:qv,onOpenChange:ae=>{rs(ae),ae||Au(null)}}),o.jsx(q0e,{open:pl,role:Vv,onOpenChange:ae=>{Wn(ae),ae||_n(null)},onDeleted:()=>h(ae=>ae+1)}),o.jsx(V0e,{open:Wv,partner:Hv,onOpenChange:ae=>{Iu(ae),ae||pi(null)},onSaved:()=>{G(1),Q(ae=>ae+1)}}),o.jsx(W0e,{open:gl,partner:yl,onOpenChange:ae=>{gi(ae),ae||xh(null)},onDeleted:()=>{Q(ae=>ae+1)}}),o.jsx(H0e,{open:Gv,group:bh,onOpenChange:ae=>{ns(ae),ae||as(null)},onSaved:()=>{qe(1),Ie(ae=>ae+1)}}),o.jsx(G0e,{open:os,group:Mu,onOpenChange:ae=>{wh(ae),ae||$t(null)},onDeleted:()=>{Ie(ae=>ae+1)}}),o.jsx(Y0e,{open:Sh,member:xt,onOpenChange:ae=>{vl(ae),ae||hr(null)},onSaved:()=>{fr(1),gr(ae=>ae+1)}}),o.jsx(uE,{open:Fv,onOpenChange:ao,title:"Bulk import team members",description:"Upload an .xlsx file. Use the official template for column headers.",downloadingTemplate:gh,onDownloadTemplate:async()=>{Tu(!0);try{await t0e(),ee.success("Template downloaded.")}catch(ae){const Qe=ae instanceof Error?ae.message:"Download failed.";ee.error("Template download failed",{description:Qe})}finally{Tu(!1)}},onImportFile:async ae=>{const Qe=await n0e(ae);return gr(bt=>bt+1),{successCount:Qe.successCount,failCount:Qe.failCount}}}),o.jsx(K0e,{open:Qr,member:Ao,onOpenChange:ae=>{Mr(ae),ae||fl(null)},onDeleted:()=>{gr(ae=>ae+1)}})]})}function z0e({open:e,role:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=v.useState(!1),[l,d]=v.useState(""),[c,f]=v.useState(""),[h,p]=v.useState(""),[g,x]=v.useState(""),[b,w]=v.useState(!0);v.useEffect(()=>{e&&(s(!1),d(t?.roleName??""),f(t?.roleCode??""),p(t?.remark??""),x(t?.orderNum===null||t?.orderNum===void 0?"":String(t.orderNum)),w(t?.state??!0))},[e,t]);const j=v.useMemo(()=>!!(l.trim()&&c.trim()&&g.trim()),[l,c,g]),N=O=>{const P=O.trim();if(!P)return null;const E=Number.parseInt(P,10);return Number.isFinite(E)?E:null},C=async()=>{if(console.log("submit",t),!j){ee.error("Please fill in required fields.",{description:"Role Name, Role Code, and Order are required."});return}s(!0);try{const O={roleName:l.trim(),roleCode:c.trim(),remark:h.trim()?h.trim():null,state:!!b,orderNum:N(g)};a&&t?.id?(await zve(t.id,O),ee.success("Role updated.",{description:"Role fields have been saved successfully."})):(await Bve(O),ee.success("Role created.",{description:"A new role has been created successfully."})),r(!1),n()}catch(O){ee.error(a?"Failed to update role.":"Failed to create role.",{description:O?.message?String(O.message):"Please try again."})}finally{s(!1)}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:a?"Edit Role":"Create Role"}),o.jsx(qt,{children:a?"Update role fields and save changes.":"Fill out the form to create a new role."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Role Name *"}),o.jsx(me,{value:l,onChange:O=>d(O.target.value),placeholder:"e.g. Inventory Specialist"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Role Code *"}),o.jsx(me,{value:c,onChange:O=>f(O.target.value),placeholder:"e.g. inventory_specialist"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Remark"}),o.jsx(me,{value:h,onChange:O=>p(O.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{value:g,onChange:O=>x(O.target.value),placeholder:"e.g. 10"})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:b,onCheckedChange:w})]})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:i,onClick:C,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function U0e({open:e,role:t,onOpenChange:r}){const n=t?.id??"",a=t?.roleName??"",[i,s]=v.useState(!1),[l,d]=v.useState([]),[c,f]=v.useState(new Set),[h,p]=v.useState(new Set),[g,x]=v.useState(!1),b=v.useRef(null),[w,j]=v.useState(""),N=v.useRef(null),[C,O]=v.useState("");v.useEffect(()=>(N.current&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>O(w.trim()),300),()=>{N.current&&window.clearTimeout(N.current)}),[w]),v.useEffect(()=>e?(s(!1),p(new Set),f(new Set),(async()=>{b.current?.abort();const W=new AbortController;b.current=W,x(!0);try{const q=await Tve(W.signal);if(d(q??[]),n){const M=await Wve(n,W.signal);p(new Set(M))}}catch(q){if(q?.name==="AbortError")return;ee.error("Failed to load menus.",{description:q?.message?String(q.message):"Please try again."}),d([]),p(new Set)}finally{x(!1)}})(),()=>b.current?.abort()):void 0,[e,n]);const P=v.useMemo(()=>{const H=W=>W.reduce((q,M)=>q+1+(M.children?H(M.children):0),0);return H(l)},[l]),E=v.useMemo(()=>{const H=C.trim().toLowerCase();if(!H)return l;const W=M=>{const Y=(M.menuName??"").toLowerCase(),F=(M.routeUrl??"").toLowerCase();return Y.includes(H)||F.includes(H)},q=M=>{const Y=[];for(const F of M){const D=F.children?q(F.children):[];(W(F)||D.length)&&Y.push({...F,children:D.length?D:void 0})}return Y};return q(l)},[l,C]);v.useEffect(()=>{if(!C.trim())return;const W=new Set,q=M=>{for(const Y of M)Y.children?.length&&W.add(Y.id),Y.children?.length&&q(Y.children)};q(E),f(W)},[C,E]);const T=H=>{const W=[],q=M=>{M.id&&W.push(M.id),M.children?.length&&M.children.forEach(q)};return q(H),W},A=H=>{const W=T(H);if(!W.length)return{checked:!1,indeterminate:!1};let q=0;for(const M of W)h.has(M)&&(q+=1);return q===0?{checked:!1,indeterminate:!1}:q===W.length?{checked:!0,indeterminate:!1}:{checked:!1,indeterminate:!0}},I=(H,W)=>{p(q=>{const M=new Set(q),Y=T(H);return W?Y.forEach(F=>M.add(F)):Y.forEach(F=>M.delete(F)),M})},R=H=>{f(W=>{const q=new Set(W);return q.has(H)?q.delete(H):q.add(H),q})},L=H=>{const W=C.trim(),q=H??"";if(!W)return q||"N/A";const M=q.toLowerCase().indexOf(W.toLowerCase());if(M<0)return q||"N/A";const Y=q.slice(0,M),F=q.slice(M,M+W.length),D=q.slice(M+W.length);return o.jsxs("span",{children:[Y,o.jsx("span",{className:"bg-yellow-200 rounded px-0.5",children:F}),D]})},V=({node:H,depth:W})=>{const q=!!H.children?.length,M=c.has(H.id),{checked:Y,indeterminate:F}=A(H);return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 py-1",style:{paddingLeft:W*16},children:[o.jsx("button",{type:"button",className:ke("h-6 w-6 flex items-center justify-center rounded hover:bg-gray-100",!q&&"opacity-0 pointer-events-none"),onClick:()=>q&&R(H.id),"aria-label":q?M?"Collapse":"Expand":"No children",children:q?M?o.jsx(Bs,{className:"h-4 w-4"}):o.jsx(Ui,{className:"h-4 w-4"}):null}),o.jsx(Co,{id:`perm-menu-${H.id}`,checked:F?"indeterminate":Y,onCheckedChange:D=>I(H,!!D)}),o.jsx("label",{htmlFor:`perm-menu-${H.id}`,className:"text-sm leading-none cursor-pointer select-none",children:L(H.menuName??H.routeUrl??H.id)})]}),q&&M&&o.jsx("div",{children:H.children.map(D=>o.jsx(V,{node:D,depth:W+1},D.id))})]})},z=async()=>{if(console.log("submit",t),!!n){s(!0);try{await Dve({roleId:n,menuIds:Array.from(h)}),ee.success("Role menu permissions saved.",{description:"Menu permissions have been updated successfully."}),r(!1)}catch(H){ee.error("Failed to save menu permissions.",{description:H?.message?String(H.message):"Please try again."})}finally{s(!1)}}},G=async()=>{if(!(!n||h.size===0)){s(!0);try{await Lve({roleId:n,menuIds:Array.from(h)}),p(new Set),ee.success("Role menu permissions cleared.",{description:"Selected permissions have been removed."})}catch(H){ee.error("Failed to delete menu permissions.",{description:H?.message?String(H.message):"Please try again."})}finally{s(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"50%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Menu Permissions"}),o.jsx(qt,{children:a?`Set menu permissions for role: ${a}`:"Set menu permissions for this role."})]}),o.jsx("div",{className:"space-y-4 py-4",children:o.jsxs("div",{className:"rounded border border-gray-200 bg-white",children:[o.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 border-b border-gray-200",children:o.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[o.jsx("div",{children:g?"Loading menus...":`Total ${P} menus`}),o.jsx(me,{value:w,onChange:H=>j(H.target.value),placeholder:"Search menus",className:"h-8 w-44 bg-white"})]})}),o.jsx(hC,{className:"h-72",children:o.jsxs("div",{className:"p-3 space-y-2",children:[E.map(H=>o.jsx(V,{node:H,depth:0},H.id)),!g&&E.length===0&&o.jsx("div",{className:"text-sm text-gray-500 py-6 text-center",children:"No menus."})]})})]})}),o.jsxs(Dt,{className:"flex flex-row justify-end gap-2",children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{variant:"destructive",className:"gap-2",disabled:i||h.size===0||!n,onClick:G,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),"Delete Selected"]}),o.jsx(de,{disabled:i||!n,onClick:z,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function q0e({open:e,role:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>(t?.roleName??"").trim()||t?.roleCode||t?.id||"this role",[t]),l=async()=>{if(console.log("submit",t),!!t?.id){i(!0);try{await Vve(t.id),ee.success("Role deleted.",{description:"The role has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete role.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Role"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function V0e({open:e,partner:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=v.useState(!1),[l,d]=v.useState(""),[c,f]=v.useState(""),[h,p]=v.useState(""),[g,x]=v.useState(!0);v.useEffect(()=>{e&&(s(!1),d(t?.partnerName??""),f(t?.contactEmail??""),p(t?.phoneNumber??""),x(t?.state??!0))},[e,t]);const b=async()=>{if(!l.trim()){ee.error("Company name is required.");return}s(!0);try{a&&t?.id?(await u0e(t.id,{partnerName:l.trim(),contactEmail:c.trim()?c.trim():null,phoneNumber:h.trim()?h.trim():null,state:g}),ee.success("Company updated.")):(await c0e({partnerName:l.trim(),contactEmail:c.trim()?c.trim():null,phoneNumber:h.trim()?h.trim():null,state:g}),ee.success("Company created.")),r(!1),n()}catch(w){ee.error(a?"Failed to update company.":"Failed to create company.",{description:w?.message?String(w.message):"Please try again."})}finally{s(!1)}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:a?"Edit Company":"Create New Company"}),o.jsx(qt,{children:a?"Update company details and save.":"Add a new company record."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Company Name *"}),o.jsx(me,{placeholder:"Company Name",value:l,onChange:w=>d(w.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Contact Email"}),o.jsx(me,{placeholder:"admin@company.com",value:c,onChange:w=>f(w.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Phone Number"}),o.jsx(me,{type:"tel",placeholder:"+1 (555) 000-0000",value:h,onChange:w=>p(w.target.value)})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(br,{id:"partner-status",checked:g,onCheckedChange:x}),o.jsx(ue,{htmlFor:"partner-status",children:"Active"})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:i,onClick:b,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function W0e({open:e,partner:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=(t?.partnerName??"").trim()||t?.id||"this company",l=async()=>{if(t?.id){i(!0);try{await d0e(t.id),ee.success("Company deleted."),r(!1),n()}catch(d){ee.error("Failed to delete company.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Company"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function H0e({open:e,group:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=v.useState(!1),[l,d]=v.useState(""),[c,f]=v.useState(""),[h,p]=v.useState(!0),[g,x]=v.useState([]),[b,w]=v.useState(!1);v.useEffect(()=>{if(!e)return;const N=new AbortController;return(async()=>{w(!0);try{const C=await $0e(N.signal);x(C)}catch(C){C?.name!=="AbortError"&&(ee.error("Failed to load companies.",{description:C?.message?String(C.message):"Please try again."}),x([]))}finally{w(!1)}})(),()=>N.abort()},[e]),v.useEffect(()=>{e&&(s(!1),d(t?.groupName??""),f(t?.partnerId??""),p(t?.state??!0))},[e,t]);const j=async()=>{if(!l.trim()||!c.trim()){ee.error("Region name and company are required.");return}s(!0);try{a&&t?.id?(await v0e(t.id,{groupName:l.trim(),partnerId:c.trim(),state:h}),ee.success("Region updated.")):(await y0e({groupName:l.trim(),partnerId:c.trim(),state:h}),ee.success("Region created.")),r(!1),n()}catch(N){ee.error(a?"Failed to update region.":"Failed to create region.",{description:N?.message?String(N.message):"Please try again."})}finally{s(!1)}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-[600px]",children:[o.jsxs(At,{children:[o.jsx(It,{children:a?"Edit Region":"Create New Region"}),o.jsx(qt,{children:a?"Update region and parent company.":"Create a region under an active company."})]}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Region Name *"}),o.jsx(me,{placeholder:"e.g. West Coast Region",value:l,onChange:N=>d(N.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Assign to Company *"}),o.jsxs($e,{value:c||void 0,onValueChange:f,disabled:b,children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:b?"Loading companies...":"Select Company"})}),o.jsx(ze,{children:g.map(N=>o.jsx(we,{value:N.id,children:N.partnerName??N.id},N.id))})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(br,{id:"group-status",checked:h,onCheckedChange:p}),o.jsx(ue,{htmlFor:"group-status",children:"Active"})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:i||b,onClick:j,className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":"Save"})]})]})})}function G0e({open:e,group:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=(t?.groupName??"").trim()||t?.id||"this region",l=async()=>{if(t?.id){i(!0);try{await x0e(t.id),ee.success("Region deleted."),r(!1),n()}catch(d){ee.error("Failed to delete region.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete Region"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function Y0e({open:e,member:t,onOpenChange:r,onSaved:n}){const a=!!t?.id,[i,s]=v.useState(!1),[l,d]=v.useState(""),[c,f]=v.useState(""),[h,p]=v.useState(""),[g,x]=v.useState(""),[b,w]=v.useState(""),[j,N]=v.useState(""),[C,O]=v.useState(!0),[P,E]=v.useState(new Set),[T,A]=v.useState([]),[I,R]=v.useState(!1),[L,V]=v.useState([]),[z,G]=v.useState(!1),[H,W]=v.useState(""),q=v.useRef(null),M=()=>{d(""),f(""),p(""),x(""),w(""),N(""),O(!0),E(new Set)},Y=async re=>{const Q=[];let ce=1;const se=100;for(;;){const be=await dE({skipCount:ce,maxResultCount:se},re);if(Q.push(...be.items??[]),!be.items||be.items.length200))break}const fe=new Map;for(const be of Q)be.id&&!fe.has(be.id)&&fe.set(be.id,be);return Array.from(fe.values())},F=async re=>{const Q=[];let ce=1;const se=200;for(;;){const be=await Nu({skipCount:ce,maxResultCount:se},re);if(Q.push(...be.items??[]),!be.items||be.items.length200))break}const fe=new Map;for(const be of Q)be.id&&!fe.has(be.id)&&fe.set(be.id,be);return Array.from(fe.values())};v.useEffect(()=>{if(!e)return;q.current?.abort();const re=new AbortController;return q.current=re,s(!1),M(),R(!0),G(!0),(async()=>{try{const[ce,se]=await Promise.all([Y(re.signal),F(re.signal)]);if(A(ce),V(se),t?.id){const fe=await Kve(t.id,re.signal);d(fe.fullName??""),f(fe.userName??""),x(fe.email??""),w(fe.phone!=null?String(fe.phone):"");let be=(fe.roleId??"").toString().trim();if(!be&&fe.roleName){const Se=String(fe.roleName).trim().toLowerCase(),Ne=ce.find(qe=>{const De=String(qe.roleName??"").trim().toLowerCase(),He=String(qe.roleCode??"").trim().toLowerCase(),ne=String(qe.id??"").trim().toLowerCase();return De===Se||He===Se||ne===Se});Ne?.id&&(be=Ne.id)}N(be),O(!!fe.state);const Z=fe.locationIds&&fe.locationIds.length?fe.locationIds:[];if(Z.length)E(new Set(Z));else if(fe.locations?.length){const Se=new Set(fe.locations),Ne=new Set;for(const qe of se){const De=`${(qe.locationCode??"").trim()} - ${(qe.locationName??"").trim()}`.trim(),He=(qe.locationName??"").trim(),ne=(qe.locationCode??"").trim();(Se.has(De)||Se.has(He)||Se.has(ne))&&Ne.add(qe.id)}E(Ne)}}}catch(ce){ce?.name!=="AbortError"&&ee.error("Failed to load user form.",{description:ce?.message?String(ce.message):"Please try again."})}finally{R(!1),G(!1)}})(),()=>re.abort()},[e,t?.id]);const D=v.useMemo(()=>!(!l.trim()||!c.trim()||!g.trim()||!String(b??"").trim()||!j.trim()||P.size===0||!a&&!h.trim()),[l,c,g,b,j,P,a,h]),$=(re,Q)=>{E(ce=>{const se=new Set(ce);return Q?se.add(re):se.delete(re),se})},K=async re=>{if(re?.preventDefault(),re?.stopPropagation(),console.log("[MemberDialog] submit called",{isEdit:a,memberId:t?.id,canSubmit:D,roleId:j,fullName:l,userName:c,selectedLocationIds:P.size}),!D){const Q=[];l.trim()||Q.push("Full Name"),c.trim()||Q.push("User Name"),g.trim()||Q.push("Email"),String(b??"").trim()||Q.push("Phone"),j.trim()||Q.push("Role"),P.size===0&&Q.push("Locations"),!a&&!h.trim()&&Q.push("Password"),ee.error("Missing required fields.",{description:`Please fill: ${Q.join(", ")}.`});return}if(!a&&!t?.id){s(!0);try{const Q=Array.from(P);console.log("[MemberDialog] Creating user",{fullName:l,userName:c,roleId:j,locationIds:Q}),await Qve({fullName:l.trim(),userName:c.trim(),password:h.trim(),email:g.trim(),phone:String(b).trim(),roleId:j.trim(),locationIds:Q,state:C}),ee.success("User created.",{description:"A new user has been created successfully."}),r(!1),n()}catch(Q){console.error("[MemberDialog] Create error",Q),ee.error("Failed to create user.",{description:Q?.message?String(Q.message):"Please try again."})}finally{s(!1)}}else if(a&&t?.id){s(!0);try{const Q=Array.from(P);console.log("[MemberDialog] Updating user",{id:t.id,fullName:l,userName:c,roleId:j,locationIds:Q}),await Zve(t.id,{fullName:l.trim(),userName:c.trim(),password:h.trim()?h.trim():null,email:g.trim(),phone:String(b).trim(),roleId:j.trim(),locationIds:Q,state:C}),ee.success("User updated.",{description:"Changes have been saved successfully."}),r(!1),n()}catch(Q){console.error("[MemberDialog] Update error",Q),ee.error("Failed to update user.",{description:Q?.message?String(Q.message):"Please try again."})}finally{s(!1)}}else console.error("[MemberDialog] Invalid state",{isEdit:a,memberId:t?.id}),ee.error("Invalid form state.",{description:"Please refresh and try again."})},J=re=>{const Q=(re.locationCode??"").trim(),ce=(re.locationName??"").trim();return Q&&ce?`${Q} - ${ce}`:ce||Q||re.id},oe=v.useMemo(()=>{const re=H.trim().toLowerCase();return re?L.filter(Q=>J(Q).toLowerCase().includes(re)):L},[L,H]);return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"50%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:a?"Edit User":"New User"}),o.jsx(qt,{children:"Role is single-select; Locations is multi-select."})]}),o.jsxs("div",{className:"space-y-4 py-4 max-h-[70vh] overflow-y-auto pr-1",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Full Name *"}),o.jsx(me,{value:l,onChange:re=>d(re.target.value),placeholder:"John Doe"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"User Name *"}),o.jsx(me,{value:c,onChange:re=>f(re.target.value),placeholder:"username"})]})]}),!a&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Password *"}),o.jsx(me,{type:"password",value:h,onChange:re=>p(re.target.value),placeholder:"Enter password",autoComplete:"new-password",className:"w-full"})]}),a&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Password (Optional)"}),o.jsx(me,{type:"password",value:h,onChange:re=>p(re.target.value),placeholder:"Enter new password (optional)",autoComplete:"new-password",className:"w-full"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Email *"}),o.jsx(me,{value:g,onChange:re=>x(re.target.value),placeholder:"john@example.com"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Phone *"}),o.jsx(me,{value:b,onChange:re=>w(re.target.value),placeholder:"+1 (555) 000-0000"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Role *"}),o.jsxs($e,{value:j||"",onValueChange:re=>{const Q=re&&re.trim()?re.trim():"";console.log("[MemberDialog] Role changed",{old:j,new:Q,v:re}),N(Q)},disabled:I,children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:I?"Loading roles...":"Select role"})}),o.jsx(ze,{children:T.map(re=>o.jsx(we,{value:re.id,children:ZN(re.roleName,re.roleCode??re.id)},re.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Locations *"}),o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx(me,{value:H,onChange:re=>W(re.target.value),placeholder:"Search locations",className:"h-9"}),o.jsxs("div",{className:"text-xs text-gray-500 shrink-0",children:[P.size," selected"]})]}),o.jsx(hC,{className:"h-[180px] w-full border rounded-md p-2",children:o.jsx("div",{className:"space-y-2",children:z?o.jsx("div",{className:"text-sm text-gray-500 py-2",children:"Loading..."}):oe.map(re=>o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Co,{id:`loc-${re.id}`,checked:P.has(re.id),onCheckedChange:Q=>$(re.id,!!Q)}),o.jsx("label",{htmlFor:`loc-${re.id}`,className:"text-sm cursor-pointer w-full hover:bg-gray-50 p-1 rounded",children:J(re)})]},re.id))})}),o.jsx("p",{className:"text-xs text-gray-500",children:"* Users must be assigned to at least one location."})]}),o.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[o.jsx(br,{id:"member-status",checked:C,onCheckedChange:O}),o.jsx(ue,{htmlFor:"member-status",children:C?"Active":"Inactive"})]})]}),o.jsxs(Dt,{children:[o.jsx(de,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsx(de,{disabled:i||!D,onClick:re=>{re.preventDefault(),re.stopPropagation(),K(re)},className:"bg-blue-600 text-white hover:bg-blue-700",children:i?"Saving...":a?"Save":"Create"})]})]})})}function K0e({open:e,member:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>{const d=(t?.fullName??"").trim(),c=(t?.userName??"").trim();return d||c||"this user"},[t?.fullName,t?.userName]),l=async()=>{if(console.log("submit",t),!!t?.id){i(!0);try{await e0e(t.id),ee.success("User deleted.",{description:"The user has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete user.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete User"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{variant:"outline",className:"min-w-24",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{variant:"destructive",className:"min-w-24 gap-2",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}function Rt(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function ha(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function bn(e,t){const r=Rt(e);return isNaN(t)?ha(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Za(e,t){const r=Rt(e);if(isNaN(t))return ha(e,NaN);if(!t)return r;const n=r.getDate(),a=ha(e,r.getTime());a.setMonth(r.getMonth()+t+1,0);const i=a.getDate();return n>=i?a:(r.setFullYear(a.getFullYear(),a.getMonth(),n),r)}const hE=6048e5,X0e=864e5;let J0e={};function dh(){return J0e}function _o(e,t){const r=dh(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Rt(e),i=a.getDay(),s=(i=a.getTime()?r+1:t.getTime()>=s.getTime()?r:r-1}function iu(e){const t=Rt(e);return t.setHours(0,0,0,0),t}function uy(e){const t=Rt(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function yo(e,t){const r=iu(e),n=iu(t),a=+r-uy(r),i=+n-uy(n);return Math.round((a-i)/X0e)}function Q0e(e){const t=uz(e),r=ha(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),al(r)}function eC(e,t){const r=t*7;return bn(e,r)}function Z0e(e,t){return Za(e,t*12)}function exe(e){let t;return e.forEach(function(r){const n=Rt(r);(t===void 0||t{const n=Rt(r);(!t||t>n||isNaN(+n))&&(t=n)}),t||new Date(NaN)}function Fn(e,t){const r=iu(e),n=iu(t);return+r==+n}function mE(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function rxe(e){if(!mE(e)&&typeof e!="number")return!1;const t=Rt(e);return!isNaN(Number(t))}function If(e,t){const r=Rt(e),n=Rt(t),a=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return a*12+i}function nxe(e,t,r){const n=_o(e,r),a=_o(t,r),i=+n-uy(n),s=+a-uy(a);return Math.round((i-s)/hE)}function pE(e){const t=Rt(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function zn(e){const t=Rt(e);return t.setDate(1),t.setHours(0,0,0,0),t}function dz(e){const t=Rt(e),r=ha(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}function gE(e,t){const r=dh(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=Rt(e),i=a.getDay(),s=(i{let n;const a=axe[e];return typeof a=="string"?n=a:t===1?n=a.one:n=a.other.replace("{{count}}",t.toString()),r?.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function ZS(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const ixe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},sxe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},lxe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},cxe={date:ZS({formats:ixe,defaultWidth:"full"}),time:ZS({formats:sxe,defaultWidth:"full"}),dateTime:ZS({formats:lxe,defaultWidth:"full"})},uxe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},dxe=(e,t,r,n)=>uxe[e];function Ad(e){return(t,r)=>{const n=r?.context?String(r.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const s=e.defaultFormattingWidth||e.defaultWidth,l=r?.width?String(r.width):s;a=e.formattingValues[l]||e.formattingValues[s]}else{const s=e.defaultWidth,l=r?.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[s]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const fxe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},hxe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},mxe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},pxe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},gxe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},yxe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},vxe=(e,t)=>{const r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},xxe={ordinalNumber:vxe,era:Ad({values:fxe,defaultWidth:"wide"}),quarter:Ad({values:hxe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Ad({values:mxe,defaultWidth:"wide"}),day:Ad({values:pxe,defaultWidth:"wide"}),dayPeriod:Ad({values:gxe,defaultWidth:"wide",formattingValues:yxe,defaultFormattingWidth:"wide"})};function Id(e){return(t,r={})=>{const n=r.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const s=i[0],l=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(l)?wxe(l,h=>h.test(s)):bxe(l,h=>h.test(s));let c;c=e.valueCallback?e.valueCallback(d):d,c=r.valueCallback?r.valueCallback(c):c;const f=t.slice(s.length);return{value:c,rest:f}}}function bxe(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function wxe(e,t){for(let r=0;r{const n=t.match(e.matchPattern);if(!n)return null;const a=n[0],i=t.match(e.parsePattern);if(!i)return null;let s=e.valueCallback?e.valueCallback(i[0]):i[0];s=r.valueCallback?r.valueCallback(s):s;const l=t.slice(a.length);return{value:s,rest:l}}}const jxe=/^(\d+)(th|st|nd|rd)?/i,Nxe=/\d+/i,Cxe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},_xe={any:[/^b/i,/^(a|c)/i]},Exe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Pxe={any:[/1/i,/2/i,/3/i,/4/i]},Oxe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Txe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},kxe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Axe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ixe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Mxe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Rxe={ordinalNumber:Sxe({matchPattern:jxe,parsePattern:Nxe,valueCallback:e=>parseInt(e,10)}),era:Id({matchPatterns:Cxe,defaultMatchWidth:"wide",parsePatterns:_xe,defaultParseWidth:"any"}),quarter:Id({matchPatterns:Exe,defaultMatchWidth:"wide",parsePatterns:Pxe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Id({matchPatterns:Oxe,defaultMatchWidth:"wide",parsePatterns:Txe,defaultParseWidth:"any"}),day:Id({matchPatterns:kxe,defaultMatchWidth:"wide",parsePatterns:Axe,defaultParseWidth:"any"}),dayPeriod:Id({matchPatterns:Ixe,defaultMatchWidth:"any",parsePatterns:Mxe,defaultParseWidth:"any"})},hz={code:"en-US",formatDistance:oxe,formatLong:cxe,formatRelative:dxe,localize:xxe,match:Rxe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Dxe(e){const t=Rt(e);return yo(t,dz(t))+1}function mz(e){const t=Rt(e),r=+al(t)-+Q0e(t);return Math.round(r/hE)+1}function pz(e,t){const r=Rt(e),n=r.getFullYear(),a=dh(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=ha(e,0);s.setFullYear(n+1,0,i),s.setHours(0,0,0,0);const l=_o(s,t),d=ha(e,0);d.setFullYear(n,0,i),d.setHours(0,0,0,0);const c=_o(d,t);return r.getTime()>=l.getTime()?n+1:r.getTime()>=c.getTime()?n:n-1}function Lxe(e,t){const r=dh(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=pz(e,t),i=ha(e,0);return i.setFullYear(a,0,n),i.setHours(0,0,0,0),_o(i,t)}function gz(e,t){const r=Rt(e),n=+_o(r,t)-+Lxe(r,t);return Math.round(n/hE)+1}function Yt(e,t){const r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}const Mi={y(e,t){const r=e.getFullYear(),n=r>0?r:1-r;return Yt(t==="yy"?n%100:n,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):Yt(r+1,2)},d(e,t){return Yt(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return Yt(e.getHours()%12||12,t.length)},H(e,t){return Yt(e.getHours(),t.length)},m(e,t){return Yt(e.getMinutes(),t.length)},s(e,t){return Yt(e.getSeconds(),t.length)},S(e,t){const r=t.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return Yt(a,t.length)}},nc={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},s$={G:function(e,t,r){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return r.ordinalNumber(a,{unit:"year"})}return Mi.y(e,t)},Y:function(e,t,r,n){const a=pz(e,n),i=a>0?a:1-a;if(t==="YY"){const s=i%100;return Yt(s,2)}return t==="Yo"?r.ordinalNumber(i,{unit:"year"}):Yt(i,t.length)},R:function(e,t){const r=uz(e);return Yt(r,t.length)},u:function(e,t){const r=e.getFullYear();return Yt(r,t.length)},Q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return Yt(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return Yt(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){const n=e.getMonth();switch(t){case"M":case"MM":return Mi.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return Yt(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){const a=gz(e,n);return t==="wo"?r.ordinalNumber(a,{unit:"week"}):Yt(a,t.length)},I:function(e,t,r){const n=mz(e);return t==="Io"?r.ordinalNumber(n,{unit:"week"}):Yt(n,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):Mi.d(e,t)},D:function(e,t,r){const n=Dxe(e);return t==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Yt(n,t.length)},E:function(e,t,r){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return Yt(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){const a=e.getDay(),i=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return Yt(i,t.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const n=e.getDay(),a=n===0?7:n;switch(t){case"i":return String(a);case"ii":return Yt(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const n=e.getHours();let a;switch(n===12?a=nc.noon:n===0?a=nc.midnight:a=n/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const n=e.getHours();let a;switch(n>=17?a=nc.evening:n>=12?a=nc.afternoon:n>=4?a=nc.morning:a=nc.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let n=e.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Mi.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):Mi.H(e,t)},K:function(e,t,r){const n=e.getHours()%12;return t==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Yt(n,t.length)},k:function(e,t,r){let n=e.getHours();return n===0&&(n=24),t==="ko"?r.ordinalNumber(n,{unit:"hour"}):Yt(n,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):Mi.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):Mi.s(e,t)},S:function(e,t){return Mi.S(e,t)},X:function(e,t,r){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return c$(n);case"XXXX":case"XX":return ks(n);case"XXXXX":case"XXX":default:return ks(n,":")}},x:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"x":return c$(n);case"xxxx":case"xx":return ks(n);case"xxxxx":case"xxx":default:return ks(n,":")}},O:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+l$(n,":");case"OOOO":default:return"GMT"+ks(n,":")}},z:function(e,t,r){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+l$(n,":");case"zzzz":default:return"GMT"+ks(n,":")}},t:function(e,t,r){const n=Math.trunc(e.getTime()/1e3);return Yt(n,t.length)},T:function(e,t,r){const n=e.getTime();return Yt(n,t.length)}};function l$(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),i=n%60;return i===0?r+String(a):r+String(a)+t+Yt(i,2)}function c$(e,t){return e%60===0?(e>0?"-":"+")+Yt(Math.abs(e)/60,2):ks(e,t)}function ks(e,t=""){const r=e>0?"-":"+",n=Math.abs(e),a=Yt(Math.trunc(n/60),2),i=Yt(n%60,2);return r+a+t+i}const u$=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},yz=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},$xe=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return u$(e,t);let i;switch(n){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",u$(n,t)).replace("{{time}}",yz(a,t))},Fxe={p:yz,P:$xe},Bxe=/^D+$/,zxe=/^Y+$/,Uxe=["D","DD","YY","YYYY"];function qxe(e){return Bxe.test(e)}function Vxe(e){return zxe.test(e)}function Wxe(e,t,r){const n=Hxe(e,t,r);if(console.warn(n),Uxe.includes(e))throw new RangeError(n)}function Hxe(e,t,r){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Gxe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Yxe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Kxe=/^'([^]*?)'?$/,Xxe=/''/g,Jxe=/[a-zA-Z]/;function dl(e,t,r){const n=dh(),a=r?.locale??n.locale??hz,i=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,s=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,l=Rt(e);if(!rxe(l))throw new RangeError("Invalid time value");let d=t.match(Yxe).map(f=>{const h=f[0];if(h==="p"||h==="P"){const p=Fxe[h];return p(f,a.formatLong)}return f}).join("").match(Gxe).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const h=f[0];if(h==="'")return{isToken:!1,value:Qxe(f)};if(s$[h])return{isToken:!0,value:f};if(h.match(Jxe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+h+"`");return{isToken:!1,value:f}});a.localize.preprocessor&&(d=a.localize.preprocessor(l,d));const c={firstWeekContainsDate:i,weekStartsOn:s,locale:a};return d.map(f=>{if(!f.isToken)return f.value;const h=f.value;(!r?.useAdditionalWeekYearTokens&&Vxe(h)||!r?.useAdditionalDayOfYearTokens&&qxe(h))&&Wxe(h,t,String(e));const p=s$[h[0]];return p(l,h,a.localize,c)}).join("")}function Qxe(e){const t=e.match(Kxe);return t?t[1].replace(Xxe,"'"):e}function Zxe(e){const t=Rt(e),r=t.getFullYear(),n=t.getMonth(),a=ha(e,0);return a.setFullYear(r,n+1,0),a.setHours(0,0,0,0),a.getDate()}function ebe(e){return Math.trunc(+Rt(e)/1e3)}function tbe(e){const t=Rt(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(0,0,0,0),t}function rbe(e,t){return nxe(tbe(e),zn(e),t)+1}function tC(e,t){const r=Rt(e),n=Rt(t);return r.getTime()>n.getTime()}function vz(e,t){const r=Rt(e),n=Rt(t);return+r<+n}function yE(e,t){const r=Rt(e),n=Rt(t);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()}function nbe(e,t){const r=Rt(e),n=Rt(t);return r.getFullYear()===n.getFullYear()}function ej(e,t){return bn(e,-t)}function tj(e,t){const r=Rt(e),n=r.getFullYear(),a=r.getDate(),i=ha(e,0);i.setFullYear(n,t,15),i.setHours(0,0,0,0);const s=Zxe(i);return r.setMonth(t,Math.min(a,s)),r}function d$(e,t){const r=Rt(e);return isNaN(+r)?ha(e,NaN):(r.setFullYear(t),r)}var ft=function(){return ft=Object.assign||function(t){for(var r,n=1,a=arguments.length;n1&&(d||!c),h=t>1&&(c||!d),p=function(){n&&i(n)},g=function(){a&&i(a)};return o.jsx(Dbe,{displayMonth:e.displayMonth,hideNext:f,hidePrevious:h,nextMonth:a,previousMonth:n,onPreviousClick:p,onNextClick:g})}function Lbe(e){var t,r=ir(),n=r.classNames,a=r.disableNavigation,i=r.styles,s=r.captionLayout,l=r.components,d=(t=l?.CaptionLabel)!==null&&t!==void 0?t:wz,c;return a?c=o.jsx(d,{id:e.id,displayMonth:e.displayMonth}):s==="dropdown"?c=o.jsx(f$,{displayMonth:e.displayMonth,id:e.id}):s==="dropdown-buttons"?c=o.jsxs(o.Fragment,{children:[o.jsx(f$,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),o.jsx(h$,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):c=o.jsxs(o.Fragment,{children:[o.jsx(d,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),o.jsx(h$,{displayMonth:e.displayMonth,id:e.id})]}),o.jsx("div",{className:n.caption,style:i.caption,children:c})}function $be(e){var t=ir(),r=t.footer,n=t.styles,a=t.classNames.tfoot;return r?o.jsx("tfoot",{className:a,style:n.tfoot,children:o.jsx("tr",{children:o.jsx("td",{colSpan:8,children:r})})}):o.jsx(o.Fragment,{})}function Fbe(e,t,r){for(var n=r?al(new Date):_o(new Date,{locale:e,weekStartsOn:t}),a=[],i=0;i<7;i++){var s=bn(n,i);a.push(s)}return a}function Bbe(){var e=ir(),t=e.classNames,r=e.styles,n=e.showWeekNumber,a=e.locale,i=e.weekStartsOn,s=e.ISOWeek,l=e.formatters.formatWeekdayName,d=e.labels.labelWeekday,c=Fbe(a,i,s);return o.jsxs("tr",{style:r.head_row,className:t.head_row,children:[n&&o.jsx("td",{style:r.head_cell,className:t.head_cell}),c.map(function(f,h){return o.jsx("th",{scope:"col",className:t.head_cell,style:r.head_cell,"aria-label":d(f,{locale:a}),children:l(f,{locale:a})},h)})]})}function zbe(){var e,t=ir(),r=t.classNames,n=t.styles,a=t.components,i=(e=a?.HeadRow)!==null&&e!==void 0?e:Bbe;return o.jsx("thead",{style:n.head,className:r.head,children:o.jsx(i,{})})}function Ube(e){var t=ir(),r=t.locale,n=t.formatters.formatDay;return o.jsx(o.Fragment,{children:n(e.date,{locale:r})})}var vE=v.createContext(void 0);function qbe(e){if(!fh(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return o.jsx(vE.Provider,{value:t,children:e.children})}return o.jsx(Vbe,{initialProps:e.initialProps,children:e.children})}function Vbe(e){var t=e.initialProps,r=e.children,n=t.selected,a=t.min,i=t.max,s=function(c,f,h){var p,g;(p=t.onDayClick)===null||p===void 0||p.call(t,c,f,h);var x=!!(f.selected&&a&&n?.length===a);if(!x){var b=!!(!f.selected&&i&&n?.length===i);if(!b){var w=n?xz([],n):[];if(f.selected){var j=w.findIndex(function(N){return Fn(c,N)});w.splice(j,1)}else w.push(c);(g=t.onSelect)===null||g===void 0||g.call(t,w,c,f,h)}}},l={disabled:[]};n&&l.disabled.push(function(c){var f=i&&n.length>i-1,h=n.some(function(p){return Fn(p,c)});return!!(f&&!h)});var d={selected:n,onDayClick:s,modifiers:l};return o.jsx(vE.Provider,{value:d,children:r})}function xE(){var e=v.useContext(vE);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function Wbe(e,t){var r=t||{},n=r.from,a=r.to;return n&&a?Fn(a,e)&&Fn(n,e)?void 0:Fn(a,e)?{from:a,to:void 0}:Fn(n,e)?void 0:tC(n,e)?{from:e,to:a}:{from:n,to:e}:a?tC(e,a)?{from:a,to:e}:{from:e,to:a}:n?vz(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var bE=v.createContext(void 0);function Hbe(e){if(!hh(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return o.jsx(bE.Provider,{value:t,children:e.children})}return o.jsx(Gbe,{initialProps:e.initialProps,children:e.children})}function Gbe(e){var t=e.initialProps,r=e.children,n=t.selected,a=n||{},i=a.from,s=a.to,l=t.min,d=t.max,c=function(g,x,b){var w,j;(w=t.onDayClick)===null||w===void 0||w.call(t,g,x,b);var N=Wbe(g,n);(j=t.onSelect)===null||j===void 0||j.call(t,N,g,x,b)},f={range_start:[],range_end:[],range_middle:[],disabled:[]};if(i?(f.range_start=[i],s?(f.range_end=[s],Fn(i,s)||(f.range_middle=[{after:i,before:s}])):f.range_end=[i]):s&&(f.range_start=[s],f.range_end=[s]),l&&(i&&!s&&f.disabled.push({after:ej(i,l-1),before:bn(i,l-1)}),i&&s&&f.disabled.push({after:i,before:bn(i,l-1)}),!i&&s&&f.disabled.push({after:ej(s,l-1),before:bn(s,l-1)})),d){if(i&&!s&&(f.disabled.push({before:bn(i,-d+1)}),f.disabled.push({after:bn(i,d-1)})),i&&s){var h=yo(s,i)+1,p=d-h;f.disabled.push({before:ej(i,p)}),f.disabled.push({after:bn(s,p)})}!i&&s&&(f.disabled.push({before:bn(s,-d+1)}),f.disabled.push({after:bn(s,d-1)}))}return o.jsx(bE.Provider,{value:{selected:n,onDayClick:c,modifiers:f},children:r})}function wE(){var e=v.useContext(bE);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function qp(e){return Array.isArray(e)?xz([],e):e!==void 0?[e]:[]}function Ybe(e){var t={};return Object.entries(e).forEach(function(r){var n=r[0],a=r[1];t[n]=qp(a)}),t}var eo;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(eo||(eo={}));var Kbe=eo.Selected,Wo=eo.Disabled,Xbe=eo.Hidden,Jbe=eo.Today,rj=eo.RangeEnd,nj=eo.RangeMiddle,aj=eo.RangeStart,Qbe=eo.Outside;function Zbe(e,t,r){var n,a=(n={},n[Kbe]=qp(e.selected),n[Wo]=qp(e.disabled),n[Xbe]=qp(e.hidden),n[Jbe]=[e.today],n[rj]=[],n[nj]=[],n[aj]=[],n[Qbe]=[],n);return e.fromDate&&a[Wo].push({before:e.fromDate}),e.toDate&&a[Wo].push({after:e.toDate}),fh(e)?a[Wo]=a[Wo].concat(t.modifiers[Wo]):hh(e)&&(a[Wo]=a[Wo].concat(r.modifiers[Wo]),a[aj]=r.modifiers[aj],a[nj]=r.modifiers[nj],a[rj]=r.modifiers[rj]),a}var Nz=v.createContext(void 0);function ewe(e){var t=ir(),r=xE(),n=wE(),a=Zbe(t,r,n),i=Ybe(t.modifiers),s=ft(ft({},a),i);return o.jsx(Nz.Provider,{value:s,children:e.children})}function Cz(){var e=v.useContext(Nz);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function twe(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function rwe(e){return!!(e&&typeof e=="object"&&"from"in e)}function nwe(e){return!!(e&&typeof e=="object"&&"after"in e)}function awe(e){return!!(e&&typeof e=="object"&&"before"in e)}function owe(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function iwe(e,t){var r,n=t.from,a=t.to;if(n&&a){var i=yo(a,n)<0;i&&(r=[a,n],n=r[0],a=r[1]);var s=yo(e,n)>=0&&yo(a,e)>=0;return s}return a?Fn(a,e):n?Fn(n,e):!1}function swe(e){return mE(e)}function lwe(e){return Array.isArray(e)&&e.every(mE)}function cwe(e,t){return t.some(function(r){if(typeof r=="boolean")return r;if(swe(r))return Fn(e,r);if(lwe(r))return r.includes(e);if(rwe(r))return iwe(e,r);if(owe(r))return r.dayOfWeek.includes(e.getDay());if(twe(r)){var n=yo(r.before,e),a=yo(r.after,e),i=n>0,s=a<0,l=tC(r.before,r.after);return l?s&&i:i||s}return nwe(r)?yo(e,r.after)>0:awe(r)?yo(r.before,e)>0:typeof r=="function"?r(e):!1})}function SE(e,t,r){var n=Object.keys(t).reduce(function(i,s){var l=t[s];return cwe(e,l)&&i.push(s),i},[]),a={};return n.forEach(function(i){return a[i]=!0}),r&&!yE(e,r)&&(a.outside=!0),a}function uwe(e,t){for(var r=zn(e[0]),n=pE(e[e.length-1]),a,i,s=r;s<=n;){var l=SE(s,t),d=!l.disabled&&!l.hidden;if(!d){s=bn(s,1);continue}if(l.selected)return s;l.today&&!i&&(i=s),a||(a=s),s=bn(s,1)}return i||a}var dwe=365;function _z(e,t){var r=t.moveBy,n=t.direction,a=t.context,i=t.modifiers,s=t.retry,l=s===void 0?{count:0,lastFocused:e}:s,d=a.weekStartsOn,c=a.fromDate,f=a.toDate,h=a.locale,p={day:bn,week:eC,month:Za,year:Z0e,startOfWeek:function(w){return a.ISOWeek?al(w):_o(w,{locale:h,weekStartsOn:d})},endOfWeek:function(w){return a.ISOWeek?fz(w):gE(w,{locale:h,weekStartsOn:d})}},g=p[r](e,n==="after"?1:-1);n==="before"&&c?g=exe([c,g]):n==="after"&&f&&(g=txe([f,g]));var x=!0;if(i){var b=SE(g,i);x=!b.disabled&&!b.hidden}return x?g:l.count>dwe?l.lastFocused:_z(g,{moveBy:r,direction:n,context:a,modifiers:i,retry:ft(ft({},l),{count:l.count+1})})}var Ez=v.createContext(void 0);function fwe(e){var t=mh(),r=Cz(),n=v.useState(),a=n[0],i=n[1],s=v.useState(),l=s[0],d=s[1],c=uwe(t.displayMonths,r),f=a??(l&&t.isDateDisplayed(l))?l:c,h=function(){d(a),i(void 0)},p=function(w){i(w)},g=ir(),x=function(w,j){if(a){var N=_z(a,{moveBy:w,direction:j,context:g,modifiers:r});Fn(a,N)||(t.goToDate(N,a),p(N))}},b={focusedDay:a,focusTarget:f,blur:h,focus:p,focusDayAfter:function(){return x("day","after")},focusDayBefore:function(){return x("day","before")},focusWeekAfter:function(){return x("week","after")},focusWeekBefore:function(){return x("week","before")},focusMonthBefore:function(){return x("month","before")},focusMonthAfter:function(){return x("month","after")},focusYearBefore:function(){return x("year","before")},focusYearAfter:function(){return x("year","after")},focusStartOfWeek:function(){return x("startOfWeek","before")},focusEndOfWeek:function(){return x("endOfWeek","after")}};return o.jsx(Ez.Provider,{value:b,children:e.children})}function jE(){var e=v.useContext(Ez);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function hwe(e,t){var r=Cz(),n=SE(e,r,t);return n}var NE=v.createContext(void 0);function mwe(e){if(!Lv(e.initialProps)){var t={selected:void 0};return o.jsx(NE.Provider,{value:t,children:e.children})}return o.jsx(pwe,{initialProps:e.initialProps,children:e.children})}function pwe(e){var t=e.initialProps,r=e.children,n=function(i,s,l){var d,c,f;if((d=t.onDayClick)===null||d===void 0||d.call(t,i,s,l),s.selected&&!t.required){(c=t.onSelect)===null||c===void 0||c.call(t,void 0,i,s,l);return}(f=t.onSelect)===null||f===void 0||f.call(t,i,i,s,l)},a={selected:t.selected,onDayClick:n};return o.jsx(NE.Provider,{value:a,children:r})}function Pz(){var e=v.useContext(NE);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function gwe(e,t){var r=ir(),n=Pz(),a=xE(),i=wE(),s=jE(),l=s.focusDayAfter,d=s.focusDayBefore,c=s.focusWeekAfter,f=s.focusWeekBefore,h=s.blur,p=s.focus,g=s.focusMonthBefore,x=s.focusMonthAfter,b=s.focusYearBefore,w=s.focusYearAfter,j=s.focusStartOfWeek,N=s.focusEndOfWeek,C=function(q){var M,Y,F,D;Lv(r)?(M=n.onDayClick)===null||M===void 0||M.call(n,e,t,q):fh(r)?(Y=a.onDayClick)===null||Y===void 0||Y.call(a,e,t,q):hh(r)?(F=i.onDayClick)===null||F===void 0||F.call(i,e,t,q):(D=r.onDayClick)===null||D===void 0||D.call(r,e,t,q)},O=function(q){var M;p(e),(M=r.onDayFocus)===null||M===void 0||M.call(r,e,t,q)},P=function(q){var M;h(),(M=r.onDayBlur)===null||M===void 0||M.call(r,e,t,q)},E=function(q){var M;(M=r.onDayMouseEnter)===null||M===void 0||M.call(r,e,t,q)},T=function(q){var M;(M=r.onDayMouseLeave)===null||M===void 0||M.call(r,e,t,q)},A=function(q){var M;(M=r.onDayPointerEnter)===null||M===void 0||M.call(r,e,t,q)},I=function(q){var M;(M=r.onDayPointerLeave)===null||M===void 0||M.call(r,e,t,q)},R=function(q){var M;(M=r.onDayTouchCancel)===null||M===void 0||M.call(r,e,t,q)},L=function(q){var M;(M=r.onDayTouchEnd)===null||M===void 0||M.call(r,e,t,q)},V=function(q){var M;(M=r.onDayTouchMove)===null||M===void 0||M.call(r,e,t,q)},z=function(q){var M;(M=r.onDayTouchStart)===null||M===void 0||M.call(r,e,t,q)},G=function(q){var M;(M=r.onDayKeyUp)===null||M===void 0||M.call(r,e,t,q)},H=function(q){var M;switch(q.key){case"ArrowLeft":q.preventDefault(),q.stopPropagation(),r.dir==="rtl"?l():d();break;case"ArrowRight":q.preventDefault(),q.stopPropagation(),r.dir==="rtl"?d():l();break;case"ArrowDown":q.preventDefault(),q.stopPropagation(),c();break;case"ArrowUp":q.preventDefault(),q.stopPropagation(),f();break;case"PageUp":q.preventDefault(),q.stopPropagation(),q.shiftKey?b():g();break;case"PageDown":q.preventDefault(),q.stopPropagation(),q.shiftKey?w():x();break;case"Home":q.preventDefault(),q.stopPropagation(),j();break;case"End":q.preventDefault(),q.stopPropagation(),N();break}(M=r.onDayKeyDown)===null||M===void 0||M.call(r,e,t,q)},W={onClick:C,onFocus:O,onBlur:P,onKeyDown:H,onKeyUp:G,onMouseEnter:E,onMouseLeave:T,onPointerEnter:A,onPointerLeave:I,onTouchCancel:R,onTouchEnd:L,onTouchMove:V,onTouchStart:z};return W}function ywe(){var e=ir(),t=Pz(),r=xE(),n=wE(),a=Lv(e)?t.selected:fh(e)?r.selected:hh(e)?n.selected:void 0;return a}function vwe(e){return Object.values(eo).includes(e)}function xwe(e,t){var r=[e.classNames.day];return Object.keys(t).forEach(function(n){var a=e.modifiersClassNames[n];if(a)r.push(a);else if(vwe(n)){var i=e.classNames["day_".concat(n)];i&&r.push(i)}}),r}function bwe(e,t){var r=ft({},e.styles.day);return Object.keys(t).forEach(function(n){var a;r=ft(ft({},r),(a=e.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function wwe(e,t,r){var n,a,i,s=ir(),l=jE(),d=hwe(e,t),c=gwe(e,d),f=ywe(),h=!!(s.onDayClick||s.mode!=="default");v.useEffect(function(){var E;d.outside||l.focusedDay&&h&&Fn(l.focusedDay,e)&&((E=r.current)===null||E===void 0||E.focus())},[l.focusedDay,e,r,h,d.outside]);var p=xwe(s,d).join(" "),g=bwe(s,d),x=!!(d.outside&&!s.showOutsideDays||d.hidden),b=(i=(a=s.components)===null||a===void 0?void 0:a.DayContent)!==null&&i!==void 0?i:Ube,w=o.jsx(b,{date:e,displayMonth:t,activeModifiers:d}),j={style:g,className:p,children:w,role:"gridcell"},N=l.focusTarget&&Fn(l.focusTarget,e)&&!d.outside,C=l.focusedDay&&Fn(l.focusedDay,e),O=ft(ft(ft({},j),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=C||N?0:-1,n)),c),P={isButton:h,isHidden:x,activeModifiers:d,selectedDays:f,buttonProps:O,divProps:j};return P}function Swe(e){var t=v.useRef(null),r=wwe(e.date,e.displayMonth,t);return r.isHidden?o.jsx("div",{role:"gridcell"}):r.isButton?o.jsx(dy,ft({name:"day",ref:t},r.buttonProps)):o.jsx("div",ft({},r.divProps))}function jwe(e){var t=e.number,r=e.dates,n=ir(),a=n.onWeekNumberClick,i=n.styles,s=n.classNames,l=n.locale,d=n.labels.labelWeekNumber,c=n.formatters.formatWeekNumber,f=c(Number(t),{locale:l});if(!a)return o.jsx("span",{className:s.weeknumber,style:i.weeknumber,children:f});var h=d(Number(t),{locale:l}),p=function(g){a(t,r,g)};return o.jsx(dy,{name:"week-number","aria-label":h,className:s.weeknumber,style:i.weeknumber,onClick:p,children:f})}function Nwe(e){var t,r,n=ir(),a=n.styles,i=n.classNames,s=n.showWeekNumber,l=n.components,d=(t=l?.Day)!==null&&t!==void 0?t:Swe,c=(r=l?.WeekNumber)!==null&&r!==void 0?r:jwe,f;return s&&(f=o.jsx("td",{className:i.cell,style:a.cell,children:o.jsx(c,{number:e.weekNumber,dates:e.dates})})),o.jsxs("tr",{className:i.row,style:a.row,children:[f,e.dates.map(function(h){return o.jsx("td",{className:i.cell,style:a.cell,role:"presentation",children:o.jsx(d,{displayMonth:e.displayMonth,date:h})},ebe(h))})]})}function m$(e,t,r){for(var n=r?.ISOWeek?fz(t):gE(t,r),a=r?.ISOWeek?al(e):_o(e,r),i=yo(n,a),s=[],l=0;l<=i;l++)s.push(bn(a,l));var d=s.reduce(function(c,f){var h=r?.ISOWeek?mz(f):gz(f,r),p=c.find(function(g){return g.weekNumber===h});return p?(p.dates.push(f),c):(c.push({weekNumber:h,dates:[f]}),c)},[]);return d}function Cwe(e,t){var r=m$(zn(e),pE(e),t);if(t?.useFixedWeeks){var n=rbe(e,t);if(n<6){var a=r[r.length-1],i=a.dates[a.dates.length-1],s=eC(i,6-n),l=m$(eC(i,1),s,t);r.push.apply(r,l)}}return r}function _we(e){var t,r,n,a=ir(),i=a.locale,s=a.classNames,l=a.styles,d=a.hideHead,c=a.fixedWeeks,f=a.components,h=a.weekStartsOn,p=a.firstWeekContainsDate,g=a.ISOWeek,x=Cwe(e.displayMonth,{useFixedWeeks:!!c,ISOWeek:g,locale:i,weekStartsOn:h,firstWeekContainsDate:p}),b=(t=f?.Head)!==null&&t!==void 0?t:zbe,w=(r=f?.Row)!==null&&r!==void 0?r:Nwe,j=(n=f?.Footer)!==null&&n!==void 0?n:$be;return o.jsxs("table",{id:e.id,className:s.table,style:l.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!d&&o.jsx(b,{}),o.jsx("tbody",{className:s.tbody,style:l.tbody,children:x.map(function(N){return o.jsx(w,{displayMonth:e.displayMonth,dates:N.dates,weekNumber:N.weekNumber},N.weekNumber)})}),o.jsx(j,{displayMonth:e.displayMonth})]})}function Ewe(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Pwe=Ewe()?v.useLayoutEffect:v.useEffect,oj=!1,Owe=0;function p$(){return"react-day-picker-".concat(++Owe)}function Twe(e){var t,r=e??(oj?p$():null),n=v.useState(r),a=n[0],i=n[1];return Pwe(function(){a===null&&i(p$())},[]),v.useEffect(function(){oj===!1&&(oj=!0)},[]),(t=e??a)!==null&&t!==void 0?t:void 0}function kwe(e){var t,r,n=ir(),a=n.dir,i=n.classNames,s=n.styles,l=n.components,d=mh().displayMonths,c=Twe(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),f=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,h=[i.month],p=s.month,g=e.displayIndex===0,x=e.displayIndex===d.length-1,b=!g&&!x;a==="rtl"&&(t=[g,x],x=t[0],g=t[1]),g&&(h.push(i.caption_start),p=ft(ft({},p),s.caption_start)),x&&(h.push(i.caption_end),p=ft(ft({},p),s.caption_end)),b&&(h.push(i.caption_between),p=ft(ft({},p),s.caption_between));var w=(r=l?.Caption)!==null&&r!==void 0?r:Lbe;return o.jsxs("div",{className:h.join(" "),style:p,children:[o.jsx(w,{id:c,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),o.jsx(_we,{id:f,"aria-labelledby":c,displayMonth:e.displayMonth})]},e.displayIndex)}function Awe(e){var t=ir(),r=t.classNames,n=t.styles;return o.jsx("div",{className:r.months,style:n.months,children:e.children})}function Iwe(e){var t,r,n=e.initialProps,a=ir(),i=jE(),s=mh(),l=v.useState(!1),d=l[0],c=l[1];v.useEffect(function(){a.initialFocus&&i.focusTarget&&(d||(i.focus(i.focusTarget),c(!0)))},[a.initialFocus,d,i.focus,i.focusTarget,i]);var f=[a.classNames.root,a.className];a.numberOfMonths>1&&f.push(a.classNames.multiple_months),a.showWeekNumber&&f.push(a.classNames.with_weeknumber);var h=ft(ft({},a.styles.root),a.style),p=Object.keys(n).filter(function(x){return x.startsWith("data-")}).reduce(function(x,b){var w;return ft(ft({},x),(w={},w[b]=n[b],w))},{}),g=(r=(t=n.components)===null||t===void 0?void 0:t.Months)!==null&&r!==void 0?r:Awe;return o.jsx("div",ft({className:f.join(" "),style:h,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},p,{children:o.jsx(g,{children:s.displayMonths.map(function(x,b){return o.jsx(kwe,{displayIndex:b,displayMonth:x},b)})})}))}function Mwe(e){var t=e.children,r=abe(e,["children"]);return o.jsx(jbe,{initialProps:r,children:o.jsx(Ibe,{children:o.jsx(mwe,{initialProps:r,children:o.jsx(qbe,{initialProps:r,children:o.jsx(Hbe,{initialProps:r,children:o.jsx(ewe,{children:o.jsx(fwe,{children:t})})})})})})})}function Rwe(e){return o.jsx(Mwe,ft({},e,{children:o.jsx(Iwe,{initialProps:e})}))}function Dwe({className:e,classNames:t,showOutsideDays:r=!0,...n}){return o.jsx(Rwe,{showOutsideDays:r,className:ke("p-3",e),classNames:{months:"flex flex-col gap-4 sm:flex-row sm:gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:ke(Kp({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse",head_row:"",head_cell:"text-muted-foreground w-9 text-center text-[0.8rem] font-normal p-0 align-middle",row:"mt-2",cell:ke("relative p-0 text-center text-sm align-middle focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",n.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:ke(Kp({variant:"ghost"}),"h-9 w-9 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:({className:a,...i})=>o.jsx(aC,{className:ke("size-4",a),...i}),IconRight:({className:a,...i})=>o.jsx(Ui,{className:ke("size-4",a),...i})},...n})}const Oz=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}}),CE="/reports";function xr(e,t,r,n=""){if(!e||typeof e!="object")return n;const a=e,i=a[t]??a[r];return i==null?n:String(i)}function rn(e,t,r,n=0){if(!e||typeof e!="object")return n;const a=e,i=a[t]??a[r],s=typeof i=="number"?i:Number(i);return Number.isFinite(s)?s:n}function Lwe(e){if(!e||typeof e!="object")return{taskId:"",labelCode:"",productName:"None",categoryName:"None",templateText:"",printedAt:"",printedByName:"None",locationText:"None",locationId:"",expiryDateText:"None"};const t=e;return{taskId:xr(t,"taskId","TaskId"),labelCode:xr(t,"labelCode","LabelCode")||"None",productName:xr(t,"productName","ProductName","None")||"None",categoryName:xr(t,"categoryName","CategoryName","None")||"None",templateText:xr(t,"templateText","TemplateText",""),printedAt:xr(t,"printedAt","PrintedAt",""),printedByName:xr(t,"printedByName","PrintedByName","None")||"None",locationText:xr(t,"locationText","LocationText","None")||"None",locationId:xr(t,"locationId","LocationId",""),expiryDateText:xr(t,"expiryDateText","ExpiryDateText","None")||"None"}}function $we(e,t={includePaging:!0}){const r={Sorting:e.sorting,PartnerId:e.partnerId,GroupId:e.groupId,LocationId:e.locationId,StartDate:e.startDate,EndDate:e.endDate,Keyword:e.keyword};return t.includePaging&&(r.SkipCount=e.skipCount,r.MaxResultCount=e.maxResultCount),r}async function Fwe(e,t){const r=await Oz.requestJson({path:`${CE}/print-log-list`,method:"GET",query:$we(e,{includePaging:!0}),signal:t}),n=r&&typeof r=="object"?r:{},a=n.items??n.Items,i=Array.isArray(a)?a.map(Lwe):[],s=rn(n,"totalCount","TotalCount",i.length);return{items:i,totalCount:s}}function Bwe(e){if(!e||typeof e!="object")return null;const t=e,r=xr(t,"categoryName","CategoryName",xr(t,"name","Name",xr(t,"labelCategoryName","LabelCategoryName","Category")));if(!r.trim())return null;const n=rn(t,"count","Count",rn(t,"printCount","PrintCount",rn(t,"totalPrinted","TotalPrinted",0)));return{name:r.trim(),count:n}}function zwe(e){if(!e||typeof e!="object")return null;const t=e,r=xr(t,"date","Date",xr(t,"day","Day",xr(t,"printDate","PrintDate","")));if(!r.trim())return null;const n=rn(t,"count","Count",rn(t,"volume","Volume",0));return{date:r.trim(),count:n}}function Uwe(e){if(!e||typeof e!="object")return null;const t=e,r=xr(t,"productName","ProductName","");return r.trim()?{productName:r.trim(),categoryName:xr(t,"categoryName","CategoryName","None")||"None",totalPrinted:rn(t,"totalPrinted","TotalPrinted",rn(t,"printCount","PrintCount",0)),usagePercent:rn(t,"usagePercent","UsagePercent",0)}:null}function qwe(e){if(!e||typeof e!="object")return{summary:{totalLabelsPrinted:0,totalLabelsPrintedPrevPeriod:0,totalLabelsPrintedChangeRate:0,hottestCategoryName:"None",hottestCategoryCount:0,topProductName:"None",topProductCount:0,avgDailyPrints:0,avgDailyPrintsChangeRate:0},labelsByCategory:[],printVolumeTrend:[],mostUsedProducts:[]};const t=e,r=t.summary??t.Summary,n=r&&typeof r=="object"?r:{},a=t.labelsByCategory??t.LabelsByCategory,i=t.printVolumeTrend??t.PrintVolumeTrend,s=t.mostUsedProducts??t.MostUsedProducts,l=[];if(Array.isArray(a))for(const f of a){const h=Bwe(f);h&&l.push(h)}const d=[];if(Array.isArray(i))for(const f of i){const h=zwe(f);h&&d.push(h)}const c=[];if(Array.isArray(s))for(const f of s){const h=Uwe(f);h&&c.push(h)}return{summary:{totalLabelsPrinted:rn(n,"totalLabelsPrinted","TotalLabelsPrinted",0),totalLabelsPrintedPrevPeriod:rn(n,"totalLabelsPrintedPrevPeriod","TotalLabelsPrintedPrevPeriod",0),totalLabelsPrintedChangeRate:rn(n,"totalLabelsPrintedChangeRate","TotalLabelsPrintedChangeRate",0),hottestCategoryName:xr(n,"hottestLabelCategoryName","HottestLabelCategoryName",xr(n,"mostPopularLabelCategoryName","MostPopularLabelCategoryName",xr(n,"hottestCategoryName","HottestCategoryName","None")))||"None",hottestCategoryCount:rn(n,"hottestLabelCategoryCount","HottestLabelCategoryCount",rn(n,"hottestCategoryCount","HottestCategoryCount",0)),topProductName:xr(n,"topProductName","TopProductName",xr(n,"mostUsedProductName","MostUsedProductName","None"))||"None",topProductCount:rn(n,"topProductCount","TopProductCount",0),avgDailyPrints:rn(n,"avgDailyPrints","AvgDailyPrints",0),avgDailyPrintsChangeRate:rn(n,"avgDailyPrintsChangeRate","AvgDailyPrintsChangeRate",0)},labelsByCategory:l,printVolumeTrend:d,mostUsedProducts:c}}function Vwe(e){return{PartnerId:e.partnerId,GroupId:e.groupId,LocationId:e.locationId,StartDate:e.startDate,EndDate:e.endDate,Keyword:e.keyword}}async function Wwe(e,t){const r=await Oz.requestJson({path:`${CE}/label-report`,method:"GET",query:Vwe(e),signal:t});return qwe(r)}async function Hwe(e,t){await ju({path:`${CE}/export-print-log-excel`,query:{Sorting:e.sorting,PartnerId:e.partnerId,GroupId:e.groupId,LocationId:e.locationId,StartDate:e.startDate,EndDate:e.endDate,Keyword:e.keyword},defaultFileName:"print-log-export.xlsx",signal:t})}const xn="all";function Gwe(){const e=new Date,t=new Date(e);return t.setDate(t.getDate()-29),{start:t.toISOString().slice(0,10),end:e.toISOString().slice(0,10)}}function Mp(e){const t=(e??"").trim();if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return;const r=new Date(`${t}T00:00:00`);if(!Number.isNaN(r.getTime()))return r}function g$(e){const t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function Ywe(e){const t=(e??"").trim();if(!t)return"None";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})}function In(e){const t=(e??"").trim();return t||"None"}function y$(e){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(1)}%`:"0%"}function Kwe(e){const t=(e??"").trim();if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t.length>10?t.slice(0,10):t:r.toLocaleDateString("en-US",{month:"numeric",day:"numeric"})}function Xwe({startDate:e,endDate:t,onRangeChange:r}){const[n,a]=v.useState(!1),i=v.useMemo(()=>{const l=Mp(e),d=Mp(t);if(l&&d)return{from:l,to:d};if(l)return{from:l,to:void 0}},[e,t]),s=`${e||"YYYY-MM-DD"} — ${t||"YYYY-MM-DD"}`;return o.jsxs("div",{className:"flex items-center gap-2 shrink-0",lang:"en-US",children:[o.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Period Search:"}),o.jsxs(ka,{open:n,onOpenChange:a,children:[o.jsx(Aa,{asChild:!0,children:o.jsxs(de,{type:"button",variant:"outline",className:"h-10 min-w-[17rem] justify-start gap-2 border border-gray-300 bg-white px-3 text-sm font-mono tabular-nums text-gray-900 hover:bg-gray-50",children:[o.jsx(lq,{className:"h-4 w-4 shrink-0 text-gray-500","aria-hidden":!0}),s]})}),o.jsx(Ia,{className:"w-auto p-0",align:"start",children:o.jsx(Dwe,{mode:"range",numberOfMonths:1,defaultMonth:Mp(e)??Mp(t)??new Date,selected:i,onSelect:l=>{if(!l?.from)return;const d=g$(l.from),c=l.to?g$(l.to):d;r(d,c),l.from&&l.to&&a(!1)},initialFocus:!0})})]})]})}function Jwe(e){const t=e??"";if(!t.trim())return o.jsx("span",{className:"text-gray-500",children:"None"});const r=t.endsWith(" !!!"),n=r?t.slice(0,-4):t,a=n.lastIndexOf(" "),i=a<0?"":n.slice(0,a+1),s=a<0?n:n.slice(a+1);return o.jsxs(o.Fragment,{children:[i,o.jsx("span",{className:"font-bold text-gray-900",children:s}),r&&o.jsx("span",{className:"text-red-600",children:" !!!"})]})}const v$={summary:{totalLabelsPrinted:0,totalLabelsPrintedPrevPeriod:0,totalLabelsPrintedChangeRate:0,hottestCategoryName:"None",hottestCategoryCount:0,topProductName:"None",topProductCount:0,avgDailyPrints:0,avgDailyPrintsChangeRate:0},labelsByCategory:[],printVolumeTrend:[],mostUsedProducts:[]};function Qwe({layoutReportsOpenKey:e=0,layoutReportsTargetTab:t="label-report"}={}){const[r,n]=v.useState("print-log"),a=v.useRef(0),[i,s]=v.useState([]),[l,d]=v.useState([]),[c,f]=v.useState([]),[h,p]=v.useState(xn),[g,x]=v.useState(xn),[b,w]=v.useState(xn),{start:j,end:N}=Gwe(),[C,O]=v.useState(j),[P,E]=v.useState(N),[T,A]=v.useState(""),[I,R]=v.useState(""),L=v.useRef(null),[V,z]=v.useState([]),[G,H]=v.useState(0),[W,q]=v.useState(!1),[M,Y]=v.useState(1),[F]=v.useState(10),[D,$]=v.useState(null),[K,J]=v.useState(!1),[oe,re]=v.useState(!1),[Q,ce]=v.useState(!0),se=v.useRef(null),fe=v.useRef(null);v.useEffect(()=>(L.current&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>R(T.trim()),300),()=>{L.current&&window.clearTimeout(L.current)}),[T]),v.useEffect(()=>{e>0&&e>a.current&&(a.current=e,n(t))},[e,t]);const be=Math.max(1,Math.ceil(G/F)),Z=v.useCallback(()=>h===xn?void 0:i.find(Ae=>Ae.id===h)?.partnerName?.trim()||void 0,[h,i]),Se=v.useCallback(()=>g===xn?void 0:l.find(Ae=>Ae.id===g)?.groupName?.trim()||void 0,[g,l]),Ne=v.useCallback(()=>({partnerId:h===xn?void 0:h,groupId:g===xn?void 0:g,locationId:b===xn?void 0:b,startDate:C.trim()||void 0,endDate:P.trim()||void 0,keyword:I||void 0}),[I,P,g,b,h,C]);v.useEffect(()=>{Y(1)},[I,h,g,b,C,P,r,F]),v.useEffect(()=>{let ye=!1;return(async()=>{ce(!0);try{const[Ge,ut]=await Promise.all([uh({skipCount:1,maxResultCount:500,state:!0}),fE({skipCount:1,maxResultCount:500,state:!0})]);if(ye)return;s(Ge.items??[]),d(ut.items??[])}catch(Ge){ye||(s([]),d([]),ee.error("Failed to load companies / regions.",{description:Ge instanceof Error?Ge.message:"Please try again."}))}finally{ye||ce(!1)}})(),()=>{ye=!0}},[]),v.useEffect(()=>{let ye=!1;return(async()=>{try{const Ge=await Nu({skipCount:1,maxResultCount:2e3,partner:Z(),groupName:Se(),state:!0});if(ye)return;f(Ge.items??[])}catch(Ge){ye||(f([]),ee.error("Failed to load locations.",{description:Ge instanceof Error?Ge.message:"Please try again."}))}})(),()=>{ye=!0}},[Se,Z,h,g]),v.useEffect(()=>r!=="print-log"?void 0:((async()=>{se.current?.abort();const Ae=new AbortController;se.current=Ae,q(!0);const Ge=Ne();try{const ut=await Fwe({skipCount:Qa(M),maxResultCount:F,sorting:"PrintedAt desc",...Ge},Ae.signal);z(ut.items??[]),H(ut.totalCount??0)}catch(ut){if(ut instanceof Error&&ut.name==="AbortError")return;ee.error("Failed to load print log.",{description:ut instanceof Error?ut.message:"Please try again."}),z([]),H(0)}finally{Ae.signal.aborted||q(!1)}})(),()=>se.current?.abort()),[r,Ne,M,F]),v.useEffect(()=>r!=="label-report"?void 0:((async()=>{fe.current?.abort();const Ae=new AbortController;fe.current=Ae,J(!0);const Ge=Ne();try{const ut=await Wwe(Ge,Ae.signal);$(ut)}catch(ut){if(ut instanceof Error&&ut.name==="AbortError")return;ee.error("Failed to load label report.",{description:ut instanceof Error?ut.message:"Please try again."}),$(v$)}finally{Ae.signal.aborted||J(!1)}})(),()=>fe.current?.abort()),[r,Ne]);const qe=ye=>{p(ye),x(xn),w(xn)},De=ye=>{x(ye),w(xn)},He=async()=>{const ye=Ne();re(!0);try{await Hwe({...ye,skipCount:1,maxResultCount:10,sorting:"PrintedAt desc"}),ee.success("Export ready",{description:"The Excel download should start shortly."})}catch(Ae){const Ge=Ae instanceof _r||Ae instanceof Error?Ae.message:"Please try again.";ee.error("Export failed",{description:Ge})}finally{re(!1)}},ne=D??v$,pe=(ne.printVolumeTrend??[]).map(ye=>({date:Kwe(ye.date),count:ye.count})),_e=(ne.labelsByCategory??[]).map(ye=>({name:ye.name,count:ye.count}));return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"pb-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[o.jsxs($e,{value:h,onValueChange:qe,disabled:Q,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Company"})}),o.jsxs(ze,{children:[o.jsx(we,{value:xn,children:"All companies"}),i.map(ye=>o.jsx(we,{value:ye.id,children:In(ye.partnerName)},ye.id))]})]}),o.jsxs($e,{value:g,onValueChange:De,disabled:Q,children:[o.jsx(Be,{className:"w-[140px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Region"})}),o.jsxs(ze,{children:[o.jsx(we,{value:xn,children:"All regions"}),l.filter(ye=>h===xn?!0:ye.partnerId===h).map(ye=>o.jsx(we,{value:ye.id,children:In(ye.groupName)},ye.id))]})]}),o.jsxs($e,{value:b,onValueChange:w,disabled:Q,children:[o.jsx(Be,{className:"w-[160px] h-10 rounded-md border border-gray-300 bg-white font-medium text-gray-900 shrink-0",children:o.jsx(Fe,{placeholder:"Location"})}),o.jsxs(ze,{children:[o.jsx(we,{value:xn,children:"All locations"}),c.map(ye=>o.jsx(we,{value:ye.id??"",children:In(ye.locationName)||In(ye.locationCode)},ye.id))]})]}),o.jsx(Xwe,{startDate:C,endDate:P,onRangeChange:(ye,Ae)=>{O(ye),E(Ae)}}),o.jsxs("div",{className:"flex items-center w-64 rounded-md border border-gray-300 bg-white overflow-hidden shrink-0",style:{height:40},children:[o.jsx(Rf,{className:"h-4 w-4 text-gray-400 shrink-0 ml-3 pointer-events-none"}),o.jsx(me,{value:T,onChange:ye=>A(ye.target.value),placeholder:"Search Product or Category...",className:"flex-1 min-w-0 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 py-2 px-2 h-full placeholder:text-gray-500"})]}),o.jsx("div",{className:"flex-1 min-w-2"}),r==="print-log"&&o.jsxs(de,{type:"button",variant:"outline",className:"h-10 border border-gray-300 rounded-md text-gray-900 bg-white hover:bg-gray-50 gap-2 shrink-0",disabled:oe,onClick:()=>void He(),children:[o.jsx(oC,{className:"w-4 h-4"})," ",oe?"Exporting…":"Export Report"]})]}),o.jsx("div",{className:"w-full border-b border-gray-200 mt-4",children:o.jsxs("div",{className:"flex overflow-x-auto w-fit",children:[o.jsx("button",{type:"button",onClick:()=>n("print-log"),style:r==="print-log"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:ke("px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2",r==="print-log"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"),children:"Print Log"}),o.jsx("button",{type:"button",onClick:()=>n("label-report"),style:r==="label-report"?{borderBottomWidth:2,borderBottomStyle:"solid",borderBottomColor:"#2563eb"}:void 0,className:ke("px-4 py-2.5 text-sm font-medium whitespace-nowrap cursor-pointer transition-colors -mb-px border-b-2",r==="label-report"?"text-blue-600":"border-b-transparent text-gray-600 hover:text-gray-800"),children:"Label Report"})]})})]}),o.jsxs("div",{className:"flex-1 overflow-auto pt-6",children:[r==="print-log"&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"bg-white border border-gray-200 shadow-sm rounded-md overflow-hidden min-h-[200px]",children:[W&&o.jsx("div",{className:"p-6 text-sm text-gray-500",children:"Loading print log…"}),!W&&o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{className:"bg-gray-100 hover:bg-gray-100",children:[o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Label ID"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Product Name"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Category"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Template"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Printed At"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Printed By"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Location"}),o.jsx(Ee,{className:"text-gray-900 font-bold border-r",children:"Expiry Date"}),o.jsx(Ee,{className:"text-gray-900 font-bold text-center",children:"Action"})]})}),o.jsxs(pn,{children:[V.length===0&&o.jsx(nt,{children:o.jsx(xe,{colSpan:9,className:"text-center text-sm text-gray-500 py-10",children:"No print records"})}),V.map(ye=>o.jsxs(nt,{children:[o.jsx(xe,{className:"border-r font-mono text-gray-600",children:In(ye.labelCode)}),o.jsx(xe,{className:"border-r font-medium",children:In(ye.productName)}),o.jsx(xe,{className:"border-r",children:o.jsx(fn,{variant:"secondary",className:"bg-blue-50 text-blue-700 hover:bg-blue-50 border-blue-200",children:In(ye.categoryName)})}),o.jsx(xe,{className:"border-r text-gray-600 text-sm",children:Jwe(ye.templateText)}),o.jsx(xe,{className:"border-r text-gray-600 text-sm font-numeric",children:Ywe(ye.printedAt)}),o.jsx(xe,{className:"border-r text-gray-600 text-sm",children:In(ye.printedByName)}),o.jsx(xe,{className:"border-r text-gray-600 text-sm font-numeric",children:In(ye.locationText)}),o.jsx(xe,{className:"border-r text-sm font-mono text-gray-800",children:In(ye.expiryDateText)}),o.jsx(xe,{className:"text-center",children:o.jsxs("div",{className:"inline-flex h-8 items-center justify-center gap-1 rounded-md border border-gray-300 bg-white px-4 text-sm font-medium text-gray-900 shadow-sm select-none pointer-events-none","aria-label":"Reprint",children:[o.jsx(T$,{className:"w-3 h-3 shrink-0 text-gray-700","aria-hidden":!0}),o.jsx("span",{children:"Reprint"})]})})]},ye.taskId+ye.labelCode))]})]})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-end gap-2 text-sm text-gray-600",children:[o.jsx("span",{children:G===0?"Showing 0 of 0":`Showing ${(M-1)*F+1}–${Math.min(M*F,G)} of ${G}`}),o.jsx(ia,{className:"mx-0 w-auto justify-end",children:o.jsxs(sa,{children:[o.jsx(St,{children:o.jsx(la,{className:M<=1?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>M>1&&Y(ye=>Math.max(1,ye-1)),"aria-disabled":M<=1})}),o.jsx(St,{children:o.jsxs(Cn,{className:"cursor-default",size:"default",isActive:!0,onClick:ye=>ye.preventDefault(),children:["Page ",M," / ",be]})}),o.jsx(St,{children:o.jsx(ca,{className:M>=be?"pointer-events-none opacity-50":"cursor-pointer",onClick:()=>MMath.min(be,ye+1)),"aria-disabled":M>=be})})]})})]})]}),r==="label-report"&&o.jsxs("div",{className:"space-y-6",children:[K&&o.jsx("div",{className:"text-sm text-gray-500",children:"Loading label report…"}),!K&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Total Labels Printed"}),o.jsx(zs,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:ne.summary.totalLabelsPrinted.toLocaleString("en-US")}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[y$(ne.summary.totalLabelsPrintedChangeRate)," vs previous period"]})]})]}),o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Most Printed Category"}),o.jsx(uq,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:In(ne.summary.hottestCategoryName)}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[ne.summary.hottestCategoryCount.toLocaleString("en-US")," label(s) in range"]})]})]}),o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Top Product"}),o.jsx(_$,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:In(ne.summary.topProductName)}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[ne.summary.topProductCount.toLocaleString("en-US")," label(s) in range"]})]})]}),o.jsxs(wn,{children:[o.jsxs(Na,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[o.jsx(Ca,{className:"text-sm font-medium",children:"Avg. Daily Prints"}),o.jsx(Qq,{className:"h-4 w-4 text-muted-foreground"})]}),o.jsxs(Dn,{children:[o.jsx("div",{className:"text-2xl font-bold",children:Number.isFinite(ne.summary.avgDailyPrints)?ne.summary.avgDailyPrints.toLocaleString("en-US",{maximumFractionDigits:1}):"0"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[y$(ne.summary.avgDailyPrintsChangeRate)," vs previous period"]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(wn,{className:"col-span-1",children:[o.jsxs(Na,{children:[o.jsx(Ca,{children:"Labels by Category"}),o.jsx(Hd,{children:"Distribution of printed labels by label category in the selected range."})]}),o.jsx(Dn,{className:"h-[300px]",children:_e.length===0?o.jsx("div",{className:"h-full flex items-center justify-center text-sm text-gray-500",children:"No data"}):o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(Zle,{data:_e,children:[o.jsx(Gg,{strokeDasharray:"3 3",vertical:!1}),o.jsx(Ys,{dataKey:"name",fontSize:12,tickLine:!1,axisLine:!1}),o.jsx(Ks,{fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:ye=>`${ye}`}),o.jsx(ta,{}),o.jsx(ul,{dataKey:"count",fill:"#facc15",radius:[4,4,0,0]})]})})})]}),o.jsxs(wn,{className:"col-span-1",children:[o.jsxs(Na,{children:[o.jsx(Ca,{children:"Print Volume Trends"}),o.jsx(Hd,{children:"Daily print volume in the current filter window (up to 7 days)."})]}),o.jsx(Dn,{className:"h-[300px]",children:pe.length===0?o.jsx("div",{className:"h-full flex items-center justify-center text-sm text-gray-500",children:"No data"}):o.jsx(sg,{width:"100%",height:"100%",children:o.jsxs(kF,{data:pe,children:[o.jsx(Gg,{strokeDasharray:"3 3",vertical:!1}),o.jsx(Ys,{dataKey:"date",fontSize:12,tickLine:!1,axisLine:!1}),o.jsx(Ks,{fontSize:12,tickLine:!1,axisLine:!1}),o.jsx(ta,{}),o.jsx(vu,{type:"monotone",dataKey:"count",stroke:"#dc2626",strokeWidth:2,dot:{r:4},activeDot:{r:6}})]})})})]})]}),o.jsxs(wn,{children:[o.jsx(Na,{children:o.jsx(Ca,{children:"Most Used Products"})}),o.jsx(Dn,{children:o.jsxs(hn,{children:[o.jsx(mn,{children:o.jsxs(nt,{children:[o.jsx(Ee,{children:"Product Name"}),o.jsx(Ee,{children:"Category"}),o.jsx(Ee,{className:"text-right",children:"Total Printed"}),o.jsx(Ee,{className:"text-right",children:"Usage %"})]})}),o.jsxs(pn,{children:[ne.mostUsedProducts.length===0&&o.jsx(nt,{children:o.jsx(xe,{colSpan:4,className:"text-center text-sm text-gray-500",children:"No data"})}),ne.mostUsedProducts.map((ye,Ae)=>o.jsxs(nt,{children:[o.jsx(xe,{className:"font-medium",children:In(ye.productName)}),o.jsx(xe,{children:In(ye.categoryName)}),o.jsx(xe,{className:"text-right font-numeric",children:ye.totalPrinted.toLocaleString("en-US")}),o.jsx(xe,{className:"text-right font-numeric",children:Number.isFinite(ye.usagePercent)?`${ye.usagePercent.toFixed(1)}%`:"—"})]},`${ye.productName}-${Ae}`))]})]})})]})]})]})]})]})}function Zwe({className:e,...t}){return o.jsx("textarea",{"data-slot":"textarea",className:ke("resize-none border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-input-background px-3 py-2 text-base transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}const x$={Settings:jc,LayoutDashboard:Vp,Tag:Nc,MapPin:su,Users:hy,Package:Sc,FileText:zs,HelpCircle:Wd,Layers:lC,Type:Df,FileBox:iC};function ij(e){const t=(e??"").trim();return t||"N/A"}function e1e(e){const t=e.trim();if(!t)return null;const r=Number.parseInt(t,10);return Number.isFinite(r)?r:null}function t1e(){const[e,t]=v.useState([]),[r,n]=v.useState(!1),[a,i]=v.useState(0),[s,l]=v.useState(null),[d,c]=v.useState(""),f=v.useRef(null),[h,p]=v.useState(""),[g,x]=v.useState(!1),[b,w]=v.useState(!1),[j,N]=v.useState(!1),[C,O]=v.useState(null),[P,E]=v.useState(null),T=v.useRef(null);v.useEffect(()=>(f.current&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>p(d.trim()),300),()=>{f.current&&window.clearTimeout(f.current)}),[d]),v.useEffect(()=>((async()=>{T.current?.abort();const V=new AbortController;T.current=V,n(!0);try{const z=await nz({skipCount:1,maxResultCount:5e3,keyword:h||void 0},V.signal);t(z.items??[])}catch(z){if(z?.name==="AbortError")return;ee.error("Failed to load system menus.",{description:z?.message?String(z.message):"Please try again."}),t([])}finally{n(!1)}})(),()=>T.current?.abort()),[h,a]);const A=()=>i(L=>L+1),I=L=>{l(null),O(L),w(!0)},R=L=>{l(null),E(L),N(!0)};return o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"pb-4",children:o.jsxs("div",{className:"flex flex-nowrap items-center gap-3",children:[o.jsx(me,{placeholder:"Search",value:d,onChange:L=>c(L.target.value),style:{height:40,boxSizing:"border-box"},className:"border border-gray-300 rounded-md w-40 shrink-0 bg-white placeholder:text-gray-500"}),o.jsx("div",{className:"flex-1"}),o.jsxs(de,{className:"bg-blue-600 text-white hover:bg-blue-700",onClick:()=>x(!0),children:[o.jsx(Un,{className:"w-4 h-4 mr-2"}),"New Menu"]})]})}),o.jsx("div",{className:"flex-1 flex flex-col min-h-0 bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden",children:o.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:o.jsxs(hn,{children:[o.jsx(mn,{className:"bg-gray-50 sticky top-0 z-10",children:o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Menu Name"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Route URL"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Router Name"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Type"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Order"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Visible"}),o.jsx(Ee,{className:"font-semibold text-gray-900",children:"Enabled"}),o.jsx(Ee,{className:"font-semibold text-gray-900 w-16 text-right",children:"Actions"})]})}),o.jsx(pn,{children:e.length===0?o.jsx(nt,{children:o.jsx(xe,{colSpan:8,className:"text-center py-10 text-gray-500",children:r?"Loading...":"No data"})}):e.map(L=>o.jsxs(nt,{className:"hover:bg-gray-50",children:[o.jsx(xe,{className:"font-medium text-gray-900",children:ij(L.menuName)}),o.jsx(xe,{className:"text-gray-700",children:ij(L.routeUrl)}),o.jsx(xe,{className:"text-gray-700",children:ij(L.routerName)}),o.jsx(xe,{className:"text-gray-700",children:L.menuType??"N/A"}),o.jsx(xe,{className:"text-gray-700",children:L.orderNum??"N/A"}),o.jsx(xe,{className:"text-gray-700",children:L.isShow?"Yes":"No"}),o.jsx(xe,{className:"text-gray-700",children:L.state?"Yes":"No"}),o.jsx(xe,{className:"text-right",children:o.jsxs(ka,{open:s===L.id,onOpenChange:V=>l(V?L.id:null),children:[o.jsx(Aa,{asChild:!0,children:o.jsx(de,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Row actions",children:o.jsx(ni,{className:"h-4 w-4"})})}),o.jsx(Ia,{className:"w-44 p-2",align:"end",children:o.jsxs("div",{className:"flex flex-col",children:[o.jsxs(de,{variant:"ghost",className:"justify-start",onClick:()=>I(L),children:[o.jsx(oa,{className:"w-4 h-4 mr-2"}),"Edit"]}),o.jsxs(de,{variant:"ghost",className:"justify-start text-red-600 hover:text-red-700",onClick:()=>R(L),children:[o.jsx(zt,{className:"w-4 h-4 mr-2"}),"Delete"]})]})})]})})]},L.id))})]})})}),o.jsx(b$,{mode:"create",open:g,menu:null,onOpenChange:x,onSaved:A}),o.jsx(b$,{mode:"edit",open:b,menu:C,onOpenChange:w,onSaved:A}),o.jsx(r1e,{open:j,menu:P,onOpenChange:N,onDeleted:A})]})}function b$({mode:e,open:t,menu:r,onOpenChange:n,onSaved:a}){const i=e==="edit",[s,l]=v.useState(!1),[d,c]=v.useState(""),[f,h]=v.useState(""),[p,g]=v.useState(""),[x,b]=v.useState("menu"),[w,j]=v.useState(""),[N,C]=v.useState(""),[O,P]=v.useState([]),[E,T]=v.useState(!1),[A,I]=v.useState(""),[R,L]=v.useState(""),[V,z]=v.useState(""),[G,H]=v.useState(""),[W,q]=v.useState(""),[M,Y]=v.useState(""),[F,D]=v.useState(!1),[$,K]=v.useState(!0),[J,oe]=v.useState(!0);v.useEffect(()=>{if(!t)return;l(!1),c(r?.menuName??""),h(r?.routerName??""),g(r?.routeUrl??""),b(r?.menuType===0?"directory":"menu"),j(r?.permissionCode??"");const Z=String(r?.parentId??"").trim();C(!Z||Z==="00000000-0000-0000-0000-000000000000"?"":Z),I(r?.menuIcon??""),L(r?.orderNum===null||r?.orderNum===void 0?"":String(r.orderNum)),z(r?.link??""),H(r?.component??""),q(r?.query??""),Y(r?.remark??""),D(!!r?.isCache),K(r?.isShow??!0),oe(r?.state??!0)},[t,r]);const re="__parent_root__";v.useEffect(()=>{if(!t)return;let Z=!1;return T(!0),kve().then(Se=>{Z||P(Se)}).catch(()=>{Z||P([])}).finally(()=>{Z||T(!1)}),()=>{Z=!0}},[t]);const Q=Z=>!Z.trim()||Z==="00000000-0000-0000-0000-000000000000",ce=v.useMemo(()=>{const Z=O.filter(Ne=>Ne.id&&Ne.id!==r?.id),Se=(N||"").trim();return Se&&!Q(Se)&&!Z.some(Ne=>Ne.id===Se)?[...Z,{id:Se,menuName:`(Current parent) ${Se}`}]:Z},[O,N,r?.id]),se=Q(N)?re:N,fe=v.useMemo(()=>!!(d.trim()&&p.trim()&&R.trim()),[d,p,R]),be=async()=>{if(!fe){ee.error("Please fill in required fields.",{description:"Menu Name, Route URL, and Order are required."});return}l(!0);try{const Z={menuName:d.trim(),routerName:f.trim()?f.trim():null,routeUrl:p.trim(),menuType:x==="directory"?0:1,permissionCode:w.trim()?w.trim():null,parentId:Q(N)?null:N.trim(),menuIcon:A||null,orderNum:e1e(R),link:V.trim()?V.trim():null,component:G.trim()?G.trim():null,query:W.trim()?W.trim():null,remark:M.trim()?M.trim():null,isCache:F,isShow:$,state:J};if(i){if(!r?.id)throw new Error("Missing id.");await Ive(r.id,Z),ee.success("Menu updated.",{description:"Changes have been saved successfully."})}else await Ave(Z),ee.success("Menu created.",{description:"A new menu has been created successfully."});n(!1),a()}catch(Z){ee.error(i?"Failed to update menu.":"Failed to create menu.",{description:Z?.message?String(Z.message):"Please try again."})}finally{l(!1)}};return o.jsx(kt,{open:t,onOpenChange:n,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"70%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:i?"Edit System Menu":"New System Menu"}),o.jsx(qt,{children:i?"Update system menu fields and save changes.":"Fill out the form to create a new system menu."})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-6 py-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Menu Name *"}),o.jsx(me,{value:d,onChange:Z=>c(Z.target.value),placeholder:"e.g. Location Manager"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Route URL *"}),o.jsx(me,{value:p,onChange:Z=>g(Z.target.value),placeholder:"e.g. /location"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Router Name"}),o.jsx(me,{value:f,onChange:Z=>h(Z.target.value),placeholder:"e.g. location"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Menu Type"}),o.jsxs($e,{value:x,onValueChange:Z=>b(Z),children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{})}),o.jsxs(ze,{children:[o.jsx(we,{value:"directory",children:"Directory"}),o.jsx(we,{value:"menu",children:"Menu"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Permission Code"}),o.jsx(me,{value:w,onChange:Z=>j(Z.target.value),placeholder:"e.g. sys:menu"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Parent"}),o.jsxs($e,{value:se,disabled:E,onValueChange:Z=>C(Z===re?"":Z),children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:E?"Loading…":"Select parent directory"})}),o.jsxs(ze,{children:[o.jsx(we,{value:re,children:"Root (no parent)"}),ce.map(Z=>o.jsx(we,{value:Z.id,children:Z.menuName?.trim()||Z.id},Z.id))]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Menu Icon"}),o.jsxs($e,{value:A||"none",onValueChange:Z=>I(Z==="none"?"":Z),children:[o.jsx(Be,{className:"h-10 rounded-md border border-gray-200 bg-white",children:o.jsx(Fe,{placeholder:"Select an icon"})}),o.jsxs(ze,{children:[o.jsx(we,{value:"none",children:"None"}),Object.keys(x$).map(Z=>{const Se=x$[Z];return o.jsx(we,{value:Z,children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(Se,{className:"h-4 w-4"}),Z]})},Z)})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Order *"}),o.jsx(me,{value:R,onChange:Z=>L(Z.target.value),placeholder:"e.g. 10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Link"}),o.jsx(me,{value:V,onChange:Z=>z(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Component"}),o.jsx(me,{value:G,onChange:Z=>H(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Query"}),o.jsx(me,{value:W,onChange:Z=>q(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Remark"}),o.jsx(Zwe,{value:M,onChange:Z=>Y(Z.target.value),placeholder:"Optional"})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Cache"}),o.jsx(br,{checked:F,onCheckedChange:D})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Visible"}),o.jsx(br,{checked:$,onCheckedChange:K})]}),o.jsxs("div",{className:"flex items-center justify-between border border-gray-200 rounded-md px-3 bg-white",style:{height:40},children:[o.jsx("div",{className:"text-sm font-medium text-gray-900",children:"Enabled"}),o.jsx(br,{checked:J,onCheckedChange:oe})]})]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>n(!1),children:"Cancel"}),o.jsx(de,{className:"min-w-24 bg-blue-600 text-white hover:bg-blue-700",disabled:s,onClick:be,children:s?"Saving...":i?"Save Changes":"Create"})]})]})})}function r1e({open:e,menu:t,onOpenChange:r,onDeleted:n}){const[a,i]=v.useState(!1),s=v.useMemo(()=>{const d=(t?.menuName??"").trim(),c=(t?.routeUrl??"").trim();return d&&c?`${d} (${c})`:d||c||"this menu"},[t?.menuName,t?.routeUrl]),l=async()=>{if(t?.id){i(!0);try{await Rve(t.id),ee.success("Menu deleted.",{description:"The menu has been removed successfully."}),r(!1),n()}catch(d){ee.error("Failed to delete menu.",{description:d?.message?String(d.message):"Please try again."})}finally{i(!1)}}};return o.jsx(kt,{open:e,onOpenChange:r,children:o.jsxs(Ot,{className:"sm:max-w-none",style:{width:"30%"},children:[o.jsxs(At,{children:[o.jsx(It,{children:"Delete System Menu"}),o.jsx(qt,{children:"This action cannot be undone."})]}),o.jsxs("div",{className:"text-sm text-gray-700",children:["Are you sure you want to delete ",o.jsx("span",{className:"font-medium",children:s}),"?"]}),o.jsxs(Dt,{className:"flex-row flex-wrap justify-end",children:[o.jsx(de,{className:"min-w-24",variant:"outline",onClick:()=>r(!1),children:"Cancel"}),o.jsxs(de,{className:"min-w-24 gap-2",variant:"destructive",disabled:a,onClick:l,children:[o.jsx(zt,{className:"h-4 w-4 shrink-0"}),a?"Deleting...":"Delete"]})]})]})})}const $v=Er({getToken:()=>{try{return localStorage.getItem("access_token")??localStorage.getItem("token")??null}catch{return null}}});function _E(e){if(e==null||typeof e!="object")return null;const t=e,r=t.id!=null?String(t.id).trim():"",n=String(t.supportPhone??"").trim(),a=String(t.supportEmail??"").trim();return!r&&!n&&!a?null:{id:r,locationId:t.locationId!=null?String(t.locationId):null,locationName:t.locationName!=null?String(t.locationName):null,supportPhone:n,supportEmail:a}}function n1e(e){if(!e)return null;if(Array.isArray(e))return e[0]??null;if(typeof e=="object"){const t=e;if(Array.isArray(t.items))return t.items[0]??null;if("supportPhone"in t||"supportEmail"in t)return t}return null}async function a1e(e){const t=await $v.requestJson({path:"/location-support",method:"GET",query:{SkipCount:1,MaxResultCount:1},signal:e});return n1e(t)}async function o1e(e){try{const t=await $v.requestJson({path:"/location-support/support",method:"GET",signal:e});return _E(t)}catch(t){if(t instanceof _r&&t.status===404)try{return await a1e(e)}catch(r){if(r instanceof _r&&r.status===404)return null;throw r}throw t}}async function i1e(e){const t=await $v.requestJson({path:"/location-support",method:"POST",body:{supportPhone:e.supportPhone,supportEmail:e.supportEmail}}),r=_E(t);return r||t}async function s1e(e,t){const r=await $v.requestJson({path:`/location-support/${encodeURIComponent(e)}`,method:"PUT",body:{supportPhone:t.supportPhone,supportEmail:t.supportEmail}}),n=_E(r);return n||r}function l1e(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function c1e(){const[e,t]=v.useState(null),[r,n]=v.useState(""),[a,i]=v.useState(""),[s,l]=v.useState(!0),[d,c]=v.useState(!1);v.useEffect(()=>{let h=!1;return(async()=>{l(!0);try{const g=await o1e();if(h)return;if(!g){t(null),n(""),i("");return}const x=(g.id??"").trim();t(x||null),n((g.supportPhone??"").trim()),i((g.supportEmail??"").trim())}catch(g){if(h)return;t(null),n(""),i(""),ee.error("Failed to load support settings.",{description:g instanceof Error?g.message:"Please try again."})}finally{h||l(!1)}})(),()=>{h=!0}},[]);const f=async()=>{const h=r.trim(),p=a.trim();if(!h){ee.error("Support phone is required.");return}if(!p){ee.error("Support email is required.");return}if(!l1e(p)){ee.error("Support email format is invalid.");return}c(!0);try{const g={supportPhone:h,supportEmail:p},x=e?await s1e(e,g):await i1e(g),b=(x.id??"").trim();t(b||null),n((x.supportPhone??"").trim()),i((x.supportEmail??"").trim()),ee.success("Support settings saved.")}catch(g){ee.error("Failed to save support settings.",{description:g instanceof Error?g.message:"Please try again."})}finally{c(!1)}};return o.jsx("div",{className:"max-w-4xl space-y-6",children:o.jsxs(wn,{children:[o.jsxs(Na,{children:[o.jsx(Ca,{children:"Support Contact Settings"}),o.jsx(Hd,{children:"Configure the global support phone and email used by the app support page."})]}),o.jsxs(Dn,{className:"space-y-4",children:[o.jsx("div",{className:"text-xs text-gray-500",children:e?"Existing global support record found. You can update phone and email.":"No global support record found. Saving will create a new record."}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Support Phone *"}),o.jsxs("div",{className:"flex h-10 rounded-md border border-input bg-transparent overflow-hidden",children:[o.jsx("div",{className:"w-10 shrink-0 flex items-center justify-center border-r border-input bg-gray-50",children:o.jsx(Hq,{className:"w-4 h-4 text-gray-400"})}),o.jsx(me,{className:"h-10 border-0 rounded-none shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",value:r,onChange:h=>n(h.target.value),placeholder:"e.g. 1-800-SUPPORT",disabled:s||d})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Support Email *"}),o.jsxs("div",{className:"flex h-10 rounded-md border border-input bg-transparent overflow-hidden",children:[o.jsx("div",{className:"w-10 shrink-0 flex items-center justify-center border-r border-input bg-gray-50",children:o.jsx($q,{className:"w-4 h-4 text-gray-400"})}),o.jsx(me,{className:"h-10 border-0 rounded-none shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",value:a,onChange:h=>i(h.target.value),placeholder:"support@medvantage.com",disabled:s||d})]})]})]}),o.jsx("div",{className:"flex justify-end pt-2",children:o.jsx(de,{onClick:()=>void f(),className:"bg-blue-600 text-white hover:bg-blue-700",disabled:s||d,children:d?"Saving...":e?"Update":"Create"})})]})]})})}const EE="access_token",Tz="refresh_token";function rC(){try{return localStorage.getItem(EE)??localStorage.getItem("token")??null}catch{return null}}function u1e(e){try{localStorage.setItem(EE,e.token),e.refreshToken&&localStorage.setItem(Tz,e.refreshToken)}catch{}}function w$(){try{localStorage.removeItem(EE),localStorage.removeItem("token"),localStorage.removeItem(Tz)}catch{}}const kz=Er({getToken:()=>rC()});async function d1e(e){return await kz.requestJson({path:"/auth-session/my-menus",method:"GET",signal:e})}async function f1e(e){return await kz.requestJson({path:"/auth-session/logout",method:"POST",signal:e})}const Az=U.createContext(null);function Iz(){const e=U.useContext(Az);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}function h1e(e){return String(e?.id??e?.Id??"")}function Mz(e){const t=e?.children??e?.Children,r=Array.isArray(t)?t.map(Mz):void 0;return{id:h1e(e),parentId:e?.parentId??e?.ParentId??null,menuName:e?.menuName??e?.MenuName??null,routerName:e?.routerName??e?.RouterName??null,routeUrl:e?.routeUrl??e?.RouteUrl??e?.router??e?.Router??null,menuIcon:e?.menuIcon??e?.MenuIcon??null,menuType:e?.menuType??e?.MenuType??null,permissionCode:e?.permissionCode??e?.PermissionCode??null,orderNum:e?.orderNum??e?.OrderNum??null,state:e?.state??e?.State??null,component:e?.component??e?.Component??null,isCache:e?.isCache??e?.IsCache??null,isShow:e?.isShow??e?.IsShow??null,query:e?.query??e?.Query??null,remark:e?.remark??e?.Remark??null,link:e?.link??e?.Link??null,menuSource:e?.menuSource??e?.MenuSource??null,concurrencyStamp:e?.concurrencyStamp??e?.ConcurrencyStamp??null,children:r}}function m1e({children:e}){const[t,r]=U.useState(()=>({token:rC(),user:null,menus:[],permissionCodes:[],roleCodes:[],loading:!1})),n=U.useCallback(async()=>{const l=rC();if(!l){r(d=>({...d,token:null,user:null,menus:[],permissionCodes:[],roleCodes:[],loading:!1}));return}r(d=>({...d,token:l,loading:!0}));try{const d=await d1e(),c=Array.isArray(d?.menus)?d.menus.map(Mz):[],f=Array.isArray(d?.permissionCodes)?d.permissionCodes:[],h=Array.isArray(d?.roleCodes)?d.roleCodes:[],p=d?.user??null,g=p?{id:String(p.id??p.Id??""),userName:String(p.userName??p.UserName??""),nick:p.nick??p.Nick??null,email:p.email??p.Email??null,icon:p.icon??p.Icon??null}:null;r(x=>({...x,token:l,user:g,menus:c,permissionCodes:f,roleCodes:h,loading:!1}))}catch(d){const c=d instanceof _r,f=c?d.status:0,h=c&&(f===401||f===403),p=d instanceof Error?d.message:typeof d=="string"?d:"请稍后重试。";ee.error("加载菜单权限失败",{description:p}),h?(w$(),r(g=>({...g,loading:!1,token:null,user:null,menus:[],permissionCodes:[],roleCodes:[]}))):r(g=>({...g,loading:!1}))}},[]);U.useEffect(()=>{n()},[n]);const a=U.useCallback(()=>{w$(),r(l=>({...l,token:null,user:null,menus:[],permissionCodes:[],roleCodes:[]}))},[]),i=U.useCallback(async()=>{try{await f1e()}catch{}finally{a(),ee.success("已退出登录")}},[a]),s=U.useMemo(()=>({...t,refresh:n,clearLocalAuth:a,logout:i}),[t,n,a,i]);return o.jsx(Az.Provider,{value:s,children:e})}const p1e=Er();async function g1e(e){const t=await p1e.requestJson({path:"/account/login",method:"POST",body:{userName:e.userName,password:e.password,uuid:e.uuid??null,code:e.code??null}}),r=String(t?.token??t?.Token??"");if(!r)throw new Error("登录失败:未返回 token。");const n=t?.refreshToken??t?.RefreshToken??null;return u1e({token:r,refreshToken:n}),{token:r,refreshToken:n}}function y1e(){const e=Iz(),[t,r]=U.useState(""),[n,a]=U.useState(""),[i,s]=U.useState(!1),l=!!(t.trim()&&n.trim()&&!i),d=async()=>{if(!l)return;const c=t.trim();s(!0);try{await g1e({userName:c,password:n.trim()}),await e.refresh(),ee.success("Signed in")}catch(f){ee.error("Sign-in failed",{description:f?.message?String(f.message):"Please check your email/password and try again."})}finally{s(!1)}};return o.jsx("div",{className:"w-screen h-screen grid items-center justify-center bg-[#f6f7fb] p-4",children:o.jsxs("div",{className:"w-full max-w-md bg-white border border-gray-200 rounded-2xl shadow-sm p-8",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-xl font-semibold text-gray-900",children:"Platform Sign In"}),o.jsx("div",{className:"text-sm text-gray-500 mt-1",children:"Your sidebar menu and permissions will load after sign-in."})]}),o.jsxs("div",{className:"mt-6 space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Email"}),o.jsx(me,{type:"email",value:t,onChange:c=>r(c.target.value),placeholder:"Enter your email",autoComplete:"username",onKeyDown:c=>{c.key==="Enter"&&d()}})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(ue,{children:"Password"}),o.jsx(me,{type:"password",value:n,onChange:c=>a(c.target.value),placeholder:"Enter your password",autoComplete:"current-password",onKeyDown:c=>{c.key==="Enter"&&d()}})]}),o.jsx(de,{className:"w-full bg-blue-600 text-white hover:bg-blue-700",disabled:!l,onClick:d,children:i?"Signing in...":"Sign In"})]})]})})}const v1e=new Set(["Labels","Label Categories","Label Types","Label Templates","Multiple Options"]);function x1e(){const e=Iz(),[t,r]=v.useState("Dashboard"),[n,a]=v.useState(null),[i,s]=v.useState(0),[l,d]=v.useState(0),[c,f]=v.useState("print-log"),[h,p]=v.useState(!1),g=N=>{const C=(N??"").trim();return C?C==="System Management"?"System Menu":C==="Location Management"?"Location Manager":C==="Account Manager"?"Account Management":C:"Dashboard"},x=g(t),b=v.useCallback(N=>{const C=g(N);if(C==="Location Manager"){a("Location Manager"),r("Account Management");return}r(C)},[]),w=v.useCallback(()=>{s(0)},[]);if(v.useEffect(()=>{v1e.has(x)||s(0),x!=="Reports"&&d(0),x!=="Label Templates"&&p(!1)},[x]),!e.token)return o.jsx(y1e,{});const j=()=>{const N=x;switch(N){case"Dashboard":return o.jsx(yce,{onNewLabel:()=>{s(C=>C+1),r("Labels")},onViewReports:()=>{f("label-report"),d(C=>C+1),r("Reports")},onViewAllRecentLabels:()=>{f("print-log"),d(C=>C+1),r("Reports")}});case"Training":return o.jsx(lve,{});case"Alerts":return o.jsx(dve,{});case"Menu Management":return o.jsx(jve,{});case"System Menu":return o.jsx(t1e,{});case"Account Management":return o.jsx(B0e,{initialSubTab:n,onInitialSubTabConsumed:()=>a(null)});case"Reports":return o.jsx(Qwe,{layoutReportsOpenKey:l,layoutReportsTargetTab:c});case"Support":return o.jsx(c1e,{});case"Labels":case"Label Categories":case"Label Types":case"Label Templates":case"Multiple Options":return o.jsx(sve,{currentView:N,onViewChange:r,labelCreateOpenSeq:i,onLabelCreateIntentConsumed:w,onLabelTemplateEditorLayoutOverlay:p});default:return o.jsx(vce,{title:N})}};return o.jsx(o.Fragment,{children:o.jsx(gW,{currentView:x,setCurrentView:b,menus:e.menus,onLogout:e.logout,hideAppChrome:h,children:j()})})}function b1e(){return o.jsxs(o.Fragment,{children:[o.jsx(m1e,{children:o.jsx(x1e,{})}),o.jsx(Y9,{position:"top-center",richColors:!0,closeButton:!0,expand:!1})]})}w9.createRoot(document.getElementById("root")).render(o.jsx(b1e,{})); diff --git a/美国版/Food Labeling Management Platform/build/index.html b/美国版/Food Labeling Management Platform/build/index.html index 50b13dc..c1979a4 100644 --- a/美国版/Food Labeling Management Platform/build/index.html +++ b/美国版/Food Labeling Management Platform/build/index.html @@ -5,7 +5,7 @@ Food Labeling Management Platform - + diff --git a/美国版/Food Labeling Management Platform/src/components/bulk/batch-import-dialog.tsx b/美国版/Food Labeling Management Platform/src/components/bulk/batch-import-dialog.tsx index ab804c7..78abdfe 100644 --- a/美国版/Food Labeling Management Platform/src/components/bulk/batch-import-dialog.tsx +++ b/美国版/Food Labeling Management Platform/src/components/bulk/batch-import-dialog.tsx @@ -1,4 +1,5 @@ -import React, { useRef, useState } from "react"; +import React, { useCallback, useId, useRef, useState } from "react"; +import { FileSpreadsheet, Upload, X } from "lucide-react"; import { Button } from "../ui/button"; import { Dialog, @@ -9,6 +10,7 @@ import { DialogTitle, } from "../ui/dialog"; import { Label } from "../ui/label"; +import { cn } from "../ui/utils"; import { toast } from "sonner"; import { ApiError } from "../../lib/apiClient"; @@ -24,6 +26,25 @@ export type BatchImportDialogProps = { downloadingTemplate?: boolean; }; +const ACCEPT = ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + +function formatFileSize(bytes: number): string { + if (!Number.isFinite(bytes) || bytes < 0) return ""; + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; +} + +function pickFile(list: FileList | null): File | null { + const f = list?.[0]; + if (!f) return null; + const name = f.name.toLowerCase(); + if (!name.endsWith(".xlsx")) { + return null; + } + return f; +} + export function BatchImportDialog({ open, onOpenChange, @@ -33,15 +54,42 @@ export function BatchImportDialog({ onImportFile, downloadingTemplate = false, }: BatchImportDialogProps) { + const fileInputId = useId(); const inputRef = useRef(null); const [file, setFile] = useState(null); const [busy, setBusy] = useState(false); + const [dragActive, setDragActive] = useState(false); const reset = () => { setFile(null); + setDragActive(false); if (inputRef.current) inputRef.current.value = ""; }; + const clearSelectedFile = () => { + setFile(null); + if (inputRef.current) inputRef.current.value = ""; + }; + + const applyFiles = useCallback((list: FileList | null) => { + const f = pickFile(list); + if (list?.length && !f) { + toast.error("Invalid file", { description: "Please choose an .xlsx file." }); + return; + } + setFile(f); + }, []); + + /** 延迟触发:避免嵌在 Radix Dialog 内时,同步 click() 导致部分浏览器不触发 change */ + const openPicker = () => { + window.setTimeout(() => { + const el = inputRef.current; + if (!el) return; + el.value = ""; + el.click(); + }, 0); + }; + return ( - - - {title} - {description ? {description} : null} + + + {title} + {description ? ( + {description} + ) : null} -
+ +
- + { - const f = e.target.files?.[0] ?? null; - setFile(f); - }} + accept={ACCEPT} + className="sr-only" + tabIndex={-1} + aria-label="Choose Excel spreadsheet" + onChange={(e) => applyFiles(e.target.files)} /> + + + {file ? ( +
+ +
+
Selected file
+
+ {file.name} +
+ {formatFileSize(file.size) ? ( +
{formatFileSize(file.size)}
+ ) : null} +
+ +
+ ) : ( +
+ No file selected yet — use Browse or drag an .xlsx above +
+ )} + +

+ After a file is selected, click Import to upload + it to the server. +

+
+ +
+
-
- -
+ - ))} -
+
+ {ELEMENT_CATEGORIES.map((cat) => ( +
+
{cat.title}
+ {cat.subtitle ? ( +
{cat.subtitle}
+ ) : null} +
+ {cat.items.map((item, i) => ( + + ))}
- ))} -
- +
+ ))} + ); } diff --git a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx index 49b9a1e..b07cb43 100644 --- a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx +++ b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/LabelCanvas.tsx @@ -1450,7 +1450,16 @@ export function LabelCanvas({ }; return ( -
+
{/* Label Preview 标题 + 网格/预览/缩放 */}
Label Preview @@ -1571,9 +1580,10 @@ export function LabelCanvas({
-
+
+
Properties (Element)
- -
+
+
@@ -218,23 +217,23 @@ export function PropertiesPanel({
)}
- +
); } return ( -
-
+
+
Properties (Element)
- +
Select an element on the canvas to edit its properties.
- +
); } diff --git a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/index.tsx b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/index.tsx index 17efae8..3f5a77d 100644 --- a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/index.tsx +++ b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplateEditor/index.tsx @@ -407,7 +407,16 @@ export function LabelTemplateEditor({ }, [template]); return ( -
+
{/* Toolbar */}
- {/* Three columns */} -
-
+ {/* 三列:行布局内联;左侧整列 overflow-y:auto,保证橙色 Print input 可滚到 */} +
+
-
+
- - - - Label preview - -
-
- -
-
-
-
-
+
+ + + + Label preview + +
+
+ +
+
+
+
); } diff --git a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplatesView.tsx b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplatesView.tsx index f8fc276..6c034d9 100755 --- a/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplatesView.tsx +++ b/美国版/Food Labeling Management Platform/src/components/labels/LabelTemplatesView.tsx @@ -479,9 +479,21 @@ export function LabelTemplatesView({ onTemplateEditorOverlayChange }: LabelTempl ); return ( -
- {viewMode === 'editor' ? ( -
+
+ {viewMode === "editor" ? ( +
) : ( -
{listPanel}
+
+ {listPanel} +
)} +
@@ -186,20 +186,19 @@ export function LabelTypesView() { Type Code State Order - Last Edited Actions {loading ? ( - + Loading... ) : types.length === 0 ? ( - + No results. @@ -214,9 +213,6 @@ export function LabelTypesView() { {item.orderNum ?? "None"} - - {item.creationTime ? new Date(item.creationTime).toLocaleString() : "None"} - Template Products State - Last Edited Actions {loading ? ( - + Loading... ) : labels.length === 0 ? ( - + No results. @@ -773,9 +757,6 @@ export function LabelsList({ openCreateSeq = 0, onOpenCreateIntentConsumed }: La {item.state === true ? "Active" : "Inactive"} - - {labelRowLastEdited(item)} - {/* Tabs:模板编辑器全屏编辑时隐藏 */} {!templateEditorHidesTabs && ( @@ -78,8 +79,11 @@ export function LabelsView({
)} - {/* Content:Label Templates 编辑态需占满主区域高度,故用 flex-1 + min-h-0 传递 */} -
+ {/* min-h-0 未进预编译 CSS,用内联保证模板编辑区能拿到剩余高度 */} +
{currentView === 'Labels' && (
)} - {currentView === 'Label Templates' && ( -
+ {currentView === "Label Templates" && ( +
)} diff --git a/美国版/Food Labeling Management Platform/src/components/layout/Layout.tsx b/美国版/Food Labeling Management Platform/src/components/layout/Layout.tsx index 7de2e9f..b001c63 100755 --- a/美国版/Food Labeling Management Platform/src/components/layout/Layout.tsx +++ b/美国版/Food Labeling Management Platform/src/components/layout/Layout.tsx @@ -27,7 +27,17 @@ export function Layout({ {!hideAppChrome && ( )} -
+
{!hideAppChrome && ( <>
setCurrentView('Support')} /> @@ -49,11 +59,35 @@ export function Layout({
-
{children}
+
+ {children} +
diff --git a/美国版/Food Labeling Management Platform/src/components/locations/LocationsView.tsx b/美国版/Food Labeling Management Platform/src/components/locations/LocationsView.tsx index 9bb78d6..3349878 100755 --- a/美国版/Food Labeling Management Platform/src/components/locations/LocationsView.tsx +++ b/美国版/Food Labeling Management Platform/src/components/locations/LocationsView.tsx @@ -55,7 +55,8 @@ import type { LocationCreateInput, LocationDto } from "../../types/location"; import type { GroupListItem } from "../../types/group"; import type { PartnerListItem } from "../../types/partner"; import { BatchImportDialog } from "../bulk/batch-import-dialog"; -import { LocationBulkEditDialog } from "./location-bulk-edit-dialog"; +import { LocationBulkEditPage } from "./location-bulk-edit-page"; +import { cn } from "../ui/utils"; const LOCATION_PG_NONE = "__none__"; @@ -149,7 +150,7 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { const [actionsOpenForId, setActionsOpenForId] = useState(null); const [selectedIds, setSelectedIds] = useState>(() => new Set()); const [bulkImportOpen, setBulkImportOpen] = useState(false); - const [bulkEditOpen, setBulkEditOpen] = useState(false); + const [locationBulkEditPage, setLocationBulkEditPage] = useState(false); const [bulkEditSeed, setBulkEditSeed] = useState([]); const [tmplDownloading, setTmplDownloading] = useState(false); const [excelExporting, setExcelExporting] = useState(false); @@ -272,7 +273,7 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { }; const toolbarSection = ( -
+
Bulk Edit @@ -385,7 +386,7 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { - + 0 && locations.every((l) => selectedIds.has(l.id))} onCheckedChange={(c) => { @@ -427,7 +428,7 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { ) : ( locations.map((loc) => ( - + { @@ -567,6 +568,26 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { ); + const listOrBulkMain = locationBulkEditPage ? ( +
+
+ { + setLocationBulkEditPage(false); + setBulkEditSeed([]); + }} + onSaved={() => { + setSelectedIds(new Set()); + refreshList(); + }} + /> +
+
+ ) : ( + tableAndPagination + ); + const dialogs = ( <> - { - setSelectedIds(new Set()); - refreshList(); - }} - /> ); @@ -645,7 +657,7 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { return (
{renderBeforeTabs(toolbarSection)} -
{tableAndPagination}
+
{listOrBulkMain}
{dialogs}
); @@ -654,7 +666,7 @@ export function LocationsView({ renderBeforeTabs }: LocationsViewProps = {}) { return (
{toolbarSection} -
{tableAndPagination}
+
{listOrBulkMain}
{dialogs}
); diff --git a/美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-dialog.tsx b/美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-dialog.tsx deleted file mode 100644 index 8c607a0..0000000 --- a/美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-dialog.tsx +++ /dev/null @@ -1,279 +0,0 @@ -import React, { useEffect, useMemo, useState } from "react"; -import { Button } from "../ui/button"; -import { Input } from "../ui/input"; -import { Switch } from "../ui/switch"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, -} from "../ui/dialog"; -import { toast } from "sonner"; -import { ApiError } from "../../lib/apiClient"; -import { updateLocationsBulk, type LocationBulkUpdateItemVo } from "../../services/locationService"; -import type { LocationDto } from "../../types/location"; - -const ZERO = "00000000-0000-0000-0000-000000000000"; - -function isValidBulkId(id: string): boolean { - const s = (id ?? "").trim(); - if (!s) return false; - return s.toLowerCase() !== ZERO; -} - -export type LocationBulkEditDialogProps = { - open: boolean; - onOpenChange: (open: boolean) => void; - /** 从列表勾选带入的行 */ - seed: LocationDto[]; - onSaved: () => void; -}; - -type RowState = LocationBulkUpdateItemVo & { locationCodeReadonly: string }; - -function locToRow(loc: LocationDto): RowState { - return { - id: loc.id, - locationCodeReadonly: (loc.locationCode ?? loc.id ?? "").trim(), - partner: loc.partner ?? "", - groupName: loc.groupName ?? "", - locationName: (loc.locationName ?? "").trim() || "", - street: loc.street ?? "", - city: loc.city ?? "", - stateCode: loc.stateCode ?? "", - country: loc.country ?? "", - zipCode: loc.zipCode ?? "", - phone: loc.phone ?? "", - email: loc.email ?? "", - latitude: loc.latitude ?? null, - longitude: loc.longitude ?? null, - state: loc.state !== false, - }; -} - -function emptyPadRow(): RowState { - return { - id: "", - locationCodeReadonly: "", - partner: "", - groupName: "", - locationName: "", - street: "", - city: "", - stateCode: "", - country: "", - zipCode: "", - phone: "", - email: "", - latitude: null, - longitude: null, - state: true, - }; -} - -export function LocationBulkEditDialog({ open, onOpenChange, seed, onSaved }: LocationBulkEditDialogProps) { - const [rows, setRows] = useState([]); - const [saving, setSaving] = useState(false); - - const minRows = useMemo(() => Math.max(seed.length + 10, 10), [seed.length]); - - useEffect(() => { - if (!open) return; - const data = seed.map(locToRow); - const pad = Math.max(0, minRows - data.length); - setRows([...data, ...Array.from({ length: pad }, () => emptyPadRow())]); - }, [open, seed, minRows]); - - const updateRow = (idx: number, patch: Partial) => { - setRows((prev) => { - const next = [...prev]; - next[idx] = { ...next[idx], ...patch }; - return next; - }); - }; - - const removeRow = (idx: number) => { - setRows((prev) => { - if (prev.length <= 1) return prev; - return prev.filter((_, i) => i !== idx); - }); - }; - - const handleSave = async () => { - const items: LocationBulkUpdateItemVo[] = rows - .filter((r) => isValidBulkId(r.id)) - .map((r) => ({ - id: r.id.trim(), - partner: r.partner?.trim() || null, - groupName: r.groupName?.trim() || null, - locationName: r.locationName.trim(), - street: r.street?.trim() || null, - city: r.city?.trim() || null, - stateCode: r.stateCode?.trim() || null, - country: r.country?.trim() || null, - zipCode: r.zipCode?.trim() || null, - phone: r.phone?.trim() || null, - email: r.email?.trim() || null, - latitude: r.latitude, - longitude: r.longitude, - state: r.state !== false, - })); - - if (items.length === 0) { - toast.error("No valid rows", { description: "Select locations in the list or keep rows with valid IDs." }); - return; - } - - setSaving(true); - try { - const res = await updateLocationsBulk({ items }); - toast.success("Bulk update finished", { - description: `Success: ${res.successCount}, failed: ${res.failCount}`, - }); - if (res.errors?.length) { - const preview = res.errors - .slice(0, 5) - .map((e) => `Row ${e.rowNumber ?? "?"}: ${e.message ?? ""}`) - .join("\n"); - toast.message("Errors (first 5)", { description: preview }); - } - onSaved(); - onOpenChange(false); - } catch (e) { - const msg = e instanceof ApiError ? e.message : e instanceof Error ? e.message : "Save failed."; - toast.error("Bulk save failed", { description: msg }); - } finally { - setSaving(false); - } - }; - - return ( - - -
- - - Location bulk edit - Edit multiple locations and save all. - - -
-
-
- - - - - - - - - - - - - - - - - - - - {rows.map((r, idx) => ( - - - - - - - - - - - - - - - - - - ))} - -
- Location IDCompanyRegionLocation Name *StreetCityStateCountryZipPhoneEmailLatLngActive
-
- {idx + 1} - -
-
- - - updateRow(idx, { partner: e.target.value })} /> - - updateRow(idx, { groupName: e.target.value })} /> - - updateRow(idx, { locationName: e.target.value })} /> - - updateRow(idx, { street: e.target.value })} /> - - updateRow(idx, { city: e.target.value })} /> - - updateRow(idx, { stateCode: e.target.value })} /> - - updateRow(idx, { country: e.target.value })} /> - - updateRow(idx, { zipCode: e.target.value })} /> - - updateRow(idx, { phone: e.target.value })} /> - - updateRow(idx, { email: e.target.value })} /> - - { - const v = e.target.value.trim(); - updateRow(idx, { latitude: v === "" ? null : Number(v) }); - }} - /> - - { - const v = e.target.value.trim(); - updateRow(idx, { longitude: v === "" ? null : Number(v) }); - }} - /> - -
- updateRow(idx, { state: !!c })} /> -
-
-
-
-

You can copy and paste from Excel or Google Sheets.

-

Columns marked * are required for rows that have a valid Location row id.

-

Use the × on each row to remove a row (keep at least one row).

-
- -
- ); -} diff --git a/美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-page.tsx b/美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-page.tsx new file mode 100644 index 0000000..166809a --- /dev/null +++ b/美国版/Food Labeling Management Platform/src/components/locations/location-bulk-edit-page.tsx @@ -0,0 +1,240 @@ +import React, { useEffect, useState } from "react"; +import { Button } from "../ui/button"; +import { Input } from "../ui/input"; +import { Switch } from "../ui/switch"; +import { toast } from "sonner"; +import { ApiError } from "../../lib/apiClient"; +import { updateLocationsBulk, type LocationBulkUpdateItemVo } from "../../services/locationService"; +import type { LocationDto } from "../../types/location"; + +const ZERO = "00000000-0000-0000-0000-000000000000"; + +function isValidBulkId(id: string): boolean { + const s = (id ?? "").trim(); + if (!s) return false; + return s.toLowerCase() !== ZERO; +} + +export type LocationBulkEditPageProps = { + seed: LocationDto[]; + onBack: () => void; + onSaved: () => void; +}; + +type RowState = LocationBulkUpdateItemVo & { locationCodeReadonly: string }; + +function locToRow(loc: LocationDto): RowState { + return { + id: loc.id, + locationCodeReadonly: (loc.locationCode ?? loc.id ?? "").trim(), + partner: loc.partner ?? "", + groupName: loc.groupName ?? "", + locationName: (loc.locationName ?? "").trim() || "", + street: loc.street ?? "", + city: loc.city ?? "", + stateCode: loc.stateCode ?? "", + country: loc.country ?? "", + zipCode: loc.zipCode ?? "", + phone: loc.phone ?? "", + email: loc.email ?? "", + latitude: loc.latitude ?? null, + longitude: loc.longitude ?? null, + state: loc.state !== false, + }; +} + +export function LocationBulkEditPage({ seed, onBack, onSaved }: LocationBulkEditPageProps) { + const [rows, setRows] = useState([]); + const [saving, setSaving] = useState(false); + + useEffect(() => { + setRows(seed.map(locToRow)); + }, [seed]); + + const updateRow = (idx: number, patch: Partial) => { + setRows((prev) => { + const next = [...prev]; + next[idx] = { ...next[idx], ...patch }; + return next; + }); + }; + + const handleSave = async () => { + const items: LocationBulkUpdateItemVo[] = rows + .filter((r) => isValidBulkId(r.id)) + .map((r) => ({ + id: r.id.trim(), + partner: r.partner?.trim() || null, + groupName: r.groupName?.trim() || null, + locationName: r.locationName.trim(), + street: r.street?.trim() || null, + city: r.city?.trim() || null, + stateCode: r.stateCode?.trim() || null, + country: r.country?.trim() || null, + zipCode: r.zipCode?.trim() || null, + phone: r.phone?.trim() || null, + email: r.email?.trim() || null, + latitude: r.latitude, + longitude: r.longitude, + state: r.state !== false, + })); + + if (items.length === 0) { + toast.error("No valid rows", { description: "Select locations in the list first, then open Bulk Edit." }); + return; + } + + setSaving(true); + try { + const res = await updateLocationsBulk({ items }); + toast.success("Bulk update finished", { + description: `Success: ${res.successCount}, failed: ${res.failCount}`, + }); + if (res.errors?.length) { + const preview = res.errors + .slice(0, 5) + .map((e) => `Row ${e.rowNumber ?? "?"}: ${e.message ?? ""}`) + .join("\n"); + toast.message("Errors (first 5)", { description: preview }); + } + onSaved(); + onBack(); + } catch (e) { + const msg = e instanceof ApiError ? e.message : e instanceof Error ? e.message : "Save failed."; + toast.error("Bulk save failed", { description: msg }); + } finally { + setSaving(false); + } + }; + + return ( +
+
+ +

Location bulk edit

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + {rows.map((r, idx) => ( + + + + + + + + + + + + + + + + + + ))} + +
#Location IDCompanyRegionLocation Name *StreetCityStateCountryZipPhoneEmailLatLngActive
+ {idx + 1} + + + + updateRow(idx, { partner: e.target.value })} + /> + + updateRow(idx, { groupName: e.target.value })} + /> + + updateRow(idx, { locationName: e.target.value })} + /> + + updateRow(idx, { street: e.target.value })} /> + + updateRow(idx, { city: e.target.value })} /> + + updateRow(idx, { stateCode: e.target.value })} /> + + updateRow(idx, { country: e.target.value })} /> + + updateRow(idx, { zipCode: e.target.value })} /> + + updateRow(idx, { phone: e.target.value })} /> + + updateRow(idx, { email: e.target.value })} /> + + { + const v = e.target.value.trim(); + updateRow(idx, { latitude: v === "" ? null : Number(v) }); + }} + /> + + { + const v = e.target.value.trim(); + updateRow(idx, { longitude: v === "" ? null : Number(v) }); + }} + /> + +
+ updateRow(idx, { state: !!c })} /> +
+
+
+
+

Only the locations you selected in the list are shown here.

+

You can copy and paste from Excel or Google Sheets.

+

Columns marked * are required for each row.

+
+
+ ); +} diff --git a/美国版/Food Labeling Management Platform/src/components/people/PeopleView.tsx b/美国版/Food Labeling Management Platform/src/components/people/PeopleView.tsx index ef93e76..3e82029 100755 --- a/美国版/Food Labeling Management Platform/src/components/people/PeopleView.tsx +++ b/美国版/Food Labeling Management Platform/src/components/people/PeopleView.tsx @@ -1096,7 +1096,7 @@ export function PeopleView({ initialSubTab, onInitialSubTabConsumed }: PeopleVie - + 0 && members.every((m) => selectedMemberIds.has(m.id))} onCheckedChange={(c) => { @@ -1131,7 +1131,7 @@ export function PeopleView({ initialSubTab, onInitialSubTabConsumed }: PeopleVie ) : ( members.map((m) => ( - + { diff --git a/美国版/Food Labeling Management Platform/src/components/products/ProductsView.tsx b/美国版/Food Labeling Management Platform/src/components/products/ProductsView.tsx index 807f55e..338f58a 100755 --- a/美国版/Food Labeling Management Platform/src/components/products/ProductsView.tsx +++ b/美国版/Food Labeling Management Platform/src/components/products/ProductsView.tsx @@ -81,7 +81,8 @@ import type { ProductCategoryDto, ProductCategoryCreateInput } from "../../types import { SearchableSelect } from "../ui/searchable-select"; import { SearchableMultiSelect } from "../ui/searchable-multi-select"; import { BatchImportDialog } from "../bulk/batch-import-dialog"; -import { ProductBulkEditDialog } from "./product-bulk-edit-dialog"; +import { ProductBulkEditPage } from "./product-bulk-edit-page"; +import { cn } from "../ui/utils"; import { Pagination, PaginationContent, @@ -170,7 +171,7 @@ export function ProductsView() { const [actionsOpenId, setActionsOpenId] = useState(null); const [selectedProductIds, setSelectedProductIds] = useState>(() => new Set()); const [bulkImportOpen, setBulkImportOpen] = useState(false); - const [bulkEditOpen, setBulkEditOpen] = useState(false); + const [productBulkEditPage, setProductBulkEditPage] = useState(false); const [bulkEditSeed, setBulkEditSeed] = useState([]); const [tmplDownloading, setTmplDownloading] = useState(false); const [excelExporting, setExcelExporting] = useState(false); @@ -362,6 +363,10 @@ export function ProductsView() { reloadCategoryCatalog(); }; + useEffect(() => { + if (activeTab !== "products") setProductBulkEditPage(false); + }, [activeTab]); + const locationOptions = useMemo( () => locations.map((loc) => ({ @@ -394,7 +399,7 @@ export function ProductsView() { return (
-
+
+ {productBulkEditPage ? ( +
+ { + setProductBulkEditPage(false); + setBulkEditSeed([]); + }} + onSaved={() => { + setSelectedProductIds(new Set()); + refresh(); + }} + /> +
+ ) : ( + <>
{activeTab === "products" && ( <> @@ -568,7 +590,7 @@ export function ProductsView() { return; } setBulkEditSeed(seed); - setBulkEditOpen(true); + setProductBulkEditPage(true); }} > Bulk Edit @@ -602,7 +624,7 @@ export function ProductsView() {
- + 0 && products.every((p) => selectedProductIds.has(p.id))} onCheckedChange={(c) => { @@ -644,7 +666,7 @@ export function ProductsView() { const active = p.state !== false; return ( - + { @@ -995,6 +1017,8 @@ export function ProductsView() { )} + + )} - { - setSelectedProductIds(new Set()); - refresh(); - }} - /> - void; - seed: ProductDto[]; - categories: ProductCategoryDto[]; - onSaved: () => void; -}; - -type RowState = ProductBulkUpdateItemVo; - -function productToRow(p: ProductDto, locationIds: string[]): RowState { - return { - id: p.id, - productCode: p.productCode ?? "", - productName: (p.productName ?? "").trim(), - categoryId: (p.categoryId ?? "").trim() || null, - productImageUrl: p.productImageUrl ?? null, - state: p.state !== false, - locationIds: [...locationIds], - }; -} - -function emptyPadRow(): RowState { - return { - id: "", - productCode: "", - productName: "", - categoryId: null, - productImageUrl: null, - state: true, - locationIds: [], - }; -} - -function parseIdsCsv(s: string): string[] { - return s - .split(/[,;|\s]+/) - .map((x) => x.trim()) - .filter(Boolean); -} - -export function ProductBulkEditDialog({ open, onOpenChange, seed, categories, onSaved }: ProductBulkEditDialogProps) { - const [rows, setRows] = useState([]); - const [saving, setSaving] = useState(false); - const [locCsvByIdx, setLocCsvByIdx] = useState([]); - - const minRows = useMemo(() => Math.max(seed.length + 10, 10), [seed.length]); - - useEffect(() => { - if (!open) return; - const data = seed.map((p) => productToRow(p, p.locationIds ?? [])); - const pad = Math.max(0, minRows - data.length); - const padded = [...data, ...Array.from({ length: pad }, () => emptyPadRow())]; - setRows(padded); - setLocCsvByIdx( - padded.map((r) => (r.locationIds && r.locationIds.length ? r.locationIds.join(",") : "")), - ); - }, [open, seed, minRows]); - - const updateRow = (idx: number, patch: Partial) => { - setRows((prev) => { - const next = [...prev]; - next[idx] = { ...next[idx], ...patch }; - return next; - }); - }; - - const removeRow = (idx: number) => { - setRows((prev) => (prev.length <= 1 ? prev : prev.filter((_, i) => i !== idx))); - setLocCsvByIdx((prev) => (prev.length <= 1 ? prev : prev.filter((_, i) => i !== idx))); - }; - - const syncLocIds = (idx: number, csv: string) => { - const nextCsv = [...locCsvByIdx]; - nextCsv[idx] = csv; - setLocCsvByIdx(nextCsv); - updateRow(idx, { locationIds: parseIdsCsv(csv) }); - }; - - const handleSave = async () => { - const items: ProductBulkUpdateItemVo[] = rows - .filter((r) => isValidBulkProductId(r.id)) - .map((r, i) => ({ - id: r.id.trim(), - productCode: String(r.productCode ?? "").trim() || null, - productName: r.productName.trim(), - categoryId: r.categoryId?.trim() ? r.categoryId.trim() : null, - productImageUrl: r.productImageUrl?.trim() ? r.productImageUrl.trim() : null, - state: r.state !== false, - locationIds: parseIdsCsv(locCsvByIdx[i] ?? ""), - })); - - if (items.length === 0) { - toast.error("No valid rows", { description: "Select products in the list first." }); - return; - } - - setSaving(true); - try { - const res = await updateProductsBulk({ items }); - toast.success("Bulk update finished", { - description: `Success: ${res.successCount}, failed: ${res.failCount}`, - }); - onSaved(); - onOpenChange(false); - } catch (e) { - const msg = e instanceof ApiError ? e.message : e instanceof Error ? e.message : "Save failed."; - toast.error("Bulk save failed", { description: msg }); - } finally { - setSaving(false); - } - }; - - return ( - - -
- - - Product bulk edit - Edit products in a grid and save all. - - -
-
-
- - - - - - - - - - - - {rows.map((r, idx) => ( - - - - - - - - - - ))} - -
- Product CodeProduct *CategoryImage URLLocation IDsActive
-
- {idx + 1} - -
-
- updateRow(idx, { productCode: e.target.value })} /> - - updateRow(idx, { productName: e.target.value })} /> - - - - updateRow(idx, { productImageUrl: e.target.value || null })} - /> - - syncLocIds(idx, e.target.value)} - placeholder="id1,id2" - /> - - updateRow(idx, { state: !!c })} /> -
- -
-

Columns with * are required for saved rows.

-

Location IDs: comma-separated location primary keys (GUID).

-
- - - ); -} diff --git a/美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-page.tsx b/美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-page.tsx new file mode 100644 index 0000000..0ad04c8 --- /dev/null +++ b/美国版/Food Labeling Management Platform/src/components/products/product-bulk-edit-page.tsx @@ -0,0 +1,196 @@ +import React, { useEffect, useState } from "react"; +import { Button } from "../ui/button"; +import { Input } from "../ui/input"; +import { Switch } from "../ui/switch"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "../ui/select"; +import { toast } from "sonner"; +import { ApiError } from "../../lib/apiClient"; +import { updateProductsBulk, type ProductBulkUpdateItemVo } from "../../services/productService"; +import type { ProductDto } from "../../types/product"; +import type { ProductCategoryDto } from "../../types/productCategory"; + +function isValidBulkProductId(id: string): boolean { + return !!(id ?? "").trim(); +} + +export type ProductBulkEditPageProps = { + seed: ProductDto[]; + categories: ProductCategoryDto[]; + onBack: () => void; + onSaved: () => void; +}; + +type RowState = ProductBulkUpdateItemVo; + +function productToRow(p: ProductDto, locationIds: string[]): RowState { + return { + id: p.id, + productCode: p.productCode ?? "", + productName: (p.productName ?? "").trim(), + categoryId: (p.categoryId ?? "").trim() || null, + productImageUrl: p.productImageUrl ?? null, + state: p.state !== false, + locationIds: [...locationIds], + }; +} + +function parseIdsCsv(s: string): string[] { + return s + .split(/[,;|\s]+/) + .map((x) => x.trim()) + .filter(Boolean); +} + +export function ProductBulkEditPage({ seed, categories, onBack, onSaved }: ProductBulkEditPageProps) { + const [rows, setRows] = useState([]); + const [saving, setSaving] = useState(false); + const [locCsvByIdx, setLocCsvByIdx] = useState([]); + + useEffect(() => { + const data = seed.map((p) => productToRow(p, p.locationIds ?? [])); + setRows(data); + setLocCsvByIdx(data.map((r) => (r.locationIds && r.locationIds.length ? r.locationIds.join(",") : ""))); + }, [seed]); + + const updateRow = (idx: number, patch: Partial) => { + setRows((prev) => { + const next = [...prev]; + next[idx] = { ...next[idx], ...patch }; + return next; + }); + }; + + const syncLocIds = (idx: number, csv: string) => { + const nextCsv = [...locCsvByIdx]; + nextCsv[idx] = csv; + setLocCsvByIdx(nextCsv); + updateRow(idx, { locationIds: parseIdsCsv(csv) }); + }; + + const handleSave = async () => { + const items: ProductBulkUpdateItemVo[] = rows + .filter((r) => isValidBulkProductId(r.id)) + .map((r, i) => ({ + id: r.id.trim(), + productCode: String(r.productCode ?? "").trim() || null, + productName: r.productName.trim(), + categoryId: r.categoryId?.trim() ? r.categoryId.trim() : null, + productImageUrl: r.productImageUrl?.trim() ? r.productImageUrl.trim() : null, + state: r.state !== false, + locationIds: parseIdsCsv(locCsvByIdx[i] ?? ""), + })); + + if (items.length === 0) { + toast.error("No valid rows", { description: "Select products in the list first, then open Bulk Edit." }); + return; + } + + setSaving(true); + try { + const res = await updateProductsBulk({ items }); + toast.success("Bulk update finished", { + description: `Success: ${res.successCount}, failed: ${res.failCount}`, + }); + onSaved(); + onBack(); + } catch (e) { + const msg = e instanceof ApiError ? e.message : e instanceof Error ? e.message : "Save failed."; + toast.error("Bulk save failed", { description: msg }); + } finally { + setSaving(false); + } + }; + + return ( +
+
+ +

Product bulk edit

+ +
+
+ + + + + + + + + + + + + + {rows.map((r, idx) => ( + + + + + + + + + + ))} + +
#Product CodeProduct *CategoryImage URLLocation IDsActive
+ {idx + 1} + + updateRow(idx, { productCode: e.target.value })} /> + + updateRow(idx, { productName: e.target.value })} /> + + + + updateRow(idx, { productImageUrl: e.target.value || null })} + /> + + syncLocIds(idx, e.target.value)} + placeholder="id1,id2" + /> + + updateRow(idx, { state: !!c })} /> +
+
+
+

Only the products you selected in the list are shown here.

+

Columns with * are required for saved rows.

+

Location IDs: comma-separated location primary keys (GUID).

+
+
+ ); +} diff --git a/美国版/Food Labeling Management Platform/src/components/ui/table.tsx b/美国版/Food Labeling Management Platform/src/components/ui/table.tsx index 59e4dcc..b129c0d 100755 --- a/美国版/Food Labeling Management Platform/src/components/ui/table.tsx +++ b/美国版/Food Labeling Management Platform/src/components/ui/table.tsx @@ -70,7 +70,7 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) { [role=checkbox]]:translate-y-[2px]", + "text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&>[role=checkbox]]:translate-y-[2px]", className, )} {...props} @@ -83,7 +83,7 @@ function TableCell({ className, ...props }: React.ComponentProps<"td">) { [role=checkbox]]:translate-y-[2px]", + "p-2 align-middle whitespace-nowrap [&>[role=checkbox]]:translate-y-[2px]", className, )} {...props} diff --git a/美国版/Food Labeling Management Platform/src/lib/batchFileHttp.ts b/美国版/Food Labeling Management Platform/src/lib/batchFileHttp.ts index cfb951d..e1a2a54 100644 --- a/美国版/Food Labeling Management Platform/src/lib/batchFileHttp.ts +++ b/美国版/Food Labeling Management Platform/src/lib/batchFileHttp.ts @@ -40,8 +40,11 @@ function parseFileNameFromContentDisposition(h: string | null): string | null { function getAbpErrorMessage(payload: unknown): string | null { if (!payload || typeof payload !== "object") return null; - const p = payload as { error?: { message?: string } }; - return p.error?.message?.trim() || null; + const p = payload as { error?: { message?: string }; errors?: unknown }; + const nested = p.error?.message?.trim(); + if (nested) return nested; + if (typeof p.errors === "string" && p.errors.trim()) return p.errors.trim(); + return null; } function unwrapEnvelope(payload: unknown): T { @@ -105,6 +108,51 @@ export async function authorizedGetBlobDownload(opts: { } /** + * POST 下载二进制。ABP 约定控制器里 `Export*` / `Download*` 多为 **POST**; + * 若误用 GET,会命中 `GET …/{id}` 把路径段当成 id(如产品导出报「产品不存在」)。 + */ +export async function authorizedPostBlobDownload(opts: { + path: string; + query?: Record; + defaultFileName: string; + signal?: AbortSignal; +}): Promise { + const baseUrl = import.meta.env.VITE_API_BASE_URL ?? "http://localhost:19001"; + const url = joinUrl(baseUrl, `${API_PREFIX}${opts.path}${toQueryString(opts.query ?? {})}`); + const token = getTokenForFetch(); + const headers: Record = { Accept: "*/*" }; + if (token) headers.Authorization = `Bearer ${token}`; + const res = await fetch(url, { + method: "POST", + headers, + signal: opts.signal, + }); + const ct = res.headers.get("content-type") ?? ""; + if (!res.ok) { + if (ct.includes("application/json")) { + const payload = await res.json().catch(() => null); + const msg = getAbpErrorMessage(payload) || "Download failed."; + throw new ApiError(msg, res.status, payload); + } + const t = await res.text().catch(() => ""); + throw new ApiError(t || "Download failed.", res.status, t); + } + if (ct.includes("application/json")) { + const payload = await res.json().catch(() => null); + const msg = getAbpErrorMessage(payload) || "Download failed."; + throw new ApiError(msg, res.status, payload); + } + const blob = await res.blob(); + const name = parseFileNameFromContentDisposition(res.headers.get("content-disposition")) || opts.defaultFileName; + const href = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = href; + a.download = name; + a.click(); + URL.revokeObjectURL(href); +} + +/** * multipart 上传文件,解析 JSON 响应(兼容 ABP 包裹 `{ data, succeeded }`)。 */ export async function authorizedPostMultipartJson(opts: { diff --git a/美国版/Food Labeling Management Platform/src/services/groupService.ts b/美国版/Food Labeling Management Platform/src/services/groupService.ts index 9d0a607..fa66ce6 100644 --- a/美国版/Food Labeling Management Platform/src/services/groupService.ts +++ b/美国版/Food Labeling Management Platform/src/services/groupService.ts @@ -114,7 +114,7 @@ export type GroupExportQuery = { sorting?: string; }; -/** GET /api/app/group/export-pdf */ +/** POST /api/app/group/export-pdf — ABP `Export*` 为 POST */ export async function exportGroupsPdf(input: GroupExportQuery, signal?: AbortSignal): Promise { const baseUrl = getBaseUrl(); const token = getToken(); @@ -129,7 +129,7 @@ export async function exportGroupsPdf(input: GroupExportQuery, signal?: AbortSig ); const headers: Record = {}; if (token) headers.Authorization = `Bearer ${token}`; - const res = await fetch(url, { method: "GET", headers, signal }); + const res = await fetch(url, { method: "POST", headers, signal }); if (!res.ok) { const ct = res.headers.get("content-type") ?? ""; let msg = "Export failed."; diff --git a/美国版/Food Labeling Management Platform/src/services/locationService.ts b/美国版/Food Labeling Management Platform/src/services/locationService.ts index 849e2c6..2f3b4a2 100644 --- a/美国版/Food Labeling Management Platform/src/services/locationService.ts +++ b/美国版/Food Labeling Management Platform/src/services/locationService.ts @@ -1,5 +1,5 @@ import { createApiClient } from "../lib/apiClient"; -import { authorizedGetBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; +import { authorizedPostBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; import type { LocationCreateInput, LocationDto, @@ -151,7 +151,7 @@ export type LocationBulkUpdateResultDto = { }; export async function downloadLocationImportTemplate(signal?: AbortSignal): Promise { - await authorizedGetBlobDownload({ + await authorizedPostBlobDownload({ path: "/location/download-location-import-template", defaultFileName: "Location-Manager-template.xlsx", signal, @@ -159,7 +159,7 @@ export async function downloadLocationImportTemplate(signal?: AbortSignal): Prom } export async function exportLocationsExcel(input: LocationExportQueryInput, signal?: AbortSignal): Promise { - await authorizedGetBlobDownload({ + await authorizedPostBlobDownload({ path: "/location/export-locations-excel", query: { Sorting: input.sorting, @@ -185,9 +185,9 @@ export async function importLocationsBatch(file: File, signal?: AbortSignal): Pr export async function updateLocationsBulk( body: { items: LocationBulkUpdateItemVo[] }, ): Promise { - // ABP 约定控制器:`Update*Async` 多为 PUT,POST 会 405 + // ABP:`UpdateLocationsBulkAsync` → `locations-bulk`(勿写 `update-locations-bulk`) return api.requestJson({ - path: "/location/update-locations-bulk", + path: "/location/locations-bulk", method: "PUT", body, }); diff --git a/美国版/Food Labeling Management Platform/src/services/partnerService.ts b/美国版/Food Labeling Management Platform/src/services/partnerService.ts index b28308c..4c3e13c 100644 --- a/美国版/Food Labeling Management Platform/src/services/partnerService.ts +++ b/美国版/Food Labeling Management Platform/src/services/partnerService.ts @@ -118,7 +118,7 @@ export type PartnerExportQuery = { sorting?: string; }; -/** GET /api/app/partner/export-pdf — 与列表筛选字段一致 */ +/** POST /api/app/partner/export-pdf — ABP `Export*` 为 POST,勿用 GET(会误命中 `GET …/{id}`) */ export async function exportPartnersPdf(input: PartnerExportQuery, signal?: AbortSignal): Promise { const baseUrl = getBaseUrl(); const token = getToken(); @@ -132,7 +132,7 @@ export async function exportPartnersPdf(input: PartnerExportQuery, signal?: Abor ); const headers: Record = {}; if (token) headers.Authorization = `Bearer ${token}`; - const res = await fetch(url, { method: "GET", headers, signal }); + const res = await fetch(url, { method: "POST", headers, signal }); if (!res.ok) { const ct = res.headers.get("content-type") ?? ""; let msg = "Export failed."; diff --git a/美国版/Food Labeling Management Platform/src/services/productService.ts b/美国版/Food Labeling Management Platform/src/services/productService.ts index 776a60b..ccbd27b 100644 --- a/美国版/Food Labeling Management Platform/src/services/productService.ts +++ b/美国版/Food Labeling Management Platform/src/services/productService.ts @@ -1,5 +1,5 @@ import { createApiClient } from "../lib/apiClient"; -import { authorizedGetBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; +import { authorizedGetBlobDownload, authorizedPostBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; import type { ProductCreateInput, ProductDto, @@ -147,13 +147,17 @@ export type ProductBulkUpdateResultDto = { }; export async function downloadProductImportTemplate(signal?: AbortSignal): Promise { - await authorizedGetBlobDownload({ + await authorizedPostBlobDownload({ path: `${PATH}/download-product-import-template`, defaultFileName: "Product-Manager-template.xlsx", signal, }); } +/** + * 与后端 `ExportProductsExcelAsync([FromQuery] ProductGetListInputVo)` 一致:GET + 查询参数。 + * 勿用 POST,否则易与 `GET /product/{id}` 等路由混淆或 405。 + */ export async function exportProductsExcel(input: ProductExportQueryInput, signal?: AbortSignal): Promise { await authorizedGetBlobDownload({ path: `${PATH}/export-products-excel`, @@ -177,9 +181,9 @@ export async function importProductsBatch(file: File, signal?: AbortSignal): Pro } export async function updateProductsBulk(body: { items: ProductBulkUpdateItemVo[] }): Promise { - // ABP 约定控制器:`Update*Async` 多为 PUT,POST 会 405 + // ABP:`UpdateProductsBulkAsync` → `products-bulk`(勿写 `update-products-bulk`) return api.requestJson({ - path: `${PATH}/update-products-bulk`, + path: `${PATH}/products-bulk`, method: "PUT", body, }); diff --git a/美国版/Food Labeling Management Platform/src/services/reportsService.ts b/美国版/Food Labeling Management Platform/src/services/reportsService.ts index b3510e5..800b357 100644 --- a/美国版/Food Labeling Management Platform/src/services/reportsService.ts +++ b/美国版/Food Labeling Management Platform/src/services/reportsService.ts @@ -1,5 +1,5 @@ import { ApiError, createApiClient } from "../lib/apiClient"; -import { authorizedGetBlobDownload } from "../lib/batchFileHttp"; +import { authorizedPostBlobDownload } from "../lib/batchFileHttp"; import type { LabelReportData, LabelReportQueryInput, @@ -357,7 +357,7 @@ export async function exportPrintLogPdf(input: ReportsPrintLogQueryInput): Promi `/api/app${REPORTS_PREFIX}/export-print-log-pdf${buildPrintLogExportQuery(input)}` ); const token = getTokenForFetch(); - const res = await fetch(path, { method: "GET", headers: token ? { Authorization: `Bearer ${token}` } : {} }); + const res = await fetch(path, { method: "POST", headers: token ? { Authorization: `Bearer ${token}` } : {} }); const ct = res.headers.get("content-type") ?? ""; if (!res.ok) { if (ct.includes("application/json")) { @@ -387,7 +387,7 @@ export async function exportPrintLogPdf(input: ReportsPrintLogQueryInput): Promi } export async function exportPrintLogExcel(input: ReportsPrintLogQueryInput, signal?: AbortSignal): Promise { - await authorizedGetBlobDownload({ + await authorizedPostBlobDownload({ path: `${REPORTS_PREFIX}/export-print-log-excel`, query: { Sorting: input.sorting ?? "PrintedAt desc", @@ -410,7 +410,7 @@ export async function exportLabelReportPdf(input: LabelReportQueryInput): Promis `/api/app${REPORTS_PREFIX}/export-label-report-pdf${buildLabelReportExportQuery(input)}` ); const token = getTokenForFetch(); - const res = await fetch(path, { method: "GET", headers: token ? { Authorization: `Bearer ${token}` } : {} }); + const res = await fetch(path, { method: "POST", headers: token ? { Authorization: `Bearer ${token}` } : {} }); const ct = res.headers.get("content-type") ?? ""; if (!res.ok) { if (ct.includes("application/json")) { diff --git a/美国版/Food Labeling Management Platform/src/services/roleService.ts b/美国版/Food Labeling Management Platform/src/services/roleService.ts index 2758d45..f23e700 100644 --- a/美国版/Food Labeling Management Platform/src/services/roleService.ts +++ b/美国版/Food Labeling Management Platform/src/services/roleService.ts @@ -67,7 +67,7 @@ export type RoleExportQuery = { state?: boolean; }; -/** GET /api/app/role/export-pdf — 与角色列表筛选字段一致 */ +/** POST /api/app/role/export-pdf — ABP `Export*` 为 POST */ export async function exportRolesPdf(input: RoleExportQuery, signal?: AbortSignal): Promise { const baseUrl = getBaseUrl(); const token = getToken(); @@ -81,7 +81,7 @@ export async function exportRolesPdf(input: RoleExportQuery, signal?: AbortSigna ); const headers: Record = {}; if (token) headers.Authorization = `Bearer ${token}`; - const res = await fetch(url, { method: "GET", headers, signal }); + const res = await fetch(url, { method: "POST", headers, signal }); if (!res.ok) { const ct = res.headers.get("content-type") ?? ""; let msg = "Export failed."; diff --git a/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts b/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts index 5f9c731..2fe67d2 100644 --- a/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts +++ b/美国版/Food Labeling Management Platform/src/services/teamMemberService.ts @@ -1,5 +1,5 @@ -import { ApiError, createApiClient } from "../lib/apiClient"; -import { authorizedGetBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; +import { createApiClient } from "../lib/apiClient"; +import { authorizedPostBlobDownload, authorizedPostMultipartJson } from "../lib/batchFileHttp"; import type { PagedResultDto, TeamMemberCreateInput, @@ -277,7 +277,7 @@ export type TeamMemberBulkUpdateResultDto = { }; export async function downloadTeamMemberImportTemplate(signal?: AbortSignal): Promise { - await authorizedGetBlobDownload({ + await authorizedPostBlobDownload({ path: `${PATH}/download-team-member-import-template`, defaultFileName: "Team-Member-template.xlsx", signal, @@ -285,7 +285,7 @@ export async function downloadTeamMemberImportTemplate(signal?: AbortSignal): Pr } export async function exportTeamMembersPdf(input: TeamMemberExportQueryInput, signal?: AbortSignal): Promise { - await authorizedGetBlobDownload({ + await authorizedPostBlobDownload({ path: `${PATH}/export-team-members-pdf`, query: { Keyword: input.keyword, @@ -308,53 +308,14 @@ export async function importTeamMembersBatch(file: File, signal?: AbortSignal): }); } -function bulkItemToUpdateInput(item: TeamMemberBulkUpdateItemVo): TeamMemberUpdateInput { - const phoneStr = item.phone == null ? null : String(item.phone).trim() || null; - const input: TeamMemberUpdateInput = { - fullName: item.fullName, - userName: item.userName, - email: item.email ?? null, - phone: phoneStr, - roleId: item.roleId, - locationIds: item.locationIds ?? [], - state: item.state, - }; - if (item.password && String(item.password).trim()) { - input.password = item.password; - } - return input; -} - -// 部分环境 bulk 路径与 `PUT /team-member/{id}` 冲突;不改后端时改为逐条 PUT。 export async function updateTeamMembersBulk( body: { items: TeamMemberBulkUpdateItemVo[] }, ): Promise { - const ZERO = "00000000-0000-0000-0000-000000000000"; - const errors: NonNullable = []; - let successCount = 0; - let failCount = 0; - - for (let i = 0; i < body.items.length; i += 1) { - const item = body.items[i]; - const rowNumber = i + 1; - const id = (item.id ?? "").trim(); - if (!id || id.toLowerCase() === ZERO) continue; - - try { - await updateTeamMember(id, bulkItemToUpdateInput(item)); - successCount += 1; - } catch (e) { - failCount += 1; - const message = - e instanceof ApiError ? e.message : e instanceof Error ? e.message : "Update failed."; - errors.push({ rowNumber, id, message }); - } - } - - return { - successCount, - failCount, - errors: errors.length ? errors : undefined, - }; + // ABP 约定 URL:`UpdateTeamMembersBulkAsync` 去掉动词前缀后为 `team-members-bulk`(勿用 `update-...`,否则会被 `PUT …/{id}` 当成 Guid) + return api.requestJson({ + path: `${PATH}/team-members-bulk`, + method: "PUT", + body, + }); } diff --git a/项目相关文档/批量导入导出接口说明.md b/项目相关文档/批量导入导出接口说明.md index 8fcd1a0..3016f32 100644 --- a/项目相关文档/批量导入导出接口说明.md +++ b/项目相关文档/批量导入导出接口说明.md @@ -113,9 +113,9 @@ | 项目 | 说明 | |------|------| | 方法 | `UpdateLocationsBulkAsync` | -| HTTP | `POST` | +| HTTP | `PUT` | | Content-Type | `application/json` | -| 常见路径 | `/api/app/location/update-locations-bulk` | +| 常见路径 | `/api/app/location/locations-bulk`(ABP 会去掉方法名中的 `Update` 前缀,不是 `update-locations-bulk`) | | Body | `LocationBulkUpdateInputVo` | **请求体 `LocationBulkUpdateInputVo`** @@ -207,9 +207,9 @@ | 项目 | 说明 | |------|------| | 方法 | `UpdateTeamMembersBulkAsync` | -| HTTP | `POST` | +| HTTP | `PUT` | | Content-Type | `application/json` | -| 常见路径 | `/api/app/team-member/update-team-members-bulk` | +| 常见路径 | `/api/app/team-member/team-members-bulk`(勿写 `update-team-members-bulk`,否则易命中 `PUT …/{id}` 导致 Guid 校验错误) | | Body | `TeamMemberBulkUpdateInputVo`:`items` 为 `TeamMemberBulkUpdateItemVo` 数组 | 每行含 **`id`(成员 Guid)** 及与单条 **`PUT /api/app/team-member/{id}`** 相同的字段(`password` 可空表示不改密码)。`id` 为全零 GUID 的项忽略。整单规则与 Location 批量编辑相同(`MaxBulkUpdateItems`、至少一条有效 `id` 等)。 @@ -270,9 +270,9 @@ | 项目 | 说明 | |------|------| | 方法 | `UpdateProductsBulkAsync` | -| HTTP | `POST` | +| HTTP | `PUT` | | Content-Type | `application/json` | -| 常见路径 | `/api/app/product/update-products-bulk` | +| 常见路径 | `/api/app/product/products-bulk` | | Body | `ProductBulkUpdateInputVo`:`items` 为 `ProductBulkUpdateItemVo` 数组 | 每行含 **`id`(产品主键字符串,与列表/详情返回的 `id` 一致)** 及与单条 **`PUT /api/app/product/{id}`** 相同的 body 字段(`ProductUpdateInputVo` / `ProductCreateInputVo` 形状:`productCode`、`productName`、`categoryId`、`productImageUrl`、`state`、`locationIds`)。`id` 为空或仅空白的项**忽略**。整单规则与 Location / Team Member 批量编辑相同(`MaxBulkUpdateItems`、至少一条有效 `id` 等)。 @@ -366,7 +366,7 @@ curl -X POST "$BASE/api/app/location/import-locations-batch" \ -H "Authorization: TOKEN" \ -F "file=@./Location-Manager-template.xlsx" -curl -X POST "$BASE/api/app/location/update-locations-bulk" \ +curl -X PUT "$BASE/api/app/location/locations-bulk" \ -H "Authorization: TOKEN" \ -H "Content-Type: application/json" \ -d "{\"items\":[{\"id\":\"YOUR_LOCATION_ID\",\"locationName\":\"UNCC store\",\"state\":true}]}" @@ -384,7 +384,7 @@ curl -X POST "$BASE/api/app/team-member/import-team-members-batch" \ -H "Authorization: TOKEN" \ -F "file=@./Team-Member-template.xlsx" -curl -X POST "$BASE/api/app/team-member/update-team-members-bulk" \ +curl -X PUT "$BASE/api/app/team-member/team-members-bulk" \ -H "Authorization: TOKEN" \ -H "Content-Type: application/json" \ -d "{\"items\":[{\"id\":\"YOUR_USER_GUID\",\"fullName\":\"John\",\"userName\":\"john@example.com\",\"email\":\"john@example.com\",\"phone\":789654444,\"roleId\":\"ROLE_GUID\",\"locationIds\":[\"LOCATION_GUID\"],\"state\":true}]}" @@ -416,7 +416,7 @@ curl -X POST "$BASE/api/app/product/import-products-batch" \ -H "Authorization: TOKEN" \ -F "file=@./Product-Manager-template.xlsx" -curl -X POST "$BASE/api/app/product/update-products-bulk" \ +curl -X PUT "$BASE/api/app/product/products-bulk" \ -H "Authorization: TOKEN" \ -H "Content-Type: application/json" \ -d "{\"items\":[{\"id\":\"YOUR_PRODUCT_ID\",\"productName\":\"Tuna & Bacon Sub\",\"categoryId\":\"CATEGORY_ID\",\"productCode\":\"40001\",\"state\":true,\"locationIds\":[\"LOCATION_GUID_1\",\"LOCATION_GUID_2\"]}]}" -- libgit2 0.21.4