1import{j as t}from"./vendor-ui.BwPBmVwt.js";import{r as C,R as M}from"./vendor-react.kR8tqwKZ.js";import{c as Xs,s as re,bp as it,P as en,B as V,bd as Ne,be as je,bf as ve,X as Gt,bq as nt,br as tn,au as sn,ao as ke,O as nn}from"./index.86ltQqcV.js";import{u as an}from"./useTabParam.0zzDdGkW.js";import{T as rn,a as on,b as Ze,c as Ve}from"./tabs.B_vF9hjw.js";import{c as L}from"./utils.DalesSUU.js";import{u as Ht}from"./useQuery.CKEnFAuE.js";import{d as ln,e as cn,a as dn}from"./packagingFeeCalculator.Ds_FKGKV.js";import{s as Be,f as z,n as lt,o as Ut,q as ge,r as hn,u as mn,v as un,w as xn,x as zt,y as Kt,z as fn,A as gn,B as pn,C as yn,D as bn,E as Nn,F as Zt,G as jn,H as vn,I as Vt,J as wn,K as Mn,L as kn,M as Cn,N as Dn,O as _n,P as Sn,Q as On,R as Wn,S as Fn,U as Tn,V as Ln,W as In,X as En,d as pe}from"./vendor-utils.D2q0l15H.js";import{k as he}from"./ko.CSP0_8Uo.js";import{I as de}from"./input.Bn8hRSEL.js";import{C as We}from"./calendar.o8eP9MLv.js";import{S as An}from"./search.CoLV_vkF.js";import{P as we}from"./package.sYWGe6pn.js";import{u as Pn,A as Bn}from"./AdminWriteGuard.xT1R3h4-.js";import{R as Fe}from"./refresh-cw.BJ6elI4y.js";import{S as $n}from"./save.DyDnqxYS.js";import{I as Yn}from"./info.oSrbbhNg.js";import{T as Te}from"./truck.Cz6XYkxF.js";import{S as xe}from"./settings.Eoz354Vz.js";import{L as qn}from"./lock-open.DyYde3-e.js";import{L as Le}from"./lock.DKQK9Mbl.js";import{T as Ce}from"./triangle-alert.DiFS_pz6.js";import{T as Jt}from"./trash-2.DYInpbaD.js";import{P as Qt}from"./plus.VSSFQhJP.js";import{C as Xt}from"./circle-check.C2VxFn-u.js";import{C as at}from"./circle-x.CdkrLera.js";import{T as Ie}from"./trending-up.DrO9OvSf.js";import{T as Me}from"./trending-down.HWXfzOr_.js";import{A as rt}from"./arrow-right.BJDjibZk.js";import{L as es}from"./lightbulb.D5sQEORT.js";import{G as Rn}from"./grid-3x3.MTklan2N.js";import{C as Gn}from"./chevron-down.8Oyg22r0.js";import{C as Hn}from"./chevron-right.BO4QQ722.js";import{C as Ee}from"./chart-column.wBcVfGnD.js";import{M as jt}from"./minus.-470SVQC.js";import"./vendor-three.C5-HLXBy.js";const Un=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]],zn=Xs("circle-dollar-sign",Un),fe=500,Kn={cj:"CJ",chunil:"ì²ì¼",kyungdong:"ê²½ë"},ts={cj:"CJëííµì´",chunil:"ì²ì¼íë°°",kyungdong:"ê²½ëíë°°"},Zn={CJëííµì´:"cj",ì²ì¼íë°°:"chunil",ê²½ëíë°°:"kyungdong"},Vn=[{label:"ìµê·¼ 7ì¼",days:7},{label:"ìµê·¼ 14ì¼",days:14},{label:"ìµê·¼ 30ì¼",days:30},{label:"ìµê·¼ 60ì¼",days:60}],Je=1e3;async function Jn(e,s){const a=[];let n=0;for(;;){const{data:r,error:o}=await re.from("tp_order").select("id, order_code, order_date, shipping_company, item_invoices, user_name, phone_number, shipping_fee").gte("order_date",e).lte("order_date",s).range(n,n+Je-1);if(o)throw o;if(!r||r.length===0||(a.push(...r),r.length<Je))break;n+=Je}return a}async function Qn(e){const s=[];for(let a=0;a<e.length;a+=fe){const n=e.slice(a,a+fe),{data:r,error:o}=await re.from("tp_order_mapping").select(` 2 internal_order_id, 3 request_order_id, 4 ln_order_requests!inner ( 5 is_matched, 6 customer_name, 7 customer_phone, 8 wood_subtotal, 9 accessory_subtotal, 10 packaging_fee, 11 total_amount, 12 request_data 13 ) 14 `).in("internal_order_id",n);if(o)throw o;r&&s.push(...r)}return s}async function Xn(e){const s=[];for(let a=0;a<e.length;a+=fe){const n=e.slice(a,a+fe),{data:r,error:o}=await re.from("tp_order_items").select("order_id, customer_width, customer_depth, quantity, manufacturing_specs, product_id").in("order_id",n);!o&&r&&s.push(...r)}return s}async function ea(e){const s=[],a=[...new Set(e)];for(let n=0;n<a.length;n+=fe){const r=a.slice(n,n+fe),{data:o,error:i}=await re.from("ln_shipping_invoice").select("*").in("order_code",r).order("invoice_seq",{ascending:!0});!i&&o&&s.push(...o)}return s}const ta=["admin","shippingFeeTracking"];function sa(){const[e,s]=C.useState(""),[a,n]=C.useState(!1),[r,o]=C.useState("all"),[i,l]=C.useState({from:Be(new Date,14),to:new Date}),{data:c=[],isLoading:h}=Ht({queryKey:[...ta,i.from?.toISOString(),i.to?.toISOString()],queryFn:async()=>
14{if(!i.from||!i.to)return[];const m=z(lt(i.from),"yyyy-MM-dd"),u=z(Ut(i.to),"yyyy-MM-dd"),g=await Jn(m,u);if(g.length===0)return[];const N=g.map(v=>v.id),y=new Map(g.map(v=>[v.id,v])),w=await Qn(N),f=w.map(v=>y.get(v.internal_order_id)?.order_code).filter(Boolean),p=new Map;for(const v of g){const F=v.item_invoices||[];if(F.length>0){const O=F.filter(E=>E.shipping_company).map((E,Y)=>({invoice_seq:Y+1,carrier:Zn[E.shipping_company]||"cj",recipient_name:"",recipient_phone:"",actual_fee:E.actual_fee!=null&&E.actual_fee>0?E.actual_fee:null}));O.length>0&&p.set(v.order_code,O)}}const k=f.filter(v=>!p.has(v));k.length>0&&(await ea(k)).forEach(F=>{const O=p.get(F.order_code)||[];O.push({invoice_seq:F.invoice_seq,carrier:F.carrier,recipient_name:F.recipient_name,recipient_phone:F.recipient_phone,actual_fee:F.actual_fee}),p.set(F.order_code,O)});const j=new Map,b=new Map,_=new Set;w.forEach(v=>{const F=y.get(v.internal_order_id),O=F?.order_code||"";if(!O)return;const E=p.get(O)||[],Y=E.reduce((B,K)=>B+(K.actual_fee??0),0),R=!_.has(v.request_order_id);if(v.request_order_id&&_.add(v.request_order_id),R){const K=v.ln_order_requests.request_data?.wood_items||[];if(K.length>0){const Z=b.get(O)||[];Z.push(...K.map(G=>({width:G.width||0,length:G.length||0,thickness:G.thickness||18,density:G.density??null,quantity:G.quantity||1}))),b.set(O,Z)}}const H=j.get(O);H?(H.mappingCount+=1,R&&(H.wood_subtotal+=v.ln_order_requests.wood_subtotal||0,H.accessory_subtotal+=v.ln_order_requests.accessory_subtotal||0,H.packaging_fee+=v.ln_order_requests.packaging_fee||0,H.total_amount+=v.ln_order_requests.total_amount||0)):j.set(O,{order_code:O,order_date:F?.order_date||"",internal_order_id:v.internal_order_id,request_order_id:v.request_order_id,is_matched:v.ln_order_requests.is_matched,customer_name:v.ln_order_requests.customer_name,customer_phone:v.ln_order_requests.customer_phone,mappingCount:1,wood_subtotal:v.ln_order_requests.wood_subtotal||0,accessory_subtotal:v.ln_order_requests.accessory_subtotal||0,packaging_fee:v.ln_order_requests.packaging_fee||0,shipping_company:F?.shipping_company||"",total_amount:v.ln_order_requests.total_amount||0,invoices:E,actualFeeTotal:Y,currentLogicFee:null,currentLogicBreakdown:null})});const T=[];for(const v of g){const F=v.order_code;if(j.has(F))continue;T.push(v.id);const O=p.get(F)||[],E=O.reduce((Y,R)=>Y+(R.actual_fee??0),0);j.set(F,{order_code:F,order_date:v.order_date||"",internal_order_id:v.id,request_order_id:0,is_matched:!1,customer_name:v.user_name||"",customer_phone:v.phone_number||"",mappingCount:0,wood_subtotal:0,accessory_subtotal:0,packaging_fee:v.shipping_fee||0,shipping_company:v.shipping_company||"",total_amount:0,invoices:O,actualFeeTotal:E,currentLogicFee:null,currentLogicBreakdown:null})}if(T.length>0){const v=await Xn(T),F=new Map(g.map(O=>[O.id,O.order_code]));for(const O of v){if(O.product_id==="prod_cut_accessory")continue;const E=F.get(O.order_id);if(!E)continue;const Y=O.customer_width||O.manufacturing_specs?.width||0,R=O.customer_depth||O.manufacturing_specs?.length||0;if(!Y||!R)continue;const H=O.manufacturing_specs?.thickness||O.manufacturing_specs?.options?.thickness||18,B={width:Y,length:R,thickness:H,density:O.manufacturing_specs?.density??null,quantity:O.quantity||1},K=b.get(E)||[];K.push(B),b.set(E,K)}}await it();for(const[v,F]of j){const O=b.get(v);if(O&&O.length>0){const E=ln(O);E&&(F.currentLogicFee=E.fee,F.currentLogicBreakdown=E)}}const $=Array.from(j.values());return $.sort((v,F)=>v.order_date?F.order_date?new Date(F.order_date).getTime()-new Date(v.order_date).getTime():-1:1),$}}),d=C.useMemo(()=>{let m=c;if(e){const u=e.toLowerCase();m=m.filter(g=>g.order_code.toLowerCase().includes(u)||g.customer_name.toLowerCase().includes(u)||g.customer_phone.includes(u))}return a&&(m=m.filter(u=>u.actualFeeTotal>0)),r!=="all"&&(m=m.filter(u=>u.invoices.some(g=>g.carrier===r))),m},[c,e,a,r]),x=C.useMemo(()=>{const m=d.filter(_=>_.actualFeeTotal>0),u=d.filter(_=>_.invoices.length>1).length,g=m.reduce((_,T)=>_+(T.packaging_fee||0),0),N=m.reduce((_,T)=>_+T.actualFeeTotal,0),y=g-N,w=g>0?y/g*100:0,f=m.filter(_=>_.currentLogicFee!=null),p=f.reduce((_,T)=>_+(T.currentLogicFee??0),0),k=f.reduce((_,T)=>_+T.actualFeeTotal,0),j=p-k,b=p>0?j/p*100:0;return{totalOrders:d.length,matchedWithExcel:m.length,unmatchedWithExcel:d.length-m.length,multipleShipments:u,expectedFeeTotal:g,actualFeeTotal:N,feeDifference:y,differencePercent:w,currentLogicFeeTotal:p,currentLogicDifference:j,currentLogicDiffPercent:b,currentLogicMatchedCount:f.length}},[d]);return{orders:c,filteredOrders:d,loading:h,searchTerm:e,setSearchTerm:s,showOnlyMatched:a,setShowOnlyMatched:n,carrierFilter:r,setCarrierFilter:o,dateRange:i,setDateRange:l,stats:x}}function na(e,s,a="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:a}).format(s).split(/\s/g).slice(2).join(" ")}const aa={},be={};function me(e,s){try{const n=(aa[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(s).split("GMT")[1];return n in be?be[n]:vt(n,n.split(":"))}catch{if(e in be)return be[e];const a=e?.match(ra);return a?vt(e,a.slice(1)):NaN}}const ra=/([+-]\d\d):?(\d\d)?/;function vt(e,s){const a=+(s[0]||0),n=+(s[1]||0),r=+(s[2]||0)/60;return be[e]=a*60+n>0?a*60+n+r:a*60-n-r}class ae extends Date{constructor(...s){super(),s.length>1&&typeof s[s.length-1]=="string"&&(this.timeZone=s.pop()),this.internal=new Date,isNaN(me(this.timeZone,this))?this.setTime(NaN):s.length?typeof s[0]=="number"&&(s.length===1||s.length===2&&typeof s[1]!="number")?this.setTime(s[0]):typeof s[0]=="string"?this.setTime(+new Date(s[0])):s[0]instanceof Date?this.setTime(+s[0]):(this.setTime(+new Date(...s)),ss(this),ot(this)):this.setTime(Date.now())}static tz(s,...a){return a.length?new ae(...a,s):new ae(Date.now(),s)}withTimeZone(s){return new ae(+this,s)}getTimezoneOffset(){const s=-me(this.timeZone,this);return s>0?Math.floor(s):Math.ceil(s)}setTime(s){return Date.prototype.setTime.apply(this,arguments),ot(this),+this}[Symbol.for("constructDateFrom")](s){return new ae(+new Date(s),this.timeZone)}}const wt=/^(get|set)(?!UTC)/;
vendor: 4,813 bytes, line 14
14Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!wt.test(e))return;const s=e.replace(wt,"$1UTC");ae.prototype[s]&&(e.startsWith("get")?ae.prototype[e]=function(){return this.internal[s]()}:(ae.prototype[e]=function(){return Date.prototype[s].apply(this.internal,arguments),oa(this),+this},ae.prototype[s]=function(){return Date.prototype[s].apply(this,arguments),ot(this),+this}))});function ot(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-me(e.timeZone,e)*60))}function oa(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),ss(e)}function ss(e){const s=me(e.timeZone,e),a=s>0?Math.floor(s):Math.ceil(s),n=new Date(+e);n.setUTCHours(n.getUTCHours()-1);const r=-new Date(+e).getTimezoneOffset(),o=-new Date(+n).getTimezoneOffset(),i=r-o,l=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&l&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=r-a;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const h=new Date(+e);h.setUTCSeconds(0);const d=r>0?h.getSeconds():(h.getSeconds()-60)%60,x=Math.round(-(me(e.timeZone,e)*60))%60;(x||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+x),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+x+d));const m=me(e.timeZone,e),u=m>0?Math.floor(m):Math.ceil(m),N=-new Date(+e).getTimezoneOffset()-u,y=u!==a,w=N-c;if(y&&w){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+w);const f=me(e.timeZone,e),p=f>0?Math.floor(f):Math.ceil(f),k=u-p;k&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+k),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+k))}}class U extends ae{static tz(s,...a){return a.length?new U(...a,s):new U(Date.now(),s)}toISOString(){const[s,a,n]=this.tzComponents(),r=`${s}${a}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[s,a,n,r]=this.internal.toUTCString().split(" ");return`${s?.slice(0,-1)} ${n} ${a} ${r}`}toTimeString(){const s=this.internal.toUTCString().split(" ")[4],[a,n,r]=this.tzComponents();return`${s} GMT${a}${n}${r} (${na(this.timeZone,this)})`}toLocaleString(s,a){return Date.prototype.toLocaleString.call(this,s,{...a,timeZone:a?.timeZone||this.timeZone})}toLocaleDateString(s,a){return Date.prototype.toLocaleDateString.call(this,s,{...a,timeZone:a?.timeZone||this.timeZone})}toLocaleTimeString(s,a){return Date.prototype.toLocaleTimeString.call(this,s,{...a,timeZone:a?.timeZone||this.timeZone})}tzComponents(){const s=this.getTimezoneOffset(),a=s>0?"-":"+",n=String(Math.floor(Math.abs(s)/60)).padStart(2,"0"),r=String(Math.abs(s)%60).padStart(2,"0");return[a,n,r]}withTimeZone(s){return new U(+this,s)}[Symbol.for("constructDateFrom")](s){return new U(+new Date(s),this.timeZone)}}const Mt=5,ia=4;function la(e,s){const a=s.startOfMonth(e),n=a.getDay()>0?a.getDay():7,r=s.addDays(e,-n+1),o=s.addDays(r,Mt*7-1);return s.getMonth(e)===s.getMonth(o)?Mt:ia}function ns(e,s){const a=s.startOfMonth(e),n=a.getDay();return n===1?a:n===0?s.addDays(a,-6):s.addDays(a,-1*(n-1))}function ca(e,s){const a=ns(e,s),n=la(e,s);return s.addDays(a,n*7-1)}const as={...ge,labels:{labelDayButton:(e,s,a,n)=>{let r;n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,l)=>z(i,l,{locale:ge,...a});let o=r(e,"PPPP");return s.today&&(o=`Today, ${o}`),s.selected&&(o=`${o}, selected`),o},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,s,a)=>{let n;return a&&typeof a.format=="function"?n=a.format.bind(a):n=(r,o)=>z(r,o,{locale:ge,...s}),n(e,"LLLL yyyy")},labelGridcell:(e,s,a,n)=>{let r;n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,l)=>z(i,l,{locale:ge,...a});let o=r(e,"PPPP");return s?.today&&(o=`Today, ${o}`),o},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,s,a)=>{let n;return a&&typeof a.format=="function"?n=a.format.bind(a):n=(r,o)=>z(r,o,{locale:ge,...s}),n(e,"cccc")}}};class X{constructor(s,a){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?U.tz(this.options.timeZone):new this.Date,this.newDate=(n,r,o)=>this.overrides?.newDate?this.overrides.newDate(n,r,o):this.options.timeZone?new U(n,r,o,this.options.timeZone):new Date(n,r,o),this.addDays=(n,r)=>this.overrides?.addDays?this.overrides.addDays(n,r):hn(n,r),this.addMonths=(n,r)=>this.overrides?.addMonths?this.overrides.addMonths(n,r):mn(n,r),this.addWeeks=(n,r)=>
14this.overrides?.addWeeks?this.overrides.addWeeks(n,r):un(n,r),this.addYears=(n,r)=>this.overrides?.addYears?this.overrides.addYears(n,r):xn(n,r),this.differenceInCalendarDays=(n,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(n,r):zt(n,r),this.differenceInCalendarMonths=(n,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(n,r):Kt(n,r),this.eachMonthOfInterval=n=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(n):fn(n),this.eachYearOfInterval=n=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(n):gn(n),o=new Set(r.map(l=>this.getYear(l)));if(o.size===r.length)return r;const i=[];return o.forEach(l=>{i.push(new Date(l,0,1))}),i},this.endOfBroadcastWeek=n=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(n):ca(n,this),this.endOfISOWeek=n=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(n):pn(n),this.endOfMonth=n=>this.overrides?.endOfMonth?this.overrides.endOfMonth(n):yn(n),this.endOfWeek=(n,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(n,r):bn(n,this.options),this.endOfYear=n=>this.overrides?.endOfYear?this.overrides.endOfYear(n):Nn(n),this.format=(n,r,o)=>{const i=this.overrides?.format?this.overrides.format(n,r,this.options):z(n,r,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=n=>this.overrides?.getISOWeek?this.overrides.getISOWeek(n):Zt(n),this.getMonth=(n,r)=>this.overrides?.getMonth?this.overrides.getMonth(n,this.options):jn(n,this.options),this.getYear=(n,r)=>this.overrides?.getYear?this.overrides.getYear(n,this.options):vn(n,this.options),this.getWeek=(n,r)=>this.overrides?.getWeek?this.overrides.getWeek(n,this.options):Vt(n,this.options),this.isAfter=(n,r)=>this.overrides?.isAfter?this.overrides.isAfter(n,r):wn(n,r),this.isBefore=(n,r)=>this.overrides?.isBefore?this.overrides.isBefore(n,r):Mn(n,r),this.isDate=n=>this.overrides?.isDate?this.overrides.isDate(n):kn(n),this.isSameDay=(n,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(n,r):Cn(n,r),this.isSameMonth=(n,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(n,r):Dn(n,r),this.isSameYear=(n,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(n,r):_n(n,r),this.max=n=>this.overrides?.max?this.overrides.max(n):Sn(n),this.min=n=>this.overrides?.min?this.overrides.min(n):On(n),this.setMonth=(n,r)=>this.overrides?.setMonth?this.overrides.setMonth(n,r):Wn(n,r),this.setYear=(n,r)=>this.overrides?.setYear?this.overrides.setYear(n,r):Fn(n,r),this.startOfBroadcastWeek=(n,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(n,this):ns(n,this),this.startOfDay=n=>this.overrides?.startOfDay?this.overrides.startOfDay(n):lt(n),this.startOfISOWeek=n=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(n):Tn(n),this.startOfMonth=n=>this.overrides?.startOfMonth?this.overrides.startOfMonth(n):Ln(n),this.startOfWeek=(n,r)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(n,this.options):In(n,this.options),this.startOfYear=n=>this.overrides?.startOfYear?this.overrides.startOfYear(n):En(n),this.options={locale:as,...s},this.overrides=a}getDigitMap(){const{numerals:s="latn"}=this.options,a=new Intl.NumberFormat("en-US",{numberingSystem:s}),n={};for(let r=0;r<10;r++)n[r.toString()]=a.format(r);return n}replaceDigits(s){const a=this.getDigitMap();return s.replace(/\d/g,n=>a[n]||n)}formatNumber(s){return this.replaceDigits(s.toString())}getMonthYearOrder(){const s=this.options.locale?.code;return s&&X.yearFirstLocales.has(s)?"year-first":"month-first"}formatMonthYear(s){const{locale:a,timeZone:n,numerals:r}=this.options,o=a?.code;if(o&&X.yearFirstLocales.has(o))try{return new Intl.DateTimeFormat(o,{month:"long",year:"numeric",timeZone:n,numberingSystem:r}).format(s)}catch{}const i=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(s,i)}}X.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const oe=new X;class rs{constructor(s,a,n=oe){this.date=s,this.displayMonth=a,this.outside=!!(a&&!n.isSameMonth(s,a)),this.dateLib=n,this.isoDate=n.format(s,"yyyy-MM-dd"),this.displayMonthId=n.format(a,"yyyy-MM"),this.dateMonthId=n.format(s,"yyyy-MM")}isEqualTo(s){return this.dateLib.isSameDay(s.date,this.date)&&this.dateLib.isSameMonth(s.displayMonth,this.displayMonth)}}class da{constructor(s,a){this.date=s,this.weeks=a}}class ha{constructor(s,a){this.days=a,this.weekNumber=s}}function ma(e){return M.createElement("button",{...e})}function ua(e){return M.createElement("span",{...e})}function xa(e){const{size:s=24,orientation:a="left",className:n}=e;return M.createElement("svg",{className:n,width:s,height:s,viewBox:"0 0 24 24"},a==="up"&&M.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),a==="down"&&M.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),a==="left"&&M.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),a==="right"&&M.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function fa(e){const{day:s,modifiers:a,...n}=e;return M.createElement("td",{...n})}function ga(e){const{day:s,modifiers:a,...n}=e,r=M.useRef(null);return M.useEffect(()=>{a.focused&&r.current?.focus()},[a.focused]),M.createElement("button",{ref:r,...n})}var D;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(D||(D={}));var q;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(q||(q={}));var se;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(se||(se={}));var Q;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Q||(Q={}));function pa(e){const{options:s,className:a,components:n,classNames:r,...o}=e,i=[r[D.Dropdown],a].join(" "),l=s?.find(({value:c})=>c===o.value);return M.createElement("span",{"data-disabled":o.disabled,className:r[D.DropdownRoot]},M.createElement(n.Select,{className:i,...o},s?.map(({value:c,label:h,disabled:d})=>M.createElement(n.Option,{key:c,value:c,disabled:d},h))),M.createElement("span",{className:r[D.CaptionLabel],"aria-hidden":!0},l?.label,M.createElement(n.Chevron,{orientation:"down",size:18,className:r[D.Chevron]}
vendor: 4,287 bytes, line 14
14)))}function ya(e){return M.createElement("div",{...e})}function ba(e){return M.createElement("div",{...e})}function Na(e){const{calendarMonth:s,displayIndex:a,...n}=e;return M.createElement("div",{...n},e.children)}function ja(e){const{calendarMonth:s,displayIndex:a,...n}=e;return M.createElement("div",{...n})}function va(e){return M.createElement("table",{...e})}function wa(e){return M.createElement("div",{...e})}const os=C.createContext(void 0);function De(){const e=C.useContext(os);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function Ma(e){const{components:s}=De();return M.createElement(s.Dropdown,{...e})}function ka(e){const{onPreviousClick:s,onNextClick:a,previousMonth:n,nextMonth:r,...o}=e,{components:i,classNames:l,labels:{labelPrevious:c,labelNext:h}}=De(),d=C.useCallback(m=>{r&&a?.(m)},[r,a]),x=C.useCallback(m=>{n&&s?.(m)},[n,s]);return M.createElement("nav",{...o},M.createElement(i.PreviousMonthButton,{type:"button",className:l[D.PreviousMonthButton],tabIndex:n?void 0:-1,"aria-disabled":n?void 0:!0,"aria-label":c(n),onClick:x},M.createElement(i.Chevron,{disabled:n?void 0:!0,className:l[D.Chevron],orientation:"left"})),M.createElement(i.NextMonthButton,{type:"button",className:l[D.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":h(r),onClick:d},M.createElement(i.Chevron,{disabled:r?void 0:!0,orientation:"right",className:l[D.Chevron]})))}function Ca(e){const{components:s}=De();return M.createElement(s.Button,{...e})}function Da(e){return M.createElement("option",{...e})}function _a(e){const{components:s}=De();return M.createElement(s.Button,{...e})}function Sa(e){const{rootRef:s,...a}=e;return M.createElement("div",{...a,ref:s})}function Oa(e){return M.createElement("select",{...e})}function Wa(e){const{week:s,...a}=e;return M.createElement("tr",{...a})}function Fa(e){return M.createElement("th",{...e})}function Ta(e){return M.createElement("thead",{"aria-hidden":!0},M.createElement("tr",{...e}))}function La(e){const{week:s,...a}=e;return M.createElement("th",{...a})}function Ia(e){return M.createElement("th",{...e})}function Ea(e){return M.createElement("tbody",{...e})}function Aa(e){const{components:s}=De();return M.createElement(s.Dropdown,{...e})}const Pa=Object.freeze(Object.defineProperty({__proto__:null,Button:ma,CaptionLabel:ua,Chevron:xa,Day:fa,DayButton:ga,Dropdown:pa,DropdownNav:ya,Footer:ba,Month:Na,MonthCaption:ja,MonthGrid:va,Months:wa,MonthsDropdown:Ma,Nav:ka,NextMonthButton:Ca,Option:Da,PreviousMonthButton:_a,Root:Sa,Select:Oa,Week:Wa,WeekNumber:La,WeekNumberHeader:Ia,Weekday:Fa,Weekdays:Ta,Weeks:Ea,YearsDropdown:Aa},Symbol.toStringTag,{value:"Module"}));function le(e,s,a=!1,n=oe){let{from:r,to:o}=e;const{differenceInCalendarDays:i,isSameDay:l}=n;return r&&o?(i(o,r)<0&&([r,o]=[o,r]),i(s,r)>=(a?1:0)&&i(o,s)>=(a?1:0)):!a&&o?l(o,s):!a&&r?l(r,s):!1}function ct(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function $e(e){return!!(e&&typeof e=="object"&&"from"in e)}function dt(e){return!!(e&&typeof e=="object"&&"after"in e)}function ht(e){return!!(e&&typeof e=="object"&&"before"in e)}function is(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function ls(e,s){return Array.isArray(e)&&e.every(s.isDate)}function ce(e,s,a=oe){const n=Array.isArray(s)?s:[s],{isSameDay:r,differenceInCalendarDays:o,isAfter:i}=a;return n.some(l=>{if(typeof l=="boolean")return l;if(a.isDate(l))return r(e,l);if(ls(l,a))return l.some(c=>r(e,c));if($e(l))return le(l,e,!1,a);if(is(l))return Array.isArray(l.dayOfWeek)?l.dayOfWeek.includes(e.getDay()):l.dayOfWeek===e.getDay();if(ct(l)){const c=o(l.before,e),h=o(l.after,e),d=c>0,x=h<0;return i(l.before,l.after)?x&&d:d||x}return dt(l)?o(e,l.after)>0:ht(l)?o(l.before,e)>0:typeof l=="function"?l(e):!1})}function Ba(e,s,a,n,r){const{disabled:o,hidden:i,modifiers:l,showOutsideDays:c,broadcastCalendar:h,today:d=r.today()}=s,{isSameDay:x,isSameMonth:m,startOfMonth:u,isBefore:g,endOfMonth:N,isAfter:y}=r,w=a&&u(a),f=n&&N(n),p={[q.focused]:[],[q.outside]:[],[q.disabled]:[],[q.hidden]:[],[q.today]:[]},k={};for(const j of e){const{date:b,displayMonth:_}=j,T=!!(_&&!m(b,_)),$=!!(w&&g(b,w)),v=!!(f&&y(b,f)),F=!!(o&&ce(b,o,r)),O=!!(i&&ce(b,i,r))||$||v||!h&&!c&&T||h&&c===!1&&T,E=x(b,d);
14T&&p.outside.push(j),F&&p.disabled.push(j),O&&p.hidden.push(j),E&&p.today.push(j),l&&Object.keys(l).forEach(Y=>{const R=l?.[Y];R&&ce(b,R,r)&&(k[Y]?k[Y].push(j):k[Y]=[j])})}return j=>{const b={[q.focused]:!1,[q.disabled]:!1,[q.hidden]:!1,[q.outside]:!1,[q.today]:!1},_={};for(const T in p){const $=p[T];b[T]=$.some(v=>v===j)}for(const T in k)_[T]=k[T].some($=>$===j);return{...b,..._}}}function $a(e,s,a={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[o])=>(a[o]?r.push(a[o]):s[q[o]]?r.push(s[q[o]]):s[se[o]]&&r.push(s[se[o]]),r),[s[D.Day]])}function Ya(e){return{...Pa,...e}}function qa(e){const s={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([a,n])=>{a.startsWith("data-")&&(s[a]=n)}),s}function Ra(){const e={};for(const s in D)e[D[s]]=`rdp-${D[s]}`;for(const s in q)e[q[s]]=`rdp-${q[s]}`;for(const s in se)e[se[s]]=`rdp-${se[s]}`;for(const s in Q)e[Q[s]]=`rdp-${Q[s]}`;return e}function cs(e,s,a){return(a??new X(s)).formatMonthYear(e)}const Ga=cs;function Ha(e,s,a){return(a??new X(s)).format(e,"d")}function Ua(e,s=oe){return s.format(e,"LLLL")}function za(e,s,a){return(a??new X(s)).format(e,"cccccc")}function Ka(e,s=oe){return e<10?s.formatNumber(`0${e.toLocaleString()}`):s.formatNumber(`${e.toLocaleString()}`)}function Za(){return""}function ds(e,s=oe){return s.format(e,"yyyy")}const Va=ds,Ja=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:cs,formatDay:Ha,formatMonthCaption:Ga,formatMonthDropdown:Ua,formatWeekNumber:Ka,formatWeekNumberHeader:Za,formatWeekdayName:za,formatYearCaption:Va,formatYearDropdown:ds},Symbol.toStringTag,{value:"Module"}));function Qa(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...Ja,...e}}function mt(e,s,a,n){let r=(n??new X(a)).format(e,"PPPP");return s.today&&(r=`Today, ${r}`),s.selected&&(r=`${r}, selected`),r}const Xa=mt;function ut(e,s,a){return(a??new X(s)).formatMonthYear(e)}const er=ut;function hs(e,s,a,n){let r=(n??new X(a)).format(e,"PPPP");return s?.today&&(r=`Today, ${r}`),r}function ms(e){return"Choose the Month"}function us(){return""}const tr="Go to the Next Month";function xs(e,s){return tr}function fs(e){return"Go to the Previous Month"}function gs(e,s,a){return(a??new X(s)).format(e,"cccc")}function ps(e,s){return`Week ${e}`}function ys(e){return"Week Number"}function bs(e){return"Choose the Year"}const sr=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:er,labelDay:Xa,labelDayButton:mt,labelGrid:ut,labelGridcell:hs,labelMonthDropdown:ms,labelNav:us,labelNext:xs,labelPrevious:fs,labelWeekNumber:ps,labelWeekNumberHeader:ys,labelWeekday:gs,labelYearDropdown:bs},Symbol.toStringTag,{value:"Module"})),te=(e,s,a)=>s||(a?typeof a=="function"?a:(...n)=>a:e);function nr(e,s){const a=s.locale?.labels??{};return{...sr,...e??{},labelDayButton:te(mt,e?.labelDayButton,a.labelDayButton),labelMonthDropdown:te(ms,e?.labelMonthDropdown,a.labelMonthDropdown),labelNext:te(xs,e?.labelNext,a.labelNext),labelPrevious:te(fs,e?.labelPrevious,a.labelPrevious),labelWeekNumber:te(ps,e?.labelWeekNumber,a.labelWeekNumber),labelYearDropdown:te(bs,e?.labelYearDropdown,a.labelYearDropdown),labelGrid:te(ut,e?.labelGrid,a.labelGrid),labelGridcell:te(hs,e?.labelGridcell,a.labelGridcell),labelNav:te(us,e?.labelNav,a.labelNav),labelWeekNumberHeader:te(ys,e?.labelWeekNumberHeader,a.labelWeekNumberHeader),labelWeekday:te(gs,e?.labelWeekday,a.labelWeekday)}}function ar(e,s,a,n,r){const{startOfMonth:o,startOfYear:i,endOfYear:l,eachMonthOfInterval:c,getMonth:h}=r;return c({start:i(e),end:l(e)}).map(m=>{const u=n.formatMonthDropdown(m,r),g=h(m),N=s&&m<o(s)||a&&m>o(a)||!1;return{value:g,label:u,disabled:N}})}function rr(e,s={},a={}){let n={...s?.[D.Day]};return Object.entries(e).filter(([,r])=>
vendor: 9,224 bytes, line 14
14r===!0).forEach(([r])=>{n={...n,...a?.[r]}}),n}function or(e,s,a,n){const r=n??e.today(),o=a?e.startOfBroadcastWeek(r,e):s?e.startOfISOWeek(r):e.startOfWeek(r),i=[];for(let l=0;l<7;l++){const c=e.addDays(o,l);i.push(c)}return i}function ir(e,s,a,n,r=!1){if(!e||!s)return;const{startOfYear:o,endOfYear:i,eachYearOfInterval:l,getYear:c}=n,h=o(e),d=i(s),x=l({start:h,end:d});return r&&x.reverse(),x.map(m=>{const u=a.formatYearDropdown(m,n);return{value:c(m),label:u,disabled:!1}})}function lr(e,s={}){const{weekStartsOn:a,locale:n}=s,r=a??n?.options?.weekStartsOn??0,o=l=>{const c=typeof l=="number"||typeof l=="string"?new Date(l):l;return new U(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,e)},i=l=>{const c=o(l);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>o(U.tz(e)),newDate:(l,c,h)=>new U(l,c,h,12,0,0,e),startOfDay:l=>o(l),startOfWeek:(l,c)=>{const h=o(l),d=c?.weekStartsOn??r,x=(h.getDay()-d+7)%7;return h.setDate(h.getDate()-x),h},startOfISOWeek:l=>{const c=o(l),h=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-h),c},startOfMonth:l=>{const c=o(l);return c.setDate(1),c},startOfYear:l=>{const c=o(l);return c.setMonth(0,1),c},endOfWeek:(l,c)=>{const h=o(l),m=(((c?.weekStartsOn??r)+6)%7-h.getDay()+7)%7;return h.setDate(h.getDate()+m),h},endOfISOWeek:l=>{const c=o(l),h=(7-c.getDay())%7;return c.setDate(c.getDate()+h),c},endOfMonth:l=>{const c=o(l);return c.setMonth(c.getMonth()+1,0),c},endOfYear:l=>{const c=o(l);return c.setMonth(11,31),c},eachMonthOfInterval:l=>{const c=o(l.start),h=o(l.end),d=[],x=new U(c.getFullYear(),c.getMonth(),1,12,0,0,e),m=h.getFullYear()*12+h.getMonth();for(;x.getFullYear()*12+x.getMonth()<=m;)d.push(new U(x,e)),x.setMonth(x.getMonth()+1,1);return d},addDays:(l,c)=>{const h=o(l);return h.setDate(h.getDate()+c),h},addWeeks:(l,c)=>{const h=o(l);return h.setDate(h.getDate()+c*7),h},addMonths:(l,c)=>{const h=o(l);return h.setMonth(h.getMonth()+c),h},addYears:(l,c)=>{const h=o(l);return h.setFullYear(h.getFullYear()+c),h},eachYearOfInterval:l=>{const c=o(l.start),h=o(l.end),d=[],x=new U(c.getFullYear(),0,1,12,0,0,e);for(;x.getFullYear()<=h.getFullYear();)d.push(new U(x,e)),x.setFullYear(x.getFullYear()+1,0,1);return d},getWeek:(l,c)=>{const h=i(l);return Vt(h,{weekStartsOn:c?.weekStartsOn??r,firstWeekContainsDate:c?.firstWeekContainsDate??n?.options?.firstWeekContainsDate??1})},getISOWeek:l=>{const c=i(l);return Zt(c)},differenceInCalendarDays:(l,c)=>{const h=i(l),d=i(c);return zt(h,d)},differenceInCalendarMonths:(l,c)=>{const h=i(l),d=i(c);return Kt(h,d)}}}const _e=e=>e instanceof HTMLElement?e:null,Qe=e=>[...e.querySelectorAll("[data-animated-month]")??[]],cr=e=>_e(e.querySelector("[data-animated-month]")),Xe=e=>_e(e.querySelector("[data-animated-caption]")),et=e=>_e(e.querySelector("[data-animated-weeks]")),dr=e=>_e(e.querySelector("[data-animated-nav]")),hr=e=>_e(e.querySelector("[data-animated-weekdays]"));function mr(e,s,{classNames:a,months:n,focused:r,dateLib:o}){const i=C.useRef(null),l=C.useRef(n),c=C.useRef(!1);C.useLayoutEffect(()=>{const h=l.current;if(l.current=n,!s||!e.current||!(e.current instanceof HTMLElement)||n.length===0||h.length===0||n.length!==h.length)return;const d=o.isSameMonth(n[0].date,h[0].date),x=o.isAfter(n[0].date,h[0].date),m=x?a[Q.caption_after_enter]:a[Q.caption_before_enter],u=x?a[Q.weeks_after_enter]:a[Q.weeks_before_enter],g=i.current,N=e.current.cloneNode(!0);if(N instanceof HTMLElement?(Qe(N).forEach(p=>{if(!(p instanceof HTMLElement))return;const k=cr(p);k&&p.contains(k)&&p.removeChild(k);const j=Xe(p);j&&j.classList.remove(m);const b=et(p);b&&b.classList.remove(u)}),i.current=N):i.current=null,c.current||d||r)return;const y=g instanceof HTMLElement?Qe(g):[],w=Qe(e.current);if(w?.every(f=>f instanceof HTMLElement)&&y&&y.every(f=>f instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const f=dr(e.current);f&&(f.style.zIndex="1"),w.forEach((p,k)=>{const j=y[k];if(!j)return;p.style.position="relative",p.style.overflow="hidden";const b=Xe(p);b&&b.classList.add(m);const _=et(p);_&&_.classList.add(u);const T=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),f&&(f.style.zIndex=""),b&&b.classList.remove(m),_&&_.classList.remove(u),p.style.position="",p.style.overflow="",p.contains(j)&&p.removeChild(j)};j.style.pointerEvents="none",j.style.position="absolute",j.style.overflow="hidden",j.setAttribute("aria-hidden","true");const $=hr(j);$&&($.style.opacity="0");const v=Xe(j);v&&(v.classList.add(x?a[Q.caption_before_exit]:a[Q.caption_after_exit]),v.addEventListener("animationend",T));const F=et(j);F&&F.classList.add(x?a[Q.weeks_before_exit]:a[Q.weeks_after_exit]),p.insertBefore(j,p.firstChild)})}})}function ur(e,s,a,n){const r=e[0],o=e[e.length-1],{ISOWeek:i,fixedWeeks:l,broadcastCalendar:c}=a??{},{addDays:h,differenceInCalendarDays:d,differenceInCalendarMonths:x,endOfBroadcastWeek:m,endOfISOWeek:u,endOfMonth:g,endOfWeek:N,isAfter:y,startOfBroadcastWeek:w,startOfISOWeek:f,startOfWeek:p}=n,k=c?w(r,n):i?f(r):p(r),j=c?m(o):i?u(g(o)):N(g(o)),b=s&&(c?m(s):i?u(s):N(s)),_=b&&y(j,b)?b:j,T=d(_,k),$=x(o,r)+1,v=[];for(let E=0;E<=T;E++){const Y=h(k,E);v.push(Y)}const O=(c?35:42)*$;if(l&&v.length<O){const E=O-v.length;for(let Y=0;Y<E;Y++){const R=h(v[v.length-1],1);v.push(R)}}return v}function xr(e){const s=[];return e.reduce((a,n)=>{const r=n.weeks.reduce((o,i)=>o.concat(i.days.slice()),s.slice());return a.concat(r.slice())},s.slice())}function fr(e,s,a,n){const{numberOfMonths:r=1}=a,o=[];for(let i=0;i<r;i++){const l=n.addMonths(e,i);if(s&&l>s)break;o.push(l)}return o}function kt(e,s,a,n){const{month:r,defaultMonth:o,today:i=n.today(),numberOfMonths:l=1}=e;let c=r||o||i;const{differenceInCalendarMonths:h,addMonths:d,startOfMonth:x}=n;if(a&&h(a,c)<l-1){const m=-1*(l-1);c=d(a,m)}return s&&h(c,s)<0&&(c=s),x(c)}function gr(e,s,a,n){const{addDays:r,endOfBroadcastWeek:o,endOfISOWeek:i,endOfMonth:l,endOfWeek:c,getISOWeek:h,getWeek:d,startOfBroadcastWeek:x,startOfISOWeek:m,startOfWeek:u}=n,g=e.reduce((N,y)=>{const w=a.broadcastCalendar?x(y,n):a.ISOWeek?m(y):u(y),f=a.broadcastCalendar?o(y):a.ISOWeek?i(l(y)):c(l(y)),p=s.filter(_=>_>=w&&_<=f),k=a.broadcastCalendar?35:42;if(a.fixedWeeks&&p.length<k){const _=s.filter(T=>{const $=k-p.length;return T>f&&T<=r(f,$)});p.push(..._)}const j=p.reduce((_,T)=>{const $=a.ISOWeek?h(T):d(T),v=_.find(O=>O.weekNumber===$),F=new rs(T,y,n);return v?v.days.push(F):_.push(new ha($,[F])),_},[]),b=new da(y,j);return N.push(b),N},[]);return a.reverseMonths?g.reverse():g}function pr(e,s){let{startMonth:a,endMonth:n}=e;const{startOfYear:r,startOfDay:o,startOfMonth:i,endOfMonth:l,addYears:c,endOfYear:h,newDate:d,today:x}=s,{fromYear:m,toYear:u,fromMonth:g,toMonth:N}=e;!a&&g&&(a=g),!a&&m&&(a=s.newDate(m,0,1)),!n&&N&&(n=N),!n&&u&&(n=d(u,11,31));const y=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return a?a=i(a):m?a=d(m,0,1):!a&&y&&(a=r(c(e.today??x(),-100))),n?n=l(n):u?n=d(u,11,31):!n&&y&&(n=h(e.today??x())),[a&&o(a),n&&o(n)]}function yr(e,s,a,n){if(a.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:o=1}=a,{startOfMonth:i,addMonths:l,differenceInCalendarMonths:c}=n,h=r?o:1,d=i(e);if(!s)return l(d,h);if(!(c(s,e)<o))return l(d,h)}function br(e,s,a,n){if(a.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:o}=a,{startOfMonth:i,addMonths:l,differenceInCalendarMonths:c}=n,h=r?o??1:1,d=i(e);if(!s)return l(d,-h);if(!(c(d,s)<=0))return l(d,-h)}function Nr(e){const s=[];return e.reduce((a,n)=>a.concat(n.weeks.slice()),s.slice())}function Ye(e,s){const[a,n]=C.useState(e);return[s===void 0?a:s,n]}function jr(e,s){const[a,n]=pr(e,s),{startOfMonth:r,endOfMonth:o}=s,i=kt(e,a,n,s),[l,c]=Ye(i,e.month?i:void 0);C.useEffect(()=>{const k=kt(e,a,n,s);c(k)},[e.timeZone]);const{months:h,weeks:d,days:x,previousMonth:m,nextMonth:u}=C.useMemo(()=>{const k=fr(l,n,{numberOfMonths:e.numberOfMonths},s),j=ur(k,e.endMonth?o(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},s),b=gr(k,j,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},s),_=Nr(b),T=xr(b),$=br(l,a,e,s),v=yr(l,n,e,s);return{months:b,weeks:_,days:T,previousMonth:$,nextMonth:v}},[s,l.getTime(),n?.getTime(),a?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:g,onMonthChange:N}=e,y=k=>d.some(j=>j.days.some(b=>b.isEqualTo(k))),w=k=>{if(g)return;let j=r(k);a&&j<r(a)&&(j=r(a)),n&&j>r(n)&&(j=r(n)),c(j),N?.(j)};return{months:h,weeks:d,days:x,navStart:a,navEnd:n,previousMonth:m,nextMonth:u,goToMonth:w,goToDay:k=>{y(k)||w(k.date)}}}var ne;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(ne||(ne={}));function Ct(e){return!e[q.disabled]&&!e[q.hidden]&&!e[q.outside]}function vr(e,s,a,n){let r,o=-1;for(const i of e){const l=s(i);Ct(l)&&(l[q.focused]&&o<ne.FocusedModifier?(r=i,o=ne.FocusedModifier):n?.isEqualTo(i)&&o<ne.LastFocused?(r=i,o=ne.LastFocused):a(i.date)&&o<ne.Selected?(r=i,o=ne.Selected):l[q.today]&&o<ne.Today&&(r=i,o=ne.Today))}return r||(r=e.find(i=>
14Ct(s(i)))),r}function wr(e,s,a,n,r,o,i){const{ISOWeek:l,broadcastCalendar:c}=o,{addDays:h,addMonths:d,addWeeks:x,addYears:m,endOfBroadcastWeek:u,endOfISOWeek:g,endOfWeek:N,max:y,min:w,startOfBroadcastWeek:f,startOfISOWeek:p,startOfWeek:k}=i;let b={day:h,week:x,month:d,year:m,startOfWeek:_=>c?f(_,i):l?p(_):k(_),endOfWeek:_=>c?u(_):l?g(_):N(_)}[e](a,s==="after"?1:-1);return s==="before"&&n?b=y([n,b]):s==="after"&&r&&(b=w([r,b])),b}function Ns(e,s,a,n,r,o,i,l=0){if(l>365)return;const c=wr(e,s,a.date,n,r,o,i),h=!!(o.disabled&&ce(c,o.disabled,i)),d=!!(o.hidden&&ce(c,o.hidden,i)),x=c,m=new rs(c,x,i);return!h&&!d?m:Ns(e,s,m,n,r,o,i,l+1)}function Mr(e,s,a,n,r){const{autoFocus:o}=e,[i,l]=C.useState(),c=vr(s.days,a,n||(()=>!1),i),[h,d]=C.useState(o?c:void 0);return{isFocusTarget:N=>!!c?.isEqualTo(N),setFocused:d,focused:h,blur:()=>{l(h),d(void 0)},moveFocus:(N,y)=>{if(!h)return;const w=Ns(N,y,h,s.navStart,s.navEnd,e,r);w&&(e.disableNavigation&&!s.days.some(p=>p.isEqualTo(w))||(s.goToDay(w),d(w)))}}}function kr(e,s){const{selected:a,required:n,onSelect:r}=e,[o,i]=Ye(a,r?a:void 0),l=r?a:o,{isSameDay:c}=s,h=u=>l?.some(g=>c(g,u))??!1,{min:d,max:x}=e;return{selected:l,select:(u,g,N)=>{let y=[...l??[]];if(h(u)){if(l?.length===d||n&&l?.length===1)return;y=l?.filter(w=>!c(w,u))}else l?.length===x?y=[u]:y=[...y,u];return r||i(y),r?.(y,u,g,N),y},isSelected:h}}function Cr(e,s,a=0,n=0,r=!1,o=oe){const{from:i,to:l}=s||{},{isSameDay:c,isAfter:h,isBefore:d}=o;let x;if(!i&&!l)x={from:e,to:a>0?void 0:e};else if(i&&!l)c(i,e)?a===0?x={from:i,to:e}:r?x={from:i,to:void 0}:x=void 0:d(e,i)?x={from:e,to:i}:x={from:i,to:e};else if(i&&l)if(c(i,e)&&c(l,e))r?x={from:i,to:l}:x=void 0;else if(c(i,e))x={from:i,to:a>0?void 0:e};else if(c(l,e))x={from:e,to:a>0?void 0:e};else if(d(e,i))x={from:e,to:l};else if(h(e,i))x={from:i,to:e};else if(h(e,l))x={from:i,to:e};else throw new Error("Invalid range");if(x?.from&&x?.to){const m=o.differenceInCalendarDays(x.to,x.from);n>0&&m>n?x={from:e,to:void 0}:a>1&&m<a&&(x={from:e,to:void 0})}return x}function Dr(e,s,a=oe){const n=Array.isArray(s)?s:[s];let r=e.from;const o=a.differenceInCalendarDays(e.to,e.from),i=Math.min(o,6);for(let l=0;l<=i;l++){if(n.includes(r.getDay()))return!0;r=a.addDays(r,1)}return!1}function Dt(e,s,a=oe){return le(e,s.from,!1,a)||le(e,s.to,!1,a)||le(s,e.from,!1,a)||le(s,e.to,!1,a)}function _r(e,s,a=oe){const n=Array.isArray(s)?s:[s];if(n.filter(l=>typeof l!="function").some(l=>typeof l=="boolean"?l:a.isDate(l)?le(e,l,!1,a):ls(l,a)?l.some(c=>le(e,c,!1,a)):$e(l)?l.from&&l.to?Dt(e,{from:l.from,to:l.to},a):!1:is(l)?Dr(e,l.dayOfWeek,a):ct(l)?a.isAfter(l.before,l.after)?Dt(e,{from:a.addDays(l.after,1),to:a.addDays(l.before,-1)},a):ce(e.from,l,a)||ce(e.to,l,a):dt(l)||ht(l)?ce(e.from,l,a)||ce(e.to,l,a):!1))return!0;const i=n.filter(l=>typeof l=="function");if(i.length){let l=e.from;const c=a.differenceInCalendarDays(e.to,e.from);for(let h=0;h<=c;h++){if(i.some(d=>d(l)))return!0;l=a.addDays(l,1)}}return!1}function Sr(e,s){const{disabled:a,excludeDisabled:n,resetOnSelect:r,selected:o,required:i,onSelect:l}=e,[c,h]=Ye(o,l?o:void 0),d=l?o:c;return{selected:d,select:(u,g,N)=>{const{min:y,max:w}=e;let f;if(u){const p=d?.from,k=d?.to,j=!!p&&!!k,b=!!p&&!!k&&s.isSameDay(p,k)&&s.isSameDay(u,p);r&&(j||!d?.from)?!i&&b?f=void 0:f={from:u,to:void 0}:f=Cr(u,d,y,w,i,s)}return n&&a&&f?.from&&f.to&&_r({from:f.from,to:f.to},a,s)&&(f.from=u,f.to=void 0),l||h(f),l?.(f,u,g,N),f},isSelected:u=>d&&le(d,u,!1,s)}}function Or(e,s){const{selected:a,required:n,onSelect:r}=e,[o,i]=Ye(a,r?a:void 0),l=r?a:o,{isSameDay:c}=s;return{selected:l,select:(x,m,u)=>{let g=x;return!n&&l&&l&&c(x,l)&&(g=void 0),r||i(g),r?.(g,x,m,u),g},isSelected:x=>l?c(l,x):!1}}function Wr(e,s){const a=Or(e,s),n=kr(e,s),r=Sr(e,s);switch(e.mode){case"single":return a;case"multiple":return n;case"range":return r;default:return}}function ee(e,s){return e instanceof U&&e.timeZone===s?e:new U(e,s)}function ue(e,s,a){return ee(e,s)}function _t(e,s,a){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?ue(e,s):Array.isArray(e)?e.map(n=>n instanceof Date?ue(n,s):n):$e(e)?{...e,from:e.from?ee(e.from,s):e.from,to:e.to?ee(e.to,s):e.to}:ct(e)?{before:ue(e.before,s),after:ue(e.after,s)}:dt(e)?{after:ue(e.after,s)}:ht(e)?{before:ue(e.before,s)}:e}function tt(e,s,a){return e&&(Array.isArray(e)?e.map(n=>_t(n,s)):_t(e,s))}function Fr(e){let s=e;const a=s.timeZone;if(a&&(s={...e,timeZone:a},s.today&&(s.today=ee(s.today,a)),s.month&&(s.month=ee(s.month,a)),s.defaultMonth&&(s.defaultMonth=ee(s.defaultMonth,a)),s.startMonth&&(s.startMonth=ee(s.startMonth,a)),s.endMonth&&(s.endMonth=ee(s.endMonth,a)),s.mode==="single"&&s.selected?s.selected=ee(s.selected,a):s.mode==="multiple"&&s.selected?s.selected=s.selected?.map(W=>ee(W,a)):s.mode==="range"&&s.selected&&(s.selected={from:s.selected.from?ee(s.selected.from,a):s.selected.from,to:s.selected.to?ee(s.selected.to,a):s.selected.to}),s.disabled!==void 0&&(s.disabled=tt(s.disabled,a)),s.hidden!==void 0&&(s.hidden=tt(s.hidden,a)),s.modifiers)){const W={};
14Object.keys(s.modifiers).forEach(P=>{W[P]=tt(s.modifiers?.[P],a)}),s.modifiers=W}const{components:n,formatters:r,labels:o,dateLib:i,locale:l,classNames:c}=C.useMemo(()=>{const W={...as,...s.locale},P=s.broadcastCalendar?1:s.weekStartsOn,S=s.noonSafe&&s.timeZone?lr(s.timeZone,{weekStartsOn:P,locale:W}):void 0,A=s.dateLib&&S?{...S,...s.dateLib}:s.dateLib??S,J=new X({locale:W,weekStartsOn:P,firstWeekContainsDate:s.firstWeekContainsDate,useAdditionalWeekYearTokens:s.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:s.useAdditionalDayOfYearTokens,timeZone:s.timeZone,numerals:s.numerals},A);return{dateLib:J,components:Ya(s.components),formatters:Qa(s.formatters),labels:nr(s.labels,J.options),locale:W,classNames:{...Ra(),...s.classNames}}},[s.locale,s.broadcastCalendar,s.weekStartsOn,s.firstWeekContainsDate,s.useAdditionalWeekYearTokens,s.useAdditionalDayOfYearTokens,s.timeZone,s.numerals,s.dateLib,s.noonSafe,s.components,s.formatters,s.labels,s.classNames]);s.today||(s={...s,today:i.today()});const{captionLayout:h,mode:d,navLayout:x,numberOfMonths:m=1,onDayBlur:u,onDayClick:g,onDayFocus:N,onDayKeyDown:y,onDayMouseEnter:w,onDayMouseLeave:f,onNextClick:p,onPrevClick:k,showWeekNumber:j,styles:b}=s,{formatCaption:_,formatDay:T,formatMonthDropdown:$,formatWeekNumber:v,formatWeekNumberHeader:F,formatWeekdayName:O,formatYearDropdown:E}=r,Y=jr(s,i),{days:R,months:H,navStart:B,navEnd:K,previousMonth:Z,nextMonth:G,goToMonth:ie}=Y,qe=Ba(R,s,B,K,i),{isSelected:Re,select:Ge,selected:Se}=Wr(s,i)??{},{blur:ft,focused:gt,isFocusTarget:Cs,moveFocus:pt,setFocused:Oe}=Mr(s,Y,qe,Re??(()=>!1),i),{labelDayButton:Ds,labelGridcell:_s,labelGrid:Ss,labelMonthDropdown:Os,labelNav:yt,labelPrevious:Ws,labelNext:Fs,labelWeekday:Ts,labelWeekNumber:Ls,labelWeekNumberHeader:Is,labelYearDropdown:Es}=o,As=C.useMemo(()=>or(i,s.ISOWeek,s.broadcastCalendar,s.today),[i,s.ISOWeek,s.broadcastCalendar,s.today]),bt=d!==void 0||g!==void 0,He=C.useCallback(()=>{Z&&(ie(Z),k?.(Z))},[Z,ie,k]),Ue=C.useCallback(()=>{G&&(ie(G),p?.(G))},[ie,G,p]),Ps=C.useCallback((W,P)=>S=>{S.preventDefault(),S.stopPropagation(),Oe(W),!P.disabled&&(Ge?.(W.date,P,S),g?.(W.date,P,S))},[Ge,g,Oe]),Bs=C.useCallback((W,P)=>S=>{Oe(W),N?.(W.date,P,S)},[N,Oe]),$s=C.useCallback((W,P)=>S=>{ft(),u?.(W.date,P,S)},[ft,u]),Ys=C.useCallback((W,P)=>S=>{const A={ArrowLeft:[S.shiftKey?"month":"day",s.dir==="rtl"?"after":"before"],ArrowRight:[S.shiftKey?"month":"day",s.dir==="rtl"?"before":"after"],ArrowDown:[S.shiftKey?"year":"week","after"],ArrowUp:[S.shiftKey?"year":"week","before"],PageUp:[S.shiftKey?"year":"month","before"],PageDown:[S.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(A[S.key]){S.preventDefault(),S.stopPropagation();const[J,I]=A[S.key];pt(J,I)}y?.(W.date,P,S)},[pt,y,s.dir]),qs=C.useCallback((W,P)=>S=>{w?.(W.date,P,S)},[w]),Rs=C.useCallback((W,P)=>S=>{f?.(W.date,P,S)},[f]),Gs=C.useCallback(W=>P=>{const S=Number(P.target.value),A=i.setMonth(i.startOfMonth(W),S);ie(A)},[i,ie]),Hs=C.useCallback(W=>P=>{const S=Number(P.target.value),A=i.setYear(i.startOfMonth(W),S);ie(A)},[i,ie]),{className:Us,style:zs}=C.useMemo(()=>({className:[c[D.Root],s.className].filter(Boolean).join(" "),style:{...b?.[D.Root],...s.style}}),[c,s.className,s.style,b]),Ks=qa(s),Nt=C.useRef(null);mr(Nt,!!s.animate,{classNames:c,months:H,focused:gt,dateLib:i});const Zs={dayPickerProps:s,selected:Se,select:Ge,isSelected:Re,months:H,nextMonth:G,previousMonth:Z,goToMonth:ie,getModifiers:qe,components:n,classNames:c,styles:b,labels:o,formatters:r};return M.createElement(os.Provider,{value:Zs},M.createElement(n.Root,{rootRef:s.animate?Nt:void 0,className:Us,style:zs,dir:s.dir,id:s.id,lang:s.lang??l.code,nonce:s.nonce,title:s.title,role:s.role,"aria-label":s["aria-label"],"aria-labelledby":s["aria-labelledby"],...Ks},M.createElement(n.Months,{className:c[D.Months],style:b?.[D.Months]},!s.hideNavigation&&!x&&M.createElement(n.Nav,{"data-animated-nav":s.animate?"true":void 0,className:c[D.Nav],style:b?.[D.Nav],"aria-label":yt(),onPreviousClick:He,onNextClick:Ue,previousMonth:Z,nextMonth:G}),H.map((W,P)=>M.createElement(n.Month,{"data-animated-month":s.animate?"true":void 0,className:c[D.Month],style:b?.[D.Month],key:P,displayIndex:P,calendarMonth:W},x==="around"&&!s.hideNavigation&&P===0&&M.createElement(n.PreviousMonthButton,{type:"button",className:c[D.PreviousMonthButton],tabIndex:Z?void 0:-1,"aria-disabled":Z?void 0:!0,"aria-label":Ws(Z),onClick:He,"data-animated-button":s.animate?"true":void 0},M.createElement(n.Chevron,{disabled:Z?void 0:!0,className:c[D.Chevron],orientation:s.dir==="rtl"?"right":"left"})),M.createElement(n.MonthCaption,{"data-animated-caption":s.animate?"true":void 0,className:c[D.MonthCaption],style:b?.[D.MonthCaption],calendarMonth:W,displayIndex:P},h?.startsWith("dropdown")?M.createElement(n.DropdownNav,{className:c[D.Dropdowns],style:b?.[D.Dropdowns]},(()=>{const S=h==="dropdown"||h==="dropdown-months"?M.createElement(n.MonthsDropdown,{key:"month",className:c[D.MonthsDropdown],"aria-label":Os(),classNames:c,components:n,disabled:!!s.disableNavigation,onChange:Gs(W.date),options:ar(W.date,B,K,r,i),style:b?.[D.Dropdown],value:i.getMonth(W.date)}):M.createElement("span",{key:"month"},$(W.date,i)),A=h==="dropdown"||h==="dropdown-years"?M.createElement(n.Years
14Dropdown,{key:"year",className:c[D.YearsDropdown],"aria-label":Es(i.options),classNames:c,components:n,disabled:!!s.disableNavigation,onChange:Hs(W.date),options:ir(B,K,r,i,!!s.reverseYears),style:b?.[D.Dropdown],value:i.getYear(W.date)}):M.createElement("span",{key:"year"},E(W.date,i));return i.getMonthYearOrder()==="year-first"?[A,S]:[S,A]})(),M.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},_(W.date,i.options,i))):M.createElement(n.CaptionLabel,{className:c[D.CaptionLabel],role:"status","aria-live":"polite"},_(W.date,i.options,i))),x==="around"&&!s.hideNavigation&&P===m-1&&M.createElement(n.NextMonthButton,{type:"button",className:c[D.NextMonthButton],tabIndex:G?void 0:-1,"aria-disabled":G?void 0:!0,"aria-label":Fs(G),onClick:Ue,"data-animated-button":s.animate?"true":void 0},M.createElement(n.Chevron,{disabled:G?void 0:!0,className:c[D.Chevron],orientation:s.dir==="rtl"?"left":"right"})),P===m-1&&x==="after"&&!s.hideNavigation&&M.createElement(n.Nav,{"data-animated-nav":s.animate?"true":void 0,className:c[D.Nav],style:b?.[D.Nav],"aria-label":yt(),onPreviousClick:He,onNextClick:Ue,previousMonth:Z,nextMonth:G}),M.createElement(n.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Ss(W.date,i.options,i)||void 0,className:c[D.MonthGrid],style:b?.[D.MonthGrid]},!s.hideWeekdays&&M.createElement(n.Weekdays,{"data-animated-weekdays":s.animate?"true":void 0,className:c[D.Weekdays],style:b?.[D.Weekdays]},j&&M.createElement(n.WeekNumberHeader,{"aria-label":Is(i.options),className:c[D.WeekNumberHeader],style:b?.[D.WeekNumberHeader],scope:"col"},F()),As.map(S=>M.createElement(n.Weekday,{"aria-label":Ts(S,i.options,i),className:c[D.Weekday],key:String(S),style:b?.[D.Weekday],scope:"col"},O(S,i.options,i)))),M.createElement(n.Weeks,{"data-animated-weeks":s.animate?"true":void 0,className:c[D.Weeks],style:b?.[D.Weeks]},W.weeks.map(S=>M.createElement(n.Week,{className:c[D.Week],key:S.weekNumber,style:b?.[D.Week],week:S},j&&M.createElement(n.WeekNumber,{week:S,style:b?.[D.WeekNumber],"aria-label":Ls(S.weekNumber,{locale:l}),className:c[D.WeekNumber],scope:"row",role:"rowheader"},v(S.weekNumber,i)),S.days.map(A=>{const{date:J}=A,I=qe(A);if(I[q.focused]=!I.hidden&&!!gt?.isEqualTo(A),I[se.selected]=Re?.(J)||I.selected,$e(Se)){const{from:ze,to:Ke}=Se;I[se.range_start]=!!(ze&&Ke&&i.isSameDay(J,ze)),I[se.range_end]=!!(ze&&Ke&&i.isSameDay(J,Ke)),I[se.range_middle]=le(Se,J,!0,i)}const Vs=rr(I,b,s.modifiersStyles),Js=$a(I,c,s.modifiersClassNames),Qs=!bt&&!I.hidden?_s(J,I,i.options,i):void 0;return M.createElement(n.Day,{key:`${A.isoDate}_${A.displayMonthId}`,day:A,modifiers:I,className:Js.join(" "),style:Vs,role:"gridcell","aria-selected":I.selected||void 0,"aria-label":Qs,"data-day":A.isoDate,"data-month":A.outside?A.dateMonthId:void 0,"data-selected":I.selected||void 0,"data-disabled":I.disabled||void 0,"data-hidden":I.hidden||void 0,"data-outside":A.outside||void 0,"data-focused":I.focused||void 0,"data-today":I.today||void 0},!I.hidden&&bt?M.createElement(n.DayButton,{className:c[D.DayButton],style:b?.[D.DayButton],type:"button",day:A,modifiers:I,disabled:!I.focused&&I.disabled||void 0,"aria-disabled":I.focused&&I.disabled||void 0,tabIndex:Cs(A)?0:-1,"aria-label":Ds(J,I,i.options,i),onClick:Ps(A,I),onBlur:$s(A,I),onFocus:Bs(A,I),onKeyDown:Ys(A,I),onMouseEnter:qs(A,I),onMouseLeave:Rs(A,I)},T(J,i.options,i)):!I.hidden&&T(A.date,i.options,i))})))))))),s.footer&&M.createElement(n.Footer,{className:c[D.Footer],style:b?.[D.Footer],role:"status","aria-live":"polite"},s.footer)))}function Ae({className:e,classNames:s,showOutsideDays:a=!0,locale:n=he,...r}){return t.jsx(Fr,{showOutsideDays:a,locale:n,className:en("p-3",e),classNames:{...s},...r})}function Tr({dateRange:e,setDateRange:s,searchTerm:a,setSearchTerm:n,showOnlyMatched:r,setShowOnlyMatched:o,carrierFilter:i,setCarrierFilter:l}){return t.jsxs("div",{className:"bg-white rounded-xl border border-gray-200 p-4 space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx("span",{className:"text-sm text-gray-500 flex items-center mr-2",children:"ë¹ ë¥¸ ì í:"}),Vn.map(({label:c,days:h})=>t.jsx(V,{variant:"outline",size:"sm",className:L("h-8",e.from&&e.to&&Math.round((e.to.getTime()-e.from.getTime())/(1e3*60*60*24))===h&&z(e.to,"yyyy-MM-dd")===z(new Date,"yyyy-MM-dd")?"bg-blue-50 border-blue-300 text-blue-700":""),onClick:()=>s({from:Be(new Date,h),to:new Date}),children:c},c))]}),t.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-600 whitespace-nowrap",children:"ììì¼"}),t.jsxs(Ne,{children:[t.jsx(je,{asChild:!0,children:t.jsxs(V,{variant:"outline",className:"w-[180px] justify-start text-left font-normal",children:[t.jsx(We,{className:"mr-2 h-4 w-4"}),e.from?z(e.from,"yyyy-MM-dd"):"ì í"]})}),t.jsx(ve,{className:"w-auto p-0 bg-white",align:"start",children:t.jsx(Ae,{mode:"single",selected:e.from,onSelect:c=>c&&s(h=>({...h,from:c})),locale:he,initialFocus:!0})})]})]}),t.jsx("span",{className:"text-gray-400",children:"~"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm text-gray-600 whitespace-nowrap",children:"ì¢
ë£ì¼"}),t.jsxs(Ne,{children:[t.jsx(je,{asChild:!0,children:t.jsxs(V,{variant:"outline",className:"w-[180px] justify-start text-left font-normal",children:[t.jsx(We,{className:"mr-2 h-4 w-4"}),e.to?z(e.to,"yyyy-MM-dd"):"ì í"]})}),t.jsx(ve,{className:"w-auto p-0 bg-white",align:"start",children:t.jsx(Ae,{mode:"single",selected:e.to,onSelect:c=>c&&s(h=>({...h,to:c})),locale:he,initialFocus:!0,disabled:c=>e.from?c<e.from:!1})})]})]}),t.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[t.jsx(An,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),t.jsx(de,{placeholder:"주문ë²í¸/ì´ë¦/ì°ë½ì² ê²ì",value:a,onChange:c=>n(c.target.value),className:"pl-9 pr-8"}),a&&t.jsx("button",{type:"button",onClick:()=>n(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-gray-100 text-gray-400 hover:text-gray-600",title:"ê²ìì´ ì§ì°ê¸°",children:t.jsx(Gt,{className:"h-4 w-4"})})]}),t.jsxs(V,{variant:r?"default":"outline",onClick:()=>o(!r),className:"gap-2",children:[t.jsx(zn,{className:"w-4 h-4"}),"ì´ì 매ì¹ë§ 보기"]}),t.jsx("div",{className:"flex items-center gap-1 border rounded-lg p-1",children:[{value:"all",label:"ì ì²´"},{value:"cj",label:"CJ",color:"yellow"},{value:"chunil",label:"ì²ì¼",color:"green"},{value:"kyungdong",label:"ê²½ë",color:"blue"}].map(({value:c,label:h,color:d})=>t.jsx(V,{variant:i===c?"default":"ghost",size:"sm",onClick:()=>l(c),className:L("h-7 px-3",i===c&&c!=="all"&&{yellow:"bg-yellow-500 hover:bg-yellow-600",green:"bg-green-500 hover:bg-green-600",blue:"bg-blue-500 hover:bg-blue-600"}[d]),children:h},c))})]})]})}const Lr={CJëííµì´:"CJ",ì²ì¼íë°°:"ì²ì¼",ê²½ëíë°°:"ê²½ë"};function Ir(e){return Lr[e]||e}function St(e,s){const a=e-s;return a===0?t.jsx("span",{className:"text-gray-500",children:"0ì"}):a>0?t.jsxs("span",{className:"text-blue-600 font-medium",children:["+",a.toLocaleStr
14ing(),"ì"]}):t.jsxs("span",{className:"text-red-600 font-medium",children:[a.toLocaleString(),"ì"]})}function Er(e){return e.invoices.length===0?"-":[...new Set(e.invoices.map(a=>Kn[a.carrier]||a.carrier))].join(", ")}function Ar({breakdown:e,onClose:s}){return t.jsxs("div",{className:"w-[280px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h4",{className:"font-bold text-sm text-gray-900",children:"ë¡ì§ ë´ì"}),t.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600",children:t.jsx(Gt,{className:"w-4 h-4"})})]}),t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("span",{className:L("px-2 py-0.5 rounded-full text-xs font-medium",e.type==="í물íë°°"?"bg-orange-100 text-orange-700":"bg-indigo-100 text-indigo-700"),children:e.type}),t.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-700",children:e.gradeName})]}),t.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 space-y-2 text-sm",children:[t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500",children:"ê¸°ì¤ ìê¸"}),t.jsxs("span",{className:"font-medium",children:[e.baseFee.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500",children:"ì´ ë¬´ê²"}),t.jsxs("span",{className:"font-medium",children:[e.totalWeightKg.toFixed(1),"kg"]})]}),t.jsxs("div",{className:"flex justify-between",children:[t.jsx("span",{className:"text-gray-500",children:"ê±´ì"}),t.jsxs("span",{className:"font-medium",children:[e.unitCount,"ê±´",t.jsxs("span",{className:"text-xs text-gray-400 ml-1",children:["(",e.weightPerUnit,"kg/ê±´)"]})]})]})]}),t.jsxs("div",{className:"mt-3 px-1 text-xs text-gray-500 space-y-0.5",children:[t.jsxs("div",{children:[e.baseFee.toLocaleString(),"ì x ",e.unitCount,"ê±´ = ",e.rawAmount.toLocaleString(),"ì"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{children:"ì²ì ì¬ë¦¼ â"}),t.jsxs("span",{className:"text-sm font-bold text-gray-900",children:[e.fee.toLocaleString(),"ì"]})]})]}),e.items.length>1&&t.jsxs("div",{className:"mt-3 pt-3 border-t",children:[t.jsx("div",{className:"text-xs font-medium text-gray-500 mb-1.5",children:"ìì´í
ë³ ë±ê¸"}),t.jsx("div",{className:"space-y-1",children:e.items.map((a,n)=>t.jsxs("div",{className:"flex justify-between text-xs",children:[t.jsxs("span",{className:"text-gray-600",children:[a.w," x ",a.l,"mm (",a.qty,"ê°)"]}),t.jsx("span",{className:"font-medium text-gray-700",children:a.grade})]},n))})]})]})}function Pr({filteredOrders:e,loading:s}){const[a,n]=C.useState(null);return t.jsx("div",{className:"bg-white rounded-xl border border-gray-200 overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm table-fixed",children:[t.jsxs("colgroup",{children:[t.jsx("col",{className:"w-[5%]"}),t.jsx("col",{className:"w-[13%]"}),t.jsx("col",{className:"w-[5%]"}),t.jsx("col",{className:"w-[9%]"}),t.jsx("col",{className:"w-[4%]"}),t.jsx("col",{className:"w-[8%]"}),t.jsx("col",{className:"w-[7%]"}),t.jsx("col",{className:"w-[9%]"}),t.jsx("col",{className:"w-[9%]"}),t.jsx("col",{className:"w-[11%]"}),t.jsx("col",{className:"w-[9%]"})]}),t.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-3 text-center text-sm font-medium text-gray-600 whitespace-nowrap",children:"주문ì¼"}),t.jsx("th",{className:"px-2 py-3 text-left text-sm font-medium text-gray-600 whitespace-nowrap",children:"주문ë²í¸"}),t.jsx("th",{className:"px-2 py-3 text-center text-sm font-medium text-gray-600 whitespace-nowrap",children:"ì´ë¦"}),t.jsx("th",{className:"px-2 py-3 text-center text-sm font-medium text-gray-600 whitespace-nowrap",children:"ì°ë½ì²"}),t.jsx("th",{className:"px-2 py-3 text-center text-sm font-medium text-gray-600 whitespace-nowrap",children:"íë°°ì¬"}),t.jsx("th",{className:"px-2 py-3 text-right text-sm font-medium text-gray-600 whitespace-nowrap",children:"ë°°ì¡ë¹"}),t.jsx("th",{className:"px-2 py-3 text-center text-sm font-medium text-gray-600 bg-blue-50 whitespace-nowrap",children:"ì¤ì íë°°ì¬"}),t.jsx("th",{className:"px-2 py-3 text-right text-sm font-medium text-gray-600 bg-blue-50 whitespace-nowrap",children:"ì¤ì ë°°ì¡ë¹"}),t.jsx("th",{className:"px-2 py-3 text-right text-sm font-medium text-gray-600 bg-blue-50 whitespace-nowrap",children:"ì°¨ì¡"}),t.jsx("th",{className:"px-2 py-3 text-right text-sm font-medium text-gray-600 bg-emerald-50 whitespace-nowrap",children:"íì¬ë¡ì§"}),t.jsx("th",{className:"px-2 py-3 text-right text-sm font-medium text-gray-600 bg-emerald-50 whitespace-nowrap",children:"ë¡ì§ì°¨ì¡"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100",children:s?t.jsx("tr",{children:t.jsx("td",{colSpan:11,className:"px-4 py-8 text-center text-gray-500",children:"ë¡ë© ì¤..."})}):e.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:11,className:"px-4 py-8 text-center text-gray-500",children:"ì¡°íë ì£¼ë¬¸ì´ ììµëë¤."})}):e.map(r=>{const o=r.invoices.filter(i=>i.actual_fee!=null).length;return t.jsxs("tr",{className:L("hover:bg-gray-50 align-middle",o>1&&"bg-orange-50/50"),children:[t.jsx("td",{className:"px-2 py-3 text-center text-sm text-gray-600 whitespace-nowrap",children:r.order_date?z(new Date(r.order_date),"MM-dd"):"-"}),t.jsx("td",{className:"px-2 py-3 text-left",children:t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("a",{href:`/admin/orders/${r.order_code}`,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-sm font-bold text-blue-600 hover:text-blue-800 hover:underline",children:r.order_code}),o>1&&t.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-orange-100 text-orange-700 text-xs font-medium cursor-help flex-shrink-0",title:`ë¤ê±´ ì¶ê³ : ì´ ì£¼ë¬¸ì ${o}ê±´ì ê°ë³ ë°°ì¡ì¼ë¡ ë°ì¡ëììµëë¤`,children:[t.jsx(we,{className:"w-3 h-3"}),o]})]})}),t.jsx("td",{className:"px-2 py-3 text-center text-sm truncate",title:r.customer_name,children:r.customer_name}),t.jsx("td",{className:"px-2 py-3 text-center text-sm text-gray-600 whitespace-nowrap truncate",children:r.customer_phone||"-"}),t.jsx("td",{className:"px-2 py-3 text-center text-sm whitespace-nowrap",children:Ir(r.shipping_company)||"-"}),t.jsxs("td",{className:"px-2 py-3 text-right text-sm font-medium whitespace-nowrap",children:[r.packaging_fee.toLocaleStr
14ing(),"ì"]}),t.jsx("td",{className:"px-2 py-3 text-center text-sm bg-blue-50/50 whitespace-nowrap",children:Er(r)}),t.jsx("td",{className:"px-2 py-3 text-right bg-blue-50/50 whitespace-nowrap",children:r.actualFeeTotal>0?t.jsxs("div",{children:[t.jsxs("span",{className:"font-bold text-sm text-blue-700",children:[r.actualFeeTotal.toLocaleString(),"ì"]}),o>1&&t.jsxs("div",{className:"text-xs text-gray-500",children:["(",o,"ê±´)"]})]}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-2 py-3 text-right bg-blue-50/50 whitespace-nowrap",children:r.actualFeeTotal>0?St(r.packaging_fee,r.actualFeeTotal):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-2 py-3 text-right bg-emerald-50/50 whitespace-nowrap",children:r.currentLogicFee!=null?r.currentLogicBreakdown?t.jsxs(Ne,{open:a===r.order_code,onOpenChange:i=>n(i?r.order_code:null),children:[t.jsx(je,{asChild:!0,children:t.jsxs("button",{className:L("inline-flex items-center gap-0.5 font-medium text-sm cursor-pointer hover:underline decoration-dotted underline-offset-2",r.currentLogicFee!==r.packaging_fee?"text-emerald-700":"text-gray-600"),children:[r.currentLogicFee.toLocaleString(),"ì",t.jsx("span",{className:"text-gray-400 text-xs",children:"?"})]})}),t.jsx(ve,{className:"w-auto p-4 bg-white border border-gray-200 shadow-lg",side:"left",align:"start",children:t.jsx(Ar,{breakdown:r.currentLogicBreakdown,onClose:()=>n(null)})})]}):t.jsxs("span",{className:L("font-medium text-sm",r.currentLogicFee!==r.packaging_fee?"text-emerald-700":"text-gray-600"),children:[r.currentLogicFee.toLocaleString(),"ì"]}):t.jsx("span",{className:"text-gray-400",children:"-"})}),t.jsx("td",{className:"px-2 py-3 text-right bg-emerald-50/50 whitespace-nowrap",children:r.currentLogicFee!=null&&r.actualFeeTotal>0?St(r.currentLogicFee,r.actualFeeTotal):t.jsx("span",{className:"text-gray-400",children:"-"})})]},r.order_code)})})]})})}async function Br(){const{data:e,error:s}=await re.from("ln_packaging_fee_config").select("*").eq("config_type","packaging_fee_v2").eq("is_active",!0).maybeSingle();if(s)throw console.error("[PackagingFeeSettingsService] ì¡°í ì¤í¨:",s),s;return e?e.config_data:nt}async function $r(e){await re.from("ln_packaging_fee_config").update({is_active:!1}).eq("config_type","packaging_fee_v2").eq("is_active",!0);const{error:s}=await re.from("ln_packaging_fee_config").insert({config_type:"packaging_fee_v2",config_data:e,description:"ìì í¬ì¥ë¹ V2 ì¤ì ",is_active:!0,updated_at:new Date().toISOString()});if(s)throw console.error("[PackagingFeeSettingsService] ì ì¥ ì¤í¨:",s),s;tn(),await it()}function Yr(){const[e,s]=C.useState(nt),[a,n]=C.useState(nt),[r,o]=C.useState(!0),[i,l]=C.useState(!1),[c,h]=C.useState(!1),d=C.useCallback(async()=>{o(!0);try{const f=await Br();s(f),n(f),h(!1)}catch(f){console.error("ì¤ì ë¡ë ì¤í¨:",f),pe.error("ì¤ì ì ë¶ë¬ì¤ëë° ì¤í¨íìµëë¤")}finally{o(!1)}},[]);C.useEffect(()=>{d()},[d]),C.useEffect(()=>{const f=JSON.stringify(e)!==JSON.stringify(a);h(f)},[e,a]);const x=C.useCallback(f=>{s(p=>({...p,parcelTiers:f}))},[]),m=C.useCallback(f=>{s(p=>({...p,freightTiers:f}))},[]),u=C.useCallback((f,p)=>{s(k=>({...k,[f]:p}))},[]),g=C.useCallback(f=>{s(p=>({...p,parcelGapDecisions:f}))},[]),N=C.useCallback(f=>{s(p=>({...p,freightGapDecisions:f}))},[]),y=C.useCallback(async f=>{if(!c){pe.info("ë³ê²½ë ë´ì©ì´ ììµëë¤");return}l(!0);try{await $r(e),n(e),h(!1),pe.success("ì¤ì ì´ ì ì¥ëììµëë¤"),f?.()}catch(p){console.error("ì¤ì ì ì¥ ì¤í¨:",p),pe.error("ì¤ì ì ì¥ì ì¤í¨íìµëë¤")}finally{l(!1)}},[e,c]),w=C.useCallback(()=>{s(a),pe.info("ë³ê²½ ì¬íì´ ì·¨ìëììµëë¤")},[a]);return{settings:e,loading:r,saving:i,hasChanges:c,loadSettings:d,handleSave:y,handleReset:w,updateParcelTiers:x,updateFreightTiers:m,updateConstant:u,updateParcelGapDecisions:g,updateFreightGapDecisions:N}}const Pe={small:{label:"ìí",description:"í 200mmÃê¸¸ì´ 1200mm ì´í ë±"},medium:{label:"ì¤í",description:"í 400mmÃê¸¸ì´ 1000mm ì´í ë±"},large:{label:"ëí",description:"í 600mmÃê¸¸ì´ 900mm ì´í ë±"}};function qr({onSaved:e}={}){const s=Pn(),{settings:a,loading:n,saving:r,hasChanges:o,loadSettings:i,handleSave:l,handleReset:c,updateParcelTiers:h,updateFreightTiers:d,updateConstant:x,updateParcelGapDecisions:m,updateFreightGapDecisions:u}=Yr(),[g,N]=C.useState(!1),[y,w]=C.useState(!1);return n?t.jsxs("div",{className:"flex items-center justify-center py-20",children:[t.jsx(Fe,{className:"w-6 h-6 animate-spin text-gray-400"}),t.jsx("span",{className:"ml-2 text-gray-500",children:"ì¤ì ì ë¶ë¬ì¤ë ì¤..."})]}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{className:"w-5 h-5 text-blue-600"}),t.jsx("h2",{className:"text-lg font-semibold",children:"ìì í¬ì¥ë¹ ì¤ì "}),o&&t.jsx("span",{className:"px-2 py-0.5 text-xs bg-orange-100 text-orange-700 rounded-full",children:"ë³ê²½ë¨"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(V,{variant:"outline",size:"sm",onClick:i,disabled:r,children:[t.jsx(Fe,{className:"w-4 h-4 mr-1"}),"ìë¡ê³ 침"]}),t.jsxs(Bn,{children:[o&&t.jsx(V,{variant:"outline",size:"sm",onClick:c,disabled:r,children:"ì·¨ì"}),t.jsxs(V,{size:"sm",onClick:()=>l(e),disabled:!o||r,children:[t.jsx($n,{className:"w-4 h-4 mr-1"}),r?"ì ì¥ ì¤...":"ì ì¥"]})]})]})]}),t.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 border border-blue-200 rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[t.jsx(Yn,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-gray-900",children:"íì¬ë¡ì§ ë°©ì"}),t.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["주문 ë´ ëª¨ë ìì´í
ì¤ ",t.jsx("strong",{children:"ê°ì¥ í° ìì´í
"}),"ì¼ë¡ ë±ê¸ì íì í©ëë¤. ì¼ë°íë°° í
ì´ë¸ì 매ì¹ëì§ ìë ìì´í
ì´ ",t.jsx("strong",{children:"íëë¼ë"})," ìì¼ë©´ ì ì²´ ì£¼ë¬¸ì´ í물íë°°ë¡ ì íë©ëë¤."]})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[t.jsxs("div",{className:"bg-white rounded-lg p-3 border border-blue-100",children:[t.jsx("p",{className:"font-medium text-gray-800 mb
14-1",children:"1. ë±ê¸ íì "}),t.jsxs("p",{className:"text-gray-600",children:["ì¼ë°íë°°: íÃê¸¸ì´ ìì°¨ 매ì¹",t.jsx("br",{}),"í물íë°°: #ììëë¡ ë§¤ì¹"]})]}),t.jsxs("div",{className:"bg-white rounded-lg p-3 border border-blue-100",children:[t.jsx("p",{className:"font-medium text-gray-800 mb-1",children:"2. ê±´ì ì°ì¶"}),t.jsxs("p",{className:"text-gray-600",children:["ì´ ë¬´ê² Ã· ",a.weightPerUnit,"kg = ê±´ì (ì¬ë¦¼, ìµì 1)"]})]}),t.jsxs("div",{className:"bg-white rounded-lg p-3 border border-blue-100",children:[t.jsx("p",{className:"font-medium text-gray-800 mb-1",children:"3. ìµì¢
ìê¸"}),t.jsxs("p",{className:"text-gray-600",children:["ë±ê¸ ìê¸ Ã ê±´ì â ì²ì ë¨ì ì¬ë¦¼",t.jsx("br",{}),"ìµë ",a.maxFee.toLocaleString(),"ìê¹ì§"]})]})]})]}),t.jsx(st,{icon:t.jsx(we,{className:"w-4 h-4"}),title:"ì¼ë°íë°° ìê¸í",description:"í(ì§§ì쪽) à 길ì´(긴쪽) ììëë¡ ë§¤ì¹í©ëë¤. 첫 ë²ì§¸ 매ì¹ë ë±ê¸ì´ ì ì©ë©ëë¤.",editingSize:g,onToggleEditSize:s?void 0:()=>N(!g),children:t.jsx(Hr,{tiers:a.parcelTiers,onUpdate:h,editingSize:g,gapDecisions:a.parcelGapDecisions??{},onGapDecisionsChange:m,readOnly:s})}),t.jsx(st,{icon:t.jsx(Te,{className:"w-4 h-4"}),title:"í물íë°° ìê¸í",description:"ì¼ë°íë°°ì 매ì¹ëì§ ìë ìì´í
ì í물íë°°ë¡ ì íë©ëë¤. #ììëë¡ ë§¤ì¹í©ëë¤.",editingSize:y,onToggleEditSize:s?void 0:()=>
14w(!y),children:t.jsx(Xr,{tiers:a.freightTiers,onUpdate:d,editingSize:y,gapDecisions:a.freightGapDecisions??{},onGapDecisionsChange:u,readOnly:s})}),t.jsx(st,{icon:t.jsx(xe,{className:"w-4 h-4"}),title:"기í ì¤ì ",description:"ê±´ì ì°ì¶ ë° ë¬´ê² ê³ì°ì ì¬ì©ëë ììì
ëë¤.",children:t.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700",children:"ë¬´ê² ë¨ì (ê±´ì 기ì¤)"}),t.jsx("p",{className:"text-xs text-gray-500",children:"ì´ ë¬´ê²(kg)ë¹ 1ê±´ì¼ë¡ ê³ì°í©ëë¤"}),t.jsxs("div",{className:"relative",children:[t.jsx(de,{type:"text",inputMode:"numeric",value:a.weightPerUnit,onChange:f=>x("weightPerUnit",parseInt(f.target.value)||20),className:"pr-8",disabled:s}),t.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-400",children:"kg"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700",children:"기본 ë°ë"}),t.jsx("p",{className:"text-xs text-gray-500",children:"ëª©ì¬ ê¸°ë³¸ ë°ë (kg/mm³). ë¬´ê² ìë ê³ì°ì ì¬ì©"}),t.jsx(de,{type:"text",inputMode:"decimal",value:a.defaultDensity,onChange:f=>x("defaultDensity",parseFloat(f.target.value)||65e-8),disabled:s})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700",children:"ìì í¬ì¥ë¹ ìí"}),t.jsx("p",{className:"text-xs text-gray-500",children:"1í ê³ì°ë¹ ìµë ê¸ì¡. ì©ë¬ ì¤ë¹ ìí 기ì¤"}),t.jsxs("div",{className:"relative",children:[t.jsx(de,{type:"text",inputMode:"numeric",value:a.maxFee,onChange:f=>x("maxFee",parseInt(f.target.value)||sn),className:"pr-8",disabled:s}),t.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-400",children:"ì"})]})]})]})})]})}function Rr(e){const s=new Map,a=(o,i)=>{if(o<=0||i<=0)return;const l=`${o}Ã${i}`;s.has(l)||s.set(l,{width:o,length:i})},n=Math.max(...e.map(o=>o.maxWidth),0),r=Math.max(...e.map(o=>o.maxLength),0);for(const o of e)a(o.maxWidth,o.maxLength),a(Math.max(1,o.maxWidth-50),o.maxLength),a(o.maxWidth,Math.max(1,o.maxLength-50)),a(o.maxWidth+50,o.maxLength),a(o.maxWidth,o.maxLength+50);return a(n+100,r),a(n,r+100),Array.from(s.entries()).map(([o,i])=>({...i,label:o})).sort((o,i)=>o.width-i.width||o.length-i.length)}function Gr(e){const a=Rr(e).map(r=>{const o=e.findIndex(l=>r.width<=l.maxWidth&&r.length<=l.maxLength),i=o>=0?e[o]:null;return{width:r.width,length:r.length,label:r.label,matchedIdx:o>=0?o:null,matchedGrade:i?Pe[i.grade]?.label??i.grade:null,isGap:o<0}}),n=[];for(let r=1;r<e.length;r++)for(let o=0;o<r;o++)if(e[o].maxWidth>=e[r].maxWidth&&e[o].maxLength>=e[r].maxLength){n.push({tierIdx:r,shadowedByIdx:o});break}return{tests:a,shadowed:n,gapCount:a.filter(r=>r.isGap).length}}function Hr({tiers:e,onUpdate:s,editingSize:a,gapDecisions:n,onGapDecisionsChange:r,readOnly:o}){const i=n,l=(x,m,u)=>{const g=[...e];g[x]={...g[x],[m]:u},s(g)},c=()=>{s([...e,{maxWidth:0,maxLength:0,grade:"small",fee:0}])},h=x=>{s(e.filter((m,u)=>u!==x))},d=C.useMemo(()=>a?Gr(e):null,[e,a]);return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"border border-gray-200 rounded overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-600 w-[80px]",children:"ë±ê¸"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600 w-12",children:"#"}),t.jsxs("th",{className:"px-3 py-2 text-left font-medium text-gray-600",children:["ìµë í (mm) ",!a&&t.jsx(Le,{className:"w-3 h-3 inline ml-1 text-gray-400"})]}),t.jsxs("th",{className:"px-3 py-2 text-left font-medium text-gray-600",children:["ìµë ê¸¸ì´ (mm) ",!a&&t.jsx(Le,{className:"w-3 h-3 inline ml-1 text-gray-400"})]}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-600 w-[140px]",children:"ìê¸ (ì)"}),a&&t.jsx("th",{className:"px-3 py-2 w-12"})]})}),t.jsx("tbody",{children:e.map((x,m)=>{const u=d?.shadowed.some(g=>g.tierIdx===m);return t.jsxs("tr",{className:L("border-t border-gray-100 hover:bg-gray-50",u&&"bg-red-50/50"),children:[t.jsx("td",{className:"px-3 py-1.5 text-sm text-gray-700 font-medium",children:Pe[x.grade]?.label??x.grade}),t.jsxs("td",{className:"px-3 py-1.5 text-gray-400 text-center",children:[m+1,u&&t.jsx(Ce,{className:"w-3 h-3 text-red-500
14inline ml-1"})]}),t.jsx("td",{className:"px-3 py-1.5",children:t.jsx(de,{type:"text",inputMode:"numeric",value:x.maxWidth,onChange:g=>l(m,"maxWidth",parseInt(g.target.value)||0),className:L("h-8",!a&&"bg-gray-50 text-gray-600"),disabled:!a})}),t.jsx("td",{className:"px-3 py-1.5",children:t.jsx(de,{type:"text",inputMode:"numeric",value:x.maxLength,onChange:g=>l(m,"maxLength",parseInt(g.target.value)||0),className:L("h-8",!a&&"bg-gray-50 text-gray-600"),disabled:!a})}),t.jsx("td",{className:"px-3 py-1.5",children:t.jsx(de,{type:"text",inputMode:"numeric",value:x.fee,onChange:g=>l(m,"fee",parseInt(g.target.value)||0),className:"h-8",disabled:o})}),a&&!o&&t.jsx("td",{className:"px-3 py-1.5",children:t.jsx("button",{onClick:()=>h(m),className:"text-red-400 hover:text-red-600 p-1",title:"ìì ",children:t.jsx(Jt,{className:"w-4 h-4"})})})]},m)})})]})}),a&&!o&&t.jsxs(V,{variant:"outline",size:"sm",onClick:c,children:[t.jsx(Qt,{className:"w-4 h-4 mr-1"}),"í ì¶ê°"]}),t.jsx("p",{className:"text-xs text-gray-400",children:"ììëë¡ ë§¤ì¹: í ⤠ìµëí AND ê¸¸ì´ â¤ ìµë길ì´ì¸ 첫 ë²ì§¸ íì´ ì ì©ë©ëë¤. ì´ë¤ íìë 매ì¹ëì§ ìì¼ë©´ í물íë°°ë¡ ì íë©ëë¤."}),a&&d&&t.jsx(Kr,{validation:d,tiers:e,confirmed:i,onConfirm:(x,m)=>r({...i,[x]:m}),onUndo:x=>{const{[x]:m,...u}=i;r(u)}})]})}function Ur(e,s,a,n){const r=n.filter(l=>l.grade===a);if(r.some(l=>e<=l.maxWidth&&s<=l.maxLength))return null;if(r.length===0)return"í´ë¹ ë±ê¸ì íì´ ììµëë¤";const o=[],i=r.reduce((l,c)=>{const h=Math.max(0,e-l.maxWidth)+Math.max(0,s-l.maxLength),d=Math.max(0,e-c.maxWidth)+Math.max(0,s-c.maxLength);return h<=d?l:c});return e>i.maxWidth&&o.push(`í ${i.maxWidth}â${e}`),s>i.maxLength&&o.push(`ê¸¸ì´ ${i.maxLength}â${s}`),o.length>0?`ì¡°ê±´ ì¡°ì íì: ${o.join(", ")}`:null}function zr(e,s,a,n){const r=n.find(h=>h.name===a);if(!r)return"í´ë¹ ë±ê¸ì ì°¾ì ì ììµëë¤";const o=Math.min(e,s),i=Math.max(e,s),l=o+i,c=[];return r.exactWidth!==void 0&&o!==r.exactWidth&&c.push(`í=${r.exactWidth} (íì¬ ${o})`),r.exactLength!==void 0&&i!==r.exactLength&&c.push(`길ì´=${r.exactLength} (íì¬ ${i})`),r.minWidth!==void 0&&o<r.minWidth&&c.push(`íâ¥${r.minWidth}â${o}`),r.maxWidth!==void 0&&o>r.maxWidth&&c.push(`íâ¤${r.maxWidth}â${o}`),r.minLength!==void 0&&i<r.minLength&&c.push(`길ì´â¥${r.minLength}â${i}`),r.maxLength!==void 0&&i>r.maxLength&&c.push(`길ì´â¤${r.maxLength}â${i}`),r.minSum!==void 0&&l<r.minSum&&c.push(`í©â¥${r.minSum}â${l}`),r.maxSum!==void 0&&l>r.maxSum&&c.push(`í©â¤${r.maxSum}â${l}`),c.length>0?`ì¡°ê±´ ì¡°ì íì: ${c.join(", ")}`:null}function Kr({validation:e,tiers:s,confirmed:a,onConfirm:n,onUndo:r}){const{tests:o,shadowed:i,gapCount:l}=e,c=o.filter(m=>m.isGap&&a[m.label]).length,h=l-c,d=h>0||i.length>0,x=[...new Set(s.map(m=>m.grade))];return t.jsxs("div",{className:L("rounded-lg border p-3 mt-2",d?"bg-amber-50 border-amber-200":"bg-green-50 border-green-200"),children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d?t.jsx(Ce,{className:"w-4 h-4 text-amber-600"}):t.jsx(Xt,{className:"w-4 h-4 text-green-600"}),t.jsx("span",{className:L("text-sm font-medium",d?"text-amber-800":"text-green-800"),children:d?`ë±ê¸ ì§ì íì ${h>0?`(미ì§ì ${h}ê±´`:"("}${i.length>0?`${h>0?", ":""}겹침 ${i.length}ê±´`:""})`:"커ë²ë¦¬ì§ ì ì â 모ë ì¬ì´ì¦ ë±ê¸ ì§ì ìë£"})]}),i.length>0&&t.jsx("div",{className:"mb-2 space-y-1",children:i.map(m=>t.jsxs("div",{className:"flex items-start gap-1.5 text-xs text-red-700",children:[t.jsx(at,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),t.jsxs("span",{children:[t.jsxs("strong",{children:[m.tierIdx+1,"ë² í"]}),"ì´ ",t.jsxs("strong",{children:[m.shadowedByIdx+1,"ë² í"]}),"ì ìì í í¬í¨ëì´ ëë¬ ë¶ê°ë¥í©ëë¤."]})]},m.tierIdx))}),t.jsx("div",{className:"overflow-hidden rounded border border-gray-200/50",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-white/60",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1.5 text-left font-medium text-gray-600",children:"í
ì¤í¸ ì¬ì´ì¦"}),t.jsx("th",{className:"px-2 py-1.5 text-center font-medium text-gray-600",children:"íì¬ ë§¤ì¹"}),t.jsx("th",{className:"px-2 py-1.5 text-center font-medium text-gray-600",children:"ë±ê¸ ì§ì "})]})}),t.jsx("tbody",{children:o.map(m=>{const u=a[m.label],g=!!u;return t.jsxs("tr",{className:L("border-t border-gray-100",m.isGap&&!g&&"bg-red-50",m.isGap&&g&&"bg-green-50/50"),children:[t.jsx("td",{className:"px-2 py-1.5 font-mono text-gray-700",children:m.label}),t.jsx("td",{className:"px-2 py-1.5 text-center",children:m.matchedGrade?t.jsxs("span",{className:"text-gray-700",children:[m.matchedGrade," (#",(m.matchedIdx??0)+1,")"]}):t.jsx("span",{className:L("font-medium",g?"text-gray-500":"text-orange-600"),children:"미매ì¹"})}),t.jsx("td",{className:"px-2 py-1.5 text-center",children:m.isGap?g?t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx("span",{className:L("px-1.5 py-0.5 rounded text-xs font-medium",u==="freight"?"bg-green-100 text-green-700":"bg-blue-100 text-blue-700"),
14children:u==="freight"?"í물 ì í":Pe[u]?.label??u}),t.jsx("button",{onClick:()=>r(m.label),className:"text-gray-400 hover:text-gray-600",title:"ì¬ì í",children:t.jsx(at,{className:"w-3 h-3"})})]}),u!=="freight"&&(()=>{const N=Ur(m.width,m.length,u,s);return N?t.jsx("span",{className:"block text-[10px] text-amber-600 leading-tight",children:N}):null})()]}):t.jsxs("select",{className:"h-6 px-1 text-xs border border-red-300 rounded bg-white text-red-700 focus:outline-none focus:ring-1 focus:ring-red-400",value:"",onChange:N=>n(m.label,N.target.value),children:[t.jsx("option",{value:"",disabled:!0,children:"ì í..."}),t.jsx("option",{value:"freight",children:"í물 ì í"}),x.map(N=>t.jsx("option",{value:N,children:Pe[N]?.label??N},N))]}):t.jsx("span",{className:"text-green-600",children:"ì ì"})})]},m.label)})})]})}),t.jsx("p",{className:"text-xs text-gray-500 mt-1.5",children:"* ë¯¸ë§¤ì¹ ì¬ì´ì¦ì ëí´ ìëí ë±ê¸ ë¶ë¥ë¥¼ íì¸í©ëë¤. ì¬ì´ì¦ ì¡°ê±´ì ë³ê²½ëì§ ììµëë¤."})]})}const Zr={exactWidth:"ì íí í",minWidth:"í â¥",maxWidth:"í â¤",exactLength:"ì íí 길ì´",minLength:"ê¸¸ì´ â¥",maxLength:"ê¸¸ì´ â¤",minSum:"í+ê¸¸ì´ â¥",maxSum:"í+ê¸¸ì´ â¤"},Vr=[{label:"í",keys:["exactWidth","minWidth","maxWidth"]},{label:"길ì´",keys:["exactLength","minLength","maxLength"]},{label:"í©ê³",keys:["minSum","maxSum"]}];function Jr(e){const s=new Map,a=(o,i)=>{if(o<=0||i<=0)return;const l=`${o}Ã${i}`;s.has(l)||s.set(l,{width:o,length:i})},n=new Set,r=new Set;for(const o of e){if(o.exactWidth!==void 0&&n.add(o.exactWidth),o.minWidth!==void 0&&(n.add(o.minWidth),n.add(o.minWidth-50)),o.maxWidth!==void 0&&(n.add(o.maxWidth),n.add(o.maxWidth+50)),o.exactLength!==void 0&&r.add(o.exactLength),o.minLength!==void 0&&(r.add(o.minLength),r.add(o.minLength-50)),o.maxLength!==void 0&&(r.add(o.maxLength),r.add(o.maxLength+50)),o.minSum!==void 0){const i=Math.round(o.minSum/2);a(i,o.minSum-i),a(i,o.minSum-i-50)}if(o.maxSum!==void 0){const i=Math.round(o.maxSum/2);a(i,o.maxSum-i),a(i,o.maxSum-i+50)}}n.size===0&&[600,800,1e3,1200].forEach(o=>n.add(o)),r.size===0&&[1e3,1500,2e3,2400].forEach(o=>r.add(o));for(const o of n)for(const i of r)a(Math.min(o,i),Math.max(o,i));return Array.from(s.entries()).map(([o,i])=>({...i,label:o})).sort((o,i)=>o.width-i.width||o.length-i.length)}function Qr(e){const s=[...e].sort((n,r)=>n.priority-r.priority);return Jr(e).map(n=>{const r=Math.min(n.width,n.length),o=Math.max(n.width,n.length),i=r+o,l=s.find(c=>!(c.exactWidth!==void 0&&r!==c.exactWidth||c.exactLength!==void 0&&o!==c.exactLength||c.minWidth!==void 0&&r<c.minWidth||c.maxWidth!==void 0&&r>c.maxWidth||c.minLength!==void 0&&o<c.minLength||c.maxLength!==void 0&&o>c.maxLength||c.minSum!==void 0&&i<c.minSum||c.maxSum!==void 0&&i>c.maxSum));return{label:n.label,width:r,length:o,matchedTier:l?.name??null,isGap:!l}})}function Xr({tiers:e,onUpdate:s,editingSize:a,gapDecisions:n,onGapDecisionsChange:r,readOnly:o}){const i=n,l=(u,g,N)=>{const y=[...e];y[u]={...y[u],[g]:N},s(y)},c=(u,g,N)=>{const y=[...e],w={...y[u]},f=parseInt(N);N===""||isNaN(f)?delete w[g]:w[g]=f,y[u]=w,s(y)},h=()=>{const u=e.reduce((g,N)=>Math.max(g,N.priority),0);s([...e,{name:"ì ê·",fee:0,priority:u+1}])},d=u=>{s(e.filter((g,N)=>N!==u))},x=[...e].map((u,g)=>({...u,_origIdx:g})).sort((u,g)=>u.priority-g.priority),m=C.useMemo(()=>a?Qr(e):null,[e,a]);return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"border border-gray-200 rounded overflow-hidden",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-600 w-[80px]",children:"ë±ê¸"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600 w-12",children:"#"}),t.jsxs("th",{className:"px-3 py-2 text-left font-medium text-gray-600",children:["ì¬ì´ì¦ ì¡°ê±´ ",!a&&t.jsx(Le,{className:"w-3 h-3 inline ml-1 text-gray-400"})]}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-600 w-[140px]",children:"ìê¸ (ì)"}),a&&t.jsx("th",{className:"px-3 py-2 w-12"})]})}),t.jsx("tbody",{children:x.map(u=>{const g=u._origIdx;return t.jsxs("tr",{className:"border-t border-gray-100 hover:bg-gray-50",children:[t.jsx("td",{className:"px-3 py-1.5 text-sm text-gray-700 font-medium whitespace-nowrap",children:u.name}),t.jsx("td",{className:"px-3 py-1.5 text-gray-400 text-center",children:u.priority}),t.jsx("td",{className:"px-3 py-2",children:a?t.jsx("div",{className:"space-y-1.5",children:Vr.map(N=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[10px] text-gray-400 w-6 flex-shrink-0 text-right",children:N.label}),t.jsx("div",{className:"flex gap-2 flex-1",children:N.keys.map(y=>{const w=u[y];return t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"block text-[11px] text-gray-400 mb-0.5 whitespace-nowrap",children:Zr[y]}),t.jsx(de,{type:"text",inputMode:"numeric",value:w??"",onChange:f=>c(g,y,f.target.value),className:"h-7 text-xs",placeholder:"-"})]},y)})})]},N.label))}):t.jsx("span",{className:"text-xs text-gray-500",children:eo(u)})}),t.jsx("td",{className:"px-3 py-1.5",children:t.jsx(de,{type:"text",inputMode:"numeric",value:u.fee,onChange:N=>l(g,"fee",parseInt(N.target.value)||0),className:"h-8",disabled:o})}),a&&!o&&t.jsx("td",{className:"px-3 py-1.5",children:t.jsx("button",{onClick:()=>d(g),className:"text-red-400 hover:text-red-600 p-1",title:"ìì ",children:t.jsx(Jt,{className:"w-4 h-4"})})})]},g)})})]})}),a&&!o&&t.jsxs(V,{variant:"outline",size:"sm",onClick:h,children:[t.jsx(Qt,{className:"w-4 h-4 mr-1"}),"ë±ê¸ ì¶ê°"]}),t.jsx("p",{className:"text-xs text-gray-400",children:"#ììëë¡ ë§¤ì¹ (1 â 2 â 3 ...). ì¤ì ë ì¡°ê±´ì 모ë ANDë¡ ê²°í©ë©ëë¤. ë¹ íëë 무ìë©ëë¤. ê°ì¥ ë§ì§ë§ í목ì catch-allë¡ ì¬ì©íì¸ì."}),a&&m&&t.jsx(to,{results:m,tiers:e,confirmed:i,onConfirm:(u,g)=>r({...i,[u]:g}),onUndo:u=>{const{[u]:g,...N}=i;r(N)}})]})}function eo(e){const s=[];return e.exactWidth!==void 0&&s.push(`í=${e.exactWidth}`),e.exactLength!==void 0&&s.push(`길ì´=${e.exactLength}`),e.minWidth!==void 0&&s.push(`íâ¥${e.minWidth}`),e.maxWidth!==void 0&&s.push(`íâ¤${e.maxWidth}`),e.minLength!==void 0&&s.push(`길ì´â¥${e.minLength}`),e.maxLength!==void 0&&s.push(`길ì´â¤${e.maxLength}`),e.minSum!==void 0&&s.push(`í©â¥${e.minSum}`),e.maxSum!==void 0&&s.push(`í©â¤${e.maxSum}`),s.length>0?s.join(", "):"ì¡°ê±´ ìì (catch-all)"}function to({results:e,tiers:s,confirmed:a,onConfirm:n,onUndo:r}){const o=e.filter(d=>d.isGap).length,i=e.filter(d=>d.isGap&&a[d.label]).length,l=o-i,c=l>0,h=[...new Set(s.map(d=>d.name))].sort();
14return t.jsxs("div",{className:L("rounded-lg border p-3 mt-2",c?"bg-amber-50 border-amber-200":"bg-green-50 border-green-200"),children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c?t.jsx(Ce,{className:"w-4 h-4 text-amber-600"}):t.jsx(Xt,{className:"w-4 h-4 text-green-600"}),t.jsx("span",{className:L("text-sm font-medium",c?"text-amber-800":"text-green-800"),children:c?`ë±ê¸ ì§ì íì â ${l}ê±´ì í ì¤í¸ ì¬ì´ì¦ 미ì§ì `:"í물 커ë²ë¦¬ì§ ì ì â 모ë í ì¤í¸ ì¬ì´ì¦ ë±ê¸ ì§ì ìë£"})]}),t.jsx("div",{className:"grid grid-cols-4 gap-2",children:e.map(d=>{const x=a[d.label],m=!!x;return t.jsxs("div",{className:L("rounded px-2 py-1.5 text-xs border",d.isGap&&!m?"bg-red-50 border-red-200":d.isGap&&m?"bg-green-50/50 border-green-200":"bg-white border-gray-200"),children:[t.jsx("span",{className:"font-mono text-gray-700",children:d.label}),d.isGap?m?t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[t.jsx("span",{className:"px-1.5 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700",children:x}),t.jsx("button",{onClick:()=>r(d.label),className:"text-gray-400 hover:text-gray-600",title:"ì¬ì í",children:t.jsx(at,{className:"w-3 h-3"})})]}),(()=>{const u=zr(d.width,d.length,x,s);return u?t.jsx("span",{className:"block text-[10px] text-amber-600 leading-tight",children:u}):null})()]}):t.jsxs("select",{className:"block w-full mt-0.5 h-5 px-0.5 text-xs border border-red-300 rounded bg-white text-red-700 focus:outline-none focus:ring-1 focus:ring-red-400",value:"",onChange:u=>n(d.label,u.target.value),children:[t.jsx("option",{value:"",disabled:!0,children:"ë±ê¸ ì í..."}),h.map(u=>t.jsx("option",{value:u,children:u},u))]}):t.jsx("span",{className:"block text-gray-500",children:d.matchedTier})]},d.label)})}),t.jsx("p",{className:"text-xs text-gray-500 mt-1.5",children:"* ë¯¸ë§¤ì¹ ì¬ì´ì¦ì ëí´ ìëí ë±ê¸ ë¶ë¥ë¥¼ íì¸í©ëë¤. ì¬ì´ì¦ ì¡°ê±´ì ë³ê²½ëì§ ììµëë¤."})]})}function st({icon:e,title:s,description:a,children:n,editingSize:r,onToggleEditSize:o}){return t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[t.jsx("div",{className:"p-1.5 bg-gray-100 rounded text-gray-600",children:e}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"font-medium text-gray-900",children:s}),t.jsx("p",{className:"text-sm text-gray-500",children:a})]}),o&&t.jsxs(V,{variant:r?"default":"outline",size:"sm",onClick:o,className:r?"bg-amber-600 hover:bg-amber-700":"",children:[r?t.jsx(qn,{className:"w-4 h-4 mr-1"}):t.jsx(Le,{className:"w-4 h-4 mr-1"}),r?"ì¬ì´ì¦ í¸ì§ ì¤":"ì¬ì´ì¦ ìì "]})]}),n]})}const Ot=500,Wt=80;async function so(e,s){const{data:a,error:n}=await re.from("tp_order").select("id, order_code, order_date, shipping_company").gte("order_date",e).lte("order_date",s);if(n)throw n;if(!a||a.length===0)return{invoiceMap:new Map,orders:[],mappings:[]};const r=a.map(c=>c.id),o=[];for(let c=0;c<r.length;c+=Ot){const h=r.slice(c,c+Ot),{data:d,error:x}=await re.from("tp_order_mapping").select(` 15 internal_order_id, 16 request_order_id, 17 ln_order_requests!inner ( 18 packaging_fee, 19 request_data 20 ) 21 `).in("internal_order_id",h);if(x)throw console.error("[ShippingAnalysis] 매í ì¡°í ì¤í¨:",x),x;d&&o.push(...d)}const i=a.map(c=>
21c.order_code).filter(Boolean),l=new Map;for(let c=0;c<i.length;c+=Wt){const h=i.slice(c,c+Wt),{data:d,error:x}=await re.from("ln_shipping_invoice").select("order_code, carrier, invoice_seq, actual_fee").in("order_code",h).order("invoice_seq",{ascending:!0});if(x&&console.error("[ShippingAnalysis] ì¸ë³´ì´ì¤ ì¡°í ì¤í¨:",x),d)for(const m of d){const u=l.get(m.order_code)||[];u.push({carrier:m.carrier,invoice_seq:m.invoice_seq,actual_fee:m.actual_fee}),l.set(m.order_code,u)}}return{invoiceMap:l,orders:a,mappings:o}}const js=[{label:"~200 à ~600",widthMin:0,widthMax:200,lengthMin:0,lengthMax:600},{label:"~200 à ~1200",widthMin:0,widthMax:200,lengthMin:601,lengthMax:1200},{label:"~200 à 1200+",widthMin:0,widthMax:200,lengthMin:1201,lengthMax:99999},{label:"~400 à ~600",widthMin:201,widthMax:400,lengthMin:0,lengthMax:600},{label:"~400 à ~1000",widthMin:201,widthMax:400,lengthMin:601,lengthMax:1e3},{label:"~400 à 1000+",widthMin:201,widthMax:400,lengthMin:1001,lengthMax:99999},{label:"~600 à ~900",widthMin:401,widthMax:600,lengthMin:0,lengthMax:900},{label:"~600 à 900+",widthMin:401,widthMax:600,lengthMin:901,lengthMax:99999},{label:"~700 à any",widthMin:601,widthMax:700,lengthMin:0,lengthMax:99999},{label:"700+ à any",widthMin:701,widthMax:99999,lengthMin:0,lengthMax:99999}],no=[{label:"~400",min:0,max:400},{label:"401~600",min:401,max:600},{label:"601~800",min:601,max:800},{label:"801~1000",min:801,max:1e3},{label:"1001~1200",min:1001,max:1200},{label:"1200+",min:1201,max:99999}],ao=[{label:"~1200",min:0,max:1200},{label:"1201~1600",min:1201,max:1600},{label:"1601~2000",min:1601,max:2e3},{label:"2001~2400",min:2001,max:2400},{label:"2400+",min:2401,max:99999}],Ft=no.flatMap(e=>ao.map(s=>({widthLabel:e.label,lengthLabel:s.label,widthMin:e.min,widthMax:e.max,lengthMin:s.min,lengthMax:s.max}))),vs={small:"ìí",medium:"ì¤í",large:"ëí",freight:"í물"},ro=["admin","shippingCostAnalysis"];function oo(){const[e,s]=C.useState({from:Be(new Date,60),to:new Date}),{data:a=[],isLoading:n,error:r}=Ht({queryKey:[...ro,e.from?.toISOString(),e.to?.toISOString()],queryFn:async()=>{if(!e.from||!e.to)return[];const i=z(lt(e.from),"yyyy-MM-dd"),l=z(Ut(e.to),"yyyy-MM-dd"),{invoiceMap:c,orders:h,mappings:d}=await so(i,l);if(h.length===0)return[];await it();const x=ke(),m=new Map(h.map(y=>[y.id,y])),u=new Map,g=new Set;for(const y of d){const w=m.get(y.internal_order_id);if(!w)continue;const f=w.order_code;if(!c.has(f))continue;const p=!g.has(y.request_order_id);y.request_order_id&&g.add(y.request_order_id);const k=u.get(f);if(k){if(p){k.expectedFee+=y.ln_order_requests?.packaging_fee||0;const j=Tt(y.ln_order_requests?.request_data);k.woodItems.push(...j)}}else{const j=Tt(y.ln_order_requests?.request_data);u.set(f,{orderCode:f,orderDate:w.order_date,shippingCompany:w.shipping_company||"",expectedFee:y.ln_order_requests?.packaging_fee||0,woodItems:j})}}const N=[];for(const[y,w]of u){const f=c.get(y);if(!f||f.length===0)continue;const p=f.reduce((B,K)=>B+(K.actual_fee??0),0),k=f[0].carrier,j=w.woodItems.reduce((B,K)=>B+K.quantity,0),b=w.woodItems.length>0?Math.max(...w.woodItems.map(B=>Math.min(B.width,B.length))):0,_=w.woodItems.length>0?Math.max(...w.woodItems.map(B=>Math.max(B.width,B.length))):0,{totalVolumeCm3:T,totalWeightKg:$,isFreightShipping:v}=io(w.woodItems),F=v?"freight":cn(b,_),O=dn(w.woodItems.map(B=>({width:B.width,length:B.length,thickness:B.thickness,quantity:B.quantity}))),E=Math.max(1,Math.ceil($/x.weightPerUnit));let Y,R,H=!1;if(v){const B=co(w.woodItems);Y=B.tierName,H=B.isCatchAll}else R=lo(b,_,x.parcelTiers);N.push({orderCode:y,orderDate:w.orderDate,carrier:k,actualFee:p,expectedFee:w.expectedFee,recalculatedFee:O,shippingCompany:w.shippingCompany,woodItems:w.woodItems,totalQuantity:j,maxWidth:b,maxLength:_,invoiceCount:f.length,totalVolumeCm3:T,totalWeightKg:$,isFreight:v,grade:F,matchedTierName:Y,matchedParcelTierIdx:R,isCatchAll:H,unitCount:E})}return N}}),o=C.useMemo(()=>a.length===0?null:uo(a),[a]);return{dateRange:e,setDateRange:s,loading:n,error:r,matchedOrders:a,analysis:o}}function io(e){const s=ke(),{defaultDensity:a}=s;let n=0,r=0;for(const l of e){const c=parseFloat(l.thickness)||18,h=l.width||0,d=l.length||0,x=l.quantity||1;n+=h*d*c*x,r+=h*d*c*a*x}
21const o=n/1e3,i=e.length>0&&e.some(l=>{const c=Math.min(l.width,l.length),h=Math.max(l.width,l.length);return!s.parcelTiers.some(d=>c<=d.maxWidth&&h<=d.maxLength)});return{totalVolumeCm3:o,totalWeightKg:r,isFreightShipping:i}}function lo(e,s,a){const n=Math.min(e,s),r=Math.max(e,s),o=a.findIndex(i=>n<=i.maxWidth&&r<=i.maxLength);return o>=0?o:void 0}function co(e){const s=ke(),a=[...s.freightTiers].sort((c,h)=>c.priority-h.priority),n=Math.max(...s.freightTiers.map(c=>c.priority)),r=s.freightTiers.find(c=>c.priority===n);let o="미ë¶ë¥",i=-1,l=!1;for(const c of e){const h=Math.min(c.width,c.length),d=Math.max(c.width,c.length),x=h+d;let m=!1;for(const u of a)if(ho(h,d,x,u)){u.fee>i&&(i=u.fee,o=u.name),m=!0;break}m||(l=!0,r&&r.fee>i&&(i=r.fee,o=r.name))}return{tierName:o,isCatchAll:l}}function ho(e,s,a,n){return!(n.exactWidth!==void 0&&e!==n.exactWidth||n.exactLength!==void 0&&s!==n.exactLength||n.minWidth!==void 0&&e<n.minWidth||n.maxWidth!==void 0&&e>n.maxWidth||n.minLength!==void 0&&s<n.minLength||n.maxLength!==void 0&&s>n.maxLength||n.minSum!==void 0&&a<n.minSum||n.maxSum!==void 0&&a>n.maxSum)}function Tt(e){if(!e)return[];try{const a=(typeof e=="string"?JSON.parse(e):e)?.wood_items;return Array.isArray(a)?a.map(n=>({woodType:n.woodType||n.wood_type||"기í",thickness:String(n.thickness||"18"),width:Number(n.width)||0,length:Number(n.length)||0,quantity:Number(n.quantity)||1})):[]}catch{return[]}}function Lt(){return{count:0,avgActualFee:0,avgExpectedFee:0,totalActualFee:0,totalExpectedFee:0,avgDiff:0}}function It(e,s,a){e.count+=1,e.totalActualFee+=s,e.totalExpectedFee+=a}function Et(e){e.count>0&&(e.avgActualFee=Math.round(e.totalActualFee/e.count),e.avgExpectedFee=Math.round(e.totalExpectedFee/e.count),e.avgDiff=e.avgExpectedFee-e.avgActualFee)}function mo(e,s){return js.find(a=>e>=a.widthMin&&e<=a.widthMax&&s>=a.lengthMin&&s<=a.lengthMax)??null}function ws(e,s){return s<=0?e:Math.ceil(e*s/1e3)*1e3}function Ms(e){return e<=0?0:Math.ceil(e/1e3)*1e3}function xt(e,s){return s<=0||e<=0?0:Math.ceil(e/s/1e3)*1e3}function uo(e){const s=ke(),a=e.reduce((f,p)=>f+p.actualFee,0),n=e.reduce((f,p)=>f+p.recalculatedFee,0),r=[...new Set(e.map(f=>f.carrier))].sort(),o=new Map;for(const f of js){const p={};for(const k of r)p[k]=Lt();o.set(f.label,{bucket:f,byCarrier:p,total:Lt()})}for(const f of e){const p=mo(f.maxWidth,f.maxLength);if(!p)continue;const k=o.get(p.label);k&&(It(k.total,f.actualFee,f.recalculatedFee),k.byCarrier[f.carrier]&&It(k.byCarrier[f.carrier],f.actualFee,f.recalculatedFee))}const i=[];for(const f of o.values()){Et(f.total);for(const p of r)Et(f.byCarrier[p]);f.total.count>0&&i.push(f)}const l=new Map,c=["small","medium","large","freight"];for(const f of c)l.set(f,{count:0,totalActual:0,totalExpected:0});for(const f of e){const p=l.get(f.grade);p&&(p.count+=1,p.totalActual+=f.actualFee,p.totalExpected+=f.recalculatedFee)}const h=c.map(f=>{const p=l.get(f);return{grade:f,gradeLabel:vs[f],orderCount:p.count,totalActualFee:p.totalActual,totalExpectedFee:p.totalExpected,avgActualFee:p.count>0?Math.round(p.totalActual/p.count):0,avgExpectedFee:p.count>0?Math.round(p.totalExpected/p.count):0}}).filter(f=>f.orderCount>0),d=e.filter(f=>!f.isFreight),x=xo(d,s.parcelTiers),m=e.filter(f=>f.isFreight),u=fo(m,s.freightTiers),g=n-a,{sizeDistribution:N,coverageGaps:y,tierRecommendations:w}=go(m);return{totalMatchedOrders:e.length,totalActualFee:a,totalExpectedFee:n,avgActualFee:Math.round(a/e.length),avgExpectedFee:Math.round(n/e.length),overallDiff:g,overallDiffPercent:n>0?g/n*100:0,pivotTable:i,gradeAnalysis:h,parcelTierAnalysis:x,freightTierAnalysis:u,carriers:r,sizeDistribution:N,coverageGaps:y,tierRecommendations:w}}function xo(e,s){if(e.length===0||s.length===0)return[];const a=new Map;for(let n=0;n<s.length;n++)a.set(n,[]);for(const n of e)n.matchedParcelTierIdx!==void 0&&a.get(n.matchedParcelTierIdx)?.push(n);return[...a.entries()].filter(([,n])=>n.length>0).map(([n,r])=>{const o=s[n],i=Math.round(r.reduce((d,x)=>d+x.actualFee,0)/r.length),l=Math.round(r.reduce((d,x)=>d+x.recalculatedFee,0)/r.length),c=r.reduce((d,x)=>d+x.unitCount,0)/r.length,h=Math.round(c*10)/10;return{tierIdx:n,tierLabel:`~${o.maxWidth}Ã${o.maxLength}`,tierFee:o.fee,gradeLabel:vs[o.grade],orderCount:r.length,avgActualFee:i,avgRecalcFee:l,avgUnitCount:h,currentCharge:ws(o.fee,c),recommendedCharge:Ms(i),recommendedBaseFee:xt(i,c)}})}function fo(e,s){if(e.length===0||s.length===0)return[];const a=new Map;
21for(const n of s)a.set(n.name,{tierName:n.name,conditionLabel:yo(n),tierFee:n.fee,priority:n.priority,orders:[]});for(const n of e){const r=n.matchedTierName||"미ë¶ë¥",o=a.get(r);o&&o.orders.push(n)}return[...a.values()].filter(n=>n.orders.length>0).sort((n,r)=>n.priority-r.priority).map(n=>{const r=Math.round(n.orders.reduce((c,h)=>c+h.actualFee,0)/n.orders.length),o=Math.round(n.orders.reduce((c,h)=>c+h.recalculatedFee,0)/n.orders.length),i=n.orders.reduce((c,h)=>c+h.unitCount,0)/n.orders.length,l=Math.round(i*10)/10;return{tierName:n.tierName,conditionLabel:n.conditionLabel,tierFee:n.tierFee,priority:n.priority,orderCount:n.orders.length,totalActualFee:n.orders.reduce((c,h)=>c+h.actualFee,0),avgActualFee:r,avgRecalcFee:o,avgUnitCount:l,currentCharge:ws(n.tierFee,i),recommendedCharge:Ms(r),recommendedBaseFee:xt(r,i)}})}function go(e){const s=ke(),a=Math.max(...s.freightTiers.map(m=>m.priority)),n=s.freightTiers.find(m=>m.priority===a)?.fee??0,r=new Map;for(const m of Ft){const u=`${m.widthLabel}Ã${m.lengthLabel}`;r.set(u,{range:m,orders:[],tierNames:new Map})}for(const m of e){const u=Ft.find(w=>m.maxWidth>=w.widthMin&&m.maxWidth<=w.widthMax&&m.maxLength>=w.lengthMin&&m.maxLength<=w.lengthMax);if(!u)continue;const g=`${u.widthLabel}Ã${u.lengthLabel}`,N=r.get(g);if(!N)continue;N.orders.push(m);const y=m.matchedTierName||"미ë¶ë¥";N.tierNames.set(y,(N.tierNames.get(y)||0)+1)}const o=[],i=[];let l=0,c=0,h=0;for(const m of r.values()){if(m.orders.length===0)continue;const u=m.orders,g=u.map(j=>j.actualFee),N=u.filter(j=>j.isCatchAll).length,y=u.reduce((j,b)=>j+b.unitCount,0)/u.length;let w=null,f=0;for(const[j,b]of m.tierNames)b>f&&(w=j,f=b);const p=N>u.length/2,k={range:m.range,orderCount:u.length,avgActualFee:Math.round(g.reduce((j,b)=>j+b,0)/g.length),minActualFee:Math.min(...g),maxActualFee:Math.max(...g),avgUnitCount:Math.round(y*10)/10,matchedTierName:w,catchAllCount:N,isGap:p,catchAllFee:n};o.push(k),p&&(i.push(k),l+=u.length,c+=u.reduce((j,b)=>j+b.recalculatedFee,0),h+=u.reduce((j,b)=>j+b.actualFee,0))}o.sort((m,u)=>m.range.widthMin-u.range.widthMin||m.range.lengthMin-u.range.lengthMin);const d={totalGapOrders:l,totalCatchAllCost:c,totalActualCost:h,costDifference:c-h,gaps:i},x=i.filter(m=>m.orderCount>=2).map((m,u)=>{const g=xt(m.avgActualFee,m.avgUnitCount);return{range:m.range,suggestedName:`ì ê·êµ¬ê°${u+1}`,suggestedConditions:po(m.range),suggestedFee:g,orderCount:m.orderCount,avgActualFee:m.avgActualFee,avgUnitCount:m.avgUnitCount,currentCatchAllFee:n,potentialSaving:Math.round((n-g)*m.avgUnitCount*m.orderCount)}});return{sizeDistribution:o,coverageGaps:d,tierRecommendations:x}}function po(e){const s={};return e.widthMin>0&&(s.minWidth=e.widthMin),e.widthMax<99999&&(s.maxWidth=e.widthMax),e.lengthMin>0&&(s.minLength=e.lengthMin),e.lengthMax<99999&&(s.maxLength=e.lengthMax),s}function yo(e){const s=[];return e.exactWidth!==void 0&&s.push(`í=${e.exactWidth}`),e.exactLength!==void 0&&s.push(`길ì´=${e.exactLength}`),e.minWidth!==void 0&&s.push(`íâ¥${e.minWidth}`),e.maxWidth!==void 0&&s.push(`íâ¤${e.maxWidth}`),e.minLength!==void 0&&s.push(`길ì´â¥${e.minLength}`),e.maxLength!==void 0&&s.push(`길ì´â¤${e.maxLength}`),e.minSum!==void 0&&s.push(`í©â¥${e.minSum}`),e.maxSum!==void 0&&s.push(`í©â¤${e.maxSum}`),s.length>0?s.join(", "):"ì¡°ê±´ ìì (catch-all)"}function At({value:e}){if(e===0)return t.jsx("span",{className:"text-gray-400",children:"0"});const s=e>0;return t.jsxs("span",{className:L("inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium",s?"bg-blue-50 text-blue-700":"bg-red-50 text-red-700"),children:[s?t.jsx(Ie,{className:"w-3 h-3"}):t.jsx(Me,{className:"w-3 h-3"}),s?"+":"",e.toLocaleString()]})}function Pt(e,s){return s<=0?e:Math.round(e/s)}function bo({parcelTierAnalysis:e,freightTierAnalysis:s,onGoToSettings:a}){return e.length>0||s.length>0?t.jsxs("div",{className:"space-y-4",children:[t.jsx(jo,{parcelTierAnalysis:e,freightTierAnalysis:s}),e.length>0&&t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[t.jsx("div",{className:"p-4 border-b border-gray-100",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:"p-1.5 bg-indigo-50 rounded text-indigo-600",children:t.jsx(we,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"font-semibold text-gray-900",children:"ì¼ë°íë°° ë±ê¸ë³ ë¶ì"}),t.jsx("p",{className:"text-sm text-gray-500",children:"ì¬ì´ì¦ 구ê°ë³ ì¤ì ì´ì ê¸°ë° ê¸°ë³¸ìê¸ ì¶ì²"})]}),a&&t.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-md transition-colors",children:[t.jsx(xe,{className:"w-3.5 h-3.5"}),"ì¤ì ìì ìê¸ ìì "]})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm table-fixed",children:[t.jsx(Bt,{}),t.jsx("thead",{className:"bg-gray-50",children:t.jsx($t,{})}),t.jsx("tbody",{children:e.map(r=>
21t.jsxs("tr",{className:"border-t border-gray-100 hover:bg-gray-50",children:[t.jsx("td",{className:"px-3 py-2.5 font-medium text-gray-800 text-xs",children:r.tierLabel}),t.jsx("td",{className:"px-3 py-2.5 text-center",children:t.jsx(No,{label:r.gradeLabel})}),t.jsxs("td",{className:"px-3 py-2.5 text-center text-xs text-gray-600",children:[r.orderCount,"ê±´"]}),t.jsxs("td",{className:"px-3 py-2.5 text-right text-xs text-gray-500",children:[r.tierFee.toLocaleString(),"ì"]}),t.jsxs("td",{className:"px-3 py-2.5 text-right text-xs font-medium text-gray-700",children:[Pt(r.avgActualFee,r.avgUnitCount).toLocaleString(),"ì"]}),t.jsx("td",{className:"px-3 py-2.5 text-center",children:t.jsx(rt,{className:"w-3.5 h-3.5 text-gray-300 mx-auto"})}),t.jsx("td",{className:"px-3 py-2.5 text-right",children:t.jsx(qt,{current:r.tierFee,recommended:r.recommendedBaseFee})}),t.jsx("td",{className:"px-3 py-2.5 text-right",children:t.jsx(Rt,{value:r.recommendedBaseFee-r.tierFee})})]},r.tierIdx))})]})}),t.jsx(Yt,{})]}),s.length>0&&t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[t.jsx("div",{className:"p-4 border-b border-gray-100",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:"p-1.5 bg-orange-50 rounded text-orange-600",children:t.jsx(Te,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("h3",{className:"font-semibold text-gray-900",children:"í물íë°° ë±ê¸ë³ ë¶ì"}),t.jsx("p",{className:"text-sm text-gray-500",children:"í물íë°° ë±ê¸ë³ ì¤ì ì´ì ê¸°ë° ê¸°ë³¸ìê¸ ì¶ì²"})]}),a&&t.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-orange-600 bg-orange-50 hover:bg-orange-100 rounded-md transition-colors",children:[t.jsx(xe,{className:"w-3.5 h-3.5"}),"ì¤ì ìì ìê¸ ìì "]})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm table-fixed",children:[t.jsx(Bt,{}),t.jsx("thead",{className:"bg-gray-50",children:t.jsx($t,{})}),t.jsx("tbody",{children:s.map(r=>t.jsxs("tr",{className:"border-t border-gray-100 hover:bg-gray-50",children:[t.jsx("td",{className:"px-3 py-2.5 font-medium text-gray-800 text-xs",children:r.conditionLabel}),t.jsx("td",{className:"px-3 py-2.5 text-center text-xs text-gray-700",children:r.tierName}),t.jsxs("td",{className:"px-3 py-2.5 text-center text-xs text-gray-600",children:[r.orderCount,"ê±´"]}),t.jsxs("td",{className:"px-3 py-2.5 text-right text-xs text-gray-500",children:[r.tierFee.toLocaleString(),"ì"]}),t.jsxs("td",{className:"px-3 py-2.5 text-right text-xs font-medium text-gray-700",children:[Pt(r.avgActualFee,r.avgUnitCount).toLocaleString(),"ì"]}),t.jsx("td",{className:"px-3 py-2.5 text-center",children:t.jsx(rt,{className:"w-3.5 h-3.5 text-gray-300 mx-auto"})}),t.jsx("td",{className:"px-3 py-2.5 text-right",children:t.jsx(qt,{current:r.tierFee,recommended:r.recommendedBaseFee})}),t.jsx("td",{className:"px-3 py-2.5 text-right",children:t.jsx(Rt,{value:r.recommendedBaseFee-r.tierFee})})]},r.tierName))})]})}),t.jsx(Yt,{})]})]}):null}function Bt(){return t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"22%"}})," ",t.jsx("col",{style:{width:"10%"}})," ",t.jsx("col",{style:{width:"8%"}})," ",t.jsx("col",{style:{width:"13%"}})," ",t.jsx("col",{style:{width:"15%"}})," ",t.jsx("col",{style:{width:"4%"}})," ",t.jsx("col",{style:{width:"14%"}})," ",t.jsx("col",{style:{width:"14%"}})," "]})}function $t(){return t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2.5 text-left font-medium text-gray-600 text-xs",children:"ì¬ì´ì¦ ì¡°ê±´"}),t.jsx("th",{className:"px-3 py-2.5 text-center font-medium text-gray-600 text-xs",children:"ë±ê¸"}),t.jsx("th",{className:"px-3 py-2.5 text-center font-medium text-gray-600 text-xs",children:"ê±´ì"}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"íì¬ ì¤ì "}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"ê±´ë¹ ì¤ì ì´ì"}),t.jsx("th",{className:"px-3 py-2.5 text-center font-medium text-gray-600 text-xs"}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"ì¶ì² ìê¸"}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"ì°¨ì´"})]})}function Yt(){return t.jsx("div",{className:"p-3 bg-gray-50 border-t border-gray-100 text-xs text-gray-500",children:"* íì¬ ì¤ì = ì¤ì íì 기본ìê¸. ê±´ë¹ ì¤ì ì´ì = íê· ì¤ì ì´ì / íê· ê±´ì. ì¶ì² ìê¸ = ceil(ê±´ë¹ì¤ì ì´ì / 1,000) à 1,000."})}function No({label:e}){return t.jsx("span",{className:"text-xs font-medium text-gray-700",children:e})}function qt({current:e,recommended:s}){if(s===0)return t.jsx("span",{className:"text-xs text-gray-400",children:"-"});const a=e===s,n=s>e;return t.jsxs("span",{className:L("text-xs font-bold",a?"text-gray-500":n?"text-red-600":"text-blue-600"),children:[s.toLocaleStr
21ing(),"ì"]})}function Rt({value:e}){if(e===0)return t.jsx("span",{className:"text-xs text-gray-400",children:"ëì¼"});const s=e>0;return t.jsxs("span",{className:L("text-xs font-medium",s?"text-red-600":"text-blue-600"),children:[s?"â²":"â¼",Math.abs(e).toLocaleString()]})}function jo({parcelTierAnalysis:e,freightTierAnalysis:s}){const a=[...e.map(o=>({name:`ì¼ë° ${o.tierLabel}`,diff:o.recommendedBaseFee-o.tierFee,count:o.orderCount})),...s.map(o=>({name:o.tierName,diff:o.recommendedBaseFee-o.tierFee,count:o.orderCount}))].filter(o=>o.diff!==0&&o.count>=3);if(a.length===0)return null;const n=a.filter(o=>o.diff>0),r=a.filter(o=>o.diff<0);return t.jsxs("div",{className:"bg-gradient-to-r from-amber-50 to-yellow-50 border border-amber-200 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[t.jsx(es,{className:"w-4 h-4 text-amber-600 mt-0.5"}),t.jsx("h4",{className:"font-semibold text-gray-900 text-sm",children:"ìê¸ ì¡°ì ì¸ì¬ì´í¸"})]}),t.jsxs("div",{className:"space-y-2 text-sm",children:[n.length>0&&t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-red-500 font-bold text-xs mt-0.5",children:"ì¸ì ê¶ì¥"}),t.jsxs("span",{className:"text-gray-700",children:[n.map(o=>`${o.name} (+${o.diff.toLocaleString()}ì)`).join(", "),"â íì¬ ê¸°ë³¸ìê¸ì´ ì¤ì ì´ì ëë¹ ë®ì ìì¤ì´ ë°ìíê³ ììµëë¤."]})]}),r.length>0&&t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-blue-500 font-bold text-xs mt-0.5",children:"ì¸í ê°ë¥"}),t.jsxs("span",{className:"text-gray-700",children:[r.map(o=>`${o.name} (${o.diff.toLocaleString()}ì)`).join(", "),"â íì¬ ê¸°ë³¸ìê¸ì´ ì¤ì ì´ìë³´ë¤ ëì ë§ì§ì´ ììµëë¤."]})]})]})]})}function vo({sizeDistribution:e,coverageGaps:s,tierRecommendations:a,freightTierAnalysis:n,onGoToSettings:r}){if(e.length===0&&n.length===0)return null;const o=n.filter(l=>l.orderCount>=3&&l.recommendedBaseFee!==l.tierFee&&l.recommendedBaseFee>0),i=a.length>0||o.length>0;return t.jsxs("div",{className:"space-y-4",children:[s.totalGapOrders>0&&t.jsx(wo,{coverageGaps:s}),e.length>0&&t.jsx(Mo,{cells:e}),i&&t.jsx(ko,{modificationSuggestions:o,newRecommendations:a,onGoToSettings:r})]})}function wo({coverageGaps:e}){return t.jsxs("div",{className:"bg-gradient-to-r from-red-50 to-orange-50 border border-red-200 rounded-lg p-4",children:[t.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[t.jsx(Ce,{className:"w-4 h-4 text-red-500 mt-0.5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-gray-900 text-sm",children:"커ë²ë¦¬ì§ ê° ê°ì§ (í물íë°°)"}),t.jsxs("p",{className:"text-sm text-gray-600 mt-0.5",children:["íì¬ í물 ë±ê¸ ì¤ì ìì 매ì¹ëì§ ìë ì£¼ë¬¸ì´ ",t.jsxs("strong",{className:"text-red-600",children:[e.totalGapOrders,"ê±´"]})," ë°ê²¬ëììµëë¤. ì´ ì£¼ë¬¸ë¤ì catch-all(ìµê³ ìê¸ ë±ê¸)ì´ ìë ì ì©ëê³ ììµëë¤."]}),t.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"* ì¼ë°íë°°ë ë¯¸ë§¤ì¹ ì ìëì¼ë¡ íë¬¼ë¡ ì íëì´ ê°ì´ ë°ìíì§ ììµëë¤"})]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-3",children:[t.jsxs("div",{className:"bg-white/70 rounded-lg p-3",children:[t.jsx("p",{className:"text-xs text-gray-500",children:"catch-all ë¶ê³¼ ì´ì¡"}),t.jsxs("p",{className:"text-lg font-bold text-red-600",children:[e.totalCatchAllCost.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:"bg-white/70 rounded-lg p-3",children:[t.jsx("p",{className:"text-xs text-gray-500",children:"ì¤ì ì´ì ì´ì¡"}),t.jsxs("p",{className:"text-lg font-bold text-gray-800",children:[e.totalActualCost.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:"bg-white/70 rounded-lg p-3",children:[t.jsx("p",{className:"text-xs text-gray-500",children:"ì°¨ì´ (ê³¼ë¤ ì§ì)"}),t.jsxs("p",{className:L("text-lg font-bold",e.costDifference>0?"text-blue-600":"text-red-600"),children:[e.costDifference>0?"+":"",e.costDifference.toLocaleString(),"ì"]})]})]}),t.jsx("div",{className:"mt-3 space-y-1",children:e.gaps.map(s=>t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-red-400",children:"â"}),t.jsxs("span",{className:"text-gray-700",children:["í ",s.range.widthLabel," Ã ê¸¸ì´ ",s.range.lengthLabel]}),t.jsx("span",{className:"text-gray-400",children:"â"}),t.jsxs("span",{className:"text-gray-600",children:[s.orderCount,"ê±´"]}),t.jsx("span",{className:"text-gray-400",children:"|"}),t.jsxs("span",{className:"text-gray-600",children:["íê· ì¤ì ì´ì ",s.avgActualFee.toLocaleStr
21ing(),"ì"]}),t.jsx("span",{className:"text-gray-400",children:"|"}),t.jsxs("span",{className:"text-red-500 text-xs",children:["catch-all ",s.catchAllFee.toLocaleString(),"ì ì ì© ì¤"]})]},`${s.range.widthLabel}Ã${s.range.lengthLabel}`))})]})}function Mo({cells:e}){const[s,a]=C.useState(!1),n=e.filter(r=>r.isGap).length;return t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>a(r=>!r),className:"w-full p-4 flex items-center gap-2 text-left hover:bg-gray-50 transition-colors",children:[t.jsx("div",{className:"p-1.5 bg-violet-50 rounded text-violet-600",children:t.jsx(Rn,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("h3",{className:"font-semibold text-gray-900",children:"í물 ì¬ì´ì¦ë³ ì¤ì ì´ì ë¶í¬"}),t.jsxs("p",{className:"text-sm text-gray-500",children:["í물íë°° 주문ì íÃê¸¸ì´ êµ¬ê°ë³ ì¤ì ì´ì íµê³ì íì¬ ë§¤ì¹ ë±ê¸ì ë³´ì¬ì¤ëë¤",t.jsxs("span",{className:"ml-2 text-gray-400",children:["(",e.length,"ê° êµ¬ê°",n>0?`, ê° ${n}ê±´`:"",")"]})]})]}),s?t.jsx(Gn,{className:"w-5 h-5 text-gray-400 flex-shrink-0"}):t.jsx(Hn,{className:"w-5 h-5 text-gray-400 flex-shrink-0"})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-x-auto border-t border-gray-100",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-gray-50",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2.5 text-left font-medium text-gray-600 text-xs",children:"í 구ê°"}),t.jsx("th",{className:"px-3 py-2.5 text-left font-medium text-gray-600 text-xs",children:"ê¸¸ì´ êµ¬ê°"}),t.jsx("th",{className:"px-3 py-2.5 text-center font-medium text-gray-600 text-xs",children:"ê±´ì"}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"íê· ì¤ì ì´ì"}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"ìµì"}),t.jsx("th",{className:"px-3 py-2.5 text-right font-medium text-gray-600 text-xs",children:"ìµë"}),t.jsx("th",{className:"px-3 py-2.5 text-center font-medium text-gray-600 text-xs",children:"íê· ê±´ì"}),t.jsx("th",{className:"px-3 py-2.5 text-left font-medium text-gray-600 text-xs",children:"ë§¤ì¹ ë±ê¸"}),t.jsx("th",{className:"px-3 py-2.5 text-center font-medium text-gray-600 text-xs",children:"ìí"})]})}),t.jsx("tbody",{children:e.map(r=>{const o=`${r.range.widthLabel}Ã${r.range.lengthLabel}`;return t.jsxs("tr",{className:L("border-t border-gray-100 hover:bg-gray-50",r.isGap&&"bg-red-50/50"),children:[t.jsx("td",{className:"px-3 py-2.5 text-xs font-medium text-gray-800",children:r.range.widthLabel}),t.jsx("td",{className:"px-3 py-2.5 text-xs font-medium text-gray-800",children:r.range.lengthLabel}),t.jsx("td",{className:"px-3 py-2.5 text-center text-xs text-gray-600",children:r.orderCount}),t.jsxs("td",{className:"px-3 py-2.5 text-right text-xs font-medium text-gray-700",children:[r.avgActualFee.toLocaleString(),"ì"]}),t.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-gray-500",children:r.minActualFee.toLocaleString()}),t.jsx("td",{className:"px-3 py-2.5 text-right text-xs text-gray-500",children:r.maxActualFee.toLocaleString()}),t.jsx("td",{className:"px-3 py-2.5 text-center text-xs text-gray-600",children:r.avgUnitCount}),t.jsxs("td",{className:"px-3 py-2.5 text-xs",children:[r.matchedTierName?t.jsx("span",{className:"text-gray-700",children:r.matchedTierName}):t.jsx("span",{className:"text-gray-400",children:"-"}),r.catchAllCount>0&&t.jsxs("span",{className:"ml-1 text-red-500 text-[10px]",children:["(catch-all ",r.catchAllCount,"ê±´)"]})]}),t.jsx("td",{className:"px-3 py-2.5 text-center",children:r.isGap?t.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-medium text-red-600 bg-red-100 px-1.5 py-0.5 rounded",children:[t.jsx(Ce,{className:"w-3 h-3"}),"ê°"]}):t.jsx("span",{className:"text-[10px] font-medium text-green-600 bg-green-100 px-1.5 py-0.5 rounded",children:"ì ì"})})]},o)})})]})}),t.jsx("div",{className:"p-3 bg-gray-50 border-t border-gray-100 text-xs text-gray-500",children:"* í = min(ê°ë¡,ì¸ë¡), ê¸¸ì´ = max(ê°ë¡,ì¸ë¡). ê° = 주문 ê³¼ë°ì´ catch-all ì ì©. íê· ê±´ì = ceil(ì´ë¬´ê²/15kg)."})]})]})}function ko({modificationSuggestions:e,newRecommendations:s,onGoToSettings:a}){return t.jsxs("div",{className:"bg-gradient-to-r from-emerald-50 to-teal-50 border border-emerald-200 rounded-lg overflow-hidden",children:[t.jsx("div",{className:"p-4 border-b border-emerald-100",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(es,{className:"w-4 h-4 text-emerald-600 mt-0.5"}),t.jsxs("div",{children:[t.jsx("h4",{className:"font-semibold text-gray-900 text-sm",children:"ë±ê¸ ì¶ì²"}),t.jsx("p",{className:"text-sm text-gray-600",children:"ì¤ì ì´ì ë°ì´í°ë¥¼ 기ë°ì¼ë¡ 기존 ë±ê¸ ìê¸ ìì ê³¼ ì ê· ë±ê¸ ì¶ê°ë¥¼ ì¶ì²í©ëë¤."})]})]})}),t.jsxs("div",{className:"p-4 space-y-4",children:[e.length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h5",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"기존 ë±ê¸ ìê¸ ìì ê¶ì¥"}),a&&t.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-amber-700 bg-amber-100 hover:bg-amber-200 rounded-lg transition-colors",children:[t.jsx(xe,{className:"w-3.5 h-3.5"}),"ì¤ì ìì ìê¸ ìì í기"]})]}),e.map(n=>t.jsx(Co,{tier:n},n.tierName))]}),s.length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h5",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider",children:"ì ê· ë±ê¸ ì¶ê° ê¶ì¥"}),a&&t.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-emerald-700 bg-emerald-100 hover:bg-emerald-200 rounded-lg transition-colors",children:[t.jsx(xe,{className:"w-3.5 h-3.5"}),"ì¤ì ìì ë±ê¸ ì¶ê°í기"]})]}),s.map((n,r)=>t.jsx(Do,{rec:n},r))]})]})]})}function Co({tier:e}){const s=e.recommendedBaseFee-e.tierFee,a=s>0;return t.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:t.jsx("div",{className:"flex items-center justify-between",children:t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-800",children:e.tierName}),t.jsx("span",{className:"text-xs text-gray-400",children:"|"}),t.jsxs("span",{className:"text-xs text-gray-500",children:[e.orderCount,"ê±´ ë¶ì"]}),t.jsx("span",{className:"text-xs text-gray-400",children:"|"}),t.jsx("span",{className:"text-xs text-gray-500",children:e.conditionLabel})]}),t.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[t.jsx("span",{className:"text-gray-500",children:"íì¬ ìê¸"}),t.jsxs("span",{className:"font-medium text-gray-700",children:[e.tierFee.toLocaleStr
21ing(),"ì"]}),t.jsx(rt,{className:"w-3 h-3 text-gray-300"}),t.jsx("span",{className:"text-gray-500",children:"ì¶ì² ìê¸"}),t.jsxs("span",{className:L("font-bold",a?"text-red-600":"text-blue-600"),children:[e.recommendedBaseFee.toLocaleString(),"ì"]}),t.jsxs("span",{className:L("text-xs font-medium",a?"text-red-500":"text-blue-500"),children:["(",a?"â²":"â¼",Math.abs(s).toLocaleString(),"ì)"]})]}),t.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500",children:[a?t.jsx(Ie,{className:"w-3 h-3 text-red-400"}):t.jsx(Me,{className:"w-3 h-3 text-blue-400"}),t.jsxs("span",{children:["ê±´ë¹ ì¤ì ì´ì íê· ",Math.round(e.avgActualFee/e.avgUnitCount).toLocaleString(),"ì",a?" â íì¬ ìê¸ì´ ì¤ì ì´ìë³´ë¤ ë®ì ìì¤ ë°ì":" â íì¬ ìê¸ì´ ì¤ì ì´ìë³´ë¤ ëì ë§ì§ ì¬ì "]})]})]})})})}function Do({rec:e}){const s=[];return e.suggestedConditions.minWidth&&s.push(`í ⥠${e.suggestedConditions.minWidth}`),e.suggestedConditions.maxWidth&&s.push(`í ⤠${e.suggestedConditions.maxWidth}`),e.suggestedConditions.minLength&&s.push(`ê¸¸ì´ â¥ ${e.suggestedConditions.minLength}`),e.suggestedConditions.maxLength&&s.push(`ê¸¸ì´ â¤ ${e.suggestedConditions.maxLength}`),t.jsx("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-semibold text-gray-800",children:["í ",e.range.widthLabel," Ã ê¸¸ì´ ",e.range.lengthLabel]}),t.jsx("span",{className:"text-xs text-gray-400",children:"|"}),t.jsxs("span",{className:"text-xs text-gray-500",children:[e.orderCount,"ê±´ ë¶ì"]}),t.jsx("span",{className:"inline-flex items-center text-[10px] font-medium text-orange-600 bg-orange-100 px-1.5 py-0.5 rounded",children:"미ë±ë¡ 구ê°"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-1 text-xs",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"ì¶ì² ì¡°ê±´: "}),t.jsx("span",{className:"text-gray-700",children:s.join(", ")})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"íê· ì¤ì ì´ì: "}),t.jsxs("span",{className:"text-gray-700",children:[e.avgActualFee.toLocaleString(),"ì"]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"ì¶ì² 기본ìê¸: "}),t.jsxs("span",{className:"font-bold text-emerald-700",children:[e.suggestedFee.toLocaleString(),"ì"]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-gray-500",children:"íì¬ catch-all: "}),t.jsxs("span",{className:"text-red-600",children:[e.currentCatchAllFee.toLocaleString(),"ì"]})]})]}),e.potentialSaving>0&&t.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[t.jsx(Me,{className:"w-3 h-3 text-blue-500"}),t.jsxs("span",{className:"text-blue-600 font-medium",children:["ë±ê¸ ì¶ê° ì ì½ ",e.potentialSaving.toLocaleString(),"ì ê³¼ë¤ì§ì ì ê° ìì"]})]})]})})}const ks={cj:"text-blue-700",chunil:"text-green-700",kyungdong:"text-orange-700"},_o=[{label:"30ì¼",days:30},{label:"60ì¼",days:60},{label:"90ì¼",days:90}];function So({orders:e}){const[s,a]=C.useState(!1);return e.length===0?null:t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[t.jsxs("button",{className:"w-full p-4 flex items-center justify-between hover:bg-gray-50 transition-colors",onClick:()=>a(!s),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ee,{className:"w-4 h-4 text-gray-600"}),t.jsx("span",{className:"font-medium text-gray-900",children:"ìì¸ ì£¼ë¬¸ ë°ì´í°"}),t.jsxs("span",{className:"text-sm text-gray-400",children:["(",e.length,"ê±´)"]})]}),t.jsx("span",{className:"text-sm text-gray-400",children:s?"ì 기":"í¼ì¹ê¸°"})]}),s&&t.jsxs("div",{className:"overflow-x-auto max-h-[500px]",children:[t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-gray-50 sticky top-0",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-600",children:"주문ë²í¸"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium text-gray-600",children:"주문ì¼"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600",children:"íë°°ì¬"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600",children:"ìë"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600",children:"ìµë íÃ길ì´"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600",children:"목ì¬"}),t.jsx("th",{className:"px-3 py-2 text-center font-medium text-gray-600",children:"ëê»"}),t.jsx("th",{className:"px-3 py-2 text-right font-medium text-gray-600",children:"íì¬ ë¡ì§"}),t.jsx("th",{className:"px-3 py-2 text-right font-medium text-gray-600",children:"ì¤ì ì´ì"}),t.jsx("th",{className:"px-3 py-2 text-right font-medium text-gray-600",children:"ì°¨ì¡"})]})}),t.jsx("tbody",{children:e.slice(0,200).map(n=>{const r=n.recalculatedFee-n.actualFee,o=[...new Set(n.woodItems.map(l
21=>l.woodType))],i=[...new Set(n.woodItems.map(l=>l.thickness))];return t.jsxs("tr",{className:"border-t border-gray-100 hover:bg-gray-50",children:[t.jsx("td",{className:"px-3 py-1.5 font-mono text-gray-700",children:n.orderCode}),t.jsx("td",{className:"px-3 py-1.5 text-gray-500",children:n.orderDate?.slice(5,10)}),t.jsx("td",{className:L("px-3 py-1.5 text-center",ks[n.carrier]||"text-gray-600"),children:ts[n.carrier]||n.carrier}),t.jsxs("td",{className:"px-3 py-1.5 text-center",children:[n.totalQuantity,"ì¥"]}),t.jsxs("td",{className:"px-3 py-1.5 text-center text-gray-600",children:[n.maxWidth,"Ã",n.maxLength]}),t.jsx("td",{className:"px-3 py-1.5 text-center text-gray-600 max-w-[120px] truncate",children:o.join(", ")}),t.jsxs("td",{className:"px-3 py-1.5 text-center",children:[i.join("/"),"T"]}),t.jsx("td",{className:"px-3 py-1.5 text-right",children:n.recalculatedFee.toLocaleString()}),t.jsx("td",{className:"px-3 py-1.5 text-right",children:n.actualFee.toLocaleString()}),t.jsxs("td",{className:L("px-3 py-1.5 text-right font-medium",r>0?"text-blue-600":r<0?"text-red-600":"text-gray-400"),children:[r>0?"+":"",r.toLocaleString()]})]},n.orderCode)})})]}),e.length>200&&t.jsxs("div",{className:"p-3 text-center text-xs text-gray-400",children:["ìì 200ê±´ë§ íìë©ëë¤ (ì ì²´ ",e.length,"ê±´)"]})]})]})}function Oo({onGoToSettings:e}){const{dateRange:s,setDateRange:a,loading:n,error:r,matchedOrders:o,analysis:i}=oo();return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ee,{className:"w-5 h-5 text-indigo-600"}),t.jsx("h2",{className:"text-lg font-semibold",children:"ì¤ì ì´ì ë¶ì"})]}),t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg p-4 flex items-center gap-3 flex-wrap",children:[t.jsx("span",{className:"text-sm text-gray-500",children:"기ê°:"}),_o.map(l=>t.jsxs(V,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>a({from:Be(new Date,l.days),to:new Date}),children:["ìµê·¼ ",l.label]},l.days)),t.jsxs(Ne,{children:[t.jsx(je,{asChild:!0,children:t.jsxs(V,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1",children:[t.jsx(We,{className:"w-3.5 h-3.5"}),s.from?z(s.from,"yy.MM.dd",{locale:he}):"ììì¼"]})}),t.jsx(ve,{className:"w-auto p-0 bg-white",align:"start",children:t.jsx(Ae,{mode:"single",selected:s.from,onSelect:l=>l&&a(c=>({...c,from:l})),locale:he,initialFocus:!0})})]}),t.jsx("span",{className:"text-gray-400 text-xs",children:"~"}),t.jsxs(Ne,{children:[t.jsx(je,{asChild:!0,children:t.jsxs(V,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1",children:[t.jsx(We,{className:"w-3.5 h-3.5"}),s.to?z(s.to,"yy.MM.dd",{locale:he}):"ì¢
ë£ì¼"]})}),t.jsx(ve,{className:"w-auto p-0 bg-white",align:"start",children:t.jsx(Ae,{mode:"single",selected:s.to,onSelect:l=>l&&a(c=>({...c,to:l})),locale:he,initialFocus:!0,disabled:l=>s.from?l<s.from:!1})})]}),n&&t.jsx(Fe,{className:"w-4 h-4 animate-spin text-gray-400"}),t.jsxs("span",{className:"ml-auto text-sm text-gray-500",children:["ë§¤ì¹ ì£¼ë¬¸: ",t.jsxs("strong",{className:"text-indigo-600",children:[o.length,"ê±´"]})]})]}),n&&t.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-400",children:[t.jsx(Fe,{className:"w-5 h-5 mr-2 animate-spin"}),t.jsx("span",{children:"ë¶ì ë°ì´í° ë¡ë© ì¤..."})]}),!n&&r&&t.jsxs("div",{className:"text-center py-16",children:[t.jsx("div",{className:"text-red-500 mb-2",children:"ë°ì´í° ì¡°í ì¤ ì¤ë¥ê° ë°ìíìµëë¤"}),t.jsx("pre",{className:"text-xs text-gray-500 bg-gray-50 rounded p-3 inline-block max-w-lg text-left",children:r instanceof Error?r.message:JSON.stringify(r,null,2)})]}),!n&&!r&&!i&&t.jsxs("div",{className:"text-center py-16 text-gray-400",children:[t.jsx(Ee,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),t.jsx("p",{children:"매ì¹ë ì£¼ë¬¸ì´ ììµëë¤. ë°°ì¡ë¹ ì¶ì íìì ìì
ì 먼ì ì
ë¡ëíì¸ì."})]}),!n&&i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-5 gap-4",children:[t.jsx(ye,{label:"ë§¤ì¹ ì£¼ë¬¸",value:`${i.totalMatchedOrders}ê±´`}),t.jsx(ye,{label:"íì¬ë¡ì§ íê· ",value:`${i.avgExpectedFee.toLocaleStr
21ing()}ì`}),t.jsx(ye,{label:"íê· ì¤ì ì´ì",value:`${i.avgActualFee.toLocaleString()}ì`}),t.jsx(ye,{label:"íê· ì°¨ì¡",value:`${i.overallDiff>0?"+":""}${Math.round(i.overallDiff/i.totalMatchedOrders).toLocaleString()}ì`,variant:i.overallDiff>0?"positive":i.overallDiff<0?"negative":"neutral"}),t.jsx(ye,{label:"ì°¨ì¡ë¥ ",value:`${i.overallDiffPercent>0?"+":""}${i.overallDiffPercent.toFixed(1)}%`,variant:i.overallDiff>0?"positive":i.overallDiff<0?"negative":"neutral"})]}),t.jsx(vo,{sizeDistribution:i.sizeDistribution,coverageGaps:i.coverageGaps,tierRecommendations:i.tierRecommendations,freightTierAnalysis:i.freightTierAnalysis,onGoToSettings:e}),t.jsx(bo,{parcelTierAnalysis:i.parcelTierAnalysis,freightTierAnalysis:i.freightTierAnalysis,onGoToSettings:e}),t.jsx(Wo,{title:"ì¬ì´ì¦ êµ¬ê° Ã íë°°ì¬ë³ ì¤ì ì´ì",description:"목ì¬ì ìµë í(ì¢ì쪽) à ìµë ê¸¸ì´ êµ¬ê°ë³ë¡ íë°°ì¬ ì¤ì íê· ì´ìì ë¹êµí©ëë¤",icon:t.jsx(we,{className:"w-4 h-4"}),pivotTable:i.pivotTable,carriers:i.carriers}),t.jsx(So,{orders:o})]})]})}function ye({label:e,value:s,variant:a="neutral"}){return t.jsxs("div",{className:L("rounded-xl border p-4",a==="positive"&&"border-blue-200 bg-blue-50",a==="negative"&&"border-red-200 bg-red-50",a==="neutral"&&"border-gray-200 bg-white"),children:[t.jsx("p",{className:"text-sm text-gray-500",children:e}),t.jsx("p",{className:L("text-xl font-bold mt-1",a==="positive"&&"text-blue-600",a==="negative"&&"text-red-600",a==="neutral"&&"text-gray-900"),children:s})]})}function Wo({title:e,description:s,icon:a,pivotTable:n,carriers:r}){return t.jsxs("div",{className:"bg-white border border-gray-200 rounded-lg overflow-hidden",children:[t.jsx("div",{className:"p-4 border-b border-gray-100",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("div",{className:"p-1.5 bg-indigo-50 rounded text-indigo-600",children:a}),t.jsxs("div",{children:[t.jsx("h3",{className:"font-semibold text-gray-900",children:e}),t.jsx("p",{className:"text-sm text-gray-500",children:s})]})]})}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsxs("thead",{className:"bg-gray-50",children:[t.jsxs("tr",{children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium text-gray-600 whitespace-nowrap",rowSpan:2,children:"ì¬ì´ì¦ êµ¬ê° (íÃê¸¸ì´ mm)"}),t.jsx("th",{className:"px-3 py-3 text-center font-medium text-gray-600 whitespace-nowrap",rowSpan:2,children:"ê±´ì"}),r.map(o=>t.jsx("th",{className:"text-center border-l border-gray-200",colSpan:2,children:t.jsx("div",{className:L("px-3 py-2 font-medium whitespace-nowrap",ks[o]||"text-gray-600"),children:ts[o]||o})},o)),t.jsx("th",{className:"text-center border-l border-gray-200",colSpan:2,children:t.jsx("div",{className:"px-3 py-2 font-medium text-gray-700",children:"ì ì²´ íê· "})})]}),t.jsxs("tr",{className:"bg-gray-50/50",children:[r.map(o=>t.jsxs(M.Fragment,{children:[t.jsx("th",{className:"px-2 py-1 text-center text-xs text-gray-500 font-normal border-l border-gray-200",children:"ì¤ì ì´ì"}),t.jsx("th",{className:"px-2 py-1 text-center text-xs text-gray-500 font-normal",children:"ì°¨ì¡"})]},o)),t.jsx("th",{className:"px-2 py-1 text-center text-xs text-gray-500 font-normal border-l border-gray-200",children:"ì¤ì ì´ì"}),t.jsx("th",{className:"px-2 py-1 text-center text-xs text-gray-500 font-normal",children:"ì°¨ì¡"})]})]}),t.jsx("tbody",{children:n.map(o=>t.jsxs("tr",{className:"border-t border-gray-100 hover:bg-gray-50",children:[t.jsx("td",{className:"px-4 py-2.5 font-medium text-gray-800 whitespace-nowrap",children:o.bucket.label}),t.jsx("td",{className:"px-3 py-2.5 text-center text-gray-600",children:o.total.count}),r.map(i=>{const l=o.byCarrier[i];return!l||l.count===0?t.jsxs(M.Fragment,{children:[t.jsx("td",{className:"px-2 py-2.5 text-center text-gray-300 border-l border-gray-100",children:"-"}),t.jsx("td",{className:"px-2 py-2.5 text-center text-gray-300",children:"-"})]},i):t.jsxs(M.Fragment,{children:[t.jsxs("td",{className:"px-2 py-2.5 text-center whitespace-nowrap border-l border-gray-100",children:[t.jsx("span",{className:"text-gray-800",children:l.avgActualFee.toLocaleStr
21ing()}),t.jsxs("span",{className:"text-gray-400 text-xs ml-1",children:["(",l.count,")"]})]}),t.jsx("td",{className:"px-2 py-2.5 text-center",children:t.jsx(At,{value:l.avgDiff})})]},i)}),t.jsx("td",{className:"px-2 py-2.5 text-center font-medium text-gray-800 whitespace-nowrap border-l border-gray-200",children:o.total.avgActualFee.toLocaleString()}),t.jsx("td",{className:"px-2 py-2.5 text-center",children:t.jsx(At,{value:o.total.avgDiff})})]},o.bucket.label))})]})}),t.jsx("div",{className:"p-3 bg-gray-50 border-t border-gray-100 text-xs text-gray-500",children:"* ì°¨ì¡ = íì¬ë¡ì§ - ì¤ì ì´ì. ìì(íëì) = ì´ìµ, ìì(빨ê°ì) = ìì¤. ê´í¸ ì ì«ì = í´ë¹ íë°°ì¬ ê±´ì"})]})}function gi(){const[e,s]=an("tracking"),a=nn(),n=C.useCallback(()=>{a.invalidateQueries({queryKey:["admin","shippingFeeTracking"]}),a.invalidateQueries({queryKey:["admin","shippingCostAnalysis"]})},[a]);return t.jsxs("div",{className:"p-6",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[t.jsx(Te,{className:"w-8 h-8 text-blue-600"}),t.jsxs("div",{children:[t.jsx("h1",{className:"text-[22px] font-bold text-gray-900",children:"ë°°ì¡ë¹ ê´ë¦¬"}),t.jsx("p",{className:"text-sm text-gray-500",children:"ë°°ì¡ë¹ ì¶ì ë° ìì í¬ì¥ë¹ ì¤ì ì ê´ë¦¬í©ëë¤"})]})]}),t.jsxs(rn,{value:e,onValueChange:s,children:[t.jsxs(on,{className:"mb-6",children:[t.jsxs(Ze,{value:"tracking",className:"gap-2",children:[t.jsx(Te,{className:"w-4 h-4"}),"ë°°ì¡ë¹ ì¶ì "]}),t.jsxs(Ze,{value:"analysis",className:"gap-2",children:[t.jsx(Ee,{className:"w-4 h-4"}),"ì¤ì ì´ì ë¶ì"]}),t.jsxs(Ze,{value:"settings",className:"gap-2",children:[t.jsx(xe,{className:"w-4 h-4"}),"ìì í¬ì¥ë¹ ì¤ì "]})]}),t.jsx(Ve,{value:"tracking",children:t.jsx(Fo,{})}),t.jsx(Ve,{value:"analysis",children:t.jsx(Oo,{onGoToSettings:()=>s("settings")})}),t.jsx(Ve,{value:"settings",children:t.jsx(qr,{onSaved:n})})]})]})}function Fo(){const{filteredOrders:e,loading:s,searchTerm:a,setSearchTerm:n,showOnlyMatched:r,setShowOnlyMatched:o,carrierFilter:i,setCarrierFilter:l,dateRange:c,setDateRange:h,stats:d}=sa();return t.jsxs("div",{className:"space-y-6",children:[t.jsx(Tr,{dateRange:c,setDateRange:h,searchTerm:a,setSearchTerm:n,showOnlyMatched:r,setShowOnlyMatched:o,carrierFilter:i,setCarrierFilter:l}),t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"w-[145px] flex-shrink-0 bg-white rounded-xl border border-gray-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ì´ ì£¼ë¬¸"}),t.jsxs("p",{className:"text-[22px] font-bold text-gray-900",children:[d.totalOrders,"ê±´"]})]}),t.jsxs("div",{className:"w-[145px] flex-shrink-0 bg-white rounded-xl border border-gray-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ì´ì 매ì¹"}),t.jsxs("p",{className:"text-[22px] font-bold text-green-600",children:[d.matchedWithExcel,"ê±´"]})]}),t.jsxs("div",{className:"w-[145px] flex-shrink-0 bg-white rounded-xl border border-gray-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"미매ì¹"}),t.jsxs("p",{className:"text-[22px] font-bold text-gray-400",children:[d.unmatchedWithExcel,"ê±´"]})]}),t.jsxs("div",{className:"w-[145px] flex-shrink-0 rounded-xl border border-orange-200 bg-orange-50 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ë¤ê±´ ì¶ê³ "}),t.jsxs("p",{className:"text-[22px] font-bold text-orange-600",children:[d.multipleShipments,"ê±´"]})]}),t.jsxs("div",{className:"flex-1 bg-white rounded-xl border border-gray-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ê³ ê° ì²êµ¬ ë°°ì¡ë¹"}),t.jsxs("p",{className:"text-[22px] font-bold text-gray-900",children:[d.expectedFeeTotal.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:"flex-1 bg-white rounded-xl border border-gray-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"íë°°ì¬ ì´ìë¹"}),t.jsxs("p",{className:"text-[22px] font-bold text-gray-900",children:[d.actualFeeTotal.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:L("flex-1 rounded-xl border p-4",d.feeDifference>0?"border-blue-200 bg-blue-50":d.feeDifference<0?"border-red-200 bg-red-50":"bg-white border-gray-200"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ì°¨ì¡ í©ê³"}),d.feeDifference>0?t.jsx(Ie,{className:"w-4 h-4 text-blue-600"}):d.feeDifference<0?t.jsx(Me,{className:"w-4 h-4 text-red-600"}):t.jsx(jt,{className:"w-4 h-4 text-gray-400"})]}),t.jsxs("p",{className:L("text-[22px] font-bold",d.feeDifference>0?"text-blue-600":d.feeDifference<0?"text-red-600":"text-gray-900"),children:[d.feeDifference>
210?"+":"",d.feeDifference.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:L("flex-1 rounded-xl border p-4",d.differencePercent>0?"border-blue-200 bg-blue-50":d.differencePercent<0?"border-red-200 bg-red-50":"bg-white border-gray-200"),children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ì°¨ì¡ë¥ "}),t.jsxs("p",{className:L("text-[22px] font-bold",d.differencePercent>0?"text-blue-600":d.differencePercent<0?"text-red-600":"text-gray-900"),children:[d.differencePercent>0?"+":"",d.differencePercent.toFixed(1),"%"]})]})]}),d.currentLogicMatchedCount>0&&t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"w-[145px] flex-shrink-0 bg-emerald-50 rounded-xl border border-emerald-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ë¡ì§ ì ì©"}),t.jsxs("p",{className:"text-[22px] font-bold text-emerald-700",children:[d.currentLogicMatchedCount,"ê±´"]})]}),t.jsxs("div",{className:"flex-1 bg-emerald-50 rounded-xl border border-emerald-200 p-4",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"íì¬ ë¡ì§ ë°°ì¡ë¹"}),t.jsxs("p",{className:"text-[22px] font-bold text-emerald-700",children:[d.currentLogicFeeTotal.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:L("flex-1 rounded-xl border p-4",d.currentLogicDifference>0?"border-blue-200 bg-blue-50":d.currentLogicDifference<0?"border-red-200 bg-red-50":"bg-emerald-50 border-emerald-200"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ë¡ì§ ì°¨ì¡"}),d.currentLogicDifference>0?t.jsx(Ie,{className:"w-4 h-4 text-blue-600"}):d.currentLogicDifference<0?t.jsx(Me,{className:"w-4 h-4 text-red-600"}):t.jsx(jt,{className:"w-4 h-4 text-gray-400"})]}),t.jsxs("p",{className:L("text-[22px] font-bold",d.currentLogicDifference>0?"text-blue-600":d.currentLogicDifference<0?"text-red-600":"text-gray-900"),children:[d.currentLogicDifference>0?"+":"",d.currentLogicDifference.toLocaleString(),"ì"]})]}),t.jsxs("div",{className:L("flex-1 rounded-xl border p-4",d.currentLogicDiffPercent>0?"border-blue-200 bg-blue-50":d.currentLogicDiffPercent<0?"border-red-200 bg-red-50":"bg-emerald-50 border-emerald-200"),children:[t.jsx("p",{className:"text-sm text-gray-500",children:"ë¡ì§ ì°¨ì¡ë¥ "}),t.jsxs("p",{className:L("text-[22px] font-bold",d.currentLogicDiffPercent>0?"text-blue-600":d.currentLogicDiffPercent<0?"text-red-600":"text-gray-900"),children:[d.currentLogicDiffPercent>0?"+":"",d.currentLogicDiffPercent.toFixed(1),"%"]})]})]}),t.jsx(Pr,{filteredOrders:e,loading:s})]})}export{gi as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.